@dynamic-labs/sdk-react-core 5.8.1 → 5.9.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,24 @@
1
1
 
2
+ ### [5.9.1](https://github.com/dynamic-labs/dynamic-auth/compare/v5.9.0...v5.9.1) (2026-09-18)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * **sdk-react-core:** sanitize interpolated values in theme stylesheet builder ([#12416](https://github.com/dynamic-labs/dynamic-auth/issues/12416)) ([f256c08](https://github.com/dynamic-labs/dynamic-auth/commit/f256c08209b7818292a7d4d76793c592bd0ca2a0))
8
+ * **webview-controller:** route MetaMask connector storage through native secure storage ([#12304](https://github.com/dynamic-labs/dynamic-auth/issues/12304)) ([627a483](https://github.com/dynamic-labs/dynamic-auth/commit/627a4839a8071d2b2eed1ef6536cd3ecfc833000)), closes [dynamic-labs-oss/public-wallet-connectors#189](https://github.com/dynamic-labs-oss/public-wallet-connectors/issues/189)
9
+
10
+ ## [5.9.0](https://github.com/dynamic-labs/dynamic-auth/compare/v5.8.1...v5.9.0) (2026-09-16)
11
+
12
+
13
+ ### Features
14
+
15
+ * **sdk-react-core:** gate business account mutations behind step-up auth ([#12410](https://github.com/dynamic-labs/dynamic-auth/issues/12410)) ([d394719](https://github.com/dynamic-labs/dynamic-auth/commit/d3947198f9f84debccdd3ae4a4321f56b24467fb))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * prefer dashboard-saved RPC urls when mapping viem chains ([#12404](https://github.com/dynamic-labs/dynamic-auth/issues/12404)) ([dfe75b4](https://github.com/dynamic-labs/dynamic-auth/commit/dfe75b4193cff46b0fa0ef014f8b040587a0667e))
21
+
2
22
  ### [5.8.1](https://github.com/dynamic-labs/dynamic-auth/compare/v5.8.0...v5.8.1) (2026-09-15)
3
23
 
4
24
 
package/package.cjs CHANGED
@@ -3,11 +3,11 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "5.8.1";
6
+ var version = "5.9.1";
7
7
  var dependencies = {
8
- "@dynamic-labs/sdk-api-core": "0.32.0",
9
- "@dynamic-labs-sdk/client": "1.31.2",
10
- "@dynamic-labs-wallet/browser-wallet-client": "1.0.118",
8
+ "@dynamic-labs/sdk-api-core": "0.40.0",
9
+ "@dynamic-labs-sdk/client": "1.33.3",
10
+ "@dynamic-labs-wallet/browser-wallet-client": "1.1.10",
11
11
  "@dynamic-labs-wallet/forward-mpc-client": "1.0.2",
12
12
  "@hcaptcha/react-hcaptcha": "1.4.4",
13
13
  "@marsidev/react-turnstile": "1.5.2",
package/package.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use client'
2
- var version = "5.8.1";
2
+ var version = "5.9.1";
3
3
  var dependencies = {
4
- "@dynamic-labs/sdk-api-core": "0.32.0",
5
- "@dynamic-labs-sdk/client": "1.31.2",
6
- "@dynamic-labs-wallet/browser-wallet-client": "1.0.118",
4
+ "@dynamic-labs/sdk-api-core": "0.40.0",
5
+ "@dynamic-labs-sdk/client": "1.33.3",
6
+ "@dynamic-labs-wallet/browser-wallet-client": "1.1.10",
7
7
  "@dynamic-labs-wallet/forward-mpc-client": "1.0.2",
8
8
  "@hcaptcha/react-hcaptcha": "1.4.4",
9
9
  "@marsidev/react-turnstile": "1.5.2",
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "5.8.1",
3
+ "version": "5.9.1",
4
4
  "dependencies": {
5
- "@dynamic-labs/sdk-api-core": "0.32.0",
6
- "@dynamic-labs-sdk/client": "1.31.2",
7
- "@dynamic-labs-wallet/browser-wallet-client": "1.0.118",
5
+ "@dynamic-labs/sdk-api-core": "0.40.0",
6
+ "@dynamic-labs-sdk/client": "1.33.3",
7
+ "@dynamic-labs-wallet/browser-wallet-client": "1.1.10",
8
8
  "@dynamic-labs-wallet/forward-mpc-client": "1.0.2",
9
9
  "@hcaptcha/react-hcaptcha": "1.4.4",
10
10
  "@marsidev/react-turnstile": "1.5.2",
@@ -18,17 +18,17 @@
18
18
  "react-i18next": "13.5.0",
19
19
  "react-international-phone": "4.5.0",
20
20
  "yup": "0.32.11",
21
- "@dynamic-labs/assert-package-version": "5.8.1",
22
- "@dynamic-labs/iconic": "5.8.1",
23
- "@dynamic-labs/locale": "5.8.1",
24
- "@dynamic-labs/logger": "5.8.1",
25
- "@dynamic-labs/multi-wallet": "5.8.1",
26
- "@dynamic-labs/rpc-providers": "5.8.1",
27
- "@dynamic-labs/store": "5.8.1",
28
- "@dynamic-labs/types": "5.8.1",
29
- "@dynamic-labs/utils": "5.8.1",
30
- "@dynamic-labs/wallet-book": "5.8.1",
31
- "@dynamic-labs/wallet-connector-core": "5.8.1",
21
+ "@dynamic-labs/assert-package-version": "5.9.1",
22
+ "@dynamic-labs/iconic": "5.9.1",
23
+ "@dynamic-labs/locale": "5.9.1",
24
+ "@dynamic-labs/logger": "5.9.1",
25
+ "@dynamic-labs/multi-wallet": "5.9.1",
26
+ "@dynamic-labs/rpc-providers": "5.9.1",
27
+ "@dynamic-labs/store": "5.9.1",
28
+ "@dynamic-labs/types": "5.9.1",
29
+ "@dynamic-labs/utils": "5.9.1",
30
+ "@dynamic-labs/wallet-book": "5.9.1",
31
+ "@dynamic-labs/wallet-connector-core": "5.9.1",
32
32
  "eventemitter3": "5.0.1"
33
33
  },
34
34
  "devDependencies": {
@@ -48,6 +48,14 @@ const findOrCreateStyleTag = (nonce) => {
48
48
  styleTag.dataset.source = 'dynamic-theme';
49
49
  return styleTag;
50
50
  };
51
+ // Characters outside this set could break out of a CSS declaration
52
+ // (e.g. `;`, `}`, `\` escapes, comments) when interpolated into the
53
+ // generated theme stylesheet. `/` (modern alpha syntax) and `_`
54
+ // (custom-property names) are safe: comments need `*` which is excluded
55
+ const SAFE_CSS_VALUE_PATTERN = /^[a-zA-Z0-9#(),.%_/\s+-]+$/;
56
+ const isSafeCssValue = (value) => value !== undefined &&
57
+ value !== '' &&
58
+ (typeof value === 'number' || SAFE_CSS_VALUE_PATTERN.test(value));
51
59
  const buildStylesheet = (theme) => {
52
60
  const { customColor, brandStyle } = theme;
53
61
  const footerBackgroundColor = brandStyle === 'bold' ? customColor : undefined;
@@ -61,7 +69,7 @@ const buildStylesheet = (theme) => {
61
69
  return `@layer dynamic-project-environment-theme {
62
70
  #dynamic-widget, #dynamic-modal, .dynamic-shadow-dom {
63
71
  ${cssAttributes
64
- .filter(([, value]) => value !== undefined && value !== '')
72
+ .filter(([, value]) => isSafeCssValue(value))
65
73
  .map(([key, value]) => `${key}: ${value};`)
66
74
  .join('\n ')}
67
75
  }
@@ -44,6 +44,14 @@ const findOrCreateStyleTag = (nonce) => {
44
44
  styleTag.dataset.source = 'dynamic-theme';
45
45
  return styleTag;
46
46
  };
47
+ // Characters outside this set could break out of a CSS declaration
48
+ // (e.g. `;`, `}`, `\` escapes, comments) when interpolated into the
49
+ // generated theme stylesheet. `/` (modern alpha syntax) and `_`
50
+ // (custom-property names) are safe: comments need `*` which is excluded
51
+ const SAFE_CSS_VALUE_PATTERN = /^[a-zA-Z0-9#(),.%_/\s+-]+$/;
52
+ const isSafeCssValue = (value) => value !== undefined &&
53
+ value !== '' &&
54
+ (typeof value === 'number' || SAFE_CSS_VALUE_PATTERN.test(value));
47
55
  const buildStylesheet = (theme) => {
48
56
  const { customColor, brandStyle } = theme;
49
57
  const footerBackgroundColor = brandStyle === 'bold' ? customColor : undefined;
@@ -57,7 +65,7 @@ const buildStylesheet = (theme) => {
57
65
  return `@layer dynamic-project-environment-theme {
58
66
  #dynamic-widget, #dynamic-modal, .dynamic-shadow-dom {
59
67
  ${cssAttributes
60
- .filter(([, value]) => value !== undefined && value !== '')
68
+ .filter(([, value]) => isSafeCssValue(value))
61
69
  .map(([key, value]) => `${key}: ${value};`)
62
70
  .join('\n ')}
63
71
  }
@@ -6,9 +6,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
7
  var React = require('react');
8
8
  var waas = require('@dynamic-labs-sdk/client/waas');
9
+ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
9
10
  var client = require('../../../client/client.cjs');
10
11
  require('@dynamic-labs-sdk/client/core');
11
- require('@dynamic-labs/sdk-api-core');
12
12
  require('@dynamic-labs-sdk/client');
13
13
  require('../../../config/ApiEndpoint.cjs');
14
14
  require('@dynamic-labs/iconic');
@@ -33,6 +33,7 @@ require('../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
33
33
  require('../../../events/dynamicEvents.cjs');
34
34
  var useProjectSettings = require('../../../client/extension/projectSettings/useProjectSettings/useProjectSettings.cjs');
35
35
  var useDynamicWaas = require('../useDynamicWaas/useDynamicWaas.cjs');
36
+ var useStepUpAuthentication = require('../useStepUpAuthentication/useStepUpAuthentication.cjs');
36
37
 
37
38
  const NO_WAAS_CHAIN_ERROR = 'No enabled WaaS chain found for business account operations';
38
39
  const NO_CONNECTOR_ERROR = 'WaaS wallet connector not found';
@@ -40,6 +41,7 @@ const useBusinessAccounts = () => {
40
41
  const { getWaasWalletConnector } = useDynamicWaas.useDynamicWaas();
41
42
  const projectSettings = useProjectSettings.useProjectSettings();
42
43
  const dynamicClient = client.useDynamicClient();
44
+ const { isStepUpRequired, promptStepUpAuth } = useStepUpAuthentication.useStepUpAuthentication();
43
45
  const enabledChainNames = React.useMemo(() => {
44
46
  var _a, _b;
45
47
  return ((_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.chainConfigurations) !== null && _b !== void 0 ? _b : [])
@@ -64,6 +66,23 @@ const useBusinessAccounts = () => {
64
66
  }
65
67
  return connector.getWaasWalletClient();
66
68
  }), [defaultChainName, getWaasWalletConnector]);
69
+ // Forces the step-up auth popup for every scope that still lacks a valid
70
+ // elevated token, so mutating business account calls always carry one.
71
+ // Returns whether a prompt ran, so connector-based callers can rebuild the
72
+ // cached iframe client after a session rotation.
73
+ const ensureStepUpAuth = React.useCallback((scopes) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
74
+ const requiredScopes = [];
75
+ for (const scope of scopes) {
76
+ if (yield isStepUpRequired({ scope })) {
77
+ requiredScopes.push(scope);
78
+ }
79
+ }
80
+ if (requiredScopes.length === 0) {
81
+ return false;
82
+ }
83
+ yield promptStepUpAuth({ requestedScopes: requiredScopes });
84
+ return true;
85
+ }), [isStepUpRequired, promptStepUpAuth]);
67
86
  const createBusinessAccount = React.useCallback((...args_1) => _tslib.__awaiter(void 0, [...args_1], void 0, function* (input = {}) {
68
87
  const client = yield getBusinessClient();
69
88
  return client.businessAccounts.createBusinessAccount({ request: input });
@@ -76,36 +95,59 @@ const useBusinessAccounts = () => {
76
95
  const client = yield getBusinessClient();
77
96
  return client.businessAccounts.getBusinessAccount({ businessAccountId });
78
97
  }), [getBusinessClient]);
79
- const addBusinessAccountMember = React.useCallback((input) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
80
- const client = yield getBusinessClient();
81
- return client.businessAccounts.addMember(input);
82
- }), [getBusinessClient]);
98
+ const addBusinessAccountMember = React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ businessAccountId, userId, identifier, identifierType, role, }) {
99
+ yield ensureStepUpAuth([sdkApiCore.TokenScope.BusinessAccountmemberadd]);
100
+ return waas.addBusinessAccountMember({
101
+ businessAccountId,
102
+ role,
103
+ targetIdentity: { identifier, identifierType, userId },
104
+ }, dynamicClient);
105
+ }), [dynamicClient, ensureStepUpAuth]);
83
106
  const addWalletToBusinessAccount = React.useCallback((input) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
84
- const client = yield getBusinessClient();
85
- return client.businessAccounts.addWalletToBusinessAccount(input);
86
- }), [getBusinessClient]);
107
+ yield ensureStepUpAuth([sdkApiCore.TokenScope.BusinessAccountlinkWallet]);
108
+ return waas.addWalletToBusinessAccount(input, dynamicClient);
109
+ }), [dynamicClient, ensureStepUpAuth]);
87
110
  // Adds a signer via the SSE reshare ceremony on the wallet's chain connector.
88
111
  // Mints the new signer's share set and seeds it to client-keyshare-service.
89
- const addBusinessAccountSigner = React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ accountAddress, walletId, chainName, businessAccountId, targetSignerIdentity, signerType, password, targetSignerPassword, }) {
112
+ const addBusinessAccountSigner = React.useCallback((_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ accountAddress, walletId, chainName, businessAccountId, targetSignerIdentity, signerType, password, targetSignerPassword, }) {
90
113
  const connector = getWaasWalletConnector(chainName);
91
114
  if (!connector) {
92
115
  throw new Error(NO_CONNECTOR_ERROR);
93
116
  }
117
+ if (!businessAccountId && !walletId) {
118
+ throw new Error('addBusinessAccountSigner requires a walletId when no businessAccountId is provided');
119
+ }
94
120
  // No account yet: find-or-create the per-wallet business account first
95
121
  // (idempotent — converts the personal wallet, seating its owner as the
96
122
  // first signer, or returns the existing one if already linked), then
97
- // reshare the new signer into it.
123
+ // reshare the new signer into it. That path also needs the link_wallet
124
+ // elevation, so request both scopes in a single step-up prompt.
125
+ const requiredScopes = businessAccountId
126
+ ? [sdkApiCore.TokenScope.BusinessAccountsigneradd]
127
+ : [
128
+ sdkApiCore.TokenScope.BusinessAccountsigneradd,
129
+ sdkApiCore.TokenScope.BusinessAccountlinkWallet,
130
+ ];
131
+ const prompted = yield ensureStepUpAuth(requiredScopes);
98
132
  let resolvedBusinessAccountId = businessAccountId;
99
133
  if (!resolvedBusinessAccountId) {
100
134
  if (!walletId) {
101
135
  throw new Error('addBusinessAccountSigner requires a walletId when no businessAccountId is provided');
102
136
  }
103
- const account = yield addWalletToBusinessAccount({ walletId });
137
+ const account = yield waas.addWalletToBusinessAccount({ walletId }, dynamicClient);
138
+ if (waas.isBusinessAccountActionRequired(account)) {
139
+ throw new Error(`addBusinessAccountSigner requires approval: ${account.reason}`);
140
+ }
104
141
  resolvedBusinessAccountId = account.id;
105
142
  }
106
143
  if (!resolvedBusinessAccountId) {
107
144
  throw new Error('addBusinessAccountSigner could not resolve a businessAccountId');
108
145
  }
146
+ // Step-up reauth can rotate the session, so drop the cached iframe
147
+ // client and let it re-auth with the fresh token before the reshare.
148
+ if (prompted) {
149
+ yield connector.getWaasWalletClient(undefined, { forceRebuild: true });
150
+ }
109
151
  return connector.addSignerViaReshare({
110
152
  accountAddress,
111
153
  businessAccountId: resolvedBusinessAccountId,
@@ -115,8 +157,8 @@ const useBusinessAccounts = () => {
115
157
  targetSignerPassword,
116
158
  walletId,
117
159
  });
118
- }), [addWalletToBusinessAccount, getWaasWalletConnector]);
119
- const createWalletForBusinessAccount = React.useCallback((_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ businessAccountId, chainName, thresholdSignatureScheme, password, }) {
160
+ }), [dynamicClient, ensureStepUpAuth, getWaasWalletConnector]);
161
+ const createWalletForBusinessAccount = React.useCallback((_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ businessAccountId, chainName, thresholdSignatureScheme, password, }) {
120
162
  const chain = chainName !== null && chainName !== void 0 ? chainName : defaultChainName;
121
163
  if (!chain) {
122
164
  throw new Error(NO_WAAS_CHAIN_ERROR);
@@ -135,13 +177,26 @@ const useBusinessAccounts = () => {
135
177
  const client = yield getBusinessClient();
136
178
  return client.getWallets();
137
179
  }), [getBusinessClient]);
138
- const removeBusinessAccountMember = React.useCallback((_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ businessAccountId, userId }) {
180
+ const removeBusinessAccountMember = React.useCallback((_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ businessAccountId, userId }) {
181
+ yield ensureStepUpAuth([sdkApiCore.TokenScope.BusinessAccountmemberremove]);
139
182
  return waas.removeBusinessAccountMember({ businessAccountId, userId }, dynamicClient);
140
- }), [dynamicClient]);
141
- const updateBusinessAccountMemberRole = React.useCallback((input) => _tslib.__awaiter(void 0, void 0, void 0, function* () { return waas.updateBusinessAccountMemberRole(input, dynamicClient); }), [dynamicClient]);
142
- const transferBusinessAccountOwnership = React.useCallback((input) => _tslib.__awaiter(void 0, void 0, void 0, function* () { return waas.transferBusinessAccountOwnership(input, dynamicClient); }), [dynamicClient]);
143
- const removeBusinessAccountWallet = React.useCallback((input) => _tslib.__awaiter(void 0, void 0, void 0, function* () { return waas.removeBusinessAccountWallet(input, dynamicClient); }), [dynamicClient]);
144
- const removeBusinessAccountSigner = React.useCallback((input) => _tslib.__awaiter(void 0, void 0, void 0, function* () { return waas.removeBusinessAccountSigner(input, dynamicClient); }), [dynamicClient]);
183
+ }), [dynamicClient, ensureStepUpAuth]);
184
+ const updateBusinessAccountMemberRole = React.useCallback((input) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
185
+ yield ensureStepUpAuth([sdkApiCore.TokenScope.BusinessAccountmemberroleupdate]);
186
+ return waas.updateBusinessAccountMemberRole(input, dynamicClient);
187
+ }), [dynamicClient, ensureStepUpAuth]);
188
+ const transferBusinessAccountOwnership = React.useCallback((input) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
189
+ yield ensureStepUpAuth([sdkApiCore.TokenScope.BusinessAccounttransferOwnership]);
190
+ return waas.transferBusinessAccountOwnership(input, dynamicClient);
191
+ }), [dynamicClient, ensureStepUpAuth]);
192
+ const removeBusinessAccountWallet = React.useCallback((input) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
193
+ yield ensureStepUpAuth([sdkApiCore.TokenScope.BusinessAccountwalletremove]);
194
+ return waas.removeBusinessAccountWallet(input, dynamicClient);
195
+ }), [dynamicClient, ensureStepUpAuth]);
196
+ const removeBusinessAccountSigner = React.useCallback((input) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
197
+ yield ensureStepUpAuth([sdkApiCore.TokenScope.BusinessAccountsignerremove]);
198
+ return waas.removeBusinessAccountSigner(input, dynamicClient);
199
+ }), [dynamicClient, ensureStepUpAuth]);
145
200
  const updateBusinessAccount = React.useCallback((input) => _tslib.__awaiter(void 0, void 0, void 0, function* () { return waas.updateBusinessAccount(input, dynamicClient); }), [dynamicClient]);
146
201
  return {
147
202
  addBusinessAccountMember,
@@ -68,11 +68,11 @@ export type AddBusinessAccountSignerInput = {
68
68
  targetSignerPassword?: string;
69
69
  };
70
70
  export declare const useBusinessAccounts: () => {
71
- addBusinessAccountMember: (input: AddBusinessAccountMemberInput) => Promise<any>;
71
+ addBusinessAccountMember: ({ businessAccountId, userId, identifier, identifierType, role, }: AddBusinessAccountMemberInput) => Promise<import("@dynamic-labs-sdk/client/waas").BusinessAccountActionRequired | import("@dynamic-labs-sdk/client/waas").BusinessAccountMember>;
72
72
  addBusinessAccountSigner: ({ accountAddress, walletId, chainName, businessAccountId, targetSignerIdentity, signerType, password, targetSignerPassword, }: AddBusinessAccountSignerInput) => Promise<{
73
73
  shareSetId: string;
74
- }>;
75
- addWalletToBusinessAccount: (input: AddWalletToBusinessAccountInput) => Promise<any>;
74
+ } | import("@dynamic-labs-wallet/core").BusinessAccountActionRequired>;
75
+ addWalletToBusinessAccount: (input: AddWalletToBusinessAccountInput) => Promise<import("@dynamic-labs-sdk/client/waas").BusinessAccountActionRequired | import("@dynamic-labs-sdk/client/waas").BusinessAccountDetail>;
76
76
  createBusinessAccount: (input?: CreateBusinessAccountInput) => Promise<any>;
77
77
  createWalletForBusinessAccount: ({ businessAccountId, chainName, thresholdSignatureScheme, password, }: CreateWalletForBusinessAccountInput) => Promise<{
78
78
  accountAddress: string;
@@ -84,10 +84,10 @@ export declare const useBusinessAccounts: () => {
84
84
  getBusinessAccount: (businessAccountId: string) => Promise<any>;
85
85
  listBusinessAccounts: (input?: ListBusinessAccountsInput) => Promise<any>;
86
86
  listMyWalletAccounts: () => Promise<any>;
87
- removeBusinessAccountMember: ({ businessAccountId, userId }: RemoveBusinessAccountMemberInput) => Promise<import("@dynamic-labs-sdk/client/waas").BusinessAccountMember>;
88
- removeBusinessAccountSigner: (input: RemoveBusinessAccountSignerInput) => Promise<import("@dynamic-labs-sdk/client/waas").BusinessAccountSigner>;
89
- removeBusinessAccountWallet: (input: RemoveBusinessAccountWalletInput) => Promise<import("@dynamic-labs-sdk/client/waas").BusinessAccountDetail>;
90
- transferBusinessAccountOwnership: (input: TransferBusinessAccountOwnershipInput) => Promise<import("@dynamic-labs-sdk/client/waas").BusinessAccountDetail>;
87
+ removeBusinessAccountMember: ({ businessAccountId, userId }: RemoveBusinessAccountMemberInput) => Promise<import("@dynamic-labs-sdk/client/waas").BusinessAccountActionRequired | import("@dynamic-labs-sdk/client/waas").BusinessAccountMember>;
88
+ removeBusinessAccountSigner: (input: RemoveBusinessAccountSignerInput) => Promise<import("@dynamic-labs-sdk/client/waas").BusinessAccountActionRequired | import("@dynamic-labs-sdk/client/waas").BusinessAccountSigner>;
89
+ removeBusinessAccountWallet: (input: RemoveBusinessAccountWalletInput) => Promise<import("@dynamic-labs-sdk/client/waas").BusinessAccountActionRequired | import("@dynamic-labs-sdk/client/waas").BusinessAccountDetail>;
90
+ transferBusinessAccountOwnership: (input: TransferBusinessAccountOwnershipInput) => Promise<import("@dynamic-labs-sdk/client/waas").BusinessAccountActionRequired | import("@dynamic-labs-sdk/client/waas").BusinessAccountDetail>;
91
91
  updateBusinessAccount: (input: UpdateBusinessAccountInput) => Promise<import("@dynamic-labs-sdk/client/waas").BusinessAccount>;
92
- updateBusinessAccountMemberRole: (input: UpdateBusinessAccountMemberRoleInput) => Promise<import("@dynamic-labs-sdk/client/waas").BusinessAccountMember>;
92
+ updateBusinessAccountMemberRole: (input: UpdateBusinessAccountMemberRoleInput) => Promise<import("@dynamic-labs-sdk/client/waas").BusinessAccountActionRequired | import("@dynamic-labs-sdk/client/waas").BusinessAccountMember>;
93
93
  };
@@ -1,10 +1,10 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
3
  import { useMemo, useCallback } from 'react';
4
- import { removeBusinessAccountMember, updateBusinessAccountMemberRole, transferBusinessAccountOwnership, removeBusinessAccountWallet, removeBusinessAccountSigner, updateBusinessAccount } from '@dynamic-labs-sdk/client/waas';
4
+ import { addBusinessAccountMember, addWalletToBusinessAccount, isBusinessAccountActionRequired, removeBusinessAccountMember, updateBusinessAccountMemberRole, transferBusinessAccountOwnership, removeBusinessAccountWallet, removeBusinessAccountSigner, updateBusinessAccount } from '@dynamic-labs-sdk/client/waas';
5
+ import { TokenScope } from '@dynamic-labs/sdk-api-core';
5
6
  import { useDynamicClient } from '../../../client/client.js';
6
7
  import '@dynamic-labs-sdk/client/core';
7
- import '@dynamic-labs/sdk-api-core';
8
8
  import '@dynamic-labs-sdk/client';
9
9
  import '../../../config/ApiEndpoint.js';
10
10
  import '@dynamic-labs/iconic';
@@ -29,6 +29,7 @@ import '../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
29
29
  import '../../../events/dynamicEvents.js';
30
30
  import { useProjectSettings } from '../../../client/extension/projectSettings/useProjectSettings/useProjectSettings.js';
31
31
  import { useDynamicWaas } from '../useDynamicWaas/useDynamicWaas.js';
32
+ import { useStepUpAuthentication } from '../useStepUpAuthentication/useStepUpAuthentication.js';
32
33
 
33
34
  const NO_WAAS_CHAIN_ERROR = 'No enabled WaaS chain found for business account operations';
34
35
  const NO_CONNECTOR_ERROR = 'WaaS wallet connector not found';
@@ -36,6 +37,7 @@ const useBusinessAccounts = () => {
36
37
  const { getWaasWalletConnector } = useDynamicWaas();
37
38
  const projectSettings = useProjectSettings();
38
39
  const dynamicClient = useDynamicClient();
40
+ const { isStepUpRequired, promptStepUpAuth } = useStepUpAuthentication();
39
41
  const enabledChainNames = useMemo(() => {
40
42
  var _a, _b;
41
43
  return ((_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.chainConfigurations) !== null && _b !== void 0 ? _b : [])
@@ -60,6 +62,23 @@ const useBusinessAccounts = () => {
60
62
  }
61
63
  return connector.getWaasWalletClient();
62
64
  }), [defaultChainName, getWaasWalletConnector]);
65
+ // Forces the step-up auth popup for every scope that still lacks a valid
66
+ // elevated token, so mutating business account calls always carry one.
67
+ // Returns whether a prompt ran, so connector-based callers can rebuild the
68
+ // cached iframe client after a session rotation.
69
+ const ensureStepUpAuth = useCallback((scopes) => __awaiter(void 0, void 0, void 0, function* () {
70
+ const requiredScopes = [];
71
+ for (const scope of scopes) {
72
+ if (yield isStepUpRequired({ scope })) {
73
+ requiredScopes.push(scope);
74
+ }
75
+ }
76
+ if (requiredScopes.length === 0) {
77
+ return false;
78
+ }
79
+ yield promptStepUpAuth({ requestedScopes: requiredScopes });
80
+ return true;
81
+ }), [isStepUpRequired, promptStepUpAuth]);
63
82
  const createBusinessAccount = useCallback((...args_1) => __awaiter(void 0, [...args_1], void 0, function* (input = {}) {
64
83
  const client = yield getBusinessClient();
65
84
  return client.businessAccounts.createBusinessAccount({ request: input });
@@ -72,36 +91,59 @@ const useBusinessAccounts = () => {
72
91
  const client = yield getBusinessClient();
73
92
  return client.businessAccounts.getBusinessAccount({ businessAccountId });
74
93
  }), [getBusinessClient]);
75
- const addBusinessAccountMember = useCallback((input) => __awaiter(void 0, void 0, void 0, function* () {
76
- const client = yield getBusinessClient();
77
- return client.businessAccounts.addMember(input);
78
- }), [getBusinessClient]);
79
- const addWalletToBusinessAccount = useCallback((input) => __awaiter(void 0, void 0, void 0, function* () {
80
- const client = yield getBusinessClient();
81
- return client.businessAccounts.addWalletToBusinessAccount(input);
82
- }), [getBusinessClient]);
94
+ const addBusinessAccountMember$1 = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ businessAccountId, userId, identifier, identifierType, role, }) {
95
+ yield ensureStepUpAuth([TokenScope.BusinessAccountmemberadd]);
96
+ return addBusinessAccountMember({
97
+ businessAccountId,
98
+ role,
99
+ targetIdentity: { identifier, identifierType, userId },
100
+ }, dynamicClient);
101
+ }), [dynamicClient, ensureStepUpAuth]);
102
+ const addWalletToBusinessAccount$1 = useCallback((input) => __awaiter(void 0, void 0, void 0, function* () {
103
+ yield ensureStepUpAuth([TokenScope.BusinessAccountlinkWallet]);
104
+ return addWalletToBusinessAccount(input, dynamicClient);
105
+ }), [dynamicClient, ensureStepUpAuth]);
83
106
  // Adds a signer via the SSE reshare ceremony on the wallet's chain connector.
84
107
  // Mints the new signer's share set and seeds it to client-keyshare-service.
85
- const addBusinessAccountSigner = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ accountAddress, walletId, chainName, businessAccountId, targetSignerIdentity, signerType, password, targetSignerPassword, }) {
108
+ const addBusinessAccountSigner = useCallback((_b) => __awaiter(void 0, [_b], void 0, function* ({ accountAddress, walletId, chainName, businessAccountId, targetSignerIdentity, signerType, password, targetSignerPassword, }) {
86
109
  const connector = getWaasWalletConnector(chainName);
87
110
  if (!connector) {
88
111
  throw new Error(NO_CONNECTOR_ERROR);
89
112
  }
113
+ if (!businessAccountId && !walletId) {
114
+ throw new Error('addBusinessAccountSigner requires a walletId when no businessAccountId is provided');
115
+ }
90
116
  // No account yet: find-or-create the per-wallet business account first
91
117
  // (idempotent — converts the personal wallet, seating its owner as the
92
118
  // first signer, or returns the existing one if already linked), then
93
- // reshare the new signer into it.
119
+ // reshare the new signer into it. That path also needs the link_wallet
120
+ // elevation, so request both scopes in a single step-up prompt.
121
+ const requiredScopes = businessAccountId
122
+ ? [TokenScope.BusinessAccountsigneradd]
123
+ : [
124
+ TokenScope.BusinessAccountsigneradd,
125
+ TokenScope.BusinessAccountlinkWallet,
126
+ ];
127
+ const prompted = yield ensureStepUpAuth(requiredScopes);
94
128
  let resolvedBusinessAccountId = businessAccountId;
95
129
  if (!resolvedBusinessAccountId) {
96
130
  if (!walletId) {
97
131
  throw new Error('addBusinessAccountSigner requires a walletId when no businessAccountId is provided');
98
132
  }
99
- const account = yield addWalletToBusinessAccount({ walletId });
133
+ const account = yield addWalletToBusinessAccount({ walletId }, dynamicClient);
134
+ if (isBusinessAccountActionRequired(account)) {
135
+ throw new Error(`addBusinessAccountSigner requires approval: ${account.reason}`);
136
+ }
100
137
  resolvedBusinessAccountId = account.id;
101
138
  }
102
139
  if (!resolvedBusinessAccountId) {
103
140
  throw new Error('addBusinessAccountSigner could not resolve a businessAccountId');
104
141
  }
142
+ // Step-up reauth can rotate the session, so drop the cached iframe
143
+ // client and let it re-auth with the fresh token before the reshare.
144
+ if (prompted) {
145
+ yield connector.getWaasWalletClient(undefined, { forceRebuild: true });
146
+ }
105
147
  return connector.addSignerViaReshare({
106
148
  accountAddress,
107
149
  businessAccountId: resolvedBusinessAccountId,
@@ -111,8 +153,8 @@ const useBusinessAccounts = () => {
111
153
  targetSignerPassword,
112
154
  walletId,
113
155
  });
114
- }), [addWalletToBusinessAccount, getWaasWalletConnector]);
115
- const createWalletForBusinessAccount = useCallback((_b) => __awaiter(void 0, [_b], void 0, function* ({ businessAccountId, chainName, thresholdSignatureScheme, password, }) {
156
+ }), [dynamicClient, ensureStepUpAuth, getWaasWalletConnector]);
157
+ const createWalletForBusinessAccount = useCallback((_c) => __awaiter(void 0, [_c], void 0, function* ({ businessAccountId, chainName, thresholdSignatureScheme, password, }) {
116
158
  const chain = chainName !== null && chainName !== void 0 ? chainName : defaultChainName;
117
159
  if (!chain) {
118
160
  throw new Error(NO_WAAS_CHAIN_ERROR);
@@ -131,18 +173,31 @@ const useBusinessAccounts = () => {
131
173
  const client = yield getBusinessClient();
132
174
  return client.getWallets();
133
175
  }), [getBusinessClient]);
134
- const removeBusinessAccountMember$1 = useCallback((_c) => __awaiter(void 0, [_c], void 0, function* ({ businessAccountId, userId }) {
176
+ const removeBusinessAccountMember$1 = useCallback((_d) => __awaiter(void 0, [_d], void 0, function* ({ businessAccountId, userId }) {
177
+ yield ensureStepUpAuth([TokenScope.BusinessAccountmemberremove]);
135
178
  return removeBusinessAccountMember({ businessAccountId, userId }, dynamicClient);
136
- }), [dynamicClient]);
137
- const updateBusinessAccountMemberRole$1 = useCallback((input) => __awaiter(void 0, void 0, void 0, function* () { return updateBusinessAccountMemberRole(input, dynamicClient); }), [dynamicClient]);
138
- const transferBusinessAccountOwnership$1 = useCallback((input) => __awaiter(void 0, void 0, void 0, function* () { return transferBusinessAccountOwnership(input, dynamicClient); }), [dynamicClient]);
139
- const removeBusinessAccountWallet$1 = useCallback((input) => __awaiter(void 0, void 0, void 0, function* () { return removeBusinessAccountWallet(input, dynamicClient); }), [dynamicClient]);
140
- const removeBusinessAccountSigner$1 = useCallback((input) => __awaiter(void 0, void 0, void 0, function* () { return removeBusinessAccountSigner(input, dynamicClient); }), [dynamicClient]);
179
+ }), [dynamicClient, ensureStepUpAuth]);
180
+ const updateBusinessAccountMemberRole$1 = useCallback((input) => __awaiter(void 0, void 0, void 0, function* () {
181
+ yield ensureStepUpAuth([TokenScope.BusinessAccountmemberroleupdate]);
182
+ return updateBusinessAccountMemberRole(input, dynamicClient);
183
+ }), [dynamicClient, ensureStepUpAuth]);
184
+ const transferBusinessAccountOwnership$1 = useCallback((input) => __awaiter(void 0, void 0, void 0, function* () {
185
+ yield ensureStepUpAuth([TokenScope.BusinessAccounttransferOwnership]);
186
+ return transferBusinessAccountOwnership(input, dynamicClient);
187
+ }), [dynamicClient, ensureStepUpAuth]);
188
+ const removeBusinessAccountWallet$1 = useCallback((input) => __awaiter(void 0, void 0, void 0, function* () {
189
+ yield ensureStepUpAuth([TokenScope.BusinessAccountwalletremove]);
190
+ return removeBusinessAccountWallet(input, dynamicClient);
191
+ }), [dynamicClient, ensureStepUpAuth]);
192
+ const removeBusinessAccountSigner$1 = useCallback((input) => __awaiter(void 0, void 0, void 0, function* () {
193
+ yield ensureStepUpAuth([TokenScope.BusinessAccountsignerremove]);
194
+ return removeBusinessAccountSigner(input, dynamicClient);
195
+ }), [dynamicClient, ensureStepUpAuth]);
141
196
  const updateBusinessAccount$1 = useCallback((input) => __awaiter(void 0, void 0, void 0, function* () { return updateBusinessAccount(input, dynamicClient); }), [dynamicClient]);
142
197
  return {
143
- addBusinessAccountMember,
198
+ addBusinessAccountMember: addBusinessAccountMember$1,
144
199
  addBusinessAccountSigner,
145
- addWalletToBusinessAccount,
200
+ addWalletToBusinessAccount: addWalletToBusinessAccount$1,
146
201
  createBusinessAccount,
147
202
  createWalletForBusinessAccount,
148
203
  defaultChainName,