@imtbl/sdk 0.18.0 → 0.18.2
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.d.ts +29 -10
- package/dist/checkout_sdk.js +350 -59
- package/dist/checkout_widgets.d.ts +1 -2
- package/dist/checkout_widgets.js +1 -2
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +6 -6
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +368 -66
- package/dist/index.d.ts +39 -11
- package/dist/index.js +370 -68
- package/dist/passport.js +19 -7
- package/package.json +1 -1
package/dist/passport.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import globalAxios$1 from 'axios';
|
|
1
|
+
import globalAxios$1, { isAxiosError as isAxiosError$1 } from 'axios';
|
|
2
2
|
import { ImmutableX, Config, generateLegacyStarkPrivateKey, createStarkSigner } from '@imtbl/core-sdk';
|
|
3
|
-
import { UserManager } from 'oidc-client-ts';
|
|
3
|
+
import { UserManager, InMemoryWebStorage, WebStorageStateStore } from 'oidc-client-ts';
|
|
4
4
|
import jwt_decode from 'jwt-decode';
|
|
5
5
|
import * as crypto from 'crypto';
|
|
6
6
|
import { Magic } from 'magic-sdk';
|
|
@@ -1709,7 +1709,7 @@ class MultiRollupApiClients {
|
|
|
1709
1709
|
}
|
|
1710
1710
|
|
|
1711
1711
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1712
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.18.
|
|
1712
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.18.2' };
|
|
1713
1713
|
const createConfig = ({ basePath, headers, }) => {
|
|
1714
1714
|
if (!basePath.trim()) {
|
|
1715
1715
|
throw Error('basePath can not be empty');
|
|
@@ -1765,7 +1765,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
1765
1765
|
chainID,
|
|
1766
1766
|
coreContractAddress,
|
|
1767
1767
|
registrationContractAddress,
|
|
1768
|
-
sdkVersion: 'ts-immutable-sdk-0.18.
|
|
1768
|
+
sdkVersion: 'ts-immutable-sdk-0.18.2',
|
|
1769
1769
|
});
|
|
1770
1770
|
/**
|
|
1771
1771
|
* Sets `sdkVersion` at the time of build
|
|
@@ -6236,6 +6236,9 @@ var PassportErrorType;
|
|
|
6236
6236
|
PassportErrorType["CREATE_TRADE_ERROR"] = "CREATE_TRADE_ERROR";
|
|
6237
6237
|
PassportErrorType["OPERATION_NOT_SUPPORTED_ERROR"] = "OPERATION_NOT_SUPPORTED_ERROR";
|
|
6238
6238
|
})(PassportErrorType || (PassportErrorType = {}));
|
|
6239
|
+
function isAPIError(error) {
|
|
6240
|
+
return 'code' in error && 'message' in error;
|
|
6241
|
+
}
|
|
6239
6242
|
class PassportError extends Error {
|
|
6240
6243
|
type;
|
|
6241
6244
|
constructor(message, type) {
|
|
@@ -6248,7 +6251,13 @@ const withPassportError = async (fn, customErrorType) => {
|
|
|
6248
6251
|
return await fn();
|
|
6249
6252
|
}
|
|
6250
6253
|
catch (error) {
|
|
6251
|
-
|
|
6254
|
+
let errorMessage;
|
|
6255
|
+
if (isAxiosError$1(error) && error.response?.data && isAPIError(error.response.data)) {
|
|
6256
|
+
errorMessage = error.response.data.message;
|
|
6257
|
+
}
|
|
6258
|
+
else {
|
|
6259
|
+
errorMessage = error.message;
|
|
6260
|
+
}
|
|
6252
6261
|
throw new PassportError(errorMessage, customErrorType);
|
|
6253
6262
|
}
|
|
6254
6263
|
};
|
|
@@ -6315,6 +6324,8 @@ const formUrlEncodedHeader = {
|
|
|
6315
6324
|
},
|
|
6316
6325
|
};
|
|
6317
6326
|
const getAuthConfiguration = ({ oidcConfiguration, authenticationDomain, }) => {
|
|
6327
|
+
const store = typeof window !== 'undefined' ? window.localStorage : new InMemoryWebStorage();
|
|
6328
|
+
const userStore = new WebStorageStateStore({ store });
|
|
6318
6329
|
const baseConfiguration = {
|
|
6319
6330
|
authority: authenticationDomain,
|
|
6320
6331
|
redirect_uri: oidcConfiguration.redirectUri,
|
|
@@ -6331,6 +6342,7 @@ const getAuthConfiguration = ({ oidcConfiguration, authenticationDomain, }) => {
|
|
|
6331
6342
|
mergeClaims: true,
|
|
6332
6343
|
loadUserInfo: true,
|
|
6333
6344
|
scope: oidcConfiguration.scope,
|
|
6345
|
+
userStore,
|
|
6334
6346
|
};
|
|
6335
6347
|
if (oidcConfiguration.audience) {
|
|
6336
6348
|
baseConfiguration.extraQueryParams = {
|
|
@@ -7555,7 +7567,7 @@ class ConfirmationScreen {
|
|
|
7555
7567
|
let href = '';
|
|
7556
7568
|
if (chainType === TransactionApprovalRequestChainTypeEnum.Starkex) {
|
|
7557
7569
|
// eslint-disable-next-line max-len
|
|
7558
|
-
href = `${this.config.passportDomain}/transaction-confirmation/transaction
|
|
7570
|
+
href = `${this.config.passportDomain}/transaction-confirmation/transaction?transactionId=${transactionId}&imxEtherAddress=${imxEtherAddress}&chainType=starkex`;
|
|
7559
7571
|
}
|
|
7560
7572
|
else {
|
|
7561
7573
|
// eslint-disable-next-line max-len
|
|
@@ -7602,7 +7614,7 @@ class ConfirmationScreen {
|
|
|
7602
7614
|
return;
|
|
7603
7615
|
}
|
|
7604
7616
|
this.confirmationWindow = openPopupCenter({
|
|
7605
|
-
url: `${this.config.passportDomain}/transaction-confirmation/loading
|
|
7617
|
+
url: `${this.config.passportDomain}/transaction-confirmation/loading`,
|
|
7606
7618
|
title: CONFIRMATION_WINDOW_TITLE,
|
|
7607
7619
|
width: popupOptions?.width || CONFIRMATION_WINDOW_WIDTH,
|
|
7608
7620
|
height: popupOptions?.height || CONFIRMATION_WINDOW_HEIGHT,
|
package/package.json
CHANGED