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/dist/index.esm.js
CHANGED
|
@@ -4,6 +4,7 @@ import { AES, enc } from 'crypto-js';
|
|
|
4
4
|
import { jwtDecode } from 'jwt-decode';
|
|
5
5
|
import { omit } from 'lodash';
|
|
6
6
|
import * as WebAuthn from '@simplewebauthn/browser';
|
|
7
|
+
import { atob, toUint8Array } from 'js-base64';
|
|
7
8
|
|
|
8
9
|
/******************************************************************************
|
|
9
10
|
Copyright (c) Microsoft Corporation.
|
|
@@ -769,7 +770,7 @@ const MASTER_ENCRYPTION_KEY = '9fa9d3f3c77c20d3a50a08e5299644be29f6e6206ef3479fe
|
|
|
769
770
|
In particular, RS256 is necessary for compatibility with Microsoft Windows platform authenticators.
|
|
770
771
|
ES256 is a widely supported algorithm and is compatible with most other platform authenticators and roaming authenticators.
|
|
771
772
|
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.
|
|
772
|
-
|
|
773
|
+
|
|
773
774
|
https://chromium.googlesource.com/chromium/src/+/main/content/browser/webauth/pub_key_cred_params.md
|
|
774
775
|
*/
|
|
775
776
|
[
|
|
@@ -777,7 +778,7 @@ const MASTER_ENCRYPTION_KEY = '9fa9d3f3c77c20d3a50a08e5299644be29f6e6206ef3479fe
|
|
|
777
778
|
{ type: 'public-key', alg: PublicKeyCredentialAlgorithm.ES256 },
|
|
778
779
|
];
|
|
779
780
|
const isWeb = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
780
|
-
const currentPackageVersion = "2.2.
|
|
781
|
+
const currentPackageVersion = "2.2.13" ;
|
|
781
782
|
|
|
782
783
|
/**
|
|
783
784
|
* Storage keys adapter for Storage interface across different platforms.
|
|
@@ -7004,11 +7005,16 @@ function objectToQueryParams(obj) {
|
|
|
7004
7005
|
|
|
7005
7006
|
class Base {
|
|
7006
7007
|
constructor(config) {
|
|
7008
|
+
var _a, _b;
|
|
7007
7009
|
const sanitizedConfig = sanitizeConfig(config);
|
|
7008
7010
|
this.apiKey = sanitizedConfig.apiKey;
|
|
7009
7011
|
this.baseUrl = sanitizedConfig.baseUrl;
|
|
7010
7012
|
this.userId = sanitizedConfig.userId;
|
|
7011
7013
|
this.options = sanitizedConfig.options;
|
|
7014
|
+
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.platform) {
|
|
7015
|
+
this.options.platform;
|
|
7016
|
+
this.options.platform === 'ios' || this.options.platform === 'android';
|
|
7017
|
+
}
|
|
7012
7018
|
this.cipher = new Cipher();
|
|
7013
7019
|
this.lockManager = new LockManagerService();
|
|
7014
7020
|
this._initializeClientAuthToken(sanitizedConfig.clientAuthToken);
|
|
@@ -7053,10 +7059,7 @@ class Base {
|
|
|
7053
7059
|
}
|
|
7054
7060
|
};
|
|
7055
7061
|
this.api = new Api(httpClient);
|
|
7056
|
-
this.api.http.setSecurityData({
|
|
7057
|
-
'x-api-key': config.apiKey,
|
|
7058
|
-
'x-client-jwt': config.clientAuthToken,
|
|
7059
|
-
});
|
|
7062
|
+
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));
|
|
7060
7063
|
}
|
|
7061
7064
|
set setClientAuthToken(token) {
|
|
7062
7065
|
this._initializeClientAuthToken(token);
|
|
@@ -7607,6 +7610,50 @@ class Authenticator {
|
|
|
7607
7610
|
}
|
|
7608
7611
|
}
|
|
7609
7612
|
|
|
7613
|
+
/**
|
|
7614
|
+
* Shared base64 helpers. Platform-specific files (base64.ts, base64.native.ts)
|
|
7615
|
+
* import from here and add or re-export as needed.
|
|
7616
|
+
*/
|
|
7617
|
+
function normalizeAndPadBase64(s) {
|
|
7618
|
+
const normalized = s.replace(/-/g, '+').replace(/_/g, '/');
|
|
7619
|
+
return normalized.padEnd(normalized.length + ((4 - (normalized.length % 4)) % 4), '=');
|
|
7620
|
+
}
|
|
7621
|
+
function decodeBase64String(s) {
|
|
7622
|
+
return toUint8Array(normalizeAndPadBase64(s));
|
|
7623
|
+
}
|
|
7624
|
+
function decodeBase64URL(base64url) {
|
|
7625
|
+
const padded = normalizeAndPadBase64(base64url);
|
|
7626
|
+
const binary = atob(padded);
|
|
7627
|
+
const bytes = new Uint8Array(binary.length);
|
|
7628
|
+
for (let i = 0; i < binary.length; i++) {
|
|
7629
|
+
bytes[i] = binary.charCodeAt(i);
|
|
7630
|
+
}
|
|
7631
|
+
return bytes;
|
|
7632
|
+
}
|
|
7633
|
+
|
|
7634
|
+
/**
|
|
7635
|
+
* Web: round-trip with uint8ArrayToBase64 (which does btoa(fromUint8Array(bytes, true))).
|
|
7636
|
+
* Single decode first; if the result looks like a base64 string, decode again to get original bytes.
|
|
7637
|
+
*/
|
|
7638
|
+
function base64ToUint8Array(base64) {
|
|
7639
|
+
try {
|
|
7640
|
+
const first = toUint8Array(base64);
|
|
7641
|
+
const asStr = String.fromCharCode.apply(null, first);
|
|
7642
|
+
if (/^[A-Za-z0-9+/\-_=]*$/.test(asStr) && asStr.length >= 4) {
|
|
7643
|
+
try {
|
|
7644
|
+
return decodeBase64String(asStr);
|
|
7645
|
+
}
|
|
7646
|
+
catch (_a) {
|
|
7647
|
+
// fall through
|
|
7648
|
+
}
|
|
7649
|
+
}
|
|
7650
|
+
return first;
|
|
7651
|
+
}
|
|
7652
|
+
catch (_b) {
|
|
7653
|
+
return decodeBase64String(base64);
|
|
7654
|
+
}
|
|
7655
|
+
}
|
|
7656
|
+
|
|
7610
7657
|
class PasskeyService {
|
|
7611
7658
|
constructor(userId, storageService, request) {
|
|
7612
7659
|
this.cipher = new Cipher();
|
|
@@ -7618,7 +7665,7 @@ class PasskeyService {
|
|
|
7618
7665
|
preparePasskeyRequestOptions(options) {
|
|
7619
7666
|
var _a, _b, _c, _d, _e, _f;
|
|
7620
7667
|
const prfExtensionEvaluation = ((_b = (_a = options.extensions) === null || _a === void 0 ? void 0 : _a.prf.eval) === null || _b === void 0 ? void 0 : _b.base64)
|
|
7621
|
-
?
|
|
7668
|
+
? decodeBase64URL(options.extensions.prf.eval.base64)
|
|
7622
7669
|
: ((_d = (_c = options.extensions) === null || _c === void 0 ? void 0 : _c.prf.eval) === null || _d === void 0 ? void 0 : _d.first) instanceof ArrayBuffer
|
|
7623
7670
|
? new Uint8Array(options.extensions.prf.eval.first)
|
|
7624
7671
|
: typeof ((_f = (_e = options.extensions) === null || _e === void 0 ? void 0 : _e.prf.eval) === null || _f === void 0 ? void 0 : _f.first) === 'object'
|
|
@@ -7638,7 +7685,7 @@ class PasskeyService {
|
|
|
7638
7685
|
preparePasskeyCreationOptions(options) {
|
|
7639
7686
|
var _a, _b, _c, _d, _e, _f;
|
|
7640
7687
|
const prfExtensionEvaluation = ((_b = (_a = options.extensions) === null || _a === void 0 ? void 0 : _a.prf.eval) === null || _b === void 0 ? void 0 : _b.base64)
|
|
7641
|
-
?
|
|
7688
|
+
? decodeBase64URL(options.extensions.prf.eval.base64)
|
|
7642
7689
|
: ((_d = (_c = options.extensions) === null || _c === void 0 ? void 0 : _c.prf.eval) === null || _d === void 0 ? void 0 : _d.first) instanceof ArrayBuffer
|
|
7643
7690
|
? new Uint8Array(options.extensions.prf.eval.first)
|
|
7644
7691
|
: typeof ((_f = (_e = options.extensions) === null || _e === void 0 ? void 0 : _e.prf.eval) === null || _f === void 0 ? void 0 : _f.first) === 'object'
|
|
@@ -8039,8 +8086,50 @@ class PasskeyService {
|
|
|
8039
8086
|
errorCode: ErrorResponseCodes.sdk_passkey_prf_not_available,
|
|
8040
8087
|
});
|
|
8041
8088
|
}
|
|
8042
|
-
const
|
|
8043
|
-
|
|
8089
|
+
const prfResult = (_e = extensions.prf.results) === null || _e === void 0 ? void 0 : _e.first;
|
|
8090
|
+
let prfValue;
|
|
8091
|
+
if (typeof prfResult === 'string') {
|
|
8092
|
+
prfValue = base64ToUint8Array(prfResult);
|
|
8093
|
+
}
|
|
8094
|
+
else if (prfResult instanceof Uint8Array) {
|
|
8095
|
+
prfValue = prfResult;
|
|
8096
|
+
}
|
|
8097
|
+
else if (prfResult instanceof ArrayBuffer) {
|
|
8098
|
+
prfValue = new Uint8Array(prfResult);
|
|
8099
|
+
}
|
|
8100
|
+
else if (ArrayBuffer.isView(prfResult)) {
|
|
8101
|
+
prfValue = new Uint8Array(prfResult.buffer);
|
|
8102
|
+
}
|
|
8103
|
+
else if (Array.isArray(prfResult)) {
|
|
8104
|
+
prfValue = new Uint8Array(prfResult);
|
|
8105
|
+
}
|
|
8106
|
+
else if (prfResult && typeof prfResult === 'object') {
|
|
8107
|
+
const data = prfResult.data;
|
|
8108
|
+
if (Array.isArray(data)) {
|
|
8109
|
+
prfValue = new Uint8Array(data);
|
|
8110
|
+
}
|
|
8111
|
+
else {
|
|
8112
|
+
const values = Object.values(prfResult);
|
|
8113
|
+
if (values.length && values.every((value) => typeof value === 'number')) {
|
|
8114
|
+
prfValue = new Uint8Array(values);
|
|
8115
|
+
}
|
|
8116
|
+
else {
|
|
8117
|
+
throw new WallabyError({
|
|
8118
|
+
message: 'Unsupported PRF result type.',
|
|
8119
|
+
statusCode: 400,
|
|
8120
|
+
errorCode: ErrorResponseCodes.sdk_passkey_prf_not_available,
|
|
8121
|
+
});
|
|
8122
|
+
}
|
|
8123
|
+
}
|
|
8124
|
+
}
|
|
8125
|
+
else {
|
|
8126
|
+
throw new WallabyError({
|
|
8127
|
+
message: 'Unsupported PRF result type.',
|
|
8128
|
+
statusCode: 400,
|
|
8129
|
+
errorCode: ErrorResponseCodes.sdk_passkey_prf_not_available,
|
|
8130
|
+
});
|
|
8131
|
+
}
|
|
8132
|
+
logger.debug('SDK::PasskeyService::handleCredentialsCreationFromPrfExtension::prfValue', prfValue);
|
|
8044
8133
|
const credentialsKeyPair = await this.cipher.getCredentialsKeyPair({
|
|
8045
8134
|
prfValue,
|
|
8046
8135
|
authType: AuthType.Passkey,
|
|
@@ -8383,7 +8472,6 @@ class AuthService extends Base {
|
|
|
8383
8472
|
let deviceKeyPair;
|
|
8384
8473
|
// This logic needs to change and depend on data from server.
|
|
8385
8474
|
if (!passkeyCredential) {
|
|
8386
|
-
console.debug('SDK::AuthService::handleSignInWithPasskey:: creating new key pair');
|
|
8387
8475
|
deviceKeyPair = createIdentity();
|
|
8388
8476
|
devicePublicKey = deviceKeyPair.publicKey;
|
|
8389
8477
|
await this.localStorageService.save(LocalStorageItems.ClientAuthPublicKey, devicePublicKey);
|
|
@@ -10423,7 +10511,7 @@ class WalletDataService extends Base {
|
|
|
10423
10511
|
* @param { string } address Wallet address
|
|
10424
10512
|
* @param { string } symbol Token symbol
|
|
10425
10513
|
* @param { BlockchainName } chainName the chain name enum. i.e. 'ETHEREUM', 'BITCOIN'
|
|
10426
|
-
* @returns { TokenBalance }
|
|
10514
|
+
* @returns { TokenBalance } Balance of the token
|
|
10427
10515
|
*/
|
|
10428
10516
|
async getTokenBalance({ address, symbol, tokenStandard, chainName }) {
|
|
10429
10517
|
try {
|