@lightsparkdev/core 1.4.3 → 1.4.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.
@@ -0,0 +1,175 @@
1
+ import { Client } from 'graphql-ws';
2
+ import { Observable } from 'zen-observable-ts';
3
+ export { A as AppendUnitsOptions, ae as ById, ap as Complete, C as ConfigKeys, o as CurrencyAmountArg, k as CurrencyAmountInputObj, m as CurrencyAmountObj, n as CurrencyAmountPreferenceObj, Y as CurrencyCodes, X as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, ai as DeepPartial, D as DeprecatedCurrencyAmountObj, ad as ExpandRecursively, ah as ExtractByTypename, aj as JSONLiteral, al as JSONObject, ak as JSONType, ac as Maybe, am as NN, af as OmitTypename, ao as PartialBy, aq as RequiredKeys, S as SDKCurrencyAmountType, ar as StateCode, U as UmaCurrency, l as UmaCurrencyAmount, z as abbrCurrencyUnit, b as b64decode, a as b64encode, R as bytesToHex, a2 as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, W as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, a1 as deleteLocalStorageItem, e as ensureArray, Q as errorToJSON, B as formatCurrencyStr, G as formatInviteAmount, w as getCurrencyAmount, V as getCurrentLocale, O as getErrorMsg, $ as getLocalStorageBoolean, _ as getLocalStorageConfigItem, T as hexToBytes, K as isBare, H as isBrowser, p as isCurrencyAmountInputObj, s as isCurrencyAmountObj, t as isCurrencyAmountPreferenceObj, y as isCurrencyMap, r as isDeprecatedCurrencyAmountObj, M as isError, P as isErrorMsg, N as isErrorWithMessage, I as isNode, a5 as isNumber, aa as isObject, L as isReactNative, ab as isRecord, v as isSDKCurrencyAmount, J as isTest, ag as isType, a9 as isUint8Array, q as isUmaCurrencyAmount, a3 as linearInterpolate, Z as localeToCurrencyCode, F as localeToCurrencySymbol, a8 as lsidToUUID, x as mapCurrencyAmount, an as notNullUndefined, a6 as pollUntil, a4 as round, E as separateCurrencyStrParts, a0 as setLocalStorageBoolean, a7 as sleep, u as urlsafe_b64decode, at as zipcodeToState, as as zipcodeToStateCode } from '../index-CpAae9dR.cjs';
4
+
5
+ type Headers = Record<string, string>;
6
+ type WsConnectionParams = Record<string, unknown>;
7
+ interface AuthProvider {
8
+ addAuthHeaders(headers: Headers): Promise<Headers>;
9
+ isAuthorized(): Promise<boolean>;
10
+ addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
11
+ }
12
+
13
+ type Query<T> = {
14
+ /** The string representation of the query payload for graphQL. **/
15
+ queryPayload: string;
16
+ /** The variables that will be passed to the query. **/
17
+ variables?: {
18
+ [key: string]: unknown;
19
+ };
20
+ /**
21
+ * The function that will be called to construct the object from the
22
+ * response. *
23
+ */
24
+ constructObject: (rawData: any) => T | null;
25
+ /** The id of the node that will be used to sign the query. **/
26
+ signingNodeId?: string;
27
+ /** True if auth headers should be omitted for this query. **/
28
+ skipAuth?: boolean;
29
+ };
30
+
31
+ declare class LightsparkException extends Error {
32
+ code: string;
33
+ message: string;
34
+ extraInfo: Record<string, unknown> | undefined;
35
+ constructor(code: string, message: string, extraInfo?: Record<string, unknown>);
36
+ }
37
+
38
+ declare class LightsparkSigningException extends LightsparkException {
39
+ constructor(message: string, extraInfo?: Record<string, unknown>);
40
+ }
41
+
42
+ type GeneratedKeyPair = {
43
+ publicKey: CryptoKey | string;
44
+ privateKey: CryptoKey | string;
45
+ keyAlias?: string;
46
+ };
47
+ type CryptoInterface = {
48
+ decryptSecretWithNodePassword: (cipher: string, encryptedSecret: string, nodePassword: string) => Promise<ArrayBuffer | null>;
49
+ generateSigningKeyPair: () => Promise<GeneratedKeyPair>;
50
+ serializeSigningKey: (key: CryptoKey | string, format: "pkcs8" | "spki") => Promise<ArrayBuffer>;
51
+ getNonce: () => Promise<number>;
52
+ sign: (keyOrAlias: CryptoKey | string, data: Uint8Array) => Promise<ArrayBuffer>;
53
+ importPrivateSigningKey: (keyData: Uint8Array) => Promise<CryptoKey | string>;
54
+ };
55
+ declare function decryptSecretWithNodePassword(cipher: string, encryptedSecret: string, nodePassword: string): Promise<ArrayBuffer | null>;
56
+ declare const DefaultCrypto: {
57
+ decryptSecretWithNodePassword: typeof decryptSecretWithNodePassword;
58
+ generateSigningKeyPair: () => Promise<GeneratedKeyPair>;
59
+ serializeSigningKey: (key: CryptoKey | string, format: "pkcs8" | "spki") => Promise<ArrayBuffer>;
60
+ getNonce: () => Promise<number>;
61
+ sign: (keyOrAlias: CryptoKey | string, data: Uint8Array) => Promise<ArrayBuffer>;
62
+ importPrivateSigningKey: (keyData: Uint8Array) => Promise<CryptoKey | string>;
63
+ };
64
+
65
+ type OnlyKey = {
66
+ key: string;
67
+ alias?: never;
68
+ };
69
+ type OnlyAlias = {
70
+ key?: never;
71
+ alias: string;
72
+ };
73
+ type KeyOrAliasType = OnlyKey | OnlyAlias;
74
+ declare const KeyOrAlias: {
75
+ key: (key: string) => OnlyKey;
76
+ alias: (alias: string) => OnlyAlias;
77
+ };
78
+
79
+ declare enum SigningKeyType {
80
+ RSASigningKey = "RSASigningKey",
81
+ Secp256k1SigningKey = "Secp256k1SigningKey"
82
+ }
83
+
84
+ interface Alias {
85
+ alias: string;
86
+ }
87
+ declare abstract class SigningKey {
88
+ readonly type: SigningKeyType;
89
+ constructor(type: SigningKeyType);
90
+ abstract sign(data: Uint8Array): Promise<ArrayBuffer>;
91
+ }
92
+ declare class RSASigningKey extends SigningKey {
93
+ private readonly privateKey;
94
+ private readonly cryptoImpl;
95
+ constructor(privateKey: CryptoKey | Alias, cryptoImpl: CryptoInterface);
96
+ sign(data: Uint8Array): Promise<ArrayBuffer>;
97
+ }
98
+ declare class Secp256k1SigningKey extends SigningKey {
99
+ private readonly privateKey;
100
+ constructor(privateKey: string);
101
+ sign(data: Uint8Array): Promise<Uint8Array>;
102
+ }
103
+
104
+ declare class NodeKeyCache {
105
+ private readonly cryptoImpl;
106
+ private idToKey;
107
+ constructor(cryptoImpl?: CryptoInterface);
108
+ loadKey(id: string, keyOrAlias: KeyOrAliasType, signingKeyType: SigningKeyType): Promise<SigningKey | null>;
109
+ getKey(id: string): SigningKey | undefined;
110
+ hasKey(id: string): boolean;
111
+ private stripPemTags;
112
+ }
113
+
114
+ declare class Requester {
115
+ private readonly nodeKeyCache;
116
+ protected readonly schemaEndpoint: string;
117
+ private readonly sdkUserAgent;
118
+ private readonly authProvider;
119
+ protected readonly baseUrl: string;
120
+ private readonly cryptoImpl;
121
+ private readonly signingKey?;
122
+ private readonly fetchImpl;
123
+ protected wsClient: Promise<Client | null>;
124
+ protected resolveWsClient: ((value: Client | null) => void) | null;
125
+ constructor(nodeKeyCache: NodeKeyCache, schemaEndpoint: string, sdkUserAgent: string, authProvider?: AuthProvider, baseUrl?: string, cryptoImpl?: CryptoInterface, signingKey?: SigningKey | undefined, fetchImpl?: typeof fetch);
126
+ protected initWsClient(baseUrl: string, authProvider: AuthProvider): Promise<Client | null>;
127
+ executeQuery<T>(query: Query<T>): Promise<T | null>;
128
+ subscribe<T>(queryPayload: string, variables?: {
129
+ [key: string]: unknown;
130
+ }): Observable<{
131
+ data: T;
132
+ }>;
133
+ makeRawRequest(queryPayload: string, variables?: {
134
+ [key: string]: unknown;
135
+ }, signingNodeId?: string | undefined, skipAuth?: boolean): Promise<any>;
136
+ private getSdkUserAgent;
137
+ protected stripProtocol(url: string): string;
138
+ private addSigningDataIfNeeded;
139
+ }
140
+
141
+ declare class LightsparkAuthException extends LightsparkException {
142
+ constructor(message: string, extraInfo?: Record<string, unknown>);
143
+ }
144
+
145
+ declare class StubAuthProvider implements AuthProvider {
146
+ addAuthHeaders(headers: Headers): Promise<Headers>;
147
+ isAuthorized(): Promise<boolean>;
148
+ addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
149
+ }
150
+
151
+ type GetLoggingEnabled = (() => Promise<boolean> | boolean) | undefined;
152
+ declare enum LoggingLevel {
153
+ Trace = 0,
154
+ Info = 1
155
+ }
156
+ declare class Logger {
157
+ context: string;
158
+ loggingEnabled: boolean;
159
+ loggingLevel: LoggingLevel;
160
+ constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled);
161
+ setLevel(level: LoggingLevel): void;
162
+ setEnabled(enabled: boolean, level?: LoggingLevel): void;
163
+ updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled): Promise<void>;
164
+ trace(message: string, ...rest: unknown[]): void;
165
+ info(message: string, ...rest: unknown[]): void;
166
+ }
167
+ declare const logger: Logger;
168
+
169
+ declare enum ServerEnvironment {
170
+ PRODUCTION = "production",
171
+ DEV = "dev"
172
+ }
173
+ declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
174
+
175
+ export { type AuthProvider, type CryptoInterface, DefaultCrypto, type GeneratedKeyPair, KeyOrAlias, type KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, LoggingLevel, NodeKeyCache, type Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment, logger };
@@ -0,0 +1,175 @@
1
+ import { Client } from 'graphql-ws';
2
+ import { Observable } from 'zen-observable-ts';
3
+ export { A as AppendUnitsOptions, ae as ById, ap as Complete, C as ConfigKeys, o as CurrencyAmountArg, k as CurrencyAmountInputObj, m as CurrencyAmountObj, n as CurrencyAmountPreferenceObj, Y as CurrencyCodes, X as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, ai as DeepPartial, D as DeprecatedCurrencyAmountObj, ad as ExpandRecursively, ah as ExtractByTypename, aj as JSONLiteral, al as JSONObject, ak as JSONType, ac as Maybe, am as NN, af as OmitTypename, ao as PartialBy, aq as RequiredKeys, S as SDKCurrencyAmountType, ar as StateCode, U as UmaCurrency, l as UmaCurrencyAmount, z as abbrCurrencyUnit, b as b64decode, a as b64encode, R as bytesToHex, a2 as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, W as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, a1 as deleteLocalStorageItem, e as ensureArray, Q as errorToJSON, B as formatCurrencyStr, G as formatInviteAmount, w as getCurrencyAmount, V as getCurrentLocale, O as getErrorMsg, $ as getLocalStorageBoolean, _ as getLocalStorageConfigItem, T as hexToBytes, K as isBare, H as isBrowser, p as isCurrencyAmountInputObj, s as isCurrencyAmountObj, t as isCurrencyAmountPreferenceObj, y as isCurrencyMap, r as isDeprecatedCurrencyAmountObj, M as isError, P as isErrorMsg, N as isErrorWithMessage, I as isNode, a5 as isNumber, aa as isObject, L as isReactNative, ab as isRecord, v as isSDKCurrencyAmount, J as isTest, ag as isType, a9 as isUint8Array, q as isUmaCurrencyAmount, a3 as linearInterpolate, Z as localeToCurrencyCode, F as localeToCurrencySymbol, a8 as lsidToUUID, x as mapCurrencyAmount, an as notNullUndefined, a6 as pollUntil, a4 as round, E as separateCurrencyStrParts, a0 as setLocalStorageBoolean, a7 as sleep, u as urlsafe_b64decode, at as zipcodeToState, as as zipcodeToStateCode } from '../index-CpAae9dR.js';
4
+
5
+ type Headers = Record<string, string>;
6
+ type WsConnectionParams = Record<string, unknown>;
7
+ interface AuthProvider {
8
+ addAuthHeaders(headers: Headers): Promise<Headers>;
9
+ isAuthorized(): Promise<boolean>;
10
+ addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
11
+ }
12
+
13
+ type Query<T> = {
14
+ /** The string representation of the query payload for graphQL. **/
15
+ queryPayload: string;
16
+ /** The variables that will be passed to the query. **/
17
+ variables?: {
18
+ [key: string]: unknown;
19
+ };
20
+ /**
21
+ * The function that will be called to construct the object from the
22
+ * response. *
23
+ */
24
+ constructObject: (rawData: any) => T | null;
25
+ /** The id of the node that will be used to sign the query. **/
26
+ signingNodeId?: string;
27
+ /** True if auth headers should be omitted for this query. **/
28
+ skipAuth?: boolean;
29
+ };
30
+
31
+ declare class LightsparkException extends Error {
32
+ code: string;
33
+ message: string;
34
+ extraInfo: Record<string, unknown> | undefined;
35
+ constructor(code: string, message: string, extraInfo?: Record<string, unknown>);
36
+ }
37
+
38
+ declare class LightsparkSigningException extends LightsparkException {
39
+ constructor(message: string, extraInfo?: Record<string, unknown>);
40
+ }
41
+
42
+ type GeneratedKeyPair = {
43
+ publicKey: CryptoKey | string;
44
+ privateKey: CryptoKey | string;
45
+ keyAlias?: string;
46
+ };
47
+ type CryptoInterface = {
48
+ decryptSecretWithNodePassword: (cipher: string, encryptedSecret: string, nodePassword: string) => Promise<ArrayBuffer | null>;
49
+ generateSigningKeyPair: () => Promise<GeneratedKeyPair>;
50
+ serializeSigningKey: (key: CryptoKey | string, format: "pkcs8" | "spki") => Promise<ArrayBuffer>;
51
+ getNonce: () => Promise<number>;
52
+ sign: (keyOrAlias: CryptoKey | string, data: Uint8Array) => Promise<ArrayBuffer>;
53
+ importPrivateSigningKey: (keyData: Uint8Array) => Promise<CryptoKey | string>;
54
+ };
55
+ declare function decryptSecretWithNodePassword(cipher: string, encryptedSecret: string, nodePassword: string): Promise<ArrayBuffer | null>;
56
+ declare const DefaultCrypto: {
57
+ decryptSecretWithNodePassword: typeof decryptSecretWithNodePassword;
58
+ generateSigningKeyPair: () => Promise<GeneratedKeyPair>;
59
+ serializeSigningKey: (key: CryptoKey | string, format: "pkcs8" | "spki") => Promise<ArrayBuffer>;
60
+ getNonce: () => Promise<number>;
61
+ sign: (keyOrAlias: CryptoKey | string, data: Uint8Array) => Promise<ArrayBuffer>;
62
+ importPrivateSigningKey: (keyData: Uint8Array) => Promise<CryptoKey | string>;
63
+ };
64
+
65
+ type OnlyKey = {
66
+ key: string;
67
+ alias?: never;
68
+ };
69
+ type OnlyAlias = {
70
+ key?: never;
71
+ alias: string;
72
+ };
73
+ type KeyOrAliasType = OnlyKey | OnlyAlias;
74
+ declare const KeyOrAlias: {
75
+ key: (key: string) => OnlyKey;
76
+ alias: (alias: string) => OnlyAlias;
77
+ };
78
+
79
+ declare enum SigningKeyType {
80
+ RSASigningKey = "RSASigningKey",
81
+ Secp256k1SigningKey = "Secp256k1SigningKey"
82
+ }
83
+
84
+ interface Alias {
85
+ alias: string;
86
+ }
87
+ declare abstract class SigningKey {
88
+ readonly type: SigningKeyType;
89
+ constructor(type: SigningKeyType);
90
+ abstract sign(data: Uint8Array): Promise<ArrayBuffer>;
91
+ }
92
+ declare class RSASigningKey extends SigningKey {
93
+ private readonly privateKey;
94
+ private readonly cryptoImpl;
95
+ constructor(privateKey: CryptoKey | Alias, cryptoImpl: CryptoInterface);
96
+ sign(data: Uint8Array): Promise<ArrayBuffer>;
97
+ }
98
+ declare class Secp256k1SigningKey extends SigningKey {
99
+ private readonly privateKey;
100
+ constructor(privateKey: string);
101
+ sign(data: Uint8Array): Promise<Uint8Array>;
102
+ }
103
+
104
+ declare class NodeKeyCache {
105
+ private readonly cryptoImpl;
106
+ private idToKey;
107
+ constructor(cryptoImpl?: CryptoInterface);
108
+ loadKey(id: string, keyOrAlias: KeyOrAliasType, signingKeyType: SigningKeyType): Promise<SigningKey | null>;
109
+ getKey(id: string): SigningKey | undefined;
110
+ hasKey(id: string): boolean;
111
+ private stripPemTags;
112
+ }
113
+
114
+ declare class Requester {
115
+ private readonly nodeKeyCache;
116
+ protected readonly schemaEndpoint: string;
117
+ private readonly sdkUserAgent;
118
+ private readonly authProvider;
119
+ protected readonly baseUrl: string;
120
+ private readonly cryptoImpl;
121
+ private readonly signingKey?;
122
+ private readonly fetchImpl;
123
+ protected wsClient: Promise<Client | null>;
124
+ protected resolveWsClient: ((value: Client | null) => void) | null;
125
+ constructor(nodeKeyCache: NodeKeyCache, schemaEndpoint: string, sdkUserAgent: string, authProvider?: AuthProvider, baseUrl?: string, cryptoImpl?: CryptoInterface, signingKey?: SigningKey | undefined, fetchImpl?: typeof fetch);
126
+ protected initWsClient(baseUrl: string, authProvider: AuthProvider): Promise<Client | null>;
127
+ executeQuery<T>(query: Query<T>): Promise<T | null>;
128
+ subscribe<T>(queryPayload: string, variables?: {
129
+ [key: string]: unknown;
130
+ }): Observable<{
131
+ data: T;
132
+ }>;
133
+ makeRawRequest(queryPayload: string, variables?: {
134
+ [key: string]: unknown;
135
+ }, signingNodeId?: string | undefined, skipAuth?: boolean): Promise<any>;
136
+ private getSdkUserAgent;
137
+ protected stripProtocol(url: string): string;
138
+ private addSigningDataIfNeeded;
139
+ }
140
+
141
+ declare class LightsparkAuthException extends LightsparkException {
142
+ constructor(message: string, extraInfo?: Record<string, unknown>);
143
+ }
144
+
145
+ declare class StubAuthProvider implements AuthProvider {
146
+ addAuthHeaders(headers: Headers): Promise<Headers>;
147
+ isAuthorized(): Promise<boolean>;
148
+ addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
149
+ }
150
+
151
+ type GetLoggingEnabled = (() => Promise<boolean> | boolean) | undefined;
152
+ declare enum LoggingLevel {
153
+ Trace = 0,
154
+ Info = 1
155
+ }
156
+ declare class Logger {
157
+ context: string;
158
+ loggingEnabled: boolean;
159
+ loggingLevel: LoggingLevel;
160
+ constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled);
161
+ setLevel(level: LoggingLevel): void;
162
+ setEnabled(enabled: boolean, level?: LoggingLevel): void;
163
+ updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled): Promise<void>;
164
+ trace(message: string, ...rest: unknown[]): void;
165
+ info(message: string, ...rest: unknown[]): void;
166
+ }
167
+ declare const logger: Logger;
168
+
169
+ declare enum ServerEnvironment {
170
+ PRODUCTION = "production",
171
+ DEV = "dev"
172
+ }
173
+ declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
174
+
175
+ export { type AuthProvider, type CryptoInterface, DefaultCrypto, type GeneratedKeyPair, KeyOrAlias, type KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, LoggingLevel, NodeKeyCache, type Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment, logger };
@@ -0,0 +1,154 @@
1
+ import {
2
+ ConfigKeys,
3
+ DefaultCrypto,
4
+ KeyOrAlias,
5
+ LightsparkAuthException_default,
6
+ LightsparkSigningException_default,
7
+ Logger,
8
+ LoggingLevel,
9
+ NodeKeyCache_default,
10
+ RSASigningKey,
11
+ Requester_default,
12
+ Secp256k1SigningKey,
13
+ ServerEnvironment_default,
14
+ SigningKey,
15
+ SigningKeyType,
16
+ StubAuthProvider,
17
+ apiDomainForEnvironment,
18
+ logger
19
+ } from "../chunk-L5YREN7B.js";
20
+ import {
21
+ CurrencyUnit,
22
+ LightsparkException_default,
23
+ abbrCurrencyUnit,
24
+ b64decode,
25
+ b64encode,
26
+ bytesToHex,
27
+ clamp,
28
+ convertCurrencyAmount,
29
+ convertCurrencyAmountValue,
30
+ countryCodesToCurrencyCodes,
31
+ createSha256Hash,
32
+ defaultCurrencyCode,
33
+ deleteLocalStorageItem,
34
+ ensureArray,
35
+ errorToJSON,
36
+ formatCurrencyStr,
37
+ formatInviteAmount,
38
+ getCurrencyAmount,
39
+ getCurrentLocale,
40
+ getErrorMsg,
41
+ getLocalStorageBoolean,
42
+ getLocalStorageConfigItem,
43
+ hexToBytes,
44
+ isBare,
45
+ isBrowser,
46
+ isCurrencyAmountInputObj,
47
+ isCurrencyAmountObj,
48
+ isCurrencyAmountPreferenceObj,
49
+ isCurrencyMap,
50
+ isDeprecatedCurrencyAmountObj,
51
+ isError,
52
+ isErrorMsg,
53
+ isErrorWithMessage,
54
+ isNode,
55
+ isNumber,
56
+ isObject,
57
+ isReactNative,
58
+ isRecord,
59
+ isSDKCurrencyAmount,
60
+ isTest,
61
+ isType,
62
+ isUint8Array,
63
+ isUmaCurrencyAmount,
64
+ linearInterpolate,
65
+ localeToCurrencyCode,
66
+ localeToCurrencySymbol,
67
+ lsidToUUID,
68
+ mapCurrencyAmount,
69
+ notNullUndefined,
70
+ pollUntil,
71
+ round,
72
+ separateCurrencyStrParts,
73
+ setLocalStorageBoolean,
74
+ sleep,
75
+ urlsafe_b64decode,
76
+ zipcodeToState,
77
+ zipcodeToStateCode
78
+ } from "../chunk-IWYMQNIA.js";
79
+ export {
80
+ ConfigKeys,
81
+ CurrencyUnit,
82
+ DefaultCrypto,
83
+ KeyOrAlias,
84
+ LightsparkAuthException_default as LightsparkAuthException,
85
+ LightsparkException_default as LightsparkException,
86
+ LightsparkSigningException_default as LightsparkSigningException,
87
+ Logger,
88
+ LoggingLevel,
89
+ NodeKeyCache_default as NodeKeyCache,
90
+ RSASigningKey,
91
+ Requester_default as Requester,
92
+ Secp256k1SigningKey,
93
+ ServerEnvironment_default as ServerEnvironment,
94
+ SigningKey,
95
+ SigningKeyType,
96
+ StubAuthProvider,
97
+ abbrCurrencyUnit,
98
+ apiDomainForEnvironment,
99
+ b64decode,
100
+ b64encode,
101
+ bytesToHex,
102
+ clamp,
103
+ convertCurrencyAmount,
104
+ convertCurrencyAmountValue,
105
+ countryCodesToCurrencyCodes,
106
+ createSha256Hash,
107
+ defaultCurrencyCode,
108
+ deleteLocalStorageItem,
109
+ ensureArray,
110
+ errorToJSON,
111
+ formatCurrencyStr,
112
+ formatInviteAmount,
113
+ getCurrencyAmount,
114
+ getCurrentLocale,
115
+ getErrorMsg,
116
+ getLocalStorageBoolean,
117
+ getLocalStorageConfigItem,
118
+ hexToBytes,
119
+ isBare,
120
+ isBrowser,
121
+ isCurrencyAmountInputObj,
122
+ isCurrencyAmountObj,
123
+ isCurrencyAmountPreferenceObj,
124
+ isCurrencyMap,
125
+ isDeprecatedCurrencyAmountObj,
126
+ isError,
127
+ isErrorMsg,
128
+ isErrorWithMessage,
129
+ isNode,
130
+ isNumber,
131
+ isObject,
132
+ isReactNative,
133
+ isRecord,
134
+ isSDKCurrencyAmount,
135
+ isTest,
136
+ isType,
137
+ isUint8Array,
138
+ isUmaCurrencyAmount,
139
+ linearInterpolate,
140
+ localeToCurrencyCode,
141
+ localeToCurrencySymbol,
142
+ logger,
143
+ lsidToUUID,
144
+ mapCurrencyAmount,
145
+ notNullUndefined,
146
+ pollUntil,
147
+ round,
148
+ separateCurrencyStrParts,
149
+ setLocalStorageBoolean,
150
+ sleep,
151
+ urlsafe_b64decode,
152
+ zipcodeToState,
153
+ zipcodeToStateCode
154
+ };
@@ -65,6 +65,7 @@ __export(utils_exports, {
65
65
  isNode: () => isNode,
66
66
  isNumber: () => isNumber,
67
67
  isObject: () => isObject,
68
+ isReactNative: () => isReactNative,
68
69
  isRecord: () => isRecord,
69
70
  isSDKCurrencyAmount: () => isSDKCurrencyAmount,
70
71
  isTest: () => isTest,
@@ -141,6 +142,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
141
142
  var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
142
143
  var isTest = isNode && process.env.NODE_ENV === "test";
143
144
  var isBare = typeof Bare !== "undefined";
145
+ var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
144
146
 
145
147
  // src/utils/hex.ts
146
148
  var bytesToHex = (bytes) => {
@@ -502,6 +504,7 @@ var CurrencyUnit = {
502
504
  EUR: "EUR",
503
505
  GBP: "GBP",
504
506
  INR: "INR",
507
+ USDT: "USDT",
505
508
  Bitcoin: "BITCOIN",
506
509
  Microbitcoin: "MICROBITCOIN",
507
510
  Millibitcoin: "MILLIBITCOIN",
@@ -512,7 +515,8 @@ var CurrencyUnit = {
512
515
  Mxn: "MXN",
513
516
  Php: "PHP",
514
517
  Gbp: "GBP",
515
- Inr: "INR"
518
+ Inr: "INR",
519
+ Usdt: "USDT"
516
520
  };
517
521
  var standardUnitConversionObj = {
518
522
  [CurrencyUnit.BITCOIN]: (v, unitsPerBtc = 1) => v / unitsPerBtc,
@@ -527,7 +531,8 @@ var standardUnitConversionObj = {
527
531
  [CurrencyUnit.PHP]: (v) => v,
528
532
  [CurrencyUnit.EUR]: (v) => v,
529
533
  [CurrencyUnit.GBP]: (v) => v,
530
- [CurrencyUnit.INR]: (v) => v
534
+ [CurrencyUnit.INR]: (v) => v,
535
+ [CurrencyUnit.USDT]: (v) => v
531
536
  };
532
537
  var toBitcoinConversion = (v, unitsPerBtc = 1) => round(v * unitsPerBtc);
533
538
  var toMicrobitcoinConversion = (v, unitsPerBtc = 1) => round(v / 1e6 * unitsPerBtc);
@@ -548,7 +553,8 @@ var CONVERSION_MAP = {
548
553
  [CurrencyUnit.PHP]: toBitcoinConversion,
549
554
  [CurrencyUnit.EUR]: toBitcoinConversion,
550
555
  [CurrencyUnit.GBP]: toBitcoinConversion,
551
- [CurrencyUnit.INR]: toBitcoinConversion
556
+ [CurrencyUnit.INR]: toBitcoinConversion,
557
+ [CurrencyUnit.USDT]: toBitcoinConversion
552
558
  },
553
559
  [CurrencyUnit.MICROBITCOIN]: {
554
560
  [CurrencyUnit.BITCOIN]: (v) => v / 1e6,
@@ -562,7 +568,8 @@ var CONVERSION_MAP = {
562
568
  [CurrencyUnit.PHP]: toMicrobitcoinConversion,
563
569
  [CurrencyUnit.EUR]: toMicrobitcoinConversion,
564
570
  [CurrencyUnit.GBP]: toMicrobitcoinConversion,
565
- [CurrencyUnit.INR]: toMicrobitcoinConversion
571
+ [CurrencyUnit.INR]: toMicrobitcoinConversion,
572
+ [CurrencyUnit.USDT]: toMicrobitcoinConversion
566
573
  },
567
574
  [CurrencyUnit.MILLIBITCOIN]: {
568
575
  [CurrencyUnit.BITCOIN]: (v) => v / 1e3,
@@ -576,7 +583,8 @@ var CONVERSION_MAP = {
576
583
  [CurrencyUnit.PHP]: toMillibitcoinConversion,
577
584
  [CurrencyUnit.EUR]: toMillibitcoinConversion,
578
585
  [CurrencyUnit.GBP]: toMillibitcoinConversion,
579
- [CurrencyUnit.INR]: toMillibitcoinConversion
586
+ [CurrencyUnit.INR]: toMillibitcoinConversion,
587
+ [CurrencyUnit.USDT]: toMillibitcoinConversion
580
588
  },
581
589
  [CurrencyUnit.MILLISATOSHI]: {
582
590
  [CurrencyUnit.BITCOIN]: (v) => v / 1e11,
@@ -590,7 +598,8 @@ var CONVERSION_MAP = {
590
598
  [CurrencyUnit.PHP]: toMillisatoshiConversion,
591
599
  [CurrencyUnit.EUR]: toMillisatoshiConversion,
592
600
  [CurrencyUnit.GBP]: toMillisatoshiConversion,
593
- [CurrencyUnit.INR]: toMillisatoshiConversion
601
+ [CurrencyUnit.INR]: toMillisatoshiConversion,
602
+ [CurrencyUnit.USDT]: toMillisatoshiConversion
594
603
  },
595
604
  [CurrencyUnit.NANOBITCOIN]: {
596
605
  [CurrencyUnit.BITCOIN]: (v) => v / 1e9,
@@ -604,7 +613,8 @@ var CONVERSION_MAP = {
604
613
  [CurrencyUnit.PHP]: toNanobitcoinConversion,
605
614
  [CurrencyUnit.EUR]: toNanobitcoinConversion,
606
615
  [CurrencyUnit.GBP]: toNanobitcoinConversion,
607
- [CurrencyUnit.INR]: toNanobitcoinConversion
616
+ [CurrencyUnit.INR]: toNanobitcoinConversion,
617
+ [CurrencyUnit.USDT]: toNanobitcoinConversion
608
618
  },
609
619
  [CurrencyUnit.SATOSHI]: {
610
620
  [CurrencyUnit.BITCOIN]: (v) => v / 1e8,
@@ -618,14 +628,16 @@ var CONVERSION_MAP = {
618
628
  [CurrencyUnit.PHP]: toSatoshiConversion,
619
629
  [CurrencyUnit.EUR]: toSatoshiConversion,
620
630
  [CurrencyUnit.GBP]: toSatoshiConversion,
621
- [CurrencyUnit.INR]: toSatoshiConversion
631
+ [CurrencyUnit.INR]: toSatoshiConversion,
632
+ [CurrencyUnit.USDT]: toSatoshiConversion
622
633
  },
623
634
  [CurrencyUnit.USD]: standardUnitConversionObj,
624
635
  [CurrencyUnit.MXN]: standardUnitConversionObj,
625
636
  [CurrencyUnit.PHP]: standardUnitConversionObj,
626
637
  [CurrencyUnit.EUR]: standardUnitConversionObj,
627
638
  [CurrencyUnit.GBP]: standardUnitConversionObj,
628
- [CurrencyUnit.INR]: standardUnitConversionObj
639
+ [CurrencyUnit.INR]: standardUnitConversionObj,
640
+ [CurrencyUnit.USDT]: standardUnitConversionObj
629
641
  };
630
642
  function convertCurrencyAmountValue(fromUnit, toUnit, amount, unitsPerBtc = 1) {
631
643
  if (fromUnit === CurrencyUnit.FUTURE_VALUE || toUnit === CurrencyUnit.FUTURE_VALUE) {
@@ -713,7 +725,8 @@ function convertCurrencyAmountValues(fromUnit, amount, unitsPerBtc = 1, conversi
713
725
  inr: CurrencyUnit.INR,
714
726
  mibtc: CurrencyUnit.MICROBITCOIN,
715
727
  mlbtc: CurrencyUnit.MILLIBITCOIN,
716
- nbtc: CurrencyUnit.NANOBITCOIN
728
+ nbtc: CurrencyUnit.NANOBITCOIN,
729
+ usdt: CurrencyUnit.USDT
717
730
  };
718
731
  return Object.entries(namesToUnits).reduce(
719
732
  (acc, [name, unit]) => {
@@ -749,7 +762,21 @@ function getPreferredConversionOverride(currencyAmountArg) {
749
762
  function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
750
763
  const { value, unit } = getCurrencyAmount(currencyAmountArg);
751
764
  const conversionOverride = getPreferredConversionOverride(currencyAmountArg);
752
- const { sats, msats, btc, usd, mxn, php, mibtc, mlbtc, nbtc, eur, gbp, inr } = convertCurrencyAmountValues(unit, value, unitsPerBtc, conversionOverride);
765
+ const {
766
+ sats,
767
+ msats,
768
+ btc,
769
+ usd,
770
+ mxn,
771
+ php,
772
+ mibtc,
773
+ mlbtc,
774
+ nbtc,
775
+ eur,
776
+ gbp,
777
+ inr,
778
+ usdt
779
+ } = convertCurrencyAmountValues(unit, value, unitsPerBtc, conversionOverride);
753
780
  const mapWithCurrencyUnits = {
754
781
  [CurrencyUnit.BITCOIN]: btc,
755
782
  [CurrencyUnit.SATOSHI]: sats,
@@ -763,6 +790,7 @@ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
763
790
  [CurrencyUnit.MICROBITCOIN]: mibtc,
764
791
  [CurrencyUnit.MILLIBITCOIN]: mlbtc,
765
792
  [CurrencyUnit.NANOBITCOIN]: nbtc,
793
+ [CurrencyUnit.USDT]: usdt,
766
794
  [CurrencyUnit.FUTURE_VALUE]: NaN,
767
795
  formatted: {
768
796
  [CurrencyUnit.BITCOIN]: formatCurrencyStr({
@@ -813,6 +841,10 @@ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
813
841
  value: inr,
814
842
  unit: CurrencyUnit.INR
815
843
  }),
844
+ [CurrencyUnit.USDT]: formatCurrencyStr({
845
+ value: usdt,
846
+ unit: CurrencyUnit.USDT
847
+ }),
816
848
  [CurrencyUnit.FUTURE_VALUE]: "-"
817
849
  }
818
850
  };
@@ -883,6 +915,8 @@ var abbrCurrencyUnit = (unit) => {
883
915
  return "GBP";
884
916
  case CurrencyUnit.INR:
885
917
  return "INR";
918
+ case CurrencyUnit.USDT:
919
+ return "USDT";
886
920
  }
887
921
  return "Unsupported CurrencyUnit";
888
922
  };
@@ -2350,6 +2384,7 @@ function zipcodeToState(zipcode) {
2350
2384
  isNode,
2351
2385
  isNumber,
2352
2386
  isObject,
2387
+ isReactNative,
2353
2388
  isRecord,
2354
2389
  isSDKCurrencyAmount,
2355
2390
  isTest,
@@ -1 +1 @@
1
- export { A as AppendUnitsOptions, ad as ById, ao as Complete, o as CurrencyAmountArg, k as CurrencyAmountInputObj, m as CurrencyAmountObj, n as CurrencyAmountPreferenceObj, X as CurrencyCodes, W as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, ah as DeepPartial, D as DeprecatedCurrencyAmountObj, ac as ExpandRecursively, ag as ExtractByTypename, ai as JSONLiteral, ak as JSONObject, aj as JSONType, ab as Maybe, al as NN, ae as OmitTypename, an as PartialBy, ap as RequiredKeys, S as SDKCurrencyAmountType, aq as StateCode, U as UmaCurrency, l as UmaCurrencyAmount, z as abbrCurrencyUnit, b as b64decode, a as b64encode, Q as bytesToHex, a1 as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, V as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, a0 as deleteLocalStorageItem, e as ensureArray, P as errorToJSON, B as formatCurrencyStr, G as formatInviteAmount, w as getCurrencyAmount, T as getCurrentLocale, N as getErrorMsg, _ as getLocalStorageBoolean, Z as getLocalStorageConfigItem, R as hexToBytes, K as isBare, H as isBrowser, p as isCurrencyAmountInputObj, s as isCurrencyAmountObj, t as isCurrencyAmountPreferenceObj, y as isCurrencyMap, r as isDeprecatedCurrencyAmountObj, L as isError, O as isErrorMsg, M as isErrorWithMessage, I as isNode, a4 as isNumber, a9 as isObject, aa as isRecord, v as isSDKCurrencyAmount, J as isTest, af as isType, a8 as isUint8Array, q as isUmaCurrencyAmount, a2 as linearInterpolate, Y as localeToCurrencyCode, F as localeToCurrencySymbol, a7 as lsidToUUID, x as mapCurrencyAmount, am as notNullUndefined, a5 as pollUntil, a3 as round, E as separateCurrencyStrParts, $ as setLocalStorageBoolean, a6 as sleep, u as urlsafe_b64decode, as as zipcodeToState, ar as zipcodeToStateCode } from '../index-gUXiTlhb.cjs';
1
+ export { A as AppendUnitsOptions, ae as ById, ap as Complete, o as CurrencyAmountArg, k as CurrencyAmountInputObj, m as CurrencyAmountObj, n as CurrencyAmountPreferenceObj, Y as CurrencyCodes, X as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, ai as DeepPartial, D as DeprecatedCurrencyAmountObj, ad as ExpandRecursively, ah as ExtractByTypename, aj as JSONLiteral, al as JSONObject, ak as JSONType, ac as Maybe, am as NN, af as OmitTypename, ao as PartialBy, aq as RequiredKeys, S as SDKCurrencyAmountType, ar as StateCode, U as UmaCurrency, l as UmaCurrencyAmount, z as abbrCurrencyUnit, b as b64decode, a as b64encode, R as bytesToHex, a2 as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, W as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, a1 as deleteLocalStorageItem, e as ensureArray, Q as errorToJSON, B as formatCurrencyStr, G as formatInviteAmount, w as getCurrencyAmount, V as getCurrentLocale, O as getErrorMsg, $ as getLocalStorageBoolean, _ as getLocalStorageConfigItem, T as hexToBytes, K as isBare, H as isBrowser, p as isCurrencyAmountInputObj, s as isCurrencyAmountObj, t as isCurrencyAmountPreferenceObj, y as isCurrencyMap, r as isDeprecatedCurrencyAmountObj, M as isError, P as isErrorMsg, N as isErrorWithMessage, I as isNode, a5 as isNumber, aa as isObject, L as isReactNative, ab as isRecord, v as isSDKCurrencyAmount, J as isTest, ag as isType, a9 as isUint8Array, q as isUmaCurrencyAmount, a3 as linearInterpolate, Z as localeToCurrencyCode, F as localeToCurrencySymbol, a8 as lsidToUUID, x as mapCurrencyAmount, an as notNullUndefined, a6 as pollUntil, a4 as round, E as separateCurrencyStrParts, a0 as setLocalStorageBoolean, a7 as sleep, u as urlsafe_b64decode, at as zipcodeToState, as as zipcodeToStateCode } from '../index-CpAae9dR.cjs';