Skip to content

Commit

Permalink
fix: crypto
Browse files Browse the repository at this point in the history
  • Loading branch information
jamalavedra committed Dec 31, 2024
1 parent d2a3635 commit 7fd1768
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfort/openfort-js",
"version": "0.8.15",
"version": "0.8.16",
"author": "Openfort (https://www.openfort.xyz)",
"bugs": "https://github.com/openfort-xyz/openfort-js/issues",
"repository": "openfort-xyz/openfort-js.git",
Expand Down
14 changes: 13 additions & 1 deletion sdk/src/authManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ export default class AuthManager {
return this.refreshTokens(authentication.refreshToken, forceRefresh);
}

if (crypto.subtle) {
const webCrypto = AuthManager.getWebCrypto();
if (webCrypto?.subtle) {
return this.validateCredentialsWithCrypto(jwk, authentication);
}

Expand Down Expand Up @@ -666,6 +667,17 @@ export default class AuthManager {
return authPlayerResponse.data;
}

private static getWebCrypto(): { subtle?: SubtleCrypto } | null {
if (isBrowser()) {
return window.crypto;
}
// Node.js environment
if (typeof global !== 'undefined' && (global as any).crypto) {
return (global as any).crypto;
}
return null;
}

public async linkEmail(
email: string,
password: string,
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const VERSION = '0.8.15';
export const VERSION = '0.8.16';
export const PACKAGE = '@openfort/openfort-js';

0 comments on commit 7fd1768

Please sign in to comment.