@imtbl/sdk 0.2.0-alpha → 0.2.2-alpha
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_widgets.d.ts +4 -4
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.js +1 -1
- package/dist/index.cjs +219 -11
- package/dist/index.d.ts +27 -5
- package/dist/index.js +219 -11
- package/dist/orderbook.js +3 -5
- package/dist/passport.d.ts +23 -1
- package/dist/passport.js +215 -4
- package/package.json +2 -1
|
@@ -15288,8 +15288,8 @@ interface ImtblWalletProps extends React.DetailedHTMLProps<React.HTMLAttributes<
|
|
|
15288
15288
|
* @property {string | undefined} walletProvider - The preferred wallet provider to connect to.
|
|
15289
15289
|
* @property {string | undefined} widgetConfig - The configuration for the swap widget.
|
|
15290
15290
|
* @property {string | undefined} amount - The amount to swap.
|
|
15291
|
-
* @property {string | undefined} fromContractAddress - The contract address of the source token.
|
|
15292
|
-
* @property {string | undefined} toContractAddress - The contract address of the destination token.
|
|
15291
|
+
* @property {string | undefined} fromContractAddress - The contract address of the source token. If the string is 'NATIVE' then the native token will be used.
|
|
15292
|
+
* @property {string | undefined} toContractAddress - The contract address of the destination token. If the string is 'NATIVE' then the native token will be used.
|
|
15293
15293
|
*/
|
|
15294
15294
|
interface ImtblSwapProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
|
|
15295
15295
|
walletProvider?: string;
|
|
@@ -15344,9 +15344,9 @@ declare function ConnectReact(): JSX.Element;
|
|
|
15344
15344
|
* @interface SwapReactProps
|
|
15345
15345
|
* @property {WalletProviderName | undefined} walletProvider - The name of the wallet provider.
|
|
15346
15346
|
* @property {Web3Provider | undefined} provider - The Web3 provider.
|
|
15347
|
-
* @property {string | undefined} fromContractAddress - The address of the contract swapping from.
|
|
15347
|
+
* @property {string | undefined} fromContractAddress - The address of the contract swapping from. If the string is 'NATIVE' then the native token is used.
|
|
15348
15348
|
* @property {string | undefined} amount - The amount.
|
|
15349
|
-
* @property {string | undefined} toContractAddress - The address of the contract swapping to.
|
|
15349
|
+
* @property {string | undefined} toContractAddress - The address of the contract swapping to. If the string is 'NATIVE' then the native token is used.
|
|
15350
15350
|
*/
|
|
15351
15351
|
interface SwapReactProps {
|
|
15352
15352
|
walletProvider?: WalletProviderName;
|
package/dist/checkout_widgets.js
CHANGED
|
@@ -4,7 +4,7 @@ import { useEffect } from 'react';
|
|
|
4
4
|
function $parcel$export(e, n, v, s) {
|
|
5
5
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
6
|
}
|
|
7
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.2.
|
|
7
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.2.2-alpha";
|
|
8
8
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
9
9
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
16
16
|
chainID,
|
|
17
17
|
coreContractAddress,
|
|
18
18
|
registrationContractAddress,
|
|
19
|
-
sdkVersion: 'ts-immutable-sdk-0.2.
|
|
19
|
+
sdkVersion: 'ts-immutable-sdk-0.2.2-alpha',
|
|
20
20
|
});
|
|
21
21
|
/**
|
|
22
22
|
* Sets `sdkVersion` at the time of build
|
package/dist/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var axios$2 = require('axios');
|
|
4
4
|
var coreSdk = require('@imtbl/core-sdk');
|
|
5
5
|
var oidcClientTs = require('oidc-client-ts');
|
|
6
|
+
var jwt_decode = require('jwt-decode');
|
|
6
7
|
var magicSdk = require('magic-sdk');
|
|
7
8
|
var oidc = require('@magic-ext/oidc');
|
|
8
9
|
var BN$2 = require('bn.js');
|
|
@@ -5456,7 +5457,7 @@ class APIError extends Error {
|
|
|
5456
5457
|
|
|
5457
5458
|
/* eslint-disable implicit-arrow-linebreak */
|
|
5458
5459
|
const defaultHeaders = {
|
|
5459
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.2.
|
|
5460
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.2.2-alpha',
|
|
5460
5461
|
};
|
|
5461
5462
|
/**
|
|
5462
5463
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -5722,7 +5723,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
5722
5723
|
chainID,
|
|
5723
5724
|
coreContractAddress,
|
|
5724
5725
|
registrationContractAddress,
|
|
5725
|
-
sdkVersion: 'ts-immutable-sdk-0.2.
|
|
5726
|
+
sdkVersion: 'ts-immutable-sdk-0.2.2-alpha',
|
|
5726
5727
|
});
|
|
5727
5728
|
/**
|
|
5728
5729
|
* Sets `sdkVersion` at the time of build
|
|
@@ -9999,6 +10000,43 @@ const withPassportError = async (fn, customErrorType) => {
|
|
|
9999
10000
|
}
|
|
10000
10001
|
};
|
|
10001
10002
|
|
|
10003
|
+
const keyCrendentials = 'passport_credentials';
|
|
10004
|
+
const validCredentialsMinTtlSec = 3600; // 1 hour
|
|
10005
|
+
class DeviceCredentialsManager {
|
|
10006
|
+
saveCredentials(tokenResponse) {
|
|
10007
|
+
localStorage.setItem(keyCrendentials, JSON.stringify(tokenResponse));
|
|
10008
|
+
}
|
|
10009
|
+
getCredentials() {
|
|
10010
|
+
const credentialsJson = localStorage.getItem(keyCrendentials);
|
|
10011
|
+
if (credentialsJson) {
|
|
10012
|
+
return JSON.parse(credentialsJson);
|
|
10013
|
+
}
|
|
10014
|
+
return null;
|
|
10015
|
+
}
|
|
10016
|
+
areValid(tokenResponse) {
|
|
10017
|
+
if (tokenResponse) {
|
|
10018
|
+
const accessTokenValid = this.isTokenValid(tokenResponse.access_token);
|
|
10019
|
+
const idTokenValid = this.isTokenValid(tokenResponse.id_token);
|
|
10020
|
+
return accessTokenValid && idTokenValid;
|
|
10021
|
+
}
|
|
10022
|
+
return false;
|
|
10023
|
+
}
|
|
10024
|
+
isTokenValid(jwt) {
|
|
10025
|
+
const tokenPayload = jwt_decode(jwt);
|
|
10026
|
+
const expiresAt = tokenPayload.exp ?? 0;
|
|
10027
|
+
const now = (Date.now() / 1000) + validCredentialsMinTtlSec;
|
|
10028
|
+
return expiresAt > now;
|
|
10029
|
+
}
|
|
10030
|
+
clearCredentials() {
|
|
10031
|
+
localStorage.removeItem(keyCrendentials);
|
|
10032
|
+
}
|
|
10033
|
+
}
|
|
10034
|
+
|
|
10035
|
+
const formUrlEncodedHeader = {
|
|
10036
|
+
headers: {
|
|
10037
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
10038
|
+
},
|
|
10039
|
+
};
|
|
10002
10040
|
const getAuthConfiguration = ({ oidcConfiguration, authenticationDomain, }) => {
|
|
10003
10041
|
const baseConfiguration = {
|
|
10004
10042
|
authority: authenticationDomain,
|
|
@@ -10024,12 +10062,19 @@ const getAuthConfiguration = ({ oidcConfiguration, authenticationDomain, }) => {
|
|
|
10024
10062
|
}
|
|
10025
10063
|
return baseConfiguration;
|
|
10026
10064
|
};
|
|
10065
|
+
function wait$1(ms) {
|
|
10066
|
+
return new Promise((resolve) => {
|
|
10067
|
+
setTimeout(resolve, ms);
|
|
10068
|
+
});
|
|
10069
|
+
}
|
|
10027
10070
|
class AuthManager {
|
|
10028
10071
|
userManager;
|
|
10029
10072
|
config;
|
|
10073
|
+
deviceCredentialsManager;
|
|
10030
10074
|
constructor(config) {
|
|
10031
10075
|
this.config = config;
|
|
10032
10076
|
this.userManager = new oidcClientTs.UserManager(getAuthConfiguration(config));
|
|
10077
|
+
this.deviceCredentialsManager = new DeviceCredentialsManager();
|
|
10033
10078
|
}
|
|
10034
10079
|
static mapOidcUserToDomainModel = (oidcUser) => {
|
|
10035
10080
|
const passport = oidcUser.profile?.passport;
|
|
@@ -10059,6 +10104,27 @@ class AuthManager {
|
|
|
10059
10104
|
}
|
|
10060
10105
|
return user;
|
|
10061
10106
|
};
|
|
10107
|
+
static mapDeviceTokenResponseToDomainUserModel = (tokenResponse) => {
|
|
10108
|
+
const idTokenPayload = jwt_decode(tokenResponse.id_token);
|
|
10109
|
+
const user = {
|
|
10110
|
+
idToken: tokenResponse.id_token,
|
|
10111
|
+
accessToken: tokenResponse.access_token,
|
|
10112
|
+
refreshToken: tokenResponse.refresh_token,
|
|
10113
|
+
profile: {
|
|
10114
|
+
sub: idTokenPayload.sub,
|
|
10115
|
+
email: idTokenPayload.email,
|
|
10116
|
+
nickname: idTokenPayload.nickname,
|
|
10117
|
+
},
|
|
10118
|
+
};
|
|
10119
|
+
if (idTokenPayload?.passport?.imx_eth_address) {
|
|
10120
|
+
user.imx = {
|
|
10121
|
+
ethAddress: idTokenPayload?.passport?.imx_eth_address,
|
|
10122
|
+
starkAddress: idTokenPayload?.passport?.imx_stark_address,
|
|
10123
|
+
userAdminAddress: idTokenPayload?.passport?.imx_user_admin_address,
|
|
10124
|
+
};
|
|
10125
|
+
}
|
|
10126
|
+
return user;
|
|
10127
|
+
};
|
|
10062
10128
|
async login() {
|
|
10063
10129
|
return withPassportError(async () => {
|
|
10064
10130
|
const popupWindowFeatures = { width: 410, height: 450 };
|
|
@@ -10071,9 +10137,104 @@ class AuthManager {
|
|
|
10071
10137
|
async loginCallback() {
|
|
10072
10138
|
return withPassportError(async () => this.userManager.signinPopupCallback(), PassportErrorType.AUTHENTICATION_ERROR);
|
|
10073
10139
|
}
|
|
10140
|
+
async loginWithDeviceFlow() {
|
|
10141
|
+
return withPassportError(async () => {
|
|
10142
|
+
const response = await axios$2.post(`${this.config.authenticationDomain}/oauth/device/code`, {
|
|
10143
|
+
client_id: this.config.oidcConfiguration.clientId,
|
|
10144
|
+
scope: this.config.oidcConfiguration.scope,
|
|
10145
|
+
audience: this.config.oidcConfiguration.audience,
|
|
10146
|
+
}, formUrlEncodedHeader);
|
|
10147
|
+
return {
|
|
10148
|
+
code: response.data.user_code,
|
|
10149
|
+
deviceCode: response.data.device_code,
|
|
10150
|
+
url: response.data.verification_uri_complete,
|
|
10151
|
+
interval: response.data.interval,
|
|
10152
|
+
};
|
|
10153
|
+
}, PassportErrorType.AUTHENTICATION_ERROR);
|
|
10154
|
+
}
|
|
10155
|
+
/* eslint-disable no-await-in-loop */
|
|
10156
|
+
async connectImxDeviceFlow(deviceCode, interval, timeoutMs) {
|
|
10157
|
+
return withPassportError(async () => {
|
|
10158
|
+
const startTime = Date.now();
|
|
10159
|
+
const loopCondition = true;
|
|
10160
|
+
while (loopCondition) {
|
|
10161
|
+
if (timeoutMs != null && Date.now() - startTime > timeoutMs) {
|
|
10162
|
+
throw new Error('Timed out');
|
|
10163
|
+
}
|
|
10164
|
+
await wait$1(interval * 1000);
|
|
10165
|
+
try {
|
|
10166
|
+
const tokenResponse = await this.getDeviceFlowToken(deviceCode);
|
|
10167
|
+
const user = AuthManager.mapDeviceTokenResponseToDomainUserModel(tokenResponse);
|
|
10168
|
+
// Only persist credentials that contain the necessary data
|
|
10169
|
+
if (user.imx?.ethAddress && user.imx?.starkAddress && user.imx?.userAdminAddress) {
|
|
10170
|
+
this.deviceCredentialsManager.saveCredentials(tokenResponse);
|
|
10171
|
+
}
|
|
10172
|
+
return user;
|
|
10173
|
+
}
|
|
10174
|
+
catch (error) {
|
|
10175
|
+
if (axios$2.isAxiosError(error)) {
|
|
10176
|
+
const responseError = error.response?.data;
|
|
10177
|
+
switch (responseError.error) {
|
|
10178
|
+
case 'authorization_pending':
|
|
10179
|
+
break;
|
|
10180
|
+
case 'slow_down':
|
|
10181
|
+
break;
|
|
10182
|
+
case 'expired_token':
|
|
10183
|
+
throw new Error('Token expired, please log in again');
|
|
10184
|
+
case 'access_denied':
|
|
10185
|
+
throw new Error('User denied access');
|
|
10186
|
+
default:
|
|
10187
|
+
throw new Error('Error getting token');
|
|
10188
|
+
}
|
|
10189
|
+
}
|
|
10190
|
+
else {
|
|
10191
|
+
throw error;
|
|
10192
|
+
}
|
|
10193
|
+
}
|
|
10194
|
+
}
|
|
10195
|
+
throw new Error('Failed to get credentials');
|
|
10196
|
+
}, PassportErrorType.AUTHENTICATION_ERROR);
|
|
10197
|
+
}
|
|
10198
|
+
/* eslint-enable no-await-in-loop */
|
|
10199
|
+
async getDeviceFlowToken(deviceCode) {
|
|
10200
|
+
const response = await axios$2.post(`${this.config.authenticationDomain}/oauth/token`, {
|
|
10201
|
+
client_id: this.config.oidcConfiguration.clientId,
|
|
10202
|
+
grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
|
|
10203
|
+
device_code: deviceCode,
|
|
10204
|
+
}, formUrlEncodedHeader);
|
|
10205
|
+
return response.data;
|
|
10206
|
+
}
|
|
10207
|
+
async connectImxWithCredentials(tokenResponse) {
|
|
10208
|
+
return withPassportError(async () => {
|
|
10209
|
+
if (this.deviceCredentialsManager.areValid(tokenResponse)) {
|
|
10210
|
+
// Credentials exist and are still valid
|
|
10211
|
+
return AuthManager.mapDeviceTokenResponseToDomainUserModel(tokenResponse);
|
|
10212
|
+
}
|
|
10213
|
+
const refreshToken = tokenResponse?.refresh_token ?? null;
|
|
10214
|
+
if (refreshToken) {
|
|
10215
|
+
// Token is no longer valid, but refresh token can be used to a new one
|
|
10216
|
+
const newTokenResponse = await this.refreshToken(refreshToken);
|
|
10217
|
+
return AuthManager.mapDeviceTokenResponseToDomainUserModel(newTokenResponse);
|
|
10218
|
+
}
|
|
10219
|
+
return null;
|
|
10220
|
+
}, PassportErrorType.AUTHENTICATION_ERROR);
|
|
10221
|
+
}
|
|
10222
|
+
async refreshToken(refreshToken) {
|
|
10223
|
+
const response = await axios$2.post(`${this.config.authenticationDomain}/oauth/token`, {
|
|
10224
|
+
client_id: this.config.oidcConfiguration.clientId,
|
|
10225
|
+
grant_type: 'refresh_token',
|
|
10226
|
+
refresh_token: refreshToken,
|
|
10227
|
+
}, formUrlEncodedHeader);
|
|
10228
|
+
return response.data;
|
|
10229
|
+
}
|
|
10074
10230
|
async logout() {
|
|
10075
10231
|
return withPassportError(async () => this.userManager.signoutRedirect(), PassportErrorType.LOGOUT_ERROR);
|
|
10076
10232
|
}
|
|
10233
|
+
async logoutDeviceFlow() {
|
|
10234
|
+
return withPassportError(async () => {
|
|
10235
|
+
this.deviceCredentialsManager.clearCredentials();
|
|
10236
|
+
}, PassportErrorType.LOGOUT_ERROR);
|
|
10237
|
+
}
|
|
10077
10238
|
async loginSilent() {
|
|
10078
10239
|
return withPassportError(async () => {
|
|
10079
10240
|
const existedUser = await this.getUser();
|
|
@@ -10090,12 +10251,28 @@ class AuthManager {
|
|
|
10090
10251
|
async getUser() {
|
|
10091
10252
|
return withPassportError(async () => {
|
|
10092
10253
|
const oidcUser = await this.userManager.getUser();
|
|
10093
|
-
if (
|
|
10094
|
-
return
|
|
10254
|
+
if (oidcUser) {
|
|
10255
|
+
return AuthManager.mapOidcUserToDomainModel(oidcUser);
|
|
10095
10256
|
}
|
|
10096
|
-
|
|
10257
|
+
const deviceToken = this.deviceCredentialsManager.getCredentials();
|
|
10258
|
+
if (deviceToken) {
|
|
10259
|
+
return AuthManager.mapDeviceTokenResponseToDomainUserModel(deviceToken);
|
|
10260
|
+
}
|
|
10261
|
+
return null;
|
|
10097
10262
|
}, PassportErrorType.NOT_LOGGED_IN_ERROR);
|
|
10098
10263
|
}
|
|
10264
|
+
async getUserDeviceFlow() {
|
|
10265
|
+
return withPassportError(async () => {
|
|
10266
|
+
const deviceToken = this.deviceCredentialsManager.getCredentials();
|
|
10267
|
+
if (deviceToken) {
|
|
10268
|
+
return AuthManager.mapDeviceTokenResponseToDomainUserModel(deviceToken);
|
|
10269
|
+
}
|
|
10270
|
+
return null;
|
|
10271
|
+
}, PassportErrorType.NOT_LOGGED_IN_ERROR);
|
|
10272
|
+
}
|
|
10273
|
+
checkStoredDeviceFlowCredentials() {
|
|
10274
|
+
return this.deviceCredentialsManager.getCredentials();
|
|
10275
|
+
}
|
|
10099
10276
|
}
|
|
10100
10277
|
|
|
10101
10278
|
class MagicAdapter {
|
|
@@ -10623,6 +10800,17 @@ class PassportImxProviderFactory {
|
|
|
10623
10800
|
}
|
|
10624
10801
|
return this.createProviderInstance(user);
|
|
10625
10802
|
}
|
|
10803
|
+
async getProviderWithDeviceFlow(deviceCode, interval, timeoutMs) {
|
|
10804
|
+
const user = await this.authManager.connectImxDeviceFlow(deviceCode, interval, timeoutMs);
|
|
10805
|
+
return this.createProviderInstance(user);
|
|
10806
|
+
}
|
|
10807
|
+
async getProviderWithCredentials(tokenResponse) {
|
|
10808
|
+
const user = await this.authManager.connectImxWithCredentials(tokenResponse);
|
|
10809
|
+
if (!user) {
|
|
10810
|
+
return null;
|
|
10811
|
+
}
|
|
10812
|
+
return this.createProviderInstance(user);
|
|
10813
|
+
}
|
|
10626
10814
|
async createProviderInstance(user) {
|
|
10627
10815
|
if (!user.idToken) {
|
|
10628
10816
|
throw new PassportError('Failed to initialise', PassportErrorType.WALLET_CONNECTION_ERROR);
|
|
@@ -10930,16 +11118,38 @@ class Passport {
|
|
|
10930
11118
|
async connectImx() {
|
|
10931
11119
|
return this.passportImxProviderFactory.getProvider();
|
|
10932
11120
|
}
|
|
11121
|
+
async loginWithDeviceFlow() {
|
|
11122
|
+
return this.authManager.loginWithDeviceFlow();
|
|
11123
|
+
}
|
|
11124
|
+
async connectImxDeviceFlow(deviceCode, interval, timeoutMs) {
|
|
11125
|
+
return this.passportImxProviderFactory.getProviderWithDeviceFlow(deviceCode, interval, timeoutMs);
|
|
11126
|
+
}
|
|
11127
|
+
/**
|
|
11128
|
+
* @returns {boolean} the stored device flow credentials if they exist
|
|
11129
|
+
*/
|
|
11130
|
+
checkStoredDeviceFlowCredentials() {
|
|
11131
|
+
return this.authManager.checkStoredDeviceFlowCredentials();
|
|
11132
|
+
}
|
|
11133
|
+
async connectImxWithCredentials(tokenResponse) {
|
|
11134
|
+
return this.passportImxProviderFactory.getProviderWithCredentials(tokenResponse);
|
|
11135
|
+
}
|
|
10933
11136
|
async loginCallback() {
|
|
10934
11137
|
return this.authManager.loginCallback();
|
|
10935
11138
|
}
|
|
10936
11139
|
async logout() {
|
|
10937
11140
|
return this.authManager.logout();
|
|
10938
11141
|
}
|
|
11142
|
+
async logoutDeviceFlow() {
|
|
11143
|
+
return this.authManager.logoutDeviceFlow();
|
|
11144
|
+
}
|
|
10939
11145
|
async getUserInfo() {
|
|
10940
11146
|
const user = await this.authManager.getUser();
|
|
10941
11147
|
return user?.profile;
|
|
10942
11148
|
}
|
|
11149
|
+
async getUserInfoDeviceFlow() {
|
|
11150
|
+
const user = await this.authManager.getUserDeviceFlow();
|
|
11151
|
+
return user?.profile;
|
|
11152
|
+
}
|
|
10943
11153
|
async getIdToken() {
|
|
10944
11154
|
const user = await this.authManager.getUser();
|
|
10945
11155
|
return user?.idToken;
|
|
@@ -12834,16 +13044,14 @@ class Orderbook {
|
|
|
12834
13044
|
if (!maybeConfig) {
|
|
12835
13045
|
throw new Error('Orderbook configuration not passed, either select one of the preseet chainNames or pass in localConfig');
|
|
12836
13046
|
}
|
|
13047
|
+
const { chainName, provider } = config.overrides;
|
|
13048
|
+
maybeConfig.provider = provider
|
|
13049
|
+
|| maybeConfig.provider;
|
|
12837
13050
|
this.orderbookConfig = maybeConfig;
|
|
12838
13051
|
const { apiEndpoint } = this.orderbookConfig;
|
|
12839
13052
|
if (!apiEndpoint) {
|
|
12840
13053
|
throw new Error('API endpoint must be provided as an override');
|
|
12841
13054
|
}
|
|
12842
|
-
// TODO: Move chainId lookup to a map based on env. Just using override to get dev started
|
|
12843
|
-
const chainName = config.overrides?.chainName;
|
|
12844
|
-
if (!chainName) {
|
|
12845
|
-
throw new Error('chainName must be provided as an override');
|
|
12846
|
-
}
|
|
12847
13055
|
this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress).create();
|
|
12848
13056
|
const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
|
|
12849
13057
|
this.seaport = new Seaport(seaportLibFactory, this.orderbookConfig.provider, this.orderbookConfig.seaportContractAddress, this.orderbookConfig.zoneContractAddress);
|
|
@@ -27729,7 +27937,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
27729
27937
|
function $parcel$export(e, n, v, s) {
|
|
27730
27938
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
27731
27939
|
}
|
|
27732
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.2.
|
|
27940
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.2.2-alpha";
|
|
27733
27941
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
27734
27942
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
27735
27943
|
|
package/dist/index.d.ts
CHANGED
|
@@ -12758,6 +12758,19 @@ interface PassportOverrides {
|
|
|
12758
12758
|
}
|
|
12759
12759
|
interface PassportModuleConfiguration extends ModuleConfiguration<PassportOverrides>, OidcConfiguration {
|
|
12760
12760
|
}
|
|
12761
|
+
type DeviceConnectResponse = {
|
|
12762
|
+
code: string;
|
|
12763
|
+
deviceCode: string;
|
|
12764
|
+
url: string;
|
|
12765
|
+
interval: number;
|
|
12766
|
+
};
|
|
12767
|
+
type DeviceTokenResponse = {
|
|
12768
|
+
access_token: string;
|
|
12769
|
+
refresh_token?: string;
|
|
12770
|
+
id_token: string;
|
|
12771
|
+
token_type: string;
|
|
12772
|
+
expires_in: number;
|
|
12773
|
+
};
|
|
12761
12774
|
|
|
12762
12775
|
declare class Passport {
|
|
12763
12776
|
private readonly authManager;
|
|
@@ -12769,9 +12782,18 @@ declare class Passport {
|
|
|
12769
12782
|
constructor(passportModuleConfiguration: PassportModuleConfiguration);
|
|
12770
12783
|
connectImxSilent(): Promise<IMXProvider | null>;
|
|
12771
12784
|
connectImx(): Promise<IMXProvider>;
|
|
12785
|
+
loginWithDeviceFlow(): Promise<DeviceConnectResponse>;
|
|
12786
|
+
connectImxDeviceFlow(deviceCode: string, interval: number, timeoutMs?: number): Promise<IMXProvider | null>;
|
|
12787
|
+
/**
|
|
12788
|
+
* @returns {boolean} the stored device flow credentials if they exist
|
|
12789
|
+
*/
|
|
12790
|
+
checkStoredDeviceFlowCredentials(): DeviceTokenResponse | null;
|
|
12791
|
+
connectImxWithCredentials(tokenResponse: DeviceTokenResponse): Promise<IMXProvider | null>;
|
|
12772
12792
|
loginCallback(): Promise<void>;
|
|
12773
12793
|
logout(): Promise<void>;
|
|
12794
|
+
logoutDeviceFlow(): Promise<void>;
|
|
12774
12795
|
getUserInfo(): Promise<UserProfile | undefined>;
|
|
12796
|
+
getUserInfoDeviceFlow(): Promise<UserProfile | undefined>;
|
|
12775
12797
|
getIdToken(): Promise<string | undefined>;
|
|
12776
12798
|
getAccessToken(): Promise<string | undefined>;
|
|
12777
12799
|
}
|
|
@@ -28181,8 +28203,8 @@ interface ImtblWalletProps extends React.DetailedHTMLProps<React.HTMLAttributes<
|
|
|
28181
28203
|
* @property {string | undefined} walletProvider - The preferred wallet provider to connect to.
|
|
28182
28204
|
* @property {string | undefined} widgetConfig - The configuration for the swap widget.
|
|
28183
28205
|
* @property {string | undefined} amount - The amount to swap.
|
|
28184
|
-
* @property {string | undefined} fromContractAddress - The contract address of the source token.
|
|
28185
|
-
* @property {string | undefined} toContractAddress - The contract address of the destination token.
|
|
28206
|
+
* @property {string | undefined} fromContractAddress - The contract address of the source token. If the string is 'NATIVE' then the native token will be used.
|
|
28207
|
+
* @property {string | undefined} toContractAddress - The contract address of the destination token. If the string is 'NATIVE' then the native token will be used.
|
|
28186
28208
|
*/
|
|
28187
28209
|
interface ImtblSwapProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
|
|
28188
28210
|
walletProvider?: string;
|
|
@@ -28237,9 +28259,9 @@ declare function ConnectReact(): JSX.Element;
|
|
|
28237
28259
|
* @interface SwapReactProps
|
|
28238
28260
|
* @property {WalletProviderName | undefined} walletProvider - The name of the wallet provider.
|
|
28239
28261
|
* @property {Web3Provider | undefined} provider - The Web3 provider.
|
|
28240
|
-
* @property {string | undefined} fromContractAddress - The address of the contract swapping from.
|
|
28262
|
+
* @property {string | undefined} fromContractAddress - The address of the contract swapping from. If the string is 'NATIVE' then the native token is used.
|
|
28241
28263
|
* @property {string | undefined} amount - The amount.
|
|
28242
|
-
* @property {string | undefined} toContractAddress - The address of the contract swapping to.
|
|
28264
|
+
* @property {string | undefined} toContractAddress - The address of the contract swapping to. If the string is 'NATIVE' then the native token is used.
|
|
28243
28265
|
*/
|
|
28244
28266
|
interface SwapReactProps {
|
|
28245
28267
|
walletProvider?: WalletProviderName;
|
|
@@ -28494,4 +28516,4 @@ declare class ERC721PermissionedMintable {
|
|
|
28494
28516
|
}): Promise<PopulatedTransaction>;
|
|
28495
28517
|
}
|
|
28496
28518
|
|
|
28497
|
-
export { APIError, ActivityType, AllowedNetworkConfig, BlockchainData, BlockchainDataModuleConfiguration, BridgeEventType, BridgeFailed, BridgeReact, BridgeReactProps, BridgeSuccess, CHECKOUT_API_BASE_URL, ChainId, ChainName, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutErrorType, CheckoutModuleConfiguration, CheckoutWidgetTagNames, CheckoutWidgets, CheckoutWidgetsConfig, ConnectEventType, ConnectParams, ConnectReact, ConnectResult, ConnectionFailed, ConnectionSuccess, DexConfig, ERC20, ERC721PermissionedMintable, Environment, ErrorType, GasEstimateBridgeToL2Result, GasEstimateParams, GasEstimateSwapResult, GasEstimateTokenConfig, GasEstimateType, GenericIMXProvider, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetWalletAllowListParams, GetWalletAllowListResult, IMTBLWidgetEvents, IMXProvider, ImmutableConfiguration, ImmutableXClient, ImtblBridgeProps, ImtblConnectProps, ImtblSwapProps, ImtblWalletProps, ImxModuleConfiguration as ImxClientModuleConfiguration, WalletConnection as ImxClientWalletConnection, MetaMaskIMXProvider, ModuleConfiguration, NetworkFilter, NetworkFilterTypes, NetworkInfo, Networks, OrchestrationEventType, Orderbook, Passport, PassportError, PassportModuleConfiguration, PassportOverrides, ProviderConfiguration, RemoteConfiguration, RequestBridgeEvent, RequestConnectEvent, RequestOnrampEvent, RequestSwapEvent, RequestWalletEvent, SemanticVersion, SendTransactionParams, SendTransactionResult, SwapEventType, SwapFailed, SwapReact, SwapReactProps, SwapRejected, SwapSuccess, SwitchNetworkParams, SwitchNetworkResult, TokenFilter, TokenFilterTypes, TokenInfo, UpdateConfig, UserProfile, WalletDisconnectWalletEvent, WalletEventType, WalletFilter, WalletFilterTypes, WalletInfo, WalletNetworkSwitchEvent, WalletProviderName, WalletReact, WalletReactProps, WidgetEvent, WidgetTheme, createStarkSigner as imxClientCreateStarkSigner, generateLegacyStarkPrivateKey as imxClientGenerateLegacyStarkPrivateKey, module };
|
|
28519
|
+
export { APIError, ActivityType, AllowedNetworkConfig, BlockchainData, BlockchainDataModuleConfiguration, BridgeEventType, BridgeFailed, BridgeReact, BridgeReactProps, BridgeSuccess, CHECKOUT_API_BASE_URL, ChainId, ChainName, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutErrorType, CheckoutModuleConfiguration, CheckoutWidgetTagNames, CheckoutWidgets, CheckoutWidgetsConfig, ConnectEventType, ConnectParams, ConnectReact, ConnectResult, ConnectionFailed, ConnectionSuccess, DeviceConnectResponse, DeviceTokenResponse, DexConfig, ERC20, ERC721PermissionedMintable, Environment, ErrorType, GasEstimateBridgeToL2Result, GasEstimateParams, GasEstimateSwapResult, GasEstimateTokenConfig, GasEstimateType, GenericIMXProvider, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetWalletAllowListParams, GetWalletAllowListResult, IMTBLWidgetEvents, IMXProvider, ImmutableConfiguration, ImmutableXClient, ImtblBridgeProps, ImtblConnectProps, ImtblSwapProps, ImtblWalletProps, ImxModuleConfiguration as ImxClientModuleConfiguration, WalletConnection as ImxClientWalletConnection, MetaMaskIMXProvider, ModuleConfiguration, NetworkFilter, NetworkFilterTypes, NetworkInfo, Networks, OrchestrationEventType, Orderbook, Passport, PassportError, PassportModuleConfiguration, PassportOverrides, ProviderConfiguration, RemoteConfiguration, RequestBridgeEvent, RequestConnectEvent, RequestOnrampEvent, RequestSwapEvent, RequestWalletEvent, SemanticVersion, SendTransactionParams, SendTransactionResult, SwapEventType, SwapFailed, SwapReact, SwapReactProps, SwapRejected, SwapSuccess, SwitchNetworkParams, SwitchNetworkResult, TokenFilter, TokenFilterTypes, TokenInfo, UpdateConfig, UserProfile, WalletDisconnectWalletEvent, WalletEventType, WalletFilter, WalletFilterTypes, WalletInfo, WalletNetworkSwitchEvent, WalletProviderName, WalletReact, WalletReactProps, WidgetEvent, WidgetTheme, createStarkSigner as imxClientCreateStarkSigner, generateLegacyStarkPrivateKey as imxClientGenerateLegacyStarkPrivateKey, module };
|