Skip to content

Commit

Permalink
Merge pull request #43 from openfort-xyz/fix/encryption-session
Browse files Browse the repository at this point in the history
fix: encryption session
  • Loading branch information
gllm-dev authored Jul 16, 2024
2 parents b13cdaa + 6f25124 commit e6e7eb7
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.18] - 2024-07-16
### Fixed
- Encrypt session support

## [0.7.17] - 2024-07-15
### Added
- Added encryption session support
Expand Down
2 changes: 1 addition & 1 deletion examples/apps/auth-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/platform-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
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.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",
Expand Down
3 changes: 0 additions & 3 deletions sdk/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ export class ShieldConfiguration {

readonly shieldEncryptionKey?: string;

readonly shieldEncryptionSession?: string;

readonly debug?: boolean = false;

constructor(options: {
Expand All @@ -26,7 +24,6 @@ export class ShieldConfiguration {
}) {
this.shieldPublishableKey = options.shieldPublishableKey;
this.shieldEncryptionKey = options.shieldEncryptionKey;
this.shieldEncryptionSession = options.shieldEncryptionSession;
this.debug = options.shieldDebug || false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/iframe/iframeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 2 additions & 0 deletions sdk/src/iframe/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/openfort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions sdk/src/signer/embedded.signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class EmbeddedSigner implements ISigner {
}

public async ensureEmbeddedAccount(
encryptionSession?: string,
recoveryPassword?: string,
): Promise<GetCurrentDeviceResponse> {
const playerID = this.instanceManager.getPlayerID();
Expand All @@ -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) {
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.7.17';
export const VERSION = '0.7.18';
export const PACKAGE = '@openfort/openfort-js';
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e6e7eb7

Please sign in to comment.