@dynamic-labs-sdk/client 0.1.0-alpha.3 → 0.1.0-alpha.4

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,3 +1,9 @@
1
+ ## 0.1.0-alpha.4 (2025-09-10)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - set client version to project settings api call ([#414](https://github.com/dynamic-labs/dynamic-sdk/pull/414))
6
+
1
7
  ## 0.1.0-alpha.3 (2025-09-09)
2
8
 
3
9
  This was a version bump only, there were no code changes.
package/core.cjs.js CHANGED
@@ -258,6 +258,7 @@ exports.formatWalletProviderKey = getWalletProviderByKey.formatWalletProviderKey
258
258
  exports.getWalletProviderFromWalletAccount = getWalletProviderByKey.getWalletProviderFromWalletAccount;
259
259
  exports.getWalletProviderRegistry = getWalletProviderByKey.getWalletProviderRegistry;
260
260
  exports.getWalletProviders = getWalletProviderByKey.getWalletProviders;
261
+ exports.updateAuthFromVerifyResponse = getWalletProviderByKey.updateAuthFromVerifyResponse;
261
262
  exports.consumeMfaTokenIfRequiredForAction = getSignedSessionId.consumeMfaTokenIfRequiredForAction;
262
263
  exports.getSignedSessionId = getSignedSessionId.getSignedSessionId;
263
264
  exports.ClientsDoNotMatchError = ClientsDoNotMatchError;
package/core.esm.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';
2
2
  import { B as BaseError, a as getCore, e as assertDefined, b as getBuffer, n as name, v as version } from './getChainFromVerifiedCredentialChain.esm.js';
3
- export { A as APIError, h as ClientNotFoundError, D as DYNAMIC_SDK_API_VERSION, V as ValueMustBeDefinedError, c as createApiClient, j as getChainFromVerifiedCredentialChain, g as getDefaultClient, i as isCookieEnabled } from './getChainFromVerifiedCredentialChain.esm.js';
3
+ export { A as APIError, i as ClientNotFoundError, D as DYNAMIC_SDK_API_VERSION, V as ValueMustBeDefinedError, c as createApiClient, k as getChainFromVerifiedCredentialChain, g as getDefaultClient, j as isCookieEnabled } from './getChainFromVerifiedCredentialChain.esm.js';
4
4
  import { c as createStorageKeySchema, d as getNetworkProviders, N as NoNetworkProvidersError } from './getNetworkProviderFromNetworkId.esm.js';
5
5
  export { C as CannotTrackError, I as InvalidStorageSet, a as createLogger, f as formatSignInMessage, e as getNetworkProviderBuilderRegistry, b as getNetworkProviderFromNetworkId, h as hasExtension, s as subscribeWithSelector } from './getNetworkProviderFromNetworkId.esm.js';
6
- import { a as getWalletProviderByKey, f as createRuntimeServiceAccessKey } from './getWalletProviderByKey.esm.js';
7
- export { N as NoWalletProviderFoundError, W as WalletProviderPriority, e as emitEvent, h as formatWalletProviderKey, g as getWalletProviderFromWalletAccount, i as getWalletProviderRegistry, b as getWalletProviders } from './getWalletProviderByKey.esm.js';
6
+ import { b as getWalletProviderByKey, j as createRuntimeServiceAccessKey } from './getWalletProviderByKey.esm.js';
7
+ export { N as NoWalletProviderFoundError, W as WalletProviderPriority, e as emitEvent, k as formatWalletProviderKey, a as getWalletProviderFromWalletAccount, l as getWalletProviderRegistry, f as getWalletProviders, u as updateAuthFromVerifyResponse } from './getWalletProviderByKey.esm.js';
8
8
  export { c as consumeMfaTokenIfRequiredForAction, g as getSignedSessionId } from './getSignedSessionId.esm.js';
9
9
  import * as z from 'zod/mini';
10
10
  import EventEmitter from 'eventemitter3';
@@ -4,7 +4,7 @@ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
4
4
  var buffer = require('buffer');
5
5
 
6
6
  var name = "@dynamic-labs-sdk/client";
7
- var version = "0.1.0-alpha.3";
7
+ var version = "0.1.0-alpha.4";
8
8
  var dependencies = {
9
9
  "@dynamic-labs/sdk-api-core": "0.0.762"};
10
10
 
@@ -449,6 +449,7 @@ const getChainFromVerifiedCredentialChain = (verifiedCredentialChain)=>{
449
449
  exports.APIError = APIError;
450
450
  exports.BaseError = BaseError;
451
451
  exports.CHAINS_INFO_MAP = CHAINS_INFO_MAP;
452
+ exports.CLIENT_SDK_NAME = CLIENT_SDK_NAME;
452
453
  exports.ClientNotFoundError = ClientNotFoundError;
453
454
  exports.DYNAMIC_SDK_API_VERSION = DYNAMIC_SDK_API_VERSION;
454
455
  exports.InvalidExternalAuthError = InvalidExternalAuthError;
@@ -2,7 +2,7 @@ import { AuthStorageEnum, SDKApi, Configuration } from '@dynamic-labs/sdk-api-co
2
2
  import { Buffer as Buffer$1 } from 'buffer';
3
3
 
4
4
  var name = "@dynamic-labs-sdk/client";
5
- var version = "0.1.0-alpha.3";
5
+ var version = "0.1.0-alpha.4";
6
6
  var dependencies = {
7
7
  "@dynamic-labs/sdk-api-core": "0.0.762"};
8
8
 
@@ -444,4 +444,4 @@ const getChainFromVerifiedCredentialChain = (verifiedCredentialChain)=>{
444
444
  return chain;
445
445
  };
446
446
 
447
- export { APIError as A, BaseError as B, CHAINS_INFO_MAP as C, DYNAMIC_SDK_API_VERSION as D, InvalidExternalAuthError as I, MfaInvalidOtpError as M, SandboxMaximumThresholdReachedError as S, ValueMustBeDefinedError as V, _extends as _, getCore as a, getBuffer as b, createApiClient as c, dependencies as d, assertDefined as e, MfaRateLimitedError as f, getDefaultClient as g, ClientNotFoundError as h, isCookieEnabled as i, getChainFromVerifiedCredentialChain as j, getSessionKeys as k, name as n, randomString as r, setDefaultClient as s, version as v };
447
+ export { APIError as A, BaseError as B, CLIENT_SDK_NAME as C, DYNAMIC_SDK_API_VERSION as D, InvalidExternalAuthError as I, MfaInvalidOtpError as M, SandboxMaximumThresholdReachedError as S, ValueMustBeDefinedError as V, _extends as _, getCore as a, getBuffer as b, createApiClient as c, dependencies as d, assertDefined as e, CHAINS_INFO_MAP as f, getDefaultClient as g, MfaRateLimitedError as h, ClientNotFoundError as i, isCookieEnabled as j, getChainFromVerifiedCredentialChain as k, getSessionKeys as l, name as n, randomString as r, setDefaultClient as s, version as v };
@@ -1,6 +1,6 @@
1
- import { B as BaseError, g as getDefaultClient, a as getCore, C as CHAINS_INFO_MAP, e as assertDefined } from './getChainFromVerifiedCredentialChain.esm.js';
1
+ import { B as BaseError, g as getDefaultClient, a as getCore, f as CHAINS_INFO_MAP, e as assertDefined } from './getChainFromVerifiedCredentialChain.esm.js';
2
2
  import { EventEmitter } from 'eventemitter3';
3
- import { f as createRuntimeServiceAccessKey } from './getWalletProviderByKey.esm.js';
3
+ import { j as createRuntimeServiceAccessKey } from './getWalletProviderByKey.esm.js';
4
4
 
5
5
  /**
6
6
  * Shallow compare two objects.
@@ -1,5 +1,5 @@
1
1
  import { i as isMfaRequiredForAction, c as consumeMfaToken, b as bufferToHex } from './isMfaRequiredForAction.esm.js';
2
- import { k as getSessionKeys, e as assertDefined, a as getCore } from './getChainFromVerifiedCredentialChain.esm.js';
2
+ import { l as getSessionKeys, e as assertDefined, a as getCore } from './getChainFromVerifiedCredentialChain.esm.js';
3
3
 
4
4
  const consumeMfaTokenIfRequiredForAction = async ({ mfaAction }, client)=>{
5
5
  const isRequiredForAction = await isMfaRequiredForAction({
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var getChainFromVerifiedCredentialChain = require('./getChainFromVerifiedCredentialChain.cjs.js');
4
+ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
4
5
 
5
6
  /**
6
7
  * Adds an event listener for Dynamic client events.
@@ -63,6 +64,34 @@ var getChainFromVerifiedCredentialChain = require('./getChainFromVerifiedCredent
63
64
  eventEmitter.emit(event, args);
64
65
  };
65
66
 
67
+ const normalizeAddress = (address, chain)=>{
68
+ let normalizedAddress = address;
69
+ if (normalizedAddress == null ? void 0 : normalizedAddress.startsWith('0x')) {
70
+ normalizedAddress = normalizedAddress.slice(2);
71
+ }
72
+ /**
73
+ * These are standard from CAIP-2: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md
74
+ * see also: https://github.com/ChainAgnostic/namespaces
75
+ * note: no standard namespace currently exists for flow
76
+ */ const chainsThatRequireLowercaseAddress = [
77
+ 'EVM',
78
+ 'FLOW'
79
+ ];
80
+ normalizedAddress = chainsThatRequireLowercaseAddress.includes(chain) ? normalizedAddress == null ? void 0 : normalizedAddress.toLowerCase() : normalizedAddress;
81
+ return normalizedAddress;
82
+ };
83
+
84
+ const createWalletAccountId = (chain, address)=>`${chain}-${normalizeAddress(address, chain)}`;
85
+
86
+ const convertUnverifiedWalletAccountToWalletAccount = (unverifiedWalletAccount)=>({
87
+ address: unverifiedWalletAccount.address,
88
+ chain: unverifiedWalletAccount.chain,
89
+ id: createWalletAccountId(unverifiedWalletAccount.chain, unverifiedWalletAccount.address),
90
+ lastSelectedAt: unverifiedWalletAccount.lastSelectedAt,
91
+ verifiedCredentialId: null,
92
+ walletProviderKey: unverifiedWalletAccount.walletProviderKey
93
+ });
94
+
66
95
  /**
67
96
  * Format the wallet name and chain to get a wallet provider key.
68
97
  */ const formatWalletProviderKey = (walletName, chain)=>{
@@ -70,6 +99,57 @@ var getChainFromVerifiedCredentialChain = require('./getChainFromVerifiedCredent
70
99
  return `${sanitizedWalletName}${chain.toLocaleLowerCase()}`;
71
100
  };
72
101
 
102
+ const convertVerifiedCredentialToWalletAccount = (verified)=>{
103
+ getChainFromVerifiedCredentialChain.assertDefined(verified.address, 'Missing address in verified credential');
104
+ getChainFromVerifiedCredentialChain.assertDefined(verified.chain, 'Missing chain in verified credential');
105
+ getChainFromVerifiedCredentialChain.assertDefined(verified.walletName, 'Missing wallet name in verified credential');
106
+ const chain = getChainFromVerifiedCredentialChain.getChainFromVerifiedCredentialChain(verified.chain);
107
+ const hasChainInWalletName = verified.walletName.endsWith(chain.toLowerCase());
108
+ // we need to make sure the walletProviderKey follows the correct format ([walletName][chain])
109
+ // some walletNames will follow the legacy format (e.g. "phantom" instead of "phantomsol", "metamask" instead of "metamaskevm")
110
+ // so we need to make sure we parse it correctly
111
+ const walletProviderKey = hasChainInWalletName ? verified.walletName : formatWalletProviderKey(verified.walletName, chain);
112
+ var _verified_lastSelectedAt;
113
+ return {
114
+ address: verified.address,
115
+ chain,
116
+ id: createWalletAccountId(chain, verified.address),
117
+ lastSelectedAt: (_verified_lastSelectedAt = verified.lastSelectedAt) != null ? _verified_lastSelectedAt : null,
118
+ verifiedCredentialId: verified.id,
119
+ walletProviderKey
120
+ };
121
+ };
122
+
123
+ const getWalletAccountsFromState = (state)=>{
124
+ const { unverifiedWalletAccounts, user } = state;
125
+ const walletAccountsMap = new Map();
126
+ /**
127
+ * Handle the unverified wallet accounts before the user verified credentials
128
+ * so the later verified wallet accounts can override the unverified wallet accounts
129
+ */ unverifiedWalletAccounts.forEach((unverifiedWalletAccount)=>{
130
+ const walletAccount = convertUnverifiedWalletAccountToWalletAccount(unverifiedWalletAccount);
131
+ walletAccountsMap.set(walletAccount.id, walletAccount);
132
+ });
133
+ var _user_verifiedCredentials;
134
+ /**
135
+ * Handle user verified credentials
136
+ */ const verifiedCredentials = (_user_verifiedCredentials = user == null ? void 0 : user.verifiedCredentials) != null ? _user_verifiedCredentials : [];
137
+ verifiedCredentials.filter((verified)=>verified.format === sdkApiCore.JwtVerifiedCredentialFormatEnum.Blockchain).map((verifiedWalletAccount)=>convertVerifiedCredentialToWalletAccount(verifiedWalletAccount)).forEach((verifiedWalletAccount)=>walletAccountsMap.set(verifiedWalletAccount.id, verifiedWalletAccount));
138
+ return Array.from(walletAccountsMap.values());
139
+ };
140
+
141
+ /**
142
+ * Retrieves all wallet accounts associated with the current session.
143
+ *
144
+ * This function returns both verified and unverified wallet accounts,
145
+ * combining data from user credentials and local unverified accounts.
146
+ * You can differentiate between verified and unverified wallet accounts by
147
+ * checking the `verifiedCredentialId` property.
148
+ *
149
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
150
+ * @returns An array of wallet accounts associated with the session.
151
+ */ const getWalletAccounts = (client = getChainFromVerifiedCredentialChain.getDefaultClient())=>getWalletAccountsFromState(getChainFromVerifiedCredentialChain.getCore(client).state.get());
152
+
73
153
  class NoWalletProviderFoundError extends getChainFromVerifiedCredentialChain.BaseError {
74
154
  constructor({ walletProviderKey }){
75
155
  super({
@@ -212,6 +292,45 @@ const getWalletProviderFromWalletAccount = ({ walletAccount }, client)=>{
212
292
  return walletProvider;
213
293
  };
214
294
 
295
+ /**
296
+ * Emits the `walletAccountsChanged` event.
297
+ */ const emitWalletAccountsChangedEvent = (client)=>{
298
+ const walletAccounts = getWalletAccounts(client);
299
+ emitEvent({
300
+ args: {
301
+ walletAccounts
302
+ },
303
+ event: 'walletAccountsChanged'
304
+ }, client);
305
+ };
306
+
307
+ const checkAndRaiseWalletAccountsChangedEvent = ({ previousState }, client)=>{
308
+ const core = getChainFromVerifiedCredentialChain.getCore(client);
309
+ const walletAccountsHashBefore = getWalletAccountsHash(previousState);
310
+ const walletAccountsHashAfter = getWalletAccountsHash(core.state.get());
311
+ if (walletAccountsHashBefore !== walletAccountsHashAfter) {
312
+ emitWalletAccountsChangedEvent(client);
313
+ }
314
+ };
315
+ const getWalletAccountsHash = (state)=>getWalletAccountsFromState(state).map(({ id })=>id).sort().join('-');
316
+
317
+ const updateAuthFromVerifyResponse = ({ response }, client)=>{
318
+ const core = getChainFromVerifiedCredentialChain.getCore(client);
319
+ const previousState = getChainFromVerifiedCredentialChain._extends({}, core.state.get());
320
+ const { user, minifiedJwt, jwt, expiresAt, mfaToken } = response;
321
+ core.state.set({
322
+ legacyToken: jwt != null ? jwt : null,
323
+ mfaToken: mfaToken != null ? mfaToken : null,
324
+ // Expires at is in seconds, so we need to convert it to milliseconds
325
+ sessionExpiresAt: new Date(expiresAt * 1000),
326
+ token: minifiedJwt != null ? minifiedJwt : null,
327
+ user
328
+ });
329
+ checkAndRaiseWalletAccountsChangedEvent({
330
+ previousState
331
+ }, client);
332
+ };
333
+
215
334
  /**
216
335
  * Get all available wallet providers to interact with internally.
217
336
  */ const getWalletProviders = (client)=>{
@@ -232,12 +351,17 @@ const getWalletProviderByKey = ({ walletProviderKey }, client)=>{
232
351
 
233
352
  exports.NoWalletProviderFoundError = NoWalletProviderFoundError;
234
353
  exports.createRuntimeServiceAccessKey = createRuntimeServiceAccessKey;
354
+ exports.createWalletAccountId = createWalletAccountId;
235
355
  exports.emitEvent = emitEvent;
356
+ exports.emitWalletAccountsChangedEvent = emitWalletAccountsChangedEvent;
236
357
  exports.formatWalletProviderKey = formatWalletProviderKey;
358
+ exports.getWalletAccounts = getWalletAccounts;
237
359
  exports.getWalletProviderByKey = getWalletProviderByKey;
238
360
  exports.getWalletProviderFromWalletAccount = getWalletProviderFromWalletAccount;
239
361
  exports.getWalletProviderRegistry = getWalletProviderRegistry;
240
362
  exports.getWalletProviders = getWalletProviders;
363
+ exports.normalizeAddress = normalizeAddress;
241
364
  exports.offEvent = offEvent;
242
365
  exports.onEvent = onEvent;
243
366
  exports.onceEvent = onceEvent;
367
+ exports.updateAuthFromVerifyResponse = updateAuthFromVerifyResponse;
@@ -1,4 +1,5 @@
1
- import { g as getDefaultClient, a as getCore, B as BaseError } from './getChainFromVerifiedCredentialChain.esm.js';
1
+ import { g as getDefaultClient, a as getCore, e as assertDefined, k as getChainFromVerifiedCredentialChain, B as BaseError, _ as _extends } from './getChainFromVerifiedCredentialChain.esm.js';
2
+ import { JwtVerifiedCredentialFormatEnum } from '@dynamic-labs/sdk-api-core';
2
3
 
3
4
  /**
4
5
  * Adds an event listener for Dynamic client events.
@@ -61,6 +62,34 @@ import { g as getDefaultClient, a as getCore, B as BaseError } from './getChainF
61
62
  eventEmitter.emit(event, args);
62
63
  };
63
64
 
65
+ const normalizeAddress = (address, chain)=>{
66
+ let normalizedAddress = address;
67
+ if (normalizedAddress == null ? void 0 : normalizedAddress.startsWith('0x')) {
68
+ normalizedAddress = normalizedAddress.slice(2);
69
+ }
70
+ /**
71
+ * These are standard from CAIP-2: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md
72
+ * see also: https://github.com/ChainAgnostic/namespaces
73
+ * note: no standard namespace currently exists for flow
74
+ */ const chainsThatRequireLowercaseAddress = [
75
+ 'EVM',
76
+ 'FLOW'
77
+ ];
78
+ normalizedAddress = chainsThatRequireLowercaseAddress.includes(chain) ? normalizedAddress == null ? void 0 : normalizedAddress.toLowerCase() : normalizedAddress;
79
+ return normalizedAddress;
80
+ };
81
+
82
+ const createWalletAccountId = (chain, address)=>`${chain}-${normalizeAddress(address, chain)}`;
83
+
84
+ const convertUnverifiedWalletAccountToWalletAccount = (unverifiedWalletAccount)=>({
85
+ address: unverifiedWalletAccount.address,
86
+ chain: unverifiedWalletAccount.chain,
87
+ id: createWalletAccountId(unverifiedWalletAccount.chain, unverifiedWalletAccount.address),
88
+ lastSelectedAt: unverifiedWalletAccount.lastSelectedAt,
89
+ verifiedCredentialId: null,
90
+ walletProviderKey: unverifiedWalletAccount.walletProviderKey
91
+ });
92
+
64
93
  /**
65
94
  * Format the wallet name and chain to get a wallet provider key.
66
95
  */ const formatWalletProviderKey = (walletName, chain)=>{
@@ -68,6 +97,57 @@ import { g as getDefaultClient, a as getCore, B as BaseError } from './getChainF
68
97
  return `${sanitizedWalletName}${chain.toLocaleLowerCase()}`;
69
98
  };
70
99
 
100
+ const convertVerifiedCredentialToWalletAccount = (verified)=>{
101
+ assertDefined(verified.address, 'Missing address in verified credential');
102
+ assertDefined(verified.chain, 'Missing chain in verified credential');
103
+ assertDefined(verified.walletName, 'Missing wallet name in verified credential');
104
+ const chain = getChainFromVerifiedCredentialChain(verified.chain);
105
+ const hasChainInWalletName = verified.walletName.endsWith(chain.toLowerCase());
106
+ // we need to make sure the walletProviderKey follows the correct format ([walletName][chain])
107
+ // some walletNames will follow the legacy format (e.g. "phantom" instead of "phantomsol", "metamask" instead of "metamaskevm")
108
+ // so we need to make sure we parse it correctly
109
+ const walletProviderKey = hasChainInWalletName ? verified.walletName : formatWalletProviderKey(verified.walletName, chain);
110
+ var _verified_lastSelectedAt;
111
+ return {
112
+ address: verified.address,
113
+ chain,
114
+ id: createWalletAccountId(chain, verified.address),
115
+ lastSelectedAt: (_verified_lastSelectedAt = verified.lastSelectedAt) != null ? _verified_lastSelectedAt : null,
116
+ verifiedCredentialId: verified.id,
117
+ walletProviderKey
118
+ };
119
+ };
120
+
121
+ const getWalletAccountsFromState = (state)=>{
122
+ const { unverifiedWalletAccounts, user } = state;
123
+ const walletAccountsMap = new Map();
124
+ /**
125
+ * Handle the unverified wallet accounts before the user verified credentials
126
+ * so the later verified wallet accounts can override the unverified wallet accounts
127
+ */ unverifiedWalletAccounts.forEach((unverifiedWalletAccount)=>{
128
+ const walletAccount = convertUnverifiedWalletAccountToWalletAccount(unverifiedWalletAccount);
129
+ walletAccountsMap.set(walletAccount.id, walletAccount);
130
+ });
131
+ var _user_verifiedCredentials;
132
+ /**
133
+ * Handle user verified credentials
134
+ */ const verifiedCredentials = (_user_verifiedCredentials = user == null ? void 0 : user.verifiedCredentials) != null ? _user_verifiedCredentials : [];
135
+ verifiedCredentials.filter((verified)=>verified.format === JwtVerifiedCredentialFormatEnum.Blockchain).map((verifiedWalletAccount)=>convertVerifiedCredentialToWalletAccount(verifiedWalletAccount)).forEach((verifiedWalletAccount)=>walletAccountsMap.set(verifiedWalletAccount.id, verifiedWalletAccount));
136
+ return Array.from(walletAccountsMap.values());
137
+ };
138
+
139
+ /**
140
+ * Retrieves all wallet accounts associated with the current session.
141
+ *
142
+ * This function returns both verified and unverified wallet accounts,
143
+ * combining data from user credentials and local unverified accounts.
144
+ * You can differentiate between verified and unverified wallet accounts by
145
+ * checking the `verifiedCredentialId` property.
146
+ *
147
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
148
+ * @returns An array of wallet accounts associated with the session.
149
+ */ const getWalletAccounts = (client = getDefaultClient())=>getWalletAccountsFromState(getCore(client).state.get());
150
+
71
151
  class NoWalletProviderFoundError extends BaseError {
72
152
  constructor({ walletProviderKey }){
73
153
  super({
@@ -210,6 +290,45 @@ const getWalletProviderFromWalletAccount = ({ walletAccount }, client)=>{
210
290
  return walletProvider;
211
291
  };
212
292
 
293
+ /**
294
+ * Emits the `walletAccountsChanged` event.
295
+ */ const emitWalletAccountsChangedEvent = (client)=>{
296
+ const walletAccounts = getWalletAccounts(client);
297
+ emitEvent({
298
+ args: {
299
+ walletAccounts
300
+ },
301
+ event: 'walletAccountsChanged'
302
+ }, client);
303
+ };
304
+
305
+ const checkAndRaiseWalletAccountsChangedEvent = ({ previousState }, client)=>{
306
+ const core = getCore(client);
307
+ const walletAccountsHashBefore = getWalletAccountsHash(previousState);
308
+ const walletAccountsHashAfter = getWalletAccountsHash(core.state.get());
309
+ if (walletAccountsHashBefore !== walletAccountsHashAfter) {
310
+ emitWalletAccountsChangedEvent(client);
311
+ }
312
+ };
313
+ const getWalletAccountsHash = (state)=>getWalletAccountsFromState(state).map(({ id })=>id).sort().join('-');
314
+
315
+ const updateAuthFromVerifyResponse = ({ response }, client)=>{
316
+ const core = getCore(client);
317
+ const previousState = _extends({}, core.state.get());
318
+ const { user, minifiedJwt, jwt, expiresAt, mfaToken } = response;
319
+ core.state.set({
320
+ legacyToken: jwt != null ? jwt : null,
321
+ mfaToken: mfaToken != null ? mfaToken : null,
322
+ // Expires at is in seconds, so we need to convert it to milliseconds
323
+ sessionExpiresAt: new Date(expiresAt * 1000),
324
+ token: minifiedJwt != null ? minifiedJwt : null,
325
+ user
326
+ });
327
+ checkAndRaiseWalletAccountsChangedEvent({
328
+ previousState
329
+ }, client);
330
+ };
331
+
213
332
  /**
214
333
  * Get all available wallet providers to interact with internally.
215
334
  */ const getWalletProviders = (client)=>{
@@ -228,4 +347,4 @@ const getWalletProviderByKey = ({ walletProviderKey }, client)=>{
228
347
  return walletProvider;
229
348
  };
230
349
 
231
- export { NoWalletProviderFoundError as N, WalletProviderPriority as W, getWalletProviderByKey as a, getWalletProviders as b, onceEvent as c, onEvent as d, emitEvent as e, createRuntimeServiceAccessKey as f, getWalletProviderFromWalletAccount as g, formatWalletProviderKey as h, getWalletProviderRegistry as i, offEvent as o };
350
+ export { NoWalletProviderFoundError as N, WalletProviderPriority as W, getWalletProviderFromWalletAccount as a, getWalletProviderByKey as b, createWalletAccountId as c, emitWalletAccountsChangedEvent as d, emitEvent as e, getWalletProviders as f, getWalletAccounts as g, onceEvent as h, onEvent as i, createRuntimeServiceAccessKey as j, formatWalletProviderKey as k, getWalletProviderRegistry as l, normalizeAddress as n, offEvent as o, updateAuthFromVerifyResponse as u };
package/index.cjs.js CHANGED
@@ -4,12 +4,12 @@ var assertPackageVersion = require('@dynamic-labs-sdk/assert-package-version');
4
4
  var getChainFromVerifiedCredentialChain = require('./getChainFromVerifiedCredentialChain.cjs.js');
5
5
  var getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId.cjs.js');
6
6
  var getWalletProviderByKey = require('./getWalletProviderByKey.cjs.js');
7
- var refreshUser = require('./refreshUser.cjs.js');
8
7
  var z = require('zod/mini');
9
8
  var isMfaRequiredForAction = require('./isMfaRequiredForAction.cjs.js');
10
9
  var EventEmitter = require('eventemitter3');
11
10
  var browser = require('@simplewebauthn/browser');
12
11
  var InvalidParamError = require('./InvalidParamError.cjs.js');
12
+ var refreshUser = require('./refreshUser.cjs.js');
13
13
  var sdkApiCore = require('@dynamic-labs/sdk-api-core');
14
14
  require('buffer');
15
15
 
@@ -84,7 +84,7 @@ const retryOnFail = async ({ delay = 0, fn, maxRetries })=>{
84
84
  *
85
85
  * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
86
86
  * @returns True if the user is signed in, false otherwise.
87
- */ const isSignedIn = (client = getChainFromVerifiedCredentialChain.getDefaultClient())=>Boolean(client.user || refreshUser.getWalletAccounts(client).length > 0);
87
+ */ const isSignedIn = (client = getChainFromVerifiedCredentialChain.getDefaultClient())=>Boolean(client.user || getWalletProviderByKey.getWalletAccounts(client).length > 0);
88
88
 
89
89
  /**
90
90
  * Returns whether the given string is a valid ISO date string.
@@ -196,7 +196,7 @@ const parseFromStorage = (value)=>{
196
196
  const apiClient = getChainFromVerifiedCredentialChain.createApiClient({}, client);
197
197
  const doFetch = async ()=>apiClient.getEnvironmentSettings({
198
198
  environmentId: core.environmentId,
199
- sdkVersion: `WalletKit/${core.version}`
199
+ sdkVersion: `${getChainFromVerifiedCredentialChain.CLIENT_SDK_NAME}/${core.version}`
200
200
  }, {
201
201
  credentials: 'omit'
202
202
  });
@@ -292,7 +292,7 @@ const generateSessionKeys = async (client)=>{
292
292
  const getAvailableWalletProvidersFromWalletAccounts = (client)=>{
293
293
  const core = getChainFromVerifiedCredentialChain.getCore(client);
294
294
  const walletProvidersMap = new Map();
295
- const walletAccounts = refreshUser.getWalletAccounts(client);
295
+ const walletAccounts = getWalletProviderByKey.getWalletAccounts(client);
296
296
  walletAccounts.forEach((walletAccount)=>{
297
297
  if (walletProvidersMap.has(walletAccount.walletProviderKey)) {
298
298
  return;
@@ -1099,7 +1099,7 @@ class WalletProviderMethodUnavailableError extends getChainFromVerifiedCredentia
1099
1099
  sessionPublicKey
1100
1100
  }
1101
1101
  });
1102
- refreshUser.updateAuthFromVerifyResponse({
1102
+ getWalletProviderByKey.updateAuthFromVerifyResponse({
1103
1103
  response
1104
1104
  }, client);
1105
1105
  return response;
@@ -1184,7 +1184,7 @@ const serverRegisterPasskey = async ({ registration }, client)=>{
1184
1184
  const response = await serverRegisterPasskey({
1185
1185
  registration
1186
1186
  }, client);
1187
- refreshUser.updateAuthFromVerifyResponse({
1187
+ getWalletProviderByKey.updateAuthFromVerifyResponse({
1188
1188
  response
1189
1189
  }, client);
1190
1190
  return response;
@@ -1237,7 +1237,7 @@ const serverSigninPasskey = async ({ authentication, createMfaToken }, client)=>
1237
1237
  const response = await serverSigninPasskey({
1238
1238
  authentication
1239
1239
  }, client);
1240
- refreshUser.updateAuthFromVerifyResponse({
1240
+ getWalletProviderByKey.updateAuthFromVerifyResponse({
1241
1241
  response
1242
1242
  }, client);
1243
1243
  return response;
@@ -1293,7 +1293,7 @@ const serverSigninPasskey = async ({ authentication, createMfaToken }, client)=>
1293
1293
  },
1294
1294
  providerType: provider
1295
1295
  });
1296
- refreshUser.updateAuthFromVerifyResponse({
1296
+ getWalletProviderByKey.updateAuthFromVerifyResponse({
1297
1297
  response
1298
1298
  }, client);
1299
1299
  return response.user;
@@ -1488,7 +1488,7 @@ const providersRequiringPkce = [
1488
1488
  environmentId: core.environmentId,
1489
1489
  userFields
1490
1490
  });
1491
- refreshUser.updateAuthFromVerifyResponse({
1491
+ getWalletProviderByKey.updateAuthFromVerifyResponse({
1492
1492
  response
1493
1493
  }, client);
1494
1494
  if (response.emailVerification) {
@@ -1544,7 +1544,7 @@ const providersRequiringPkce = [
1544
1544
  createMfaToken: createMfaTokenOptions
1545
1545
  }
1546
1546
  });
1547
- refreshUser.updateAuthFromVerifyResponse({
1547
+ getWalletProviderByKey.updateAuthFromVerifyResponse({
1548
1548
  response
1549
1549
  }, client);
1550
1550
  getWalletProviderByKey.emitEvent({
@@ -1625,7 +1625,7 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
1625
1625
  authentication,
1626
1626
  createMfaToken
1627
1627
  }, client);
1628
- refreshUser.updateAuthFromVerifyResponse({
1628
+ getWalletProviderByKey.updateAuthFromVerifyResponse({
1629
1629
  response
1630
1630
  }, client);
1631
1631
  getWalletProviderByKey.emitEvent({
@@ -1669,7 +1669,7 @@ const serverAuthenticatePasskey = async ({ authentication, createMfaToken }, cli
1669
1669
  id: deviceId
1670
1670
  }
1671
1671
  });
1672
- refreshUser.updateAuthFromVerifyResponse({
1672
+ getWalletProviderByKey.updateAuthFromVerifyResponse({
1673
1673
  response
1674
1674
  }, client);
1675
1675
  getWalletProviderByKey.emitEvent({
@@ -2859,7 +2859,7 @@ const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, cl
2859
2859
  otpVerification,
2860
2860
  verificationToken
2861
2861
  }, client);
2862
- refreshUser.updateAuthFromVerifyResponse({
2862
+ getWalletProviderByKey.updateAuthFromVerifyResponse({
2863
2863
  response
2864
2864
  }, client);
2865
2865
  return response.user;
@@ -2977,7 +2977,7 @@ const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, cl
2977
2977
  }, client);
2978
2978
  assertWalletProviderMethodDefined(walletProvider, 'connect');
2979
2979
  const { addresses: [selectedAddress] } = await walletProvider.connect();
2980
- const currentAddresses = refreshUser.getWalletAccounts(client).map(({ address })=>address);
2980
+ const currentAddresses = getWalletProviderByKey.getWalletAccounts(client).map(({ address })=>address);
2981
2981
  /**
2982
2982
  * This error is thrown in case the wallet has no addresses connected
2983
2983
  * to the dapp. Then the error is thrown so the consumer can instruct the
@@ -2988,7 +2988,7 @@ const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, cl
2988
2988
  const walletAccount = {
2989
2989
  address: selectedAddress,
2990
2990
  chain: walletProvider.chain,
2991
- id: refreshUser.createWalletAccountId(walletProvider.chain, selectedAddress),
2991
+ id: getWalletProviderByKey.createWalletAccountId(walletProvider.chain, selectedAddress),
2992
2992
  lastSelectedAt: null,
2993
2993
  verifiedCredentialId: null,
2994
2994
  walletProviderKey: walletProvider.key
@@ -3000,7 +3000,7 @@ const verifyOTPForUserUpdate = async ({ otpVerification, verificationToken }, cl
3000
3000
  setUnverifiedWalletAccount({
3001
3001
  unverifiedWalletAccountToUpdate: walletAccount
3002
3002
  }, client);
3003
- refreshUser.emitWalletAccountsChangedEvent(client);
3003
+ getWalletProviderByKey.emitWalletAccountsChangedEvent(client);
3004
3004
  /*
3005
3005
  * send information to backend to kick off background jobs
3006
3006
  * this is an async work, but does not need to be awaited
@@ -3109,7 +3109,7 @@ const getSignInMessage = async ({ walletAccount }, client)=>{
3109
3109
  });
3110
3110
  };
3111
3111
 
3112
- const isSameAddress = (left, right, chain)=>refreshUser.normalizeAddress(left, chain) === refreshUser.normalizeAddress(right, chain);
3112
+ const isSameAddress = (left, right, chain)=>getWalletProviderByKey.normalizeAddress(left, chain) === getWalletProviderByKey.normalizeAddress(right, chain);
3113
3113
 
3114
3114
  /**
3115
3115
  * Verifies ownership of a wallet account and adds it to the user's profile.
@@ -3156,7 +3156,7 @@ const isSameAddress = (left, right, chain)=>refreshUser.normalizeAddress(left, c
3156
3156
  /**
3157
3157
  * Adds the user with the new wallet verified credential
3158
3158
  * This will add the new verified wallet account to the client`s state
3159
- */ refreshUser.updateAuthFromVerifyResponse({
3159
+ */ getWalletProviderByKey.updateAuthFromVerifyResponse({
3160
3160
  response
3161
3161
  }, client);
3162
3162
  } catch (error) {
@@ -3167,7 +3167,7 @@ const isSameAddress = (left, right, chain)=>refreshUser.normalizeAddress(left, c
3167
3167
  }
3168
3168
  throw error;
3169
3169
  }
3170
- const verifiedWalletAccount = refreshUser.getWalletAccounts(client).find(({ address })=>isSameAddress(address, walletAccount.address, walletAccount.chain));
3170
+ const verifiedWalletAccount = getWalletProviderByKey.getWalletAccounts(client).find(({ address })=>isSameAddress(address, walletAccount.address, walletAccount.chain));
3171
3171
  getChainFromVerifiedCredentialChain.assertDefined(verifiedWalletAccount, 'Verified wallet account not found');
3172
3172
  return verifiedWalletAccount;
3173
3173
  };
@@ -3368,7 +3368,7 @@ const isSameAddress = (left, right, chain)=>refreshUser.normalizeAddress(left, c
3368
3368
  * This information is stored in both unverified and verified wallet accounts.
3369
3369
  * This function consolidates this information to determine which wallet was most recently selected.
3370
3370
  */ const getPrimaryWalletAccount = (client = getChainFromVerifiedCredentialChain.getDefaultClient())=>{
3371
- const walletAccounts = refreshUser.getWalletAccounts(client);
3371
+ const walletAccounts = getWalletProviderByKey.getWalletAccounts(client);
3372
3372
  const sortedLastSelectedWalletAccounts = walletAccounts.filter((walletAccount)=>Boolean(walletAccount.lastSelectedAt)).sort((a, b)=>b.lastSelectedAt.getTime() - a.lastSelectedAt.getTime());
3373
3373
  if (sortedLastSelectedWalletAccounts.length === 0) {
3374
3374
  return null;
@@ -3393,7 +3393,7 @@ const isSameAddress = (left, right, chain)=>refreshUser.normalizeAddress(left, c
3393
3393
  walletId: walletAccount.verifiedCredentialId
3394
3394
  }
3395
3395
  });
3396
- refreshUser.updateAuthFromVerifyResponse({
3396
+ getWalletProviderByKey.updateAuthFromVerifyResponse({
3397
3397
  response
3398
3398
  }, client);
3399
3399
  } else {
@@ -3430,7 +3430,7 @@ const isSameAddress = (left, right, chain)=>refreshUser.normalizeAddress(left, c
3430
3430
  walletId: walletAccount.verifiedCredentialId
3431
3431
  }
3432
3432
  });
3433
- refreshUser.updateAuthFromVerifyResponse({
3433
+ getWalletProviderByKey.updateAuthFromVerifyResponse({
3434
3434
  response
3435
3435
  }, client);
3436
3436
  };
@@ -3470,7 +3470,7 @@ const isSameAddress = (left, right, chain)=>refreshUser.normalizeAddress(left, c
3470
3470
  * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
3471
3471
  * @returns The matching wallet account, or undefined if not found.
3472
3472
  */ const getWalletAccountFromAddress = ({ address, chain }, client = getChainFromVerifiedCredentialChain.getDefaultClient())=>{
3473
- const walletAccounts = refreshUser.getWalletAccounts(client);
3473
+ const walletAccounts = getWalletProviderByKey.getWalletAccounts(client);
3474
3474
  return walletAccounts.find((walletAccount)=>walletAccount.address === address && walletAccount.chain === chain);
3475
3475
  };
3476
3476
 
@@ -3526,16 +3526,16 @@ exports.getDefaultClient = getChainFromVerifiedCredentialChain.getDefaultClient;
3526
3526
  exports.NoNetworkProvidersError = getNetworkProviderFromNetworkId.NoNetworkProvidersError;
3527
3527
  exports.getNetworksData = getNetworkProviderFromNetworkId.getNetworksData;
3528
3528
  exports.hasExtension = getNetworkProviderFromNetworkId.hasExtension;
3529
+ exports.getWalletAccounts = getWalletProviderByKey.getWalletAccounts;
3529
3530
  exports.offEvent = getWalletProviderByKey.offEvent;
3530
3531
  exports.onEvent = getWalletProviderByKey.onEvent;
3531
3532
  exports.onceEvent = getWalletProviderByKey.onceEvent;
3532
- exports.NotWaasWalletAccountError = refreshUser.NotWaasWalletAccountError;
3533
- exports.getWalletAccounts = refreshUser.getWalletAccounts;
3534
- exports.refreshUser = refreshUser.refreshUser;
3535
3533
  exports.consumeMfaToken = isMfaRequiredForAction.consumeMfaToken;
3536
3534
  exports.getMfaMethods = isMfaRequiredForAction.getMfaMethods;
3537
3535
  exports.isMfaRequiredForAction = isMfaRequiredForAction.isMfaRequiredForAction;
3538
3536
  exports.InvalidParamError = InvalidParamError.InvalidParamError;
3537
+ exports.NotWaasWalletAccountError = refreshUser.NotWaasWalletAccountError;
3538
+ exports.refreshUser = refreshUser.refreshUser;
3539
3539
  exports.ClientAlreadyInitializedError = ClientAlreadyInitializedError;
3540
3540
  exports.InvalidRedirectStorageStateError = InvalidRedirectStorageStateError;
3541
3541
  exports.MissingRedirectStorageStateError = MissingRedirectStorageStateError;
package/index.esm.js CHANGED
@@ -1,18 +1,17 @@
1
1
  import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';
2
- import { B as BaseError, g as getDefaultClient, a as getCore, c as createApiClient, b as getBuffer, d as dependencies, v as version, s as setDefaultClient, _ as _extends, e as assertDefined, r as randomString, C as CHAINS_INFO_MAP, n as name } from './getChainFromVerifiedCredentialChain.esm.js';
3
- export { I as InvalidExternalAuthError, M as MfaInvalidOtpError, f as MfaRateLimitedError, S as SandboxMaximumThresholdReachedError } from './getChainFromVerifiedCredentialChain.esm.js';
2
+ import { B as BaseError, g as getDefaultClient, a as getCore, c as createApiClient, C as CLIENT_SDK_NAME, b as getBuffer, d as dependencies, v as version, s as setDefaultClient, _ as _extends, e as assertDefined, r as randomString, f as CHAINS_INFO_MAP, n as name } from './getChainFromVerifiedCredentialChain.esm.js';
3
+ export { I as InvalidExternalAuthError, M as MfaInvalidOtpError, h as MfaRateLimitedError, S as SandboxMaximumThresholdReachedError } from './getChainFromVerifiedCredentialChain.esm.js';
4
4
  import { I as InvalidStorageSet, c as createStorageKeySchema, s as subscribeWithSelector, i as isEqualShallow, C as CannotTrackError, a as createLogger, f as formatSignInMessage, g as getNetworksData, b as getNetworkProviderFromNetworkId } from './getNetworkProviderFromNetworkId.esm.js';
5
5
  export { N as NoNetworkProvidersError, h as hasExtension } from './getNetworkProviderFromNetworkId.esm.js';
6
- import { g as getWalletProviderFromWalletAccount, e as emitEvent, a as getWalletProviderByKey, b as getWalletProviders } from './getWalletProviderByKey.esm.js';
7
- export { o as offEvent, d as onEvent, c as onceEvent } from './getWalletProviderByKey.esm.js';
8
- import { g as getWalletAccounts, u as updateAuthFromVerifyResponse, c as createWalletAccountId, e as emitWalletAccountsChangedEvent, n as normalizeAddress } from './refreshUser.esm.js';
9
- export { N as NotWaasWalletAccountError, r as refreshUser } from './refreshUser.esm.js';
6
+ import { g as getWalletAccounts, a as getWalletProviderFromWalletAccount, e as emitEvent, u as updateAuthFromVerifyResponse, b as getWalletProviderByKey, c as createWalletAccountId, d as emitWalletAccountsChangedEvent, n as normalizeAddress, f as getWalletProviders } from './getWalletProviderByKey.esm.js';
7
+ export { o as offEvent, i as onEvent, h as onceEvent } from './getWalletProviderByKey.esm.js';
10
8
  import * as z from 'zod/mini';
11
9
  import { b as bufferToHex } from './isMfaRequiredForAction.esm.js';
12
10
  export { c as consumeMfaToken, g as getMfaMethods, i as isMfaRequiredForAction } from './isMfaRequiredForAction.esm.js';
13
11
  import EventEmitter$1, { EventEmitter } from 'eventemitter3';
14
12
  import { startRegistration, browserSupportsWebAuthn, startAuthentication } from '@simplewebauthn/browser';
15
13
  export { I as InvalidParamError } from './InvalidParamError.esm.js';
14
+ export { N as NotWaasWalletAccountError, r as refreshUser } from './refreshUser.esm.js';
16
15
  import { ProviderEnum, MfaBackupCodeAcknowledgement, AuthModeEnum } from '@dynamic-labs/sdk-api-core';
17
16
  import 'buffer';
18
17
 
@@ -180,7 +179,7 @@ const parseFromStorage = (value)=>{
180
179
  const apiClient = createApiClient({}, client);
181
180
  const doFetch = async ()=>apiClient.getEnvironmentSettings({
182
181
  environmentId: core.environmentId,
183
- sdkVersion: `WalletKit/${core.version}`
182
+ sdkVersion: `${CLIENT_SDK_NAME}/${core.version}`
184
183
  }, {
185
184
  credentials: 'omit'
186
185
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs-sdk/client",
3
- "version": "0.1.0-alpha.3",
3
+ "version": "0.1.0-alpha.4",
4
4
  "type": "module",
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js",
@@ -29,9 +29,9 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@dynamic-labs-sdk/assert-package-version": "0.1.0-alpha.3",
32
+ "@dynamic-labs-sdk/assert-package-version": "0.1.0-alpha.4",
33
33
  "@dynamic-labs/sdk-api-core": "0.0.762",
34
- "@dynamic-labs-wallet/browser-wallet-client": "0.0.144",
34
+ "@dynamic-labs-wallet/browser-wallet-client": "0.0.155",
35
35
  "@simplewebauthn/browser": "^13.1.0",
36
36
  "buffer": "6.0.3",
37
37
  "eventemitter3": "^5.0.1",
@@ -2,86 +2,6 @@
2
2
 
3
3
  var getChainFromVerifiedCredentialChain = require('./getChainFromVerifiedCredentialChain.cjs.js');
4
4
  var getWalletProviderByKey = require('./getWalletProviderByKey.cjs.js');
5
- var sdkApiCore = require('@dynamic-labs/sdk-api-core');
6
-
7
- const normalizeAddress = (address, chain)=>{
8
- let normalizedAddress = address;
9
- if (normalizedAddress == null ? void 0 : normalizedAddress.startsWith('0x')) {
10
- normalizedAddress = normalizedAddress.slice(2);
11
- }
12
- /**
13
- * These are standard from CAIP-2: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md
14
- * see also: https://github.com/ChainAgnostic/namespaces
15
- * note: no standard namespace currently exists for flow
16
- */ const chainsThatRequireLowercaseAddress = [
17
- 'EVM',
18
- 'FLOW'
19
- ];
20
- normalizedAddress = chainsThatRequireLowercaseAddress.includes(chain) ? normalizedAddress == null ? void 0 : normalizedAddress.toLowerCase() : normalizedAddress;
21
- return normalizedAddress;
22
- };
23
-
24
- const createWalletAccountId = (chain, address)=>`${chain}-${normalizeAddress(address, chain)}`;
25
-
26
- const convertUnverifiedWalletAccountToWalletAccount = (unverifiedWalletAccount)=>({
27
- address: unverifiedWalletAccount.address,
28
- chain: unverifiedWalletAccount.chain,
29
- id: createWalletAccountId(unverifiedWalletAccount.chain, unverifiedWalletAccount.address),
30
- lastSelectedAt: unverifiedWalletAccount.lastSelectedAt,
31
- verifiedCredentialId: null,
32
- walletProviderKey: unverifiedWalletAccount.walletProviderKey
33
- });
34
-
35
- const convertVerifiedCredentialToWalletAccount = (verified)=>{
36
- getChainFromVerifiedCredentialChain.assertDefined(verified.address, 'Missing address in verified credential');
37
- getChainFromVerifiedCredentialChain.assertDefined(verified.chain, 'Missing chain in verified credential');
38
- getChainFromVerifiedCredentialChain.assertDefined(verified.walletName, 'Missing wallet name in verified credential');
39
- const chain = getChainFromVerifiedCredentialChain.getChainFromVerifiedCredentialChain(verified.chain);
40
- const hasChainInWalletName = verified.walletName.endsWith(chain.toLowerCase());
41
- // we need to make sure the walletProviderKey follows the correct format ([walletName][chain])
42
- // some walletNames will follow the legacy format (e.g. "phantom" instead of "phantomsol", "metamask" instead of "metamaskevm")
43
- // so we need to make sure we parse it correctly
44
- const walletProviderKey = hasChainInWalletName ? verified.walletName : getWalletProviderByKey.formatWalletProviderKey(verified.walletName, chain);
45
- var _verified_lastSelectedAt;
46
- return {
47
- address: verified.address,
48
- chain,
49
- id: createWalletAccountId(chain, verified.address),
50
- lastSelectedAt: (_verified_lastSelectedAt = verified.lastSelectedAt) != null ? _verified_lastSelectedAt : null,
51
- verifiedCredentialId: verified.id,
52
- walletProviderKey
53
- };
54
- };
55
-
56
- const getWalletAccountsFromState = (state)=>{
57
- const { unverifiedWalletAccounts, user } = state;
58
- const walletAccountsMap = new Map();
59
- /**
60
- * Handle the unverified wallet accounts before the user verified credentials
61
- * so the later verified wallet accounts can override the unverified wallet accounts
62
- */ unverifiedWalletAccounts.forEach((unverifiedWalletAccount)=>{
63
- const walletAccount = convertUnverifiedWalletAccountToWalletAccount(unverifiedWalletAccount);
64
- walletAccountsMap.set(walletAccount.id, walletAccount);
65
- });
66
- var _user_verifiedCredentials;
67
- /**
68
- * Handle user verified credentials
69
- */ const verifiedCredentials = (_user_verifiedCredentials = user == null ? void 0 : user.verifiedCredentials) != null ? _user_verifiedCredentials : [];
70
- verifiedCredentials.filter((verified)=>verified.format === sdkApiCore.JwtVerifiedCredentialFormatEnum.Blockchain).map((verifiedWalletAccount)=>convertVerifiedCredentialToWalletAccount(verifiedWalletAccount)).forEach((verifiedWalletAccount)=>walletAccountsMap.set(verifiedWalletAccount.id, verifiedWalletAccount));
71
- return Array.from(walletAccountsMap.values());
72
- };
73
-
74
- /**
75
- * Retrieves all wallet accounts associated with the current session.
76
- *
77
- * This function returns both verified and unverified wallet accounts,
78
- * combining data from user credentials and local unverified accounts.
79
- * You can differentiate between verified and unverified wallet accounts by
80
- * checking the `verifiedCredentialId` property.
81
- *
82
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
83
- * @returns An array of wallet accounts associated with the session.
84
- */ const getWalletAccounts = (client = getChainFromVerifiedCredentialChain.getDefaultClient())=>getWalletAccountsFromState(getChainFromVerifiedCredentialChain.getCore(client).state.get());
85
5
 
86
6
  class NotWaasWalletAccountError extends getChainFromVerifiedCredentialChain.BaseError {
87
7
  constructor({ walletAddress }){
@@ -95,45 +15,6 @@ class NotWaasWalletAccountError extends getChainFromVerifiedCredentialChain.Base
95
15
  }
96
16
  }
97
17
 
98
- /**
99
- * Emits the `walletAccountsChanged` event.
100
- */ const emitWalletAccountsChangedEvent = (client)=>{
101
- const walletAccounts = getWalletAccounts(client);
102
- getWalletProviderByKey.emitEvent({
103
- args: {
104
- walletAccounts
105
- },
106
- event: 'walletAccountsChanged'
107
- }, client);
108
- };
109
-
110
- const checkAndRaiseWalletAccountsChangedEvent = ({ previousState }, client)=>{
111
- const core = getChainFromVerifiedCredentialChain.getCore(client);
112
- const walletAccountsHashBefore = getWalletAccountsHash(previousState);
113
- const walletAccountsHashAfter = getWalletAccountsHash(core.state.get());
114
- if (walletAccountsHashBefore !== walletAccountsHashAfter) {
115
- emitWalletAccountsChangedEvent(client);
116
- }
117
- };
118
- const getWalletAccountsHash = (state)=>getWalletAccountsFromState(state).map(({ id })=>id).sort().join('-');
119
-
120
- const updateAuthFromVerifyResponse = ({ response }, client)=>{
121
- const core = getChainFromVerifiedCredentialChain.getCore(client);
122
- const previousState = getChainFromVerifiedCredentialChain._extends({}, core.state.get());
123
- const { user, minifiedJwt, jwt, expiresAt, mfaToken } = response;
124
- core.state.set({
125
- legacyToken: jwt != null ? jwt : null,
126
- mfaToken: mfaToken != null ? mfaToken : null,
127
- // Expires at is in seconds, so we need to convert it to milliseconds
128
- sessionExpiresAt: new Date(expiresAt * 1000),
129
- token: minifiedJwt != null ? minifiedJwt : null,
130
- user
131
- });
132
- checkAndRaiseWalletAccountsChangedEvent({
133
- previousState
134
- }, client);
135
- };
136
-
137
18
  /**
138
19
  * Refreshes the current user's data from the server.
139
20
  *
@@ -148,15 +29,10 @@ const updateAuthFromVerifyResponse = ({ response }, client)=>{
148
29
  const response = await apiClient.refreshAuth({
149
30
  environmentId: core.environmentId
150
31
  });
151
- updateAuthFromVerifyResponse({
32
+ getWalletProviderByKey.updateAuthFromVerifyResponse({
152
33
  response
153
34
  }, client);
154
35
  };
155
36
 
156
37
  exports.NotWaasWalletAccountError = NotWaasWalletAccountError;
157
- exports.createWalletAccountId = createWalletAccountId;
158
- exports.emitWalletAccountsChangedEvent = emitWalletAccountsChangedEvent;
159
- exports.getWalletAccounts = getWalletAccounts;
160
- exports.normalizeAddress = normalizeAddress;
161
38
  exports.refreshUser = refreshUser;
162
- exports.updateAuthFromVerifyResponse = updateAuthFromVerifyResponse;
@@ -1,85 +1,5 @@
1
- import { e as assertDefined, j as getChainFromVerifiedCredentialChain, g as getDefaultClient, a as getCore, B as BaseError, _ as _extends, c as createApiClient } from './getChainFromVerifiedCredentialChain.esm.js';
2
- import { h as formatWalletProviderKey, e as emitEvent } from './getWalletProviderByKey.esm.js';
3
- import { JwtVerifiedCredentialFormatEnum } from '@dynamic-labs/sdk-api-core';
4
-
5
- const normalizeAddress = (address, chain)=>{
6
- let normalizedAddress = address;
7
- if (normalizedAddress == null ? void 0 : normalizedAddress.startsWith('0x')) {
8
- normalizedAddress = normalizedAddress.slice(2);
9
- }
10
- /**
11
- * These are standard from CAIP-2: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md
12
- * see also: https://github.com/ChainAgnostic/namespaces
13
- * note: no standard namespace currently exists for flow
14
- */ const chainsThatRequireLowercaseAddress = [
15
- 'EVM',
16
- 'FLOW'
17
- ];
18
- normalizedAddress = chainsThatRequireLowercaseAddress.includes(chain) ? normalizedAddress == null ? void 0 : normalizedAddress.toLowerCase() : normalizedAddress;
19
- return normalizedAddress;
20
- };
21
-
22
- const createWalletAccountId = (chain, address)=>`${chain}-${normalizeAddress(address, chain)}`;
23
-
24
- const convertUnverifiedWalletAccountToWalletAccount = (unverifiedWalletAccount)=>({
25
- address: unverifiedWalletAccount.address,
26
- chain: unverifiedWalletAccount.chain,
27
- id: createWalletAccountId(unverifiedWalletAccount.chain, unverifiedWalletAccount.address),
28
- lastSelectedAt: unverifiedWalletAccount.lastSelectedAt,
29
- verifiedCredentialId: null,
30
- walletProviderKey: unverifiedWalletAccount.walletProviderKey
31
- });
32
-
33
- const convertVerifiedCredentialToWalletAccount = (verified)=>{
34
- assertDefined(verified.address, 'Missing address in verified credential');
35
- assertDefined(verified.chain, 'Missing chain in verified credential');
36
- assertDefined(verified.walletName, 'Missing wallet name in verified credential');
37
- const chain = getChainFromVerifiedCredentialChain(verified.chain);
38
- const hasChainInWalletName = verified.walletName.endsWith(chain.toLowerCase());
39
- // we need to make sure the walletProviderKey follows the correct format ([walletName][chain])
40
- // some walletNames will follow the legacy format (e.g. "phantom" instead of "phantomsol", "metamask" instead of "metamaskevm")
41
- // so we need to make sure we parse it correctly
42
- const walletProviderKey = hasChainInWalletName ? verified.walletName : formatWalletProviderKey(verified.walletName, chain);
43
- var _verified_lastSelectedAt;
44
- return {
45
- address: verified.address,
46
- chain,
47
- id: createWalletAccountId(chain, verified.address),
48
- lastSelectedAt: (_verified_lastSelectedAt = verified.lastSelectedAt) != null ? _verified_lastSelectedAt : null,
49
- verifiedCredentialId: verified.id,
50
- walletProviderKey
51
- };
52
- };
53
-
54
- const getWalletAccountsFromState = (state)=>{
55
- const { unverifiedWalletAccounts, user } = state;
56
- const walletAccountsMap = new Map();
57
- /**
58
- * Handle the unverified wallet accounts before the user verified credentials
59
- * so the later verified wallet accounts can override the unverified wallet accounts
60
- */ unverifiedWalletAccounts.forEach((unverifiedWalletAccount)=>{
61
- const walletAccount = convertUnverifiedWalletAccountToWalletAccount(unverifiedWalletAccount);
62
- walletAccountsMap.set(walletAccount.id, walletAccount);
63
- });
64
- var _user_verifiedCredentials;
65
- /**
66
- * Handle user verified credentials
67
- */ const verifiedCredentials = (_user_verifiedCredentials = user == null ? void 0 : user.verifiedCredentials) != null ? _user_verifiedCredentials : [];
68
- verifiedCredentials.filter((verified)=>verified.format === JwtVerifiedCredentialFormatEnum.Blockchain).map((verifiedWalletAccount)=>convertVerifiedCredentialToWalletAccount(verifiedWalletAccount)).forEach((verifiedWalletAccount)=>walletAccountsMap.set(verifiedWalletAccount.id, verifiedWalletAccount));
69
- return Array.from(walletAccountsMap.values());
70
- };
71
-
72
- /**
73
- * Retrieves all wallet accounts associated with the current session.
74
- *
75
- * This function returns both verified and unverified wallet accounts,
76
- * combining data from user credentials and local unverified accounts.
77
- * You can differentiate between verified and unverified wallet accounts by
78
- * checking the `verifiedCredentialId` property.
79
- *
80
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
81
- * @returns An array of wallet accounts associated with the session.
82
- */ const getWalletAccounts = (client = getDefaultClient())=>getWalletAccountsFromState(getCore(client).state.get());
1
+ import { B as BaseError, g as getDefaultClient, a as getCore, c as createApiClient } from './getChainFromVerifiedCredentialChain.esm.js';
2
+ import { u as updateAuthFromVerifyResponse } from './getWalletProviderByKey.esm.js';
83
3
 
84
4
  class NotWaasWalletAccountError extends BaseError {
85
5
  constructor({ walletAddress }){
@@ -93,45 +13,6 @@ class NotWaasWalletAccountError extends BaseError {
93
13
  }
94
14
  }
95
15
 
96
- /**
97
- * Emits the `walletAccountsChanged` event.
98
- */ const emitWalletAccountsChangedEvent = (client)=>{
99
- const walletAccounts = getWalletAccounts(client);
100
- emitEvent({
101
- args: {
102
- walletAccounts
103
- },
104
- event: 'walletAccountsChanged'
105
- }, client);
106
- };
107
-
108
- const checkAndRaiseWalletAccountsChangedEvent = ({ previousState }, client)=>{
109
- const core = getCore(client);
110
- const walletAccountsHashBefore = getWalletAccountsHash(previousState);
111
- const walletAccountsHashAfter = getWalletAccountsHash(core.state.get());
112
- if (walletAccountsHashBefore !== walletAccountsHashAfter) {
113
- emitWalletAccountsChangedEvent(client);
114
- }
115
- };
116
- const getWalletAccountsHash = (state)=>getWalletAccountsFromState(state).map(({ id })=>id).sort().join('-');
117
-
118
- const updateAuthFromVerifyResponse = ({ response }, client)=>{
119
- const core = getCore(client);
120
- const previousState = _extends({}, core.state.get());
121
- const { user, minifiedJwt, jwt, expiresAt, mfaToken } = response;
122
- core.state.set({
123
- legacyToken: jwt != null ? jwt : null,
124
- mfaToken: mfaToken != null ? mfaToken : null,
125
- // Expires at is in seconds, so we need to convert it to milliseconds
126
- sessionExpiresAt: new Date(expiresAt * 1000),
127
- token: minifiedJwt != null ? minifiedJwt : null,
128
- user
129
- });
130
- checkAndRaiseWalletAccountsChangedEvent({
131
- previousState
132
- }, client);
133
- };
134
-
135
16
  /**
136
17
  * Refreshes the current user's data from the server.
137
18
  *
@@ -151,4 +32,4 @@ const updateAuthFromVerifyResponse = ({ response }, client)=>{
151
32
  }, client);
152
33
  };
153
34
 
154
- export { NotWaasWalletAccountError as N, createWalletAccountId as c, emitWalletAccountsChangedEvent as e, getWalletAccounts as g, normalizeAddress as n, refreshUser as r, updateAuthFromVerifyResponse as u };
35
+ export { NotWaasWalletAccountError as N, refreshUser as r };
@@ -11,6 +11,7 @@ export { MultipleClientsFoundError } from '../errors/MultipleClientsFoundError';
11
11
  export { NoWalletProviderFoundError } from '../errors/NoWalletProviderFoundError';
12
12
  export { ValueMustBeDefinedError } from '../errors/ValueMustBeDefinedError';
13
13
  export { createApiClient, DYNAMIC_SDK_API_VERSION } from '../modules/apiClient';
14
+ export { updateAuthFromVerifyResponse } from '../modules/auth/updateAuthFromVerifyResponse';
14
15
  export { emitEvent } from '../modules/clientEvents';
15
16
  export { hasExtension } from '../modules/extension/hasExtension';
16
17
  export { registerExtension } from '../modules/extension/registerExtension';
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../../packages/client/src/exports/core.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../../packages/client/src/exports/core.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,kCAAkC,EAAE,MAAM,mDAAmD,CAAC;AACvG,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,+BAA+B,EAAE,MAAM,6DAA6D,CAAC;AAC9G,OAAO,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AACtF,OAAO,EAAE,2BAA2B,EAAE,MAAM,kFAAkF,CAAC;AAC/H,YAAY,EAAE,wBAAwB,EAAE,MAAM,qFAAqF,CAAC;AACpI,YAAY,EAAE,mBAAmB,EAAE,MAAM,mEAAmE,CAAC;AAC7G,OAAO,EACL,iCAAiC,EACjC,KAAK,sBAAsB,EAC3B,KAAK,8BAA8B,GACpC,MAAM,4DAA4D,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,EAAE,4BAA4B,EAAE,MAAM,uDAAuD,CAAC;AACrG,OAAO,EAAE,uBAAuB,EAAE,MAAM,kDAAkD,CAAC;AAC3F,OAAO,EAAE,kCAAkC,EAAE,MAAM,6DAA6D,CAAC;AACjH,YAAY,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,YAAY,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,uCAAuC,EAAE,MAAM,kGAAkG,CAAC;AAC3J,OAAO,EAAE,sCAAsC,EAAE,MAAM,iGAAiG,CAAC;AACzJ,OAAO,EAAE,gCAAgC,EAAE,MAAM,2EAA2E,CAAC;AAC7H,OAAO,EACL,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACxE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACL,6BAA6B,EAC7B,KAAK,eAAe,GACrB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,mCAAmC,EAAE,MAAM,8CAA8C,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchProjectSettings.d.ts","sourceRoot":"","sources":["../../../../../../../packages/client/src/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,eAAO,MAAM,gCAAgC,QAAgB,CAAC;AAE9D;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,6HA0ChC,CAAC"}
1
+ {"version":3,"file":"fetchProjectSettings.d.ts","sourceRoot":"","sources":["../../../../../../../packages/client/src/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,eAAO,MAAM,gCAAgC,QAAgB,CAAC;AAE9D;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,6HA0ChC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"createWaasClient.d.ts","sourceRoot":"","sources":["../../../../../../../packages/client/src/modules/waas/createWaasClient/createWaasClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAGjF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAOzE,KAAK,sBAAsB,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,gBAAgB,kBACZ,sBAAsB,UAC7B,aAAa,wBAmBtB,CAAC"}
1
+ {"version":3,"file":"createWaasClient.d.ts","sourceRoot":"","sources":["../../../../../../../packages/client/src/modules/waas/createWaasClient/createWaasClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAGjF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAQzE,KAAK,sBAAsB,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,gBAAgB,kBACZ,sBAAsB,UAC7B,aAAa,wBAiBtB,CAAC"}
package/waas.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';
2
- import { B as BaseError, g as getDefaultClient, j as getChainFromVerifiedCredentialChain, e as assertDefined, n as name, v as version } from './getChainFromVerifiedCredentialChain.esm.js';
2
+ import { B as BaseError, g as getDefaultClient, k as getChainFromVerifiedCredentialChain, e as assertDefined, n as name, v as version } from './getChainFromVerifiedCredentialChain.esm.js';
3
3
  import { N as NotWaasWalletAccountError, r as refreshUser } from './refreshUser.esm.js';
4
- import { g as getWalletProviderFromWalletAccount, h as formatWalletProviderKey, a as getWalletProviderByKey, N as NoWalletProviderFoundError, b as getWalletProviders } from './getWalletProviderByKey.esm.js';
4
+ import { a as getWalletProviderFromWalletAccount, k as formatWalletProviderKey, b as getWalletProviderByKey, N as NoWalletProviderFoundError, f as getWalletProviders } from './getWalletProviderByKey.esm.js';
5
5
  import { D as DYNAMIC_WAAS_METADATA } from './constants.esm.js';
6
6
  import { WalletProviderEnum, EmbeddedWalletVersionEnum, JwtVerifiedCredentialFormatEnum } from '@dynamic-labs/sdk-api-core';
7
7
  import 'buffer';
package/waasCore.cjs.js CHANGED
@@ -19,7 +19,8 @@ const createWaasClient = ({ chainName }, client)=>{
19
19
  baseApiUrl: (core.apiBaseUrl || constants.DEFAULT_WAAS_BASE_API_URL).replace('/api/v0', ''),
20
20
  baseMPCRelayApiUrl: ((_client_projectSettings = client.projectSettings) == null ? void 0 : (_client_projectSettings_sdk_waas = _client_projectSettings.sdk.waas) == null ? void 0 : _client_projectSettings_sdk_waas.relayUrl) || constants.DEFAULT_WAAS_BASE_MPC_RELAY_API_URL,
21
21
  chainName,
22
- environmentId: core.environmentId
22
+ environmentId: core.environmentId,
23
+ sdkVersion: `${getChainFromVerifiedCredentialChain.CLIENT_SDK_NAME}/${core.version}`
23
24
  });
24
25
  };
25
26
 
package/waasCore.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';
2
- import { a as getCore, i as isCookieEnabled, C as CHAINS_INFO_MAP, j as getChainFromVerifiedCredentialChain, n as name, v as version } from './getChainFromVerifiedCredentialChain.esm.js';
2
+ import { a as getCore, C as CLIENT_SDK_NAME, j as isCookieEnabled, f as CHAINS_INFO_MAP, k as getChainFromVerifiedCredentialChain, n as name, v as version } from './getChainFromVerifiedCredentialChain.esm.js';
3
3
  import { a as DEFAULT_WAAS_BASE_MPC_RELAY_API_URL, b as DEFAULT_WAAS_BASE_API_URL, D as DYNAMIC_WAAS_METADATA } from './constants.esm.js';
4
4
  import { DynamicWalletClient, ThresholdSignatureScheme } from '@dynamic-labs-wallet/browser-wallet-client';
5
5
  import { MFAAction, WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
@@ -17,7 +17,8 @@ const createWaasClient = ({ chainName }, client)=>{
17
17
  baseApiUrl: (core.apiBaseUrl || DEFAULT_WAAS_BASE_API_URL).replace('/api/v0', ''),
18
18
  baseMPCRelayApiUrl: ((_client_projectSettings = client.projectSettings) == null ? void 0 : (_client_projectSettings_sdk_waas = _client_projectSettings.sdk.waas) == null ? void 0 : _client_projectSettings_sdk_waas.relayUrl) || DEFAULT_WAAS_BASE_MPC_RELAY_API_URL,
19
19
  chainName,
20
- environmentId: core.environmentId
20
+ environmentId: core.environmentId,
21
+ sdkVersion: `${CLIENT_SDK_NAME}/${core.version}`
21
22
  });
22
23
  };
23
24