@dynamic-labs/embedded-wallet-solana 4.30.4 → 4.31.1

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/CHANGELOG.md CHANGED
@@ -1,4 +1,22 @@
1
1
 
2
+ ### [4.31.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.31.0...v4.31.1) (2025-09-10)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * convert y parity to number instead of bigint ([#9476](https://github.com/dynamic-labs/dynamic-auth/issues/9476)) ([1e779ef](https://github.com/dynamic-labs/dynamic-auth/commit/1e779ef4217877b15857e6f8cd4e02da5d7830df))
8
+
9
+ ## [4.31.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.30.4...v4.31.0) (2025-09-09)
10
+
11
+ ### Features
12
+
13
+ * adds evmNetworks prop for the react native client ([#9429](https://github.com/dynamic-labs/dynamic-auth/pull/9429))
14
+ * allow creating a mfaToken on authenticateRecoveryCode ([#9459](https://github.com/dynamic-labs/dynamic-auth/pull/9459))
15
+
16
+ ### Bug Fixes
17
+
18
+ * fixed the yParity conversion in unFormatTransaction ([#9457](https://github.com/dynamic-labs/dynamic-auth/pull/9457))
19
+
2
20
  ### [4.30.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.30.3...v4.30.4) (2025-09-09)
3
21
 
4
22
 
package/package.cjs CHANGED
@@ -3,18 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.30.4";
7
- var dependencies = {
8
- "@dynamic-labs/utils": "4.30.4",
9
- "@dynamic-labs/logger": "4.30.4",
10
- "@dynamic-labs/types": "4.30.4",
11
- "@dynamic-labs/sdk-api-core": "0.0.762",
12
- eventemitter3: "5.0.1",
13
- "@solana/web3.js": "1.98.1",
14
- "@turnkey/iframe-stamper": "2.5.0",
15
- "@turnkey/solana": "1.0.42",
16
- "@turnkey/webauthn-stamper": "0.5.1"
17
- };
6
+ var version = "4.31.1";
18
7
 
19
- exports.dependencies = dependencies;
20
8
  exports.version = version;
package/package.js CHANGED
@@ -1,15 +1,4 @@
1
1
  'use client'
2
- var version = "4.30.4";
3
- var dependencies = {
4
- "@dynamic-labs/utils": "4.30.4",
5
- "@dynamic-labs/logger": "4.30.4",
6
- "@dynamic-labs/types": "4.30.4",
7
- "@dynamic-labs/sdk-api-core": "0.0.762",
8
- eventemitter3: "5.0.1",
9
- "@solana/web3.js": "1.98.1",
10
- "@turnkey/iframe-stamper": "2.5.0",
11
- "@turnkey/solana": "1.0.42",
12
- "@turnkey/webauthn-stamper": "0.5.1"
13
- };
2
+ var version = "4.31.1";
14
3
 
15
- export { dependencies, version };
4
+ export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/embedded-wallet-solana",
3
- "version": "4.30.4",
3
+ "version": "4.31.1",
4
4
  "description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
5
5
  "author": "Dynamic Labs, Inc.",
6
6
  "license": "MIT",
@@ -18,22 +18,21 @@
18
18
  },
19
19
  "homepage": "https://www.dynamic.xyz/",
20
20
  "dependencies": {
21
- "@dynamic-labs/utils": "4.30.4",
22
- "@dynamic-labs/logger": "4.30.4",
23
- "@dynamic-labs/types": "4.30.4",
21
+ "@dynamic-labs/utils": "4.31.1",
22
+ "@dynamic-labs/types": "4.31.1",
24
23
  "@dynamic-labs/sdk-api-core": "0.0.762",
25
- "eventemitter3": "5.0.1",
24
+ "@dynamic-labs-sdk/client": "0.1.0-alpha.3",
26
25
  "@solana/web3.js": "1.98.1",
27
26
  "@turnkey/iframe-stamper": "2.5.0",
28
27
  "@turnkey/solana": "1.0.42",
29
28
  "@turnkey/webauthn-stamper": "0.5.1",
30
- "@dynamic-labs/assert-package-version": "4.30.4",
31
- "@dynamic-labs/embedded-wallet": "4.30.4",
32
- "@dynamic-labs/rpc-providers": "4.30.4",
33
- "@dynamic-labs/solana-core": "4.30.4",
34
- "@dynamic-labs/wallet-book": "4.30.4",
35
- "@dynamic-labs/wallet-connector-core": "4.30.4",
36
- "@dynamic-labs/webauthn": "4.30.4",
29
+ "@dynamic-labs/assert-package-version": "4.31.1",
30
+ "@dynamic-labs/embedded-wallet": "4.31.1",
31
+ "@dynamic-labs/rpc-providers": "4.31.1",
32
+ "@dynamic-labs/solana-core": "4.31.1",
33
+ "@dynamic-labs/wallet-book": "4.31.1",
34
+ "@dynamic-labs/wallet-connector-core": "4.31.1",
35
+ "@dynamic-labs/webauthn": "4.31.1",
37
36
  "viem": "2.29.0"
38
37
  },
39
38
  "peerDependencies": {}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../../_virtual/_tslib.cjs');
7
7
  var web3_js = require('@solana/web3.js');
8
- var SdkApi = require('./utils/SdkApi.cjs');
8
+ var core = require('@dynamic-labs-sdk/client/core');
9
9
 
10
10
  const serializeTransaction = (transaction) => {
11
11
  if (transaction instanceof web3_js.VersionedTransaction) {
@@ -28,7 +28,7 @@ const optimizeSolanaTransaction = (environmentId, transaction, address) => _tsli
28
28
  transaction: serializedTransaction,
29
29
  },
30
30
  };
31
- const response = yield SdkApi.sdkApi().optimizeTransaction(request);
31
+ const response = yield core.createApiClient({}, core.getDefaultClient()).optimizeTransaction(request);
32
32
  const optimizedTransaction = deserializeTransaction(response.transaction);
33
33
  return optimizedTransaction;
34
34
  });
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../_virtual/_tslib.js';
3
3
  import { VersionedTransaction } from '@solana/web3.js';
4
- import { sdkApi } from './utils/SdkApi.js';
4
+ import { createApiClient, getDefaultClient } from '@dynamic-labs-sdk/client/core';
5
5
 
6
6
  const serializeTransaction = (transaction) => {
7
7
  if (transaction instanceof VersionedTransaction) {
@@ -24,7 +24,7 @@ const optimizeSolanaTransaction = (environmentId, transaction, address) => __awa
24
24
  transaction: serializedTransaction,
25
25
  },
26
26
  };
27
- const response = yield sdkApi().optimizeTransaction(request);
27
+ const response = yield createApiClient({}, getDefaultClient()).optimizeTransaction(request);
28
28
  const optimizedTransaction = deserializeTransaction(response.transaction);
29
29
  return optimizedTransaction;
30
30
  });
@@ -1,6 +0,0 @@
1
- import EventEmitter from 'eventemitter3';
2
- import { AuthEvents } from './auth';
3
- /** Maps internal event names to their listeners */
4
- export type DynamicEvents = AuthEvents;
5
- export declare const dynamicEvents: EventEmitter<AuthEvents, any>;
6
- export type DynamicEventEmitter = typeof dynamicEvents;
@@ -1,51 +0,0 @@
1
- import { AuthMethod, AuthOptions } from '@dynamic-labs/types';
2
- /**
3
- * Maps auth methods to what property will be displayed under the "option" property of the event.
4
- *
5
- * Users will be able to access this data through the AuthOptions[K] type injection as well,
6
- * but with the "option" property they will also have a standard way to access the auth method target.
7
- */
8
- type AuthEventPayloadOptionMap = {
9
- wallet: AuthOptions['wallet']['connectorName'];
10
- sms: AuthOptions['sms']['phone'];
11
- email: AuthOptions['email']['email'];
12
- social: AuthOptions['social']['provider'];
13
- externalAuth: AuthOptions['externalAuth']['externalUserId'];
14
- };
15
- /** Payload of auth events that provide insight into which auth method was selected */
16
- export type AuthEventPayload = {
17
- [K in AuthMethod]: {
18
- type: K;
19
- option: AuthEventPayloadOptionMap[K];
20
- } & AuthOptions[K];
21
- }[AuthMethod];
22
- export type AuthEvents = {
23
- /**
24
- * Informs an auth attempt failed.
25
- * In general triggered when an error occurs or when user cancels out.
26
- * For email/sms, specifically happens when users cancels the OTP verification.
27
- */
28
- authFailure: (method: AuthEventPayload,
29
- /** Will be 'user-cancelled' when cancelled, or the error when there is an error */
30
- reason: 'user-cancelled' | {
31
- error: unknown;
32
- }) => void;
33
- /** Informs an auth attempt initialized, and provides insight into which auth option it is */
34
- authInit: (method: AuthEventPayload) => void;
35
- logout: () => void;
36
- /** This event is used to trigger logout to be called, DO NOT listen to it. Listen to "logout" instead */
37
- triggerLogout: () => void;
38
- /**
39
- * Emitted when the user succesfully completes an MFA challenge
40
- */
41
- mfaCompletionSuccess: (args: {
42
- mfaToken?: string;
43
- }) => void;
44
- /**
45
- * Emitted when there is an error verifiyng the MFA challenge
46
- */
47
- mfaCompletionFailure: (args: {
48
- error: unknown;
49
- }) => void;
50
- };
51
- export {};
@@ -1,41 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- var sdkApiCore = require('@dynamic-labs/sdk-api-core');
5
-
6
- /* eslint-disable no-underscore-dangle */
7
- class ApiEndpoint {
8
- }
9
- ApiEndpoint.getBaseUrl = () => {
10
- if (!ApiEndpoint.__defined__) {
11
- throw new Error('ApiEndpoint Base URL has not been initialized');
12
- }
13
- return ApiEndpoint.__baseUrl__;
14
- };
15
- ApiEndpoint.setBaseUrl = (baseUrlInput) => {
16
- if (!ApiEndpoint.__defined__) {
17
- if (!baseUrlInput) {
18
- /**
19
- * If the baseUrl is not provided, use the default baseUrl from the sdk-api package
20
- */
21
- ApiEndpoint.__baseUrl__ = new sdkApiCore.Configuration().basePath;
22
- }
23
- else {
24
- ApiEndpoint.__baseUrl__ = baseUrlInput;
25
- }
26
- ApiEndpoint.__defined__ = true;
27
- }
28
- else if (!baseUrlInput && ApiEndpoint.__defined__) {
29
- /**
30
- * If for some reason (usually in local development), the setBaseUrl is called multiple times with undefined
31
- * And we already have it defined, let's just assume it's a no-op
32
- */
33
- return;
34
- }
35
- else if (ApiEndpoint.__baseUrl__ !== baseUrlInput) {
36
- throw new Error(`ApiEndpoint baseUrl is already set to ${ApiEndpoint.__baseUrl__}, cannot change it to ${baseUrlInput}`);
37
- }
38
- Object.freeze(ApiEndpoint);
39
- };
40
-
41
- module.exports = ApiEndpoint;
@@ -1,7 +0,0 @@
1
- declare class ApiEndpoint {
2
- private static __baseUrl__;
3
- private static __defined__;
4
- static getBaseUrl: () => string | undefined;
5
- static setBaseUrl: (baseUrlInput?: string) => void;
6
- }
7
- export default ApiEndpoint;
@@ -1,39 +0,0 @@
1
- 'use client'
2
- import { Configuration } from '@dynamic-labs/sdk-api-core';
3
-
4
- /* eslint-disable no-underscore-dangle */
5
- class ApiEndpoint {
6
- }
7
- ApiEndpoint.getBaseUrl = () => {
8
- if (!ApiEndpoint.__defined__) {
9
- throw new Error('ApiEndpoint Base URL has not been initialized');
10
- }
11
- return ApiEndpoint.__baseUrl__;
12
- };
13
- ApiEndpoint.setBaseUrl = (baseUrlInput) => {
14
- if (!ApiEndpoint.__defined__) {
15
- if (!baseUrlInput) {
16
- /**
17
- * If the baseUrl is not provided, use the default baseUrl from the sdk-api package
18
- */
19
- ApiEndpoint.__baseUrl__ = new Configuration().basePath;
20
- }
21
- else {
22
- ApiEndpoint.__baseUrl__ = baseUrlInput;
23
- }
24
- ApiEndpoint.__defined__ = true;
25
- }
26
- else if (!baseUrlInput && ApiEndpoint.__defined__) {
27
- /**
28
- * If for some reason (usually in local development), the setBaseUrl is called multiple times with undefined
29
- * And we already have it defined, let's just assume it's a no-op
30
- */
31
- return;
32
- }
33
- else if (ApiEndpoint.__baseUrl__ !== baseUrlInput) {
34
- throw new Error(`ApiEndpoint baseUrl is already set to ${ApiEndpoint.__baseUrl__}, cannot change it to ${baseUrlInput}`);
35
- }
36
- Object.freeze(ApiEndpoint);
37
- };
38
-
39
- export { ApiEndpoint as default };
@@ -1,35 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var sdkApiCore = require('@dynamic-labs/sdk-api-core');
7
- var utils = require('@dynamic-labs/utils');
8
- var helpers = require('./helpers.cjs');
9
- var ApiEndpoint = require('./ApiEndpoint.cjs');
10
- var version = require('./version.cjs');
11
-
12
- const sdkApi = () => {
13
- const baseUrl = process.env.API_BASE_URL ||
14
- process.env.NX_API_BASE_URL ||
15
- 'https://app.dynamic.xyz/api/v0';
16
- ApiEndpoint.setBaseUrl(baseUrl);
17
- const settings = {
18
- basePath: ApiEndpoint.getBaseUrl(),
19
- headers: {
20
- 'Content-Type': 'application/json',
21
- },
22
- };
23
- const minJwt = helpers.getMinAuthToken();
24
- if (minJwt) {
25
- settings.headers.Authorization = `Bearer ${minJwt}`;
26
- }
27
- const credentials = helpers.isCookieEnabled()
28
- ? 'include'
29
- : undefined;
30
- settings.headers['x-dyn-version'] = `WalletKit/${version.VERSION}`;
31
- settings.headers['x-dyn-api-version'] = `API/${version.API_VERSION}`;
32
- return new sdkApiCore.SDKApi(new sdkApiCore.Configuration(Object.assign(Object.assign({}, settings), { credentials, fetchApi: utils.FetchService.fetch })));
33
- };
34
-
35
- exports.sdkApi = sdkApi;
@@ -1,2 +0,0 @@
1
- import { SDKApi } from '@dynamic-labs/sdk-api-core';
2
- export declare const sdkApi: () => SDKApi;
@@ -1,31 +0,0 @@
1
- 'use client'
2
- import { SDKApi, Configuration } from '@dynamic-labs/sdk-api-core';
3
- import { FetchService } from '@dynamic-labs/utils';
4
- import { getMinAuthToken, isCookieEnabled } from './helpers.js';
5
- import ApiEndpoint from './ApiEndpoint.js';
6
- import { VERSION, API_VERSION } from './version.js';
7
-
8
- const sdkApi = () => {
9
- const baseUrl = process.env.API_BASE_URL ||
10
- process.env.NX_API_BASE_URL ||
11
- 'https://app.dynamic.xyz/api/v0';
12
- ApiEndpoint.setBaseUrl(baseUrl);
13
- const settings = {
14
- basePath: ApiEndpoint.getBaseUrl(),
15
- headers: {
16
- 'Content-Type': 'application/json',
17
- },
18
- };
19
- const minJwt = getMinAuthToken();
20
- if (minJwt) {
21
- settings.headers.Authorization = `Bearer ${minJwt}`;
22
- }
23
- const credentials = isCookieEnabled()
24
- ? 'include'
25
- : undefined;
26
- settings.headers['x-dyn-version'] = `WalletKit/${VERSION}`;
27
- settings.headers['x-dyn-api-version'] = `API/${API_VERSION}`;
28
- return new SDKApi(new Configuration(Object.assign(Object.assign({}, settings), { credentials, fetchApi: FetchService.fetch })));
29
- };
30
-
31
- export { sdkApi };
@@ -1,92 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var sdkApiCore = require('@dynamic-labs/sdk-api-core');
7
- var logger$1 = require('@dynamic-labs/logger');
8
- var utils = require('@dynamic-labs/utils');
9
-
10
- const logger = new logger$1.Logger('DynamicSDK');
11
- const AUTH_MIN_TOKEN = 'dynamic_min_authentication_token';
12
- const AUTH_MIN_TOKEN_DEMO = 'dynamic_min_authentication_token_demo';
13
- const isCookieEnabled = () => {
14
- var _a, _b, _c, _d;
15
- let securitySettings = (_a = utils.StorageService.getItem('dynamic_store')) !== null && _a !== void 0 ? _a : utils.StorageService.getItem('dynamic_store_demo');
16
- securitySettings = (_b = securitySettings === null || securitySettings === void 0 ? void 0 : securitySettings.settings) === null || _b === void 0 ? void 0 : _b.security;
17
- if (!securitySettings)
18
- return false;
19
- // client uses Dynamic cookies
20
- const dynamicCookiesEnabled = (((_c = securitySettings.auth) === null || _c === void 0 ? void 0 : _c.storage) || []).includes(sdkApiCore.AuthStorageEnum.Cookie);
21
- // BYO JWT client puts their non-Dynamic JWT in a cookie
22
- const byoJwtCookieEnabled = Boolean((_d = securitySettings.externalAuth) === null || _d === void 0 ? void 0 : _d.cookieName);
23
- // should return true for both of these scenarios
24
- // because we also need to do `credentials: true` in api.ts when
25
- // a byo jwt client sets their named cookie for their jwt and
26
- // needs to send it to our backend
27
- return dynamicCookiesEnabled || byoJwtCookieEnabled;
28
- };
29
- const parseToken = (token) => {
30
- var _a;
31
- if (!token)
32
- return undefined;
33
- const base64 = (_a = token.split('.')[1]) === null || _a === void 0 ? void 0 : _a.replace(/-/g, '+').replace(/_/g, '/');
34
- const jsonPayload = base64 &&
35
- decodeURIComponent(atob(base64)
36
- .split('')
37
- .map((c) => `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`)
38
- .join(''));
39
- return JSON.parse(jsonPayload);
40
- };
41
- const decodeMinJwt = (token) => {
42
- try {
43
- const json = parseToken(token);
44
- if (!json)
45
- return undefined;
46
- return sdkApiCore.MinifiedDynamicJwtFromJSON(json);
47
- }
48
- catch (e) {
49
- logger.error(e);
50
- return undefined;
51
- }
52
- };
53
- const getMinAuthToken = () => {
54
- var _a;
55
- if (typeof window === 'undefined')
56
- return undefined;
57
- const token = (_a = utils.StorageService.getItem(AUTH_MIN_TOKEN, {
58
- priority: ['secureStorage', 'localStorage'],
59
- })) !== null && _a !== void 0 ? _a : utils.StorageService.getItem(AUTH_MIN_TOKEN_DEMO, {
60
- priority: ['secureStorage', 'localStorage'],
61
- });
62
- if (!token || isMinAuthTokenExpired(token))
63
- return undefined;
64
- return token;
65
- };
66
- const isMinAuthTokenExpired = (token) => {
67
- const decoded = decodeMinJwt(token);
68
- return isTokenExpired(decoded);
69
- };
70
- const isTokenExpired = (decoded) => {
71
- if (!decoded) {
72
- return true;
73
- }
74
- if (!decoded.exp) {
75
- return true;
76
- }
77
- const expirationTime = new Date(decoded.exp * 1000).getTime();
78
- const currentTime = new Date().getTime();
79
- if (currentTime >= expirationTime) {
80
- return true;
81
- }
82
- return false;
83
- };
84
-
85
- exports.AUTH_MIN_TOKEN = AUTH_MIN_TOKEN;
86
- exports.AUTH_MIN_TOKEN_DEMO = AUTH_MIN_TOKEN_DEMO;
87
- exports.decodeMinJwt = decodeMinJwt;
88
- exports.getMinAuthToken = getMinAuthToken;
89
- exports.isCookieEnabled = isCookieEnabled;
90
- exports.isMinAuthTokenExpired = isMinAuthTokenExpired;
91
- exports.logger = logger;
92
- exports.parseToken = parseToken;
@@ -1,12 +0,0 @@
1
- import { MinifiedDynamicJwt } from '@dynamic-labs/sdk-api-core';
2
- import { Logger } from '@dynamic-labs/logger';
3
- export declare const logger: Logger;
4
- export declare const AUTH_MIN_TOKEN = "dynamic_min_authentication_token";
5
- export declare const AUTH_MIN_TOKEN_DEMO = "dynamic_min_authentication_token_demo";
6
- export declare const DYNAMIC_STORE_DEMO = "dynamic_store_demo";
7
- export declare const DYNAMIC_STORE = "dynamic_store";
8
- export declare const isCookieEnabled: () => any;
9
- export declare const parseToken: (token: string | null | undefined) => any;
10
- export declare const decodeMinJwt: (token: string | null | undefined) => Omit<MinifiedDynamicJwt, 'jwt'> | undefined;
11
- export declare const getMinAuthToken: () => string | undefined;
12
- export declare const isMinAuthTokenExpired: (token: string) => boolean;
@@ -1,81 +0,0 @@
1
- 'use client'
2
- import { AuthStorageEnum, MinifiedDynamicJwtFromJSON } from '@dynamic-labs/sdk-api-core';
3
- import { Logger } from '@dynamic-labs/logger';
4
- import { StorageService } from '@dynamic-labs/utils';
5
-
6
- const logger = new Logger('DynamicSDK');
7
- const AUTH_MIN_TOKEN = 'dynamic_min_authentication_token';
8
- const AUTH_MIN_TOKEN_DEMO = 'dynamic_min_authentication_token_demo';
9
- const isCookieEnabled = () => {
10
- var _a, _b, _c, _d;
11
- let securitySettings = (_a = StorageService.getItem('dynamic_store')) !== null && _a !== void 0 ? _a : StorageService.getItem('dynamic_store_demo');
12
- securitySettings = (_b = securitySettings === null || securitySettings === void 0 ? void 0 : securitySettings.settings) === null || _b === void 0 ? void 0 : _b.security;
13
- if (!securitySettings)
14
- return false;
15
- // client uses Dynamic cookies
16
- const dynamicCookiesEnabled = (((_c = securitySettings.auth) === null || _c === void 0 ? void 0 : _c.storage) || []).includes(AuthStorageEnum.Cookie);
17
- // BYO JWT client puts their non-Dynamic JWT in a cookie
18
- const byoJwtCookieEnabled = Boolean((_d = securitySettings.externalAuth) === null || _d === void 0 ? void 0 : _d.cookieName);
19
- // should return true for both of these scenarios
20
- // because we also need to do `credentials: true` in api.ts when
21
- // a byo jwt client sets their named cookie for their jwt and
22
- // needs to send it to our backend
23
- return dynamicCookiesEnabled || byoJwtCookieEnabled;
24
- };
25
- const parseToken = (token) => {
26
- var _a;
27
- if (!token)
28
- return undefined;
29
- const base64 = (_a = token.split('.')[1]) === null || _a === void 0 ? void 0 : _a.replace(/-/g, '+').replace(/_/g, '/');
30
- const jsonPayload = base64 &&
31
- decodeURIComponent(atob(base64)
32
- .split('')
33
- .map((c) => `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`)
34
- .join(''));
35
- return JSON.parse(jsonPayload);
36
- };
37
- const decodeMinJwt = (token) => {
38
- try {
39
- const json = parseToken(token);
40
- if (!json)
41
- return undefined;
42
- return MinifiedDynamicJwtFromJSON(json);
43
- }
44
- catch (e) {
45
- logger.error(e);
46
- return undefined;
47
- }
48
- };
49
- const getMinAuthToken = () => {
50
- var _a;
51
- if (typeof window === 'undefined')
52
- return undefined;
53
- const token = (_a = StorageService.getItem(AUTH_MIN_TOKEN, {
54
- priority: ['secureStorage', 'localStorage'],
55
- })) !== null && _a !== void 0 ? _a : StorageService.getItem(AUTH_MIN_TOKEN_DEMO, {
56
- priority: ['secureStorage', 'localStorage'],
57
- });
58
- if (!token || isMinAuthTokenExpired(token))
59
- return undefined;
60
- return token;
61
- };
62
- const isMinAuthTokenExpired = (token) => {
63
- const decoded = decodeMinJwt(token);
64
- return isTokenExpired(decoded);
65
- };
66
- const isTokenExpired = (decoded) => {
67
- if (!decoded) {
68
- return true;
69
- }
70
- if (!decoded.exp) {
71
- return true;
72
- }
73
- const expirationTime = new Date(decoded.exp * 1000).getTime();
74
- const currentTime = new Date().getTime();
75
- if (currentTime >= expirationTime) {
76
- return true;
77
- }
78
- return false;
79
- };
80
-
81
- export { AUTH_MIN_TOKEN, AUTH_MIN_TOKEN_DEMO, decodeMinJwt, getMinAuthToken, isCookieEnabled, isMinAuthTokenExpired, logger, parseToken };
@@ -1,12 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var _package = require('../../../../../package.cjs');
7
-
8
- const VERSION = _package.version;
9
- const API_VERSION = _package.dependencies['@dynamic-labs/sdk-api-core'];
10
-
11
- exports.API_VERSION = API_VERSION;
12
- exports.VERSION = VERSION;
@@ -1,2 +0,0 @@
1
- export declare const VERSION: string;
2
- export declare const API_VERSION: string;
@@ -1,7 +0,0 @@
1
- 'use client'
2
- import { version, dependencies } from '../../../../../package.js';
3
-
4
- const VERSION = version;
5
- const API_VERSION = dependencies['@dynamic-labs/sdk-api-core'];
6
-
7
- export { API_VERSION, VERSION };