@imtbl/sdk 0.15.1-alpha → 0.16.0
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/blockchain_data.js +1 -1
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.js +74 -82
- package/dist/checkout_widgets.js +1 -1
- package/dist/erc721.d.ts +4 -4
- package/dist/erc721.js +57 -69
- package/dist/erc721_mint_by_id.d.ts +4 -4
- package/dist/erc721_mint_by_id.js +51 -51
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +8 -8
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +210 -212
- package/dist/index.d.ts +8 -8
- package/dist/index.js +210 -212
- package/dist/passport.js +26 -8
- package/package.json +1 -1
package/dist/passport.js
CHANGED
|
@@ -1457,7 +1457,7 @@ class MultiRollupApiClients {
|
|
|
1457
1457
|
}
|
|
1458
1458
|
|
|
1459
1459
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1460
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.
|
|
1460
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.0.0' };
|
|
1461
1461
|
const createConfig = ({ basePath, headers, }) => {
|
|
1462
1462
|
if (!basePath.trim()) {
|
|
1463
1463
|
throw Error('basePath can not be empty');
|
|
@@ -1513,7 +1513,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
1513
1513
|
chainID,
|
|
1514
1514
|
coreContractAddress,
|
|
1515
1515
|
registrationContractAddress,
|
|
1516
|
-
sdkVersion: 'ts-immutable-sdk-0.
|
|
1516
|
+
sdkVersion: 'ts-immutable-sdk-0.0.0',
|
|
1517
1517
|
});
|
|
1518
1518
|
/**
|
|
1519
1519
|
* Sets `sdkVersion` at the time of build
|
|
@@ -5948,6 +5948,12 @@ class AuthManager {
|
|
|
5948
5948
|
userAdminAddress: idTokenPayload?.passport?.imx_user_admin_address,
|
|
5949
5949
|
};
|
|
5950
5950
|
}
|
|
5951
|
+
if (idTokenPayload?.passport?.zkevm_eth_address) {
|
|
5952
|
+
user.zkEvm = {
|
|
5953
|
+
ethAddress: idTokenPayload?.passport?.zkevm_eth_address,
|
|
5954
|
+
userAdminAddress: idTokenPayload?.passport?.zkevm_user_admin_address,
|
|
5955
|
+
};
|
|
5956
|
+
}
|
|
5951
5957
|
return user;
|
|
5952
5958
|
};
|
|
5953
5959
|
async login() {
|
|
@@ -6091,8 +6097,8 @@ class AuthManager {
|
|
|
6091
6097
|
const refreshToken = tokenResponse?.refresh_token ?? null;
|
|
6092
6098
|
if (refreshToken) {
|
|
6093
6099
|
// Token is no longer valid, but refresh token can be used to a new one
|
|
6094
|
-
const
|
|
6095
|
-
return
|
|
6100
|
+
const user = await this.refreshToken(refreshToken);
|
|
6101
|
+
return user;
|
|
6096
6102
|
}
|
|
6097
6103
|
return null;
|
|
6098
6104
|
}, PassportErrorType.AUTHENTICATION_ERROR);
|
|
@@ -6103,7 +6109,8 @@ class AuthManager {
|
|
|
6103
6109
|
grant_type: 'refresh_token',
|
|
6104
6110
|
refresh_token: refreshToken,
|
|
6105
6111
|
}, formUrlEncodedHeader);
|
|
6106
|
-
|
|
6112
|
+
const newTokenResponse = response.data;
|
|
6113
|
+
return AuthManager.mapDeviceTokenResponseToDomainUserModel(newTokenResponse);
|
|
6107
6114
|
}
|
|
6108
6115
|
async logout() {
|
|
6109
6116
|
return withPassportError(async () => {
|
|
@@ -7262,7 +7269,7 @@ class RelayerClient {
|
|
|
7262
7269
|
}
|
|
7263
7270
|
|
|
7264
7271
|
const MESSAGE_TO_SIGN = 'Only sign this message from Immutable Passport';
|
|
7265
|
-
async function registerZkEvmUser({ authManager, magicProvider, multiRollupApiClients, accessToken, }) {
|
|
7272
|
+
async function registerZkEvmUser({ authManager, config, magicProvider, multiRollupApiClients, accessToken, }) {
|
|
7266
7273
|
const web3Provider = new Web3Provider(magicProvider);
|
|
7267
7274
|
const ethSigner = web3Provider.getSigner();
|
|
7268
7275
|
const ethereumAddress = await ethSigner.getAddress();
|
|
@@ -7279,7 +7286,17 @@ async function registerZkEvmUser({ authManager, magicProvider, multiRollupApiCli
|
|
|
7279
7286
|
catch (error) {
|
|
7280
7287
|
throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, `Failed to create counterfactual address: ${error}`);
|
|
7281
7288
|
}
|
|
7282
|
-
|
|
7289
|
+
let user;
|
|
7290
|
+
if (config.crossSdkBridgeEnabled) {
|
|
7291
|
+
const credentials = authManager.checkStoredDeviceFlowCredentials();
|
|
7292
|
+
if (!credentials || !credentials.refresh_token) {
|
|
7293
|
+
throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, 'Cross SDK bridge: Failed to refresh user details');
|
|
7294
|
+
}
|
|
7295
|
+
user = await authManager.refreshToken(credentials.refresh_token);
|
|
7296
|
+
}
|
|
7297
|
+
else {
|
|
7298
|
+
user = await authManager.loginSilent();
|
|
7299
|
+
}
|
|
7283
7300
|
if (!user?.zkEvm) {
|
|
7284
7301
|
throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, 'Failed to refresh user details');
|
|
7285
7302
|
}
|
|
@@ -7287,7 +7304,7 @@ async function registerZkEvmUser({ authManager, magicProvider, multiRollupApiCli
|
|
|
7287
7304
|
}
|
|
7288
7305
|
|
|
7289
7306
|
const loginZkEvmUser = async ({ authManager, config, magicAdapter, multiRollupApiClients, }) => {
|
|
7290
|
-
const user = await authManager.getUser() || await authManager.login();
|
|
7307
|
+
const user = await authManager.getUser() || await authManager.getUserDeviceFlow() || await authManager.login();
|
|
7291
7308
|
if (!user.idToken) {
|
|
7292
7309
|
throw new Error('User is missing idToken');
|
|
7293
7310
|
}
|
|
@@ -7296,6 +7313,7 @@ const loginZkEvmUser = async ({ authManager, config, magicAdapter, multiRollupAp
|
|
|
7296
7313
|
// Generate counterfactual address and retrieve updated Auth0 user
|
|
7297
7314
|
const userZkevm = await registerZkEvmUser({
|
|
7298
7315
|
authManager,
|
|
7316
|
+
config,
|
|
7299
7317
|
magicProvider,
|
|
7300
7318
|
multiRollupApiClients,
|
|
7301
7319
|
accessToken: user.accessToken,
|
package/package.json
CHANGED