@dynamic-labs/sdk-react-core 4.63.1 → 4.65.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 +23 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +13 -13
- package/src/index.cjs +2 -0
- package/src/index.d.ts +2 -1
- package/src/index.js +1 -0
- package/src/lib/components/LegacySafariCssOverrides/LegacySafariCssOverrides.cjs +1 -1
- package/src/lib/components/LegacySafariCssOverrides/LegacySafariCssOverrides.d.ts +5 -1
- package/src/lib/components/LegacySafariCssOverrides/LegacySafariCssOverrides.js +1 -1
- package/src/lib/components/ShadowDOM/ShadowDOM.cjs +6 -6
- package/src/lib/components/ShadowDOM/ShadowDOM.d.ts +4 -1
- package/src/lib/components/ShadowDOM/ShadowDOM.js +6 -6
- package/src/lib/context/DynamicContext/DynamicContext.cjs +4 -2
- package/src/lib/context/DynamicContext/DynamicContext.js +4 -2
- package/src/lib/context/DynamicContext/types/DynamicContextProps.d.ts +6 -0
- package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +1 -0
- package/src/lib/context/DynamicContext/types/IInternalDynamicContext.d.ts +5 -1
- package/src/lib/context/ThemeContext/ThemeContext.cjs +3 -3
- package/src/lib/context/ThemeContext/ThemeContext.d.ts +1 -0
- package/src/lib/context/ThemeContext/ThemeContext.js +3 -3
- package/src/lib/context/ThemeContext/utils/stylesheetBuilder/stylesheetBuilder.cjs +8 -2
- package/src/lib/context/ThemeContext/utils/stylesheetBuilder/stylesheetBuilder.d.ts +2 -2
- package/src/lib/context/ThemeContext/utils/stylesheetBuilder/stylesheetBuilder.js +8 -2
- package/src/lib/data/api/wallets/wallets.cjs +62 -11
- package/src/lib/data/api/wallets/wallets.d.ts +1 -0
- package/src/lib/data/api/wallets/wallets.js +62 -12
- package/src/lib/shared/types/connectionAndSignature.d.ts +2 -1
- package/src/lib/shared/types/wallets.d.ts +2 -1
- package/src/lib/utils/functions/compareChains/compareChains.cjs +1 -0
- package/src/lib/utils/functions/compareChains/compareChains.js +1 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +6 -5
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.d.ts +3 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +6 -5
- package/src/lib/utils/hooks/index.d.ts +2 -0
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.cjs +20 -1
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.js +20 -1
- package/src/lib/utils/hooks/useStepUpAuthentication/index.d.ts +2 -0
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.cjs +197 -0
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.d.ts +51 -0
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.js +193 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +8 -3
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.d.ts +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +9 -4
- package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.cjs +30 -0
- package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.d.ts +6 -0
- package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.js +30 -0
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +1 -0
- package/src/lib/views/SendBalanceView/SendBalanceView.js +1 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.cjs +17 -21
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.js +17 -21
|
@@ -49,6 +49,7 @@ const storeSelectedWallet = (_a) => _tslib.__awaiter(void 0, [_a], void 0, funct
|
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
const linkWallet = (environmentId_1, _b) => _tslib.__awaiter(void 0, [environmentId_1, _b], void 0, function* (environmentId, { messageToSign, network, signedMessage, publicWalletAddress, chain, walletName, walletProvider, additionalWalletAddresses, backup, }) {
|
|
52
|
+
var _c;
|
|
52
53
|
const verifyRequest = sdkApiCore.VerifyRequestFromJSON({
|
|
53
54
|
additionalWalletAddresses,
|
|
54
55
|
backup,
|
|
@@ -84,13 +85,13 @@ const linkWallet = (environmentId_1, _b) => _tslib.__awaiter(void 0, [environmen
|
|
|
84
85
|
walletAddress: publicWalletAddress,
|
|
85
86
|
});
|
|
86
87
|
}
|
|
87
|
-
if (data.error.code === 'sandbox_maximum_threshold_reached') {
|
|
88
|
+
if (((_c = data.error) === null || _c === void 0 ? void 0 : _c.code) === 'sandbox_maximum_threshold_reached') {
|
|
88
89
|
throw new utils$1.SandboxMaximumThresholdReachedError(data.error.message);
|
|
89
90
|
}
|
|
90
91
|
throw new utils$1.DynamicError(data.error);
|
|
91
92
|
}
|
|
92
93
|
});
|
|
93
|
-
const unlinkWallet = (
|
|
94
|
+
const unlinkWallet = (_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ environmentId, primaryWalletId, walletId, onSuccess, }) {
|
|
94
95
|
// 7702 wallets have a -zerodev suffix because it's a credential created on the fly
|
|
95
96
|
const normalizedPrimaryWalletId = primaryWalletId === null || primaryWalletId === void 0 ? void 0 : primaryWalletId.replace('-zerodev', '');
|
|
96
97
|
try {
|
|
@@ -110,7 +111,7 @@ const unlinkWallet = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({
|
|
|
110
111
|
throw new utils$1.DynamicError(data.error);
|
|
111
112
|
}
|
|
112
113
|
});
|
|
113
|
-
const transferWallet = (environmentId_2,
|
|
114
|
+
const transferWallet = (environmentId_2, _e) => _tslib.__awaiter(void 0, [environmentId_2, _e], void 0, function* (environmentId, { network, messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, skipEmptyAccountCheck = false, }) {
|
|
114
115
|
// We should find a better way to do this than force type casting
|
|
115
116
|
const verifyRequest = {
|
|
116
117
|
chain,
|
|
@@ -135,7 +136,8 @@ const transferWallet = (environmentId_2, _d) => _tslib.__awaiter(void 0, [enviro
|
|
|
135
136
|
throw new utils$1.DynamicError(data.error);
|
|
136
137
|
}
|
|
137
138
|
});
|
|
138
|
-
const verifyWallet = (environmentId_3,
|
|
139
|
+
const verifyWallet = (environmentId_3, _f) => _tslib.__awaiter(void 0, [environmentId_3, _f], void 0, function* (environmentId, { messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, captchaToken, network, oauth, additionalWalletAddresses, sessionPublicKey, }) {
|
|
140
|
+
var _g, _h, _j, _k;
|
|
139
141
|
const verifyRequest = sdkApiCore.VerifyRequestFromJSON({
|
|
140
142
|
additionalWalletAddresses,
|
|
141
143
|
captchaToken,
|
|
@@ -161,13 +163,13 @@ const verifyWallet = (environmentId_3, _e) => _tslib.__awaiter(void 0, [environm
|
|
|
161
163
|
if (data.code === 'wallet_not_deployed') {
|
|
162
164
|
throw new utils$1.WalletNotDeployedError();
|
|
163
165
|
}
|
|
164
|
-
if (data.error.code === 'chainalysis_blocked_wallet') {
|
|
166
|
+
if (((_g = data.error) === null || _g === void 0 ? void 0 : _g.code) === 'chainalysis_blocked_wallet') {
|
|
165
167
|
throw new utils$1.ChainalysisError(data.payload.walletPublicKey);
|
|
166
168
|
}
|
|
167
|
-
if (data.error.code === 'gate_blocked') {
|
|
169
|
+
if (((_h = data.error) === null || _h === void 0 ? void 0 : _h.code) === 'gate_blocked') {
|
|
168
170
|
throw new utils$1.GateBlockedError(data.payload.walletPublicKey);
|
|
169
171
|
}
|
|
170
|
-
if (data.error.code === 'missing_from_list') {
|
|
172
|
+
if (((_j = data.error) === null || _j === void 0 ? void 0 : _j.code) === 'missing_from_list') {
|
|
171
173
|
throw new utils$1.NoAccessError({
|
|
172
174
|
walletPublicKey: data.payload.walletPublicKey,
|
|
173
175
|
});
|
|
@@ -175,13 +177,61 @@ const verifyWallet = (environmentId_3, _e) => _tslib.__awaiter(void 0, [environm
|
|
|
175
177
|
if (data.code === 'email_associated_with_different_provider') {
|
|
176
178
|
throw new utils$1.AccountExistsError(data.error, data.payload);
|
|
177
179
|
}
|
|
178
|
-
if (data.error.code === 'sandbox_maximum_threshold_reached') {
|
|
180
|
+
if (((_k = data.error) === null || _k === void 0 ? void 0 : _k.code) === 'sandbox_maximum_threshold_reached') {
|
|
179
181
|
throw new utils$1.SandboxMaximumThresholdReachedError(data.error.message);
|
|
180
182
|
}
|
|
181
183
|
throw new utils$1.DynamicError(data.error);
|
|
182
184
|
}
|
|
183
185
|
});
|
|
184
|
-
const
|
|
186
|
+
const walletsVerify = (environmentId_4, _l) => _tslib.__awaiter(void 0, [environmentId_4, _l], void 0, function* (environmentId, { messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, captchaToken, network, oauth, requestedScopes, additionalWalletAddresses, sessionPublicKey, }) {
|
|
187
|
+
var _m, _o, _p, _q;
|
|
188
|
+
const verifyRequest = sdkApiCore.VerifyRequestFromJSON({
|
|
189
|
+
additionalWalletAddresses,
|
|
190
|
+
captchaToken,
|
|
191
|
+
chain,
|
|
192
|
+
messageToSign,
|
|
193
|
+
network,
|
|
194
|
+
oauth,
|
|
195
|
+
publicWalletAddress,
|
|
196
|
+
requestedScopes,
|
|
197
|
+
sessionPublicKey,
|
|
198
|
+
signedMessage,
|
|
199
|
+
walletName,
|
|
200
|
+
walletProvider,
|
|
201
|
+
});
|
|
202
|
+
try {
|
|
203
|
+
const response = yield api.sdkApi().walletsVerify({
|
|
204
|
+
environmentId,
|
|
205
|
+
verifyRequest,
|
|
206
|
+
});
|
|
207
|
+
return response;
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
const data = yield utils.logResponseError(e, 'Error walletsVerify');
|
|
211
|
+
if (data.code === 'wallet_not_deployed') {
|
|
212
|
+
throw new utils$1.WalletNotDeployedError();
|
|
213
|
+
}
|
|
214
|
+
if (((_m = data.error) === null || _m === void 0 ? void 0 : _m.code) === 'chainalysis_blocked_wallet') {
|
|
215
|
+
throw new utils$1.ChainalysisError(data.payload.walletPublicKey);
|
|
216
|
+
}
|
|
217
|
+
if (((_o = data.error) === null || _o === void 0 ? void 0 : _o.code) === 'gate_blocked') {
|
|
218
|
+
throw new utils$1.GateBlockedError(data.payload.walletPublicKey);
|
|
219
|
+
}
|
|
220
|
+
if (((_p = data.error) === null || _p === void 0 ? void 0 : _p.code) === 'missing_from_list') {
|
|
221
|
+
throw new utils$1.NoAccessError({
|
|
222
|
+
walletPublicKey: data.payload.walletPublicKey,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
if (data.code === 'email_associated_with_different_provider') {
|
|
226
|
+
throw new utils$1.AccountExistsError(data.error, data.payload);
|
|
227
|
+
}
|
|
228
|
+
if (((_q = data.error) === null || _q === void 0 ? void 0 : _q.code) === 'sandbox_maximum_threshold_reached') {
|
|
229
|
+
throw new utils$1.SandboxMaximumThresholdReachedError(data.error.message);
|
|
230
|
+
}
|
|
231
|
+
throw new utils$1.DynamicError(data.error);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
const upgradeEmbeddedWalletToV2 = (_r) => _tslib.__awaiter(void 0, [_r], void 0, function* ({ environmentId, sessionPublicKey, }) {
|
|
185
235
|
try {
|
|
186
236
|
const response = yield api.sdkApi().upgradeEmbeddedWalletToV2({
|
|
187
237
|
environmentId,
|
|
@@ -194,7 +244,7 @@ const upgradeEmbeddedWalletToV2 = (_f) => _tslib.__awaiter(void 0, [_f], void 0,
|
|
|
194
244
|
throw new utils$1.DynamicError(data.error);
|
|
195
245
|
}
|
|
196
246
|
});
|
|
197
|
-
const softDeleteEmbeddedWallet = (
|
|
247
|
+
const softDeleteEmbeddedWallet = (_s) => _tslib.__awaiter(void 0, [_s], void 0, function* ({ environmentId, walletId, }) {
|
|
198
248
|
try {
|
|
199
249
|
yield api.sdkApi().softDeleteEmbeddedWallet({
|
|
200
250
|
environmentId,
|
|
@@ -206,7 +256,7 @@ const softDeleteEmbeddedWallet = (_g) => _tslib.__awaiter(void 0, [_g], void 0,
|
|
|
206
256
|
throw new utils$1.DynamicError(data.error);
|
|
207
257
|
}
|
|
208
258
|
});
|
|
209
|
-
const restoreEmbeddedWallet = (
|
|
259
|
+
const restoreEmbeddedWallet = (_t) => _tslib.__awaiter(void 0, [_t], void 0, function* ({ environmentId, walletId, }) {
|
|
210
260
|
try {
|
|
211
261
|
yield api.sdkApi().restoreEmbeddedWallet({
|
|
212
262
|
environmentId,
|
|
@@ -227,3 +277,4 @@ exports.transferWallet = transferWallet;
|
|
|
227
277
|
exports.unlinkWallet = unlinkWallet;
|
|
228
278
|
exports.upgradeEmbeddedWalletToV2 = upgradeEmbeddedWalletToV2;
|
|
229
279
|
exports.verifyWallet = verifyWallet;
|
|
280
|
+
exports.walletsVerify = walletsVerify;
|
|
@@ -14,6 +14,7 @@ export declare const unlinkWallet: ({ environmentId, primaryWalletId, walletId,
|
|
|
14
14
|
}) => Promise<UserProfile | undefined>;
|
|
15
15
|
export declare const transferWallet: (environmentId: string, { network, messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, skipEmptyAccountCheck, }: VerifyWallet) => Promise<UserProfile | undefined>;
|
|
16
16
|
export declare const verifyWallet: (environmentId: string, { messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, captchaToken, network, oauth, additionalWalletAddresses, sessionPublicKey, }: VerifyWallet) => Promise<VerifyResponse | undefined>;
|
|
17
|
+
export declare const walletsVerify: (environmentId: string, { messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, captchaToken, network, oauth, requestedScopes, additionalWalletAddresses, sessionPublicKey, }: VerifyWallet) => Promise<VerifyResponse | undefined>;
|
|
17
18
|
export declare const upgradeEmbeddedWalletToV2: ({ environmentId, sessionPublicKey, }: {
|
|
18
19
|
environmentId: string;
|
|
19
20
|
sessionPublicKey?: string;
|
|
@@ -45,6 +45,7 @@ const storeSelectedWallet = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
const linkWallet = (environmentId_1, _b) => __awaiter(void 0, [environmentId_1, _b], void 0, function* (environmentId, { messageToSign, network, signedMessage, publicWalletAddress, chain, walletName, walletProvider, additionalWalletAddresses, backup, }) {
|
|
48
|
+
var _c;
|
|
48
49
|
const verifyRequest = VerifyRequestFromJSON({
|
|
49
50
|
additionalWalletAddresses,
|
|
50
51
|
backup,
|
|
@@ -80,13 +81,13 @@ const linkWallet = (environmentId_1, _b) => __awaiter(void 0, [environmentId_1,
|
|
|
80
81
|
walletAddress: publicWalletAddress,
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
|
-
if (data.error.code === 'sandbox_maximum_threshold_reached') {
|
|
84
|
+
if (((_c = data.error) === null || _c === void 0 ? void 0 : _c.code) === 'sandbox_maximum_threshold_reached') {
|
|
84
85
|
throw new SandboxMaximumThresholdReachedError(data.error.message);
|
|
85
86
|
}
|
|
86
87
|
throw new DynamicError(data.error);
|
|
87
88
|
}
|
|
88
89
|
});
|
|
89
|
-
const unlinkWallet = (
|
|
90
|
+
const unlinkWallet = (_d) => __awaiter(void 0, [_d], void 0, function* ({ environmentId, primaryWalletId, walletId, onSuccess, }) {
|
|
90
91
|
// 7702 wallets have a -zerodev suffix because it's a credential created on the fly
|
|
91
92
|
const normalizedPrimaryWalletId = primaryWalletId === null || primaryWalletId === void 0 ? void 0 : primaryWalletId.replace('-zerodev', '');
|
|
92
93
|
try {
|
|
@@ -106,7 +107,7 @@ const unlinkWallet = (_c) => __awaiter(void 0, [_c], void 0, function* ({ enviro
|
|
|
106
107
|
throw new DynamicError(data.error);
|
|
107
108
|
}
|
|
108
109
|
});
|
|
109
|
-
const transferWallet = (environmentId_2,
|
|
110
|
+
const transferWallet = (environmentId_2, _e) => __awaiter(void 0, [environmentId_2, _e], void 0, function* (environmentId, { network, messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, skipEmptyAccountCheck = false, }) {
|
|
110
111
|
// We should find a better way to do this than force type casting
|
|
111
112
|
const verifyRequest = {
|
|
112
113
|
chain,
|
|
@@ -131,7 +132,8 @@ const transferWallet = (environmentId_2, _d) => __awaiter(void 0, [environmentId
|
|
|
131
132
|
throw new DynamicError(data.error);
|
|
132
133
|
}
|
|
133
134
|
});
|
|
134
|
-
const verifyWallet = (environmentId_3,
|
|
135
|
+
const verifyWallet = (environmentId_3, _f) => __awaiter(void 0, [environmentId_3, _f], void 0, function* (environmentId, { messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, captchaToken, network, oauth, additionalWalletAddresses, sessionPublicKey, }) {
|
|
136
|
+
var _g, _h, _j, _k;
|
|
135
137
|
const verifyRequest = VerifyRequestFromJSON({
|
|
136
138
|
additionalWalletAddresses,
|
|
137
139
|
captchaToken,
|
|
@@ -157,13 +159,13 @@ const verifyWallet = (environmentId_3, _e) => __awaiter(void 0, [environmentId_3
|
|
|
157
159
|
if (data.code === 'wallet_not_deployed') {
|
|
158
160
|
throw new WalletNotDeployedError();
|
|
159
161
|
}
|
|
160
|
-
if (data.error.code === 'chainalysis_blocked_wallet') {
|
|
162
|
+
if (((_g = data.error) === null || _g === void 0 ? void 0 : _g.code) === 'chainalysis_blocked_wallet') {
|
|
161
163
|
throw new ChainalysisError(data.payload.walletPublicKey);
|
|
162
164
|
}
|
|
163
|
-
if (data.error.code === 'gate_blocked') {
|
|
165
|
+
if (((_h = data.error) === null || _h === void 0 ? void 0 : _h.code) === 'gate_blocked') {
|
|
164
166
|
throw new GateBlockedError(data.payload.walletPublicKey);
|
|
165
167
|
}
|
|
166
|
-
if (data.error.code === 'missing_from_list') {
|
|
168
|
+
if (((_j = data.error) === null || _j === void 0 ? void 0 : _j.code) === 'missing_from_list') {
|
|
167
169
|
throw new NoAccessError({
|
|
168
170
|
walletPublicKey: data.payload.walletPublicKey,
|
|
169
171
|
});
|
|
@@ -171,13 +173,61 @@ const verifyWallet = (environmentId_3, _e) => __awaiter(void 0, [environmentId_3
|
|
|
171
173
|
if (data.code === 'email_associated_with_different_provider') {
|
|
172
174
|
throw new AccountExistsError(data.error, data.payload);
|
|
173
175
|
}
|
|
174
|
-
if (data.error.code === 'sandbox_maximum_threshold_reached') {
|
|
176
|
+
if (((_k = data.error) === null || _k === void 0 ? void 0 : _k.code) === 'sandbox_maximum_threshold_reached') {
|
|
175
177
|
throw new SandboxMaximumThresholdReachedError(data.error.message);
|
|
176
178
|
}
|
|
177
179
|
throw new DynamicError(data.error);
|
|
178
180
|
}
|
|
179
181
|
});
|
|
180
|
-
const
|
|
182
|
+
const walletsVerify = (environmentId_4, _l) => __awaiter(void 0, [environmentId_4, _l], void 0, function* (environmentId, { messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, captchaToken, network, oauth, requestedScopes, additionalWalletAddresses, sessionPublicKey, }) {
|
|
183
|
+
var _m, _o, _p, _q;
|
|
184
|
+
const verifyRequest = VerifyRequestFromJSON({
|
|
185
|
+
additionalWalletAddresses,
|
|
186
|
+
captchaToken,
|
|
187
|
+
chain,
|
|
188
|
+
messageToSign,
|
|
189
|
+
network,
|
|
190
|
+
oauth,
|
|
191
|
+
publicWalletAddress,
|
|
192
|
+
requestedScopes,
|
|
193
|
+
sessionPublicKey,
|
|
194
|
+
signedMessage,
|
|
195
|
+
walletName,
|
|
196
|
+
walletProvider,
|
|
197
|
+
});
|
|
198
|
+
try {
|
|
199
|
+
const response = yield sdkApi().walletsVerify({
|
|
200
|
+
environmentId,
|
|
201
|
+
verifyRequest,
|
|
202
|
+
});
|
|
203
|
+
return response;
|
|
204
|
+
}
|
|
205
|
+
catch (e) {
|
|
206
|
+
const data = yield logResponseError(e, 'Error walletsVerify');
|
|
207
|
+
if (data.code === 'wallet_not_deployed') {
|
|
208
|
+
throw new WalletNotDeployedError();
|
|
209
|
+
}
|
|
210
|
+
if (((_m = data.error) === null || _m === void 0 ? void 0 : _m.code) === 'chainalysis_blocked_wallet') {
|
|
211
|
+
throw new ChainalysisError(data.payload.walletPublicKey);
|
|
212
|
+
}
|
|
213
|
+
if (((_o = data.error) === null || _o === void 0 ? void 0 : _o.code) === 'gate_blocked') {
|
|
214
|
+
throw new GateBlockedError(data.payload.walletPublicKey);
|
|
215
|
+
}
|
|
216
|
+
if (((_p = data.error) === null || _p === void 0 ? void 0 : _p.code) === 'missing_from_list') {
|
|
217
|
+
throw new NoAccessError({
|
|
218
|
+
walletPublicKey: data.payload.walletPublicKey,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
if (data.code === 'email_associated_with_different_provider') {
|
|
222
|
+
throw new AccountExistsError(data.error, data.payload);
|
|
223
|
+
}
|
|
224
|
+
if (((_q = data.error) === null || _q === void 0 ? void 0 : _q.code) === 'sandbox_maximum_threshold_reached') {
|
|
225
|
+
throw new SandboxMaximumThresholdReachedError(data.error.message);
|
|
226
|
+
}
|
|
227
|
+
throw new DynamicError(data.error);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
const upgradeEmbeddedWalletToV2 = (_r) => __awaiter(void 0, [_r], void 0, function* ({ environmentId, sessionPublicKey, }) {
|
|
181
231
|
try {
|
|
182
232
|
const response = yield sdkApi().upgradeEmbeddedWalletToV2({
|
|
183
233
|
environmentId,
|
|
@@ -190,7 +240,7 @@ const upgradeEmbeddedWalletToV2 = (_f) => __awaiter(void 0, [_f], void 0, functi
|
|
|
190
240
|
throw new DynamicError(data.error);
|
|
191
241
|
}
|
|
192
242
|
});
|
|
193
|
-
const softDeleteEmbeddedWallet = (
|
|
243
|
+
const softDeleteEmbeddedWallet = (_s) => __awaiter(void 0, [_s], void 0, function* ({ environmentId, walletId, }) {
|
|
194
244
|
try {
|
|
195
245
|
yield sdkApi().softDeleteEmbeddedWallet({
|
|
196
246
|
environmentId,
|
|
@@ -202,7 +252,7 @@ const softDeleteEmbeddedWallet = (_g) => __awaiter(void 0, [_g], void 0, functio
|
|
|
202
252
|
throw new DynamicError(data.error);
|
|
203
253
|
}
|
|
204
254
|
});
|
|
205
|
-
const restoreEmbeddedWallet = (
|
|
255
|
+
const restoreEmbeddedWallet = (_t) => __awaiter(void 0, [_t], void 0, function* ({ environmentId, walletId, }) {
|
|
206
256
|
try {
|
|
207
257
|
yield sdkApi().restoreEmbeddedWallet({
|
|
208
258
|
environmentId,
|
|
@@ -215,4 +265,4 @@ const restoreEmbeddedWallet = (_h) => __awaiter(void 0, [_h], void 0, function*
|
|
|
215
265
|
}
|
|
216
266
|
});
|
|
217
267
|
|
|
218
|
-
export { linkWallet, restoreEmbeddedWallet, softDeleteEmbeddedWallet, storeSelectedWallet, transferWallet, unlinkWallet, upgradeEmbeddedWalletToV2, verifyWallet };
|
|
268
|
+
export { linkWallet, restoreEmbeddedWallet, softDeleteEmbeddedWallet, storeSelectedWallet, transferWallet, unlinkWallet, upgradeEmbeddedWalletToV2, verifyWallet, walletsVerify };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OauthProviderRequest } from '@dynamic-labs/sdk-api-core';
|
|
1
|
+
import { OauthProviderRequest, TokenScope } from '@dynamic-labs/sdk-api-core';
|
|
2
2
|
import type { GetAddressOpts, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
export interface VerifyCallbackArgs {
|
|
4
4
|
captchaToken?: string;
|
|
@@ -8,6 +8,7 @@ export interface VerifyCallbackArgs {
|
|
|
8
8
|
walletConnector: WalletConnector;
|
|
9
9
|
signedMessageOverride?: string;
|
|
10
10
|
messageToSignOverride?: string;
|
|
11
|
+
requestedScopes?: TokenScope[];
|
|
11
12
|
}
|
|
12
13
|
export type MultiWalletWidgetState = 'idle' | 'awaiting_account_switch' | 'awaiting_connection' | 'awaiting_signature' | 'detected_new_wallet';
|
|
13
14
|
export type AccountSwitchState = 'idle' | 'linking_new_wallet' | 'switching_primary' | 'primary_not_connected';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import { OauthProviderRequest, PasswordSourceTypeEnum, WalletAdditionalAddress, WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
import { OauthProviderRequest, PasswordSourceTypeEnum, TokenScope, WalletAdditionalAddress, WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
3
3
|
import type { InternalWalletConnector, Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
export type { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
export type WalletAction = 'select' | 'unlink';
|
|
@@ -38,6 +38,7 @@ export interface VerifyWallet {
|
|
|
38
38
|
captchaToken?: string;
|
|
39
39
|
chain: string | undefined;
|
|
40
40
|
messageToSign: string;
|
|
41
|
+
requestedScopes?: TokenScope[];
|
|
41
42
|
network: string | number | undefined;
|
|
42
43
|
oauth?: OauthProviderRequest;
|
|
43
44
|
publicWalletAddress: string;
|
|
@@ -127,7 +127,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
127
127
|
projectSettings,
|
|
128
128
|
setIsSingleWalletAccount,
|
|
129
129
|
});
|
|
130
|
-
const handleWalletVerify = (walletConnector, publicWalletAddress, captchaToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
130
|
+
const handleWalletVerify = (walletConnector, publicWalletAddress, captchaToken, requestedScopes) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
131
131
|
if (!walletConnectorCore.isEmailWalletConnector(walletConnector) ||
|
|
132
132
|
walletConnectorCore.isBloctoConnector(walletConnector)) {
|
|
133
133
|
replaceView('pending-signature');
|
|
@@ -137,9 +137,10 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
137
137
|
walletUiUtils.disabledConfirmationOnce();
|
|
138
138
|
}
|
|
139
139
|
yield getClientSessionKeys.generateClientSessionKeys();
|
|
140
|
-
|
|
140
|
+
return verifyWallet({
|
|
141
141
|
captchaToken,
|
|
142
142
|
publicWalletAddress,
|
|
143
|
+
requestedScopes,
|
|
143
144
|
walletConnector,
|
|
144
145
|
});
|
|
145
146
|
});
|
|
@@ -168,7 +169,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
168
169
|
setDefaultError();
|
|
169
170
|
}
|
|
170
171
|
};
|
|
171
|
-
return (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ walletConnector, getAddressOpts = undefined, }) {
|
|
172
|
+
return (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ walletConnector, getAddressOpts = undefined, requestedScopes, }) {
|
|
172
173
|
var _b;
|
|
173
174
|
const connectionCancelPromise = new utils.DeferredPromise();
|
|
174
175
|
const onGoBack = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -236,7 +237,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
236
237
|
authMethod: 'wallet',
|
|
237
238
|
onCaptchaSuccess: (captchaToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
238
239
|
try {
|
|
239
|
-
yield handleWalletVerify(walletConnector, address, captchaToken);
|
|
240
|
+
yield handleWalletVerify(walletConnector, address, captchaToken, requestedScopes);
|
|
240
241
|
}
|
|
241
242
|
catch (e) {
|
|
242
243
|
handleWalletVerifyError(e);
|
|
@@ -245,7 +246,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
245
246
|
});
|
|
246
247
|
return;
|
|
247
248
|
}
|
|
248
|
-
yield handleWalletVerify(walletConnector, address, getCaptchaToken());
|
|
249
|
+
yield handleWalletVerify(walletConnector, address, getCaptchaToken(), requestedScopes);
|
|
249
250
|
}
|
|
250
251
|
catch (err) {
|
|
251
252
|
handleWalletVerifyError(err);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { GetAddressOpts, InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
import { TokenScope } from '@dynamic-labs/sdk-api-core';
|
|
2
3
|
export type ConnectAndSignProps = {
|
|
3
4
|
getAddressOpts?: GetAddressOpts;
|
|
4
5
|
walletConnector: InternalWalletConnector;
|
|
6
|
+
requestedScopes?: TokenScope[];
|
|
5
7
|
};
|
|
6
8
|
export declare const useConnectAndSign: ({ shouldUpdateWallets, shouldCallCallback, }?: {
|
|
7
9
|
shouldUpdateWallets?: boolean | undefined;
|
|
8
10
|
shouldCallCallback?: boolean | undefined;
|
|
9
|
-
}) => ({ walletConnector, getAddressOpts, }: ConnectAndSignProps) => Promise<void>;
|
|
11
|
+
}) => ({ walletConnector, getAddressOpts, requestedScopes, }: ConnectAndSignProps) => Promise<void>;
|
|
@@ -123,7 +123,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
123
123
|
projectSettings,
|
|
124
124
|
setIsSingleWalletAccount,
|
|
125
125
|
});
|
|
126
|
-
const handleWalletVerify = (walletConnector, publicWalletAddress, captchaToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
|
+
const handleWalletVerify = (walletConnector, publicWalletAddress, captchaToken, requestedScopes) => __awaiter(void 0, void 0, void 0, function* () {
|
|
127
127
|
if (!isEmailWalletConnector(walletConnector) ||
|
|
128
128
|
isBloctoConnector(walletConnector)) {
|
|
129
129
|
replaceView('pending-signature');
|
|
@@ -133,9 +133,10 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
133
133
|
walletUiUtils.disabledConfirmationOnce();
|
|
134
134
|
}
|
|
135
135
|
yield generateClientSessionKeys();
|
|
136
|
-
|
|
136
|
+
return verifyWallet({
|
|
137
137
|
captchaToken,
|
|
138
138
|
publicWalletAddress,
|
|
139
|
+
requestedScopes,
|
|
139
140
|
walletConnector,
|
|
140
141
|
});
|
|
141
142
|
});
|
|
@@ -164,7 +165,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
164
165
|
setDefaultError();
|
|
165
166
|
}
|
|
166
167
|
};
|
|
167
|
-
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ walletConnector, getAddressOpts = undefined, }) {
|
|
168
|
+
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ walletConnector, getAddressOpts = undefined, requestedScopes, }) {
|
|
168
169
|
var _b;
|
|
169
170
|
const connectionCancelPromise = new DeferredPromise();
|
|
170
171
|
const onGoBack = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -232,7 +233,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
232
233
|
authMethod: 'wallet',
|
|
233
234
|
onCaptchaSuccess: (captchaToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
234
235
|
try {
|
|
235
|
-
yield handleWalletVerify(walletConnector, address, captchaToken);
|
|
236
|
+
yield handleWalletVerify(walletConnector, address, captchaToken, requestedScopes);
|
|
236
237
|
}
|
|
237
238
|
catch (e) {
|
|
238
239
|
handleWalletVerifyError(e);
|
|
@@ -241,7 +242,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
241
242
|
});
|
|
242
243
|
return;
|
|
243
244
|
}
|
|
244
|
-
yield handleWalletVerify(walletConnector, address, getCaptchaToken());
|
|
245
|
+
yield handleWalletVerify(walletConnector, address, getCaptchaToken(), requestedScopes);
|
|
245
246
|
}
|
|
246
247
|
catch (err) {
|
|
247
248
|
handleWalletVerifyError(err);
|
|
@@ -107,3 +107,5 @@ export { useWalletPassword } from './useWalletPassword';
|
|
|
107
107
|
export type { CheckWalletLockStateParams, UnlockWalletParams, UpdatePasswordParams, UseWalletPasswordReturn, WalletPasswordState, } from './useWalletPassword';
|
|
108
108
|
export { usePromptWalletUnlock } from './usePromptWalletUnlock';
|
|
109
109
|
export { useGetWalletPassword } from './useGetWalletPassword';
|
|
110
|
+
export { useStepUpAuthentication } from './useStepUpAuthentication';
|
|
111
|
+
export type { StepUpAuthenticationState, UseStepUpAuthenticationParams, UseStepUpAuthenticationReturn, VerifyOtpParams, VerifyWalletParams, } from './useStepUpAuthentication';
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
7
|
var React = require('react');
|
|
8
|
+
var utils = require('@dynamic-labs/utils');
|
|
8
9
|
require('@dynamic-labs-sdk/client/core');
|
|
9
10
|
require('@dynamic-labs/sdk-api-core');
|
|
10
11
|
require('../../../client/client.cjs');
|
|
@@ -16,7 +17,6 @@ require('react/jsx-runtime');
|
|
|
16
17
|
require('../../../context/ViewContext/ViewContext.cjs');
|
|
17
18
|
var logger = require('../../../shared/logger.cjs');
|
|
18
19
|
require('@dynamic-labs/wallet-book');
|
|
19
|
-
require('@dynamic-labs/utils');
|
|
20
20
|
require('../../constants/colors.cjs');
|
|
21
21
|
require('../../constants/values.cjs');
|
|
22
22
|
require('../../../shared/consts/index.cjs');
|
|
@@ -30,7 +30,10 @@ require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
|
30
30
|
var getClientSessionKeys = require('../../functions/clientSessionKeys/getClientSessionKeys.cjs');
|
|
31
31
|
require('../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
32
32
|
require('../../../events/dynamicEvents.cjs');
|
|
33
|
+
var getUserProfile = require('../../../client/extension/user/getUserProfile/getUserProfile.cjs');
|
|
33
34
|
var useOnboardingCompleteUser = require('../../../client/extension/user/useOnboardingCompleteUser/useOnboardingCompleteUser.cjs');
|
|
35
|
+
var getMinAuthToken = require('../../../client/extension/functions/getMinAuthToken/getMinAuthToken.cjs');
|
|
36
|
+
var sessionStorage = require('../../constants/sessionStorage.cjs');
|
|
34
37
|
|
|
35
38
|
const useClientSessionKeys = () => {
|
|
36
39
|
const user = useOnboardingCompleteUser.useOnboardingCompleteUser();
|
|
@@ -51,6 +54,22 @@ const useClientSessionKeys = () => {
|
|
|
51
54
|
const currentUser = userRef.current;
|
|
52
55
|
const currentPublicKey = sessionPublicKeyRef.current;
|
|
53
56
|
if (!(currentUser === null || currentUser === void 0 ? void 0 : currentUser.sessionId) || !currentPublicKey) {
|
|
57
|
+
logger.logger.instrument('[SessionChaining] Session ID and public key are required', {
|
|
58
|
+
hasClientSessionKeysInSecureStorage: Boolean(utils.StorageService.getItem(sessionStorage.CLIENT_SESSION_KEYS, sessionStorage.CLIENT_SESSION_KEYS_STORAGE_OPTIONS)),
|
|
59
|
+
hasLocalStorage: Boolean(utils.StorageService.getSourceStorage('localStorage')),
|
|
60
|
+
hasSecureStorage: Boolean(utils.StorageService.getSourceStorage('secureStorage')),
|
|
61
|
+
hasSessionId: currentUser ? Boolean(currentUser.sessionId) : false,
|
|
62
|
+
hasSessionPublicKey: Boolean(currentPublicKey),
|
|
63
|
+
hasSessionStorage: Boolean(utils.StorageService.getSourceStorage('sessionStorage')),
|
|
64
|
+
hasUser: Boolean(currentUser),
|
|
65
|
+
key: 'session_chaining_missing_requirements',
|
|
66
|
+
sessionId: currentUser === null || currentUser === void 0 ? void 0 : currentUser.sessionId,
|
|
67
|
+
sessionPublicKey: currentPublicKey,
|
|
68
|
+
stateHasMinAuthToken: Boolean(getMinAuthToken.getMinAuthToken()),
|
|
69
|
+
stateHasUser: Boolean(getUserProfile.getUserProfile()),
|
|
70
|
+
time: 0,
|
|
71
|
+
userId: currentUser === null || currentUser === void 0 ? void 0 : currentUser.id,
|
|
72
|
+
});
|
|
54
73
|
throw new Error('Session ID and public key are required');
|
|
55
74
|
}
|
|
56
75
|
const { sessionSignature: signedSessionId } = yield getClientSessionKeys.getClientSessionSignature({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { useRef, useCallback } from 'react';
|
|
4
|
+
import { StorageService } from '@dynamic-labs/utils';
|
|
4
5
|
import '@dynamic-labs-sdk/client/core';
|
|
5
6
|
import '@dynamic-labs/sdk-api-core';
|
|
6
7
|
import '../../../client/client.js';
|
|
@@ -12,7 +13,6 @@ import 'react/jsx-runtime';
|
|
|
12
13
|
import '../../../context/ViewContext/ViewContext.js';
|
|
13
14
|
import { logger } from '../../../shared/logger.js';
|
|
14
15
|
import '@dynamic-labs/wallet-book';
|
|
15
|
-
import '@dynamic-labs/utils';
|
|
16
16
|
import '../../constants/colors.js';
|
|
17
17
|
import '../../constants/values.js';
|
|
18
18
|
import '../../../shared/consts/index.js';
|
|
@@ -26,7 +26,10 @@ import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
|
26
26
|
import { getClientSessionPublicKey, getClientSessionSignature, getClientSessionNonceSignature } from '../../functions/clientSessionKeys/getClientSessionKeys.js';
|
|
27
27
|
import '../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
28
28
|
import '../../../events/dynamicEvents.js';
|
|
29
|
+
import { getUserProfile } from '../../../client/extension/user/getUserProfile/getUserProfile.js';
|
|
29
30
|
import { useOnboardingCompleteUser } from '../../../client/extension/user/useOnboardingCompleteUser/useOnboardingCompleteUser.js';
|
|
31
|
+
import { getMinAuthToken } from '../../../client/extension/functions/getMinAuthToken/getMinAuthToken.js';
|
|
32
|
+
import { CLIENT_SESSION_KEYS, CLIENT_SESSION_KEYS_STORAGE_OPTIONS } from '../../constants/sessionStorage.js';
|
|
30
33
|
|
|
31
34
|
const useClientSessionKeys = () => {
|
|
32
35
|
const user = useOnboardingCompleteUser();
|
|
@@ -47,6 +50,22 @@ const useClientSessionKeys = () => {
|
|
|
47
50
|
const currentUser = userRef.current;
|
|
48
51
|
const currentPublicKey = sessionPublicKeyRef.current;
|
|
49
52
|
if (!(currentUser === null || currentUser === void 0 ? void 0 : currentUser.sessionId) || !currentPublicKey) {
|
|
53
|
+
logger.instrument('[SessionChaining] Session ID and public key are required', {
|
|
54
|
+
hasClientSessionKeysInSecureStorage: Boolean(StorageService.getItem(CLIENT_SESSION_KEYS, CLIENT_SESSION_KEYS_STORAGE_OPTIONS)),
|
|
55
|
+
hasLocalStorage: Boolean(StorageService.getSourceStorage('localStorage')),
|
|
56
|
+
hasSecureStorage: Boolean(StorageService.getSourceStorage('secureStorage')),
|
|
57
|
+
hasSessionId: currentUser ? Boolean(currentUser.sessionId) : false,
|
|
58
|
+
hasSessionPublicKey: Boolean(currentPublicKey),
|
|
59
|
+
hasSessionStorage: Boolean(StorageService.getSourceStorage('sessionStorage')),
|
|
60
|
+
hasUser: Boolean(currentUser),
|
|
61
|
+
key: 'session_chaining_missing_requirements',
|
|
62
|
+
sessionId: currentUser === null || currentUser === void 0 ? void 0 : currentUser.sessionId,
|
|
63
|
+
sessionPublicKey: currentPublicKey,
|
|
64
|
+
stateHasMinAuthToken: Boolean(getMinAuthToken()),
|
|
65
|
+
stateHasUser: Boolean(getUserProfile()),
|
|
66
|
+
time: 0,
|
|
67
|
+
userId: currentUser === null || currentUser === void 0 ? void 0 : currentUser.id,
|
|
68
|
+
});
|
|
50
69
|
throw new Error('Session ID and public key are required');
|
|
51
70
|
}
|
|
52
71
|
const { sessionSignature: signedSessionId } = yield getClientSessionSignature({
|