wallaby-cash 2.2.1-alpha.2 → 2.2.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/dist/index.cjs.js +137 -71
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +137 -71
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +137 -71
- package/dist/index.js.map +1 -1
- package/dist/lib/transactions/index.d.ts +22 -2
- package/dist/lib/wallet/wallet.service.d.ts +1 -1
- package/dist/package.json +2 -1
- package/dist/routes/transactions.d.ts +10 -0
- package/dist/types/auth.d.ts +1 -1
- package/dist/types/common.d.ts +1 -4
- package/dist/types/transactions.d.ts +38 -5
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -88,18 +88,10 @@ class WallabyError extends Error {
|
|
|
88
88
|
this.cause = cause;
|
|
89
89
|
this.onError = onError;
|
|
90
90
|
this.data = data;
|
|
91
|
-
if (onError) {
|
|
92
|
-
onError();
|
|
93
|
-
}
|
|
94
91
|
Error.captureStackTrace(this, WallabyError);
|
|
95
92
|
}
|
|
96
|
-
static isWallabyError(
|
|
97
|
-
return
|
|
98
|
-
typeof obj === 'object' &&
|
|
99
|
-
'statusCode' in obj &&
|
|
100
|
-
'message' in obj &&
|
|
101
|
-
typeof obj.statusCode === 'number' &&
|
|
102
|
-
(obj.statusCode >= 400 || 'error' in obj));
|
|
93
|
+
static isWallabyError(error) {
|
|
94
|
+
return error instanceof WallabyError;
|
|
103
95
|
}
|
|
104
96
|
}
|
|
105
97
|
var UserAssetSource;
|
|
@@ -7174,7 +7166,7 @@ class Base {
|
|
|
7174
7166
|
}
|
|
7175
7167
|
catch (error) {
|
|
7176
7168
|
if (error === null || error === void 0 ? void 0 : error.error) {
|
|
7177
|
-
|
|
7169
|
+
logger.error('SDK::Base::handleApiCall::API Error', { error });
|
|
7178
7170
|
const apiError = error.error;
|
|
7179
7171
|
throw new WallabyError({
|
|
7180
7172
|
message: apiError.message || 'API request failed',
|
|
@@ -7468,6 +7460,16 @@ const TransactionsRoutes = {
|
|
|
7468
7460
|
method: RequestMethod.Get,
|
|
7469
7461
|
requiresAccessToken: true,
|
|
7470
7462
|
},
|
|
7463
|
+
getPendingTransactions: {
|
|
7464
|
+
fullPath: '/transactions/pending',
|
|
7465
|
+
method: RequestMethod.Get,
|
|
7466
|
+
requiresAccessToken: true,
|
|
7467
|
+
},
|
|
7468
|
+
confirmPendingTransaction: {
|
|
7469
|
+
fullPath: '/transactions/resolve',
|
|
7470
|
+
method: RequestMethod.Post,
|
|
7471
|
+
requiresAccessToken: true,
|
|
7472
|
+
},
|
|
7471
7473
|
};
|
|
7472
7474
|
|
|
7473
7475
|
/* eslint-disable no-useless-catch */
|
|
@@ -7578,7 +7580,7 @@ class PasskeyService {
|
|
|
7578
7580
|
first: prfExtensionEvaluation,
|
|
7579
7581
|
},
|
|
7580
7582
|
} }) });
|
|
7581
|
-
|
|
7583
|
+
logger.log('SDK::PasskeyService::preparePasskeyRequestOptions::parsedOptions', !!parsedOptions);
|
|
7582
7584
|
// While the authenticator still works with the prf and would return the response (if any),
|
|
7583
7585
|
// the library `@simplewebauthn/browser` does not support the prf extension in its type intentionally.
|
|
7584
7586
|
// > "Using the prf extension does not fall under the simple use of webauthn."
|
|
@@ -7598,7 +7600,7 @@ class PasskeyService {
|
|
|
7598
7600
|
first: prfExtensionEvaluation,
|
|
7599
7601
|
},
|
|
7600
7602
|
} }) });
|
|
7601
|
-
|
|
7603
|
+
logger.log('SDK::PasskeyService::preparePasskeyRequestOptions::parsedOptions', !!parsedOptions);
|
|
7602
7604
|
return parsedOptions;
|
|
7603
7605
|
}
|
|
7604
7606
|
/**
|
|
@@ -7609,7 +7611,7 @@ class PasskeyService {
|
|
|
7609
7611
|
*/
|
|
7610
7612
|
async addNewPasskey({ deviceKeyPair, getSignature, }) {
|
|
7611
7613
|
try {
|
|
7612
|
-
|
|
7614
|
+
logger.log('SDK::PasskeyService::addNewPasskey: start adding new passkey');
|
|
7613
7615
|
let passkeyCredential;
|
|
7614
7616
|
let signInResponse;
|
|
7615
7617
|
try {
|
|
@@ -7621,14 +7623,14 @@ class PasskeyService {
|
|
|
7621
7623
|
errorCode: ErrorResponseCodes.sdk_passkey_challenge_unavailable,
|
|
7622
7624
|
});
|
|
7623
7625
|
const parsedOptions = this.preparePasskeyCreationOptions(registrationChallengeResponse.registrationOptions);
|
|
7624
|
-
|
|
7626
|
+
logger.log('SDK::PasskeyService::addNewPasskey: about to register passkey credential');
|
|
7625
7627
|
passkeyCredential = await this.authenticator.register({
|
|
7626
7628
|
optionsJSON: parsedOptions,
|
|
7627
7629
|
});
|
|
7628
|
-
|
|
7630
|
+
logger.log('SDK::PasskeyService::addNewPasskey: finished registering passkey credential');
|
|
7629
7631
|
// before we sign the user in, we need to make sure the prf extension is enabled and we have a value.
|
|
7630
7632
|
const credentialsKeyPair = await this.handleCredentialsCreationFromPrfExtension(passkeyCredential);
|
|
7631
|
-
|
|
7633
|
+
logger.log('SDK::PasskeyService::addNewPasskey:: finished deriving credentials key pair', credentialsKeyPair.publicKey);
|
|
7632
7634
|
signInResponse = await this.request(AuthRoutes.signIn, {
|
|
7633
7635
|
payload: {
|
|
7634
7636
|
externalUserId: this.userId,
|
|
@@ -7638,7 +7640,7 @@ class PasskeyService {
|
|
|
7638
7640
|
passkeyRegistrationResponse: passkeyCredential,
|
|
7639
7641
|
},
|
|
7640
7642
|
});
|
|
7641
|
-
|
|
7643
|
+
logger.log('SDK::PasskeyService::addNewPasskey:: signInResponse', signInResponse);
|
|
7642
7644
|
const encryptedNewDevicePrivateKey = await this.cipher.encrypt({
|
|
7643
7645
|
data: deviceKeyPair.privateKey,
|
|
7644
7646
|
encryptionKey: credentialsKeyPair.publicKey,
|
|
@@ -7664,11 +7666,11 @@ class PasskeyService {
|
|
|
7664
7666
|
errorCode: ErrorResponseCodes.sdk_passkey_challenge_unavailable,
|
|
7665
7667
|
});
|
|
7666
7668
|
const parsedOptions = this.preparePasskeyRequestOptions(authenticationChallengeResponse.authenticationOptions);
|
|
7667
|
-
|
|
7669
|
+
logger.log('SDK::PasskeyService::addNewPasskey::catch: about to authenticate with passkey');
|
|
7668
7670
|
passkeyCredential = await this.authenticator.authenticate({
|
|
7669
7671
|
optionsJSON: parsedOptions,
|
|
7670
7672
|
});
|
|
7671
|
-
|
|
7673
|
+
logger.log('SDK::PasskeyService::addNewPasskey::catch: finished authenticating with passkey');
|
|
7672
7674
|
signInResponse = await this.request(AuthRoutes.signIn, {
|
|
7673
7675
|
payload: {
|
|
7674
7676
|
externalUserId: this.userId,
|
|
@@ -7678,16 +7680,16 @@ class PasskeyService {
|
|
|
7678
7680
|
passkeyAuthenticationResponse: passkeyCredential,
|
|
7679
7681
|
},
|
|
7680
7682
|
});
|
|
7681
|
-
|
|
7683
|
+
logger.log('SDK::PasskeyService::addNewPasskey::catch: finished signing in with passkey', {
|
|
7682
7684
|
signInResponse,
|
|
7683
7685
|
});
|
|
7684
7686
|
const credentialsKeyPair = await this.handleCredentialsCreationFromPrfExtension(passkeyCredential);
|
|
7685
|
-
|
|
7687
|
+
logger.log('SDK::PasskeyService::addNewPasskey::catch: finished deriving credentials key pair', credentialsKeyPair.publicKey);
|
|
7686
7688
|
const encryptedNewDevicePrivateKey = await this.cipher.encrypt({
|
|
7687
7689
|
data: deviceKeyPair.privateKey,
|
|
7688
7690
|
encryptionKey: credentialsKeyPair.publicKey,
|
|
7689
7691
|
});
|
|
7690
|
-
|
|
7692
|
+
logger.log('SDK::PasskeyService::addNewPasskey::catch: about to store data');
|
|
7691
7693
|
await this.handleStoringData({
|
|
7692
7694
|
authenticationResponse: signInResponse,
|
|
7693
7695
|
deviceKeyPair: {
|
|
@@ -7696,7 +7698,7 @@ class PasskeyService {
|
|
|
7696
7698
|
},
|
|
7697
7699
|
passkeyCredential,
|
|
7698
7700
|
});
|
|
7699
|
-
|
|
7701
|
+
logger.log('SDK::PasskeyService::addNewPasskey::catch: finished storing data');
|
|
7700
7702
|
return Object.assign(Object.assign({}, signInResponse), { signatureMessageResponse: authenticationChallengeResponse, prfValue: credentialsKeyPair.prfValue });
|
|
7701
7703
|
}
|
|
7702
7704
|
throw error;
|
|
@@ -7830,17 +7832,17 @@ class PasskeyService {
|
|
|
7830
7832
|
statusCode: 400,
|
|
7831
7833
|
errorCode: ErrorResponseCodes.sdk_passkey_challenge_unavailable,
|
|
7832
7834
|
});
|
|
7833
|
-
|
|
7835
|
+
logger.log('SDK::PasskeyService::register:: got challenge', {
|
|
7834
7836
|
registrationOptions: challengeResponse.registrationOptions,
|
|
7835
7837
|
});
|
|
7836
7838
|
const parsedOptions = this.preparePasskeyCreationOptions(challengeResponse.registrationOptions);
|
|
7837
|
-
|
|
7839
|
+
logger.log('SDK::PasskeyService::register:: registering passkey', {
|
|
7838
7840
|
parsedOptions,
|
|
7839
7841
|
});
|
|
7840
7842
|
const passkeyCredential = await this.authenticator.register({
|
|
7841
7843
|
optionsJSON: parsedOptions,
|
|
7842
7844
|
});
|
|
7843
|
-
|
|
7845
|
+
logger.log('SDK::PasskeyService::register:: got passkey credential', {
|
|
7844
7846
|
id: passkeyCredential.id,
|
|
7845
7847
|
type: passkeyCredential.type,
|
|
7846
7848
|
});
|
|
@@ -7851,7 +7853,7 @@ class PasskeyService {
|
|
|
7851
7853
|
errorCode: ErrorResponseCodes.sdk_passkey_prf_not_available,
|
|
7852
7854
|
});
|
|
7853
7855
|
}
|
|
7854
|
-
|
|
7856
|
+
logger.log('SDK::PasskeyService::register:: getting signature', {
|
|
7855
7857
|
message: challengeResponse.message,
|
|
7856
7858
|
privateKey: deviceKeyPair.privateKey,
|
|
7857
7859
|
});
|
|
@@ -7884,10 +7886,10 @@ class PasskeyService {
|
|
|
7884
7886
|
return Object.freeze(Object.assign(Object.assign({}, signUpResponse), { prfValue: credentialsKeyPair.prfValue, signatureMessageResponse: challengeResponse }));
|
|
7885
7887
|
}
|
|
7886
7888
|
catch (error) {
|
|
7887
|
-
|
|
7889
|
+
logger.log('SDK::PasskeyService::register::error', { error, errorCode: error.code, errorMessage: error.message });
|
|
7888
7890
|
// If it's an API error (has statusCode), preserve the original error message
|
|
7889
7891
|
if (error instanceof WallabyError) {
|
|
7890
|
-
|
|
7892
|
+
logger.log('SDK::PasskeyService::register::API error detected', { error });
|
|
7891
7893
|
throw error;
|
|
7892
7894
|
}
|
|
7893
7895
|
// we want to skip handling the error and showing the proper error message for this one.
|
|
@@ -7895,7 +7897,7 @@ class PasskeyService {
|
|
|
7895
7897
|
if ((error && error.code === AuthenticatorPreviouslyRegisteredError.error) ||
|
|
7896
7898
|
error.code === InvalidStateError.error ||
|
|
7897
7899
|
error.message === 'The authenticator was previously registered.') {
|
|
7898
|
-
|
|
7900
|
+
logger.log('SDK::PasskeyService::register::ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED', true);
|
|
7899
7901
|
throw error;
|
|
7900
7902
|
}
|
|
7901
7903
|
throw this.authenticator.handlePasskeyError(error);
|
|
@@ -7912,7 +7914,7 @@ class PasskeyService {
|
|
|
7912
7914
|
// Check if we're in a browser environment and getClientCapabilities is available
|
|
7913
7915
|
if (typeof window !== 'undefined' && typeof ((_a = window.PublicKeyCredential) === null || _a === void 0 ? void 0 : _a.getClientCapabilities) === 'function') {
|
|
7914
7916
|
const capabilities = await window.PublicKeyCredential.getClientCapabilities();
|
|
7915
|
-
|
|
7917
|
+
logger.log('SDK::PasskeyService::isDevicePrfCompatible::capabilities', capabilities);
|
|
7916
7918
|
return capabilities['extension:prf'];
|
|
7917
7919
|
}
|
|
7918
7920
|
// Fallback: assume PRF is not supported if the API is not available
|
|
@@ -7972,7 +7974,7 @@ class PasskeyService {
|
|
|
7972
7974
|
var _a, _b, _c, _d, _e;
|
|
7973
7975
|
try {
|
|
7974
7976
|
const extensions = passkeyCredential.clientExtensionResults;
|
|
7975
|
-
|
|
7977
|
+
logger.log('SDK::PasskeyService::handleCredentialsCreationFromPrfExtension::extensions', extensions);
|
|
7976
7978
|
if (!((_a = extensions.prf) === null || _a === void 0 ? void 0 : _a.enabled) && !((_c = (_b = extensions.prf) === null || _b === void 0 ? void 0 : _b.results) === null || _c === void 0 ? void 0 : _c.first)) {
|
|
7977
7979
|
throw new WallabyError({
|
|
7978
7980
|
message: 'Device is not compatible with this feature. Try using a different authentication method.',
|
|
@@ -7994,7 +7996,7 @@ class PasskeyService {
|
|
|
7994
7996
|
prfValue,
|
|
7995
7997
|
authType: AuthType.Passkey,
|
|
7996
7998
|
});
|
|
7997
|
-
|
|
7999
|
+
logger.log('SDK::PasskeyService::handleCredentialsCreationFromPrfExtension::credentials key pair was created', !!credentialsKeyPair);
|
|
7998
8000
|
return Object.assign(Object.assign({}, credentialsKeyPair), { prfValue });
|
|
7999
8001
|
}
|
|
8000
8002
|
catch (error) {
|
|
@@ -8131,23 +8133,18 @@ class AuthService extends Base {
|
|
|
8131
8133
|
logger.debug('SDK::AuthService::getSignature::authType', this.deviceAuthType);
|
|
8132
8134
|
const challengeType = passkeyChallengeType !== null && passkeyChallengeType !== void 0 ? passkeyChallengeType : PasskeyChallengeType.REGISTRATION;
|
|
8133
8135
|
logger.debug('SDK::AuthService::getSignature::challengeType', challengeType);
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
// },
|
|
8140
|
-
// });
|
|
8141
|
-
const response = await this.api.auth.generateSignatureMessage({
|
|
8142
|
-
clientAuthPubKey: deviceAuthKeys.publicKey,
|
|
8143
|
-
passkeyChallengeType: challengeType,
|
|
8136
|
+
const response = await this.request(AuthRoutes.signatureMessage, {
|
|
8137
|
+
payload: {
|
|
8138
|
+
clientAuthPubKey: deviceAuthKeys.publicKey,
|
|
8139
|
+
passkeyChallengeType: challengeType,
|
|
8140
|
+
},
|
|
8144
8141
|
});
|
|
8145
8142
|
const { signature, hashedMessage } = await this.cipher.sign({
|
|
8146
8143
|
message: response.message,
|
|
8147
8144
|
signingKey: deviceAuthKeys.privateKey,
|
|
8148
8145
|
});
|
|
8149
|
-
return Object.freeze(Object.assign({ signature,
|
|
8150
|
-
hashedMessage }
|
|
8146
|
+
return Object.freeze(Object.assign(Object.assign({}, response), { signature,
|
|
8147
|
+
hashedMessage }));
|
|
8151
8148
|
}
|
|
8152
8149
|
catch (error) {
|
|
8153
8150
|
logger.error('SDK::AuthService::getSignatureMessage::error', error);
|
|
@@ -8208,7 +8205,6 @@ class AuthService extends Base {
|
|
|
8208
8205
|
});
|
|
8209
8206
|
return authentication;
|
|
8210
8207
|
}
|
|
8211
|
-
// Re-throw the original error (likely WallabyError with proper structure)
|
|
8212
8208
|
throw error;
|
|
8213
8209
|
}
|
|
8214
8210
|
}
|
|
@@ -8421,7 +8417,6 @@ class AuthService extends Base {
|
|
|
8421
8417
|
clientAuthPubKey: deviceKeyPair.publicKey,
|
|
8422
8418
|
},
|
|
8423
8419
|
}).then(async (authResponse) => {
|
|
8424
|
-
console.log('SDK::AuthService::handleSignUpWithPassword::authResponse', authResponse);
|
|
8425
8420
|
const credentialsKeyPair = await this.cipher.getCredentialsKeyPair({
|
|
8426
8421
|
authType: this.deviceAuthType,
|
|
8427
8422
|
password: input.password,
|
|
@@ -8456,7 +8451,6 @@ class AuthService extends Base {
|
|
|
8456
8451
|
async getPasskeyCredentials() {
|
|
8457
8452
|
try {
|
|
8458
8453
|
const response = await this.api.auth.getPasskeyCredentials();
|
|
8459
|
-
console.log('SDK::AuthService::getPasskeyCredentials::response', response);
|
|
8460
8454
|
return response;
|
|
8461
8455
|
}
|
|
8462
8456
|
catch (error) {
|
|
@@ -8581,7 +8575,6 @@ class WalletHandlersService extends Base {
|
|
|
8581
8575
|
password: importWalletInput.authenticationOptions.password,
|
|
8582
8576
|
prfValue: importWalletInput.authenticationOptions.prfValue,
|
|
8583
8577
|
});
|
|
8584
|
-
console.log('importWalletRequest', importWalletRequest);
|
|
8585
8578
|
if (
|
|
8586
8579
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
8587
8580
|
importWalletRequest.encryptedSeed &&
|
|
@@ -9151,10 +9144,6 @@ class WalletService extends Base {
|
|
|
9151
9144
|
});
|
|
9152
9145
|
}
|
|
9153
9146
|
const parsedEncryptedDevicePrivateKey = safeJsonParse(encryptedDevicePrivateKey);
|
|
9154
|
-
console.log('credentials data', {
|
|
9155
|
-
password: input.authenticationOptions.password,
|
|
9156
|
-
salt: input.authenticationOptions.user.clientSalt,
|
|
9157
|
-
});
|
|
9158
9147
|
const credentialsKeyPair = await this.cipher.getCredentialsKeyPair({
|
|
9159
9148
|
authType: this.deviceAuthType,
|
|
9160
9149
|
password: input.authenticationOptions.password,
|
|
@@ -9540,12 +9529,14 @@ class WalletService extends Base {
|
|
|
9540
9529
|
privateKey: decryptedDevicePrivateKey,
|
|
9541
9530
|
});
|
|
9542
9531
|
const { message, signature } = signatureMessage;
|
|
9543
|
-
const response = await this.
|
|
9544
|
-
|
|
9545
|
-
|
|
9546
|
-
|
|
9547
|
-
|
|
9548
|
-
|
|
9532
|
+
const response = await this.request(WalletRoutes.convertMnemonicSeedPhrase, {
|
|
9533
|
+
payload: {
|
|
9534
|
+
reference,
|
|
9535
|
+
signature,
|
|
9536
|
+
message,
|
|
9537
|
+
clientAuthPubKey,
|
|
9538
|
+
encryptedSeed: wallabyBoundSeedPhrase,
|
|
9539
|
+
},
|
|
9549
9540
|
});
|
|
9550
9541
|
return response;
|
|
9551
9542
|
}
|
|
@@ -9698,7 +9689,7 @@ class WalletService extends Base {
|
|
|
9698
9689
|
// },
|
|
9699
9690
|
// },
|
|
9700
9691
|
// });
|
|
9701
|
-
const backUpResponse =
|
|
9692
|
+
const backUpResponse = await this.api.wallets.addNewDevice({
|
|
9702
9693
|
walletId: input.walletId,
|
|
9703
9694
|
message: signatureMessage.message,
|
|
9704
9695
|
signature: signatureMessage.signature,
|
|
@@ -9708,7 +9699,7 @@ class WalletService extends Base {
|
|
|
9708
9699
|
wrappingPublicKey: input.authenticationOptions.user.wallabyAuthPubKey,
|
|
9709
9700
|
type: KeyTypeName.OwnerBackupDeviceShare,
|
|
9710
9701
|
},
|
|
9711
|
-
})
|
|
9702
|
+
});
|
|
9712
9703
|
const keyShares = [
|
|
9713
9704
|
backUpResponse.share, // this is the backup share that is now rewrapped with the new device public key.
|
|
9714
9705
|
{
|
|
@@ -9724,7 +9715,7 @@ class WalletService extends Base {
|
|
|
9724
9715
|
devicePrivateKey: decryptedDevicePrivateKey,
|
|
9725
9716
|
credentialsKeyPair,
|
|
9726
9717
|
});
|
|
9727
|
-
return { success: true, reference: backUpResponse.
|
|
9718
|
+
return { success: true, reference: backUpResponse.reference };
|
|
9728
9719
|
}
|
|
9729
9720
|
catch (error) {
|
|
9730
9721
|
logger.error('SDK::Wallet::backupKeyShare::error', error);
|
|
@@ -10779,7 +10770,7 @@ class Merchants extends Base {
|
|
|
10779
10770
|
const response = await this.request(MerchantsRoutes.getMerchantData, {
|
|
10780
10771
|
payload: { merchantId },
|
|
10781
10772
|
});
|
|
10782
|
-
return response;
|
|
10773
|
+
return response.merchant;
|
|
10783
10774
|
}
|
|
10784
10775
|
catch (error) {
|
|
10785
10776
|
logger.error('SDK::Merchants::list::error', error);
|
|
@@ -10794,7 +10785,6 @@ class Merchants extends Base {
|
|
|
10794
10785
|
async getAssets() {
|
|
10795
10786
|
try {
|
|
10796
10787
|
const response = await this.request(MerchantsRoutes.getAssets);
|
|
10797
|
-
console.log('SDK::Merchants::getAssets::response', response);
|
|
10798
10788
|
return response.merchantAssets;
|
|
10799
10789
|
}
|
|
10800
10790
|
catch (error) {
|
|
@@ -11172,7 +11162,11 @@ class Transactions extends Base {
|
|
|
11172
11162
|
});
|
|
11173
11163
|
}
|
|
11174
11164
|
else {
|
|
11175
|
-
throw new
|
|
11165
|
+
throw new WallabyError({
|
|
11166
|
+
message: 'No valid seed option found on this device.',
|
|
11167
|
+
statusCode: 400,
|
|
11168
|
+
errorCode: 'sdk_no_valid_seed_option',
|
|
11169
|
+
});
|
|
11176
11170
|
}
|
|
11177
11171
|
return transferResponse;
|
|
11178
11172
|
}
|
|
@@ -11252,16 +11246,81 @@ class Transactions extends Base {
|
|
|
11252
11246
|
throw error;
|
|
11253
11247
|
}
|
|
11254
11248
|
}
|
|
11249
|
+
/**
|
|
11250
|
+
*
|
|
11251
|
+
* @public
|
|
11252
|
+
* @param {string} walletId
|
|
11253
|
+
* @param {BlockchainName} chainName
|
|
11254
|
+
* @returns {Promise<GetPendingTransactionsResponse>}
|
|
11255
|
+
*/
|
|
11256
|
+
async getPendingTransactions({ walletId, chainName }) {
|
|
11257
|
+
try {
|
|
11258
|
+
const response = await this.request(TransactionsRoutes.getPendingTransactions, {
|
|
11259
|
+
queryParams: {
|
|
11260
|
+
walletId,
|
|
11261
|
+
chainName,
|
|
11262
|
+
},
|
|
11263
|
+
});
|
|
11264
|
+
return response;
|
|
11265
|
+
}
|
|
11266
|
+
catch (error) {
|
|
11267
|
+
logger.error('SDK::Transactions::getPendingTransactions::error', error);
|
|
11268
|
+
throw error;
|
|
11269
|
+
}
|
|
11270
|
+
}
|
|
11271
|
+
/**
|
|
11272
|
+
*
|
|
11273
|
+
* @public
|
|
11274
|
+
* @param {string} id
|
|
11275
|
+
* @param {ResolvePendingTransactionDecision} choice
|
|
11276
|
+
* @param {number} symbol
|
|
11277
|
+
* @param {string} chainName
|
|
11278
|
+
* @param {string} walletId
|
|
11279
|
+
* @param {AuthResponse} authenticationOptions
|
|
11280
|
+
* @returns {ResolvePendingTransactionResponse}
|
|
11281
|
+
*/
|
|
11282
|
+
async resolvePendingTransaction({ id, choice, symbol, chainName, walletId, authenticationOptions, }) {
|
|
11283
|
+
try {
|
|
11284
|
+
// Only attempt migration if we have password auth and V2 storage might be incomplete
|
|
11285
|
+
if (this.deviceAuthType === AuthType.Password && authenticationOptions.password) {
|
|
11286
|
+
try {
|
|
11287
|
+
await this.walletService.handleUpdateToV2({
|
|
11288
|
+
password: authenticationOptions.password,
|
|
11289
|
+
walletId: walletId,
|
|
11290
|
+
});
|
|
11291
|
+
}
|
|
11292
|
+
catch (error) {
|
|
11293
|
+
// If migration fails, log it but don't block the transaction
|
|
11294
|
+
// The original transaction logic will handle missing storage items appropriately
|
|
11295
|
+
logger.debug('Migration to V2 failed, continuing with original flow:', error);
|
|
11296
|
+
}
|
|
11297
|
+
}
|
|
11298
|
+
const { deviceAuthPublicKey, signatureMessage, readyForTransportSeedPhrase, sharesEncryptedWithWallabyPubKey, hasShares } = await this.prepareTransactionAuth(authenticationOptions, walletId);
|
|
11299
|
+
if (!readyForTransportSeedPhrase && !hasShares) {
|
|
11300
|
+
throw new Error('No valid seed option found on this device.');
|
|
11301
|
+
}
|
|
11302
|
+
const confirmPendingTransactionResponse = await this.request(TransactionsRoutes.confirmPendingTransaction, {
|
|
11303
|
+
payload: Object.assign(Object.assign({}, signatureMessage), { clientAuthPubKey: deviceAuthPublicKey, encryptedShares: sharesEncryptedWithWallabyPubKey, encryptedSeed: readyForTransportSeedPhrase, id,
|
|
11304
|
+
choice,
|
|
11305
|
+
symbol,
|
|
11306
|
+
chainName }),
|
|
11307
|
+
});
|
|
11308
|
+
return confirmPendingTransactionResponse;
|
|
11309
|
+
}
|
|
11310
|
+
catch (error) {
|
|
11311
|
+
logger.error('SDK::Transactions::transfer::error', error);
|
|
11312
|
+
throw error;
|
|
11313
|
+
}
|
|
11314
|
+
}
|
|
11255
11315
|
/**
|
|
11256
11316
|
* Prepares authentication data and encrypted payload for transaction requests
|
|
11257
11317
|
* @private
|
|
11258
11318
|
*/
|
|
11259
11319
|
async prepareTransactionAuth(authenticationOptions, walletId) {
|
|
11260
|
-
const { password, prfValue, user } = authenticationOptions;
|
|
11320
|
+
const { password, prfValue, user, clientSalt: authClientSalt } = authenticationOptions;
|
|
11261
11321
|
const encryptedDevicePrivateKey = await this.localStorageService.fetch(LocalStorageItems.EncryptedDevicePrivateKey, {
|
|
11262
11322
|
walletId,
|
|
11263
11323
|
});
|
|
11264
|
-
console.log('user_in_prepare_tx_auth', user);
|
|
11265
11324
|
if (!encryptedDevicePrivateKey) {
|
|
11266
11325
|
throw new WallabyError({
|
|
11267
11326
|
message: 'No private key was found on this device.',
|
|
@@ -11270,11 +11329,12 @@ class Transactions extends Base {
|
|
|
11270
11329
|
});
|
|
11271
11330
|
}
|
|
11272
11331
|
// Get credentials key pair for device private key decryption
|
|
11332
|
+
const clientSalt = authClientSalt || user.clientSalt;
|
|
11273
11333
|
const credentialsKeyPair = await this.cipher.getCredentialsKeyPair({
|
|
11274
11334
|
authType: this.deviceAuthType,
|
|
11275
11335
|
password,
|
|
11276
11336
|
prfValue,
|
|
11277
|
-
salt:
|
|
11337
|
+
salt: clientSalt,
|
|
11278
11338
|
});
|
|
11279
11339
|
// Decrypt device private key
|
|
11280
11340
|
const decryptedDevicePrivateKey = await this.cipher.decrypt({
|
|
@@ -11319,7 +11379,7 @@ class Transactions extends Base {
|
|
|
11319
11379
|
authType: this.deviceAuthType,
|
|
11320
11380
|
password,
|
|
11321
11381
|
prfValue,
|
|
11322
|
-
salt:
|
|
11382
|
+
salt: clientSalt,
|
|
11323
11383
|
},
|
|
11324
11384
|
});
|
|
11325
11385
|
}
|
|
@@ -11334,7 +11394,7 @@ class Transactions extends Base {
|
|
|
11334
11394
|
authType: this.deviceAuthType,
|
|
11335
11395
|
password,
|
|
11336
11396
|
prfValue,
|
|
11337
|
-
salt:
|
|
11397
|
+
salt: clientSalt,
|
|
11338
11398
|
},
|
|
11339
11399
|
});
|
|
11340
11400
|
sharesEncryptedWithWallabyPubKey.push(readyForTransportShare);
|
|
@@ -11360,6 +11420,12 @@ __decorate([
|
|
|
11360
11420
|
__metadata("design:paramtypes", [Object]),
|
|
11361
11421
|
__metadata("design:returntype", Promise)
|
|
11362
11422
|
], Transactions.prototype, "createAllowance", null);
|
|
11423
|
+
__decorate([
|
|
11424
|
+
WithLock('confirmPendingTransaction'),
|
|
11425
|
+
__metadata("design:type", Function),
|
|
11426
|
+
__metadata("design:paramtypes", [Object]),
|
|
11427
|
+
__metadata("design:returntype", Promise)
|
|
11428
|
+
], Transactions.prototype, "resolvePendingTransaction", null);
|
|
11363
11429
|
|
|
11364
11430
|
/**
|
|
11365
11431
|
* The Wallaby SDK client. This class is the main entry point into Wallaby's
|