@dynamic-labs/waas 4.25.3 → 4.25.5
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 +26 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -7
- package/src/DynamicWaasMixin.cjs +225 -3
- package/src/DynamicWaasMixin.d.ts +57 -0
- package/src/DynamicWaasMixin.js +225 -4
- package/src/index.cjs +1 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.25.5](https://github.com/dynamic-labs/dynamic-auth/compare/v4.25.4...v4.25.5) (2025-07-27)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add pending account switch copykey ([#9219](https://github.com/dynamic-labs/dynamic-auth/issues/9219)) ([1d88bf2](https://github.com/dynamic-labs/dynamic-auth/commit/1d88bf27c685f122d94cdf66541365eae7e11a64))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* logout user if last wallet removed in connect-only ([#9234](https://github.com/dynamic-labs/dynamic-auth/issues/9234)) ([42ea1ad](https://github.com/dynamic-labs/dynamic-auth/commit/42ea1ad331cd635a1c17fac0dcbf213fa045586d))
|
|
13
|
+
* prevent waas wallet from being created when embedded wallet option is turned on and then off ([#9237](https://github.com/dynamic-labs/dynamic-auth/issues/9237)) ([004a350](https://github.com/dynamic-labs/dynamic-auth/commit/004a350eb0d88d7ad6d3ceea7eb0d889f7d4a6bf))
|
|
14
|
+
* stop generating session keys on wallet linking ([#9244](https://github.com/dynamic-labs/dynamic-auth/issues/9244)) ([7176be9](https://github.com/dynamic-labs/dynamic-auth/commit/7176be93e31ba55dda264e0365c84376272ee945))
|
|
15
|
+
|
|
16
|
+
### [4.25.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.25.3...v4.25.4) (2025-07-25)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* add passkey as a sign in method ([#9210](https://github.com/dynamic-labs/dynamic-auth/issues/9210)) ([90a6938](https://github.com/dynamic-labs/dynamic-auth/commit/90a69389cf89d7092519e58b0052d85c53a19905))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* **QNTM-3416:** fix rainbow wallet connection on base network ([#9227](https://github.com/dynamic-labs/dynamic-auth/issues/9227)) ([d6dcdc3](https://github.com/dynamic-labs/dynamic-auth/commit/d6dcdc3ead194d7580bb8387432dfd15555158de))
|
|
27
|
+
|
|
2
28
|
### [4.25.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.25.2...v4.25.3) (2025-07-22)
|
|
3
29
|
|
|
4
30
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/waas",
|
|
3
|
-
"version": "4.25.
|
|
3
|
+
"version": "4.25.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,12 +16,13 @@
|
|
|
16
16
|
"./package.json": "./package.json"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@dynamic-labs/assert-package-version": "4.25.
|
|
20
|
-
"@dynamic-labs-wallet/browser-wallet-client": "0.0.
|
|
21
|
-
"@dynamic-labs/ethereum-core": "4.25.
|
|
22
|
-
"@dynamic-labs/solana-core": "4.25.
|
|
23
|
-
"@dynamic-labs/sui-core": "4.25.
|
|
24
|
-
"@dynamic-labs/
|
|
19
|
+
"@dynamic-labs/assert-package-version": "4.25.5",
|
|
20
|
+
"@dynamic-labs-wallet/browser-wallet-client": "0.0.124",
|
|
21
|
+
"@dynamic-labs/ethereum-core": "4.25.5",
|
|
22
|
+
"@dynamic-labs/solana-core": "4.25.5",
|
|
23
|
+
"@dynamic-labs/sui-core": "4.25.5",
|
|
24
|
+
"@dynamic-labs/utils": "4.25.5",
|
|
25
|
+
"@dynamic-labs/wallet-book": "4.25.5"
|
|
25
26
|
},
|
|
26
27
|
"peerDependencies": {}
|
|
27
28
|
}
|
package/src/DynamicWaasMixin.cjs
CHANGED
|
@@ -5,14 +5,33 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../_virtual/_tslib.cjs');
|
|
7
7
|
var browserWalletClient = require('@dynamic-labs-wallet/browser-wallet-client');
|
|
8
|
+
var utils = require('@dynamic-labs/utils');
|
|
8
9
|
var _package = require('../package.cjs');
|
|
9
10
|
var constants = require('../utils/constants.cjs');
|
|
10
11
|
|
|
12
|
+
// This class is common across all waas connectors
|
|
13
|
+
class WaasExportHandler {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.iframeStamper = null;
|
|
16
|
+
}
|
|
17
|
+
setIframeStamper(iframe) {
|
|
18
|
+
this.iframeStamper = iframe;
|
|
19
|
+
}
|
|
20
|
+
clear() {
|
|
21
|
+
if (this.iframeStamper) {
|
|
22
|
+
this.iframeStamper.remove();
|
|
23
|
+
this.iframeStamper = null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
11
27
|
const withDynamicWaas = (BaseClass) => {
|
|
12
28
|
class DynamicWaasMixin extends BaseClass {
|
|
13
29
|
setGetAuthTokenFunction(getAuthToken) {
|
|
14
30
|
this.getAuthToken = getAuthToken;
|
|
15
31
|
}
|
|
32
|
+
setGetMfaTokenFunction(getMfaToken) {
|
|
33
|
+
this.getMfaToken = getMfaToken;
|
|
34
|
+
}
|
|
16
35
|
setEnvironmentId(environmentId) {
|
|
17
36
|
this.environmentId = environmentId;
|
|
18
37
|
}
|
|
@@ -25,11 +44,36 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
25
44
|
setGetSignedSessionIdFunction(getSignedSessionId) {
|
|
26
45
|
this.getSignedSessionId = getSignedSessionId;
|
|
27
46
|
}
|
|
47
|
+
delegateKeyShares(_a) {
|
|
48
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
49
|
+
var _b, _c;
|
|
50
|
+
if (!accountAddress) {
|
|
51
|
+
throw new Error('Account address is required');
|
|
52
|
+
}
|
|
53
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
54
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
55
|
+
if (!signedSessionId) {
|
|
56
|
+
throw new Error('Signed session ID is required');
|
|
57
|
+
}
|
|
58
|
+
const authToken = (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this);
|
|
59
|
+
if (!authToken) {
|
|
60
|
+
throw new Error('Auth token is required');
|
|
61
|
+
}
|
|
62
|
+
return walletClient.delegateKeyShares({
|
|
63
|
+
accountAddress,
|
|
64
|
+
authToken,
|
|
65
|
+
password,
|
|
66
|
+
signedSessionId,
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
28
70
|
constructor(...args) {
|
|
29
71
|
super(...args);
|
|
30
72
|
this.name = 'Dynamic Waas';
|
|
31
73
|
this.overrideKey = 'dynamicwaas';
|
|
32
74
|
this.isEmbeddedWallet = true;
|
|
75
|
+
// Initialize export handler
|
|
76
|
+
this.__exportHandler = new WaasExportHandler();
|
|
33
77
|
// Get the class name from the constructor
|
|
34
78
|
const { connectedChain } = this;
|
|
35
79
|
// Map class names to chain names
|
|
@@ -40,7 +84,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
40
84
|
};
|
|
41
85
|
const chainName = chainNameMap[connectedChain];
|
|
42
86
|
if (!chainName) {
|
|
43
|
-
throw new
|
|
87
|
+
throw new utils.DynamicError(`Unsupported chain: ${connectedChain}`);
|
|
44
88
|
}
|
|
45
89
|
this.chainName = chainName;
|
|
46
90
|
}
|
|
@@ -49,10 +93,10 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
49
93
|
var _a;
|
|
50
94
|
const authToken = (_a = this.getAuthToken) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
51
95
|
if (!authToken) {
|
|
52
|
-
throw new
|
|
96
|
+
throw new utils.DynamicError('Auth token is required');
|
|
53
97
|
}
|
|
54
98
|
if (!this.environmentId) {
|
|
55
|
-
throw new
|
|
99
|
+
throw new utils.DynamicError('Environment ID is required');
|
|
56
100
|
}
|
|
57
101
|
const client = new browserWalletClient.DynamicWalletClient({
|
|
58
102
|
authToken,
|
|
@@ -74,8 +118,186 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
74
118
|
return this.dynamicWaasClient;
|
|
75
119
|
});
|
|
76
120
|
}
|
|
121
|
+
// Common methods that are identical across all connectors
|
|
122
|
+
createWalletAccount() {
|
|
123
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ thresholdSignatureScheme = 'TWO_OF_TWO', } = {}) {
|
|
124
|
+
var _a, _b;
|
|
125
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
126
|
+
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
127
|
+
if (!signedSessionId) {
|
|
128
|
+
throw new utils.DynamicError('Signed session ID is required');
|
|
129
|
+
}
|
|
130
|
+
const createdWallet = yield walletClient.createWalletAccount({
|
|
131
|
+
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
132
|
+
signedSessionId,
|
|
133
|
+
thresholdSignatureScheme: thresholdSignatureScheme,
|
|
134
|
+
});
|
|
135
|
+
return createdWallet;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
importPrivateKey(_a) {
|
|
139
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ privateKey, thresholdSignatureScheme = 'TWO_OF_TWO', }) {
|
|
140
|
+
var _b, _c;
|
|
141
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
142
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
143
|
+
if (!signedSessionId) {
|
|
144
|
+
throw new utils.DynamicError('Signed session ID is required');
|
|
145
|
+
}
|
|
146
|
+
yield walletClient.importPrivateKey({
|
|
147
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
148
|
+
privateKey,
|
|
149
|
+
signedSessionId,
|
|
150
|
+
thresholdSignatureScheme: thresholdSignatureScheme,
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
exportPrivateKey() {
|
|
155
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, displayContainer, password, } = {}) {
|
|
156
|
+
var _a, _b, _c;
|
|
157
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
158
|
+
const targetAccountAddress = accountAddress || (yield this.getActiveAccountAddress());
|
|
159
|
+
if (!targetAccountAddress) {
|
|
160
|
+
throw new utils.DynamicError('Account address is required');
|
|
161
|
+
}
|
|
162
|
+
if (!displayContainer) {
|
|
163
|
+
throw new utils.DynamicError('Missing display container for export private key');
|
|
164
|
+
}
|
|
165
|
+
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
166
|
+
if (!signedSessionId) {
|
|
167
|
+
throw new utils.DynamicError('Signed session ID is required');
|
|
168
|
+
}
|
|
169
|
+
this.__exportHandler.setIframeStamper(displayContainer);
|
|
170
|
+
const mfaToken = yield ((_b = this.getMfaToken) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
171
|
+
yield walletClient.exportPrivateKey({
|
|
172
|
+
accountAddress: targetAccountAddress,
|
|
173
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
174
|
+
displayContainer,
|
|
175
|
+
mfaToken,
|
|
176
|
+
password,
|
|
177
|
+
signedSessionId,
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
getExportHandler() {
|
|
182
|
+
return this.__exportHandler;
|
|
183
|
+
}
|
|
184
|
+
exportClientKeyshares(_a) {
|
|
185
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
186
|
+
var _b, _c;
|
|
187
|
+
if (!accountAddress) {
|
|
188
|
+
throw new utils.DynamicError('Account address is required');
|
|
189
|
+
}
|
|
190
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
191
|
+
if (!signedSessionId) {
|
|
192
|
+
throw new utils.DynamicError('Signed session ID is required');
|
|
193
|
+
}
|
|
194
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
195
|
+
yield walletClient.exportClientKeyshares({
|
|
196
|
+
accountAddress,
|
|
197
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
198
|
+
password,
|
|
199
|
+
signedSessionId,
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
backupKeySharesToGoogleDrive(_a) {
|
|
204
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
205
|
+
var _b, _c;
|
|
206
|
+
if (!accountAddress) {
|
|
207
|
+
throw new utils.DynamicError('Account address is required');
|
|
208
|
+
}
|
|
209
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
210
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
211
|
+
if (!signedSessionId) {
|
|
212
|
+
throw new utils.DynamicError('Signed session ID is required');
|
|
213
|
+
}
|
|
214
|
+
return walletClient.backupKeySharesToGoogleDrive({
|
|
215
|
+
accountAddress,
|
|
216
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
217
|
+
password,
|
|
218
|
+
signedSessionId,
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
refreshWalletAccountShares(_a) {
|
|
223
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
224
|
+
var _b, _c, _d;
|
|
225
|
+
if (!accountAddress) {
|
|
226
|
+
throw new utils.DynamicError('Account address is required');
|
|
227
|
+
}
|
|
228
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
229
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
230
|
+
if (!signedSessionId) {
|
|
231
|
+
throw new utils.DynamicError('Signed session ID is required');
|
|
232
|
+
}
|
|
233
|
+
const mfaToken = yield ((_c = this.getMfaToken) === null || _c === void 0 ? void 0 : _c.call(this));
|
|
234
|
+
return walletClient.refreshWalletAccountShares({
|
|
235
|
+
accountAddress,
|
|
236
|
+
authToken: (_d = this.getAuthToken) === null || _d === void 0 ? void 0 : _d.call(this),
|
|
237
|
+
mfaToken,
|
|
238
|
+
password,
|
|
239
|
+
signedSessionId,
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
updatePassword(_a) {
|
|
244
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, existingPassword, newPassword, }) {
|
|
245
|
+
var _b, _c;
|
|
246
|
+
if (!accountAddress) {
|
|
247
|
+
throw new utils.DynamicError('Account address is required');
|
|
248
|
+
}
|
|
249
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
250
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
251
|
+
if (!signedSessionId) {
|
|
252
|
+
throw new utils.DynamicError('Signed session ID is required');
|
|
253
|
+
}
|
|
254
|
+
return walletClient.updatePassword({
|
|
255
|
+
accountAddress,
|
|
256
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
257
|
+
existingPassword,
|
|
258
|
+
newPassword,
|
|
259
|
+
signedSessionId,
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
signRawMessage(_a) {
|
|
264
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, message, password, }) {
|
|
265
|
+
var _b, _c, _d;
|
|
266
|
+
if (!accountAddress) {
|
|
267
|
+
throw new utils.DynamicError('Account address is required');
|
|
268
|
+
}
|
|
269
|
+
if (message.length !== 64) {
|
|
270
|
+
throw new utils.DynamicError('Message must be 64 characters long');
|
|
271
|
+
}
|
|
272
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
273
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
274
|
+
if (!signedSessionId) {
|
|
275
|
+
throw new utils.DynamicError('Signed session ID is required');
|
|
276
|
+
}
|
|
277
|
+
const mfaToken = yield ((_c = this.getMfaToken) === null || _c === void 0 ? void 0 : _c.call(this));
|
|
278
|
+
return walletClient.signRawMessage({
|
|
279
|
+
accountAddress,
|
|
280
|
+
authToken: (_d = this.getAuthToken) === null || _d === void 0 ? void 0 : _d.call(this),
|
|
281
|
+
message,
|
|
282
|
+
mfaToken,
|
|
283
|
+
password,
|
|
284
|
+
signedSessionId,
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
endSession() {
|
|
289
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
290
|
+
const waasClient = yield this.getWaasWalletClient();
|
|
291
|
+
if (!waasClient) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
yield waasClient.cleanup();
|
|
295
|
+
this.dynamicWaasClient = undefined;
|
|
296
|
+
});
|
|
297
|
+
}
|
|
77
298
|
}
|
|
78
299
|
return DynamicWaasMixin;
|
|
79
300
|
};
|
|
80
301
|
|
|
302
|
+
exports.WaasExportHandler = WaasExportHandler;
|
|
81
303
|
exports.withDynamicWaas = withDynamicWaas;
|
|
@@ -1,21 +1,78 @@
|
|
|
1
1
|
import { DynamicWalletClient } from '@dynamic-labs-wallet/browser-wallet-client';
|
|
2
|
+
export declare class WaasExportHandler {
|
|
3
|
+
private iframeStamper;
|
|
4
|
+
setIframeStamper(iframe: HTMLIFrameElement): void;
|
|
5
|
+
clear(): void;
|
|
6
|
+
}
|
|
2
7
|
export declare const withDynamicWaas: <T extends abstract new (...args: any[]) => any>(BaseClass: T) => (abstract new (...args: any[]) => {
|
|
3
8
|
[x: string]: any;
|
|
4
9
|
name: string;
|
|
5
10
|
overrideKey: string;
|
|
6
11
|
isEmbeddedWallet: boolean;
|
|
7
12
|
getSignedSessionId?: (() => Promise<string>) | undefined;
|
|
13
|
+
getMfaToken?: (() => Promise<string | undefined>) | undefined;
|
|
8
14
|
getAuthToken?: (() => string) | undefined;
|
|
9
15
|
environmentId?: string | undefined;
|
|
10
16
|
baseApiUrl?: string | undefined;
|
|
11
17
|
relayUrl?: string | undefined;
|
|
12
18
|
dynamicWaasClient: DynamicWalletClient | undefined;
|
|
13
19
|
chainName: string;
|
|
20
|
+
__exportHandler: WaasExportHandler;
|
|
21
|
+
validateActiveWallet(expectedAddress: string): Promise<void>;
|
|
14
22
|
setGetAuthTokenFunction(getAuthToken: () => string): void;
|
|
23
|
+
setGetMfaTokenFunction(getMfaToken: () => Promise<string | undefined>): void;
|
|
15
24
|
setEnvironmentId(environmentId: string): void;
|
|
16
25
|
setBaseApiUrl(baseApiUrl: string): void;
|
|
17
26
|
setRelayUrl(relayUrl: string): void;
|
|
18
27
|
setGetSignedSessionIdFunction(getSignedSessionId: () => Promise<string>): void;
|
|
28
|
+
delegateKeyShares({ accountAddress, password, }: {
|
|
29
|
+
accountAddress: string;
|
|
30
|
+
password?: string;
|
|
31
|
+
}): Promise<void>;
|
|
19
32
|
createDynamicWaasClient(): Promise<DynamicWalletClient>;
|
|
20
33
|
getWaasWalletClient(): Promise<DynamicWalletClient>;
|
|
34
|
+
createWalletAccount({ thresholdSignatureScheme, }?: {
|
|
35
|
+
thresholdSignatureScheme?: string;
|
|
36
|
+
}): Promise<{
|
|
37
|
+
chainName: string;
|
|
38
|
+
accountAddress: string;
|
|
39
|
+
publicKeyHex: string;
|
|
40
|
+
rawPublicKey: string | Uint8Array | undefined;
|
|
41
|
+
}>;
|
|
42
|
+
importPrivateKey({ privateKey, thresholdSignatureScheme, }: {
|
|
43
|
+
privateKey: string;
|
|
44
|
+
thresholdSignatureScheme?: string;
|
|
45
|
+
}): Promise<void>;
|
|
46
|
+
exportPrivateKey({ accountAddress, displayContainer, password, }?: {
|
|
47
|
+
accountAddress?: string;
|
|
48
|
+
displayContainer?: HTMLIFrameElement;
|
|
49
|
+
password?: string;
|
|
50
|
+
}): Promise<void>;
|
|
51
|
+
getExportHandler(): {
|
|
52
|
+
clear: () => void;
|
|
53
|
+
};
|
|
54
|
+
exportClientKeyshares({ accountAddress, password, }: {
|
|
55
|
+
accountAddress: string;
|
|
56
|
+
password?: string;
|
|
57
|
+
}): Promise<void>;
|
|
58
|
+
backupKeySharesToGoogleDrive({ accountAddress, password, }: {
|
|
59
|
+
accountAddress: string;
|
|
60
|
+
password?: string;
|
|
61
|
+
}): Promise<void>;
|
|
62
|
+
refreshWalletAccountShares({ accountAddress, password, }: {
|
|
63
|
+
accountAddress: string;
|
|
64
|
+
password?: string;
|
|
65
|
+
}): Promise<void>;
|
|
66
|
+
updatePassword({ accountAddress, existingPassword, newPassword, }: {
|
|
67
|
+
accountAddress: string;
|
|
68
|
+
existingPassword: string;
|
|
69
|
+
newPassword: string;
|
|
70
|
+
}): Promise<void>;
|
|
71
|
+
signRawMessage({ accountAddress, message, password, }: {
|
|
72
|
+
accountAddress: string;
|
|
73
|
+
message: string;
|
|
74
|
+
password?: string;
|
|
75
|
+
}): Promise<string>;
|
|
76
|
+
endSession(): Promise<void>;
|
|
77
|
+
getActiveAccountAddress(): Promise<string | undefined>;
|
|
21
78
|
}) & T;
|
package/src/DynamicWaasMixin.js
CHANGED
|
@@ -1,14 +1,33 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
3
3
|
import { DynamicWalletClient } from '@dynamic-labs-wallet/browser-wallet-client';
|
|
4
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
4
5
|
import { version } from '../package.js';
|
|
5
6
|
import { DEFAULT_BASE_API_URL, DEFAULT_BASE_MPC_RELAY_API_URL } from '../utils/constants.js';
|
|
6
7
|
|
|
8
|
+
// This class is common across all waas connectors
|
|
9
|
+
class WaasExportHandler {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.iframeStamper = null;
|
|
12
|
+
}
|
|
13
|
+
setIframeStamper(iframe) {
|
|
14
|
+
this.iframeStamper = iframe;
|
|
15
|
+
}
|
|
16
|
+
clear() {
|
|
17
|
+
if (this.iframeStamper) {
|
|
18
|
+
this.iframeStamper.remove();
|
|
19
|
+
this.iframeStamper = null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
7
23
|
const withDynamicWaas = (BaseClass) => {
|
|
8
24
|
class DynamicWaasMixin extends BaseClass {
|
|
9
25
|
setGetAuthTokenFunction(getAuthToken) {
|
|
10
26
|
this.getAuthToken = getAuthToken;
|
|
11
27
|
}
|
|
28
|
+
setGetMfaTokenFunction(getMfaToken) {
|
|
29
|
+
this.getMfaToken = getMfaToken;
|
|
30
|
+
}
|
|
12
31
|
setEnvironmentId(environmentId) {
|
|
13
32
|
this.environmentId = environmentId;
|
|
14
33
|
}
|
|
@@ -21,11 +40,36 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
21
40
|
setGetSignedSessionIdFunction(getSignedSessionId) {
|
|
22
41
|
this.getSignedSessionId = getSignedSessionId;
|
|
23
42
|
}
|
|
43
|
+
delegateKeyShares(_a) {
|
|
44
|
+
return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
45
|
+
var _b, _c;
|
|
46
|
+
if (!accountAddress) {
|
|
47
|
+
throw new Error('Account address is required');
|
|
48
|
+
}
|
|
49
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
50
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
51
|
+
if (!signedSessionId) {
|
|
52
|
+
throw new Error('Signed session ID is required');
|
|
53
|
+
}
|
|
54
|
+
const authToken = (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this);
|
|
55
|
+
if (!authToken) {
|
|
56
|
+
throw new Error('Auth token is required');
|
|
57
|
+
}
|
|
58
|
+
return walletClient.delegateKeyShares({
|
|
59
|
+
accountAddress,
|
|
60
|
+
authToken,
|
|
61
|
+
password,
|
|
62
|
+
signedSessionId,
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
24
66
|
constructor(...args) {
|
|
25
67
|
super(...args);
|
|
26
68
|
this.name = 'Dynamic Waas';
|
|
27
69
|
this.overrideKey = 'dynamicwaas';
|
|
28
70
|
this.isEmbeddedWallet = true;
|
|
71
|
+
// Initialize export handler
|
|
72
|
+
this.__exportHandler = new WaasExportHandler();
|
|
29
73
|
// Get the class name from the constructor
|
|
30
74
|
const { connectedChain } = this;
|
|
31
75
|
// Map class names to chain names
|
|
@@ -36,7 +80,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
36
80
|
};
|
|
37
81
|
const chainName = chainNameMap[connectedChain];
|
|
38
82
|
if (!chainName) {
|
|
39
|
-
throw new
|
|
83
|
+
throw new DynamicError(`Unsupported chain: ${connectedChain}`);
|
|
40
84
|
}
|
|
41
85
|
this.chainName = chainName;
|
|
42
86
|
}
|
|
@@ -45,10 +89,10 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
45
89
|
var _a;
|
|
46
90
|
const authToken = (_a = this.getAuthToken) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
47
91
|
if (!authToken) {
|
|
48
|
-
throw new
|
|
92
|
+
throw new DynamicError('Auth token is required');
|
|
49
93
|
}
|
|
50
94
|
if (!this.environmentId) {
|
|
51
|
-
throw new
|
|
95
|
+
throw new DynamicError('Environment ID is required');
|
|
52
96
|
}
|
|
53
97
|
const client = new DynamicWalletClient({
|
|
54
98
|
authToken,
|
|
@@ -70,8 +114,185 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
70
114
|
return this.dynamicWaasClient;
|
|
71
115
|
});
|
|
72
116
|
}
|
|
117
|
+
// Common methods that are identical across all connectors
|
|
118
|
+
createWalletAccount() {
|
|
119
|
+
return __awaiter(this, arguments, void 0, function* ({ thresholdSignatureScheme = 'TWO_OF_TWO', } = {}) {
|
|
120
|
+
var _a, _b;
|
|
121
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
122
|
+
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
123
|
+
if (!signedSessionId) {
|
|
124
|
+
throw new DynamicError('Signed session ID is required');
|
|
125
|
+
}
|
|
126
|
+
const createdWallet = yield walletClient.createWalletAccount({
|
|
127
|
+
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
128
|
+
signedSessionId,
|
|
129
|
+
thresholdSignatureScheme: thresholdSignatureScheme,
|
|
130
|
+
});
|
|
131
|
+
return createdWallet;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
importPrivateKey(_a) {
|
|
135
|
+
return __awaiter(this, arguments, void 0, function* ({ privateKey, thresholdSignatureScheme = 'TWO_OF_TWO', }) {
|
|
136
|
+
var _b, _c;
|
|
137
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
138
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
139
|
+
if (!signedSessionId) {
|
|
140
|
+
throw new DynamicError('Signed session ID is required');
|
|
141
|
+
}
|
|
142
|
+
yield walletClient.importPrivateKey({
|
|
143
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
144
|
+
privateKey,
|
|
145
|
+
signedSessionId,
|
|
146
|
+
thresholdSignatureScheme: thresholdSignatureScheme,
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
exportPrivateKey() {
|
|
151
|
+
return __awaiter(this, arguments, void 0, function* ({ accountAddress, displayContainer, password, } = {}) {
|
|
152
|
+
var _a, _b, _c;
|
|
153
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
154
|
+
const targetAccountAddress = accountAddress || (yield this.getActiveAccountAddress());
|
|
155
|
+
if (!targetAccountAddress) {
|
|
156
|
+
throw new DynamicError('Account address is required');
|
|
157
|
+
}
|
|
158
|
+
if (!displayContainer) {
|
|
159
|
+
throw new DynamicError('Missing display container for export private key');
|
|
160
|
+
}
|
|
161
|
+
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
162
|
+
if (!signedSessionId) {
|
|
163
|
+
throw new DynamicError('Signed session ID is required');
|
|
164
|
+
}
|
|
165
|
+
this.__exportHandler.setIframeStamper(displayContainer);
|
|
166
|
+
const mfaToken = yield ((_b = this.getMfaToken) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
167
|
+
yield walletClient.exportPrivateKey({
|
|
168
|
+
accountAddress: targetAccountAddress,
|
|
169
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
170
|
+
displayContainer,
|
|
171
|
+
mfaToken,
|
|
172
|
+
password,
|
|
173
|
+
signedSessionId,
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
getExportHandler() {
|
|
178
|
+
return this.__exportHandler;
|
|
179
|
+
}
|
|
180
|
+
exportClientKeyshares(_a) {
|
|
181
|
+
return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
182
|
+
var _b, _c;
|
|
183
|
+
if (!accountAddress) {
|
|
184
|
+
throw new DynamicError('Account address is required');
|
|
185
|
+
}
|
|
186
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
187
|
+
if (!signedSessionId) {
|
|
188
|
+
throw new DynamicError('Signed session ID is required');
|
|
189
|
+
}
|
|
190
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
191
|
+
yield walletClient.exportClientKeyshares({
|
|
192
|
+
accountAddress,
|
|
193
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
194
|
+
password,
|
|
195
|
+
signedSessionId,
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
backupKeySharesToGoogleDrive(_a) {
|
|
200
|
+
return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
201
|
+
var _b, _c;
|
|
202
|
+
if (!accountAddress) {
|
|
203
|
+
throw new DynamicError('Account address is required');
|
|
204
|
+
}
|
|
205
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
206
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
207
|
+
if (!signedSessionId) {
|
|
208
|
+
throw new DynamicError('Signed session ID is required');
|
|
209
|
+
}
|
|
210
|
+
return walletClient.backupKeySharesToGoogleDrive({
|
|
211
|
+
accountAddress,
|
|
212
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
213
|
+
password,
|
|
214
|
+
signedSessionId,
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
refreshWalletAccountShares(_a) {
|
|
219
|
+
return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
220
|
+
var _b, _c, _d;
|
|
221
|
+
if (!accountAddress) {
|
|
222
|
+
throw new DynamicError('Account address is required');
|
|
223
|
+
}
|
|
224
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
225
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
226
|
+
if (!signedSessionId) {
|
|
227
|
+
throw new DynamicError('Signed session ID is required');
|
|
228
|
+
}
|
|
229
|
+
const mfaToken = yield ((_c = this.getMfaToken) === null || _c === void 0 ? void 0 : _c.call(this));
|
|
230
|
+
return walletClient.refreshWalletAccountShares({
|
|
231
|
+
accountAddress,
|
|
232
|
+
authToken: (_d = this.getAuthToken) === null || _d === void 0 ? void 0 : _d.call(this),
|
|
233
|
+
mfaToken,
|
|
234
|
+
password,
|
|
235
|
+
signedSessionId,
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
updatePassword(_a) {
|
|
240
|
+
return __awaiter(this, arguments, void 0, function* ({ accountAddress, existingPassword, newPassword, }) {
|
|
241
|
+
var _b, _c;
|
|
242
|
+
if (!accountAddress) {
|
|
243
|
+
throw new DynamicError('Account address is required');
|
|
244
|
+
}
|
|
245
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
246
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
247
|
+
if (!signedSessionId) {
|
|
248
|
+
throw new DynamicError('Signed session ID is required');
|
|
249
|
+
}
|
|
250
|
+
return walletClient.updatePassword({
|
|
251
|
+
accountAddress,
|
|
252
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
253
|
+
existingPassword,
|
|
254
|
+
newPassword,
|
|
255
|
+
signedSessionId,
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
signRawMessage(_a) {
|
|
260
|
+
return __awaiter(this, arguments, void 0, function* ({ accountAddress, message, password, }) {
|
|
261
|
+
var _b, _c, _d;
|
|
262
|
+
if (!accountAddress) {
|
|
263
|
+
throw new DynamicError('Account address is required');
|
|
264
|
+
}
|
|
265
|
+
if (message.length !== 64) {
|
|
266
|
+
throw new DynamicError('Message must be 64 characters long');
|
|
267
|
+
}
|
|
268
|
+
const walletClient = yield this.getWaasWalletClient();
|
|
269
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
270
|
+
if (!signedSessionId) {
|
|
271
|
+
throw new DynamicError('Signed session ID is required');
|
|
272
|
+
}
|
|
273
|
+
const mfaToken = yield ((_c = this.getMfaToken) === null || _c === void 0 ? void 0 : _c.call(this));
|
|
274
|
+
return walletClient.signRawMessage({
|
|
275
|
+
accountAddress,
|
|
276
|
+
authToken: (_d = this.getAuthToken) === null || _d === void 0 ? void 0 : _d.call(this),
|
|
277
|
+
message,
|
|
278
|
+
mfaToken,
|
|
279
|
+
password,
|
|
280
|
+
signedSessionId,
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
endSession() {
|
|
285
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
286
|
+
const waasClient = yield this.getWaasWalletClient();
|
|
287
|
+
if (!waasClient) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
yield waasClient.cleanup();
|
|
291
|
+
this.dynamicWaasClient = undefined;
|
|
292
|
+
});
|
|
293
|
+
}
|
|
73
294
|
}
|
|
74
295
|
return DynamicWaasMixin;
|
|
75
296
|
};
|
|
76
297
|
|
|
77
|
-
export { withDynamicWaas };
|
|
298
|
+
export { WaasExportHandler, withDynamicWaas };
|
package/src/index.cjs
CHANGED
|
@@ -9,4 +9,5 @@ var DynamicWaasMixin = require('./DynamicWaasMixin.cjs');
|
|
|
9
9
|
|
|
10
10
|
assertPackageVersion.assertPackageVersion('@dynamic-labs/waas', _package.version);
|
|
11
11
|
|
|
12
|
+
exports.WaasExportHandler = DynamicWaasMixin.WaasExportHandler;
|
|
12
13
|
exports.withDynamicWaas = DynamicWaasMixin.withDynamicWaas;
|
package/src/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { withDynamicWaas } from './DynamicWaasMixin';
|
|
1
|
+
export { WaasExportHandler, withDynamicWaas } from './DynamicWaasMixin';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { assertPackageVersion } from '@dynamic-labs/assert-package-version';
|
|
3
3
|
import { version } from '../package.js';
|
|
4
|
-
export { withDynamicWaas } from './DynamicWaasMixin.js';
|
|
4
|
+
export { WaasExportHandler, withDynamicWaas } from './DynamicWaasMixin.js';
|
|
5
5
|
|
|
6
6
|
assertPackageVersion('@dynamic-labs/waas', version);
|