@openfort/openfort-js 0.8.21 → 0.8.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +197 -143
- package/dist/index.d.ts +38 -56
- package/dist/index.js +194 -144
- package/package.json +1 -2
package/dist/index.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var hash = require('@ethersproject/hash');
|
|
6
5
|
var globalAxios = require('axios');
|
|
6
|
+
var hash = require('@ethersproject/hash');
|
|
7
7
|
var secp256k1 = require('@noble/curves/secp256k1');
|
|
8
8
|
var signingKey = require('@ethersproject/signing-key');
|
|
9
9
|
var bytes = require('@ethersproject/bytes');
|
|
@@ -344,6 +344,37 @@ const AccountsApiAxiosParamCreator = function (configuration) {
|
|
|
344
344
|
options: localVarRequestOptions,
|
|
345
345
|
};
|
|
346
346
|
},
|
|
347
|
+
/**
|
|
348
|
+
*
|
|
349
|
+
* @param {string} id
|
|
350
|
+
* @param {*} [options] Override http request option.
|
|
351
|
+
* @throws {RequiredError}
|
|
352
|
+
*/
|
|
353
|
+
disableAccount: async (id, options = {}) => {
|
|
354
|
+
// verify required parameter 'id' is not null or undefined
|
|
355
|
+
assertParamExists('disableAccount', 'id', id);
|
|
356
|
+
const localVarPath = `/v1/accounts/{id}/disable`
|
|
357
|
+
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
|
|
358
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
359
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
360
|
+
let baseOptions;
|
|
361
|
+
if (configuration) {
|
|
362
|
+
baseOptions = configuration.baseOptions;
|
|
363
|
+
}
|
|
364
|
+
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
|
|
365
|
+
const localVarHeaderParameter = {};
|
|
366
|
+
const localVarQueryParameter = {};
|
|
367
|
+
// authentication sk required
|
|
368
|
+
// http bearer authentication required
|
|
369
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
370
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
371
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
372
|
+
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
|
|
373
|
+
return {
|
|
374
|
+
url: toPathString(localVarUrlObj),
|
|
375
|
+
options: localVarRequestOptions,
|
|
376
|
+
};
|
|
377
|
+
},
|
|
347
378
|
/**
|
|
348
379
|
* Retrieves the details of an existing account. Supply the unique account ID from either a account creation request or the account list, and Openfort will return the corresponding account information. Returns the latest 10 transaction intents created by this account.
|
|
349
380
|
* @summary Get existing account.
|
|
@@ -629,6 +660,16 @@ const AccountsApiFp = function (configuration) {
|
|
|
629
660
|
const localVarAxiosArgs = await localVarAxiosParamCreator.deployAccount(id, deployRequest, options);
|
|
630
661
|
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
631
662
|
},
|
|
663
|
+
/**
|
|
664
|
+
*
|
|
665
|
+
* @param {string} id
|
|
666
|
+
* @param {*} [options] Override http request option.
|
|
667
|
+
* @throws {RequiredError}
|
|
668
|
+
*/
|
|
669
|
+
async disableAccount(id, options) {
|
|
670
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.disableAccount(id, options);
|
|
671
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
672
|
+
},
|
|
632
673
|
/**
|
|
633
674
|
* Retrieves the details of an existing account. Supply the unique account ID from either a account creation request or the account list, and Openfort will return the corresponding account information. Returns the latest 10 transaction intents created by this account.
|
|
634
675
|
* @summary Get existing account.
|
|
@@ -756,6 +797,16 @@ class AccountsApi extends BaseAPI {
|
|
|
756
797
|
deployAccount(requestParameters, options) {
|
|
757
798
|
return AccountsApiFp(this.configuration).deployAccount(requestParameters.id, requestParameters.deployRequest, options).then((request) => request(this.axios, this.basePath));
|
|
758
799
|
}
|
|
800
|
+
/**
|
|
801
|
+
*
|
|
802
|
+
* @param {AccountsApiDisableAccountRequest} requestParameters Request parameters.
|
|
803
|
+
* @param {*} [options] Override http request option.
|
|
804
|
+
* @throws {RequiredError}
|
|
805
|
+
* @memberof AccountsApi
|
|
806
|
+
*/
|
|
807
|
+
disableAccount(requestParameters, options) {
|
|
808
|
+
return AccountsApiFp(this.configuration).disableAccount(requestParameters.id, options).then((request) => request(this.axios, this.basePath));
|
|
809
|
+
}
|
|
759
810
|
/**
|
|
760
811
|
* Retrieves the details of an existing account. Supply the unique account ID from either a account creation request or the account list, and Openfort will return the corresponding account information. Returns the latest 10 transaction intents created by this account.
|
|
761
812
|
* @summary Get existing account.
|
|
@@ -3266,6 +3317,108 @@ const createConfig = ({ basePath, accessToken, }) => {
|
|
|
3266
3317
|
return new Configuration$1(apiConfigOptions);
|
|
3267
3318
|
};
|
|
3268
3319
|
|
|
3320
|
+
exports.EmbeddedState = void 0;
|
|
3321
|
+
(function (EmbeddedState) {
|
|
3322
|
+
EmbeddedState[EmbeddedState["NONE"] = 0] = "NONE";
|
|
3323
|
+
EmbeddedState[EmbeddedState["UNAUTHENTICATED"] = 1] = "UNAUTHENTICATED";
|
|
3324
|
+
EmbeddedState[EmbeddedState["EMBEDDED_SIGNER_NOT_CONFIGURED"] = 2] = "EMBEDDED_SIGNER_NOT_CONFIGURED";
|
|
3325
|
+
EmbeddedState[EmbeddedState["CREATING_ACCOUNT"] = 3] = "CREATING_ACCOUNT";
|
|
3326
|
+
EmbeddedState[EmbeddedState["READY"] = 4] = "READY";
|
|
3327
|
+
})(exports.EmbeddedState || (exports.EmbeddedState = {}));
|
|
3328
|
+
var OpenfortEvents;
|
|
3329
|
+
(function (OpenfortEvents) {
|
|
3330
|
+
OpenfortEvents["LOGGED_OUT"] = "loggedOut";
|
|
3331
|
+
})(OpenfortEvents || (OpenfortEvents = {}));
|
|
3332
|
+
exports.RecoveryMethod = void 0;
|
|
3333
|
+
(function (RecoveryMethod) {
|
|
3334
|
+
RecoveryMethod["PASSWORD"] = "password";
|
|
3335
|
+
RecoveryMethod["AUTOMATIC"] = "automatic";
|
|
3336
|
+
})(exports.RecoveryMethod || (exports.RecoveryMethod = {}));
|
|
3337
|
+
var AccountType;
|
|
3338
|
+
(function (AccountType) {
|
|
3339
|
+
AccountType["UPGRADEABLE_V4"] = "Upgradeable_v04";
|
|
3340
|
+
AccountType["MANAGED_V4"] = "Managed_v04";
|
|
3341
|
+
AccountType["ERC6551_V4"] = "ERC6551_v04";
|
|
3342
|
+
AccountType["ERC6551_V5"] = "ERC6551_v05";
|
|
3343
|
+
AccountType["RECOVERABLE_V4"] = "Recoverable_v04";
|
|
3344
|
+
AccountType["MANAGED_V5"] = "Managed_v05";
|
|
3345
|
+
AccountType["UPGRADEABLE_V5"] = "Upgradeable_v05";
|
|
3346
|
+
AccountType["UPGRADEABLE_V6"] = "Upgradeable_v06";
|
|
3347
|
+
AccountType["ZKSYNC_UPGRADEABLE_V1"] = "zksync_upgradeable_v1";
|
|
3348
|
+
AccountType["ZKSYNC_UPGRADEABLE_V2"] = "zksync_upgradeable_v2";
|
|
3349
|
+
})(AccountType || (AccountType = {}));
|
|
3350
|
+
exports.AuthType = void 0;
|
|
3351
|
+
(function (AuthType) {
|
|
3352
|
+
AuthType["OPENFORT"] = "openfort";
|
|
3353
|
+
AuthType["THIRD_PARTY"] = "thirdParty";
|
|
3354
|
+
})(exports.AuthType || (exports.AuthType = {}));
|
|
3355
|
+
exports.TokenType = void 0;
|
|
3356
|
+
(function (TokenType) {
|
|
3357
|
+
TokenType["ID_TOKEN"] = "idToken";
|
|
3358
|
+
TokenType["CUSTOM_TOKEN"] = "customToken";
|
|
3359
|
+
})(exports.TokenType || (exports.TokenType = {}));
|
|
3360
|
+
exports.ThirdPartyOAuthProvider = void 0;
|
|
3361
|
+
(function (ThirdPartyOAuthProvider) {
|
|
3362
|
+
ThirdPartyOAuthProvider["ACCELBYTE"] = "accelbyte";
|
|
3363
|
+
ThirdPartyOAuthProvider["FIREBASE"] = "firebase";
|
|
3364
|
+
ThirdPartyOAuthProvider["LOOTLOCKER"] = "lootlocker";
|
|
3365
|
+
ThirdPartyOAuthProvider["PLAYFAB"] = "playfab";
|
|
3366
|
+
ThirdPartyOAuthProvider["SUPABASE"] = "supabase";
|
|
3367
|
+
ThirdPartyOAuthProvider["CUSTOM"] = "custom";
|
|
3368
|
+
ThirdPartyOAuthProvider["OIDC"] = "oidc";
|
|
3369
|
+
ThirdPartyOAuthProvider["TELEGRAM_MINI_APP"] = "telegramMiniApp";
|
|
3370
|
+
})(exports.ThirdPartyOAuthProvider || (exports.ThirdPartyOAuthProvider = {}));
|
|
3371
|
+
exports.BasicAuthProvider = void 0;
|
|
3372
|
+
(function (BasicAuthProvider) {
|
|
3373
|
+
BasicAuthProvider["EMAIL"] = "email";
|
|
3374
|
+
BasicAuthProvider["WALLET"] = "wallet";
|
|
3375
|
+
})(exports.BasicAuthProvider || (exports.BasicAuthProvider = {}));
|
|
3376
|
+
exports.OAuthProvider = void 0;
|
|
3377
|
+
(function (OAuthProvider) {
|
|
3378
|
+
OAuthProvider["GOOGLE"] = "google";
|
|
3379
|
+
OAuthProvider["TWITTER"] = "twitter";
|
|
3380
|
+
OAuthProvider["FACEBOOK"] = "facebook";
|
|
3381
|
+
OAuthProvider["DISCORD"] = "discord";
|
|
3382
|
+
OAuthProvider["EPIC_GAMES"] = "epic_games";
|
|
3383
|
+
OAuthProvider["TELEGRAM"] = "telegram";
|
|
3384
|
+
OAuthProvider["LINE"] = "line";
|
|
3385
|
+
})(exports.OAuthProvider || (exports.OAuthProvider = {}));
|
|
3386
|
+
var CodeChallengeMethodEnum;
|
|
3387
|
+
(function (CodeChallengeMethodEnum) {
|
|
3388
|
+
CodeChallengeMethodEnum["PLAIN"] = "plain";
|
|
3389
|
+
CodeChallengeMethodEnum["S256"] = "S256";
|
|
3390
|
+
})(CodeChallengeMethodEnum || (CodeChallengeMethodEnum = {}));
|
|
3391
|
+
|
|
3392
|
+
const getSignedTypedData = async (typedData, accountType, chainId, signer, evmAddress) => {
|
|
3393
|
+
// Ethers auto-generates the EIP712Domain type in the TypedDataEncoder, and so it needs to be removed
|
|
3394
|
+
const types = { ...typedData.types };
|
|
3395
|
+
// @ts-ignore
|
|
3396
|
+
delete types.EIP712Domain;
|
|
3397
|
+
// Hash the EIP712 payload and generate the complete payload
|
|
3398
|
+
let typedDataHash = hash._TypedDataEncoder.hash(typedData.domain, types, typedData.message);
|
|
3399
|
+
if ([AccountType.UPGRADEABLE_V5,
|
|
3400
|
+
AccountType.UPGRADEABLE_V6,
|
|
3401
|
+
AccountType.ZKSYNC_UPGRADEABLE_V1,
|
|
3402
|
+
AccountType.ZKSYNC_UPGRADEABLE_V2].includes(accountType)) {
|
|
3403
|
+
const updatedDomain = {
|
|
3404
|
+
name: 'Openfort',
|
|
3405
|
+
version: '0.5',
|
|
3406
|
+
chainId: Number(chainId),
|
|
3407
|
+
verifyingContract: evmAddress,
|
|
3408
|
+
};
|
|
3409
|
+
const updatedTypes = {
|
|
3410
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3411
|
+
OpenfortMessage: [{ name: 'hashedMessage', type: 'bytes32' }],
|
|
3412
|
+
};
|
|
3413
|
+
const updatedMessage = {
|
|
3414
|
+
hashedMessage: typedDataHash,
|
|
3415
|
+
};
|
|
3416
|
+
typedDataHash = hash._TypedDataEncoder.hash(updatedDomain, updatedTypes, updatedMessage);
|
|
3417
|
+
}
|
|
3418
|
+
const ethsigNoType = await signer.sign(typedDataHash, false, false);
|
|
3419
|
+
return ethsigNoType;
|
|
3420
|
+
};
|
|
3421
|
+
|
|
3269
3422
|
var StorageKeys;
|
|
3270
3423
|
(function (StorageKeys) {
|
|
3271
3424
|
StorageKeys["AUTHENTICATION"] = "openfort.authentication";
|
|
@@ -3339,7 +3492,7 @@ class KeyPair extends signingKey.SigningKey {
|
|
|
3339
3492
|
}
|
|
3340
3493
|
}
|
|
3341
3494
|
|
|
3342
|
-
const VERSION = '0.8.
|
|
3495
|
+
const VERSION = '0.8.22';
|
|
3343
3496
|
|
|
3344
3497
|
var Event;
|
|
3345
3498
|
(function (Event) {
|
|
@@ -3613,9 +3766,11 @@ class NotConfiguredError extends Error {
|
|
|
3613
3766
|
class IframeManager {
|
|
3614
3767
|
iframe;
|
|
3615
3768
|
responses = new Map();
|
|
3769
|
+
storage;
|
|
3616
3770
|
sdkConfiguration;
|
|
3617
3771
|
constructor(configuration) {
|
|
3618
3772
|
this.sdkConfiguration = configuration;
|
|
3773
|
+
this.storage = new LocalStorage();
|
|
3619
3774
|
}
|
|
3620
3775
|
async iframeSetup() {
|
|
3621
3776
|
if (window.addEventListener) {
|
|
@@ -3711,7 +3866,6 @@ class IframeManager {
|
|
|
3711
3866
|
if (response) {
|
|
3712
3867
|
clearInterval(interval);
|
|
3713
3868
|
this.responses.delete(uuid);
|
|
3714
|
-
// @ts-ignore
|
|
3715
3869
|
const responseConstructor = this.responseConstructors[response.action];
|
|
3716
3870
|
if (isErrorResponse(response)) {
|
|
3717
3871
|
if (response.error === NOT_CONFIGURED_ERROR) {
|
|
@@ -3761,7 +3915,16 @@ class IframeManager {
|
|
|
3761
3915
|
shieldURL: this.sdkConfiguration.shieldUrl,
|
|
3762
3916
|
};
|
|
3763
3917
|
this.iframe?.contentWindow?.postMessage(config, '*');
|
|
3764
|
-
|
|
3918
|
+
let response;
|
|
3919
|
+
try {
|
|
3920
|
+
response = await this.waitForResponse(config.uuid);
|
|
3921
|
+
}
|
|
3922
|
+
catch (e) {
|
|
3923
|
+
if (e instanceof WrongRecoveryPasswordError || e instanceof MissingRecoveryPasswordError) {
|
|
3924
|
+
this.storage.remove(StorageKeys.SIGNER);
|
|
3925
|
+
}
|
|
3926
|
+
throw e;
|
|
3927
|
+
}
|
|
3765
3928
|
sessionStorage.setItem('iframe-version', response.version ?? 'undefined');
|
|
3766
3929
|
return response;
|
|
3767
3930
|
}
|
|
@@ -3808,7 +3971,6 @@ class IframeManager {
|
|
|
3808
3971
|
response = await this.waitForResponse(uuid);
|
|
3809
3972
|
}
|
|
3810
3973
|
catch (e) {
|
|
3811
|
-
console.log('switchChain', e);
|
|
3812
3974
|
if (e instanceof NotConfiguredError) {
|
|
3813
3975
|
await this.configure(iframeConfiguration);
|
|
3814
3976
|
return this.switchChain(iframeConfiguration, chainId);
|
|
@@ -4109,7 +4271,6 @@ class EmbeddedSigner {
|
|
|
4109
4271
|
const deviceAccount = await this.iframeManager
|
|
4110
4272
|
.switchChain(this.iframeConfiguration, chainId);
|
|
4111
4273
|
new Account(deviceAccount.accountType, deviceAccount.address, deviceAccount.chainId, deviceAccount.ownerAddress).save(this.storage);
|
|
4112
|
-
SignerManager.storage.save(StorageKeys.SIGNER, JSON.stringify(deviceAccount));
|
|
4113
4274
|
}
|
|
4114
4275
|
async setEmbeddedRecovery({ recoveryMethod, recoveryPassword, encryptionSession }) {
|
|
4115
4276
|
await this.iframeManager
|
|
@@ -4296,8 +4457,8 @@ class SignerManager {
|
|
|
4296
4457
|
type: 'embedded',
|
|
4297
4458
|
chainId,
|
|
4298
4459
|
};
|
|
4299
|
-
SignerManager.storage.save(StorageKeys.SIGNER, JSON.stringify(signerConfiguration));
|
|
4300
4460
|
const resp = await iframeManager.configure(iframeConfiguration);
|
|
4461
|
+
SignerManager.storage.save(StorageKeys.SIGNER, JSON.stringify(signerConfiguration));
|
|
4301
4462
|
new Account(resp.accountType, resp.address, resp.chainId, resp.ownerAddress).save(this.storage);
|
|
4302
4463
|
return new EmbeddedSigner(iframeManager, iframeConfiguration, this.storage);
|
|
4303
4464
|
}
|
|
@@ -4327,78 +4488,6 @@ class SignerManager {
|
|
|
4327
4488
|
}
|
|
4328
4489
|
}
|
|
4329
4490
|
|
|
4330
|
-
exports.EmbeddedState = void 0;
|
|
4331
|
-
(function (EmbeddedState) {
|
|
4332
|
-
EmbeddedState[EmbeddedState["NONE"] = 0] = "NONE";
|
|
4333
|
-
EmbeddedState[EmbeddedState["UNAUTHENTICATED"] = 1] = "UNAUTHENTICATED";
|
|
4334
|
-
EmbeddedState[EmbeddedState["EMBEDDED_SIGNER_NOT_CONFIGURED"] = 2] = "EMBEDDED_SIGNER_NOT_CONFIGURED";
|
|
4335
|
-
EmbeddedState[EmbeddedState["CREATING_ACCOUNT"] = 3] = "CREATING_ACCOUNT";
|
|
4336
|
-
EmbeddedState[EmbeddedState["READY"] = 4] = "READY";
|
|
4337
|
-
})(exports.EmbeddedState || (exports.EmbeddedState = {}));
|
|
4338
|
-
var OpenfortEvents;
|
|
4339
|
-
(function (OpenfortEvents) {
|
|
4340
|
-
OpenfortEvents["LOGGED_OUT"] = "loggedOut";
|
|
4341
|
-
})(OpenfortEvents || (OpenfortEvents = {}));
|
|
4342
|
-
exports.RecoveryMethod = void 0;
|
|
4343
|
-
(function (RecoveryMethod) {
|
|
4344
|
-
RecoveryMethod["PASSWORD"] = "password";
|
|
4345
|
-
RecoveryMethod["AUTOMATIC"] = "automatic";
|
|
4346
|
-
})(exports.RecoveryMethod || (exports.RecoveryMethod = {}));
|
|
4347
|
-
var AccountType;
|
|
4348
|
-
(function (AccountType) {
|
|
4349
|
-
AccountType["UPGRADEABLE_V4"] = "Upgradeable_v04";
|
|
4350
|
-
AccountType["MANAGED_V4"] = "Managed_v04";
|
|
4351
|
-
AccountType["ERC6551_V4"] = "ERC6551_v04";
|
|
4352
|
-
AccountType["ERC6551_V5"] = "ERC6551_v05";
|
|
4353
|
-
AccountType["RECOVERABLE_V4"] = "Recoverable_v04";
|
|
4354
|
-
AccountType["MANAGED_V5"] = "Managed_v05";
|
|
4355
|
-
AccountType["UPGRADEABLE_V5"] = "Upgradeable_v05";
|
|
4356
|
-
AccountType["UPGRADEABLE_V6"] = "Upgradeable_v06";
|
|
4357
|
-
AccountType["ZKSYNC_UPGRADEABLE_V1"] = "zksync_upgradeable_v1";
|
|
4358
|
-
AccountType["ZKSYNC_UPGRADEABLE_V2"] = "zksync_upgradeable_v2";
|
|
4359
|
-
})(AccountType || (AccountType = {}));
|
|
4360
|
-
exports.AuthType = void 0;
|
|
4361
|
-
(function (AuthType) {
|
|
4362
|
-
AuthType["OPENFORT"] = "openfort";
|
|
4363
|
-
AuthType["THIRD_PARTY"] = "thirdParty";
|
|
4364
|
-
})(exports.AuthType || (exports.AuthType = {}));
|
|
4365
|
-
exports.TokenType = void 0;
|
|
4366
|
-
(function (TokenType) {
|
|
4367
|
-
TokenType["ID_TOKEN"] = "idToken";
|
|
4368
|
-
TokenType["CUSTOM_TOKEN"] = "customToken";
|
|
4369
|
-
})(exports.TokenType || (exports.TokenType = {}));
|
|
4370
|
-
exports.ThirdPartyOAuthProvider = void 0;
|
|
4371
|
-
(function (ThirdPartyOAuthProvider) {
|
|
4372
|
-
ThirdPartyOAuthProvider["ACCELBYTE"] = "accelbyte";
|
|
4373
|
-
ThirdPartyOAuthProvider["FIREBASE"] = "firebase";
|
|
4374
|
-
ThirdPartyOAuthProvider["LOOTLOCKER"] = "lootlocker";
|
|
4375
|
-
ThirdPartyOAuthProvider["PLAYFAB"] = "playfab";
|
|
4376
|
-
ThirdPartyOAuthProvider["SUPABASE"] = "supabase";
|
|
4377
|
-
ThirdPartyOAuthProvider["CUSTOM"] = "custom";
|
|
4378
|
-
ThirdPartyOAuthProvider["OIDC"] = "oidc";
|
|
4379
|
-
ThirdPartyOAuthProvider["TELEGRAM_MINI_APP"] = "telegramMiniApp";
|
|
4380
|
-
})(exports.ThirdPartyOAuthProvider || (exports.ThirdPartyOAuthProvider = {}));
|
|
4381
|
-
exports.BasicAuthProvider = void 0;
|
|
4382
|
-
(function (BasicAuthProvider) {
|
|
4383
|
-
BasicAuthProvider["EMAIL"] = "email";
|
|
4384
|
-
BasicAuthProvider["WALLET"] = "wallet";
|
|
4385
|
-
})(exports.BasicAuthProvider || (exports.BasicAuthProvider = {}));
|
|
4386
|
-
exports.OAuthProvider = void 0;
|
|
4387
|
-
(function (OAuthProvider) {
|
|
4388
|
-
OAuthProvider["GOOGLE"] = "google";
|
|
4389
|
-
OAuthProvider["TWITTER"] = "twitter";
|
|
4390
|
-
OAuthProvider["FACEBOOK"] = "facebook";
|
|
4391
|
-
OAuthProvider["DISCORD"] = "discord";
|
|
4392
|
-
OAuthProvider["EPIC_GAMES"] = "epic_games";
|
|
4393
|
-
OAuthProvider["TELEGRAM"] = "telegram";
|
|
4394
|
-
OAuthProvider["LINE"] = "line";
|
|
4395
|
-
})(exports.OAuthProvider || (exports.OAuthProvider = {}));
|
|
4396
|
-
var CodeChallengeMethodEnum;
|
|
4397
|
-
(function (CodeChallengeMethodEnum) {
|
|
4398
|
-
CodeChallengeMethodEnum["PLAIN"] = "plain";
|
|
4399
|
-
CodeChallengeMethodEnum["S256"] = "S256";
|
|
4400
|
-
})(CodeChallengeMethodEnum || (CodeChallengeMethodEnum = {}));
|
|
4401
|
-
|
|
4402
4491
|
const KEY_PKCE_STATE = 'pkce_state';
|
|
4403
4492
|
const KEY_PKCE_VERIFIER = 'pkce_verifier';
|
|
4404
4493
|
class DeviceCredentialsManager {
|
|
@@ -5051,34 +5140,6 @@ const sendTransaction = async ({ params, signer, account, authentication, backen
|
|
|
5051
5140
|
return response.transactionHash;
|
|
5052
5141
|
};
|
|
5053
5142
|
|
|
5054
|
-
const getSignedTypedData = async (typedData, accountType, chainId, signer, evmAddress) => {
|
|
5055
|
-
// Ethers auto-generates the EIP712Domain type in the TypedDataEncoder, and so it needs to be removed
|
|
5056
|
-
const types = { ...typedData.types };
|
|
5057
|
-
// @ts-ignore
|
|
5058
|
-
delete types.EIP712Domain;
|
|
5059
|
-
// Hash the EIP712 payload and generate the complete payload
|
|
5060
|
-
let typedDataHash = hash._TypedDataEncoder.hash(typedData.domain, types, typedData.message);
|
|
5061
|
-
if (accountType === AccountType.UPGRADEABLE_V5) {
|
|
5062
|
-
const updatedDomain = {
|
|
5063
|
-
name: 'Openfort',
|
|
5064
|
-
version: '0.5',
|
|
5065
|
-
chainId: Number(chainId),
|
|
5066
|
-
verifyingContract: evmAddress,
|
|
5067
|
-
};
|
|
5068
|
-
const updatedTypes = {
|
|
5069
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
5070
|
-
OpenfortMessage: [{ name: 'hashedMessage', type: 'bytes32' }],
|
|
5071
|
-
};
|
|
5072
|
-
const updatedMessage = {
|
|
5073
|
-
hashedMessage: typedDataHash,
|
|
5074
|
-
};
|
|
5075
|
-
typedDataHash = hash._TypedDataEncoder.hash(updatedDomain, updatedTypes, updatedMessage);
|
|
5076
|
-
// primaryType: "OpenfortMessage"
|
|
5077
|
-
}
|
|
5078
|
-
const ethsigNoType = await signer.sign(typedDataHash, false, false);
|
|
5079
|
-
return ethsigNoType;
|
|
5080
|
-
};
|
|
5081
|
-
|
|
5082
5143
|
const REQUIRED_TYPED_DATA_PROPERTIES = ['types', 'domain', 'primaryType', 'message'];
|
|
5083
5144
|
const isValidTypedDataPayload = (typedData) => (REQUIRED_TYPED_DATA_PROPERTIES.every((key) => key in typedData));
|
|
5084
5145
|
const transformTypedData = (typedData, chainId) => {
|
|
@@ -6957,7 +7018,6 @@ class EvmProvider {
|
|
|
6957
7018
|
throw new JsonRpcError(ProviderErrorCode.UNAUTHORIZED, 'Unauthorized - call eth_requestAccounts first');
|
|
6958
7019
|
}
|
|
6959
7020
|
this.#validateAndRefreshSession();
|
|
6960
|
-
console.log(`eth_sendTransaction ${this.#policyId}`);
|
|
6961
7021
|
return await sendTransaction({
|
|
6962
7022
|
params: request.params || [],
|
|
6963
7023
|
signer,
|
|
@@ -7286,7 +7346,12 @@ class Openfort {
|
|
|
7286
7346
|
* @returns A Provider instance.
|
|
7287
7347
|
* @throws {OpenfortError} If the signer is not an EmbeddedSigner.
|
|
7288
7348
|
*/
|
|
7289
|
-
getEthereumProvider(options
|
|
7349
|
+
getEthereumProvider(options) {
|
|
7350
|
+
// Apply default options with proper type safety
|
|
7351
|
+
const defaultOptions = {
|
|
7352
|
+
announceProvider: true,
|
|
7353
|
+
};
|
|
7354
|
+
const finalOptions = { ...defaultOptions, ...options };
|
|
7290
7355
|
const authentication = Authentication.fromStorage(this.storage);
|
|
7291
7356
|
const signer = SignerManager.fromStorage();
|
|
7292
7357
|
const account = Account.fromStorage(this.storage);
|
|
@@ -7298,16 +7363,18 @@ class Openfort {
|
|
|
7298
7363
|
account: account || undefined,
|
|
7299
7364
|
authentication: authentication || undefined,
|
|
7300
7365
|
backendApiClients: this.backendApiClients,
|
|
7301
|
-
policyId:
|
|
7366
|
+
policyId: finalOptions.policy,
|
|
7302
7367
|
validateAndRefreshSession: this.validateAndRefreshToken.bind(this),
|
|
7303
7368
|
});
|
|
7304
|
-
announceProvider
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7369
|
+
if (finalOptions.announceProvider) {
|
|
7370
|
+
announceProvider({
|
|
7371
|
+
info: { ...openfortProviderInfo, ...finalOptions.providerInfo },
|
|
7372
|
+
provider: this.provider,
|
|
7373
|
+
});
|
|
7374
|
+
}
|
|
7308
7375
|
}
|
|
7309
|
-
else if (this.provider &&
|
|
7310
|
-
this.provider.updatePolicy(
|
|
7376
|
+
else if (this.provider && finalOptions.policy) {
|
|
7377
|
+
this.provider.updatePolicy(finalOptions.policy);
|
|
7311
7378
|
}
|
|
7312
7379
|
return this.provider;
|
|
7313
7380
|
}
|
|
@@ -7378,37 +7445,18 @@ class Openfort {
|
|
|
7378
7445
|
* @returns The signature.
|
|
7379
7446
|
* @throws {OpenfortError} If no signer is configured.
|
|
7380
7447
|
*/
|
|
7381
|
-
async signTypedData(domain, types,
|
|
7448
|
+
async signTypedData(domain, types, message) {
|
|
7382
7449
|
await this.validateAndRefreshToken();
|
|
7383
7450
|
const signer = SignerManager.fromStorage();
|
|
7384
|
-
if (!signer) {
|
|
7385
|
-
throw new OpenfortError('No signer configured', exports.OpenfortErrorType.MISSING_SIGNER_ERROR);
|
|
7386
|
-
}
|
|
7387
|
-
let hash$1 = hash._TypedDataEncoder.hash(domain, types, value);
|
|
7388
|
-
// eslint-disable-next-line no-param-reassign
|
|
7389
|
-
delete types.EIP712Domain;
|
|
7390
7451
|
const account = Account.fromStorage(this.storage);
|
|
7391
|
-
if (account
|
|
7392
|
-
|
|
7393
|
-
AccountType.ZKSYNC_UPGRADEABLE_V1,
|
|
7394
|
-
AccountType.ZKSYNC_UPGRADEABLE_V2].includes(account.type)) {
|
|
7395
|
-
const updatedDomain = {
|
|
7396
|
-
name: 'Openfort',
|
|
7397
|
-
version: '0.5',
|
|
7398
|
-
chainId: Number(account.chainId),
|
|
7399
|
-
verifyingContract: account.address ?? undefined,
|
|
7400
|
-
};
|
|
7401
|
-
const updatedTypes = {
|
|
7402
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7403
|
-
OpenfortMessage: [{ name: 'hashedMessage', type: 'bytes32' }],
|
|
7404
|
-
};
|
|
7405
|
-
const updatedMessage = {
|
|
7406
|
-
hashedMessage: hash$1,
|
|
7407
|
-
};
|
|
7408
|
-
hash$1 = hash._TypedDataEncoder.hash(updatedDomain, updatedTypes, updatedMessage);
|
|
7409
|
-
// primaryType: "OpenfortMessage"
|
|
7452
|
+
if (!signer || !account) {
|
|
7453
|
+
throw new OpenfortError('No signer configured', exports.OpenfortErrorType.MISSING_SIGNER_ERROR);
|
|
7410
7454
|
}
|
|
7411
|
-
return await
|
|
7455
|
+
return await getSignedTypedData({
|
|
7456
|
+
domain,
|
|
7457
|
+
types,
|
|
7458
|
+
message,
|
|
7459
|
+
}, account.type, Number(account.chainId), signer, account.address);
|
|
7412
7460
|
}
|
|
7413
7461
|
/**
|
|
7414
7462
|
* Exports the private key.
|
|
@@ -7855,6 +7903,8 @@ class Openfort {
|
|
|
7855
7903
|
if (!credentials.player) {
|
|
7856
7904
|
throw new OpenfortError('No player found in credentials', exports.OpenfortErrorType.INTERNAL_ERROR);
|
|
7857
7905
|
}
|
|
7906
|
+
if (credentials.accessToken === auth.token)
|
|
7907
|
+
return;
|
|
7858
7908
|
new Authentication('jwt', credentials.accessToken, credentials.player, credentials.refreshToken).save(this.storage);
|
|
7859
7909
|
const signer = SignerManager.fromStorage();
|
|
7860
7910
|
try {
|
|
@@ -7920,8 +7970,12 @@ class SDKConfiguration {
|
|
|
7920
7970
|
}
|
|
7921
7971
|
}
|
|
7922
7972
|
|
|
7973
|
+
exports.MissingProjectEntropyError = MissingProjectEntropyError;
|
|
7974
|
+
exports.MissingRecoveryPasswordError = MissingRecoveryPasswordError;
|
|
7975
|
+
exports.NotConfiguredError = NotConfiguredError;
|
|
7923
7976
|
exports.OpenfortConfiguration = OpenfortConfiguration;
|
|
7924
7977
|
exports.OpenfortError = OpenfortError;
|
|
7925
7978
|
exports.SDKConfiguration = SDKConfiguration;
|
|
7926
7979
|
exports.ShieldConfiguration = ShieldConfiguration;
|
|
7980
|
+
exports.WrongRecoveryPasswordError = WrongRecoveryPasswordError;
|
|
7927
7981
|
exports.default = Openfort;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,57 +1,3 @@
|
|
|
1
|
-
declare type Bytes = ArrayLike<number>;
|
|
2
|
-
declare type BytesLike = Bytes | string;
|
|
3
|
-
interface Hexable {
|
|
4
|
-
toHexString(): string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare type BigNumberish = BigNumber | Bytes | bigint | string | number;
|
|
8
|
-
declare class BigNumber implements Hexable {
|
|
9
|
-
readonly _hex: string;
|
|
10
|
-
readonly _isBigNumber: boolean;
|
|
11
|
-
constructor(constructorGuard: any, hex: string);
|
|
12
|
-
fromTwos(value: number): BigNumber;
|
|
13
|
-
toTwos(value: number): BigNumber;
|
|
14
|
-
abs(): BigNumber;
|
|
15
|
-
add(other: BigNumberish): BigNumber;
|
|
16
|
-
sub(other: BigNumberish): BigNumber;
|
|
17
|
-
div(other: BigNumberish): BigNumber;
|
|
18
|
-
mul(other: BigNumberish): BigNumber;
|
|
19
|
-
mod(other: BigNumberish): BigNumber;
|
|
20
|
-
pow(other: BigNumberish): BigNumber;
|
|
21
|
-
and(other: BigNumberish): BigNumber;
|
|
22
|
-
or(other: BigNumberish): BigNumber;
|
|
23
|
-
xor(other: BigNumberish): BigNumber;
|
|
24
|
-
mask(value: number): BigNumber;
|
|
25
|
-
shl(value: number): BigNumber;
|
|
26
|
-
shr(value: number): BigNumber;
|
|
27
|
-
eq(other: BigNumberish): boolean;
|
|
28
|
-
lt(other: BigNumberish): boolean;
|
|
29
|
-
lte(other: BigNumberish): boolean;
|
|
30
|
-
gt(other: BigNumberish): boolean;
|
|
31
|
-
gte(other: BigNumberish): boolean;
|
|
32
|
-
isNegative(): boolean;
|
|
33
|
-
isZero(): boolean;
|
|
34
|
-
toNumber(): number;
|
|
35
|
-
toBigInt(): bigint;
|
|
36
|
-
toString(): string;
|
|
37
|
-
toHexString(): string;
|
|
38
|
-
toJSON(key?: string): any;
|
|
39
|
-
static from(value: any): BigNumber;
|
|
40
|
-
static isBigNumber(value: any): value is BigNumber;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface TypedDataDomain {
|
|
44
|
-
name?: string;
|
|
45
|
-
version?: string;
|
|
46
|
-
chainId?: BigNumberish;
|
|
47
|
-
verifyingContract?: string;
|
|
48
|
-
salt?: BytesLike;
|
|
49
|
-
}
|
|
50
|
-
interface TypedDataField {
|
|
51
|
-
name: string;
|
|
52
|
-
type: string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
1
|
interface ShieldAuthentication {
|
|
56
2
|
auth: ShieldAuthType;
|
|
57
3
|
token: string;
|
|
@@ -550,6 +496,28 @@ declare class JsonRpcError extends Error {
|
|
|
550
496
|
constructor(code: ProviderErrorCode | RpcErrorCode, message: string);
|
|
551
497
|
}
|
|
552
498
|
|
|
499
|
+
interface TypedDataPayload {
|
|
500
|
+
types: {
|
|
501
|
+
[K in string]: Array<{
|
|
502
|
+
name: string;
|
|
503
|
+
type: string;
|
|
504
|
+
}>;
|
|
505
|
+
} & {
|
|
506
|
+
EIP712Domain?: Array<{
|
|
507
|
+
name: string;
|
|
508
|
+
type: string;
|
|
509
|
+
}>;
|
|
510
|
+
};
|
|
511
|
+
domain: {
|
|
512
|
+
name?: string;
|
|
513
|
+
version?: string;
|
|
514
|
+
chainId?: number;
|
|
515
|
+
verifyingContract?: string;
|
|
516
|
+
salt?: string;
|
|
517
|
+
};
|
|
518
|
+
primaryType: string;
|
|
519
|
+
message: Record<string, any>;
|
|
520
|
+
}
|
|
553
521
|
interface RequestArguments {
|
|
554
522
|
method: string;
|
|
555
523
|
params?: Array<any>;
|
|
@@ -598,6 +566,7 @@ declare class Openfort {
|
|
|
598
566
|
name: string;
|
|
599
567
|
rdns: string;
|
|
600
568
|
};
|
|
569
|
+
announceProvider?: boolean;
|
|
601
570
|
}): Provider;
|
|
602
571
|
/**
|
|
603
572
|
* Configures a session key and returns the session key details.
|
|
@@ -634,7 +603,7 @@ declare class Openfort {
|
|
|
634
603
|
* @returns The signature.
|
|
635
604
|
* @throws {OpenfortError} If no signer is configured.
|
|
636
605
|
*/
|
|
637
|
-
signTypedData(domain:
|
|
606
|
+
signTypedData(domain: TypedDataPayload['domain'], types: TypedDataPayload['types'], message: TypedDataPayload['message']): Promise<string>;
|
|
638
607
|
/**
|
|
639
608
|
* Exports the private key.
|
|
640
609
|
*
|
|
@@ -976,4 +945,17 @@ interface ShieldAuthOptions {
|
|
|
976
945
|
apiSecret?: string;
|
|
977
946
|
}
|
|
978
947
|
|
|
979
|
-
|
|
948
|
+
declare class MissingRecoveryPasswordError extends Error {
|
|
949
|
+
constructor();
|
|
950
|
+
}
|
|
951
|
+
declare class MissingProjectEntropyError extends Error {
|
|
952
|
+
constructor();
|
|
953
|
+
}
|
|
954
|
+
declare class WrongRecoveryPasswordError extends Error {
|
|
955
|
+
constructor();
|
|
956
|
+
}
|
|
957
|
+
declare class NotConfiguredError extends Error {
|
|
958
|
+
constructor();
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
export { AuthPlayerResponse, AuthType, BasicAuthProvider, EmbeddedState, InitializeOAuthOptions, MissingProjectEntropyError, MissingRecoveryPasswordError, NotConfiguredError, OAuthProvider, OpenfortConfiguration, OpenfortError, OpenfortErrorType, Provider, RecoveryMethod, SDKConfiguration, SDKOverrides, SessionResponse, ShieldAuthOptions, ShieldAuthType, ShieldAuthentication, ShieldConfiguration, ShieldOptions, ThirdPartyOAuthProvider, TokenType, TransactionIntentResponse, TypedDataPayload, WrongRecoveryPasswordError, Openfort as default };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { hashMessage, _TypedDataEncoder } from '@ethersproject/hash';
|
|
2
1
|
import globalAxios, { isAxiosError } from 'axios';
|
|
2
|
+
import { _TypedDataEncoder, hashMessage } from '@ethersproject/hash';
|
|
3
3
|
import { secp256k1 } from '@noble/curves/secp256k1';
|
|
4
4
|
import { SigningKey } from '@ethersproject/signing-key';
|
|
5
5
|
import { joinSignature, arrayify, hexlify } from '@ethersproject/bytes';
|
|
@@ -321,6 +321,37 @@ const AccountsApiAxiosParamCreator = function (configuration) {
|
|
|
321
321
|
options: localVarRequestOptions,
|
|
322
322
|
};
|
|
323
323
|
},
|
|
324
|
+
/**
|
|
325
|
+
*
|
|
326
|
+
* @param {string} id
|
|
327
|
+
* @param {*} [options] Override http request option.
|
|
328
|
+
* @throws {RequiredError}
|
|
329
|
+
*/
|
|
330
|
+
disableAccount: async (id, options = {}) => {
|
|
331
|
+
// verify required parameter 'id' is not null or undefined
|
|
332
|
+
assertParamExists('disableAccount', 'id', id);
|
|
333
|
+
const localVarPath = `/v1/accounts/{id}/disable`
|
|
334
|
+
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
|
|
335
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
336
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
337
|
+
let baseOptions;
|
|
338
|
+
if (configuration) {
|
|
339
|
+
baseOptions = configuration.baseOptions;
|
|
340
|
+
}
|
|
341
|
+
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
|
|
342
|
+
const localVarHeaderParameter = {};
|
|
343
|
+
const localVarQueryParameter = {};
|
|
344
|
+
// authentication sk required
|
|
345
|
+
// http bearer authentication required
|
|
346
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
347
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
348
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
349
|
+
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
|
|
350
|
+
return {
|
|
351
|
+
url: toPathString(localVarUrlObj),
|
|
352
|
+
options: localVarRequestOptions,
|
|
353
|
+
};
|
|
354
|
+
},
|
|
324
355
|
/**
|
|
325
356
|
* Retrieves the details of an existing account. Supply the unique account ID from either a account creation request or the account list, and Openfort will return the corresponding account information. Returns the latest 10 transaction intents created by this account.
|
|
326
357
|
* @summary Get existing account.
|
|
@@ -606,6 +637,16 @@ const AccountsApiFp = function (configuration) {
|
|
|
606
637
|
const localVarAxiosArgs = await localVarAxiosParamCreator.deployAccount(id, deployRequest, options);
|
|
607
638
|
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
608
639
|
},
|
|
640
|
+
/**
|
|
641
|
+
*
|
|
642
|
+
* @param {string} id
|
|
643
|
+
* @param {*} [options] Override http request option.
|
|
644
|
+
* @throws {RequiredError}
|
|
645
|
+
*/
|
|
646
|
+
async disableAccount(id, options) {
|
|
647
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.disableAccount(id, options);
|
|
648
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
649
|
+
},
|
|
609
650
|
/**
|
|
610
651
|
* Retrieves the details of an existing account. Supply the unique account ID from either a account creation request or the account list, and Openfort will return the corresponding account information. Returns the latest 10 transaction intents created by this account.
|
|
611
652
|
* @summary Get existing account.
|
|
@@ -733,6 +774,16 @@ class AccountsApi extends BaseAPI {
|
|
|
733
774
|
deployAccount(requestParameters, options) {
|
|
734
775
|
return AccountsApiFp(this.configuration).deployAccount(requestParameters.id, requestParameters.deployRequest, options).then((request) => request(this.axios, this.basePath));
|
|
735
776
|
}
|
|
777
|
+
/**
|
|
778
|
+
*
|
|
779
|
+
* @param {AccountsApiDisableAccountRequest} requestParameters Request parameters.
|
|
780
|
+
* @param {*} [options] Override http request option.
|
|
781
|
+
* @throws {RequiredError}
|
|
782
|
+
* @memberof AccountsApi
|
|
783
|
+
*/
|
|
784
|
+
disableAccount(requestParameters, options) {
|
|
785
|
+
return AccountsApiFp(this.configuration).disableAccount(requestParameters.id, options).then((request) => request(this.axios, this.basePath));
|
|
786
|
+
}
|
|
736
787
|
/**
|
|
737
788
|
* Retrieves the details of an existing account. Supply the unique account ID from either a account creation request or the account list, and Openfort will return the corresponding account information. Returns the latest 10 transaction intents created by this account.
|
|
738
789
|
* @summary Get existing account.
|
|
@@ -3243,6 +3294,108 @@ const createConfig = ({ basePath, accessToken, }) => {
|
|
|
3243
3294
|
return new Configuration$1(apiConfigOptions);
|
|
3244
3295
|
};
|
|
3245
3296
|
|
|
3297
|
+
var EmbeddedState;
|
|
3298
|
+
(function (EmbeddedState) {
|
|
3299
|
+
EmbeddedState[EmbeddedState["NONE"] = 0] = "NONE";
|
|
3300
|
+
EmbeddedState[EmbeddedState["UNAUTHENTICATED"] = 1] = "UNAUTHENTICATED";
|
|
3301
|
+
EmbeddedState[EmbeddedState["EMBEDDED_SIGNER_NOT_CONFIGURED"] = 2] = "EMBEDDED_SIGNER_NOT_CONFIGURED";
|
|
3302
|
+
EmbeddedState[EmbeddedState["CREATING_ACCOUNT"] = 3] = "CREATING_ACCOUNT";
|
|
3303
|
+
EmbeddedState[EmbeddedState["READY"] = 4] = "READY";
|
|
3304
|
+
})(EmbeddedState || (EmbeddedState = {}));
|
|
3305
|
+
var OpenfortEvents;
|
|
3306
|
+
(function (OpenfortEvents) {
|
|
3307
|
+
OpenfortEvents["LOGGED_OUT"] = "loggedOut";
|
|
3308
|
+
})(OpenfortEvents || (OpenfortEvents = {}));
|
|
3309
|
+
var RecoveryMethod;
|
|
3310
|
+
(function (RecoveryMethod) {
|
|
3311
|
+
RecoveryMethod["PASSWORD"] = "password";
|
|
3312
|
+
RecoveryMethod["AUTOMATIC"] = "automatic";
|
|
3313
|
+
})(RecoveryMethod || (RecoveryMethod = {}));
|
|
3314
|
+
var AccountType;
|
|
3315
|
+
(function (AccountType) {
|
|
3316
|
+
AccountType["UPGRADEABLE_V4"] = "Upgradeable_v04";
|
|
3317
|
+
AccountType["MANAGED_V4"] = "Managed_v04";
|
|
3318
|
+
AccountType["ERC6551_V4"] = "ERC6551_v04";
|
|
3319
|
+
AccountType["ERC6551_V5"] = "ERC6551_v05";
|
|
3320
|
+
AccountType["RECOVERABLE_V4"] = "Recoverable_v04";
|
|
3321
|
+
AccountType["MANAGED_V5"] = "Managed_v05";
|
|
3322
|
+
AccountType["UPGRADEABLE_V5"] = "Upgradeable_v05";
|
|
3323
|
+
AccountType["UPGRADEABLE_V6"] = "Upgradeable_v06";
|
|
3324
|
+
AccountType["ZKSYNC_UPGRADEABLE_V1"] = "zksync_upgradeable_v1";
|
|
3325
|
+
AccountType["ZKSYNC_UPGRADEABLE_V2"] = "zksync_upgradeable_v2";
|
|
3326
|
+
})(AccountType || (AccountType = {}));
|
|
3327
|
+
var AuthType;
|
|
3328
|
+
(function (AuthType) {
|
|
3329
|
+
AuthType["OPENFORT"] = "openfort";
|
|
3330
|
+
AuthType["THIRD_PARTY"] = "thirdParty";
|
|
3331
|
+
})(AuthType || (AuthType = {}));
|
|
3332
|
+
var TokenType;
|
|
3333
|
+
(function (TokenType) {
|
|
3334
|
+
TokenType["ID_TOKEN"] = "idToken";
|
|
3335
|
+
TokenType["CUSTOM_TOKEN"] = "customToken";
|
|
3336
|
+
})(TokenType || (TokenType = {}));
|
|
3337
|
+
var ThirdPartyOAuthProvider;
|
|
3338
|
+
(function (ThirdPartyOAuthProvider) {
|
|
3339
|
+
ThirdPartyOAuthProvider["ACCELBYTE"] = "accelbyte";
|
|
3340
|
+
ThirdPartyOAuthProvider["FIREBASE"] = "firebase";
|
|
3341
|
+
ThirdPartyOAuthProvider["LOOTLOCKER"] = "lootlocker";
|
|
3342
|
+
ThirdPartyOAuthProvider["PLAYFAB"] = "playfab";
|
|
3343
|
+
ThirdPartyOAuthProvider["SUPABASE"] = "supabase";
|
|
3344
|
+
ThirdPartyOAuthProvider["CUSTOM"] = "custom";
|
|
3345
|
+
ThirdPartyOAuthProvider["OIDC"] = "oidc";
|
|
3346
|
+
ThirdPartyOAuthProvider["TELEGRAM_MINI_APP"] = "telegramMiniApp";
|
|
3347
|
+
})(ThirdPartyOAuthProvider || (ThirdPartyOAuthProvider = {}));
|
|
3348
|
+
var BasicAuthProvider;
|
|
3349
|
+
(function (BasicAuthProvider) {
|
|
3350
|
+
BasicAuthProvider["EMAIL"] = "email";
|
|
3351
|
+
BasicAuthProvider["WALLET"] = "wallet";
|
|
3352
|
+
})(BasicAuthProvider || (BasicAuthProvider = {}));
|
|
3353
|
+
var OAuthProvider;
|
|
3354
|
+
(function (OAuthProvider) {
|
|
3355
|
+
OAuthProvider["GOOGLE"] = "google";
|
|
3356
|
+
OAuthProvider["TWITTER"] = "twitter";
|
|
3357
|
+
OAuthProvider["FACEBOOK"] = "facebook";
|
|
3358
|
+
OAuthProvider["DISCORD"] = "discord";
|
|
3359
|
+
OAuthProvider["EPIC_GAMES"] = "epic_games";
|
|
3360
|
+
OAuthProvider["TELEGRAM"] = "telegram";
|
|
3361
|
+
OAuthProvider["LINE"] = "line";
|
|
3362
|
+
})(OAuthProvider || (OAuthProvider = {}));
|
|
3363
|
+
var CodeChallengeMethodEnum;
|
|
3364
|
+
(function (CodeChallengeMethodEnum) {
|
|
3365
|
+
CodeChallengeMethodEnum["PLAIN"] = "plain";
|
|
3366
|
+
CodeChallengeMethodEnum["S256"] = "S256";
|
|
3367
|
+
})(CodeChallengeMethodEnum || (CodeChallengeMethodEnum = {}));
|
|
3368
|
+
|
|
3369
|
+
const getSignedTypedData = async (typedData, accountType, chainId, signer, evmAddress) => {
|
|
3370
|
+
// Ethers auto-generates the EIP712Domain type in the TypedDataEncoder, and so it needs to be removed
|
|
3371
|
+
const types = { ...typedData.types };
|
|
3372
|
+
// @ts-ignore
|
|
3373
|
+
delete types.EIP712Domain;
|
|
3374
|
+
// Hash the EIP712 payload and generate the complete payload
|
|
3375
|
+
let typedDataHash = _TypedDataEncoder.hash(typedData.domain, types, typedData.message);
|
|
3376
|
+
if ([AccountType.UPGRADEABLE_V5,
|
|
3377
|
+
AccountType.UPGRADEABLE_V6,
|
|
3378
|
+
AccountType.ZKSYNC_UPGRADEABLE_V1,
|
|
3379
|
+
AccountType.ZKSYNC_UPGRADEABLE_V2].includes(accountType)) {
|
|
3380
|
+
const updatedDomain = {
|
|
3381
|
+
name: 'Openfort',
|
|
3382
|
+
version: '0.5',
|
|
3383
|
+
chainId: Number(chainId),
|
|
3384
|
+
verifyingContract: evmAddress,
|
|
3385
|
+
};
|
|
3386
|
+
const updatedTypes = {
|
|
3387
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3388
|
+
OpenfortMessage: [{ name: 'hashedMessage', type: 'bytes32' }],
|
|
3389
|
+
};
|
|
3390
|
+
const updatedMessage = {
|
|
3391
|
+
hashedMessage: typedDataHash,
|
|
3392
|
+
};
|
|
3393
|
+
typedDataHash = _TypedDataEncoder.hash(updatedDomain, updatedTypes, updatedMessage);
|
|
3394
|
+
}
|
|
3395
|
+
const ethsigNoType = await signer.sign(typedDataHash, false, false);
|
|
3396
|
+
return ethsigNoType;
|
|
3397
|
+
};
|
|
3398
|
+
|
|
3246
3399
|
var StorageKeys;
|
|
3247
3400
|
(function (StorageKeys) {
|
|
3248
3401
|
StorageKeys["AUTHENTICATION"] = "openfort.authentication";
|
|
@@ -3316,7 +3469,7 @@ class KeyPair extends SigningKey {
|
|
|
3316
3469
|
}
|
|
3317
3470
|
}
|
|
3318
3471
|
|
|
3319
|
-
const VERSION = '0.8.
|
|
3472
|
+
const VERSION = '0.8.22';
|
|
3320
3473
|
|
|
3321
3474
|
var Event;
|
|
3322
3475
|
(function (Event) {
|
|
@@ -3590,9 +3743,11 @@ class NotConfiguredError extends Error {
|
|
|
3590
3743
|
class IframeManager {
|
|
3591
3744
|
iframe;
|
|
3592
3745
|
responses = new Map();
|
|
3746
|
+
storage;
|
|
3593
3747
|
sdkConfiguration;
|
|
3594
3748
|
constructor(configuration) {
|
|
3595
3749
|
this.sdkConfiguration = configuration;
|
|
3750
|
+
this.storage = new LocalStorage();
|
|
3596
3751
|
}
|
|
3597
3752
|
async iframeSetup() {
|
|
3598
3753
|
if (window.addEventListener) {
|
|
@@ -3688,7 +3843,6 @@ class IframeManager {
|
|
|
3688
3843
|
if (response) {
|
|
3689
3844
|
clearInterval(interval);
|
|
3690
3845
|
this.responses.delete(uuid);
|
|
3691
|
-
// @ts-ignore
|
|
3692
3846
|
const responseConstructor = this.responseConstructors[response.action];
|
|
3693
3847
|
if (isErrorResponse(response)) {
|
|
3694
3848
|
if (response.error === NOT_CONFIGURED_ERROR) {
|
|
@@ -3738,7 +3892,16 @@ class IframeManager {
|
|
|
3738
3892
|
shieldURL: this.sdkConfiguration.shieldUrl,
|
|
3739
3893
|
};
|
|
3740
3894
|
this.iframe?.contentWindow?.postMessage(config, '*');
|
|
3741
|
-
|
|
3895
|
+
let response;
|
|
3896
|
+
try {
|
|
3897
|
+
response = await this.waitForResponse(config.uuid);
|
|
3898
|
+
}
|
|
3899
|
+
catch (e) {
|
|
3900
|
+
if (e instanceof WrongRecoveryPasswordError || e instanceof MissingRecoveryPasswordError) {
|
|
3901
|
+
this.storage.remove(StorageKeys.SIGNER);
|
|
3902
|
+
}
|
|
3903
|
+
throw e;
|
|
3904
|
+
}
|
|
3742
3905
|
sessionStorage.setItem('iframe-version', response.version ?? 'undefined');
|
|
3743
3906
|
return response;
|
|
3744
3907
|
}
|
|
@@ -3785,7 +3948,6 @@ class IframeManager {
|
|
|
3785
3948
|
response = await this.waitForResponse(uuid);
|
|
3786
3949
|
}
|
|
3787
3950
|
catch (e) {
|
|
3788
|
-
console.log('switchChain', e);
|
|
3789
3951
|
if (e instanceof NotConfiguredError) {
|
|
3790
3952
|
await this.configure(iframeConfiguration);
|
|
3791
3953
|
return this.switchChain(iframeConfiguration, chainId);
|
|
@@ -4086,7 +4248,6 @@ class EmbeddedSigner {
|
|
|
4086
4248
|
const deviceAccount = await this.iframeManager
|
|
4087
4249
|
.switchChain(this.iframeConfiguration, chainId);
|
|
4088
4250
|
new Account(deviceAccount.accountType, deviceAccount.address, deviceAccount.chainId, deviceAccount.ownerAddress).save(this.storage);
|
|
4089
|
-
SignerManager.storage.save(StorageKeys.SIGNER, JSON.stringify(deviceAccount));
|
|
4090
4251
|
}
|
|
4091
4252
|
async setEmbeddedRecovery({ recoveryMethod, recoveryPassword, encryptionSession }) {
|
|
4092
4253
|
await this.iframeManager
|
|
@@ -4273,8 +4434,8 @@ class SignerManager {
|
|
|
4273
4434
|
type: 'embedded',
|
|
4274
4435
|
chainId,
|
|
4275
4436
|
};
|
|
4276
|
-
SignerManager.storage.save(StorageKeys.SIGNER, JSON.stringify(signerConfiguration));
|
|
4277
4437
|
const resp = await iframeManager.configure(iframeConfiguration);
|
|
4438
|
+
SignerManager.storage.save(StorageKeys.SIGNER, JSON.stringify(signerConfiguration));
|
|
4278
4439
|
new Account(resp.accountType, resp.address, resp.chainId, resp.ownerAddress).save(this.storage);
|
|
4279
4440
|
return new EmbeddedSigner(iframeManager, iframeConfiguration, this.storage);
|
|
4280
4441
|
}
|
|
@@ -4304,78 +4465,6 @@ class SignerManager {
|
|
|
4304
4465
|
}
|
|
4305
4466
|
}
|
|
4306
4467
|
|
|
4307
|
-
var EmbeddedState;
|
|
4308
|
-
(function (EmbeddedState) {
|
|
4309
|
-
EmbeddedState[EmbeddedState["NONE"] = 0] = "NONE";
|
|
4310
|
-
EmbeddedState[EmbeddedState["UNAUTHENTICATED"] = 1] = "UNAUTHENTICATED";
|
|
4311
|
-
EmbeddedState[EmbeddedState["EMBEDDED_SIGNER_NOT_CONFIGURED"] = 2] = "EMBEDDED_SIGNER_NOT_CONFIGURED";
|
|
4312
|
-
EmbeddedState[EmbeddedState["CREATING_ACCOUNT"] = 3] = "CREATING_ACCOUNT";
|
|
4313
|
-
EmbeddedState[EmbeddedState["READY"] = 4] = "READY";
|
|
4314
|
-
})(EmbeddedState || (EmbeddedState = {}));
|
|
4315
|
-
var OpenfortEvents;
|
|
4316
|
-
(function (OpenfortEvents) {
|
|
4317
|
-
OpenfortEvents["LOGGED_OUT"] = "loggedOut";
|
|
4318
|
-
})(OpenfortEvents || (OpenfortEvents = {}));
|
|
4319
|
-
var RecoveryMethod;
|
|
4320
|
-
(function (RecoveryMethod) {
|
|
4321
|
-
RecoveryMethod["PASSWORD"] = "password";
|
|
4322
|
-
RecoveryMethod["AUTOMATIC"] = "automatic";
|
|
4323
|
-
})(RecoveryMethod || (RecoveryMethod = {}));
|
|
4324
|
-
var AccountType;
|
|
4325
|
-
(function (AccountType) {
|
|
4326
|
-
AccountType["UPGRADEABLE_V4"] = "Upgradeable_v04";
|
|
4327
|
-
AccountType["MANAGED_V4"] = "Managed_v04";
|
|
4328
|
-
AccountType["ERC6551_V4"] = "ERC6551_v04";
|
|
4329
|
-
AccountType["ERC6551_V5"] = "ERC6551_v05";
|
|
4330
|
-
AccountType["RECOVERABLE_V4"] = "Recoverable_v04";
|
|
4331
|
-
AccountType["MANAGED_V5"] = "Managed_v05";
|
|
4332
|
-
AccountType["UPGRADEABLE_V5"] = "Upgradeable_v05";
|
|
4333
|
-
AccountType["UPGRADEABLE_V6"] = "Upgradeable_v06";
|
|
4334
|
-
AccountType["ZKSYNC_UPGRADEABLE_V1"] = "zksync_upgradeable_v1";
|
|
4335
|
-
AccountType["ZKSYNC_UPGRADEABLE_V2"] = "zksync_upgradeable_v2";
|
|
4336
|
-
})(AccountType || (AccountType = {}));
|
|
4337
|
-
var AuthType;
|
|
4338
|
-
(function (AuthType) {
|
|
4339
|
-
AuthType["OPENFORT"] = "openfort";
|
|
4340
|
-
AuthType["THIRD_PARTY"] = "thirdParty";
|
|
4341
|
-
})(AuthType || (AuthType = {}));
|
|
4342
|
-
var TokenType;
|
|
4343
|
-
(function (TokenType) {
|
|
4344
|
-
TokenType["ID_TOKEN"] = "idToken";
|
|
4345
|
-
TokenType["CUSTOM_TOKEN"] = "customToken";
|
|
4346
|
-
})(TokenType || (TokenType = {}));
|
|
4347
|
-
var ThirdPartyOAuthProvider;
|
|
4348
|
-
(function (ThirdPartyOAuthProvider) {
|
|
4349
|
-
ThirdPartyOAuthProvider["ACCELBYTE"] = "accelbyte";
|
|
4350
|
-
ThirdPartyOAuthProvider["FIREBASE"] = "firebase";
|
|
4351
|
-
ThirdPartyOAuthProvider["LOOTLOCKER"] = "lootlocker";
|
|
4352
|
-
ThirdPartyOAuthProvider["PLAYFAB"] = "playfab";
|
|
4353
|
-
ThirdPartyOAuthProvider["SUPABASE"] = "supabase";
|
|
4354
|
-
ThirdPartyOAuthProvider["CUSTOM"] = "custom";
|
|
4355
|
-
ThirdPartyOAuthProvider["OIDC"] = "oidc";
|
|
4356
|
-
ThirdPartyOAuthProvider["TELEGRAM_MINI_APP"] = "telegramMiniApp";
|
|
4357
|
-
})(ThirdPartyOAuthProvider || (ThirdPartyOAuthProvider = {}));
|
|
4358
|
-
var BasicAuthProvider;
|
|
4359
|
-
(function (BasicAuthProvider) {
|
|
4360
|
-
BasicAuthProvider["EMAIL"] = "email";
|
|
4361
|
-
BasicAuthProvider["WALLET"] = "wallet";
|
|
4362
|
-
})(BasicAuthProvider || (BasicAuthProvider = {}));
|
|
4363
|
-
var OAuthProvider;
|
|
4364
|
-
(function (OAuthProvider) {
|
|
4365
|
-
OAuthProvider["GOOGLE"] = "google";
|
|
4366
|
-
OAuthProvider["TWITTER"] = "twitter";
|
|
4367
|
-
OAuthProvider["FACEBOOK"] = "facebook";
|
|
4368
|
-
OAuthProvider["DISCORD"] = "discord";
|
|
4369
|
-
OAuthProvider["EPIC_GAMES"] = "epic_games";
|
|
4370
|
-
OAuthProvider["TELEGRAM"] = "telegram";
|
|
4371
|
-
OAuthProvider["LINE"] = "line";
|
|
4372
|
-
})(OAuthProvider || (OAuthProvider = {}));
|
|
4373
|
-
var CodeChallengeMethodEnum;
|
|
4374
|
-
(function (CodeChallengeMethodEnum) {
|
|
4375
|
-
CodeChallengeMethodEnum["PLAIN"] = "plain";
|
|
4376
|
-
CodeChallengeMethodEnum["S256"] = "S256";
|
|
4377
|
-
})(CodeChallengeMethodEnum || (CodeChallengeMethodEnum = {}));
|
|
4378
|
-
|
|
4379
4468
|
const KEY_PKCE_STATE = 'pkce_state';
|
|
4380
4469
|
const KEY_PKCE_VERIFIER = 'pkce_verifier';
|
|
4381
4470
|
class DeviceCredentialsManager {
|
|
@@ -5028,34 +5117,6 @@ const sendTransaction = async ({ params, signer, account, authentication, backen
|
|
|
5028
5117
|
return response.transactionHash;
|
|
5029
5118
|
};
|
|
5030
5119
|
|
|
5031
|
-
const getSignedTypedData = async (typedData, accountType, chainId, signer, evmAddress) => {
|
|
5032
|
-
// Ethers auto-generates the EIP712Domain type in the TypedDataEncoder, and so it needs to be removed
|
|
5033
|
-
const types = { ...typedData.types };
|
|
5034
|
-
// @ts-ignore
|
|
5035
|
-
delete types.EIP712Domain;
|
|
5036
|
-
// Hash the EIP712 payload and generate the complete payload
|
|
5037
|
-
let typedDataHash = _TypedDataEncoder.hash(typedData.domain, types, typedData.message);
|
|
5038
|
-
if (accountType === AccountType.UPGRADEABLE_V5) {
|
|
5039
|
-
const updatedDomain = {
|
|
5040
|
-
name: 'Openfort',
|
|
5041
|
-
version: '0.5',
|
|
5042
|
-
chainId: Number(chainId),
|
|
5043
|
-
verifyingContract: evmAddress,
|
|
5044
|
-
};
|
|
5045
|
-
const updatedTypes = {
|
|
5046
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
5047
|
-
OpenfortMessage: [{ name: 'hashedMessage', type: 'bytes32' }],
|
|
5048
|
-
};
|
|
5049
|
-
const updatedMessage = {
|
|
5050
|
-
hashedMessage: typedDataHash,
|
|
5051
|
-
};
|
|
5052
|
-
typedDataHash = _TypedDataEncoder.hash(updatedDomain, updatedTypes, updatedMessage);
|
|
5053
|
-
// primaryType: "OpenfortMessage"
|
|
5054
|
-
}
|
|
5055
|
-
const ethsigNoType = await signer.sign(typedDataHash, false, false);
|
|
5056
|
-
return ethsigNoType;
|
|
5057
|
-
};
|
|
5058
|
-
|
|
5059
5120
|
const REQUIRED_TYPED_DATA_PROPERTIES = ['types', 'domain', 'primaryType', 'message'];
|
|
5060
5121
|
const isValidTypedDataPayload = (typedData) => (REQUIRED_TYPED_DATA_PROPERTIES.every((key) => key in typedData));
|
|
5061
5122
|
const transformTypedData = (typedData, chainId) => {
|
|
@@ -6934,7 +6995,6 @@ class EvmProvider {
|
|
|
6934
6995
|
throw new JsonRpcError(ProviderErrorCode.UNAUTHORIZED, 'Unauthorized - call eth_requestAccounts first');
|
|
6935
6996
|
}
|
|
6936
6997
|
this.#validateAndRefreshSession();
|
|
6937
|
-
console.log(`eth_sendTransaction ${this.#policyId}`);
|
|
6938
6998
|
return await sendTransaction({
|
|
6939
6999
|
params: request.params || [],
|
|
6940
7000
|
signer,
|
|
@@ -7263,7 +7323,12 @@ class Openfort {
|
|
|
7263
7323
|
* @returns A Provider instance.
|
|
7264
7324
|
* @throws {OpenfortError} If the signer is not an EmbeddedSigner.
|
|
7265
7325
|
*/
|
|
7266
|
-
getEthereumProvider(options
|
|
7326
|
+
getEthereumProvider(options) {
|
|
7327
|
+
// Apply default options with proper type safety
|
|
7328
|
+
const defaultOptions = {
|
|
7329
|
+
announceProvider: true,
|
|
7330
|
+
};
|
|
7331
|
+
const finalOptions = { ...defaultOptions, ...options };
|
|
7267
7332
|
const authentication = Authentication.fromStorage(this.storage);
|
|
7268
7333
|
const signer = SignerManager.fromStorage();
|
|
7269
7334
|
const account = Account.fromStorage(this.storage);
|
|
@@ -7275,16 +7340,18 @@ class Openfort {
|
|
|
7275
7340
|
account: account || undefined,
|
|
7276
7341
|
authentication: authentication || undefined,
|
|
7277
7342
|
backendApiClients: this.backendApiClients,
|
|
7278
|
-
policyId:
|
|
7343
|
+
policyId: finalOptions.policy,
|
|
7279
7344
|
validateAndRefreshSession: this.validateAndRefreshToken.bind(this),
|
|
7280
7345
|
});
|
|
7281
|
-
announceProvider
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7346
|
+
if (finalOptions.announceProvider) {
|
|
7347
|
+
announceProvider({
|
|
7348
|
+
info: { ...openfortProviderInfo, ...finalOptions.providerInfo },
|
|
7349
|
+
provider: this.provider,
|
|
7350
|
+
});
|
|
7351
|
+
}
|
|
7285
7352
|
}
|
|
7286
|
-
else if (this.provider &&
|
|
7287
|
-
this.provider.updatePolicy(
|
|
7353
|
+
else if (this.provider && finalOptions.policy) {
|
|
7354
|
+
this.provider.updatePolicy(finalOptions.policy);
|
|
7288
7355
|
}
|
|
7289
7356
|
return this.provider;
|
|
7290
7357
|
}
|
|
@@ -7355,37 +7422,18 @@ class Openfort {
|
|
|
7355
7422
|
* @returns The signature.
|
|
7356
7423
|
* @throws {OpenfortError} If no signer is configured.
|
|
7357
7424
|
*/
|
|
7358
|
-
async signTypedData(domain, types,
|
|
7425
|
+
async signTypedData(domain, types, message) {
|
|
7359
7426
|
await this.validateAndRefreshToken();
|
|
7360
7427
|
const signer = SignerManager.fromStorage();
|
|
7361
|
-
if (!signer) {
|
|
7362
|
-
throw new OpenfortError('No signer configured', OpenfortErrorType.MISSING_SIGNER_ERROR);
|
|
7363
|
-
}
|
|
7364
|
-
let hash = _TypedDataEncoder.hash(domain, types, value);
|
|
7365
|
-
// eslint-disable-next-line no-param-reassign
|
|
7366
|
-
delete types.EIP712Domain;
|
|
7367
7428
|
const account = Account.fromStorage(this.storage);
|
|
7368
|
-
if (account
|
|
7369
|
-
|
|
7370
|
-
AccountType.ZKSYNC_UPGRADEABLE_V1,
|
|
7371
|
-
AccountType.ZKSYNC_UPGRADEABLE_V2].includes(account.type)) {
|
|
7372
|
-
const updatedDomain = {
|
|
7373
|
-
name: 'Openfort',
|
|
7374
|
-
version: '0.5',
|
|
7375
|
-
chainId: Number(account.chainId),
|
|
7376
|
-
verifyingContract: account.address ?? undefined,
|
|
7377
|
-
};
|
|
7378
|
-
const updatedTypes = {
|
|
7379
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7380
|
-
OpenfortMessage: [{ name: 'hashedMessage', type: 'bytes32' }],
|
|
7381
|
-
};
|
|
7382
|
-
const updatedMessage = {
|
|
7383
|
-
hashedMessage: hash,
|
|
7384
|
-
};
|
|
7385
|
-
hash = _TypedDataEncoder.hash(updatedDomain, updatedTypes, updatedMessage);
|
|
7386
|
-
// primaryType: "OpenfortMessage"
|
|
7429
|
+
if (!signer || !account) {
|
|
7430
|
+
throw new OpenfortError('No signer configured', OpenfortErrorType.MISSING_SIGNER_ERROR);
|
|
7387
7431
|
}
|
|
7388
|
-
return await
|
|
7432
|
+
return await getSignedTypedData({
|
|
7433
|
+
domain,
|
|
7434
|
+
types,
|
|
7435
|
+
message,
|
|
7436
|
+
}, account.type, Number(account.chainId), signer, account.address);
|
|
7389
7437
|
}
|
|
7390
7438
|
/**
|
|
7391
7439
|
* Exports the private key.
|
|
@@ -7832,6 +7880,8 @@ class Openfort {
|
|
|
7832
7880
|
if (!credentials.player) {
|
|
7833
7881
|
throw new OpenfortError('No player found in credentials', OpenfortErrorType.INTERNAL_ERROR);
|
|
7834
7882
|
}
|
|
7883
|
+
if (credentials.accessToken === auth.token)
|
|
7884
|
+
return;
|
|
7835
7885
|
new Authentication('jwt', credentials.accessToken, credentials.player, credentials.refreshToken).save(this.storage);
|
|
7836
7886
|
const signer = SignerManager.fromStorage();
|
|
7837
7887
|
try {
|
|
@@ -7897,4 +7947,4 @@ class SDKConfiguration {
|
|
|
7897
7947
|
}
|
|
7898
7948
|
}
|
|
7899
7949
|
|
|
7900
|
-
export { AuthType, BasicAuthProvider, EmbeddedState, OAuthProvider, OpenfortConfiguration, OpenfortError, OpenfortErrorType, RecoveryMethod, SDKConfiguration, ShieldAuthType, ShieldConfiguration, ThirdPartyOAuthProvider, TokenType, Openfort as default };
|
|
7950
|
+
export { AuthType, BasicAuthProvider, EmbeddedState, MissingProjectEntropyError, MissingRecoveryPasswordError, NotConfiguredError, OAuthProvider, OpenfortConfiguration, OpenfortError, OpenfortErrorType, RecoveryMethod, SDKConfiguration, ShieldAuthType, ShieldConfiguration, ThirdPartyOAuthProvider, TokenType, WrongRecoveryPasswordError, Openfort as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfort/openfort-js",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.22",
|
|
4
4
|
"author": "Openfort (https://www.openfort.xyz)",
|
|
5
5
|
"bugs": "https://github.com/openfort-xyz/openfort-js/issues",
|
|
6
6
|
"repository": "openfort-xyz/openfort-js.git",
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
"registry": "https://registry.npmjs.org/"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ethersproject/abstract-signer": "^5.7.0",
|
|
35
34
|
"@ethersproject/bytes": "^5.7.0",
|
|
36
35
|
"@ethersproject/hash": "^5.7.0",
|
|
37
36
|
"@ethersproject/providers": "^5.7.0",
|