From 3bf60ecfc682ce40501211c4e48fd076bd91db19 Mon Sep 17 00:00:00 2001 From: gllm-dev Date: Tue, 16 Jul 2024 17:45:38 +0200 Subject: [PATCH 1/2] fix: encryption session --- CHANGELOG.md | 4 ++++ examples/apps/auth-sample/package.json | 2 +- packages/platform-bridge/package.json | 2 +- sdk/package.json | 2 +- sdk/src/config/config.ts | 3 --- sdk/src/iframe/iframeManager.ts | 2 +- sdk/src/iframe/types.ts | 2 ++ sdk/src/openfort.ts | 2 +- sdk/src/signer/embedded.signer.ts | 5 +++++ sdk/src/version.ts | 2 +- yarn.lock | 4 ++-- 11 files changed, 19 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbdd329..47a84fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.7.17] - 2024-07-16 +### Fixed +- Encrypt session support + ## [0.7.17] - 2024-07-15 ### Added - Added encryption session support diff --git a/examples/apps/auth-sample/package.json b/examples/apps/auth-sample/package.json index 1430808..4614f60 100644 --- a/examples/apps/auth-sample/package.json +++ b/examples/apps/auth-sample/package.json @@ -9,7 +9,7 @@ }, "dependencies": { "@heroicons/react": "^2.0.13", - "@openfort/openfort-js": "0.7.17", + "@openfort/openfort-js": "0.7.18", "@openfort/openfort-node": "^0.6.47", "@radix-ui/react-toast": "^1.1.2", "@rainbow-me/rainbowkit": "^2.1.1", diff --git a/packages/platform-bridge/package.json b/packages/platform-bridge/package.json index d52726c..3ce19d56 100644 --- a/packages/platform-bridge/package.json +++ b/packages/platform-bridge/package.json @@ -2,7 +2,7 @@ "name": "@openfort/platform-bridge", "version": "0.0.0", "dependencies": { - "@openfort/openfort-js": "0.7.17", + "@openfort/openfort-js": "0.7.18", "ethers": "^5.7.0" }, "devDependencies": { diff --git a/sdk/package.json b/sdk/package.json index 884054c..3713ff1 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@openfort/openfort-js", - "version": "0.7.17", + "version": "0.7.18", "author": "Openfort (https://www.openfort.xyz)", "bugs": "https://github.com/openfort-xyz/openfort-js/issues", "repository": "openfort-xyz/openfort-js.git", diff --git a/sdk/src/config/config.ts b/sdk/src/config/config.ts index 4e61033..50cb28d 100644 --- a/sdk/src/config/config.ts +++ b/sdk/src/config/config.ts @@ -14,8 +14,6 @@ export class ShieldConfiguration { readonly shieldEncryptionKey?: string; - readonly shieldEncryptionSession?: string; - readonly debug?: boolean = false; constructor(options: { @@ -26,7 +24,6 @@ export class ShieldConfiguration { }) { this.shieldPublishableKey = options.shieldPublishableKey; this.shieldEncryptionKey = options.shieldEncryptionKey; - this.shieldEncryptionSession = options.shieldEncryptionSession; this.debug = options.shieldDebug || false; } } diff --git a/sdk/src/iframe/iframeManager.ts b/sdk/src/iframe/iframeManager.ts index b1bbaff..304368e 100644 --- a/sdk/src/iframe/iframeManager.ts +++ b/sdk/src/iframe/iframeManager.ts @@ -193,7 +193,7 @@ export default class IframeManager { thirdPartyTokenType: iframeConfiguration.thirdPartyTokenType, encryptionKey: password ?? null, encryptionPart: this.sdkConfiguration?.shieldConfiguration?.shieldEncryptionKey ?? null, - encryptionSession: this.sdkConfiguration?.shieldConfiguration?.shieldEncryptionSession ?? null, + encryptionSession: iframeConfiguration.recovery?.encryptionSession ?? null, openfortURL: this.sdkConfiguration.backendUrl, shieldURL: this.sdkConfiguration.shieldUrl, }; diff --git a/sdk/src/iframe/types.ts b/sdk/src/iframe/types.ts index 7d1d3b8..54f2d81 100644 --- a/sdk/src/iframe/types.ts +++ b/sdk/src/iframe/types.ts @@ -390,6 +390,8 @@ export interface ShieldAuthentication { authProvider?: string; // When using a third party auth provider, the token type tokenType?: string; + // When using encryption sessions, the session ID + encryptionSession?: string } export enum ShieldAuthType { diff --git a/sdk/src/openfort.ts b/sdk/src/openfort.ts index 29349e5..d32546b 100644 --- a/sdk/src/openfort.ts +++ b/sdk/src/openfort.ts @@ -185,7 +185,7 @@ export class Openfort { try { const signer = this.newEmbeddedSigner(chainId); - await signer.ensureEmbeddedAccount(recoveryPassword); + await signer.ensureEmbeddedAccount(shieldAuthentication?.encryptionSession, recoveryPassword); this.signer = signer; this.instanceManager.setSignerType(SignerType.EMBEDDED); } catch (e) { diff --git a/sdk/src/signer/embedded.signer.ts b/sdk/src/signer/embedded.signer.ts index 94a4a97..93f73cf 100644 --- a/sdk/src/signer/embedded.signer.ts +++ b/sdk/src/signer/embedded.signer.ts @@ -46,6 +46,7 @@ export class EmbeddedSigner implements ISigner { } public async ensureEmbeddedAccount( + encryptionSession?: string, recoveryPassword?: string, ): Promise { const playerID = this.instanceManager.getPlayerID(); @@ -56,6 +57,10 @@ export class EmbeddedSigner implements ISigner { return currentUser; } + if (encryptionSession && this.iframeConfiguration.recovery) { + this.iframeConfiguration.recovery.encryptionSession = encryptionSession; + } + currentUser = await this.iframeManager.configure(this.iframeConfiguration, recoveryPassword); if (!currentUser.accountType || !currentUser.chainId || !currentUser.address || !currentUser.deviceID) { diff --git a/sdk/src/version.ts b/sdk/src/version.ts index 1d12507..e084ca5 100644 --- a/sdk/src/version.ts +++ b/sdk/src/version.ts @@ -1,2 +1,2 @@ -export const VERSION = '0.7.17'; +export const VERSION = '0.7.18'; export const PACKAGE = '@openfort/openfort-js'; diff --git a/yarn.lock b/yarn.lock index 1f87c97..32e7f91 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1403,7 +1403,7 @@ __metadata: languageName: unknown linkType: soft -"@openfort/openfort-js@0.7.17, @openfort/openfort-js@workspace:sdk": +"@openfort/openfort-js@0.7.18, @openfort/openfort-js@workspace:sdk": version: 0.0.0-use.local resolution: "@openfort/openfort-js@workspace:sdk" dependencies: @@ -1458,7 +1458,7 @@ __metadata: version: 0.0.0-use.local resolution: "@openfort/platform-bridge@workspace:packages/platform-bridge" dependencies: - "@openfort/openfort-js": 0.7.17 + "@openfort/openfort-js": 0.7.18 eslint: ^8.40.0 ethers: ^5.7.0 parcel: ^2.8.3 From 6f25124da45411652c18520eae4bdda17e5c8786 Mon Sep 17 00:00:00 2001 From: gllm-dev Date: Tue, 16 Jul 2024 17:46:42 +0200 Subject: [PATCH 2/2] fix: encryption session --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47a84fc..f685961 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.7.17] - 2024-07-16 +## [0.7.18] - 2024-07-16 ### Fixed - Encrypt session support