wallaby-cash 1.6.1 → 1.7.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/README.md +6 -1
- package/dist/base.d.ts +4 -4
- package/dist/documentation/auth.doc.d.ts +8 -8
- package/dist/documentation/merchants.doc.d.ts +3 -3
- package/dist/documentation/system.doc.d.ts +3 -3
- package/dist/documentation/wallet.doc.d.ts +19 -19
- package/dist/index.cjs.js +110 -120
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.esm.js +111 -121
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +111 -121
- package/dist/index.js.map +1 -1
- package/dist/lib/auth/index.d.ts +6 -6
- package/dist/lib/merchants/index.d.ts +3 -3
- package/dist/lib/system/index.d.ts +3 -3
- package/dist/lib/utils/storage.service.d.ts +1 -1
- package/dist/lib/wallet/index.d.ts +20 -22
- package/dist/routes/merchants.d.ts +2 -2
- package/dist/tests/auth.spec.d.ts +1 -0
- package/dist/tests/create-identity.spec.d.ts +1 -0
- package/dist/tests/encryption.spec.d.ts +1 -0
- package/dist/tests/hash.spec.d.ts +1 -0
- package/dist/tests/merchants.spec.d.ts +1 -0
- package/dist/tests/object-to-params.spec.d.ts +1 -0
- package/dist/tests/public-key-by-private-key.spec.d.ts +1 -0
- package/dist/tests/recovery.spec.d.ts +1 -0
- package/dist/tests/sign.spec.d.ts +1 -0
- package/dist/tests/system.spec.d.ts +1 -0
- package/dist/tests/utils.spec.d.ts +1 -0
- package/dist/tests/wallet.spec.d.ts +1 -0
- package/dist/types/base.d.ts +18 -16
- package/dist/types/common.d.ts +1 -0
- package/dist/types/storage.d.ts +2 -2
- package/dist/types/wallet.d.ts +3 -1
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# Getting started
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
|
+
|
|
4
5
|
[](https://badge.fury.io/js/wallaby-cash)
|
|
5
6
|
|
|
6
7
|
The SDK leverages Wallaby API as a gateway to web3 and the blockchain.
|
|
7
8
|
|
|
8
9
|
The SDK currently supports the following blockchains:
|
|
10
|
+
|
|
9
11
|
- Algorand
|
|
10
12
|
- Avalanche
|
|
11
13
|
- Bitcoin
|
|
@@ -13,11 +15,13 @@ The SDK currently supports the following blockchains:
|
|
|
13
15
|
- Polygon
|
|
14
16
|
|
|
15
17
|
## Install the SDK
|
|
18
|
+
|
|
16
19
|
```javascript
|
|
17
20
|
npm install wallaby-cash
|
|
18
21
|
```
|
|
19
22
|
|
|
20
23
|
## Client Initialization
|
|
24
|
+
|
|
21
25
|
After installing the library, you can then import and use the SDK.
|
|
22
26
|
|
|
23
27
|
Some configuration params are optional depending on the endpoint.
|
|
@@ -25,7 +29,7 @@ Some configuration params are optional depending on the endpoint.
|
|
|
25
29
|
|
|
26
30
|
To initialize the Wallaby client, simply import the Wallaby class and pass the config object.
|
|
27
31
|
|
|
28
|
-
To understand how to generate and use the `clientAuthToken` you can refer to authentication docs [here](./authentication/overview#how-to-generate-the-client-jwt).
|
|
32
|
+
To understand how to generate and use the `clientAuthToken` you can refer to authentication docs [here](./authentication/overview#how-to-generate-the-client-jwt).
|
|
29
33
|
|
|
30
34
|
**Example:**
|
|
31
35
|
|
|
@@ -57,6 +61,7 @@ wallaby.system.getSupportedBlockchains()
|
|
|
57
61
|
**Required packages and functions used:**
|
|
58
62
|
|
|
59
63
|
- [eth-crypto: v2.6.0 (Latest)](https://www.npmjs.com/package/eth-crypto)
|
|
64
|
+
|
|
60
65
|
- `createIdentity`: Generates public/private key pair. Which are called `clientAuthPubKey` and `clientAuthPrivKey` in wallaby. _To differentiate them from wallaby’s key pair. Which are called `wallabyAuthPubKey` and `wallabyAuthPrivKey`_
|
|
61
66
|
- `hash`: It uses `keccak256` function to hash the message string coming from wallaby.
|
|
62
67
|
- `sign`: It generates a signature from a hashed message (with client public key) and the client private key
|
package/dist/base.d.ts
CHANGED
|
@@ -4,15 +4,15 @@ import { LocalStorage } from './types/storage';
|
|
|
4
4
|
export declare abstract class Base {
|
|
5
5
|
private apiKey;
|
|
6
6
|
private baseUrl;
|
|
7
|
-
private jwt
|
|
7
|
+
private jwt?;
|
|
8
8
|
private clientAuthToken;
|
|
9
9
|
userId: string;
|
|
10
10
|
options?: WallabyConfigOptions;
|
|
11
11
|
constructor(config: WallabyConfig);
|
|
12
12
|
/**
|
|
13
|
-
|
|
13
|
+
* This library uses `localStorage` as the default storage.
|
|
14
14
|
* If you want to use a different storage, you can pass it in the options object of the Wallaby config.
|
|
15
|
-
|
|
15
|
+
* storage: new CustomStorage()
|
|
16
16
|
* {
|
|
17
17
|
* }
|
|
18
18
|
*/
|
|
@@ -31,7 +31,7 @@ export declare abstract class Base {
|
|
|
31
31
|
get storageService(): StorageService;
|
|
32
32
|
/**
|
|
33
33
|
*
|
|
34
|
-
|
|
34
|
+
* This is the main request method that is used to make requests to the Wallaby API.
|
|
35
35
|
* @param { RequestRoute } route full route object to the request endpoint.
|
|
36
36
|
* @param { RequestOptions } options Extends the `RequestInit` interface to include a payload and queryParams.
|
|
37
37
|
* @returns Promise of <T> where T is the type of the response.
|
|
@@ -3,7 +3,7 @@ import { SignatureMessageResponse, AuthRequest, AuthResponse, WallabyConfig, Cli
|
|
|
3
3
|
export declare class Auth extends Base {
|
|
4
4
|
constructor(config: WallabyConfig);
|
|
5
5
|
/**
|
|
6
|
-
|
|
6
|
+
* Authenticates a user by either signing them in or signing them up based on the presence of existing credentials.
|
|
7
7
|
*
|
|
8
8
|
* @param { string } password - The user's password.
|
|
9
9
|
* @returns {Promise<AuthResponse>} - A promise that resolves to the authentication response.
|
|
@@ -12,7 +12,7 @@ export declare class Auth extends Base {
|
|
|
12
12
|
/**
|
|
13
13
|
*
|
|
14
14
|
* @public
|
|
15
|
-
|
|
15
|
+
* The returned message will be used to authorize the user to sign operations
|
|
16
16
|
* @param {string} password
|
|
17
17
|
* @returns {SignatureMessageResponse} The returned message will be used for sign up and sign in signature
|
|
18
18
|
*/
|
|
@@ -20,7 +20,7 @@ export declare class Auth extends Base {
|
|
|
20
20
|
/**
|
|
21
21
|
*
|
|
22
22
|
* @public
|
|
23
|
-
|
|
23
|
+
* Users will be able to sign in by providing a signature and message. Use the same key pair used on sign up'
|
|
24
24
|
* @param { string } password
|
|
25
25
|
* @param { string } firstName
|
|
26
26
|
* @param { string } lastName
|
|
@@ -31,7 +31,7 @@ export declare class Auth extends Base {
|
|
|
31
31
|
/**
|
|
32
32
|
*
|
|
33
33
|
* @public
|
|
34
|
-
|
|
34
|
+
* Users will be able to sign in by providing a signature and message, the device auth public key and their signature.
|
|
35
35
|
* @param { string } password password is used decrypt the device auth private key.
|
|
36
36
|
* @returns { AuthResponse | undefined } Once the user is signed in, the response will contain the user object and the access token.
|
|
37
37
|
*/
|
|
@@ -39,18 +39,18 @@ export declare class Auth extends Base {
|
|
|
39
39
|
/**
|
|
40
40
|
*
|
|
41
41
|
* @public
|
|
42
|
-
|
|
42
|
+
* Refreshes the access token stored in local storage.
|
|
43
43
|
* @returns {string} The new access token
|
|
44
44
|
*/
|
|
45
45
|
refreshAccessToken(): Promise<RefreshAccessTokenResponse | undefined>;
|
|
46
46
|
/**
|
|
47
|
-
|
|
47
|
+
* This method is used to refresh the device auth key pair.
|
|
48
48
|
* @param {string} password
|
|
49
49
|
* @returns {User} User object
|
|
50
50
|
*/
|
|
51
|
-
updateClientAuthPubKey({ password
|
|
51
|
+
updateClientAuthPubKey({ password }: Pick<ClientAuthPubKeyRequest, 'password'>): Promise<ClientAuthPubKeyResponse | undefined>;
|
|
52
52
|
/**
|
|
53
|
-
|
|
53
|
+
* The user salt is used to double encrypt the seed phrase before being stored
|
|
54
54
|
* in local storage.
|
|
55
55
|
* @returns {string} Returns user's salt that is generated by Wallaby system
|
|
56
56
|
*/
|
|
@@ -6,14 +6,14 @@ export declare class Merchants extends Base {
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
8
|
* @public
|
|
9
|
-
|
|
9
|
+
* List of all merchants in the system
|
|
10
10
|
* @returns { ListMerchantsResponse } Array of all merchants
|
|
11
11
|
*/
|
|
12
12
|
list(): Promise<ListMerchantsResponse>;
|
|
13
13
|
/**
|
|
14
14
|
*
|
|
15
15
|
* @public
|
|
16
|
-
|
|
16
|
+
* Allows to create a new merchant
|
|
17
17
|
* @returns { Merchant } Merchant data
|
|
18
18
|
*/
|
|
19
19
|
create({ name }: {
|
|
@@ -22,7 +22,7 @@ export declare class Merchants extends Base {
|
|
|
22
22
|
/**
|
|
23
23
|
*
|
|
24
24
|
* @public
|
|
25
|
-
|
|
25
|
+
* Allows to update merchant data
|
|
26
26
|
* @returns { Merchant } Merchant data
|
|
27
27
|
*/
|
|
28
28
|
update({ merchantId, name, status }: {
|
|
@@ -4,14 +4,14 @@ export declare class System extends Base {
|
|
|
4
4
|
constructor(config: WallabyConfig);
|
|
5
5
|
/**
|
|
6
6
|
* @public
|
|
7
|
-
|
|
7
|
+
* Get all supported chains
|
|
8
8
|
* @param {null}
|
|
9
9
|
* @returns {Array<Blockchain>} Array of supported chains
|
|
10
10
|
*/
|
|
11
11
|
getSupportedBlockchains(): Promise<Array<Blockchain> | undefined>;
|
|
12
12
|
/**
|
|
13
13
|
* @public
|
|
14
|
-
|
|
14
|
+
* Get all supported assets configuration
|
|
15
15
|
* @param {null}
|
|
16
16
|
* @returns {Array<AssetConfig>} Array of supported tokens
|
|
17
17
|
*/
|
|
@@ -24,7 +24,7 @@ export declare class System extends Base {
|
|
|
24
24
|
getUserData(userId: string): Promise<User | undefined>;
|
|
25
25
|
/**
|
|
26
26
|
* @public
|
|
27
|
-
|
|
27
|
+
* This returns essential data by the external user ID provided at sign up.
|
|
28
28
|
* @param {string} externalUserId
|
|
29
29
|
* @returns {User} Returns user public data
|
|
30
30
|
*/
|
|
@@ -6,13 +6,13 @@ export declare class Wallet extends Base {
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
8
|
* @public
|
|
9
|
-
|
|
9
|
+
* Retrieve the user's mnemonic seed phrases
|
|
10
10
|
* @param password User's wallet password
|
|
11
11
|
* @returns { Promise<{standardSeedPhrase: string, algorandSeedPhrase: string}> }
|
|
12
12
|
* @deprecated This function has been renamed to `export` and will be removed in the next major release.
|
|
13
13
|
* It returns the user's standard (24 words) and algorand (25 words) seed phrases
|
|
14
14
|
*/
|
|
15
|
-
mnemonicSeedPhrase({ password
|
|
15
|
+
mnemonicSeedPhrase({ password }: {
|
|
16
16
|
password: string;
|
|
17
17
|
}): Promise<{
|
|
18
18
|
standardSeedPhrase: string;
|
|
@@ -21,18 +21,18 @@ export declare class Wallet extends Base {
|
|
|
21
21
|
/**
|
|
22
22
|
*
|
|
23
23
|
* @public
|
|
24
|
-
|
|
24
|
+
* Create a newly fresh wallet, returns asset list and encrypted seedPhrase
|
|
25
25
|
* @param { string } address Wallet address
|
|
26
26
|
* @param { string } symbol Token symbol
|
|
27
27
|
* @param { BlockchainName } chainName the chain name enum. i.e. 'ETHEREUM', 'BITCOIN'
|
|
28
28
|
* @returns { CreateWalletResponse } The wallet has been created successfully
|
|
29
29
|
*/
|
|
30
|
-
getTokenBalance({ address, symbol, tokenStandard, chainName
|
|
30
|
+
getTokenBalance({ address, symbol, tokenStandard, chainName }: TokenBalanceRequest): Promise<TokenBalanceResponse | undefined>;
|
|
31
31
|
/**
|
|
32
32
|
*
|
|
33
33
|
* @public
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
* Fetches the balances for a group of tokens in bulk.
|
|
35
|
+
* Takes an array of addresses and tokens and return their balances.
|
|
36
36
|
* @param { string } address Wallet address
|
|
37
37
|
* @param { string } symbol Token symbol
|
|
38
38
|
* @param { BlockchainName } chainName the chain name enum. i.e. 'ETHEREUM', 'BITCOIN'
|
|
@@ -42,7 +42,7 @@ export declare class Wallet extends Base {
|
|
|
42
42
|
/**
|
|
43
43
|
*
|
|
44
44
|
* @public
|
|
45
|
-
|
|
45
|
+
* Fetches the balances for all tokens in a specific wallet.
|
|
46
46
|
* @param { string } walletId Wallet address
|
|
47
47
|
* @returns { TokenBalanceResponse[] } Returns an array of the requested tokens balances.
|
|
48
48
|
*/
|
|
@@ -52,7 +52,7 @@ export declare class Wallet extends Base {
|
|
|
52
52
|
/**
|
|
53
53
|
*`
|
|
54
54
|
* @public
|
|
55
|
-
|
|
55
|
+
* Create a newly fresh wallet, returns asset list and encrypted seedPhrase
|
|
56
56
|
* @param {string} password The user's chosen password
|
|
57
57
|
* @param {string} firstName The user's first name
|
|
58
58
|
* @param {string} lastName The user's last name
|
|
@@ -63,7 +63,7 @@ export declare class Wallet extends Base {
|
|
|
63
63
|
/**
|
|
64
64
|
*
|
|
65
65
|
* @public
|
|
66
|
-
|
|
66
|
+
* Creates a fresh wallet and always signs user up with using a new external user ID
|
|
67
67
|
* @param {string} password The user's chosen password
|
|
68
68
|
* @returns {CreateWalletResponse} Assets list and encrypted seedPhrase.
|
|
69
69
|
*/
|
|
@@ -71,7 +71,7 @@ export declare class Wallet extends Base {
|
|
|
71
71
|
/**
|
|
72
72
|
*
|
|
73
73
|
* @public
|
|
74
|
-
|
|
74
|
+
* Import an existing wallet, returns asset list and encrypted seedPhrase
|
|
75
75
|
* @param {string} password The user's chosen password
|
|
76
76
|
* @param {string} seedPhrase The user's seed phrase
|
|
77
77
|
* @returns {ImportWalletResponse} The wallet has been imported successfully
|
|
@@ -81,7 +81,7 @@ export declare class Wallet extends Base {
|
|
|
81
81
|
/**
|
|
82
82
|
*
|
|
83
83
|
* @public
|
|
84
|
-
|
|
84
|
+
* Retrieve the user's mnemonic seed phrases
|
|
85
85
|
* @param password User's wallet password
|
|
86
86
|
* @returns { Promise<{standardSeedPhrase: string, algorandSeedPhrase: string}> }
|
|
87
87
|
* It returns the user's standard (24 words) and algorand (25 words) seed phrases
|
|
@@ -95,14 +95,14 @@ export declare class Wallet extends Base {
|
|
|
95
95
|
/**
|
|
96
96
|
*
|
|
97
97
|
* @public
|
|
98
|
-
|
|
98
|
+
* Removes all Wallaby data from local storage.
|
|
99
99
|
* @returns {Boolean}
|
|
100
100
|
*/
|
|
101
|
-
clearDevice(): Promise<
|
|
101
|
+
clearDevice(): Promise<boolean>;
|
|
102
102
|
/**
|
|
103
103
|
*
|
|
104
104
|
* @public
|
|
105
|
-
|
|
105
|
+
* Convert BIP39 Standard seed phrase to Algorand fixed 25 words mnemonic phrase
|
|
106
106
|
* @param {string} password
|
|
107
107
|
* @param {Encrypted} encryptedSeedPhrase It needs to be encypted using wallabyAuthPubKey
|
|
108
108
|
* @returns {ConvertMnemonicSeedPhraseResponse} The mnemonic seed phrase has been converted successfully.
|
|
@@ -111,7 +111,7 @@ export declare class Wallet extends Base {
|
|
|
111
111
|
/**
|
|
112
112
|
*
|
|
113
113
|
* @public
|
|
114
|
-
|
|
114
|
+
* Recover the lost wallet and its assets.
|
|
115
115
|
* @param {string} newPassword User need to set a new password while recovering the wallet
|
|
116
116
|
* @param {string} seedPhrase It needs to be encypted using wallabyAuthPubKey
|
|
117
117
|
* @returns {RecoverWalletResponse} The wallet has been recovered successfully.
|
|
@@ -119,7 +119,7 @@ export declare class Wallet extends Base {
|
|
|
119
119
|
recover({ newPassword, seedPhrase, }: Omit<RecoverWalletRequest, 'clientAuthPubKey'>): Promise<RecoverWalletResponse | undefined>;
|
|
120
120
|
/**
|
|
121
121
|
*
|
|
122
|
-
|
|
122
|
+
* Get all user assets across all wallets by specifying user id
|
|
123
123
|
* @param userId Wallaby's user ID
|
|
124
124
|
* @param queryOptions Optional query options
|
|
125
125
|
* @returns {UserWalletsResponse} Returns an array of user assets by specifying user id
|
|
@@ -127,14 +127,14 @@ export declare class Wallet extends Base {
|
|
|
127
127
|
getUserAssets({ userId, queryOptions }: QueryUserRequest): Promise<UserAssetsResponse | undefined>;
|
|
128
128
|
/**
|
|
129
129
|
*
|
|
130
|
-
|
|
130
|
+
* Get all wallets belonging to a user.
|
|
131
131
|
* @param userId Wallaby's user ID
|
|
132
132
|
* @returns {UserWalletsResponse} Returns an array of user wallets by specifying user ID
|
|
133
133
|
*/
|
|
134
134
|
getUserWallets({ userId, queryOptions }: QueryUserRequest): Promise<UserWalletsResponse | undefined>;
|
|
135
135
|
/**
|
|
136
136
|
*
|
|
137
|
-
|
|
137
|
+
* Get all assets that exist in a certain wallet, by specifying a wallet ID
|
|
138
138
|
* @param walletId Wallaby's wallet ID
|
|
139
139
|
* @param { BasicQueryOptions } queryOptions Optional query options
|
|
140
140
|
* @returns { WalletAssetsResponse } Returns all assets belonging in a certain wallet ID
|
|
@@ -143,7 +143,7 @@ export declare class Wallet extends Base {
|
|
|
143
143
|
/**
|
|
144
144
|
*
|
|
145
145
|
* @public
|
|
146
|
-
|
|
146
|
+
* Initiate creation for a new multisig asset, by specifying participants and the threshold
|
|
147
147
|
* @param {string} assetSymbol Asset symbol
|
|
148
148
|
* @param {string} tokenType Optional value only used when dealing with non native assets (aka tokens), If native asset, keep the field empty
|
|
149
149
|
* @param {number} threshold The threshold is the number of signatures required to sign a transaction
|