Skip to content

Commit

Permalink
Merge pull request #9 from openfort-xyz/fix/check-recovery
Browse files Browse the repository at this point in the history
fix: recovery check for embedded
  • Loading branch information
gllm-dev authored Mar 12, 2024
2 parents a4b7a20 + 846e7fd commit 7430388
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfort/openfort-js",
"version": "0.5.6",
"version": "0.5.7",
"description": "",
"author": "Openfort",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/openfort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class Openfort {
this._signer = signer;

const loaded = await signer.isLoaded();
if (loaded) {
if (!loaded) {
throw new MissingRecoveryMethod(
"This device has not been configured, in order to recover your account or create a new one you must provide recovery method",
);
Expand Down
12 changes: 11 additions & 1 deletion src/signer/embedded.signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,17 @@ export class EmbeddedSigner implements ISigner {
}

async isLoaded(): Promise<boolean> {
return this._deviceID !== null || (await this._iframeClient.getCurrentDevice()) !== "";
if (this._deviceID) {
return true;
}

const localStorageDevice = await this._iframeClient.getCurrentDevice();
if (localStorageDevice) {
this._deviceID = localStorageDevice;
return true;
}

return false
}

iFrameLoaded(): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const VERSION = "0.5.5";
export const VERSION = "0.5.7";
export const PACKAGE = "@openfort/openfort-js";

0 comments on commit 7430388

Please sign in to comment.