@dynamic-labs/sdk-react-core 5.8.1 → 5.9.0

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,16 @@
1
1
 
2
+ ## [5.9.0](https://github.com/dynamic-labs/dynamic-auth/compare/v5.8.1...v5.9.0) (2026-09-16)
3
+
4
+
5
+ ### Features
6
+
7
+ * **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))
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * 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))
13
+
2
14
  ### [5.8.1](https://github.com/dynamic-labs/dynamic-auth/compare/v5.8.0...v5.8.1) (2026-09-15)
3
15
 
4
16
 
package/package.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "5.8.1";
6
+ var version = "5.9.0";
7
7
  var dependencies = {
8
8
  "@dynamic-labs/sdk-api-core": "0.32.0",
9
9
  "@dynamic-labs-sdk/client": "1.31.2",
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- var version = "5.8.1";
2
+ var version = "5.9.0";
3
3
  var dependencies = {
4
4
  "@dynamic-labs/sdk-api-core": "0.32.0",
5
5
  "@dynamic-labs-sdk/client": "1.31.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "5.8.1",
3
+ "version": "5.9.0",
4
4
  "dependencies": {
5
5
  "@dynamic-labs/sdk-api-core": "0.32.0",
6
6
  "@dynamic-labs-sdk/client": "1.31.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.0",
22
+ "@dynamic-labs/iconic": "5.9.0",
23
+ "@dynamic-labs/locale": "5.9.0",
24
+ "@dynamic-labs/logger": "5.9.0",
25
+ "@dynamic-labs/multi-wallet": "5.9.0",
26
+ "@dynamic-labs/rpc-providers": "5.9.0",
27
+ "@dynamic-labs/store": "5.9.0",
28
+ "@dynamic-labs/types": "5.9.0",
29
+ "@dynamic-labs/utils": "5.9.0",
30
+ "@dynamic-labs/wallet-book": "5.9.0",
31
+ "@dynamic-labs/wallet-connector-core": "5.9.0",
32
32
  "eventemitter3": "5.0.1"
33
33
  },
34
34
  "devDependencies": {
@@ -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,56 @@ 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);
104
138
  resolvedBusinessAccountId = account.id;
105
139
  }
106
140
  if (!resolvedBusinessAccountId) {
107
141
  throw new Error('addBusinessAccountSigner could not resolve a businessAccountId');
108
142
  }
143
+ // Step-up reauth can rotate the session, so drop the cached iframe
144
+ // client and let it re-auth with the fresh token before the reshare.
145
+ if (prompted) {
146
+ yield connector.getWaasWalletClient(undefined, { forceRebuild: true });
147
+ }
109
148
  return connector.addSignerViaReshare({
110
149
  accountAddress,
111
150
  businessAccountId: resolvedBusinessAccountId,
@@ -115,8 +154,8 @@ const useBusinessAccounts = () => {
115
154
  targetSignerPassword,
116
155
  walletId,
117
156
  });
118
- }), [addWalletToBusinessAccount, getWaasWalletConnector]);
119
- const createWalletForBusinessAccount = React.useCallback((_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ businessAccountId, chainName, thresholdSignatureScheme, password, }) {
157
+ }), [dynamicClient, ensureStepUpAuth, getWaasWalletConnector]);
158
+ const createWalletForBusinessAccount = React.useCallback((_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ businessAccountId, chainName, thresholdSignatureScheme, password, }) {
120
159
  const chain = chainName !== null && chainName !== void 0 ? chainName : defaultChainName;
121
160
  if (!chain) {
122
161
  throw new Error(NO_WAAS_CHAIN_ERROR);
@@ -135,13 +174,26 @@ const useBusinessAccounts = () => {
135
174
  const client = yield getBusinessClient();
136
175
  return client.getWallets();
137
176
  }), [getBusinessClient]);
138
- const removeBusinessAccountMember = React.useCallback((_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ businessAccountId, userId }) {
177
+ const removeBusinessAccountMember = React.useCallback((_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ businessAccountId, userId }) {
178
+ yield ensureStepUpAuth([sdkApiCore.TokenScope.BusinessAccountmemberremove]);
139
179
  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]);
180
+ }), [dynamicClient, ensureStepUpAuth]);
181
+ const updateBusinessAccountMemberRole = React.useCallback((input) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
182
+ yield ensureStepUpAuth([sdkApiCore.TokenScope.BusinessAccountmemberroleupdate]);
183
+ return waas.updateBusinessAccountMemberRole(input, dynamicClient);
184
+ }), [dynamicClient, ensureStepUpAuth]);
185
+ const transferBusinessAccountOwnership = React.useCallback((input) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
186
+ yield ensureStepUpAuth([sdkApiCore.TokenScope.BusinessAccounttransferOwnership]);
187
+ return waas.transferBusinessAccountOwnership(input, dynamicClient);
188
+ }), [dynamicClient, ensureStepUpAuth]);
189
+ const removeBusinessAccountWallet = React.useCallback((input) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
190
+ yield ensureStepUpAuth([sdkApiCore.TokenScope.BusinessAccountwalletremove]);
191
+ return waas.removeBusinessAccountWallet(input, dynamicClient);
192
+ }), [dynamicClient, ensureStepUpAuth]);
193
+ const removeBusinessAccountSigner = React.useCallback((input) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
194
+ yield ensureStepUpAuth([sdkApiCore.TokenScope.BusinessAccountsignerremove]);
195
+ return waas.removeBusinessAccountSigner(input, dynamicClient);
196
+ }), [dynamicClient, ensureStepUpAuth]);
145
197
  const updateBusinessAccount = React.useCallback((input) => _tslib.__awaiter(void 0, void 0, void 0, function* () { return waas.updateBusinessAccount(input, dynamicClient); }), [dynamicClient]);
146
198
  return {
147
199
  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").BusinessAccountMember>;
72
72
  addBusinessAccountSigner: ({ accountAddress, walletId, chainName, businessAccountId, targetSignerIdentity, signerType, password, targetSignerPassword, }: AddBusinessAccountSignerInput) => Promise<{
73
73
  shareSetId: string;
74
74
  }>;
75
- addWalletToBusinessAccount: (input: AddWalletToBusinessAccountInput) => Promise<any>;
75
+ addWalletToBusinessAccount: (input: AddWalletToBusinessAccountInput) => Promise<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;
@@ -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, 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,56 @@ 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);
100
134
  resolvedBusinessAccountId = account.id;
101
135
  }
102
136
  if (!resolvedBusinessAccountId) {
103
137
  throw new Error('addBusinessAccountSigner could not resolve a businessAccountId');
104
138
  }
139
+ // Step-up reauth can rotate the session, so drop the cached iframe
140
+ // client and let it re-auth with the fresh token before the reshare.
141
+ if (prompted) {
142
+ yield connector.getWaasWalletClient(undefined, { forceRebuild: true });
143
+ }
105
144
  return connector.addSignerViaReshare({
106
145
  accountAddress,
107
146
  businessAccountId: resolvedBusinessAccountId,
@@ -111,8 +150,8 @@ const useBusinessAccounts = () => {
111
150
  targetSignerPassword,
112
151
  walletId,
113
152
  });
114
- }), [addWalletToBusinessAccount, getWaasWalletConnector]);
115
- const createWalletForBusinessAccount = useCallback((_b) => __awaiter(void 0, [_b], void 0, function* ({ businessAccountId, chainName, thresholdSignatureScheme, password, }) {
153
+ }), [dynamicClient, ensureStepUpAuth, getWaasWalletConnector]);
154
+ const createWalletForBusinessAccount = useCallback((_c) => __awaiter(void 0, [_c], void 0, function* ({ businessAccountId, chainName, thresholdSignatureScheme, password, }) {
116
155
  const chain = chainName !== null && chainName !== void 0 ? chainName : defaultChainName;
117
156
  if (!chain) {
118
157
  throw new Error(NO_WAAS_CHAIN_ERROR);
@@ -131,18 +170,31 @@ const useBusinessAccounts = () => {
131
170
  const client = yield getBusinessClient();
132
171
  return client.getWallets();
133
172
  }), [getBusinessClient]);
134
- const removeBusinessAccountMember$1 = useCallback((_c) => __awaiter(void 0, [_c], void 0, function* ({ businessAccountId, userId }) {
173
+ const removeBusinessAccountMember$1 = useCallback((_d) => __awaiter(void 0, [_d], void 0, function* ({ businessAccountId, userId }) {
174
+ yield ensureStepUpAuth([TokenScope.BusinessAccountmemberremove]);
135
175
  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]);
176
+ }), [dynamicClient, ensureStepUpAuth]);
177
+ const updateBusinessAccountMemberRole$1 = useCallback((input) => __awaiter(void 0, void 0, void 0, function* () {
178
+ yield ensureStepUpAuth([TokenScope.BusinessAccountmemberroleupdate]);
179
+ return updateBusinessAccountMemberRole(input, dynamicClient);
180
+ }), [dynamicClient, ensureStepUpAuth]);
181
+ const transferBusinessAccountOwnership$1 = useCallback((input) => __awaiter(void 0, void 0, void 0, function* () {
182
+ yield ensureStepUpAuth([TokenScope.BusinessAccounttransferOwnership]);
183
+ return transferBusinessAccountOwnership(input, dynamicClient);
184
+ }), [dynamicClient, ensureStepUpAuth]);
185
+ const removeBusinessAccountWallet$1 = useCallback((input) => __awaiter(void 0, void 0, void 0, function* () {
186
+ yield ensureStepUpAuth([TokenScope.BusinessAccountwalletremove]);
187
+ return removeBusinessAccountWallet(input, dynamicClient);
188
+ }), [dynamicClient, ensureStepUpAuth]);
189
+ const removeBusinessAccountSigner$1 = useCallback((input) => __awaiter(void 0, void 0, void 0, function* () {
190
+ yield ensureStepUpAuth([TokenScope.BusinessAccountsignerremove]);
191
+ return removeBusinessAccountSigner(input, dynamicClient);
192
+ }), [dynamicClient, ensureStepUpAuth]);
141
193
  const updateBusinessAccount$1 = useCallback((input) => __awaiter(void 0, void 0, void 0, function* () { return updateBusinessAccount(input, dynamicClient); }), [dynamicClient]);
142
194
  return {
143
- addBusinessAccountMember,
195
+ addBusinessAccountMember: addBusinessAccountMember$1,
144
196
  addBusinessAccountSigner,
145
- addWalletToBusinessAccount,
197
+ addWalletToBusinessAccount: addWalletToBusinessAccount$1,
146
198
  createBusinessAccount,
147
199
  createWalletForBusinessAccount,
148
200
  defaultChainName,