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.cjs.js
CHANGED
|
@@ -115,18 +115,10 @@ class WallabyError extends Error {
|
|
|
115
115
|
this.cause = cause;
|
|
116
116
|
this.onError = onError;
|
|
117
117
|
this.data = data;
|
|
118
|
-
if (onError) {
|
|
119
|
-
onError();
|
|
120
|
-
}
|
|
121
118
|
Error.captureStackTrace(this, WallabyError);
|
|
122
119
|
}
|
|
123
|
-
static isWallabyError(
|
|
124
|
-
return
|
|
125
|
-
typeof obj === 'object' &&
|
|
126
|
-
'statusCode' in obj &&
|
|
127
|
-
'message' in obj &&
|
|
128
|
-
typeof obj.statusCode === 'number' &&
|
|
129
|
-
(obj.statusCode >= 400 || 'error' in obj));
|
|
120
|
+
static isWallabyError(error) {
|
|
121
|
+
return error instanceof WallabyError;
|
|
130
122
|
}
|
|
131
123
|
}
|
|
132
124
|
exports.UserAssetSource = void 0;
|
|
@@ -7201,7 +7193,7 @@ class Base {
|
|
|
7201
7193
|
}
|
|
7202
7194
|
catch (error) {
|
|
7203
7195
|
if (error === null || error === void 0 ? void 0 : error.error) {
|
|
7204
|
-
|
|
7196
|
+
logger.error('SDK::Base::handleApiCall::API Error', { error });
|
|
7205
7197
|
const apiError = error.error;
|
|
7206
7198
|
throw new WallabyError({
|
|
7207
7199
|
message: apiError.message || 'API request failed',
|
|
@@ -7495,6 +7487,16 @@ const TransactionsRoutes = {
|
|
|
7495
7487
|
method: exports.RequestMethod.Get,
|
|
7496
7488
|
requiresAccessToken: true,
|
|
7497
7489
|
},
|
|
7490
|
+
getPendingTransactions: {
|
|
7491
|
+
fullPath: '/transactions/pending',
|
|
7492
|
+
method: exports.RequestMethod.Get,
|
|
7493
|
+
requiresAccessToken: true,
|
|
7494
|
+
},
|
|
7495
|
+
confirmPendingTransaction: {
|
|
7496
|
+
fullPath: '/transactions/resolve',
|
|
7497
|
+
method: exports.RequestMethod.Post,
|
|
7498
|
+
requiresAccessToken: true,
|
|
7499
|
+
},
|
|
7498
7500
|
};
|
|
7499
7501
|
|
|
7500
7502
|
/* eslint-disable no-useless-catch */
|
|
@@ -7605,7 +7607,7 @@ class PasskeyService {
|
|
|
7605
7607
|
first: prfExtensionEvaluation,
|
|
7606
7608
|
},
|
|
7607
7609
|
} }) });
|
|
7608
|
-
|
|
7610
|
+
logger.log('SDK::PasskeyService::preparePasskeyRequestOptions::parsedOptions', !!parsedOptions);
|
|
7609
7611
|
// While the authenticator still works with the prf and would return the response (if any),
|
|
7610
7612
|
// the library `@simplewebauthn/browser` does not support the prf extension in its type intentionally.
|
|
7611
7613
|
// > "Using the prf extension does not fall under the simple use of webauthn."
|
|
@@ -7625,7 +7627,7 @@ class PasskeyService {
|
|
|
7625
7627
|
first: prfExtensionEvaluation,
|
|
7626
7628
|
},
|
|
7627
7629
|
} }) });
|
|
7628
|
-
|
|
7630
|
+
logger.log('SDK::PasskeyService::preparePasskeyRequestOptions::parsedOptions', !!parsedOptions);
|
|
7629
7631
|
return parsedOptions;
|
|
7630
7632
|
}
|
|
7631
7633
|
/**
|
|
@@ -7636,7 +7638,7 @@ class PasskeyService {
|
|
|
7636
7638
|
*/
|
|
7637
7639
|
async addNewPasskey({ deviceKeyPair, getSignature, }) {
|
|
7638
7640
|
try {
|
|
7639
|
-
|
|
7641
|
+
logger.log('SDK::PasskeyService::addNewPasskey: start adding new passkey');
|
|
7640
7642
|
let passkeyCredential;
|
|
7641
7643
|
let signInResponse;
|
|
7642
7644
|
try {
|
|
@@ -7648,14 +7650,14 @@ class PasskeyService {
|
|
|
7648
7650
|
errorCode: exports.ErrorResponseCodes.sdk_passkey_challenge_unavailable,
|
|
7649
7651
|
});
|
|
7650
7652
|
const parsedOptions = this.preparePasskeyCreationOptions(registrationChallengeResponse.registrationOptions);
|
|
7651
|
-
|
|
7653
|
+
logger.log('SDK::PasskeyService::addNewPasskey: about to register passkey credential');
|
|
7652
7654
|
passkeyCredential = await this.authenticator.register({
|
|
7653
7655
|
optionsJSON: parsedOptions,
|
|
7654
7656
|
});
|
|
7655
|
-
|
|
7657
|
+
logger.log('SDK::PasskeyService::addNewPasskey: finished registering passkey credential');
|
|
7656
7658
|
// before we sign the user in, we need to make sure the prf extension is enabled and we have a value.
|
|
7657
7659
|
const credentialsKeyPair = await this.handleCredentialsCreationFromPrfExtension(passkeyCredential);
|
|
7658
|
-
|
|
7660
|
+
logger.log('SDK::PasskeyService::addNewPasskey:: finished deriving credentials key pair', credentialsKeyPair.publicKey);
|
|
7659
7661
|
signInResponse = await this.request(AuthRoutes.signIn, {
|
|
7660
7662
|
payload: {
|
|
7661
7663
|
externalUserId: this.userId,
|
|
@@ -7665,7 +7667,7 @@ class PasskeyService {
|
|
|
7665
7667
|
passkeyRegistrationResponse: passkeyCredential,
|
|
7666
7668
|
},
|
|
7667
7669
|
});
|
|
7668
|
-
|
|
7670
|
+
logger.log('SDK::PasskeyService::addNewPasskey:: signInResponse', signInResponse);
|
|
7669
7671
|
const encryptedNewDevicePrivateKey = await this.cipher.encrypt({
|
|
7670
7672
|
data: deviceKeyPair.privateKey,
|
|
7671
7673
|
encryptionKey: credentialsKeyPair.publicKey,
|
|
@@ -7691,11 +7693,11 @@ class PasskeyService {
|
|
|
7691
7693
|
errorCode: exports.ErrorResponseCodes.sdk_passkey_challenge_unavailable,
|
|
7692
7694
|
});
|
|
7693
7695
|
const parsedOptions = this.preparePasskeyRequestOptions(authenticationChallengeResponse.authenticationOptions);
|
|
7694
|
-
|
|
7696
|
+
logger.log('SDK::PasskeyService::addNewPasskey::catch: about to authenticate with passkey');
|
|
7695
7697
|
passkeyCredential = await this.authenticator.authenticate({
|
|
7696
7698
|
optionsJSON: parsedOptions,
|
|
7697
7699
|
});
|
|
7698
|
-
|
|
7700
|
+
logger.log('SDK::PasskeyService::addNewPasskey::catch: finished authenticating with passkey');
|
|
7699
7701
|
signInResponse = await this.request(AuthRoutes.signIn, {
|
|
7700
7702
|
payload: {
|
|
7701
7703
|
externalUserId: this.userId,
|
|
@@ -7705,16 +7707,16 @@ class PasskeyService {
|
|
|
7705
7707
|
passkeyAuthenticationResponse: passkeyCredential,
|
|
7706
7708
|
},
|
|
7707
7709
|
});
|
|
7708
|
-
|
|
7710
|
+
logger.log('SDK::PasskeyService::addNewPasskey::catch: finished signing in with passkey', {
|
|
7709
7711
|
signInResponse,
|
|
7710
7712
|
});
|
|
7711
7713
|
const credentialsKeyPair = await this.handleCredentialsCreationFromPrfExtension(passkeyCredential);
|
|
7712
|
-
|
|
7714
|
+
logger.log('SDK::PasskeyService::addNewPasskey::catch: finished deriving credentials key pair', credentialsKeyPair.publicKey);
|
|
7713
7715
|
const encryptedNewDevicePrivateKey = await this.cipher.encrypt({
|
|
7714
7716
|
data: deviceKeyPair.privateKey,
|
|
7715
7717
|
encryptionKey: credentialsKeyPair.publicKey,
|
|
7716
7718
|
});
|
|
7717
|
-
|
|
7719
|
+
logger.log('SDK::PasskeyService::addNewPasskey::catch: about to store data');
|
|
7718
7720
|
await this.handleStoringData({
|
|
7719
7721
|
authenticationResponse: signInResponse,
|
|
7720
7722
|
deviceKeyPair: {
|
|
@@ -7723,7 +7725,7 @@ class PasskeyService {
|
|
|
7723
7725
|
},
|
|
7724
7726
|
passkeyCredential,
|
|
7725
7727
|
});
|
|
7726
|
-
|
|
7728
|
+
logger.log('SDK::PasskeyService::addNewPasskey::catch: finished storing data');
|
|
7727
7729
|
return Object.assign(Object.assign({}, signInResponse), { signatureMessageResponse: authenticationChallengeResponse, prfValue: credentialsKeyPair.prfValue });
|
|
7728
7730
|
}
|
|
7729
7731
|
throw error;
|
|
@@ -7857,17 +7859,17 @@ class PasskeyService {
|
|
|
7857
7859
|
statusCode: 400,
|
|
7858
7860
|
errorCode: exports.ErrorResponseCodes.sdk_passkey_challenge_unavailable,
|
|
7859
7861
|
});
|
|
7860
|
-
|
|
7862
|
+
logger.log('SDK::PasskeyService::register:: got challenge', {
|
|
7861
7863
|
registrationOptions: challengeResponse.registrationOptions,
|
|
7862
7864
|
});
|
|
7863
7865
|
const parsedOptions = this.preparePasskeyCreationOptions(challengeResponse.registrationOptions);
|
|
7864
|
-
|
|
7866
|
+
logger.log('SDK::PasskeyService::register:: registering passkey', {
|
|
7865
7867
|
parsedOptions,
|
|
7866
7868
|
});
|
|
7867
7869
|
const passkeyCredential = await this.authenticator.register({
|
|
7868
7870
|
optionsJSON: parsedOptions,
|
|
7869
7871
|
});
|
|
7870
|
-
|
|
7872
|
+
logger.log('SDK::PasskeyService::register:: got passkey credential', {
|
|
7871
7873
|
id: passkeyCredential.id,
|
|
7872
7874
|
type: passkeyCredential.type,
|
|
7873
7875
|
});
|
|
@@ -7878,7 +7880,7 @@ class PasskeyService {
|
|
|
7878
7880
|
errorCode: exports.ErrorResponseCodes.sdk_passkey_prf_not_available,
|
|
7879
7881
|
});
|
|
7880
7882
|
}
|
|
7881
|
-
|
|
7883
|
+
logger.log('SDK::PasskeyService::register:: getting signature', {
|
|
7882
7884
|
message: challengeResponse.message,
|
|
7883
7885
|
privateKey: deviceKeyPair.privateKey,
|
|
7884
7886
|
});
|
|
@@ -7911,10 +7913,10 @@ class PasskeyService {
|
|
|
7911
7913
|
return Object.freeze(Object.assign(Object.assign({}, signUpResponse), { prfValue: credentialsKeyPair.prfValue, signatureMessageResponse: challengeResponse }));
|
|
7912
7914
|
}
|
|
7913
7915
|
catch (error) {
|
|
7914
|
-
|
|
7916
|
+
logger.log('SDK::PasskeyService::register::error', { error, errorCode: error.code, errorMessage: error.message });
|
|
7915
7917
|
// If it's an API error (has statusCode), preserve the original error message
|
|
7916
7918
|
if (error instanceof WallabyError) {
|
|
7917
|
-
|
|
7919
|
+
logger.log('SDK::PasskeyService::register::API error detected', { error });
|
|
7918
7920
|
throw error;
|
|
7919
7921
|
}
|
|
7920
7922
|
// we want to skip handling the error and showing the proper error message for this one.
|
|
@@ -7922,7 +7924,7 @@ class PasskeyService {
|
|
|
7922
7924
|
if ((error && error.code === AuthenticatorPreviouslyRegisteredError.error) ||
|
|
7923
7925
|
error.code === InvalidStateError.error ||
|
|
7924
7926
|
error.message === 'The authenticator was previously registered.') {
|
|
7925
|
-
|
|
7927
|
+
logger.log('SDK::PasskeyService::register::ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED', true);
|
|
7926
7928
|
throw error;
|
|
7927
7929
|
}
|
|
7928
7930
|
throw this.authenticator.handlePasskeyError(error);
|
|
@@ -7939,7 +7941,7 @@ class PasskeyService {
|
|
|
7939
7941
|
// Check if we're in a browser environment and getClientCapabilities is available
|
|
7940
7942
|
if (typeof window !== 'undefined' && typeof ((_a = window.PublicKeyCredential) === null || _a === void 0 ? void 0 : _a.getClientCapabilities) === 'function') {
|
|
7941
7943
|
const capabilities = await window.PublicKeyCredential.getClientCapabilities();
|
|
7942
|
-
|
|
7944
|
+
logger.log('SDK::PasskeyService::isDevicePrfCompatible::capabilities', capabilities);
|
|
7943
7945
|
return capabilities['extension:prf'];
|
|
7944
7946
|
}
|
|
7945
7947
|
// Fallback: assume PRF is not supported if the API is not available
|
|
@@ -7999,7 +8001,7 @@ class PasskeyService {
|
|
|
7999
8001
|
var _a, _b, _c, _d, _e;
|
|
8000
8002
|
try {
|
|
8001
8003
|
const extensions = passkeyCredential.clientExtensionResults;
|
|
8002
|
-
|
|
8004
|
+
logger.log('SDK::PasskeyService::handleCredentialsCreationFromPrfExtension::extensions', extensions);
|
|
8003
8005
|
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)) {
|
|
8004
8006
|
throw new WallabyError({
|
|
8005
8007
|
message: 'Device is not compatible with this feature. Try using a different authentication method.',
|
|
@@ -8021,7 +8023,7 @@ class PasskeyService {
|
|
|
8021
8023
|
prfValue,
|
|
8022
8024
|
authType: exports.AuthType.Passkey,
|
|
8023
8025
|
});
|
|
8024
|
-
|
|
8026
|
+
logger.log('SDK::PasskeyService::handleCredentialsCreationFromPrfExtension::credentials key pair was created', !!credentialsKeyPair);
|
|
8025
8027
|
return Object.assign(Object.assign({}, credentialsKeyPair), { prfValue });
|
|
8026
8028
|
}
|
|
8027
8029
|
catch (error) {
|
|
@@ -8158,23 +8160,18 @@ class AuthService extends Base {
|
|
|
8158
8160
|
logger.debug('SDK::AuthService::getSignature::authType', this.deviceAuthType);
|
|
8159
8161
|
const challengeType = passkeyChallengeType !== null && passkeyChallengeType !== void 0 ? passkeyChallengeType : exports.PasskeyChallengeType.REGISTRATION;
|
|
8160
8162
|
logger.debug('SDK::AuthService::getSignature::challengeType', challengeType);
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
// },
|
|
8167
|
-
// });
|
|
8168
|
-
const response = await this.api.auth.generateSignatureMessage({
|
|
8169
|
-
clientAuthPubKey: deviceAuthKeys.publicKey,
|
|
8170
|
-
passkeyChallengeType: challengeType,
|
|
8163
|
+
const response = await this.request(AuthRoutes.signatureMessage, {
|
|
8164
|
+
payload: {
|
|
8165
|
+
clientAuthPubKey: deviceAuthKeys.publicKey,
|
|
8166
|
+
passkeyChallengeType: challengeType,
|
|
8167
|
+
},
|
|
8171
8168
|
});
|
|
8172
8169
|
const { signature, hashedMessage } = await this.cipher.sign({
|
|
8173
8170
|
message: response.message,
|
|
8174
8171
|
signingKey: deviceAuthKeys.privateKey,
|
|
8175
8172
|
});
|
|
8176
|
-
return Object.freeze(Object.assign({ signature,
|
|
8177
|
-
hashedMessage }
|
|
8173
|
+
return Object.freeze(Object.assign(Object.assign({}, response), { signature,
|
|
8174
|
+
hashedMessage }));
|
|
8178
8175
|
}
|
|
8179
8176
|
catch (error) {
|
|
8180
8177
|
logger.error('SDK::AuthService::getSignatureMessage::error', error);
|
|
@@ -8235,7 +8232,6 @@ class AuthService extends Base {
|
|
|
8235
8232
|
});
|
|
8236
8233
|
return authentication;
|
|
8237
8234
|
}
|
|
8238
|
-
// Re-throw the original error (likely WallabyError with proper structure)
|
|
8239
8235
|
throw error;
|
|
8240
8236
|
}
|
|
8241
8237
|
}
|
|
@@ -8448,7 +8444,6 @@ class AuthService extends Base {
|
|
|
8448
8444
|
clientAuthPubKey: deviceKeyPair.publicKey,
|
|
8449
8445
|
},
|
|
8450
8446
|
}).then(async (authResponse) => {
|
|
8451
|
-
console.log('SDK::AuthService::handleSignUpWithPassword::authResponse', authResponse);
|
|
8452
8447
|
const credentialsKeyPair = await this.cipher.getCredentialsKeyPair({
|
|
8453
8448
|
authType: this.deviceAuthType,
|
|
8454
8449
|
password: input.password,
|
|
@@ -8483,7 +8478,6 @@ class AuthService extends Base {
|
|
|
8483
8478
|
async getPasskeyCredentials() {
|
|
8484
8479
|
try {
|
|
8485
8480
|
const response = await this.api.auth.getPasskeyCredentials();
|
|
8486
|
-
console.log('SDK::AuthService::getPasskeyCredentials::response', response);
|
|
8487
8481
|
return response;
|
|
8488
8482
|
}
|
|
8489
8483
|
catch (error) {
|
|
@@ -8608,7 +8602,6 @@ class WalletHandlersService extends Base {
|
|
|
8608
8602
|
password: importWalletInput.authenticationOptions.password,
|
|
8609
8603
|
prfValue: importWalletInput.authenticationOptions.prfValue,
|
|
8610
8604
|
});
|
|
8611
|
-
console.log('importWalletRequest', importWalletRequest);
|
|
8612
8605
|
if (
|
|
8613
8606
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
8614
8607
|
importWalletRequest.encryptedSeed &&
|
|
@@ -9178,10 +9171,6 @@ class WalletService extends Base {
|
|
|
9178
9171
|
});
|
|
9179
9172
|
}
|
|
9180
9173
|
const parsedEncryptedDevicePrivateKey = safeJsonParse(encryptedDevicePrivateKey);
|
|
9181
|
-
console.log('credentials data', {
|
|
9182
|
-
password: input.authenticationOptions.password,
|
|
9183
|
-
salt: input.authenticationOptions.user.clientSalt,
|
|
9184
|
-
});
|
|
9185
9174
|
const credentialsKeyPair = await this.cipher.getCredentialsKeyPair({
|
|
9186
9175
|
authType: this.deviceAuthType,
|
|
9187
9176
|
password: input.authenticationOptions.password,
|
|
@@ -9567,12 +9556,14 @@ class WalletService extends Base {
|
|
|
9567
9556
|
privateKey: decryptedDevicePrivateKey,
|
|
9568
9557
|
});
|
|
9569
9558
|
const { message, signature } = signatureMessage;
|
|
9570
|
-
const response = await this.
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9559
|
+
const response = await this.request(WalletRoutes.convertMnemonicSeedPhrase, {
|
|
9560
|
+
payload: {
|
|
9561
|
+
reference,
|
|
9562
|
+
signature,
|
|
9563
|
+
message,
|
|
9564
|
+
clientAuthPubKey,
|
|
9565
|
+
encryptedSeed: wallabyBoundSeedPhrase,
|
|
9566
|
+
},
|
|
9576
9567
|
});
|
|
9577
9568
|
return response;
|
|
9578
9569
|
}
|
|
@@ -9725,7 +9716,7 @@ class WalletService extends Base {
|
|
|
9725
9716
|
// },
|
|
9726
9717
|
// },
|
|
9727
9718
|
// });
|
|
9728
|
-
const backUpResponse =
|
|
9719
|
+
const backUpResponse = await this.api.wallets.addNewDevice({
|
|
9729
9720
|
walletId: input.walletId,
|
|
9730
9721
|
message: signatureMessage.message,
|
|
9731
9722
|
signature: signatureMessage.signature,
|
|
@@ -9735,7 +9726,7 @@ class WalletService extends Base {
|
|
|
9735
9726
|
wrappingPublicKey: input.authenticationOptions.user.wallabyAuthPubKey,
|
|
9736
9727
|
type: exports.KeyTypeName.OwnerBackupDeviceShare,
|
|
9737
9728
|
},
|
|
9738
|
-
})
|
|
9729
|
+
});
|
|
9739
9730
|
const keyShares = [
|
|
9740
9731
|
backUpResponse.share, // this is the backup share that is now rewrapped with the new device public key.
|
|
9741
9732
|
{
|
|
@@ -9751,7 +9742,7 @@ class WalletService extends Base {
|
|
|
9751
9742
|
devicePrivateKey: decryptedDevicePrivateKey,
|
|
9752
9743
|
credentialsKeyPair,
|
|
9753
9744
|
});
|
|
9754
|
-
return { success: true, reference: backUpResponse.
|
|
9745
|
+
return { success: true, reference: backUpResponse.reference };
|
|
9755
9746
|
}
|
|
9756
9747
|
catch (error) {
|
|
9757
9748
|
logger.error('SDK::Wallet::backupKeyShare::error', error);
|
|
@@ -10806,7 +10797,7 @@ class Merchants extends Base {
|
|
|
10806
10797
|
const response = await this.request(MerchantsRoutes.getMerchantData, {
|
|
10807
10798
|
payload: { merchantId },
|
|
10808
10799
|
});
|
|
10809
|
-
return response;
|
|
10800
|
+
return response.merchant;
|
|
10810
10801
|
}
|
|
10811
10802
|
catch (error) {
|
|
10812
10803
|
logger.error('SDK::Merchants::list::error', error);
|
|
@@ -10821,7 +10812,6 @@ class Merchants extends Base {
|
|
|
10821
10812
|
async getAssets() {
|
|
10822
10813
|
try {
|
|
10823
10814
|
const response = await this.request(MerchantsRoutes.getAssets);
|
|
10824
|
-
console.log('SDK::Merchants::getAssets::response', response);
|
|
10825
10815
|
return response.merchantAssets;
|
|
10826
10816
|
}
|
|
10827
10817
|
catch (error) {
|
|
@@ -11199,7 +11189,11 @@ class Transactions extends Base {
|
|
|
11199
11189
|
});
|
|
11200
11190
|
}
|
|
11201
11191
|
else {
|
|
11202
|
-
throw new
|
|
11192
|
+
throw new WallabyError({
|
|
11193
|
+
message: 'No valid seed option found on this device.',
|
|
11194
|
+
statusCode: 400,
|
|
11195
|
+
errorCode: 'sdk_no_valid_seed_option',
|
|
11196
|
+
});
|
|
11203
11197
|
}
|
|
11204
11198
|
return transferResponse;
|
|
11205
11199
|
}
|
|
@@ -11279,16 +11273,81 @@ class Transactions extends Base {
|
|
|
11279
11273
|
throw error;
|
|
11280
11274
|
}
|
|
11281
11275
|
}
|
|
11276
|
+
/**
|
|
11277
|
+
*
|
|
11278
|
+
* @public
|
|
11279
|
+
* @param {string} walletId
|
|
11280
|
+
* @param {BlockchainName} chainName
|
|
11281
|
+
* @returns {Promise<GetPendingTransactionsResponse>}
|
|
11282
|
+
*/
|
|
11283
|
+
async getPendingTransactions({ walletId, chainName }) {
|
|
11284
|
+
try {
|
|
11285
|
+
const response = await this.request(TransactionsRoutes.getPendingTransactions, {
|
|
11286
|
+
queryParams: {
|
|
11287
|
+
walletId,
|
|
11288
|
+
chainName,
|
|
11289
|
+
},
|
|
11290
|
+
});
|
|
11291
|
+
return response;
|
|
11292
|
+
}
|
|
11293
|
+
catch (error) {
|
|
11294
|
+
logger.error('SDK::Transactions::getPendingTransactions::error', error);
|
|
11295
|
+
throw error;
|
|
11296
|
+
}
|
|
11297
|
+
}
|
|
11298
|
+
/**
|
|
11299
|
+
*
|
|
11300
|
+
* @public
|
|
11301
|
+
* @param {string} id
|
|
11302
|
+
* @param {ResolvePendingTransactionDecision} choice
|
|
11303
|
+
* @param {number} symbol
|
|
11304
|
+
* @param {string} chainName
|
|
11305
|
+
* @param {string} walletId
|
|
11306
|
+
* @param {AuthResponse} authenticationOptions
|
|
11307
|
+
* @returns {ResolvePendingTransactionResponse}
|
|
11308
|
+
*/
|
|
11309
|
+
async resolvePendingTransaction({ id, choice, symbol, chainName, walletId, authenticationOptions, }) {
|
|
11310
|
+
try {
|
|
11311
|
+
// Only attempt migration if we have password auth and V2 storage might be incomplete
|
|
11312
|
+
if (this.deviceAuthType === exports.AuthType.Password && authenticationOptions.password) {
|
|
11313
|
+
try {
|
|
11314
|
+
await this.walletService.handleUpdateToV2({
|
|
11315
|
+
password: authenticationOptions.password,
|
|
11316
|
+
walletId: walletId,
|
|
11317
|
+
});
|
|
11318
|
+
}
|
|
11319
|
+
catch (error) {
|
|
11320
|
+
// If migration fails, log it but don't block the transaction
|
|
11321
|
+
// The original transaction logic will handle missing storage items appropriately
|
|
11322
|
+
logger.debug('Migration to V2 failed, continuing with original flow:', error);
|
|
11323
|
+
}
|
|
11324
|
+
}
|
|
11325
|
+
const { deviceAuthPublicKey, signatureMessage, readyForTransportSeedPhrase, sharesEncryptedWithWallabyPubKey, hasShares } = await this.prepareTransactionAuth(authenticationOptions, walletId);
|
|
11326
|
+
if (!readyForTransportSeedPhrase && !hasShares) {
|
|
11327
|
+
throw new Error('No valid seed option found on this device.');
|
|
11328
|
+
}
|
|
11329
|
+
const confirmPendingTransactionResponse = await this.request(TransactionsRoutes.confirmPendingTransaction, {
|
|
11330
|
+
payload: Object.assign(Object.assign({}, signatureMessage), { clientAuthPubKey: deviceAuthPublicKey, encryptedShares: sharesEncryptedWithWallabyPubKey, encryptedSeed: readyForTransportSeedPhrase, id,
|
|
11331
|
+
choice,
|
|
11332
|
+
symbol,
|
|
11333
|
+
chainName }),
|
|
11334
|
+
});
|
|
11335
|
+
return confirmPendingTransactionResponse;
|
|
11336
|
+
}
|
|
11337
|
+
catch (error) {
|
|
11338
|
+
logger.error('SDK::Transactions::transfer::error', error);
|
|
11339
|
+
throw error;
|
|
11340
|
+
}
|
|
11341
|
+
}
|
|
11282
11342
|
/**
|
|
11283
11343
|
* Prepares authentication data and encrypted payload for transaction requests
|
|
11284
11344
|
* @private
|
|
11285
11345
|
*/
|
|
11286
11346
|
async prepareTransactionAuth(authenticationOptions, walletId) {
|
|
11287
|
-
const { password, prfValue, user } = authenticationOptions;
|
|
11347
|
+
const { password, prfValue, user, clientSalt: authClientSalt } = authenticationOptions;
|
|
11288
11348
|
const encryptedDevicePrivateKey = await this.localStorageService.fetch(exports.LocalStorageItems.EncryptedDevicePrivateKey, {
|
|
11289
11349
|
walletId,
|
|
11290
11350
|
});
|
|
11291
|
-
console.log('user_in_prepare_tx_auth', user);
|
|
11292
11351
|
if (!encryptedDevicePrivateKey) {
|
|
11293
11352
|
throw new WallabyError({
|
|
11294
11353
|
message: 'No private key was found on this device.',
|
|
@@ -11297,11 +11356,12 @@ class Transactions extends Base {
|
|
|
11297
11356
|
});
|
|
11298
11357
|
}
|
|
11299
11358
|
// Get credentials key pair for device private key decryption
|
|
11359
|
+
const clientSalt = authClientSalt || user.clientSalt;
|
|
11300
11360
|
const credentialsKeyPair = await this.cipher.getCredentialsKeyPair({
|
|
11301
11361
|
authType: this.deviceAuthType,
|
|
11302
11362
|
password,
|
|
11303
11363
|
prfValue,
|
|
11304
|
-
salt:
|
|
11364
|
+
salt: clientSalt,
|
|
11305
11365
|
});
|
|
11306
11366
|
// Decrypt device private key
|
|
11307
11367
|
const decryptedDevicePrivateKey = await this.cipher.decrypt({
|
|
@@ -11346,7 +11406,7 @@ class Transactions extends Base {
|
|
|
11346
11406
|
authType: this.deviceAuthType,
|
|
11347
11407
|
password,
|
|
11348
11408
|
prfValue,
|
|
11349
|
-
salt:
|
|
11409
|
+
salt: clientSalt,
|
|
11350
11410
|
},
|
|
11351
11411
|
});
|
|
11352
11412
|
}
|
|
@@ -11361,7 +11421,7 @@ class Transactions extends Base {
|
|
|
11361
11421
|
authType: this.deviceAuthType,
|
|
11362
11422
|
password,
|
|
11363
11423
|
prfValue,
|
|
11364
|
-
salt:
|
|
11424
|
+
salt: clientSalt,
|
|
11365
11425
|
},
|
|
11366
11426
|
});
|
|
11367
11427
|
sharesEncryptedWithWallabyPubKey.push(readyForTransportShare);
|
|
@@ -11387,6 +11447,12 @@ __decorate([
|
|
|
11387
11447
|
__metadata("design:paramtypes", [Object]),
|
|
11388
11448
|
__metadata("design:returntype", Promise)
|
|
11389
11449
|
], Transactions.prototype, "createAllowance", null);
|
|
11450
|
+
__decorate([
|
|
11451
|
+
WithLock('confirmPendingTransaction'),
|
|
11452
|
+
__metadata("design:type", Function),
|
|
11453
|
+
__metadata("design:paramtypes", [Object]),
|
|
11454
|
+
__metadata("design:returntype", Promise)
|
|
11455
|
+
], Transactions.prototype, "resolvePendingTransaction", null);
|
|
11390
11456
|
|
|
11391
11457
|
/**
|
|
11392
11458
|
* The Wallaby SDK client. This class is the main entry point into Wallaby's
|