@dynamic-labs/waas 4.92.4 → 5.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +10 -10
- package/src/DynamicWaasMixin.cjs +107 -27
- package/src/DynamicWaasMixin.d.ts +31 -1
- package/src/DynamicWaasMixin.js +107 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
|
|
2
|
+
## [5.0.0-rc.1](https://github.com/dynamic-labs/dynamic-auth/compare/v5.0.0-rc.0...v5.0.0-rc.1) (2026-07-17)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### ⚠ BREAKING CHANGES
|
|
6
|
+
|
|
7
|
+
* move legacy embedded wallet to waas upgrade flow to new legacy-embedded-wallet-migration package (#11841)
|
|
8
|
+
* drop default injection of legacy embedded wallet connectors (#11833)
|
|
9
|
+
* remove legacy embedded wallet support (#11979)
|
|
10
|
+
* throw when legacy embedded wallet is detected without migration provider (#11855)
|
|
11
|
+
* remove deprecated eclipse package (#11831)
|
|
12
|
+
* remove deprecated functions and props (#11832)
|
|
13
|
+
|
|
14
|
+
|
|
2
15
|
### [4.92.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.92.3...v4.92.4) (2026-07-16)
|
|
3
16
|
|
|
4
17
|
|
|
@@ -57,6 +70,7 @@
|
|
|
57
70
|
* improve social OAuth error messages ([#11837](https://github.com/dynamic-labs/dynamic-auth/issues/11837)) ([8e57c06](https://github.com/dynamic-labs/dynamic-auth/commit/8e57c067c5a89111a32a12fb82e190cf6c46ad67))
|
|
58
71
|
* **react-native-extension:** reject path traversal in downloadFile fileName ([#11816](https://github.com/dynamic-labs/dynamic-auth/issues/11816)) ([9367a56](https://github.com/dynamic-labs/dynamic-auth/commit/9367a56b6daa853d7f7e7f5534261bc68825b239))
|
|
59
72
|
* **sdk-react-core:** display exactly the bytes signed in personal_sign preview ([#11818](https://github.com/dynamic-labs/dynamic-auth/issues/11818)) ([30b9382](https://github.com/dynamic-labs/dynamic-auth/commit/30b93829122f00060cb484aef09a03294c03f651))
|
|
73
|
+
|
|
60
74
|
|
|
61
75
|
### [4.91.6](https://github.com/dynamic-labs/dynamic-auth/compare/v4.91.5...v4.91.6) (2026-07-03)
|
|
62
76
|
|
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": "
|
|
3
|
+
"version": "5.0.0-rc.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@dynamic-labs-sdk/client": "1.18.0",
|
|
20
|
-
"@dynamic-labs/assert-package-version": "
|
|
21
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
20
|
+
"@dynamic-labs/assert-package-version": "5.0.0-rc.1",
|
|
21
|
+
"@dynamic-labs/sdk-api-core": "0.0.1082",
|
|
22
22
|
"@dynamic-labs-wallet/browser-wallet-client": "1.0.70",
|
|
23
23
|
"@dynamic-labs-wallet/forward-mpc-client": "1.0.1",
|
|
24
|
-
"@dynamic-labs/ethereum-core": "
|
|
25
|
-
"@dynamic-labs/logger": "
|
|
26
|
-
"@dynamic-labs/solana-core": "
|
|
27
|
-
"@dynamic-labs/sui-core": "
|
|
28
|
-
"@dynamic-labs/utils": "
|
|
29
|
-
"@dynamic-labs/wallet-book": "
|
|
30
|
-
"@dynamic-labs/wallet-connector-core": "
|
|
24
|
+
"@dynamic-labs/ethereum-core": "5.0.0-rc.1",
|
|
25
|
+
"@dynamic-labs/logger": "5.0.0-rc.1",
|
|
26
|
+
"@dynamic-labs/solana-core": "5.0.0-rc.1",
|
|
27
|
+
"@dynamic-labs/sui-core": "5.0.0-rc.1",
|
|
28
|
+
"@dynamic-labs/utils": "5.0.0-rc.1",
|
|
29
|
+
"@dynamic-labs/wallet-book": "5.0.0-rc.1",
|
|
30
|
+
"@dynamic-labs/wallet-connector-core": "5.0.0-rc.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {}
|
|
33
33
|
}
|
package/src/DynamicWaasMixin.cjs
CHANGED
|
@@ -189,12 +189,38 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
189
189
|
}
|
|
190
190
|
const original = this.getSignedSessionId;
|
|
191
191
|
let revoked = false;
|
|
192
|
-
|
|
192
|
+
let revokedReason;
|
|
193
|
+
let revokedInvocationCount = 0;
|
|
194
|
+
this.revokeSignedSession = (reason = 'unspecified') => {
|
|
193
195
|
revoked = true;
|
|
196
|
+
revokedReason = reason;
|
|
197
|
+
this.instrument('[DynamicWaasMixin] signed-session callback revoked', {
|
|
198
|
+
key: 'signed-session-callback-revoked',
|
|
199
|
+
operation: 'revokeSignedSession',
|
|
200
|
+
reason,
|
|
201
|
+
time: 0,
|
|
202
|
+
});
|
|
194
203
|
};
|
|
195
204
|
return {
|
|
196
205
|
getSignedSessionId: () => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
197
206
|
if (revoked) {
|
|
207
|
+
revokedInvocationCount += 1;
|
|
208
|
+
// The stale client fetched a nonce after being replaced — this is
|
|
209
|
+
// the race the revoke guards against. We log it (rather than only
|
|
210
|
+
// throwing) so Datadog can distinguish this benign guard from a
|
|
211
|
+
// real backend nonce_already_used failure: a revoked hit means the
|
|
212
|
+
// new client, not this one, owns the fresh nonce. `firstInvocation`
|
|
213
|
+
// flags the leading edge so false-positive logouts (a revoked
|
|
214
|
+
// callback firing once right after a successful backup) are easy to
|
|
215
|
+
// separate from a stale client that keeps retrying.
|
|
216
|
+
this.instrument('[DynamicWaasMixin] revoked signed-session callback invoked by stale client', {
|
|
217
|
+
firstInvocation: revokedInvocationCount === 1,
|
|
218
|
+
key: 'signed-session-callback-revoked-invoked',
|
|
219
|
+
operation: 'getSignedSessionId',
|
|
220
|
+
reason: revokedReason,
|
|
221
|
+
revokedInvocationCount,
|
|
222
|
+
time: 0,
|
|
223
|
+
});
|
|
198
224
|
throw new Error('[DynamicWaasMixin] WaaS client replaced — signed session callback revoked');
|
|
199
225
|
}
|
|
200
226
|
return original();
|
|
@@ -254,7 +280,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
254
280
|
// The old DynamicWalletClient is not destroyed — it has no cancellation
|
|
255
281
|
// API — but revoking its reverse-channel callback prevents it from
|
|
256
282
|
// fetching fresh nonces and competing with the new client's recovery.
|
|
257
|
-
(_a = this.revokeSignedSession) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
283
|
+
(_a = this.revokeSignedSession) === null || _a === void 0 ? void 0 : _a.call(this, 'force-rebuild');
|
|
258
284
|
this.revokeSignedSession = undefined;
|
|
259
285
|
this.dynamicWaasClient = undefined;
|
|
260
286
|
}
|
|
@@ -420,25 +446,80 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
420
446
|
});
|
|
421
447
|
});
|
|
422
448
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
449
|
+
/**
|
|
450
|
+
* Runs the shared cloud-backup lifecycle: resolve the password, build the
|
|
451
|
+
* iframe client, fetch the signed session id and session public key, then
|
|
452
|
+
* hand off to the provider-specific `walletClient.backupKeySharesTo*` call.
|
|
453
|
+
*
|
|
454
|
+
* Every step emits an instrumentation event tagged with a single
|
|
455
|
+
* `backupLifecycleId` so a backup can be followed end-to-end in Datadog.
|
|
456
|
+
* The same id is passed to the wallet client as `traceContext.traceId`, so
|
|
457
|
+
* the client's own sub-steps (client key-share request, backup-locations
|
|
458
|
+
* endpoint, etc.) log under the same trace — making it clear whether a
|
|
459
|
+
* backup finished before an unexpected signed-session fetch/logout.
|
|
460
|
+
*
|
|
461
|
+
* `public` for the same TS4094 mixin constraint as the other helpers here;
|
|
462
|
+
* it is internal-only.
|
|
463
|
+
*/
|
|
464
|
+
runBackupLifecycle(_a) {
|
|
465
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ provider, accountAddress, password, performBackup, }) {
|
|
466
|
+
var _b, _c;
|
|
426
467
|
if (!accountAddress) {
|
|
427
468
|
throw new utils.DynamicError('Account address is required', 'account_address_is_required');
|
|
428
469
|
}
|
|
470
|
+
const backupLifecycleId = this.generateTraceId();
|
|
471
|
+
const startTime = Date.now();
|
|
472
|
+
const traceContext = { startTime, traceId: backupLifecycleId };
|
|
473
|
+
const lifecycleContext = { accountAddress, backupLifecycleId, provider };
|
|
474
|
+
this.instrument('[backupKeyShares] lifecycle - start', Object.assign({ key: 'backup-lifecycle-start', operation: 'backupKeyShares', time: 0 }, lifecycleContext));
|
|
429
475
|
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPassword({ accountAddress }));
|
|
476
|
+
this.instrument('[backupKeyShares] password resolved', Object.assign({ hasPassword: resolvedPassword !== undefined, key: 'backup-password-resolved', operation: 'backupKeyShares', time: 0 }, lifecycleContext));
|
|
430
477
|
const walletClient = yield this.getWaasWalletClient();
|
|
478
|
+
this.instrument('[backupKeyShares] wallet client ready', Object.assign({ key: 'backup-wallet-client-ready', operation: 'backupKeyShares', time: 0 }, lifecycleContext));
|
|
431
479
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
480
|
+
this.instrument('[backupKeyShares] signed session id resolved', Object.assign({ hasSignedSessionId: Boolean(signedSessionId), key: 'backup-signed-session-resolved', operation: 'backupKeyShares', time: 0 }, lifecycleContext));
|
|
432
481
|
if (!signedSessionId) {
|
|
433
482
|
throw new utils.DynamicError('Signed session ID is required', 'signed_session_id_is_required');
|
|
434
483
|
}
|
|
435
|
-
|
|
484
|
+
const sessionPublicKey = yield ((_c = this.getSessionPublicKey) === null || _c === void 0 ? void 0 : _c.call(this));
|
|
485
|
+
this.instrument('[backupKeyShares] session public key resolved', Object.assign({ hasSessionPublicKey: Boolean(sessionPublicKey), key: 'backup-session-public-key-resolved', operation: 'backupKeyShares', time: 0 }, lifecycleContext));
|
|
486
|
+
// instrumentAsync emits `backup-request-start/completed/failed` so the
|
|
487
|
+
// provider call itself (and the client sub-steps under the shared
|
|
488
|
+
// traceId) is timed and its failure surfaced.
|
|
489
|
+
yield this.instrumentAsync({
|
|
490
|
+
context: lifecycleContext,
|
|
491
|
+
fn: () => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
492
|
+
return performBackup({
|
|
493
|
+
resolvedPassword,
|
|
494
|
+
sessionPublicKey,
|
|
495
|
+
signedSessionId,
|
|
496
|
+
traceContext,
|
|
497
|
+
walletClient,
|
|
498
|
+
});
|
|
499
|
+
}),
|
|
500
|
+
operation: 'backupKeyShares',
|
|
501
|
+
resource: 'backup-request',
|
|
502
|
+
});
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
backupKeySharesToGoogleDrive(_a) {
|
|
506
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, googleDriveAccessToken, }) {
|
|
507
|
+
return this.runBackupLifecycle({
|
|
436
508
|
accountAddress,
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
509
|
+
password,
|
|
510
|
+
performBackup: (_b) => _tslib.__awaiter(this, [_b], void 0, function* ({ walletClient, resolvedPassword, signedSessionId, sessionPublicKey, traceContext, }) {
|
|
511
|
+
var _c;
|
|
512
|
+
return walletClient.backupKeySharesToGoogleDrive({
|
|
513
|
+
accountAddress,
|
|
514
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
515
|
+
googleDriveAccessToken,
|
|
516
|
+
password: resolvedPassword,
|
|
517
|
+
sessionPublicKey,
|
|
518
|
+
signedSessionId,
|
|
519
|
+
traceContext,
|
|
520
|
+
});
|
|
521
|
+
}),
|
|
522
|
+
provider: 'google-drive',
|
|
442
523
|
});
|
|
443
524
|
});
|
|
444
525
|
}
|
|
@@ -464,22 +545,21 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
464
545
|
}
|
|
465
546
|
backupKeySharesToICloud(_a) {
|
|
466
547
|
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
467
|
-
|
|
468
|
-
if (!accountAddress) {
|
|
469
|
-
throw new utils.DynamicError('Account address is required', 'account_address_is_required');
|
|
470
|
-
}
|
|
471
|
-
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPassword({ accountAddress }));
|
|
472
|
-
const walletClient = yield this.getWaasWalletClient();
|
|
473
|
-
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
474
|
-
if (!signedSessionId) {
|
|
475
|
-
throw new utils.DynamicError('Signed session ID is required', 'signed_session_id_is_required');
|
|
476
|
-
}
|
|
477
|
-
return walletClient.backupKeySharesToICloud({
|
|
548
|
+
return this.runBackupLifecycle({
|
|
478
549
|
accountAddress,
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
550
|
+
password,
|
|
551
|
+
performBackup: (_b) => _tslib.__awaiter(this, [_b], void 0, function* ({ walletClient, resolvedPassword, signedSessionId, sessionPublicKey, traceContext, }) {
|
|
552
|
+
var _c;
|
|
553
|
+
return walletClient.backupKeySharesToICloud({
|
|
554
|
+
accountAddress,
|
|
555
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
556
|
+
password: resolvedPassword,
|
|
557
|
+
sessionPublicKey,
|
|
558
|
+
signedSessionId,
|
|
559
|
+
traceContext,
|
|
560
|
+
});
|
|
561
|
+
}),
|
|
562
|
+
provider: 'icloud',
|
|
483
563
|
});
|
|
484
564
|
});
|
|
485
565
|
}
|
|
@@ -774,7 +854,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
774
854
|
});
|
|
775
855
|
}
|
|
776
856
|
}
|
|
777
|
-
(_a = this.revokeSignedSession) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
857
|
+
(_a = this.revokeSignedSession) === null || _a === void 0 ? void 0 : _a.call(this, 'end-session');
|
|
778
858
|
this.revokeSignedSession = undefined;
|
|
779
859
|
this.dynamicWaasClient = undefined;
|
|
780
860
|
});
|
|
@@ -30,7 +30,7 @@ export declare const withDynamicWaas: <T extends abstract new (...args: any[]) =
|
|
|
30
30
|
relayUrl?: string | undefined;
|
|
31
31
|
baseClientKeysharesRelayApiUrl?: string | undefined;
|
|
32
32
|
dynamicWaasClient: DynamicWalletClient | undefined;
|
|
33
|
-
revokeSignedSession: (() => void) | undefined;
|
|
33
|
+
revokeSignedSession: ((reason?: string) => void) | undefined;
|
|
34
34
|
chainName: string;
|
|
35
35
|
authMode: 'cookie' | 'header';
|
|
36
36
|
logger: Logger;
|
|
@@ -139,6 +139,36 @@ export declare const withDynamicWaas: <T extends abstract new (...args: any[]) =
|
|
|
139
139
|
accountAddress: string;
|
|
140
140
|
password?: string;
|
|
141
141
|
}): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Runs the shared cloud-backup lifecycle: resolve the password, build the
|
|
144
|
+
* iframe client, fetch the signed session id and session public key, then
|
|
145
|
+
* hand off to the provider-specific `walletClient.backupKeySharesTo*` call.
|
|
146
|
+
*
|
|
147
|
+
* Every step emits an instrumentation event tagged with a single
|
|
148
|
+
* `backupLifecycleId` so a backup can be followed end-to-end in Datadog.
|
|
149
|
+
* The same id is passed to the wallet client as `traceContext.traceId`, so
|
|
150
|
+
* the client's own sub-steps (client key-share request, backup-locations
|
|
151
|
+
* endpoint, etc.) log under the same trace — making it clear whether a
|
|
152
|
+
* backup finished before an unexpected signed-session fetch/logout.
|
|
153
|
+
*
|
|
154
|
+
* `public` for the same TS4094 mixin constraint as the other helpers here;
|
|
155
|
+
* it is internal-only.
|
|
156
|
+
*/
|
|
157
|
+
runBackupLifecycle({ provider, accountAddress, password, performBackup, }: {
|
|
158
|
+
provider: string;
|
|
159
|
+
accountAddress: string;
|
|
160
|
+
password?: string;
|
|
161
|
+
performBackup: (prerequisites: {
|
|
162
|
+
walletClient: DynamicWalletClient;
|
|
163
|
+
resolvedPassword: string | undefined;
|
|
164
|
+
signedSessionId: string;
|
|
165
|
+
sessionPublicKey: string | undefined;
|
|
166
|
+
traceContext: {
|
|
167
|
+
traceId: string;
|
|
168
|
+
startTime: number;
|
|
169
|
+
};
|
|
170
|
+
}) => Promise<void>;
|
|
171
|
+
}): Promise<void>;
|
|
142
172
|
backupKeySharesToGoogleDrive({ accountAddress, password, googleDriveAccessToken, }: {
|
|
143
173
|
accountAddress: string;
|
|
144
174
|
password?: string;
|
package/src/DynamicWaasMixin.js
CHANGED
|
@@ -185,12 +185,38 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
185
185
|
}
|
|
186
186
|
const original = this.getSignedSessionId;
|
|
187
187
|
let revoked = false;
|
|
188
|
-
|
|
188
|
+
let revokedReason;
|
|
189
|
+
let revokedInvocationCount = 0;
|
|
190
|
+
this.revokeSignedSession = (reason = 'unspecified') => {
|
|
189
191
|
revoked = true;
|
|
192
|
+
revokedReason = reason;
|
|
193
|
+
this.instrument('[DynamicWaasMixin] signed-session callback revoked', {
|
|
194
|
+
key: 'signed-session-callback-revoked',
|
|
195
|
+
operation: 'revokeSignedSession',
|
|
196
|
+
reason,
|
|
197
|
+
time: 0,
|
|
198
|
+
});
|
|
190
199
|
};
|
|
191
200
|
return {
|
|
192
201
|
getSignedSessionId: () => __awaiter(this, void 0, void 0, function* () {
|
|
193
202
|
if (revoked) {
|
|
203
|
+
revokedInvocationCount += 1;
|
|
204
|
+
// The stale client fetched a nonce after being replaced — this is
|
|
205
|
+
// the race the revoke guards against. We log it (rather than only
|
|
206
|
+
// throwing) so Datadog can distinguish this benign guard from a
|
|
207
|
+
// real backend nonce_already_used failure: a revoked hit means the
|
|
208
|
+
// new client, not this one, owns the fresh nonce. `firstInvocation`
|
|
209
|
+
// flags the leading edge so false-positive logouts (a revoked
|
|
210
|
+
// callback firing once right after a successful backup) are easy to
|
|
211
|
+
// separate from a stale client that keeps retrying.
|
|
212
|
+
this.instrument('[DynamicWaasMixin] revoked signed-session callback invoked by stale client', {
|
|
213
|
+
firstInvocation: revokedInvocationCount === 1,
|
|
214
|
+
key: 'signed-session-callback-revoked-invoked',
|
|
215
|
+
operation: 'getSignedSessionId',
|
|
216
|
+
reason: revokedReason,
|
|
217
|
+
revokedInvocationCount,
|
|
218
|
+
time: 0,
|
|
219
|
+
});
|
|
194
220
|
throw new Error('[DynamicWaasMixin] WaaS client replaced — signed session callback revoked');
|
|
195
221
|
}
|
|
196
222
|
return original();
|
|
@@ -250,7 +276,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
250
276
|
// The old DynamicWalletClient is not destroyed — it has no cancellation
|
|
251
277
|
// API — but revoking its reverse-channel callback prevents it from
|
|
252
278
|
// fetching fresh nonces and competing with the new client's recovery.
|
|
253
|
-
(_a = this.revokeSignedSession) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
279
|
+
(_a = this.revokeSignedSession) === null || _a === void 0 ? void 0 : _a.call(this, 'force-rebuild');
|
|
254
280
|
this.revokeSignedSession = undefined;
|
|
255
281
|
this.dynamicWaasClient = undefined;
|
|
256
282
|
}
|
|
@@ -416,25 +442,80 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
416
442
|
});
|
|
417
443
|
});
|
|
418
444
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
445
|
+
/**
|
|
446
|
+
* Runs the shared cloud-backup lifecycle: resolve the password, build the
|
|
447
|
+
* iframe client, fetch the signed session id and session public key, then
|
|
448
|
+
* hand off to the provider-specific `walletClient.backupKeySharesTo*` call.
|
|
449
|
+
*
|
|
450
|
+
* Every step emits an instrumentation event tagged with a single
|
|
451
|
+
* `backupLifecycleId` so a backup can be followed end-to-end in Datadog.
|
|
452
|
+
* The same id is passed to the wallet client as `traceContext.traceId`, so
|
|
453
|
+
* the client's own sub-steps (client key-share request, backup-locations
|
|
454
|
+
* endpoint, etc.) log under the same trace — making it clear whether a
|
|
455
|
+
* backup finished before an unexpected signed-session fetch/logout.
|
|
456
|
+
*
|
|
457
|
+
* `public` for the same TS4094 mixin constraint as the other helpers here;
|
|
458
|
+
* it is internal-only.
|
|
459
|
+
*/
|
|
460
|
+
runBackupLifecycle(_a) {
|
|
461
|
+
return __awaiter(this, arguments, void 0, function* ({ provider, accountAddress, password, performBackup, }) {
|
|
462
|
+
var _b, _c;
|
|
422
463
|
if (!accountAddress) {
|
|
423
464
|
throw new DynamicError('Account address is required', 'account_address_is_required');
|
|
424
465
|
}
|
|
466
|
+
const backupLifecycleId = this.generateTraceId();
|
|
467
|
+
const startTime = Date.now();
|
|
468
|
+
const traceContext = { startTime, traceId: backupLifecycleId };
|
|
469
|
+
const lifecycleContext = { accountAddress, backupLifecycleId, provider };
|
|
470
|
+
this.instrument('[backupKeyShares] lifecycle - start', Object.assign({ key: 'backup-lifecycle-start', operation: 'backupKeyShares', time: 0 }, lifecycleContext));
|
|
425
471
|
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPassword({ accountAddress }));
|
|
472
|
+
this.instrument('[backupKeyShares] password resolved', Object.assign({ hasPassword: resolvedPassword !== undefined, key: 'backup-password-resolved', operation: 'backupKeyShares', time: 0 }, lifecycleContext));
|
|
426
473
|
const walletClient = yield this.getWaasWalletClient();
|
|
474
|
+
this.instrument('[backupKeyShares] wallet client ready', Object.assign({ key: 'backup-wallet-client-ready', operation: 'backupKeyShares', time: 0 }, lifecycleContext));
|
|
427
475
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
476
|
+
this.instrument('[backupKeyShares] signed session id resolved', Object.assign({ hasSignedSessionId: Boolean(signedSessionId), key: 'backup-signed-session-resolved', operation: 'backupKeyShares', time: 0 }, lifecycleContext));
|
|
428
477
|
if (!signedSessionId) {
|
|
429
478
|
throw new DynamicError('Signed session ID is required', 'signed_session_id_is_required');
|
|
430
479
|
}
|
|
431
|
-
|
|
480
|
+
const sessionPublicKey = yield ((_c = this.getSessionPublicKey) === null || _c === void 0 ? void 0 : _c.call(this));
|
|
481
|
+
this.instrument('[backupKeyShares] session public key resolved', Object.assign({ hasSessionPublicKey: Boolean(sessionPublicKey), key: 'backup-session-public-key-resolved', operation: 'backupKeyShares', time: 0 }, lifecycleContext));
|
|
482
|
+
// instrumentAsync emits `backup-request-start/completed/failed` so the
|
|
483
|
+
// provider call itself (and the client sub-steps under the shared
|
|
484
|
+
// traceId) is timed and its failure surfaced.
|
|
485
|
+
yield this.instrumentAsync({
|
|
486
|
+
context: lifecycleContext,
|
|
487
|
+
fn: () => __awaiter(this, void 0, void 0, function* () {
|
|
488
|
+
return performBackup({
|
|
489
|
+
resolvedPassword,
|
|
490
|
+
sessionPublicKey,
|
|
491
|
+
signedSessionId,
|
|
492
|
+
traceContext,
|
|
493
|
+
walletClient,
|
|
494
|
+
});
|
|
495
|
+
}),
|
|
496
|
+
operation: 'backupKeyShares',
|
|
497
|
+
resource: 'backup-request',
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
backupKeySharesToGoogleDrive(_a) {
|
|
502
|
+
return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, googleDriveAccessToken, }) {
|
|
503
|
+
return this.runBackupLifecycle({
|
|
432
504
|
accountAddress,
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
505
|
+
password,
|
|
506
|
+
performBackup: (_b) => __awaiter(this, [_b], void 0, function* ({ walletClient, resolvedPassword, signedSessionId, sessionPublicKey, traceContext, }) {
|
|
507
|
+
var _c;
|
|
508
|
+
return walletClient.backupKeySharesToGoogleDrive({
|
|
509
|
+
accountAddress,
|
|
510
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
511
|
+
googleDriveAccessToken,
|
|
512
|
+
password: resolvedPassword,
|
|
513
|
+
sessionPublicKey,
|
|
514
|
+
signedSessionId,
|
|
515
|
+
traceContext,
|
|
516
|
+
});
|
|
517
|
+
}),
|
|
518
|
+
provider: 'google-drive',
|
|
438
519
|
});
|
|
439
520
|
});
|
|
440
521
|
}
|
|
@@ -460,22 +541,21 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
460
541
|
}
|
|
461
542
|
backupKeySharesToICloud(_a) {
|
|
462
543
|
return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
463
|
-
|
|
464
|
-
if (!accountAddress) {
|
|
465
|
-
throw new DynamicError('Account address is required', 'account_address_is_required');
|
|
466
|
-
}
|
|
467
|
-
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPassword({ accountAddress }));
|
|
468
|
-
const walletClient = yield this.getWaasWalletClient();
|
|
469
|
-
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
470
|
-
if (!signedSessionId) {
|
|
471
|
-
throw new DynamicError('Signed session ID is required', 'signed_session_id_is_required');
|
|
472
|
-
}
|
|
473
|
-
return walletClient.backupKeySharesToICloud({
|
|
544
|
+
return this.runBackupLifecycle({
|
|
474
545
|
accountAddress,
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
546
|
+
password,
|
|
547
|
+
performBackup: (_b) => __awaiter(this, [_b], void 0, function* ({ walletClient, resolvedPassword, signedSessionId, sessionPublicKey, traceContext, }) {
|
|
548
|
+
var _c;
|
|
549
|
+
return walletClient.backupKeySharesToICloud({
|
|
550
|
+
accountAddress,
|
|
551
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
552
|
+
password: resolvedPassword,
|
|
553
|
+
sessionPublicKey,
|
|
554
|
+
signedSessionId,
|
|
555
|
+
traceContext,
|
|
556
|
+
});
|
|
557
|
+
}),
|
|
558
|
+
provider: 'icloud',
|
|
479
559
|
});
|
|
480
560
|
});
|
|
481
561
|
}
|
|
@@ -770,7 +850,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
770
850
|
});
|
|
771
851
|
}
|
|
772
852
|
}
|
|
773
|
-
(_a = this.revokeSignedSession) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
853
|
+
(_a = this.revokeSignedSession) === null || _a === void 0 ? void 0 : _a.call(this, 'end-session');
|
|
774
854
|
this.revokeSignedSession = undefined;
|
|
775
855
|
this.dynamicWaasClient = undefined;
|
|
776
856
|
});
|