@lightsparkdev/core 1.4.2 → 1.4.4
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 +14 -0
- package/README.md +0 -2
- package/dist/{chunk-CP4LQTTD.js → chunk-ADHQHZNM.js} +50 -18
- package/dist/chunk-VY7NND44.js +713 -0
- package/dist/{index-BCTAeaWD.d.cts → index-CFQtMxrx.d.cts} +18 -2
- package/dist/{index-BCTAeaWD.d.ts → index-CFQtMxrx.d.ts} +18 -2
- package/dist/index.cjs +2586 -2532
- package/dist/index.d.cts +8 -171
- package/dist/index.d.ts +8 -171
- package/dist/index.js +34 -674
- package/dist/react-native/index.cjs +3111 -0
- package/dist/react-native/index.d.cts +175 -0
- package/dist/react-native/index.d.ts +175 -0
- package/dist/react-native/index.js +154 -0
- package/dist/utils/index.cjs +45 -10
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +7 -1
- package/package.json +15 -1
- package/src/Logger.ts +2 -1
- package/src/crypto/SigningKey.ts +4 -2
- package/src/index.ts +3 -11
- package/src/react-native/index.ts +2 -0
- package/src/requester/DefaultRequester.ts +46 -0
- package/src/requester/Requester.ts +21 -37
- package/src/requester/tests/DefaultRequester.test.ts +129 -0
- package/src/requester/tests/Requester.test.ts +23 -32
- package/src/shared.ts +10 -0
- package/src/utils/currency.ts +42 -1
- package/src/utils/environment.ts +10 -0
|
@@ -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-CFQtMxrx.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-CFQtMxrx.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-VY7NND44.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-ADHQHZNM.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
|
+
};
|