wallaby-cash 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generated/api.d.ts +66 -288
- package/dist/index.cjs.js +34 -37
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +34 -38
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +34 -38
- package/dist/index.js.map +1 -1
- package/dist/lib/transactions/index.d.ts +2 -3
- package/dist/lib/wallet/wallet-handlers.service.d.ts +2 -2
- package/dist/package.json +1 -1
- package/dist/types/common.d.ts +1 -0
- package/dist/types/transactions.d.ts +8 -9
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -98,6 +98,14 @@ exports.TransportEnum = void 0;
|
|
|
98
98
|
TransportEnum["Hybrid"] = "hybrid";
|
|
99
99
|
})(exports.TransportEnum || (exports.TransportEnum = {}));
|
|
100
100
|
|
|
101
|
+
const isWallabyError = (obj) => {
|
|
102
|
+
return (!!obj &&
|
|
103
|
+
typeof obj === 'object' &&
|
|
104
|
+
'statusCode' in obj &&
|
|
105
|
+
'message' in obj &&
|
|
106
|
+
typeof obj.statusCode === 'number' &&
|
|
107
|
+
(obj.statusCode >= 400 || 'error' in obj));
|
|
108
|
+
};
|
|
101
109
|
exports.UserAssetSource = void 0;
|
|
102
110
|
(function (UserAssetSource) {
|
|
103
111
|
UserAssetSource["Merchant"] = "merchant";
|
|
@@ -7018,7 +7026,7 @@ class Base {
|
|
|
7018
7026
|
* @returns Promise of <T> where T is the type of the response.
|
|
7019
7027
|
*/
|
|
7020
7028
|
async request(route, options) {
|
|
7021
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
7029
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
7022
7030
|
try {
|
|
7023
7031
|
let url;
|
|
7024
7032
|
if (typeof route.fullPath !== 'string') {
|
|
@@ -7076,10 +7084,10 @@ class Base {
|
|
|
7076
7084
|
if (((_e = error.response) === null || _e === void 0 ? void 0 : _e.data.errorCode) && error.response.data.errorCode === exports.ErrorResponseCodes.user_already_exists) {
|
|
7077
7085
|
return error.response.data;
|
|
7078
7086
|
}
|
|
7079
|
-
return Promise.reject(error.
|
|
7087
|
+
return Promise.reject((_f = error.response) === null || _f === void 0 ? void 0 : _f.data);
|
|
7080
7088
|
}
|
|
7081
7089
|
logger.error('SDK::Base::RequestMethod.Post::error', error);
|
|
7082
|
-
return Promise.reject(error);
|
|
7090
|
+
return Promise.reject(error.message);
|
|
7083
7091
|
}
|
|
7084
7092
|
case exports.RequestMethod.Put:
|
|
7085
7093
|
try {
|
|
@@ -7089,8 +7097,8 @@ class Base {
|
|
|
7089
7097
|
}
|
|
7090
7098
|
catch (error) {
|
|
7091
7099
|
if (error instanceof axios.AxiosError) {
|
|
7092
|
-
logger.error('SDK::Base::RequestMethod.Put::error', (
|
|
7093
|
-
return Promise.reject((
|
|
7100
|
+
logger.error('SDK::Base::RequestMethod.Put::error', (_g = error.response) === null || _g === void 0 ? void 0 : _g.data);
|
|
7101
|
+
return Promise.reject((_h = error.response) === null || _h === void 0 ? void 0 : _h.data);
|
|
7094
7102
|
}
|
|
7095
7103
|
return Promise.reject(error === null || error === void 0 ? void 0 : error.message);
|
|
7096
7104
|
}
|
|
@@ -7102,8 +7110,8 @@ class Base {
|
|
|
7102
7110
|
}
|
|
7103
7111
|
catch (error) {
|
|
7104
7112
|
if (error instanceof axios.AxiosError) {
|
|
7105
|
-
logger.error('SDK::Base::RequestMethod.Put::AxiosError', (
|
|
7106
|
-
return Promise.reject((
|
|
7113
|
+
logger.error('SDK::Base::RequestMethod.Put::AxiosError', (_j = error.response) === null || _j === void 0 ? void 0 : _j.data);
|
|
7114
|
+
return Promise.reject((_k = error.response) === null || _k === void 0 ? void 0 : _k.data);
|
|
7107
7115
|
}
|
|
7108
7116
|
return Promise.reject(error === null || error === void 0 ? void 0 : error.message);
|
|
7109
7117
|
}
|
|
@@ -8424,14 +8432,6 @@ class AuthService extends Base {
|
|
|
8424
8432
|
message: 'Password must be at least 8 characters long',
|
|
8425
8433
|
};
|
|
8426
8434
|
}
|
|
8427
|
-
// Check if password contains at least 1 number
|
|
8428
|
-
const hasNumber = /\d/.test(password);
|
|
8429
|
-
if (!hasNumber) {
|
|
8430
|
-
return {
|
|
8431
|
-
valid: false,
|
|
8432
|
-
message: 'Password must contain at least 1 number',
|
|
8433
|
-
};
|
|
8434
|
-
}
|
|
8435
8435
|
// Check maximum length (128 characters) to avoid DDoS attacks
|
|
8436
8436
|
if (password.length > 128) {
|
|
8437
8437
|
return {
|
|
@@ -10944,9 +10944,9 @@ class Transactions extends Base {
|
|
|
10944
10944
|
throw new Error('No valid seed option found on this device.');
|
|
10945
10945
|
}
|
|
10946
10946
|
if (!transferResponse ||
|
|
10947
|
-
transferResponse
|
|
10947
|
+
isWallabyError(transferResponse) ||
|
|
10948
10948
|
(typeof transferResponse === 'object' && Object.keys(transferResponse).length === 0)) {
|
|
10949
|
-
throw new Error(transferResponse
|
|
10949
|
+
throw new Error(isWallabyError(transferResponse) ? transferResponse.error : 'Unknown error');
|
|
10950
10950
|
}
|
|
10951
10951
|
return transferResponse;
|
|
10952
10952
|
}
|
|
@@ -10992,30 +10992,26 @@ class Transactions extends Base {
|
|
|
10992
10992
|
logger.debug('Migration to V2 failed, continuing with original flow:', error);
|
|
10993
10993
|
}
|
|
10994
10994
|
}
|
|
10995
|
-
const { deviceAuthPublicKey, signatureMessage, readyForTransportSeedPhrase } = await this.prepareTransactionAuth(authenticationOptions, walletId);
|
|
10995
|
+
const { deviceAuthPublicKey, signatureMessage, readyForTransportSeedPhrase, sharesEncryptedWithWallabyPubKey, hasShares } = await this.prepareTransactionAuth(authenticationOptions, walletId);
|
|
10996
10996
|
const { message, signature } = signatureMessage;
|
|
10997
|
-
// Create allowance
|
|
10998
|
-
if (!readyForTransportSeedPhrase) {
|
|
10999
|
-
throw new Error('
|
|
10997
|
+
// Create allowance requires either a seed phrase or key shares
|
|
10998
|
+
if (!readyForTransportSeedPhrase && !hasShares) {
|
|
10999
|
+
throw new Error('No valid seed option found on this device.');
|
|
11000
11000
|
}
|
|
11001
|
+
const payload = Object.assign({ message,
|
|
11002
|
+
walletId,
|
|
11003
|
+
authenticationOptions,
|
|
11004
|
+
signature, clientAuthPubKey: deviceAuthPublicKey, ownerAddress,
|
|
11005
|
+
spenderAddress,
|
|
11006
|
+
chainName,
|
|
11007
|
+
assetSymbol,
|
|
11008
|
+
amount,
|
|
11009
|
+
assetId, contractAddress: contractAddress !== null && contractAddress !== void 0 ? contractAddress : suiObjectId, reference,
|
|
11010
|
+
memo }, (hasShares ? { encryptedShares: sharesEncryptedWithWallabyPubKey } : { encryptedSeed: readyForTransportSeedPhrase }));
|
|
11001
11011
|
const response = await this.request(TransactionsRoutes.createAllowance, {
|
|
11002
|
-
payload
|
|
11003
|
-
message,
|
|
11004
|
-
signature,
|
|
11005
|
-
clientAuthPubKey: deviceAuthPublicKey,
|
|
11006
|
-
encryptedSeed: readyForTransportSeedPhrase,
|
|
11007
|
-
ownerAddress,
|
|
11008
|
-
spenderAddress,
|
|
11009
|
-
chainName,
|
|
11010
|
-
assetSymbol,
|
|
11011
|
-
amount,
|
|
11012
|
-
assetId,
|
|
11013
|
-
contractAddress: contractAddress !== null && contractAddress !== void 0 ? contractAddress : suiObjectId,
|
|
11014
|
-
reference,
|
|
11015
|
-
memo,
|
|
11016
|
-
},
|
|
11012
|
+
payload,
|
|
11017
11013
|
});
|
|
11018
|
-
if (response
|
|
11014
|
+
if (isWallabyError(response)) {
|
|
11019
11015
|
throw new Error(response.error);
|
|
11020
11016
|
}
|
|
11021
11017
|
return response;
|
|
@@ -11183,6 +11179,7 @@ exports.createIdentity = createIdentity;
|
|
|
11183
11179
|
exports.decryptWithPrivateKey = decryptWithPrivateKey;
|
|
11184
11180
|
exports.encryptWithPublicKey = encryptWithPublicKey;
|
|
11185
11181
|
exports.hash = hash;
|
|
11182
|
+
exports.isWallabyError = isWallabyError;
|
|
11186
11183
|
exports.keccak256 = keccak256;
|
|
11187
11184
|
exports.publicKeyByPrivateKey = publicKeyByPrivateKey;
|
|
11188
11185
|
exports.recoverPublicKey = recoverPublicKey;
|