wallaby-cash 2.3.5 → 2.3.7-alpha.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/dist/base.d.ts +1 -0
- package/dist/generated/api.d.ts +84 -55
- package/dist/helpers/omit.d.ts +1 -0
- package/dist/index.cjs.js +471 -367
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +469 -368
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +469 -368
- package/dist/index.js.map +1 -1
- package/dist/lib/auth/auth.service.d.ts +2 -3
- package/dist/lib/network/network-diagnostic.d.ts +43 -0
- package/dist/lib/transactions/index.d.ts +2 -3
- package/dist/lib/utils/storage.service.d.ts +0 -12
- package/dist/lib/wallet/wallet-data.service.d.ts +1 -1
- package/dist/lib/wallet/wallet-handlers.service.d.ts +1 -16
- package/dist/lib/wallet/wallet.service.d.ts +7 -7
- package/dist/package.json +3 -2
- package/dist/routes/swap.d.ts +1 -3
- package/dist/routes/wallet.d.ts +1 -1
- package/dist/types/auth.d.ts +9 -7
- package/dist/types/common.d.ts +4 -0
- package/dist/types/error-response-codes.d.ts +6 -1
- package/dist/types/network-diagnostic.d.ts +23 -0
- package/dist/types/storage.d.ts +0 -1
- package/dist/types/transactions.d.ts +7 -4
- package/dist/types/wallet.d.ts +3 -17
- package/package.json +3 -2
- package/dist/lib/auth/auth.model.d.ts +0 -108
- package/dist/lib/transactions/transactions.model.d.ts +0 -22
package/dist/index.cjs.js
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
4
|
|
|
5
|
+
const algosdk = require('algosdk');
|
|
6
|
+
const bip39 = require('bip39');
|
|
5
7
|
const uuid = require('uuid');
|
|
6
8
|
const log = require('loglevel');
|
|
7
9
|
const cryptoJs = require('crypto-js');
|
|
8
10
|
const jwtDecode = require('jwt-decode');
|
|
9
|
-
const lodash = require('lodash');
|
|
10
11
|
const WebAuthn = require('@simplewebauthn/browser');
|
|
11
12
|
const jsBase64 = require('js-base64');
|
|
12
13
|
|
|
@@ -30,6 +31,8 @@ n.default = e;
|
|
|
30
31
|
return Object.freeze(n);
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
const algosdk__namespace = /*#__PURE__*/_interopNamespaceCompat(algosdk);
|
|
35
|
+
const bip39__namespace = /*#__PURE__*/_interopNamespaceCompat(bip39);
|
|
33
36
|
const log__default = /*#__PURE__*/_interopDefaultCompat(log);
|
|
34
37
|
const WebAuthn__namespace = /*#__PURE__*/_interopNamespaceCompat(WebAuthn);
|
|
35
38
|
|
|
@@ -105,10 +108,11 @@ exports.TransportEnum = void 0;
|
|
|
105
108
|
* @property {string} [errorCode] - Specific error code for categorizing the error.
|
|
106
109
|
* @property {any} [data] - Additional data related to the error.
|
|
107
110
|
* @property {number} [status] - Alias for statusCode for compatibility.
|
|
111
|
+
* @property {NetworkDiagnosticResult} [networkDiagnostic] - Optional network diagnostic information for network-related errors.
|
|
108
112
|
*/
|
|
109
113
|
class WallabyError extends Error {
|
|
110
114
|
constructor(errorPayload) {
|
|
111
|
-
const { message, statusCode, errorCode, data, cause, onError } = errorPayload;
|
|
115
|
+
const { message, statusCode, errorCode, data, cause, onError, networkDiagnostic } = errorPayload;
|
|
112
116
|
super(message);
|
|
113
117
|
this.name = 'WallabyError';
|
|
114
118
|
this.status = statusCode;
|
|
@@ -116,6 +120,7 @@ class WallabyError extends Error {
|
|
|
116
120
|
this.cause = cause;
|
|
117
121
|
this.onError = onError;
|
|
118
122
|
this.data = data;
|
|
123
|
+
this.networkDiagnostic = networkDiagnostic;
|
|
119
124
|
Error.captureStackTrace(this, WallabyError);
|
|
120
125
|
}
|
|
121
126
|
static isWallabyError(error) {
|
|
@@ -291,7 +296,6 @@ exports.LocalStorageItems = void 0;
|
|
|
291
296
|
LocalStorageItems["EncryptedAlgorandSeedPhrase"] = "encrypted-algorand-seedPhrase";
|
|
292
297
|
LocalStorageItems["EncryptedDevicePrivateKey"] = "encrypted-private-key";
|
|
293
298
|
LocalStorageItems["ClientAuthPublicKey"] = "client-auth-pub-key";
|
|
294
|
-
LocalStorageItems["WallabyAuthPubKey"] = "wallaby-auth-pub-key";
|
|
295
299
|
LocalStorageItems["ClientAuthToken"] = "republic-jwt";
|
|
296
300
|
LocalStorageItems["PasskeyCredential"] = "pass-key-credential";
|
|
297
301
|
LocalStorageItems["Blob"] = "blob";
|
|
@@ -396,6 +400,12 @@ exports.ErrorResponseCodes = void 0;
|
|
|
396
400
|
ErrorResponseCodes["sdk_passkey_challenge_unavailable"] = "sdk_passkey_challenge_unavailable";
|
|
397
401
|
ErrorResponseCodes["sdk_passkey_authentication_failed"] = "sdk_passkey_authentication_failed";
|
|
398
402
|
ErrorResponseCodes["sdk_passkey_registration_failed"] = "sdk_passkey_registration_failed";
|
|
403
|
+
// network diagnostic errors
|
|
404
|
+
ErrorResponseCodes["sdk_network_offline"] = "sdk_network_offline";
|
|
405
|
+
ErrorResponseCodes["sdk_network_connectivity"] = "sdk_network_connectivity";
|
|
406
|
+
ErrorResponseCodes["sdk_network_likely_cors_or_auth"] = "sdk_network_likely_cors_or_auth";
|
|
407
|
+
ErrorResponseCodes["sdk_network_fast_failure"] = "sdk_network_fast_failure";
|
|
408
|
+
ErrorResponseCodes["sdk_network_unknown"] = "sdk_network_unknown";
|
|
399
409
|
})(exports.ErrorResponseCodes || (exports.ErrorResponseCodes = {}));
|
|
400
410
|
|
|
401
411
|
const UnknownError = {
|
|
@@ -552,12 +562,12 @@ const global$1 = (typeof global !== "undefined" ? global :
|
|
|
552
562
|
var env = {};
|
|
553
563
|
|
|
554
564
|
// from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
|
|
555
|
-
var performance = global$1.performance || {};
|
|
556
|
-
performance.now ||
|
|
557
|
-
performance.mozNow ||
|
|
558
|
-
performance.msNow ||
|
|
559
|
-
performance.oNow ||
|
|
560
|
-
performance.webkitNow ||
|
|
565
|
+
var performance$1 = global$1.performance || {};
|
|
566
|
+
performance$1.now ||
|
|
567
|
+
performance$1.mozNow ||
|
|
568
|
+
performance$1.msNow ||
|
|
569
|
+
performance$1.oNow ||
|
|
570
|
+
performance$1.webkitNow ||
|
|
561
571
|
function(){ return (new Date()).getTime() };
|
|
562
572
|
|
|
563
573
|
var browser$1 = {
|
|
@@ -597,7 +607,7 @@ const MASTER_ENCRYPTION_KEY = '9fa9d3f3c77c20d3a50a08e5299644be29f6e6206ef3479fe
|
|
|
597
607
|
{ type: 'public-key', alg: exports.PublicKeyCredentialAlgorithm.ES256 },
|
|
598
608
|
];
|
|
599
609
|
const isWeb = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
600
|
-
const currentPackageVersion = "2.3.
|
|
610
|
+
const currentPackageVersion = "2.3.7-alpha.0" ;
|
|
601
611
|
|
|
602
612
|
/**
|
|
603
613
|
* Storage keys adapter for Storage interface across different platforms.
|
|
@@ -4929,43 +4939,6 @@ class StorageService {
|
|
|
4929
4939
|
}
|
|
4930
4940
|
throw new Error(`Unsupported seed phrase type: ${seedPhraseType}`);
|
|
4931
4941
|
}
|
|
4932
|
-
/**
|
|
4933
|
-
*
|
|
4934
|
-
* Stores Wallaby auth public key to local storage
|
|
4935
|
-
* @param wallabyAuthPubKey
|
|
4936
|
-
*/
|
|
4937
|
-
async setWallabyAuthPubKey(wallabyAuthPubKey) {
|
|
4938
|
-
await this.save(exports.V2KeyNames.WallabyAuthPubKey, wallabyAuthPubKey);
|
|
4939
|
-
}
|
|
4940
|
-
/**
|
|
4941
|
-
*
|
|
4942
|
-
* Fetches Wallaby auth public key from local storage
|
|
4943
|
-
* @returns { string | undefined } Wallaby Auth Public key or undefined.
|
|
4944
|
-
*/
|
|
4945
|
-
async getWallabyAuthPubKey() {
|
|
4946
|
-
let wallabyAuthPubKey = await this.fetch(exports.V2KeyNames.WallabyAuthPubKey);
|
|
4947
|
-
if (wallabyAuthPubKey) {
|
|
4948
|
-
return wallabyAuthPubKey;
|
|
4949
|
-
}
|
|
4950
|
-
// Legacy key migration
|
|
4951
|
-
const legacyKey = `wallabyAuthPubKey_${this.userId}`;
|
|
4952
|
-
const legacyPubKey = await this.getItem(legacyKey);
|
|
4953
|
-
if (legacyPubKey) {
|
|
4954
|
-
wallabyAuthPubKey = legacyPubKey;
|
|
4955
|
-
}
|
|
4956
|
-
else {
|
|
4957
|
-
const v1Key = `${this.environment}-wallaby-auth-public-key-${this.userId}`;
|
|
4958
|
-
const v1PubKey = await this.getItem(v1Key);
|
|
4959
|
-
if (v1PubKey) {
|
|
4960
|
-
wallabyAuthPubKey = v1PubKey;
|
|
4961
|
-
}
|
|
4962
|
-
}
|
|
4963
|
-
if (wallabyAuthPubKey) {
|
|
4964
|
-
await this.setWallabyAuthPubKey(wallabyAuthPubKey);
|
|
4965
|
-
return wallabyAuthPubKey;
|
|
4966
|
-
}
|
|
4967
|
-
return undefined;
|
|
4968
|
-
}
|
|
4969
4942
|
/**
|
|
4970
4943
|
* @deprecated This function is only used in tests, and should not be used anywhere else.
|
|
4971
4944
|
* Encrypts and stores device auth private key
|
|
@@ -6340,16 +6313,6 @@ class Api {
|
|
|
6340
6313
|
* @secure
|
|
6341
6314
|
*/
|
|
6342
6315
|
getEstimateFee: (query, params = {}) => this.http.request(Object.assign({ path: `/api/v1/transactions/estimate-fee`, method: "GET", query: query, secure: true, format: "json" }, params)),
|
|
6343
|
-
/**
|
|
6344
|
-
* No description
|
|
6345
|
-
*
|
|
6346
|
-
* @tags Transactions, Query
|
|
6347
|
-
* @name FetchTransactionByHashOrReference
|
|
6348
|
-
* @summary Fetch transaction status data using a reference or transaction hash
|
|
6349
|
-
* @request GET:/api/v1/transactions/status
|
|
6350
|
-
* @secure
|
|
6351
|
-
*/
|
|
6352
|
-
fetchTransactionByHashOrReference: (query, params = {}) => this.http.request(Object.assign({ path: `/api/v1/transactions/status`, method: "GET", query: query, secure: true, format: "json" }, params)),
|
|
6353
6316
|
/**
|
|
6354
6317
|
* @description The sign and broadcast transaction API was designed and implemented specifically for uses cases where the caller has their own custom raw transaction that is not yet currently supported by Wallaby
|
|
6355
6318
|
*
|
|
@@ -6360,6 +6323,16 @@ class Api {
|
|
|
6360
6323
|
* @secure
|
|
6361
6324
|
*/
|
|
6362
6325
|
signAndBroadcastRawTx: (data, params = {}) => this.http.request(Object.assign({ path: `/api/v1/transactions/sign-broadcast-rawtx`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json" }, params)),
|
|
6326
|
+
/**
|
|
6327
|
+
* No description
|
|
6328
|
+
*
|
|
6329
|
+
* @tags Transactions, Query
|
|
6330
|
+
* @name FetchTransactionByHashOrReference
|
|
6331
|
+
* @summary Fetch transaction status data using a reference or transaction hash
|
|
6332
|
+
* @request GET:/api/v1/transactions/status
|
|
6333
|
+
* @secure
|
|
6334
|
+
*/
|
|
6335
|
+
fetchTransactionByHashOrReference: (query, params = {}) => this.http.request(Object.assign({ path: `/api/v1/transactions/status`, method: "GET", query: query, secure: true, format: "json" }, params)),
|
|
6363
6336
|
/**
|
|
6364
6337
|
* No description
|
|
6365
6338
|
*
|
|
@@ -6871,6 +6844,184 @@ function objectToQueryParams(obj) {
|
|
|
6871
6844
|
return params.toString();
|
|
6872
6845
|
}
|
|
6873
6846
|
|
|
6847
|
+
var NetworkDiagnosticCategory;
|
|
6848
|
+
(function (NetworkDiagnosticCategory) {
|
|
6849
|
+
NetworkDiagnosticCategory["OfflineHint"] = "offline_hint";
|
|
6850
|
+
NetworkDiagnosticCategory["LikelyCorsOrAuthOrExtension"] = "likely_cors_or_auth_or_extension";
|
|
6851
|
+
NetworkDiagnosticCategory["ConnectivityOrDns"] = "connectivity_or_dns";
|
|
6852
|
+
NetworkDiagnosticCategory["FastFailureHint"] = "fast_failure_hint";
|
|
6853
|
+
NetworkDiagnosticCategory["UnknownNetwork"] = "unknown_network";
|
|
6854
|
+
})(NetworkDiagnosticCategory || (NetworkDiagnosticCategory = {}));
|
|
6855
|
+
|
|
6856
|
+
const HEALTH_CHECK_TIMEOUT_MS = 5000;
|
|
6857
|
+
class NetworkDiagnostic {
|
|
6858
|
+
/**
|
|
6859
|
+
* Run comprehensive network diagnostics after a fetch failure.
|
|
6860
|
+
* Combines multiple signals to determine the likely cause of the failure.
|
|
6861
|
+
*/
|
|
6862
|
+
static async run(context) {
|
|
6863
|
+
const { failedUrl, originalError } = context;
|
|
6864
|
+
logger.info('Running network diagnostic', { failedUrl, originalError });
|
|
6865
|
+
const signals = {
|
|
6866
|
+
online: NetworkDiagnostic.getNavigatorOnline(),
|
|
6867
|
+
healthCheck: 'unavailable',
|
|
6868
|
+
failedRequestUrl: failedUrl,
|
|
6869
|
+
};
|
|
6870
|
+
const hints = [];
|
|
6871
|
+
const resourceTiming = NetworkDiagnostic.getResourceTimingForUrl(failedUrl);
|
|
6872
|
+
if (resourceTiming) {
|
|
6873
|
+
signals.resourceTiming = {
|
|
6874
|
+
nextHopProtocol: resourceTiming.nextHopProtocol,
|
|
6875
|
+
duration: resourceTiming.duration,
|
|
6876
|
+
transferSize: resourceTiming.transferSize,
|
|
6877
|
+
};
|
|
6878
|
+
if (resourceTiming.duration < 50) {
|
|
6879
|
+
hints.push('Very fast failure may indicate a local blocker or extension.');
|
|
6880
|
+
}
|
|
6881
|
+
}
|
|
6882
|
+
const healthUrl = NetworkDiagnostic.deriveHealthUrl(failedUrl);
|
|
6883
|
+
signals.healthCheck = await NetworkDiagnostic.simpleHealthCheck(healthUrl);
|
|
6884
|
+
const category = NetworkDiagnostic.determineCategory(signals);
|
|
6885
|
+
const message = NetworkDiagnostic.getCategoryMessage(category);
|
|
6886
|
+
return {
|
|
6887
|
+
category,
|
|
6888
|
+
message,
|
|
6889
|
+
signals,
|
|
6890
|
+
hints: hints.length > 0 ? hints : undefined,
|
|
6891
|
+
};
|
|
6892
|
+
}
|
|
6893
|
+
/**
|
|
6894
|
+
* Check if navigator.onLine is available and return its value.
|
|
6895
|
+
*/
|
|
6896
|
+
static getNavigatorOnline() {
|
|
6897
|
+
if (typeof navigator !== 'undefined' && typeof navigator.onLine === 'boolean') {
|
|
6898
|
+
return navigator.onLine;
|
|
6899
|
+
}
|
|
6900
|
+
return 'unknown';
|
|
6901
|
+
}
|
|
6902
|
+
/**
|
|
6903
|
+
* Get the PerformanceResourceTiming entry for the given URL.
|
|
6904
|
+
* Returns the most recent entry if multiple matches exist.
|
|
6905
|
+
*/
|
|
6906
|
+
static getResourceTimingForUrl(url) {
|
|
6907
|
+
if (typeof performance === 'undefined' || typeof performance.getEntriesByType !== 'function') {
|
|
6908
|
+
return undefined;
|
|
6909
|
+
}
|
|
6910
|
+
try {
|
|
6911
|
+
const entries = performance.getEntriesByType('resource');
|
|
6912
|
+
const matchingEntries = entries.filter((entry) => entry.name && entry.name.includes(url));
|
|
6913
|
+
if (matchingEntries.length === 0) {
|
|
6914
|
+
return undefined;
|
|
6915
|
+
}
|
|
6916
|
+
return matchingEntries[matchingEntries.length - 1];
|
|
6917
|
+
}
|
|
6918
|
+
catch (_a) {
|
|
6919
|
+
return undefined;
|
|
6920
|
+
}
|
|
6921
|
+
}
|
|
6922
|
+
/**
|
|
6923
|
+
* Perform a simple no-cors health check to the `/healthz` endpoint.
|
|
6924
|
+
* This uses mode: 'no-cors' to avoid CORS preflight and credential issues.
|
|
6925
|
+
*/
|
|
6926
|
+
static async simpleHealthCheck(healthUrl) {
|
|
6927
|
+
if (typeof fetch === 'undefined') {
|
|
6928
|
+
return 'unavailable';
|
|
6929
|
+
}
|
|
6930
|
+
const controller = new AbortController();
|
|
6931
|
+
const timeoutId = setTimeout(() => controller.abort(), HEALTH_CHECK_TIMEOUT_MS);
|
|
6932
|
+
try {
|
|
6933
|
+
const response = await fetch(healthUrl, {
|
|
6934
|
+
method: 'HEAD',
|
|
6935
|
+
mode: 'no-cors',
|
|
6936
|
+
cache: 'no-store',
|
|
6937
|
+
signal: controller.signal,
|
|
6938
|
+
});
|
|
6939
|
+
if (response.type === 'opaque') {
|
|
6940
|
+
return 'ok';
|
|
6941
|
+
}
|
|
6942
|
+
return 'failed';
|
|
6943
|
+
}
|
|
6944
|
+
catch (_a) {
|
|
6945
|
+
return 'failed';
|
|
6946
|
+
}
|
|
6947
|
+
finally {
|
|
6948
|
+
clearTimeout(timeoutId);
|
|
6949
|
+
}
|
|
6950
|
+
}
|
|
6951
|
+
/**
|
|
6952
|
+
* Derive the health check URL from the base URL origin and `/healthz`.
|
|
6953
|
+
*/
|
|
6954
|
+
static deriveHealthUrl(baseUrl) {
|
|
6955
|
+
try {
|
|
6956
|
+
const url = new URL(baseUrl);
|
|
6957
|
+
const origin = url.origin;
|
|
6958
|
+
return `${origin}/healthz`;
|
|
6959
|
+
}
|
|
6960
|
+
catch (_a) {
|
|
6961
|
+
return `${baseUrl}/healthz`;
|
|
6962
|
+
}
|
|
6963
|
+
}
|
|
6964
|
+
/**
|
|
6965
|
+
* Determine the diagnostic category based on collected signals.
|
|
6966
|
+
* Order matters - checks are performed in priority order.
|
|
6967
|
+
*/
|
|
6968
|
+
static determineCategory(signals) {
|
|
6969
|
+
if (signals.online === false) {
|
|
6970
|
+
return NetworkDiagnosticCategory.OfflineHint;
|
|
6971
|
+
}
|
|
6972
|
+
if (signals.healthCheck === 'ok') {
|
|
6973
|
+
return NetworkDiagnosticCategory.LikelyCorsOrAuthOrExtension;
|
|
6974
|
+
}
|
|
6975
|
+
if (signals.resourceTiming && signals.resourceTiming.duration !== undefined && signals.resourceTiming.duration < 50) {
|
|
6976
|
+
return NetworkDiagnosticCategory.FastFailureHint;
|
|
6977
|
+
}
|
|
6978
|
+
if (signals.healthCheck === 'failed') {
|
|
6979
|
+
return NetworkDiagnosticCategory.ConnectivityOrDns;
|
|
6980
|
+
}
|
|
6981
|
+
return NetworkDiagnosticCategory.UnknownNetwork;
|
|
6982
|
+
}
|
|
6983
|
+
/**
|
|
6984
|
+
* Get a user-facing message for the given diagnostic category.
|
|
6985
|
+
*/
|
|
6986
|
+
static getCategoryMessage(category) {
|
|
6987
|
+
switch (category) {
|
|
6988
|
+
case NetworkDiagnosticCategory.OfflineHint:
|
|
6989
|
+
return 'Device reports offline; check Wi-Fi or mobile data.';
|
|
6990
|
+
case NetworkDiagnosticCategory.LikelyCorsOrAuthOrExtension:
|
|
6991
|
+
return 'Reachability to the API is OK; the failure may be due to CORS, authentication headers, or a browser extension blocking authenticated requests.';
|
|
6992
|
+
case NetworkDiagnosticCategory.ConnectivityOrDns:
|
|
6993
|
+
return 'Cannot reach the API host; check DNS, VPN, firewall, or ISP filtering.';
|
|
6994
|
+
case NetworkDiagnosticCategory.FastFailureHint:
|
|
6995
|
+
return 'Very fast failure may indicate a local blocker or extension.';
|
|
6996
|
+
case NetworkDiagnosticCategory.UnknownNetwork:
|
|
6997
|
+
default:
|
|
6998
|
+
return 'Network request failed; see diagnostic details.';
|
|
6999
|
+
}
|
|
7000
|
+
}
|
|
7001
|
+
/**
|
|
7002
|
+
* Check if an error is a network-layer failure candidate that should trigger diagnostics.
|
|
7003
|
+
* Returns true for TypeErrors with fetch-related messages, or DOMException with NetworkError name.
|
|
7004
|
+
*/
|
|
7005
|
+
static isNetworkFailureCandidate(error) {
|
|
7006
|
+
if (!error)
|
|
7007
|
+
return false;
|
|
7008
|
+
if (error instanceof TypeError) {
|
|
7009
|
+
const message = error.message.toLowerCase();
|
|
7010
|
+
return (message.includes('failed to fetch') ||
|
|
7011
|
+
message.includes('load failed') ||
|
|
7012
|
+
message.includes('networkerror') ||
|
|
7013
|
+
message.includes('network request failed'));
|
|
7014
|
+
}
|
|
7015
|
+
if (error instanceof Error && error.name === 'NetworkError') {
|
|
7016
|
+
return true;
|
|
7017
|
+
}
|
|
7018
|
+
if (typeof DOMException !== 'undefined' && error instanceof DOMException && error.name === 'NetworkError') {
|
|
7019
|
+
return true;
|
|
7020
|
+
}
|
|
7021
|
+
return false;
|
|
7022
|
+
}
|
|
7023
|
+
}
|
|
7024
|
+
|
|
6874
7025
|
class Base {
|
|
6875
7026
|
constructor(config) {
|
|
6876
7027
|
var _a, _b;
|
|
@@ -6921,6 +7072,26 @@ class Base {
|
|
|
6921
7072
|
if (error instanceof WallabyError) {
|
|
6922
7073
|
throw error;
|
|
6923
7074
|
}
|
|
7075
|
+
// Handle network-level failures with diagnostics
|
|
7076
|
+
if (NetworkDiagnostic.isNetworkFailureCandidate(error)) {
|
|
7077
|
+
const fullUrl = `${this.baseUrl.replace(/\/api\/v1\/?$/, '')}${params.path || ''}`;
|
|
7078
|
+
const diagnostic = await NetworkDiagnostic.run({
|
|
7079
|
+
failedUrl: fullUrl,
|
|
7080
|
+
originalError: error,
|
|
7081
|
+
});
|
|
7082
|
+
const errorCode = this.mapCategoryToErrorCode(diagnostic.category);
|
|
7083
|
+
throw new WallabyError({
|
|
7084
|
+
message: diagnostic.message,
|
|
7085
|
+
statusCode: 0,
|
|
7086
|
+
errorCode,
|
|
7087
|
+
data: {
|
|
7088
|
+
originalError: error,
|
|
7089
|
+
networkDiagnostic: diagnostic,
|
|
7090
|
+
},
|
|
7091
|
+
cause: error.cause,
|
|
7092
|
+
networkDiagnostic: diagnostic,
|
|
7093
|
+
});
|
|
7094
|
+
}
|
|
6924
7095
|
// Wrap any other errors
|
|
6925
7096
|
throw new WallabyError({
|
|
6926
7097
|
message: error.message || 'Unknown error occurred',
|
|
@@ -7090,6 +7261,25 @@ class Base {
|
|
|
7090
7261
|
name: error.name,
|
|
7091
7262
|
error,
|
|
7092
7263
|
});
|
|
7264
|
+
if (NetworkDiagnostic.isNetworkFailureCandidate(error)) {
|
|
7265
|
+
const diagnostic = await NetworkDiagnostic.run({
|
|
7266
|
+
failedUrl: fullUrl,
|
|
7267
|
+
originalError: error,
|
|
7268
|
+
});
|
|
7269
|
+
const errorCode = this.mapCategoryToErrorCode(diagnostic.category);
|
|
7270
|
+
throw new WallabyError({
|
|
7271
|
+
message: diagnostic.message,
|
|
7272
|
+
statusCode: 0,
|
|
7273
|
+
errorCode,
|
|
7274
|
+
data: {
|
|
7275
|
+
code: error.name,
|
|
7276
|
+
originalError: error,
|
|
7277
|
+
networkDiagnostic: diagnostic,
|
|
7278
|
+
},
|
|
7279
|
+
cause: error.cause,
|
|
7280
|
+
networkDiagnostic: diagnostic,
|
|
7281
|
+
});
|
|
7282
|
+
}
|
|
7093
7283
|
throw new WallabyError({
|
|
7094
7284
|
message: error.message || 'Network request failed',
|
|
7095
7285
|
statusCode: 0,
|
|
@@ -7102,6 +7292,20 @@ class Base {
|
|
|
7102
7292
|
});
|
|
7103
7293
|
}
|
|
7104
7294
|
}
|
|
7295
|
+
mapCategoryToErrorCode(category) {
|
|
7296
|
+
switch (category) {
|
|
7297
|
+
case NetworkDiagnosticCategory.OfflineHint:
|
|
7298
|
+
return exports.ErrorResponseCodes.sdk_network_offline;
|
|
7299
|
+
case NetworkDiagnosticCategory.ConnectivityOrDns:
|
|
7300
|
+
return exports.ErrorResponseCodes.sdk_network_connectivity;
|
|
7301
|
+
case NetworkDiagnosticCategory.LikelyCorsOrAuthOrExtension:
|
|
7302
|
+
return exports.ErrorResponseCodes.sdk_network_likely_cors_or_auth;
|
|
7303
|
+
case NetworkDiagnosticCategory.FastFailureHint:
|
|
7304
|
+
return exports.ErrorResponseCodes.sdk_network_fast_failure;
|
|
7305
|
+
default:
|
|
7306
|
+
return exports.ErrorResponseCodes.sdk_network_unknown;
|
|
7307
|
+
}
|
|
7308
|
+
}
|
|
7105
7309
|
async _getRequestHeaders() {
|
|
7106
7310
|
const accessToken = await this.localStorageService.fetch(exports.LocalStorageItems.AccessToken);
|
|
7107
7311
|
if (!isTest && jwtHasExpired(this.clientAuthToken)) {
|
|
@@ -7193,8 +7397,8 @@ const WalletRoutes = {
|
|
|
7193
7397
|
requiresAccessToken: false,
|
|
7194
7398
|
},
|
|
7195
7399
|
getTokenBalance: {
|
|
7196
|
-
fullPath: ({ address,
|
|
7197
|
-
return (`/query/assets/balance?address=${address}&assetSymbol=${
|
|
7400
|
+
fullPath: ({ address, assetSymbol, chainName, tokenStandard }) => {
|
|
7401
|
+
return (`/query/assets/balance?address=${address}&assetSymbol=${assetSymbol}` +
|
|
7198
7402
|
`${tokenStandard ? `&tokenType=${tokenStandard}` : ''}` +
|
|
7199
7403
|
`${chainName ? `&chainName=${chainName}` : ''}`);
|
|
7200
7404
|
},
|
|
@@ -7380,22 +7584,29 @@ const TransactionsRoutes = {
|
|
|
7380
7584
|
|
|
7381
7585
|
const SwapRoutes = {
|
|
7382
7586
|
getQuote: {
|
|
7383
|
-
fullPath: ({ walletId }) => `/
|
|
7587
|
+
fullPath: ({ walletId }) => `/wallets/${walletId}/swap/quote`,
|
|
7384
7588
|
method: exports.RequestMethod.Post,
|
|
7385
7589
|
requiresAccessToken: true,
|
|
7386
7590
|
},
|
|
7387
7591
|
executeSwap: {
|
|
7388
|
-
fullPath:
|
|
7592
|
+
fullPath: '/wallets/execute-swap',
|
|
7389
7593
|
method: exports.RequestMethod.Post,
|
|
7390
7594
|
requiresAccessToken: true,
|
|
7391
7595
|
},
|
|
7392
7596
|
getSwaps: {
|
|
7393
|
-
fullPath: ({ walletId }) => `/
|
|
7597
|
+
fullPath: ({ walletId }) => `/wallets/${walletId}/swaps`,
|
|
7394
7598
|
method: exports.RequestMethod.Get,
|
|
7395
7599
|
requiresAccessToken: true,
|
|
7396
7600
|
},
|
|
7397
7601
|
};
|
|
7398
7602
|
|
|
7603
|
+
function omit(obj, keys) {
|
|
7604
|
+
if (!obj)
|
|
7605
|
+
return {};
|
|
7606
|
+
const keysSet = new Set(keys);
|
|
7607
|
+
return Object.fromEntries(Object.entries(obj).filter(([k]) => !keysSet.has(k)));
|
|
7608
|
+
}
|
|
7609
|
+
|
|
7399
7610
|
/* eslint-disable no-useless-catch */
|
|
7400
7611
|
/**
|
|
7401
7612
|
* Web Authenticator Implementation
|
|
@@ -7535,7 +7746,7 @@ class PasskeyService {
|
|
|
7535
7746
|
this.authenticator = new Authenticator();
|
|
7536
7747
|
}
|
|
7537
7748
|
preparePasskeyRequestOptions(options) {
|
|
7538
|
-
var _a, _b, _c, _d, _e, _f;
|
|
7749
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7539
7750
|
const prfExtensionEvaluation = ((_b = (_a = options.extensions) === null || _a === void 0 ? void 0 : _a.prf.eval) === null || _b === void 0 ? void 0 : _b.base64)
|
|
7540
7751
|
? decodeBase64URL(options.extensions.prf.eval.base64)
|
|
7541
7752
|
: ((_d = (_c = options.extensions) === null || _c === void 0 ? void 0 : _c.prf.eval) === null || _d === void 0 ? void 0 : _d.first) instanceof ArrayBuffer
|
|
@@ -7543,11 +7754,13 @@ class PasskeyService {
|
|
|
7543
7754
|
: typeof ((_f = (_e = options.extensions) === null || _e === void 0 ? void 0 : _e.prf.eval) === null || _f === void 0 ? void 0 : _f.first) === 'object'
|
|
7544
7755
|
? new Uint8Array(Object.values(options.extensions.prf.eval.first))
|
|
7545
7756
|
: undefined;
|
|
7546
|
-
const parsedOptions = Object.assign(Object.assign({}, options), { extensions: Object.assign(Object.assign({}, options.extensions), { prf:
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7757
|
+
const parsedOptions = Object.assign(Object.assign({}, options), { extensions: Object.assign(Object.assign({}, options.extensions), { prf: prfExtensionEvaluation !== undefined
|
|
7758
|
+
? {
|
|
7759
|
+
eval: {
|
|
7760
|
+
first: prfExtensionEvaluation,
|
|
7761
|
+
},
|
|
7762
|
+
}
|
|
7763
|
+
: ((_h = (_g = options.extensions) === null || _g === void 0 ? void 0 : _g.prf) !== null && _h !== void 0 ? _h : {}) }) });
|
|
7551
7764
|
logger.log('SDK::PasskeyService::preparePasskeyRequestOptions::parsedOptions', !!parsedOptions);
|
|
7552
7765
|
// While the authenticator still works with the prf and would return the response (if any),
|
|
7553
7766
|
// the library `@simplewebauthn/browser` does not support the prf extension in its type intentionally.
|
|
@@ -7555,7 +7768,7 @@ class PasskeyService {
|
|
|
7555
7768
|
return parsedOptions;
|
|
7556
7769
|
}
|
|
7557
7770
|
preparePasskeyCreationOptions(options) {
|
|
7558
|
-
var _a, _b, _c, _d, _e, _f;
|
|
7771
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7559
7772
|
const prfExtensionEvaluation = ((_b = (_a = options.extensions) === null || _a === void 0 ? void 0 : _a.prf.eval) === null || _b === void 0 ? void 0 : _b.base64)
|
|
7560
7773
|
? decodeBase64URL(options.extensions.prf.eval.base64)
|
|
7561
7774
|
: ((_d = (_c = options.extensions) === null || _c === void 0 ? void 0 : _c.prf.eval) === null || _d === void 0 ? void 0 : _d.first) instanceof ArrayBuffer
|
|
@@ -7563,12 +7776,8 @@ class PasskeyService {
|
|
|
7563
7776
|
: typeof ((_f = (_e = options.extensions) === null || _e === void 0 ? void 0 : _e.prf.eval) === null || _f === void 0 ? void 0 : _f.first) === 'object'
|
|
7564
7777
|
? new Uint8Array(Object.values(options.extensions.prf.eval.first))
|
|
7565
7778
|
: undefined;
|
|
7566
|
-
const parsedOptions = Object.assign(Object.assign({}, options), { extensions: Object.assign(Object.assign({}, options.extensions), { prf: {
|
|
7567
|
-
|
|
7568
|
-
first: prfExtensionEvaluation,
|
|
7569
|
-
},
|
|
7570
|
-
} }) });
|
|
7571
|
-
logger.log('SDK::PasskeyService::preparePasskeyRequestOptions::parsedOptions', !!parsedOptions);
|
|
7779
|
+
const parsedOptions = Object.assign(Object.assign({}, options), { extensions: Object.assign(Object.assign({}, options.extensions), { prf: prfExtensionEvaluation !== undefined ? { eval: { first: prfExtensionEvaluation } } : ((_h = (_g = options.extensions) === null || _g === void 0 ? void 0 : _g.prf) !== null && _h !== void 0 ? _h : {}) }) });
|
|
7780
|
+
logger.log('SDK::PasskeyService::preparePasskeyCreationOptions::parsedOptions', !!parsedOptions);
|
|
7572
7781
|
return parsedOptions;
|
|
7573
7782
|
}
|
|
7574
7783
|
/**
|
|
@@ -7583,7 +7792,10 @@ class PasskeyService {
|
|
|
7583
7792
|
let passkeyCredential;
|
|
7584
7793
|
let signInResponse;
|
|
7585
7794
|
try {
|
|
7586
|
-
const registrationChallengeResponse = await getSignature(
|
|
7795
|
+
const registrationChallengeResponse = await getSignature({
|
|
7796
|
+
deviceAuthKeys: deviceKeyPair,
|
|
7797
|
+
passkeyChallengeType: exports.PasskeyChallengeType.REGISTRATION,
|
|
7798
|
+
});
|
|
7587
7799
|
if (!registrationChallengeResponse.registrationOptions)
|
|
7588
7800
|
throw new WallabyError({
|
|
7589
7801
|
message: 'Passkey challenge could not be retrieved, please try again later.',
|
|
@@ -7626,7 +7838,10 @@ class PasskeyService {
|
|
|
7626
7838
|
catch (error) {
|
|
7627
7839
|
logger.error('SDK::PasskeyService::addNewPasskey::error', error);
|
|
7628
7840
|
if (error && error.code === AuthenticatorPreviouslyRegisteredError.error) {
|
|
7629
|
-
const authenticationChallengeResponse = await getSignature(
|
|
7841
|
+
const authenticationChallengeResponse = await getSignature({
|
|
7842
|
+
deviceAuthKeys: deviceKeyPair,
|
|
7843
|
+
passkeyChallengeType: exports.PasskeyChallengeType.AUTHENTICATION,
|
|
7844
|
+
});
|
|
7630
7845
|
if (!authenticationChallengeResponse.authenticationOptions)
|
|
7631
7846
|
throw new WallabyError({
|
|
7632
7847
|
message: 'Passkey challenge could not be retrieved, please try again later.',
|
|
@@ -7697,7 +7912,7 @@ class PasskeyService {
|
|
|
7697
7912
|
errorCode: exports.ErrorResponseCodes.sdk_passkey_challenge_unavailable,
|
|
7698
7913
|
});
|
|
7699
7914
|
const parsedOptions = this.preparePasskeyRequestOptions(challengeResponse.authenticationOptions);
|
|
7700
|
-
const updatedOptions = Object.assign(Object.assign({}, challengeResponse.authenticationOptions), { extensions: Object.assign(Object.assign({},
|
|
7915
|
+
const updatedOptions = Object.assign(Object.assign({}, challengeResponse.authenticationOptions), { extensions: Object.assign(Object.assign({}, omit(parsedOptions.extensions, ['credProps'])), { prf: {
|
|
7701
7916
|
eval: {
|
|
7702
7917
|
first: (_b = (_a = parsedOptions.extensions.prf) === null || _a === void 0 ? void 0 : _a.eval) === null || _b === void 0 ? void 0 : _b.first,
|
|
7703
7918
|
},
|
|
@@ -7926,10 +8141,6 @@ class PasskeyService {
|
|
|
7926
8141
|
key: exports.LocalStorageItems.AccessToken,
|
|
7927
8142
|
value: authenticationResponse.accessToken,
|
|
7928
8143
|
},
|
|
7929
|
-
{
|
|
7930
|
-
key: exports.LocalStorageItems.WallabyAuthPubKey,
|
|
7931
|
-
value: authenticationResponse.user.wallabyAuthPubKey,
|
|
7932
|
-
},
|
|
7933
8144
|
]);
|
|
7934
8145
|
}
|
|
7935
8146
|
/**
|
|
@@ -8138,13 +8349,14 @@ class AuthService extends Base {
|
|
|
8138
8349
|
* @param { PasskeyChallengeType } passkeyChallengeType the type of passkey challenge to request, either for registration or authentication.
|
|
8139
8350
|
* @returns the messaged, the hash, and the signature using the passed private key.
|
|
8140
8351
|
*/
|
|
8141
|
-
async getSignature(deviceAuthKeys, passkeyChallengeType) {
|
|
8352
|
+
async getSignature({ deviceAuthKeys, walletId, passkeyChallengeType, }) {
|
|
8142
8353
|
try {
|
|
8143
8354
|
logger.debug('SDK::AuthService::getSignature::authType', this.deviceAuthType);
|
|
8144
8355
|
const challengeType = passkeyChallengeType !== null && passkeyChallengeType !== void 0 ? passkeyChallengeType : exports.PasskeyChallengeType.REGISTRATION;
|
|
8145
8356
|
logger.debug('SDK::AuthService::getSignature::challengeType', challengeType);
|
|
8146
8357
|
const response = await this.request(AuthRoutes.signatureMessage, {
|
|
8147
8358
|
payload: {
|
|
8359
|
+
walletId,
|
|
8148
8360
|
clientAuthPubKey: deviceAuthKeys.publicKey,
|
|
8149
8361
|
passkeyChallengeType: challengeType,
|
|
8150
8362
|
},
|
|
@@ -8175,7 +8387,10 @@ class AuthService extends Base {
|
|
|
8175
8387
|
logger.info('key pair generated', !!deviceKeyPair);
|
|
8176
8388
|
let authentication;
|
|
8177
8389
|
try {
|
|
8178
|
-
const signatureMessageResponse = await this.getSignature(
|
|
8390
|
+
const signatureMessageResponse = await this.getSignature({
|
|
8391
|
+
deviceAuthKeys: deviceKeyPair,
|
|
8392
|
+
passkeyChallengeType: exports.PasskeyChallengeType.REGISTRATION,
|
|
8393
|
+
});
|
|
8179
8394
|
logger.info('signature has been generated', !!signatureMessageResponse);
|
|
8180
8395
|
switch (this.deviceAuthType) {
|
|
8181
8396
|
case exports.AuthType.Passkey:
|
|
@@ -8208,7 +8423,10 @@ class AuthService extends Base {
|
|
|
8208
8423
|
// TODO Add passkey errors to the WallabyError ErrorResponseCodes
|
|
8209
8424
|
if ((error && error.error === InvalidStateError.error) || error.code === AuthenticatorPreviouslyRegisteredError.error) {
|
|
8210
8425
|
logger.info('SDK::AuthService::signUp::handling previously registered passkey error');
|
|
8211
|
-
const newChallenge = await this.getSignature(
|
|
8426
|
+
const newChallenge = await this.getSignature({
|
|
8427
|
+
deviceAuthKeys: deviceKeyPair,
|
|
8428
|
+
passkeyChallengeType: exports.PasskeyChallengeType.AUTHENTICATION,
|
|
8429
|
+
});
|
|
8212
8430
|
authentication = await this.passkeyService.authenticate({
|
|
8213
8431
|
deviceKeyPair: { publicKey: deviceKeyPair.publicKey, decryptedPrivateKey: deviceKeyPair.privateKey },
|
|
8214
8432
|
challengeResponse: newChallenge,
|
|
@@ -8245,10 +8463,7 @@ class AuthService extends Base {
|
|
|
8245
8463
|
errorCode: exports.ErrorResponseCodes.sdk_invalid_parameter,
|
|
8246
8464
|
});
|
|
8247
8465
|
}
|
|
8248
|
-
await this.localStorageService.
|
|
8249
|
-
{ key: exports.LocalStorageItems.AccessToken, value: authentication.accessToken },
|
|
8250
|
-
{ key: exports.LocalStorageItems.WallabyAuthPubKey, value: authentication.user.wallabyAuthPubKey },
|
|
8251
|
-
]);
|
|
8466
|
+
await this.localStorageService.save(exports.LocalStorageItems.AccessToken, authentication.accessToken);
|
|
8252
8467
|
return Object.freeze(Object.assign(Object.assign({}, authentication), input));
|
|
8253
8468
|
}
|
|
8254
8469
|
catch (error) {
|
|
@@ -8324,7 +8539,9 @@ class AuthService extends Base {
|
|
|
8324
8539
|
},
|
|
8325
8540
|
credentialsKeyPair,
|
|
8326
8541
|
});
|
|
8327
|
-
const signatureMessage = await this.getSignature({
|
|
8542
|
+
const signatureMessage = await this.getSignature({
|
|
8543
|
+
deviceAuthKeys: { publicKey: clientPublicKey, privateKey: decryptedClientAuthPrivKey },
|
|
8544
|
+
});
|
|
8328
8545
|
const authentication = await this.request(AuthRoutes.signIn, {
|
|
8329
8546
|
payload: {
|
|
8330
8547
|
externalUserId: this.userId,
|
|
@@ -8448,10 +8665,6 @@ class AuthService extends Base {
|
|
|
8448
8665
|
key: exports.LocalStorageItems.AccessToken,
|
|
8449
8666
|
value: authResponse.accessToken,
|
|
8450
8667
|
},
|
|
8451
|
-
{
|
|
8452
|
-
key: exports.LocalStorageItems.WallabyAuthPubKey,
|
|
8453
|
-
value: authResponse.user.wallabyAuthPubKey,
|
|
8454
|
-
},
|
|
8455
8668
|
]);
|
|
8456
8669
|
return authResponse;
|
|
8457
8670
|
});
|
|
@@ -8536,12 +8749,16 @@ class WalletHandlersService extends Base {
|
|
|
8536
8749
|
this.userId = config.userId;
|
|
8537
8750
|
}
|
|
8538
8751
|
async handleImportWallet(deviceAuthKeys, importWalletInput) {
|
|
8539
|
-
var _a, _b, _c, _d;
|
|
8752
|
+
var _a, _b, _c, _d, _e;
|
|
8540
8753
|
try {
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8754
|
+
// Since users importing a wallet can be requesting to create a new record, walletId is not available yet.
|
|
8755
|
+
// However the enclave needs a uuid to bind the ephemeral wallaby auth public key to it for the first request
|
|
8756
|
+
// Using the reference as the fallback for the walletId in this case.
|
|
8757
|
+
const { signature, message, wallabyAuthPubKey } = await this.authService.getSignature({
|
|
8758
|
+
walletId: (_a = importWalletInput.walletId) !== null && _a !== void 0 ? _a : importWalletInput.reference,
|
|
8759
|
+
deviceAuthKeys: { publicKey: deviceAuthKeys.publicKey, privateKey: deviceAuthKeys.privateKey },
|
|
8760
|
+
passkeyChallengeType: this.deviceAuthType === exports.AuthType.Passkey ? exports.PasskeyChallengeType.AUTHENTICATION : undefined,
|
|
8761
|
+
});
|
|
8545
8762
|
if ((importWalletInput.returnWalletOption === exports.ReturnWalletOption.ReturnOnlyEncryptedShares ||
|
|
8546
8763
|
importWalletInput.returnWalletOption === exports.ReturnWalletOption.ReturnBothEncryptedSharesAndSeed) &&
|
|
8547
8764
|
!importWalletInput.keyShareOptions) {
|
|
@@ -8551,7 +8768,7 @@ class WalletHandlersService extends Base {
|
|
|
8551
8768
|
errorCode: exports.ErrorResponseCodes.sdk_missing_parameter,
|
|
8552
8769
|
});
|
|
8553
8770
|
}
|
|
8554
|
-
const { numberOfKeyShares, threshold } = (
|
|
8771
|
+
const { numberOfKeyShares, threshold } = (_b = importWalletInput.keyShareOptions) !== null && _b !== void 0 ? _b : {};
|
|
8555
8772
|
if (threshold && numberOfKeyShares && numberOfKeyShares < threshold) {
|
|
8556
8773
|
throw new WallabyError({
|
|
8557
8774
|
message: 'Number of shares must be greater than or equal to the threshold',
|
|
@@ -8561,10 +8778,11 @@ class WalletHandlersService extends Base {
|
|
|
8561
8778
|
}
|
|
8562
8779
|
const readyForTransportSeedPhrase = await this.cipher.encrypt({
|
|
8563
8780
|
data: importWalletInput.seedPhrase,
|
|
8564
|
-
encryptionKey:
|
|
8781
|
+
encryptionKey: wallabyAuthPubKey,
|
|
8565
8782
|
});
|
|
8566
8783
|
const importWalletPayload = {
|
|
8567
|
-
reference:
|
|
8784
|
+
reference: importWalletInput.reference,
|
|
8785
|
+
walletId: importWalletInput.walletId,
|
|
8568
8786
|
message,
|
|
8569
8787
|
signature,
|
|
8570
8788
|
encryptedSeed: readyForTransportSeedPhrase,
|
|
@@ -8573,7 +8791,7 @@ class WalletHandlersService extends Base {
|
|
|
8573
8791
|
numShares: numberOfKeyShares !== null && numberOfKeyShares !== void 0 ? numberOfKeyShares : 0,
|
|
8574
8792
|
threshold: threshold !== null && threshold !== void 0 ? threshold : 0,
|
|
8575
8793
|
walletOwnershipType: exports.WalletOwnershipType.SingleOwner,
|
|
8576
|
-
wallabyKeepsOne: (
|
|
8794
|
+
wallabyKeepsOne: (_d = (_c = importWalletInput.keyShareOptions) === null || _c === void 0 ? void 0 : _c.storeOneKeyShareWithWallaby) !== null && _d !== void 0 ? _d : false,
|
|
8577
8795
|
};
|
|
8578
8796
|
const importWalletRequest = await this.request(WalletRoutes.importSeedPhraseV2, {
|
|
8579
8797
|
payload: importWalletPayload,
|
|
@@ -8611,7 +8829,7 @@ class WalletHandlersService extends Base {
|
|
|
8611
8829
|
}
|
|
8612
8830
|
catch (error) {
|
|
8613
8831
|
throw new WallabyError({
|
|
8614
|
-
message: (
|
|
8832
|
+
message: (_e = error.message) !== null && _e !== void 0 ? _e : 'Failed to handle importing the wallet',
|
|
8615
8833
|
statusCode: error.statusCode,
|
|
8616
8834
|
errorCode: error.errorCode,
|
|
8617
8835
|
data: error.data,
|
|
@@ -8633,9 +8851,9 @@ class WalletHandlersService extends Base {
|
|
|
8633
8851
|
var _a, _b, _c, _d, _e, _f;
|
|
8634
8852
|
try {
|
|
8635
8853
|
const { signature, message, hashedMessage } = await this.authService.getSignature({
|
|
8636
|
-
publicKey: deviceAuthKeys.publicKey,
|
|
8637
|
-
|
|
8638
|
-
}
|
|
8854
|
+
deviceAuthKeys: { publicKey: deviceAuthKeys.publicKey, privateKey: deviceAuthKeys.privateKey },
|
|
8855
|
+
passkeyChallengeType: exports.PasskeyChallengeType.AUTHENTICATION,
|
|
8856
|
+
});
|
|
8639
8857
|
if ((walletCreationInput.returnWalletOption === exports.ReturnWalletOption.ReturnOnlyEncryptedShares ||
|
|
8640
8858
|
walletCreationInput.returnWalletOption === exports.ReturnWalletOption.ReturnBothEncryptedSharesAndSeed) &&
|
|
8641
8859
|
!walletCreationInput.keyShareOptions) {
|
|
@@ -8812,36 +9030,6 @@ class WalletHandlersService extends Base {
|
|
|
8812
9030
|
});
|
|
8813
9031
|
}
|
|
8814
9032
|
}
|
|
8815
|
-
/**
|
|
8816
|
-
*
|
|
8817
|
-
* @param encryptedKeyShares - Encrypted key shares that are encrypted with the wallabyAuthPublicKey.
|
|
8818
|
-
* @param walletId - The ID of the wallet for which the seed phrase is being constructed.
|
|
8819
|
-
* @param deviceAuthKeys - The device authentication key pair used to sign the request.
|
|
8820
|
-
* @description This function constructs the seed phrase from encrypted key shares.
|
|
8821
|
-
* It retrieves the seed phrase by sending a request to the Wallaby API with the encrypted key shares.
|
|
8822
|
-
* The shares should be encrypted with the wallabyAuthPublicKey before passing them into this function.
|
|
8823
|
-
* @returns The function returns the encrypted seed phrase wrapped with client device public key.
|
|
8824
|
-
*/
|
|
8825
|
-
async handleConstructingSeedPhraseFromShares({ encryptedKeyShares, walletId, deviceAuthKeys, }) {
|
|
8826
|
-
try {
|
|
8827
|
-
const { signature, message } = await this.authService.getSignature(deviceAuthKeys, exports.PasskeyChallengeType.AUTHENTICATION);
|
|
8828
|
-
const retrieveSeedPhraseResponse = await this.request(WalletRoutes.retrieveSeedPhrase, {
|
|
8829
|
-
payload: {
|
|
8830
|
-
walletId: walletId,
|
|
8831
|
-
signature,
|
|
8832
|
-
message,
|
|
8833
|
-
clientAuthPubKey: deviceAuthKeys.publicKey,
|
|
8834
|
-
recoveryPubKey: deviceAuthKeys.publicKey,
|
|
8835
|
-
encryptedShares: encryptedKeyShares,
|
|
8836
|
-
},
|
|
8837
|
-
});
|
|
8838
|
-
return retrieveSeedPhraseResponse.encryptedSeed;
|
|
8839
|
-
}
|
|
8840
|
-
catch (error) {
|
|
8841
|
-
logger.error('SDK::handleConstructingSeedPhraseFromShares::error', error);
|
|
8842
|
-
return Promise.reject(error);
|
|
8843
|
-
}
|
|
8844
|
-
}
|
|
8845
9033
|
}
|
|
8846
9034
|
|
|
8847
9035
|
class WalletService extends Base {
|
|
@@ -8951,7 +9139,6 @@ class WalletService extends Base {
|
|
|
8951
9139
|
*/
|
|
8952
9140
|
async export({ walletId, authenticationOptions, exportOptions }) {
|
|
8953
9141
|
try {
|
|
8954
|
-
const { user: { wallabyAuthPubKey }, } = authenticationOptions;
|
|
8955
9142
|
if (!exportOptions.algorandSeedPhrase && !exportOptions.standardSeedPhrase && !exportOptions.keyShares) {
|
|
8956
9143
|
throw new WallabyError({
|
|
8957
9144
|
message: 'exportOptions must be provided with at least one of the following options: algorandSeedPhrase, standardSeedPhrase, keyShares',
|
|
@@ -9042,21 +9229,7 @@ class WalletService extends Base {
|
|
|
9042
9229
|
},
|
|
9043
9230
|
});
|
|
9044
9231
|
if (exportOptions.algorandSeedPhrase) {
|
|
9045
|
-
|
|
9046
|
-
standardSeedPhrase: decryptedSeedPhrase,
|
|
9047
|
-
authenticationOptions,
|
|
9048
|
-
walletId,
|
|
9049
|
-
});
|
|
9050
|
-
decryptedAlgorandSeedPhrase = await this.cipher.displayDataFromServer({
|
|
9051
|
-
encryptedData: algorandSeedPhrase.convertedEncryptedSeed,
|
|
9052
|
-
encryptedDevicePrivateKey: parsedDevicePrivateKey,
|
|
9053
|
-
options: {
|
|
9054
|
-
authType: this.deviceAuthType,
|
|
9055
|
-
password: authenticationOptions.password,
|
|
9056
|
-
salt: authenticationOptions.user.clientSalt,
|
|
9057
|
-
prfValue: authenticationOptions.prfValue,
|
|
9058
|
-
},
|
|
9059
|
-
});
|
|
9232
|
+
decryptedAlgorandSeedPhrase = this.getAlgorandSeedPhrase(decryptedSeedPhrase);
|
|
9060
9233
|
if (!decryptedAlgorandSeedPhrase) {
|
|
9061
9234
|
throw new WallabyError({
|
|
9062
9235
|
message: 'Something went wrong decrypting algorand seed phrase.',
|
|
@@ -9075,10 +9248,20 @@ class WalletService extends Base {
|
|
|
9075
9248
|
});
|
|
9076
9249
|
}
|
|
9077
9250
|
const parsedPrimaryShare = safeJsonParse(encryptedPrimaryDeviceShare);
|
|
9251
|
+
const deviceAuthPublicKey = publicKeyByPrivateKey(decryptedDevicePrivateKey);
|
|
9252
|
+
const deviceAuthKeys = {
|
|
9253
|
+
publicKey: deviceAuthPublicKey,
|
|
9254
|
+
privateKey: decryptedDevicePrivateKey,
|
|
9255
|
+
};
|
|
9256
|
+
const { signature, message, wallabyAuthPubKey: ephemeralWallabyAuthPubKey, } = await this.authService.getSignature({
|
|
9257
|
+
deviceAuthKeys,
|
|
9258
|
+
walletId,
|
|
9259
|
+
passkeyChallengeType: exports.PasskeyChallengeType.AUTHENTICATION,
|
|
9260
|
+
});
|
|
9078
9261
|
const wallabyBoundPrimaryShare = await this.cipher.prepareStoredDataForTransport({
|
|
9079
9262
|
storedEncryptedData: parsedPrimaryShare,
|
|
9080
9263
|
encryptedDevicePrivateKey: parsedDevicePrivateKey,
|
|
9081
|
-
wallabyPublicKey: wallabyAuthPubKey,
|
|
9264
|
+
wallabyPublicKey: ephemeralWallabyAuthPubKey || authenticationOptions.user.wallabyAuthPubKey,
|
|
9082
9265
|
options: {
|
|
9083
9266
|
authType: this.deviceAuthType,
|
|
9084
9267
|
password: authenticationOptions.password,
|
|
@@ -9086,35 +9269,22 @@ class WalletService extends Base {
|
|
|
9086
9269
|
prfValue: authenticationOptions.prfValue,
|
|
9087
9270
|
},
|
|
9088
9271
|
});
|
|
9089
|
-
const
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
|
|
9094
|
-
|
|
9095
|
-
|
|
9272
|
+
const retrieveSeedPhraseResponse = await this.request(WalletRoutes.retrieveSeedPhrase, {
|
|
9273
|
+
payload: {
|
|
9274
|
+
walletId: walletId,
|
|
9275
|
+
signature,
|
|
9276
|
+
message,
|
|
9277
|
+
clientAuthPubKey: deviceAuthKeys.publicKey,
|
|
9278
|
+
recoveryPubKey: deviceAuthKeys.publicKey,
|
|
9279
|
+
encryptedShares: [wallabyBoundPrimaryShare],
|
|
9096
9280
|
},
|
|
9097
9281
|
});
|
|
9098
9282
|
decryptedSeedPhrase = await this.cipher.decrypt({
|
|
9099
|
-
cipherText:
|
|
9283
|
+
cipherText: retrieveSeedPhraseResponse.encryptedSeed,
|
|
9100
9284
|
decryptionKey: decryptedDevicePrivateKey,
|
|
9101
9285
|
});
|
|
9102
9286
|
if (exportOptions.algorandSeedPhrase) {
|
|
9103
|
-
|
|
9104
|
-
standardSeedPhrase: decryptedSeedPhrase,
|
|
9105
|
-
authenticationOptions,
|
|
9106
|
-
walletId,
|
|
9107
|
-
});
|
|
9108
|
-
decryptedAlgorandSeedPhrase = await this.cipher.displayDataFromServer({
|
|
9109
|
-
encryptedData: algorandSeedPhrase.convertedEncryptedSeed,
|
|
9110
|
-
encryptedDevicePrivateKey: parsedDevicePrivateKey,
|
|
9111
|
-
options: {
|
|
9112
|
-
authType: this.deviceAuthType,
|
|
9113
|
-
password: authenticationOptions.password,
|
|
9114
|
-
salt: authenticationOptions.user.clientSalt,
|
|
9115
|
-
prfValue: authenticationOptions.prfValue,
|
|
9116
|
-
},
|
|
9117
|
-
});
|
|
9287
|
+
decryptedAlgorandSeedPhrase = this.getAlgorandSeedPhrase(decryptedSeedPhrase);
|
|
9118
9288
|
}
|
|
9119
9289
|
}
|
|
9120
9290
|
}
|
|
@@ -9148,7 +9318,9 @@ class WalletService extends Base {
|
|
|
9148
9318
|
* @returns {ImportWalletResponse} The wallet has been created successfully.
|
|
9149
9319
|
*/
|
|
9150
9320
|
async import(input) {
|
|
9321
|
+
var _a;
|
|
9151
9322
|
try {
|
|
9323
|
+
const requestReference = (_a = input.reference) !== null && _a !== void 0 ? _a : uuid.v4();
|
|
9152
9324
|
const encryptedDevicePrivateKey = await this.localStorageService.fetch(exports.LocalStorageItems.EncryptedDevicePrivateKey);
|
|
9153
9325
|
if (!encryptedDevicePrivateKey) {
|
|
9154
9326
|
throw new WallabyError({
|
|
@@ -9179,7 +9351,7 @@ class WalletService extends Base {
|
|
|
9179
9351
|
const importRequest = await this.handlers.handleImportWallet({
|
|
9180
9352
|
publicKey: clientAuthPubKey,
|
|
9181
9353
|
privateKey: decryptedDevicePrivateKey,
|
|
9182
|
-
}, input);
|
|
9354
|
+
}, Object.assign(Object.assign({}, input), { reference: requestReference }));
|
|
9183
9355
|
return importRequest;
|
|
9184
9356
|
}
|
|
9185
9357
|
catch (error) {
|
|
@@ -9193,11 +9365,15 @@ class WalletService extends Base {
|
|
|
9193
9365
|
*
|
|
9194
9366
|
* @param { RecoverWalletRequest } input - The request object containing the necessary parameters.
|
|
9195
9367
|
* @returns { Promise<RecoverWalletResponse> } The response containing the recovered wallet details.
|
|
9368
|
+
*
|
|
9369
|
+
* @deprecated This function is deprecated and will be removed in the next major release. It only supports seed phrase recovery.
|
|
9370
|
+
* Use `import` instead with the `RETURN_ONLY_ENCRYPTED_SEED_PHRASE` option to maintain the same behavior.
|
|
9196
9371
|
*/
|
|
9197
9372
|
async recover(input) {
|
|
9198
9373
|
var _a, _b;
|
|
9199
9374
|
try {
|
|
9200
|
-
const wallabyPublicKey = input.authenticationOptions.
|
|
9375
|
+
const wallabyPublicKey = input.authenticationOptions.signatureMessageResponse.wallabyAuthPubKey ||
|
|
9376
|
+
input.authenticationOptions.user.wallabyAuthPubKey;
|
|
9201
9377
|
const deviceAuthKeyPair = createIdentity();
|
|
9202
9378
|
const credentialsKeyPair = await this.cipher.getCredentialsKeyPair({
|
|
9203
9379
|
authType: this.deviceAuthType,
|
|
@@ -9237,27 +9413,37 @@ class WalletService extends Base {
|
|
|
9237
9413
|
return recoverWithSeedPhraseResponse;
|
|
9238
9414
|
}
|
|
9239
9415
|
else if (input.decryptedShares) {
|
|
9240
|
-
|
|
9241
|
-
const encrypted = await this.cipher.encrypt({
|
|
9242
|
-
data: decryptedShare,
|
|
9243
|
-
encryptionKey: wallabyPublicKey,
|
|
9244
|
-
});
|
|
9245
|
-
return encrypted;
|
|
9246
|
-
}));
|
|
9247
|
-
if (!encryptedShares.length) {
|
|
9416
|
+
if (!input.decryptedShares.length) {
|
|
9248
9417
|
throw new WallabyError({
|
|
9249
9418
|
message: 'Decrypted shares are required',
|
|
9250
9419
|
statusCode: 400,
|
|
9251
9420
|
errorCode: exports.ErrorResponseCodes.sdk_missing_parameter,
|
|
9252
9421
|
});
|
|
9253
9422
|
}
|
|
9254
|
-
const
|
|
9255
|
-
encryptedKeyShares: encryptedShares,
|
|
9423
|
+
const { signature, message, wallabyAuthPubKey: ephemeralWallabyAuthPubKey, } = await this.authService.getSignature({
|
|
9256
9424
|
deviceAuthKeys: deviceAuthKeyPair,
|
|
9257
9425
|
walletId: input.walletId,
|
|
9426
|
+
passkeyChallengeType: exports.PasskeyChallengeType.AUTHENTICATION,
|
|
9427
|
+
});
|
|
9428
|
+
const transportEncryptionKey = ephemeralWallabyAuthPubKey || input.authenticationOptions.user.wallabyAuthPubKey;
|
|
9429
|
+
const encryptedShares = await Promise.all(input.decryptedShares.map(async (decryptedShare) => {
|
|
9430
|
+
return await this.cipher.encrypt({
|
|
9431
|
+
data: decryptedShare,
|
|
9432
|
+
encryptionKey: transportEncryptionKey,
|
|
9433
|
+
});
|
|
9434
|
+
}));
|
|
9435
|
+
const retrieveSeedPhraseResponse = await this.request(WalletRoutes.retrieveSeedPhrase, {
|
|
9436
|
+
payload: {
|
|
9437
|
+
walletId: input.walletId,
|
|
9438
|
+
signature,
|
|
9439
|
+
message,
|
|
9440
|
+
clientAuthPubKey: deviceAuthKeyPair.publicKey,
|
|
9441
|
+
recoveryPubKey: deviceAuthKeyPair.publicKey,
|
|
9442
|
+
encryptedShares,
|
|
9443
|
+
},
|
|
9258
9444
|
});
|
|
9259
9445
|
const wallabyBoundRecoverySeedPhrase = await this.cipher.flipEncryptedData({
|
|
9260
|
-
cipherText: encryptedSeed,
|
|
9446
|
+
cipherText: retrieveSeedPhraseResponse.encryptedSeed,
|
|
9261
9447
|
decryptionKey: deviceAuthKeyPair.privateKey,
|
|
9262
9448
|
encryptionKey: wallabyPublicKey,
|
|
9263
9449
|
});
|
|
@@ -9315,17 +9501,9 @@ class WalletService extends Base {
|
|
|
9315
9501
|
async retrieveShares({ walletId, authenticationOptions, deviceAuthKeys, }) {
|
|
9316
9502
|
try {
|
|
9317
9503
|
const signatureMessage = await this.authService.getSignature({
|
|
9318
|
-
publicKey: deviceAuthKeys.publicKey,
|
|
9319
|
-
|
|
9320
|
-
});
|
|
9321
|
-
// const response = await this.request<RetrieveSharesData>(WalletRoutes.retrieveShares, {
|
|
9322
|
-
// payload: {
|
|
9323
|
-
// walletId,
|
|
9324
|
-
// signature: signatureMessage.signature,
|
|
9325
|
-
// message: signatureMessage.message,
|
|
9326
|
-
// clientAuthPubKey: deviceAuthKeys.publicKey,
|
|
9327
|
-
// },
|
|
9328
|
-
// });
|
|
9504
|
+
deviceAuthKeys: { publicKey: deviceAuthKeys.publicKey, privateKey: deviceAuthKeys.privateKey },
|
|
9505
|
+
walletId,
|
|
9506
|
+
});
|
|
9329
9507
|
const response = await this.api.wallets.retrieveShares({
|
|
9330
9508
|
walletId: walletId,
|
|
9331
9509
|
signature: signatureMessage.signature,
|
|
@@ -9475,109 +9653,23 @@ class WalletService extends Base {
|
|
|
9475
9653
|
*
|
|
9476
9654
|
* @public
|
|
9477
9655
|
* Convert BIP39 Standard seed phrase to Algorand fixed 25 words mnemonic phrase
|
|
9478
|
-
* @param {
|
|
9479
|
-
*
|
|
9480
|
-
* - {string} walletId - The Wallaby wallet ID.
|
|
9481
|
-
* - {AuthenticationResponse} authenticationOptions - The authentication options carried from the authentication request (`signIn` | `signUp`)
|
|
9482
|
-
* @returns {ConvertMnemonicSeedPhraseResponse} The mnemonic seed phrase has been converted successfully.
|
|
9656
|
+
* @param {string} bip39Mnemonic - The decrypted standard seed phrase (bip32 standard 24 words mnemonic) to be transformed.
|
|
9657
|
+
* @returns {string} The Algorand fixed 25 words mnemonic phrase.
|
|
9483
9658
|
*/
|
|
9484
|
-
|
|
9659
|
+
getAlgorandSeedPhrase(bip39Mnemonic) {
|
|
9485
9660
|
try {
|
|
9486
|
-
const
|
|
9487
|
-
const
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
message: 'Device private key could not be found',
|
|
9491
|
-
statusCode: 404,
|
|
9492
|
-
errorCode: exports.ErrorResponseCodes.sdk_private_key_not_found,
|
|
9493
|
-
});
|
|
9494
|
-
const parsedEncryptedDevicePrivateKey = safeJsonParse(storedEncryptedDevicePrivateKey);
|
|
9495
|
-
if (this.deviceAuthType === exports.AuthType.Password && input.authenticationOptions.password) {
|
|
9496
|
-
try {
|
|
9497
|
-
await this.handleUpdateToV2({
|
|
9498
|
-
password: input.authenticationOptions.password,
|
|
9499
|
-
walletId: input.walletId,
|
|
9500
|
-
});
|
|
9501
|
-
}
|
|
9502
|
-
catch (error) {
|
|
9503
|
-
logger.error('SDK::WalletService::getAlgorandSeedPhrase::handleUpdateToV2::error', error);
|
|
9504
|
-
throw new WallabyError({
|
|
9505
|
-
message: 'Error accessing user wallet on this device. Please ensure the password is correct and try again.',
|
|
9506
|
-
statusCode: 500,
|
|
9507
|
-
errorCode: exports.ErrorResponseCodes.sdk_unknown_error,
|
|
9508
|
-
});
|
|
9509
|
-
}
|
|
9510
|
-
}
|
|
9511
|
-
let wallabyBoundSeedPhrase;
|
|
9512
|
-
if (standardSeedPhrase) {
|
|
9513
|
-
const encryptedSeed = await this.cipher.encrypt({
|
|
9514
|
-
data: standardSeedPhrase,
|
|
9515
|
-
encryptionKey: user.wallabyAuthPubKey,
|
|
9516
|
-
});
|
|
9517
|
-
wallabyBoundSeedPhrase = encryptedSeed;
|
|
9518
|
-
}
|
|
9519
|
-
else {
|
|
9520
|
-
const storedEncryptedStandardSeedPhrase = await this.localStorageService.fetch(exports.LocalStorageItems.EncryptedStandardSeedPhrase, {
|
|
9521
|
-
walletId: input.walletId,
|
|
9522
|
-
});
|
|
9523
|
-
if (!storedEncryptedStandardSeedPhrase) {
|
|
9524
|
-
throw new WallabyError({
|
|
9525
|
-
message: 'Device is missing required information, please import your wallet on this device before proceeding.',
|
|
9526
|
-
statusCode: 404,
|
|
9527
|
-
errorCode: exports.ErrorResponseCodes.sdk_seed_phrase_not_found,
|
|
9528
|
-
});
|
|
9529
|
-
}
|
|
9530
|
-
const parsedEncryptedStandardSeedPhrase = safeJsonParse(storedEncryptedStandardSeedPhrase);
|
|
9531
|
-
wallabyBoundSeedPhrase = await this.cipher.prepareStoredDataForTransport({
|
|
9532
|
-
storedEncryptedData: parsedEncryptedStandardSeedPhrase,
|
|
9533
|
-
encryptedDevicePrivateKey: parsedEncryptedDevicePrivateKey,
|
|
9534
|
-
wallabyPublicKey: user.wallabyAuthPubKey,
|
|
9535
|
-
options: {
|
|
9536
|
-
authType: this.deviceAuthType,
|
|
9537
|
-
password,
|
|
9538
|
-
prfValue,
|
|
9539
|
-
salt: clientSalt,
|
|
9540
|
-
},
|
|
9541
|
-
});
|
|
9542
|
-
}
|
|
9543
|
-
const credentialsKeyPair = await this.cipher.getCredentialsKeyPair({
|
|
9544
|
-
authType: this.deviceAuthType,
|
|
9545
|
-
password,
|
|
9546
|
-
salt: clientSalt,
|
|
9547
|
-
prfValue,
|
|
9548
|
-
});
|
|
9549
|
-
const decryptedDevicePrivateKey = await this.cipher.decrypt({
|
|
9550
|
-
cipherText: parsedEncryptedDevicePrivateKey,
|
|
9551
|
-
decryptionKey: credentialsKeyPair.privateKey,
|
|
9552
|
-
});
|
|
9553
|
-
if (!decryptedDevicePrivateKey) {
|
|
9554
|
-
throw new WallabyError({
|
|
9555
|
-
message: 'Failed to decrypt device private key',
|
|
9556
|
-
statusCode: 500,
|
|
9557
|
-
errorCode: exports.ErrorResponseCodes.sdk_private_key_decryption_failed,
|
|
9558
|
-
});
|
|
9559
|
-
}
|
|
9560
|
-
const clientAuthPubKey = publicKeyByPrivateKey(decryptedDevicePrivateKey);
|
|
9561
|
-
const reference = uuid.v4();
|
|
9562
|
-
const signatureMessage = await this.authService.getSignature({
|
|
9563
|
-
publicKey: clientAuthPubKey,
|
|
9564
|
-
privateKey: decryptedDevicePrivateKey,
|
|
9565
|
-
});
|
|
9566
|
-
const { message, signature } = signatureMessage;
|
|
9567
|
-
const response = await this.request(WalletRoutes.convertMnemonicSeedPhrase, {
|
|
9568
|
-
payload: {
|
|
9569
|
-
reference,
|
|
9570
|
-
signature,
|
|
9571
|
-
message,
|
|
9572
|
-
clientAuthPubKey,
|
|
9573
|
-
encryptedSeed: wallabyBoundSeedPhrase,
|
|
9574
|
-
},
|
|
9575
|
-
});
|
|
9576
|
-
return response;
|
|
9661
|
+
const seedBuffer = bip39__namespace.mnemonicToSeedSync(bip39Mnemonic);
|
|
9662
|
+
const seed = seedBuffer.slice(0, 32);
|
|
9663
|
+
const convertedSeedPhrase = algosdk__namespace.mnemonicFromSeed(seed);
|
|
9664
|
+
return convertedSeedPhrase;
|
|
9577
9665
|
}
|
|
9578
9666
|
catch (error) {
|
|
9579
9667
|
logger.error('SDK::Wallet::getAlgorandSeedPhrase::error', error);
|
|
9580
|
-
throw
|
|
9668
|
+
throw new WallabyError({
|
|
9669
|
+
message: error instanceof Error ? error.message : 'Failed to convert seed phrase to Algorand mnemonic.',
|
|
9670
|
+
statusCode: 500,
|
|
9671
|
+
errorCode: exports.ErrorResponseCodes.sdk_unknown_error,
|
|
9672
|
+
});
|
|
9581
9673
|
}
|
|
9582
9674
|
}
|
|
9583
9675
|
/**
|
|
@@ -9592,6 +9684,7 @@ class WalletService extends Base {
|
|
|
9592
9684
|
*/
|
|
9593
9685
|
async initAddNewDevice(input) {
|
|
9594
9686
|
const { walletId, backupUrl, authenticationOptions } = input;
|
|
9687
|
+
const wallabyPublicKey = authenticationOptions.signatureMessageResponse.wallabyAuthPubKey || authenticationOptions.user.wallabyAuthPubKey;
|
|
9595
9688
|
const encryptedDevicePrivateKey = await this.localStorageService.fetch(exports.LocalStorageItems.EncryptedDevicePrivateKey);
|
|
9596
9689
|
if (!encryptedDevicePrivateKey) {
|
|
9597
9690
|
throw new WallabyError({
|
|
@@ -9652,7 +9745,7 @@ class WalletService extends Base {
|
|
|
9652
9745
|
const wallabyBoundPrimaryShare = await this.cipher.prepareStoredDataForTransport({
|
|
9653
9746
|
storedEncryptedData: parsedPrimaryShare,
|
|
9654
9747
|
encryptedDevicePrivateKey: parsedEncryptedDevicePrivateKey,
|
|
9655
|
-
wallabyPublicKey
|
|
9748
|
+
wallabyPublicKey,
|
|
9656
9749
|
options: {
|
|
9657
9750
|
authType: this.deviceAuthType,
|
|
9658
9751
|
password: authenticationOptions.password,
|
|
@@ -9711,22 +9804,11 @@ class WalletService extends Base {
|
|
|
9711
9804
|
}
|
|
9712
9805
|
const devicePublicKey = (_a = (await this.localStorageService.fetch(exports.LocalStorageItems.ClientAuthPublicKey))) !== null && _a !== void 0 ? _a : publicKeyByPrivateKey(decryptedDevicePrivateKey);
|
|
9713
9806
|
const signatureMessage = await this.authService.getSignature({
|
|
9714
|
-
publicKey: devicePublicKey,
|
|
9715
|
-
|
|
9716
|
-
|
|
9717
|
-
|
|
9718
|
-
|
|
9719
|
-
// walletId: input.walletId,
|
|
9720
|
-
// message: signatureMessage.message,
|
|
9721
|
-
// signature: signatureMessage.signature,
|
|
9722
|
-
// clientAuthPubKey: devicePublicKey,
|
|
9723
|
-
// share: {
|
|
9724
|
-
// encrypted: input.encryptedShares[DEFAULT_BACKUP_SHARE_INDEX], // we only want to send the backup share to be rewrapped
|
|
9725
|
-
// wrappingPublicKey: input.authenticationOptions.user.wallabyAuthPubKey,
|
|
9726
|
-
// type: KeyTypeName.OwnerBackupDeviceShare,
|
|
9727
|
-
// },
|
|
9728
|
-
// },
|
|
9729
|
-
// });
|
|
9807
|
+
deviceAuthKeys: { publicKey: devicePublicKey, privateKey: decryptedDevicePrivateKey },
|
|
9808
|
+
walletId: input.walletId,
|
|
9809
|
+
passkeyChallengeType: exports.PasskeyChallengeType.REGISTRATION,
|
|
9810
|
+
});
|
|
9811
|
+
const wallabyPublicKey = signatureMessage.wallabyAuthPubKey || input.authenticationOptions.user.wallabyAuthPubKey;
|
|
9730
9812
|
const backUpResponse = await this.api.wallets.addNewDevice({
|
|
9731
9813
|
walletId: input.walletId,
|
|
9732
9814
|
message: signatureMessage.message,
|
|
@@ -9734,7 +9816,7 @@ class WalletService extends Base {
|
|
|
9734
9816
|
clientAuthPubKey: devicePublicKey,
|
|
9735
9817
|
share: {
|
|
9736
9818
|
encrypted: input.encryptedShares[DEFAULT_BACKUP_SHARE_INDEX], // we only want to send the backup share to be rewrapped
|
|
9737
|
-
wrappingPublicKey:
|
|
9819
|
+
wrappingPublicKey: wallabyPublicKey,
|
|
9738
9820
|
type: exports.KeyTypeName.OwnerBackupDeviceShare,
|
|
9739
9821
|
},
|
|
9740
9822
|
});
|
|
@@ -9742,7 +9824,8 @@ class WalletService extends Base {
|
|
|
9742
9824
|
backUpResponse.share, // this is the backup share that is now rewrapped with the new device public key.
|
|
9743
9825
|
{
|
|
9744
9826
|
encrypted: input.encryptedShares[DEFAULT_PRIMARY_SHARE_INDEX],
|
|
9745
|
-
wrappingPublicKey: input.authenticationOptions.
|
|
9827
|
+
wrappingPublicKey: input.authenticationOptions.signatureMessageResponse.wallabyAuthPubKey ||
|
|
9828
|
+
input.authenticationOptions.user.wallabyAuthPubKey, // this is the primary share still wrapped from the QR code.
|
|
9746
9829
|
type: exports.KeyTypeName.OwnerMainDeviceShare,
|
|
9747
9830
|
},
|
|
9748
9831
|
];
|
|
@@ -9799,12 +9882,28 @@ class WalletService extends Base {
|
|
|
9799
9882
|
});
|
|
9800
9883
|
}
|
|
9801
9884
|
const parsedDevicePrivateKey = safeJsonParse(devicePrivateKey);
|
|
9885
|
+
const derivedCredentialsKeyPair = await this.cipher.getCredentialsKeyPair({
|
|
9886
|
+
authType: this.deviceAuthType,
|
|
9887
|
+
password: input.authenticationOptions.password,
|
|
9888
|
+
salt: input.authenticationOptions.clientSalt,
|
|
9889
|
+
prfValue: input.authenticationOptions.prfValue,
|
|
9890
|
+
});
|
|
9891
|
+
const decryptedDevicePrivateKey = await this.cipher.decrypt({
|
|
9892
|
+
cipherText: parsedDevicePrivateKey,
|
|
9893
|
+
decryptionKey: derivedCredentialsKeyPair.privateKey,
|
|
9894
|
+
});
|
|
9895
|
+
const devicePublicKey = publicKeyByPrivateKey(decryptedDevicePrivateKey);
|
|
9896
|
+
const { signature, message, wallabyAuthPubKey: ephemeralWallabyAuthPubKey, } = await this.authService.getSignature({
|
|
9897
|
+
deviceAuthKeys: { privateKey: decryptedDevicePrivateKey, publicKey: devicePublicKey },
|
|
9898
|
+
walletId,
|
|
9899
|
+
});
|
|
9900
|
+
const wallabyPublicKey = ephemeralWallabyAuthPubKey || input.authenticationOptions.user.wallabyAuthPubKey;
|
|
9802
9901
|
if (storedSeedPhrase) {
|
|
9803
9902
|
const parsedStoredSeedPhrase = safeJsonParse(storedSeedPhrase);
|
|
9804
9903
|
transportSeed = await this.cipher.prepareStoredDataForTransport({
|
|
9805
9904
|
storedEncryptedData: parsedStoredSeedPhrase,
|
|
9806
9905
|
encryptedDevicePrivateKey: parsedDevicePrivateKey,
|
|
9807
|
-
wallabyPublicKey
|
|
9906
|
+
wallabyPublicKey,
|
|
9808
9907
|
options: {
|
|
9809
9908
|
authType: this.deviceAuthType,
|
|
9810
9909
|
password: input.authenticationOptions.password,
|
|
@@ -9818,7 +9917,7 @@ class WalletService extends Base {
|
|
|
9818
9917
|
transportKeyShare = await this.cipher.prepareStoredDataForTransport({
|
|
9819
9918
|
storedEncryptedData: parsedPrimaryKeyShare,
|
|
9820
9919
|
encryptedDevicePrivateKey: parsedDevicePrivateKey,
|
|
9821
|
-
wallabyPublicKey
|
|
9920
|
+
wallabyPublicKey,
|
|
9822
9921
|
options: {
|
|
9823
9922
|
authType: this.deviceAuthType,
|
|
9824
9923
|
password: input.authenticationOptions.password,
|
|
@@ -9834,21 +9933,6 @@ class WalletService extends Base {
|
|
|
9834
9933
|
errorCode: 'sdk_private_key_not_found',
|
|
9835
9934
|
});
|
|
9836
9935
|
}
|
|
9837
|
-
const derivedCredentialsKeyPair = await this.cipher.getCredentialsKeyPair({
|
|
9838
|
-
authType: this.deviceAuthType,
|
|
9839
|
-
password: input.authenticationOptions.password,
|
|
9840
|
-
salt: input.authenticationOptions.clientSalt,
|
|
9841
|
-
prfValue: input.authenticationOptions.prfValue,
|
|
9842
|
-
});
|
|
9843
|
-
const decryptedDevicePrivateKey = await this.cipher.decrypt({
|
|
9844
|
-
cipherText: parsedDevicePrivateKey,
|
|
9845
|
-
decryptionKey: derivedCredentialsKeyPair.privateKey,
|
|
9846
|
-
});
|
|
9847
|
-
const devicePublicKey = publicKeyByPrivateKey(decryptedDevicePrivateKey);
|
|
9848
|
-
const { signature, message } = await this.authService.getSignature({
|
|
9849
|
-
privateKey: decryptedDevicePrivateKey,
|
|
9850
|
-
publicKey: devicePublicKey,
|
|
9851
|
-
});
|
|
9852
9936
|
const response = await this.request(WalletRoutes.generateWalletAddresses, {
|
|
9853
9937
|
payload: {
|
|
9854
9938
|
walletId,
|
|
@@ -10040,8 +10124,8 @@ class WalletService extends Base {
|
|
|
10040
10124
|
// During migration, we need to authenticate but avoid creating conflicting device keypairs
|
|
10041
10125
|
const devicePublicKey = publicKeyByPrivateKey(decryptedPrivateKey);
|
|
10042
10126
|
const signInSignatureMessage = await this.authService.getSignature({
|
|
10043
|
-
publicKey: devicePublicKey,
|
|
10044
|
-
|
|
10127
|
+
deviceAuthKeys: { publicKey: devicePublicKey, privateKey: decryptedPrivateKey },
|
|
10128
|
+
walletId,
|
|
10045
10129
|
});
|
|
10046
10130
|
// this would ensure the stored public key is consistent with wallaby and can authenticate the user.
|
|
10047
10131
|
const authResponse = await this.request(AuthRoutes.signIn, {
|
|
@@ -10067,7 +10151,6 @@ class WalletService extends Base {
|
|
|
10067
10151
|
// Store authentication tokens
|
|
10068
10152
|
await this.localStorageService.saveInBulk([
|
|
10069
10153
|
{ key: exports.LocalStorageItems.AccessToken, value: authResponse.accessToken },
|
|
10070
|
-
{ key: exports.LocalStorageItems.WallabyAuthPubKey, value: authResponse.user.wallabyAuthPubKey },
|
|
10071
10154
|
{ key: exports.V2KeyNames.EncryptedStandardSeedPhrase, value: encryptedV2Seed, walletId },
|
|
10072
10155
|
{ key: exports.V2KeyNames.EncryptedDevicePrivateKey, value: encryptedV2PrivateKey },
|
|
10073
10156
|
]);
|
|
@@ -10168,9 +10251,11 @@ class WalletService extends Base {
|
|
|
10168
10251
|
const deviceAuthPublicKey = publicKeyByPrivateKey(decryptedDevicePrivateKey);
|
|
10169
10252
|
// Get signature message
|
|
10170
10253
|
const signatureMessage = await this.authService.getSignature({
|
|
10171
|
-
publicKey: deviceAuthPublicKey,
|
|
10172
|
-
|
|
10173
|
-
|
|
10254
|
+
deviceAuthKeys: { publicKey: deviceAuthPublicKey, privateKey: decryptedDevicePrivateKey },
|
|
10255
|
+
walletId,
|
|
10256
|
+
passkeyChallengeType: exports.PasskeyChallengeType.AUTHENTICATION,
|
|
10257
|
+
});
|
|
10258
|
+
const wallabyPublicKey = signatureMessage.wallabyAuthPubKey || authenticationOptions.user.wallabyAuthPubKey;
|
|
10174
10259
|
// Prepare encrypted data (seed phrase or key shares)
|
|
10175
10260
|
const sharesEncryptedWithWallabyPubKey = [];
|
|
10176
10261
|
let readyForTransportSeedPhrase = undefined;
|
|
@@ -10190,7 +10275,7 @@ class WalletService extends Base {
|
|
|
10190
10275
|
readyForTransportSeedPhrase = await this.cipher.prepareStoredDataForTransport({
|
|
10191
10276
|
storedEncryptedData: parsedSeedPhrase,
|
|
10192
10277
|
encryptedDevicePrivateKey: JSON.parse(encryptedDevicePrivateKey),
|
|
10193
|
-
wallabyPublicKey
|
|
10278
|
+
wallabyPublicKey,
|
|
10194
10279
|
options: {
|
|
10195
10280
|
authType: this.deviceAuthType,
|
|
10196
10281
|
password,
|
|
@@ -10205,7 +10290,7 @@ class WalletService extends Base {
|
|
|
10205
10290
|
const readyForTransportShare = await this.cipher.prepareStoredDataForTransport({
|
|
10206
10291
|
storedEncryptedData: parsedPrimaryShare,
|
|
10207
10292
|
encryptedDevicePrivateKey: JSON.parse(encryptedDevicePrivateKey),
|
|
10208
|
-
wallabyPublicKey
|
|
10293
|
+
wallabyPublicKey,
|
|
10209
10294
|
options: {
|
|
10210
10295
|
authType: this.deviceAuthType,
|
|
10211
10296
|
password,
|
|
@@ -10374,6 +10459,7 @@ class WalletService extends Base {
|
|
|
10374
10459
|
seedPhrase: decryptedSeedPhrase,
|
|
10375
10460
|
storeSeedPhrase: false,
|
|
10376
10461
|
returnWalletOption: exports.ReturnWalletOption.ReturnOnlyEncryptedShares, // always only return the encrypted shares
|
|
10462
|
+
walletId: input.walletId,
|
|
10377
10463
|
keyShareOptions: {
|
|
10378
10464
|
threshold: 2,
|
|
10379
10465
|
numberOfKeyShares: 3,
|
|
@@ -10424,20 +10510,31 @@ class WalletService extends Base {
|
|
|
10424
10510
|
logger.info('SDK::WalletService::convertToPasskey::Seed phrase removed from device storage after conversion to passkey');
|
|
10425
10511
|
}
|
|
10426
10512
|
if (!decryptedSeedPhrase && decryptedPrimaryShare) {
|
|
10513
|
+
const deviceAuthKeys = {
|
|
10514
|
+
publicKey: clientPublicKey,
|
|
10515
|
+
privateKey: decryptedClientAuthPrivKey,
|
|
10516
|
+
};
|
|
10517
|
+
const { signature, message, wallabyAuthPubKey: ephemeralWallabyAuthPubKey, } = await this.authService.getSignature({
|
|
10518
|
+
deviceAuthKeys,
|
|
10519
|
+
walletId: input.walletId,
|
|
10520
|
+
passkeyChallengeType: exports.PasskeyChallengeType.AUTHENTICATION,
|
|
10521
|
+
});
|
|
10427
10522
|
const flippedEncryptedPrimaryShare = await this.cipher.encrypt({
|
|
10428
10523
|
data: decryptedPrimaryShare,
|
|
10429
|
-
encryptionKey: authentication.user.wallabyAuthPubKey,
|
|
10524
|
+
encryptionKey: ephemeralWallabyAuthPubKey || authentication.user.wallabyAuthPubKey,
|
|
10430
10525
|
});
|
|
10431
|
-
const
|
|
10432
|
-
|
|
10433
|
-
|
|
10434
|
-
|
|
10435
|
-
|
|
10436
|
-
|
|
10526
|
+
const retrieveSeedPhraseResponse = await this.request(WalletRoutes.retrieveSeedPhrase, {
|
|
10527
|
+
payload: {
|
|
10528
|
+
walletId: input.walletId,
|
|
10529
|
+
signature,
|
|
10530
|
+
message,
|
|
10531
|
+
clientAuthPubKey: deviceAuthKeys.publicKey,
|
|
10532
|
+
recoveryPubKey: deviceAuthKeys.publicKey,
|
|
10533
|
+
encryptedShares: [flippedEncryptedPrimaryShare],
|
|
10437
10534
|
},
|
|
10438
10535
|
});
|
|
10439
10536
|
decryptedSeedPhrase = await this.cipher.decrypt({
|
|
10440
|
-
cipherText:
|
|
10537
|
+
cipherText: retrieveSeedPhraseResponse.encryptedSeed,
|
|
10441
10538
|
decryptionKey: decryptedClientAuthPrivKey,
|
|
10442
10539
|
});
|
|
10443
10540
|
}
|
|
@@ -10544,7 +10641,7 @@ class WalletDataService extends Base {
|
|
|
10544
10641
|
* Note: Either chainName or tokenStandard must be provided.
|
|
10545
10642
|
* @returns { FetchBalanceData } Returns an array of the requested tokens balances.
|
|
10546
10643
|
*/
|
|
10547
|
-
async getMultiTokenBalances({ walletId, tokensAndAddressesList }) {
|
|
10644
|
+
async getMultiTokenBalances({ walletId, tokensAndAddressesList, }) {
|
|
10548
10645
|
try {
|
|
10549
10646
|
if (!tokensAndAddressesList.length) {
|
|
10550
10647
|
throw new WallabyError({
|
|
@@ -11196,11 +11293,10 @@ class Swap extends Base {
|
|
|
11196
11293
|
}
|
|
11197
11294
|
const { deviceAuthPublicKey, signatureMessage, readyForTransportSeedPhrase, sharesEncryptedWithWallabyPubKey, hasShares } = await this.prepareSwapAuth(authenticationOptions, walletId);
|
|
11198
11295
|
let swapResponse;
|
|
11199
|
-
// Build path with walletId, but exclude it from request body
|
|
11200
|
-
const routePayload = { walletId };
|
|
11201
11296
|
if (readyForTransportSeedPhrase) {
|
|
11202
|
-
swapResponse = await this.request(Object.assign(Object.assign({}, SwapRoutes.executeSwap), { fullPath: SwapRoutes.executeSwap.fullPath
|
|
11297
|
+
swapResponse = await this.request(Object.assign(Object.assign({}, SwapRoutes.executeSwap), { fullPath: SwapRoutes.executeSwap.fullPath }), {
|
|
11203
11298
|
payload: {
|
|
11299
|
+
walletId,
|
|
11204
11300
|
quoteId,
|
|
11205
11301
|
message: signatureMessage.message,
|
|
11206
11302
|
signature: signatureMessage.signature,
|
|
@@ -11210,8 +11306,9 @@ class Swap extends Base {
|
|
|
11210
11306
|
});
|
|
11211
11307
|
}
|
|
11212
11308
|
else if (hasShares) {
|
|
11213
|
-
swapResponse = await this.request(Object.assign(Object.assign({}, SwapRoutes.executeSwap), { fullPath: SwapRoutes.executeSwap.fullPath
|
|
11309
|
+
swapResponse = await this.request(Object.assign(Object.assign({}, SwapRoutes.executeSwap), { fullPath: SwapRoutes.executeSwap.fullPath }), {
|
|
11214
11310
|
payload: {
|
|
11311
|
+
walletId,
|
|
11215
11312
|
quoteId,
|
|
11216
11313
|
message: signatureMessage.message,
|
|
11217
11314
|
signature: signatureMessage.signature,
|
|
@@ -11301,9 +11398,11 @@ class Swap extends Base {
|
|
|
11301
11398
|
const deviceAuthPublicKey = publicKeyByPrivateKey(decryptedDevicePrivateKey);
|
|
11302
11399
|
// Get signature message
|
|
11303
11400
|
const signatureMessage = await this.authService.getSignature({
|
|
11304
|
-
publicKey: deviceAuthPublicKey,
|
|
11305
|
-
|
|
11306
|
-
|
|
11401
|
+
deviceAuthKeys: { publicKey: deviceAuthPublicKey, privateKey: decryptedDevicePrivateKey },
|
|
11402
|
+
passkeyChallengeType: this.deviceAuthType === exports.AuthType.Passkey ? exports.PasskeyChallengeType.AUTHENTICATION : undefined,
|
|
11403
|
+
walletId,
|
|
11404
|
+
});
|
|
11405
|
+
const wallabyPublicKey = signatureMessage.wallabyAuthPubKey || authenticationOptions.user.wallabyAuthPubKey;
|
|
11307
11406
|
// Prepare encrypted data (seed phrase or key shares)
|
|
11308
11407
|
const sharesEncryptedWithWallabyPubKey = [];
|
|
11309
11408
|
let readyForTransportSeedPhrase = undefined;
|
|
@@ -11324,7 +11423,7 @@ class Swap extends Base {
|
|
|
11324
11423
|
readyForTransportSeedPhrase = await this.cipher.prepareStoredDataForTransport({
|
|
11325
11424
|
storedEncryptedData: parsedSeedPhrase,
|
|
11326
11425
|
encryptedDevicePrivateKey: JSON.parse(encryptedDevicePrivateKey),
|
|
11327
|
-
wallabyPublicKey
|
|
11426
|
+
wallabyPublicKey,
|
|
11328
11427
|
options: {
|
|
11329
11428
|
authType: this.deviceAuthType,
|
|
11330
11429
|
password,
|
|
@@ -11339,7 +11438,7 @@ class Swap extends Base {
|
|
|
11339
11438
|
const readyForTransportShare = await this.cipher.prepareStoredDataForTransport({
|
|
11340
11439
|
storedEncryptedData: parsedPrimaryShare,
|
|
11341
11440
|
encryptedDevicePrivateKey: JSON.parse(encryptedDevicePrivateKey),
|
|
11342
|
-
wallabyPublicKey
|
|
11441
|
+
wallabyPublicKey,
|
|
11343
11442
|
options: {
|
|
11344
11443
|
authType: this.deviceAuthType,
|
|
11345
11444
|
password,
|
|
@@ -11594,7 +11693,7 @@ class Transactions extends Base {
|
|
|
11594
11693
|
* @param {BlockchainName} blockchain
|
|
11595
11694
|
* @returns {FeeEstimateRequest}
|
|
11596
11695
|
*/
|
|
11597
|
-
async estimateFee({ originAddress, recipientAddress, amount,
|
|
11696
|
+
async estimateFee({ originAddress, recipientAddress, amount, transactionType, token, }) {
|
|
11598
11697
|
try {
|
|
11599
11698
|
const response = await this.request(TransactionsRoutes.estimateFee, {
|
|
11600
11699
|
queryParams: {
|
|
@@ -11699,6 +11798,7 @@ class Transactions extends Base {
|
|
|
11699
11798
|
if (readyForTransportSeedPhrase) {
|
|
11700
11799
|
transferResponse = await this.request(TransactionsRoutes.transfer, {
|
|
11701
11800
|
payload: {
|
|
11801
|
+
walletId,
|
|
11702
11802
|
message: signatureMessage.message,
|
|
11703
11803
|
signature: signatureMessage.signature,
|
|
11704
11804
|
clientAuthPubKey: deviceAuthPublicKey,
|
|
@@ -11716,6 +11816,7 @@ class Transactions extends Base {
|
|
|
11716
11816
|
else if (hasShares) {
|
|
11717
11817
|
transferResponse = await this.request(TransactionsRoutes.transferWithShares, {
|
|
11718
11818
|
payload: {
|
|
11819
|
+
walletId,
|
|
11719
11820
|
message: signatureMessage.message,
|
|
11720
11821
|
signature: signatureMessage.signature,
|
|
11721
11822
|
clientAuthPubKey: deviceAuthPublicKey,
|
|
@@ -11935,9 +12036,11 @@ class Transactions extends Base {
|
|
|
11935
12036
|
const deviceAuthPublicKey = publicKeyByPrivateKey(decryptedDevicePrivateKey);
|
|
11936
12037
|
// Get signature message
|
|
11937
12038
|
const signatureMessage = await this.authService.getSignature({
|
|
11938
|
-
publicKey: deviceAuthPublicKey,
|
|
11939
|
-
|
|
11940
|
-
|
|
12039
|
+
deviceAuthKeys: { publicKey: deviceAuthPublicKey, privateKey: decryptedDevicePrivateKey },
|
|
12040
|
+
walletId,
|
|
12041
|
+
passkeyChallengeType: this.deviceAuthType === exports.AuthType.Passkey ? exports.PasskeyChallengeType.AUTHENTICATION : undefined,
|
|
12042
|
+
});
|
|
12043
|
+
const wallabyPublicKey = signatureMessage.wallabyAuthPubKey || authenticationOptions.user.wallabyAuthPubKey;
|
|
11941
12044
|
// Prepare encrypted data (seed phrase or key shares)
|
|
11942
12045
|
const sharesEncryptedWithWallabyPubKey = [];
|
|
11943
12046
|
let readyForTransportSeedPhrase = undefined;
|
|
@@ -11958,7 +12061,7 @@ class Transactions extends Base {
|
|
|
11958
12061
|
readyForTransportSeedPhrase = await this.cipher.prepareStoredDataForTransport({
|
|
11959
12062
|
storedEncryptedData: parsedSeedPhrase,
|
|
11960
12063
|
encryptedDevicePrivateKey: JSON.parse(encryptedDevicePrivateKey),
|
|
11961
|
-
wallabyPublicKey
|
|
12064
|
+
wallabyPublicKey,
|
|
11962
12065
|
options: {
|
|
11963
12066
|
authType: this.deviceAuthType,
|
|
11964
12067
|
password,
|
|
@@ -11973,7 +12076,7 @@ class Transactions extends Base {
|
|
|
11973
12076
|
const readyForTransportShare = await this.cipher.prepareStoredDataForTransport({
|
|
11974
12077
|
storedEncryptedData: parsedPrimaryShare,
|
|
11975
12078
|
encryptedDevicePrivateKey: JSON.parse(encryptedDevicePrivateKey),
|
|
11976
|
-
wallabyPublicKey
|
|
12079
|
+
wallabyPublicKey,
|
|
11977
12080
|
options: {
|
|
11978
12081
|
authType: this.deviceAuthType,
|
|
11979
12082
|
password,
|
|
@@ -12062,6 +12165,7 @@ exports.InvalidUserIdError = InvalidUserIdError;
|
|
|
12062
12165
|
exports.InvalidUserIdLengthError = InvalidUserIdLengthError;
|
|
12063
12166
|
exports.MalformedPubKeyCredParamsError = MalformedPubKeyCredParamsError;
|
|
12064
12167
|
exports.NativeError = NativeError;
|
|
12168
|
+
exports.NetworkDiagnostic = NetworkDiagnostic;
|
|
12065
12169
|
exports.NoCredentialsError = NoCredentialsError;
|
|
12066
12170
|
exports.NotAllowedError = NotAllowedError;
|
|
12067
12171
|
exports.PasskeyErrorCodes = PasskeyErrorCodes;
|