@lightsparkdev/core 1.0.20 → 1.0.21
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/CHANGELOG.md +7 -0
- package/dist/{chunk-ZPGGNCAE.js → chunk-Y3FWNVYS.js} +5 -1
- package/dist/{index-324f8ba4.d.ts → index-9e41ffe5.d.ts} +2 -1
- package/dist/index.cjs +9 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -3
- package/dist/utils/index.cjs +5 -0
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +3 -1
- package/package.json +1 -1
- package/src/crypto/crypto.ts +6 -2
- package/src/crypto/tests/crypto.test.ts +5 -0
- package/src/utils/types.ts +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -903,6 +903,9 @@ function isUint8Array(variable) {
|
|
|
903
903
|
var isType = (typename) => (node) => {
|
|
904
904
|
return node?.__typename === typename;
|
|
905
905
|
};
|
|
906
|
+
function notNullUndefined(value) {
|
|
907
|
+
return value !== null && value !== void 0;
|
|
908
|
+
}
|
|
906
909
|
|
|
907
910
|
export {
|
|
908
911
|
LightsparkException_default,
|
|
@@ -947,7 +950,8 @@ export {
|
|
|
947
950
|
pollUntil,
|
|
948
951
|
lsidToUUID,
|
|
949
952
|
isUint8Array,
|
|
950
|
-
isType
|
|
953
|
+
isType,
|
|
954
|
+
notNullUndefined
|
|
951
955
|
};
|
|
952
956
|
/*! Bundled license information:
|
|
953
957
|
|
|
@@ -162,6 +162,7 @@ type JSONObject = {
|
|
|
162
162
|
[key: string]: JSONType;
|
|
163
163
|
};
|
|
164
164
|
type NN<T> = NonNullable<T>;
|
|
165
|
+
declare function notNullUndefined<TValue>(value: TValue | null | undefined): value is TValue;
|
|
165
166
|
|
|
166
167
|
declare const isError: (e: unknown) => e is Error;
|
|
167
168
|
type ErrorWithMessage = {
|
|
@@ -273,4 +274,4 @@ declare function lsidToUUID(lsid: string): string;
|
|
|
273
274
|
|
|
274
275
|
declare function isUint8Array(variable: unknown): variable is Uint8Array;
|
|
275
276
|
|
|
276
|
-
export { DeepPartial as $, isErrorMsg as A, errorToJSON as B, ConfigKeys as C, bytesToHex as D, hexToBytes as E, getLocalStorageConfigItem as F, getLocalStorageBoolean as G, setLocalStorageBoolean as H, deleteLocalStorageItem as I, getCurrentLocale as J, countryCodesToCurrencyCodes as K, CurrencyLocales as L, CurrencyCodes as M, localeToCurrencyCode as N, clamp as O, linearInterpolate as P, round as Q, isNumber as R, pollUntil as S, sleep as T, lsidToUUID as U, isUint8Array as V, Maybe as W, ExpandRecursively as X, ById as Y, OmitTypename as Z, isType as _, b64encode as a, JSONLiteral as a0, JSONType as a1, JSONObject as a2, NN as a3, b64decode as b, createSha256Hash as c, defaultCurrencyCode as d, CurrencyUnit as e, CurrencyAmountType as f, convertCurrencyAmountValue as g, convertCurrencyAmount as h, CurrencyMap as i, CurrencyAmountObj as j, CurrencyAmountArg as k, isCurrencyAmountObj as l, isCurrencyAmount as m, mapCurrencyAmount as n, isCurrencyMap as o, abbrCurrencyUnit as p, formatCurrencyStr as q, localeToCurrencySymbol as r, separateCurrencyStrParts as s, isBrowser as t, urlsafe_b64decode as u, isNode as v, isTest as w, isError as x, isErrorWithMessage as y, getErrorMsg as z };
|
|
277
|
+
export { DeepPartial as $, isErrorMsg as A, errorToJSON as B, ConfigKeys as C, bytesToHex as D, hexToBytes as E, getLocalStorageConfigItem as F, getLocalStorageBoolean as G, setLocalStorageBoolean as H, deleteLocalStorageItem as I, getCurrentLocale as J, countryCodesToCurrencyCodes as K, CurrencyLocales as L, CurrencyCodes as M, localeToCurrencyCode as N, clamp as O, linearInterpolate as P, round as Q, isNumber as R, pollUntil as S, sleep as T, lsidToUUID as U, isUint8Array as V, Maybe as W, ExpandRecursively as X, ById as Y, OmitTypename as Z, isType as _, b64encode as a, JSONLiteral as a0, JSONType as a1, JSONObject as a2, NN as a3, notNullUndefined as a4, b64decode as b, createSha256Hash as c, defaultCurrencyCode as d, CurrencyUnit as e, CurrencyAmountType as f, convertCurrencyAmountValue as g, convertCurrencyAmount as h, CurrencyMap as i, CurrencyAmountObj as j, CurrencyAmountArg as k, isCurrencyAmountObj as l, isCurrencyAmount as m, mapCurrencyAmount as n, isCurrencyMap as o, abbrCurrencyUnit as p, formatCurrencyStr as q, localeToCurrencySymbol as r, separateCurrencyStrParts as s, isBrowser as t, urlsafe_b64decode as u, isNode as v, isTest as w, isError as x, isErrorWithMessage as y, getErrorMsg as z };
|
package/dist/index.cjs
CHANGED
|
@@ -83,6 +83,7 @@ __export(src_exports, {
|
|
|
83
83
|
localeToCurrencySymbol: () => localeToCurrencySymbol,
|
|
84
84
|
lsidToUUID: () => lsidToUUID,
|
|
85
85
|
mapCurrencyAmount: () => mapCurrencyAmount,
|
|
86
|
+
notNullUndefined: () => notNullUndefined,
|
|
86
87
|
pollUntil: () => pollUntil,
|
|
87
88
|
round: () => round,
|
|
88
89
|
separateCurrencyStrParts: () => separateCurrencyStrParts,
|
|
@@ -452,8 +453,10 @@ var serializeSigningKey = async (key, format) => {
|
|
|
452
453
|
);
|
|
453
454
|
};
|
|
454
455
|
var getNonce = async () => {
|
|
455
|
-
const nonceSt = await getRandomValues32(new Uint32Array(
|
|
456
|
-
|
|
456
|
+
const nonceSt = await getRandomValues32(new Uint32Array(2));
|
|
457
|
+
const [upper, lower] = nonceSt;
|
|
458
|
+
const nonce = BigInt(upper) << 32n | BigInt(lower);
|
|
459
|
+
return Number(nonce);
|
|
457
460
|
};
|
|
458
461
|
var sign = async (keyOrAlias, data) => {
|
|
459
462
|
if (typeof keyOrAlias === "string") {
|
|
@@ -1344,6 +1347,9 @@ function isUint8Array(variable) {
|
|
|
1344
1347
|
var isType = (typename) => (node) => {
|
|
1345
1348
|
return node?.__typename === typename;
|
|
1346
1349
|
};
|
|
1350
|
+
function notNullUndefined(value) {
|
|
1351
|
+
return value !== null && value !== void 0;
|
|
1352
|
+
}
|
|
1347
1353
|
|
|
1348
1354
|
// src/crypto/SigningKey.ts
|
|
1349
1355
|
function isAlias(key) {
|
|
@@ -1688,6 +1694,7 @@ var Requester_default = Requester;
|
|
|
1688
1694
|
localeToCurrencySymbol,
|
|
1689
1695
|
lsidToUUID,
|
|
1690
1696
|
mapCurrencyAmount,
|
|
1697
|
+
notNullUndefined,
|
|
1691
1698
|
pollUntil,
|
|
1692
1699
|
round,
|
|
1693
1700
|
separateCurrencyStrParts,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Y as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, $ as DeepPartial, X as ExpandRecursively, a0 as JSONLiteral, a2 as JSONObject, a1 as JSONType, W as Maybe, a3 as NN, Z as OmitTypename, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, _ as isType, V as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, U as lsidToUUID, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from './index-
|
|
1
|
+
export { Y as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, $ as DeepPartial, X as ExpandRecursively, a0 as JSONLiteral, a2 as JSONObject, a1 as JSONType, W as Maybe, a3 as NN, Z as OmitTypename, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, _ as isType, V as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, U as lsidToUUID, n as mapCurrencyAmount, a4 as notNullUndefined, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from './index-9e41ffe5.js';
|
|
2
2
|
import { Observable } from 'zen-observable-ts';
|
|
3
3
|
|
|
4
4
|
declare class LightsparkException extends Error {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Y as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, $ as DeepPartial, X as ExpandRecursively, a0 as JSONLiteral, a2 as JSONObject, a1 as JSONType, W as Maybe, a3 as NN, Z as OmitTypename, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, _ as isType, V as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, U as lsidToUUID, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from './index-
|
|
1
|
+
export { Y as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, $ as DeepPartial, X as ExpandRecursively, a0 as JSONLiteral, a2 as JSONObject, a1 as JSONType, W as Maybe, a3 as NN, Z as OmitTypename, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, _ as isType, V as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, U as lsidToUUID, n as mapCurrencyAmount, a4 as notNullUndefined, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from './index-9e41ffe5.js';
|
|
2
2
|
import { Observable } from 'zen-observable-ts';
|
|
3
3
|
|
|
4
4
|
declare class LightsparkException extends Error {
|
package/dist/index.js
CHANGED
|
@@ -36,13 +36,14 @@ import {
|
|
|
36
36
|
localeToCurrencySymbol,
|
|
37
37
|
lsidToUUID,
|
|
38
38
|
mapCurrencyAmount,
|
|
39
|
+
notNullUndefined,
|
|
39
40
|
pollUntil,
|
|
40
41
|
round,
|
|
41
42
|
separateCurrencyStrParts,
|
|
42
43
|
setLocalStorageBoolean,
|
|
43
44
|
sleep,
|
|
44
45
|
urlsafe_b64decode
|
|
45
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-Y3FWNVYS.js";
|
|
46
47
|
|
|
47
48
|
// src/Logger.ts
|
|
48
49
|
var LoggingLevel = /* @__PURE__ */ ((LoggingLevel2) => {
|
|
@@ -342,8 +343,10 @@ var serializeSigningKey = async (key, format) => {
|
|
|
342
343
|
);
|
|
343
344
|
};
|
|
344
345
|
var getNonce = async () => {
|
|
345
|
-
const nonceSt = await getRandomValues32(new Uint32Array(
|
|
346
|
-
|
|
346
|
+
const nonceSt = await getRandomValues32(new Uint32Array(2));
|
|
347
|
+
const [upper, lower] = nonceSt;
|
|
348
|
+
const nonce = BigInt(upper) << 32n | BigInt(lower);
|
|
349
|
+
return Number(nonce);
|
|
347
350
|
};
|
|
348
351
|
var sign = async (keyOrAlias, data) => {
|
|
349
352
|
if (typeof keyOrAlias === "string") {
|
|
@@ -731,6 +734,7 @@ export {
|
|
|
731
734
|
localeToCurrencySymbol,
|
|
732
735
|
lsidToUUID,
|
|
733
736
|
mapCurrencyAmount,
|
|
737
|
+
notNullUndefined,
|
|
734
738
|
pollUntil,
|
|
735
739
|
round,
|
|
736
740
|
separateCurrencyStrParts,
|
package/dist/utils/index.cjs
CHANGED
|
@@ -66,6 +66,7 @@ __export(utils_exports, {
|
|
|
66
66
|
localeToCurrencySymbol: () => localeToCurrencySymbol,
|
|
67
67
|
lsidToUUID: () => lsidToUUID,
|
|
68
68
|
mapCurrencyAmount: () => mapCurrencyAmount,
|
|
69
|
+
notNullUndefined: () => notNullUndefined,
|
|
69
70
|
pollUntil: () => pollUntil,
|
|
70
71
|
round: () => round,
|
|
71
72
|
separateCurrencyStrParts: () => separateCurrencyStrParts,
|
|
@@ -980,6 +981,9 @@ function isUint8Array(variable) {
|
|
|
980
981
|
var isType = (typename) => (node) => {
|
|
981
982
|
return node?.__typename === typename;
|
|
982
983
|
};
|
|
984
|
+
function notNullUndefined(value) {
|
|
985
|
+
return value !== null && value !== void 0;
|
|
986
|
+
}
|
|
983
987
|
// Annotate the CommonJS export names for ESM import in node:
|
|
984
988
|
0 && (module.exports = {
|
|
985
989
|
CurrencyUnit,
|
|
@@ -1018,6 +1022,7 @@ var isType = (typename) => (node) => {
|
|
|
1018
1022
|
localeToCurrencySymbol,
|
|
1019
1023
|
lsidToUUID,
|
|
1020
1024
|
mapCurrencyAmount,
|
|
1025
|
+
notNullUndefined,
|
|
1021
1026
|
pollUntil,
|
|
1022
1027
|
round,
|
|
1023
1028
|
separateCurrencyStrParts,
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Y as ById, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, $ as DeepPartial, X as ExpandRecursively, a0 as JSONLiteral, a2 as JSONObject, a1 as JSONType, W as Maybe, a3 as NN, Z as OmitTypename, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, _ as isType, V as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, U as lsidToUUID, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from '../index-
|
|
1
|
+
export { Y as ById, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, $ as DeepPartial, X as ExpandRecursively, a0 as JSONLiteral, a2 as JSONObject, a1 as JSONType, W as Maybe, a3 as NN, Z as OmitTypename, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, _ as isType, V as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, U as lsidToUUID, n as mapCurrencyAmount, a4 as notNullUndefined, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from '../index-9e41ffe5.js';
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Y as ById, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, $ as DeepPartial, X as ExpandRecursively, a0 as JSONLiteral, a2 as JSONObject, a1 as JSONType, W as Maybe, a3 as NN, Z as OmitTypename, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, _ as isType, V as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, U as lsidToUUID, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from '../index-
|
|
1
|
+
export { Y as ById, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, $ as DeepPartial, X as ExpandRecursively, a0 as JSONLiteral, a2 as JSONObject, a1 as JSONType, W as Maybe, a3 as NN, Z as OmitTypename, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, _ as isType, V as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, U as lsidToUUID, n as mapCurrencyAmount, a4 as notNullUndefined, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from '../index-9e41ffe5.js';
|
package/dist/utils/index.js
CHANGED
|
@@ -35,13 +35,14 @@ import {
|
|
|
35
35
|
localeToCurrencySymbol,
|
|
36
36
|
lsidToUUID,
|
|
37
37
|
mapCurrencyAmount,
|
|
38
|
+
notNullUndefined,
|
|
38
39
|
pollUntil,
|
|
39
40
|
round,
|
|
40
41
|
separateCurrencyStrParts,
|
|
41
42
|
setLocalStorageBoolean,
|
|
42
43
|
sleep,
|
|
43
44
|
urlsafe_b64decode
|
|
44
|
-
} from "../chunk-
|
|
45
|
+
} from "../chunk-Y3FWNVYS.js";
|
|
45
46
|
export {
|
|
46
47
|
CurrencyUnit,
|
|
47
48
|
abbrCurrencyUnit,
|
|
@@ -79,6 +80,7 @@ export {
|
|
|
79
80
|
localeToCurrencySymbol,
|
|
80
81
|
lsidToUUID,
|
|
81
82
|
mapCurrencyAmount,
|
|
83
|
+
notNullUndefined,
|
|
82
84
|
pollUntil,
|
|
83
85
|
round,
|
|
84
86
|
separateCurrencyStrParts,
|
package/package.json
CHANGED
package/src/crypto/crypto.ts
CHANGED
|
@@ -226,8 +226,12 @@ const serializeSigningKey = async (
|
|
|
226
226
|
};
|
|
227
227
|
|
|
228
228
|
const getNonce = async () => {
|
|
229
|
-
const nonceSt = await getRandomValues32(new Uint32Array(
|
|
230
|
-
|
|
229
|
+
const nonceSt = await getRandomValues32(new Uint32Array(2));
|
|
230
|
+
const [upper, lower] = nonceSt;
|
|
231
|
+
const nonce = (BigInt(upper) << 32n) | BigInt(lower);
|
|
232
|
+
// Note: We lose some precision here going from bigint to number
|
|
233
|
+
// because js numbers are floats, but it's ok.
|
|
234
|
+
return Number(nonce);
|
|
231
235
|
};
|
|
232
236
|
|
|
233
237
|
const sign = async (
|
|
@@ -18,4 +18,9 @@ describe("Crypto tests", () => {
|
|
|
18
18
|
expect(serializedKeypair.privateKey).not.toBeNull();
|
|
19
19
|
expect(serializedKeypair.publicKey).not.toBeNull();
|
|
20
20
|
}, 60_000);
|
|
21
|
+
|
|
22
|
+
test("should generate a valid nonce", async () => {
|
|
23
|
+
const nonce = await DefaultCrypto.getNonce();
|
|
24
|
+
expect(nonce).toBeGreaterThan(0);
|
|
25
|
+
}, 10_000);
|
|
21
26
|
});
|
package/src/utils/types.ts
CHANGED
|
@@ -33,3 +33,9 @@ export type JSONType = JSONLiteral | JSONType[] | { [key: string]: JSONType };
|
|
|
33
33
|
export type JSONObject = { [key: string]: JSONType };
|
|
34
34
|
|
|
35
35
|
export type NN<T> = NonNullable<T>;
|
|
36
|
+
|
|
37
|
+
export function notNullUndefined<TValue>(
|
|
38
|
+
value: TValue | null | undefined,
|
|
39
|
+
): value is TValue {
|
|
40
|
+
return value !== null && value !== undefined;
|
|
41
|
+
}
|