@imtbl/sdk 0.22.1 → 0.22.3
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 +409 -171
- package/dist/checkout_sdk.js +265 -177
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +12 -12
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +304 -192
- package/dist/index.d.ts +434 -182
- package/dist/index.js +304 -192
- package/dist/passport.js +38 -15
- package/package.json +2 -1
package/dist/passport.js
CHANGED
|
@@ -1785,7 +1785,7 @@ class MultiRollupApiClients {
|
|
|
1785
1785
|
}
|
|
1786
1786
|
|
|
1787
1787
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1788
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.22.
|
|
1788
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.22.3' };
|
|
1789
1789
|
const createConfig = ({ basePath, headers, }) => {
|
|
1790
1790
|
if (!basePath.trim()) {
|
|
1791
1791
|
throw Error('basePath can not be empty');
|
|
@@ -1841,7 +1841,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
1841
1841
|
chainID,
|
|
1842
1842
|
coreContractAddress,
|
|
1843
1843
|
registrationContractAddress,
|
|
1844
|
-
sdkVersion: 'ts-immutable-sdk-0.22.
|
|
1844
|
+
sdkVersion: 'ts-immutable-sdk-0.22.3',
|
|
1845
1845
|
});
|
|
1846
1846
|
/**
|
|
1847
1847
|
* Sets `sdkVersion` at the time of build
|
|
@@ -6394,6 +6394,22 @@ class DeviceCredentialsManager {
|
|
|
6394
6394
|
}
|
|
6395
6395
|
}
|
|
6396
6396
|
|
|
6397
|
+
function isIdTokenExpired(idToken) {
|
|
6398
|
+
if (!idToken) {
|
|
6399
|
+
return false;
|
|
6400
|
+
}
|
|
6401
|
+
const decodedToken = jwt_decode(idToken);
|
|
6402
|
+
const now = Math.floor(Date.now() / 1000);
|
|
6403
|
+
return decodedToken.exp < now;
|
|
6404
|
+
}
|
|
6405
|
+
function isTokenExpired(oidcUser) {
|
|
6406
|
+
const { id_token: idToken, expired } = oidcUser;
|
|
6407
|
+
if (expired) {
|
|
6408
|
+
return true;
|
|
6409
|
+
}
|
|
6410
|
+
return isIdTokenExpired(idToken);
|
|
6411
|
+
}
|
|
6412
|
+
|
|
6397
6413
|
const formUrlEncodedHeader = {
|
|
6398
6414
|
headers: {
|
|
6399
6415
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
@@ -6671,23 +6687,30 @@ class AuthManager {
|
|
|
6671
6687
|
}, PassportErrorType.LOGOUT_ERROR);
|
|
6672
6688
|
}
|
|
6673
6689
|
async loginSilent() {
|
|
6674
|
-
return withPassportError(async () =>
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6690
|
+
return withPassportError(async () => this.getUser(), PassportErrorType.SILENT_LOGIN_ERROR);
|
|
6691
|
+
}
|
|
6692
|
+
async getWebUser() {
|
|
6693
|
+
const oidcUser = await this.userManager.getUser();
|
|
6694
|
+
if (!oidcUser) {
|
|
6695
|
+
return null;
|
|
6696
|
+
}
|
|
6697
|
+
const tokenExpired = isTokenExpired(oidcUser);
|
|
6698
|
+
if (!tokenExpired) {
|
|
6683
6699
|
return AuthManager.mapOidcUserToDomainModel(oidcUser);
|
|
6684
|
-
}
|
|
6700
|
+
}
|
|
6701
|
+
if (oidcUser.refresh_token) {
|
|
6702
|
+
const newOidcUser = await this.userManager.signinSilent();
|
|
6703
|
+
if (newOidcUser) {
|
|
6704
|
+
return AuthManager.mapOidcUserToDomainModel(newOidcUser);
|
|
6705
|
+
}
|
|
6706
|
+
}
|
|
6707
|
+
return null;
|
|
6685
6708
|
}
|
|
6686
6709
|
async getUser() {
|
|
6687
6710
|
return withPassportError(async () => {
|
|
6688
|
-
const
|
|
6689
|
-
if (
|
|
6690
|
-
return
|
|
6711
|
+
const user = await this.getWebUser();
|
|
6712
|
+
if (user) {
|
|
6713
|
+
return user;
|
|
6691
6714
|
}
|
|
6692
6715
|
const deviceToken = this.deviceCredentialsManager.getCredentials();
|
|
6693
6716
|
if (deviceToken) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imtbl/sdk",
|
|
3
3
|
"description": "Immutable Unified SDK",
|
|
4
|
-
"version": "0.22.
|
|
4
|
+
"version": "0.22.3",
|
|
5
5
|
"author": "Immutable",
|
|
6
6
|
"browser": "./dist/index.browser.js",
|
|
7
7
|
"bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"bn.js": "^5.2.1",
|
|
25
25
|
"enc-utils": "^3.0.0",
|
|
26
26
|
"ethers": "^5.7.2",
|
|
27
|
+
"jwt-decode": "^3.1.2",
|
|
27
28
|
"magic-sdk": "^13.3.1",
|
|
28
29
|
"oidc-client-ts": "^2.2.1"
|
|
29
30
|
},
|