wallaby-cash 2.2.12 → 2.2.13
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 +69 -0
- package/dist/generated/api.d.ts +3 -3
- package/dist/helpers/base64.base.d.ts +12 -0
- package/dist/helpers/base64.d.ts +6 -0
- package/dist/index.cjs.js +100 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +100 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +100 -12
- package/dist/index.js.map +1 -1
- package/dist/lib/auth/authenticator.d.ts +3 -3
- package/dist/lib/auth/passkey.model.d.ts +10 -3
- package/dist/lib/auth/passkey.service.base.d.ts +76 -0
- package/dist/lib/auth/passkey.service.d.ts +1 -76
- package/dist/lib/utils/constants.d.ts +1 -1
- package/dist/lib/wallet/wallet-data.service.d.ts +1 -1
- package/dist/package.json +15 -3
- package/dist/types/auth.d.ts +152 -4
- package/package.json +15 -3
package/README.md
CHANGED
|
@@ -32,6 +32,75 @@ The SDK currently supports the following blockchains:
|
|
|
32
32
|
npm install wallaby-cash@latest
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
## React Native migration plan (updated for v2.2.7)
|
|
36
|
+
|
|
37
|
+
This plan reflects the current SDK package layout and native passkey support.
|
|
38
|
+
|
|
39
|
+
### 1) Upgrade the SDK
|
|
40
|
+
|
|
41
|
+
- Use `wallaby-cash@latest` (or your pinned `file:`/git tag) so Metro can resolve the `react-native` entrypoint.
|
|
42
|
+
- If you are rolling out gradually, keep the old version in a feature-flagged branch and verify passkey flows before flipping users.
|
|
43
|
+
|
|
44
|
+
### 2) Provide a secure storage adapter
|
|
45
|
+
|
|
46
|
+
React Native must supply a storage implementation (async is supported). Any adapter that implements
|
|
47
|
+
`getItem`/`setItem`/`removeItem` or their `*Async` equivalents will work.
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
import * as Keychain from 'react-native-keychain';
|
|
51
|
+
import { Wallaby } from 'wallaby-cash';
|
|
52
|
+
|
|
53
|
+
const storageAdapter = {
|
|
54
|
+
async getItem(key) {
|
|
55
|
+
const result = await Keychain.getGenericPassword({ service: key });
|
|
56
|
+
return result ? result.password : null;
|
|
57
|
+
},
|
|
58
|
+
async setItem(key, value) {
|
|
59
|
+
await Keychain.setGenericPassword('wallaby', value, { service: key });
|
|
60
|
+
},
|
|
61
|
+
async removeItem(key) {
|
|
62
|
+
await Keychain.resetGenericPassword({ service: key });
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 3) Configure the passkey RP ID
|
|
68
|
+
|
|
69
|
+
Passkeys require a stable RP ID. Provide `hostname` in the SDK options and align it with your
|
|
70
|
+
Associated Domains (iOS) and Asset Links (Android) configuration.
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
const wallaby = new Wallaby({
|
|
74
|
+
apiKey,
|
|
75
|
+
baseUrl,
|
|
76
|
+
clientAuthToken,
|
|
77
|
+
userId,
|
|
78
|
+
options: {
|
|
79
|
+
storage: storageAdapter,
|
|
80
|
+
hostname: 'your-domain.com',
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 4) Validate native passkey support
|
|
86
|
+
|
|
87
|
+
The SDK uses `react-native-passkey` under the hood and will throw if the device does not support
|
|
88
|
+
passkeys. Make sure your UI gracefully handles these errors and provides an alternative path.
|
|
89
|
+
|
|
90
|
+
### 5) Verify PRF support and passkey flows
|
|
91
|
+
|
|
92
|
+
The native authenticator expects PRF data (`extensions.prf.eval.first`) in the passkey options.
|
|
93
|
+
Confirm your backend sends PRF extensions and validate:
|
|
94
|
+
|
|
95
|
+
- `auth.isDevicePrfCompatible()`
|
|
96
|
+
- `auth.signUp()` / `auth.signIn()`
|
|
97
|
+
- `auth.getPasskeyCredentials()`
|
|
98
|
+
|
|
99
|
+
### 6) Rollout + migration checks
|
|
100
|
+
|
|
101
|
+
The SDK already migrates legacy storage keys to v2 formats. Avoid clearing storage during rollout
|
|
102
|
+
and validate behavior on existing users before enabling passkeys for all accounts.
|
|
103
|
+
|
|
35
104
|
## Client Initialization
|
|
36
105
|
|
|
37
106
|
After installing the library, you can then import and use the SDK.
|
package/dist/generated/api.d.ts
CHANGED
|
@@ -5016,7 +5016,7 @@ export type CreateMultisigAssetData = UserAsset;
|
|
|
5016
5016
|
export type CreateWalletData = WalletCreatedDto;
|
|
5017
5017
|
export type CreateWalletV2Data = WalletCreatedDto;
|
|
5018
5018
|
export type GenerateMissingAddressesData = GenerateMissingAddressResponseDto;
|
|
5019
|
-
export type
|
|
5019
|
+
export type GetAllWalletsData = GetAllWalletsResponseDto;
|
|
5020
5020
|
export interface GetAllUsersParams {
|
|
5021
5021
|
/**
|
|
5022
5022
|
* Filter by date range from
|
|
@@ -6188,7 +6188,7 @@ export declare namespace Wallets {
|
|
|
6188
6188
|
};
|
|
6189
6189
|
type RequestBody = never;
|
|
6190
6190
|
type RequestHeaders = {};
|
|
6191
|
-
type ResponseBody =
|
|
6191
|
+
type ResponseBody = GetAllWalletsData;
|
|
6192
6192
|
}
|
|
6193
6193
|
/**
|
|
6194
6194
|
* No description
|
|
@@ -8427,7 +8427,7 @@ export declare class Api<SecurityDataType extends unknown> {
|
|
|
8427
8427
|
* @request GET:/wallets
|
|
8428
8428
|
* @secure
|
|
8429
8429
|
*/
|
|
8430
|
-
getAllUsers: (query: GetAllUsersParams, params?: RequestParams) => Promise<
|
|
8430
|
+
getAllUsers: (query: GetAllUsersParams, params?: RequestParams) => Promise<GetAllWalletsResponseDto>;
|
|
8431
8431
|
/**
|
|
8432
8432
|
* No description
|
|
8433
8433
|
*
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared base64 helpers. Platform-specific files (base64.ts, base64.native.ts)
|
|
3
|
+
* import from here and add or re-export as needed.
|
|
4
|
+
*/
|
|
5
|
+
export declare function normalizeAndPadBase64(s: string): string;
|
|
6
|
+
export declare function decodeBase64String(s: string): Uint8Array;
|
|
7
|
+
/**
|
|
8
|
+
* Single-decode only: decode base64 (or base64url) to bytes. No round-trip double-decode.
|
|
9
|
+
*/
|
|
10
|
+
export declare function base64ToUint8Array(base64: string): Uint8Array;
|
|
11
|
+
export declare function uint8ArrayToBase64(bytes: Uint8Array): string;
|
|
12
|
+
export declare function decodeBase64URL(base64url: string): Uint8Array;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web: round-trip with uint8ArrayToBase64 (which does btoa(fromUint8Array(bytes, true))).
|
|
3
|
+
* Single decode first; if the result looks like a base64 string, decode again to get original bytes.
|
|
4
|
+
*/
|
|
5
|
+
export declare function base64ToUint8Array(base64: string): Uint8Array;
|
|
6
|
+
export { uint8ArrayToBase64, decodeBase64URL } from './base64.base';
|
package/dist/index.cjs.js
CHANGED
|
@@ -8,6 +8,7 @@ const cryptoJs = require('crypto-js');
|
|
|
8
8
|
const jwtDecode = require('jwt-decode');
|
|
9
9
|
const lodash = require('lodash');
|
|
10
10
|
const WebAuthn = require('@simplewebauthn/browser');
|
|
11
|
+
const jsBase64 = require('js-base64');
|
|
11
12
|
|
|
12
13
|
const _interopDefaultCompat = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
|
|
13
14
|
|
|
@@ -796,7 +797,7 @@ const MASTER_ENCRYPTION_KEY = '9fa9d3f3c77c20d3a50a08e5299644be29f6e6206ef3479fe
|
|
|
796
797
|
In particular, RS256 is necessary for compatibility with Microsoft Windows platform authenticators.
|
|
797
798
|
ES256 is a widely supported algorithm and is compatible with most other platform authenticators and roaming authenticators.
|
|
798
799
|
Therefore a Relying Party that uses an algorithm identifier list that omits either of those values will see registration failures when users attempt to use incompatible authenticators.
|
|
799
|
-
|
|
800
|
+
|
|
800
801
|
https://chromium.googlesource.com/chromium/src/+/main/content/browser/webauth/pub_key_cred_params.md
|
|
801
802
|
*/
|
|
802
803
|
[
|
|
@@ -804,7 +805,7 @@ const MASTER_ENCRYPTION_KEY = '9fa9d3f3c77c20d3a50a08e5299644be29f6e6206ef3479fe
|
|
|
804
805
|
{ type: 'public-key', alg: exports.PublicKeyCredentialAlgorithm.ES256 },
|
|
805
806
|
];
|
|
806
807
|
const isWeb = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
807
|
-
const currentPackageVersion = "2.2.
|
|
808
|
+
const currentPackageVersion = "2.2.13" ;
|
|
808
809
|
|
|
809
810
|
/**
|
|
810
811
|
* Storage keys adapter for Storage interface across different platforms.
|
|
@@ -7031,11 +7032,16 @@ function objectToQueryParams(obj) {
|
|
|
7031
7032
|
|
|
7032
7033
|
class Base {
|
|
7033
7034
|
constructor(config) {
|
|
7035
|
+
var _a, _b;
|
|
7034
7036
|
const sanitizedConfig = sanitizeConfig(config);
|
|
7035
7037
|
this.apiKey = sanitizedConfig.apiKey;
|
|
7036
7038
|
this.baseUrl = sanitizedConfig.baseUrl;
|
|
7037
7039
|
this.userId = sanitizedConfig.userId;
|
|
7038
7040
|
this.options = sanitizedConfig.options;
|
|
7041
|
+
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.platform) {
|
|
7042
|
+
this.options.platform;
|
|
7043
|
+
this.options.platform === 'ios' || this.options.platform === 'android';
|
|
7044
|
+
}
|
|
7039
7045
|
this.cipher = new Cipher();
|
|
7040
7046
|
this.lockManager = new LockManagerService();
|
|
7041
7047
|
this._initializeClientAuthToken(sanitizedConfig.clientAuthToken);
|
|
@@ -7080,10 +7086,7 @@ class Base {
|
|
|
7080
7086
|
}
|
|
7081
7087
|
};
|
|
7082
7088
|
this.api = new Api(httpClient);
|
|
7083
|
-
this.api.http.setSecurityData({
|
|
7084
|
-
'x-api-key': config.apiKey,
|
|
7085
|
-
'x-client-jwt': config.clientAuthToken,
|
|
7086
|
-
});
|
|
7089
|
+
this.api.http.setSecurityData(Object.assign({ 'x-api-key': config.apiKey, 'x-client-jwt': config.clientAuthToken }, (_b = this.options) === null || _b === void 0 ? void 0 : _b.headers));
|
|
7087
7090
|
}
|
|
7088
7091
|
set setClientAuthToken(token) {
|
|
7089
7092
|
this._initializeClientAuthToken(token);
|
|
@@ -7634,6 +7637,50 @@ class Authenticator {
|
|
|
7634
7637
|
}
|
|
7635
7638
|
}
|
|
7636
7639
|
|
|
7640
|
+
/**
|
|
7641
|
+
* Shared base64 helpers. Platform-specific files (base64.ts, base64.native.ts)
|
|
7642
|
+
* import from here and add or re-export as needed.
|
|
7643
|
+
*/
|
|
7644
|
+
function normalizeAndPadBase64(s) {
|
|
7645
|
+
const normalized = s.replace(/-/g, '+').replace(/_/g, '/');
|
|
7646
|
+
return normalized.padEnd(normalized.length + ((4 - (normalized.length % 4)) % 4), '=');
|
|
7647
|
+
}
|
|
7648
|
+
function decodeBase64String(s) {
|
|
7649
|
+
return jsBase64.toUint8Array(normalizeAndPadBase64(s));
|
|
7650
|
+
}
|
|
7651
|
+
function decodeBase64URL(base64url) {
|
|
7652
|
+
const padded = normalizeAndPadBase64(base64url);
|
|
7653
|
+
const binary = jsBase64.atob(padded);
|
|
7654
|
+
const bytes = new Uint8Array(binary.length);
|
|
7655
|
+
for (let i = 0; i < binary.length; i++) {
|
|
7656
|
+
bytes[i] = binary.charCodeAt(i);
|
|
7657
|
+
}
|
|
7658
|
+
return bytes;
|
|
7659
|
+
}
|
|
7660
|
+
|
|
7661
|
+
/**
|
|
7662
|
+
* Web: round-trip with uint8ArrayToBase64 (which does btoa(fromUint8Array(bytes, true))).
|
|
7663
|
+
* Single decode first; if the result looks like a base64 string, decode again to get original bytes.
|
|
7664
|
+
*/
|
|
7665
|
+
function base64ToUint8Array(base64) {
|
|
7666
|
+
try {
|
|
7667
|
+
const first = jsBase64.toUint8Array(base64);
|
|
7668
|
+
const asStr = String.fromCharCode.apply(null, first);
|
|
7669
|
+
if (/^[A-Za-z0-9+/\-_=]*$/.test(asStr) && asStr.length >= 4) {
|
|
7670
|
+
try {
|
|
7671
|
+
return decodeBase64String(asStr);
|
|
7672
|
+
}
|
|
7673
|
+
catch (_a) {
|
|
7674
|
+
// fall through
|
|
7675
|
+
}
|
|
7676
|
+
}
|
|
7677
|
+
return first;
|
|
7678
|
+
}
|
|
7679
|
+
catch (_b) {
|
|
7680
|
+
return decodeBase64String(base64);
|
|
7681
|
+
}
|
|
7682
|
+
}
|
|
7683
|
+
|
|
7637
7684
|
class PasskeyService {
|
|
7638
7685
|
constructor(userId, storageService, request) {
|
|
7639
7686
|
this.cipher = new Cipher();
|
|
@@ -7645,7 +7692,7 @@ class PasskeyService {
|
|
|
7645
7692
|
preparePasskeyRequestOptions(options) {
|
|
7646
7693
|
var _a, _b, _c, _d, _e, _f;
|
|
7647
7694
|
const prfExtensionEvaluation = ((_b = (_a = options.extensions) === null || _a === void 0 ? void 0 : _a.prf.eval) === null || _b === void 0 ? void 0 : _b.base64)
|
|
7648
|
-
?
|
|
7695
|
+
? decodeBase64URL(options.extensions.prf.eval.base64)
|
|
7649
7696
|
: ((_d = (_c = options.extensions) === null || _c === void 0 ? void 0 : _c.prf.eval) === null || _d === void 0 ? void 0 : _d.first) instanceof ArrayBuffer
|
|
7650
7697
|
? new Uint8Array(options.extensions.prf.eval.first)
|
|
7651
7698
|
: typeof ((_f = (_e = options.extensions) === null || _e === void 0 ? void 0 : _e.prf.eval) === null || _f === void 0 ? void 0 : _f.first) === 'object'
|
|
@@ -7665,7 +7712,7 @@ class PasskeyService {
|
|
|
7665
7712
|
preparePasskeyCreationOptions(options) {
|
|
7666
7713
|
var _a, _b, _c, _d, _e, _f;
|
|
7667
7714
|
const prfExtensionEvaluation = ((_b = (_a = options.extensions) === null || _a === void 0 ? void 0 : _a.prf.eval) === null || _b === void 0 ? void 0 : _b.base64)
|
|
7668
|
-
?
|
|
7715
|
+
? decodeBase64URL(options.extensions.prf.eval.base64)
|
|
7669
7716
|
: ((_d = (_c = options.extensions) === null || _c === void 0 ? void 0 : _c.prf.eval) === null || _d === void 0 ? void 0 : _d.first) instanceof ArrayBuffer
|
|
7670
7717
|
? new Uint8Array(options.extensions.prf.eval.first)
|
|
7671
7718
|
: typeof ((_f = (_e = options.extensions) === null || _e === void 0 ? void 0 : _e.prf.eval) === null || _f === void 0 ? void 0 : _f.first) === 'object'
|
|
@@ -8066,8 +8113,50 @@ class PasskeyService {
|
|
|
8066
8113
|
errorCode: exports.ErrorResponseCodes.sdk_passkey_prf_not_available,
|
|
8067
8114
|
});
|
|
8068
8115
|
}
|
|
8069
|
-
const
|
|
8070
|
-
|
|
8116
|
+
const prfResult = (_e = extensions.prf.results) === null || _e === void 0 ? void 0 : _e.first;
|
|
8117
|
+
let prfValue;
|
|
8118
|
+
if (typeof prfResult === 'string') {
|
|
8119
|
+
prfValue = base64ToUint8Array(prfResult);
|
|
8120
|
+
}
|
|
8121
|
+
else if (prfResult instanceof Uint8Array) {
|
|
8122
|
+
prfValue = prfResult;
|
|
8123
|
+
}
|
|
8124
|
+
else if (prfResult instanceof ArrayBuffer) {
|
|
8125
|
+
prfValue = new Uint8Array(prfResult);
|
|
8126
|
+
}
|
|
8127
|
+
else if (ArrayBuffer.isView(prfResult)) {
|
|
8128
|
+
prfValue = new Uint8Array(prfResult.buffer);
|
|
8129
|
+
}
|
|
8130
|
+
else if (Array.isArray(prfResult)) {
|
|
8131
|
+
prfValue = new Uint8Array(prfResult);
|
|
8132
|
+
}
|
|
8133
|
+
else if (prfResult && typeof prfResult === 'object') {
|
|
8134
|
+
const data = prfResult.data;
|
|
8135
|
+
if (Array.isArray(data)) {
|
|
8136
|
+
prfValue = new Uint8Array(data);
|
|
8137
|
+
}
|
|
8138
|
+
else {
|
|
8139
|
+
const values = Object.values(prfResult);
|
|
8140
|
+
if (values.length && values.every((value) => typeof value === 'number')) {
|
|
8141
|
+
prfValue = new Uint8Array(values);
|
|
8142
|
+
}
|
|
8143
|
+
else {
|
|
8144
|
+
throw new WallabyError({
|
|
8145
|
+
message: 'Unsupported PRF result type.',
|
|
8146
|
+
statusCode: 400,
|
|
8147
|
+
errorCode: exports.ErrorResponseCodes.sdk_passkey_prf_not_available,
|
|
8148
|
+
});
|
|
8149
|
+
}
|
|
8150
|
+
}
|
|
8151
|
+
}
|
|
8152
|
+
else {
|
|
8153
|
+
throw new WallabyError({
|
|
8154
|
+
message: 'Unsupported PRF result type.',
|
|
8155
|
+
statusCode: 400,
|
|
8156
|
+
errorCode: exports.ErrorResponseCodes.sdk_passkey_prf_not_available,
|
|
8157
|
+
});
|
|
8158
|
+
}
|
|
8159
|
+
logger.debug('SDK::PasskeyService::handleCredentialsCreationFromPrfExtension::prfValue', prfValue);
|
|
8071
8160
|
const credentialsKeyPair = await this.cipher.getCredentialsKeyPair({
|
|
8072
8161
|
prfValue,
|
|
8073
8162
|
authType: exports.AuthType.Passkey,
|
|
@@ -8410,7 +8499,6 @@ class AuthService extends Base {
|
|
|
8410
8499
|
let deviceKeyPair;
|
|
8411
8500
|
// This logic needs to change and depend on data from server.
|
|
8412
8501
|
if (!passkeyCredential) {
|
|
8413
|
-
console.debug('SDK::AuthService::handleSignInWithPasskey:: creating new key pair');
|
|
8414
8502
|
deviceKeyPair = createIdentity();
|
|
8415
8503
|
devicePublicKey = deviceKeyPair.publicKey;
|
|
8416
8504
|
await this.localStorageService.save(exports.LocalStorageItems.ClientAuthPublicKey, devicePublicKey);
|
|
@@ -10450,7 +10538,7 @@ class WalletDataService extends Base {
|
|
|
10450
10538
|
* @param { string } address Wallet address
|
|
10451
10539
|
* @param { string } symbol Token symbol
|
|
10452
10540
|
* @param { BlockchainName } chainName the chain name enum. i.e. 'ETHEREUM', 'BITCOIN'
|
|
10453
|
-
* @returns { TokenBalance }
|
|
10541
|
+
* @returns { TokenBalance } Balance of the token
|
|
10454
10542
|
*/
|
|
10455
10543
|
async getTokenBalance({ address, symbol, tokenStandard, chainName }) {
|
|
10456
10544
|
try {
|