@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
package/dist/index.d.cts
CHANGED
|
@@ -1,174 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
import * as graphql_ws from 'graphql-ws';
|
|
2
|
+
import { Requester, AuthProvider } from './react-native/index.cjs';
|
|
3
|
+
export { CryptoInterface, DefaultCrypto, GeneratedKeyPair, KeyOrAlias, KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, LoggingLevel, NodeKeyCache, Query, RSASigningKey, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment, logger } from './react-native/index.cjs';
|
|
4
|
+
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';
|
|
5
|
+
import 'zen-observable-ts';
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
interface AuthProvider {
|
|
7
|
-
addAuthHeaders(headers: Headers): Promise<Headers>;
|
|
8
|
-
isAuthorized(): Promise<boolean>;
|
|
9
|
-
addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
|
|
7
|
+
declare class DefaultRequester extends Requester {
|
|
8
|
+
protected initWsClient(baseUrl: string, authProvider: AuthProvider): Promise<graphql_ws.Client | null>;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
code: string;
|
|
14
|
-
message: string;
|
|
15
|
-
extraInfo: Record<string, unknown> | undefined;
|
|
16
|
-
constructor(code: string, message: string, extraInfo?: Record<string, unknown>);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
declare class LightsparkAuthException extends LightsparkException {
|
|
20
|
-
constructor(message: string, extraInfo?: Record<string, unknown>);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
declare class StubAuthProvider implements AuthProvider {
|
|
24
|
-
addAuthHeaders(headers: Headers): Promise<Headers>;
|
|
25
|
-
isAuthorized(): Promise<boolean>;
|
|
26
|
-
addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
declare class LightsparkSigningException extends LightsparkException {
|
|
30
|
-
constructor(message: string, extraInfo?: Record<string, unknown>);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
type GeneratedKeyPair = {
|
|
34
|
-
publicKey: CryptoKey | string;
|
|
35
|
-
privateKey: CryptoKey | string;
|
|
36
|
-
keyAlias?: string;
|
|
37
|
-
};
|
|
38
|
-
type CryptoInterface = {
|
|
39
|
-
decryptSecretWithNodePassword: (cipher: string, encryptedSecret: string, nodePassword: string) => Promise<ArrayBuffer | null>;
|
|
40
|
-
generateSigningKeyPair: () => Promise<GeneratedKeyPair>;
|
|
41
|
-
serializeSigningKey: (key: CryptoKey | string, format: "pkcs8" | "spki") => Promise<ArrayBuffer>;
|
|
42
|
-
getNonce: () => Promise<number>;
|
|
43
|
-
sign: (keyOrAlias: CryptoKey | string, data: Uint8Array) => Promise<ArrayBuffer>;
|
|
44
|
-
importPrivateSigningKey: (keyData: Uint8Array) => Promise<CryptoKey | string>;
|
|
45
|
-
};
|
|
46
|
-
declare function decryptSecretWithNodePassword(cipher: string, encryptedSecret: string, nodePassword: string): Promise<ArrayBuffer | null>;
|
|
47
|
-
declare const DefaultCrypto: {
|
|
48
|
-
decryptSecretWithNodePassword: typeof decryptSecretWithNodePassword;
|
|
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
|
-
|
|
56
|
-
type OnlyKey = {
|
|
57
|
-
key: string;
|
|
58
|
-
alias?: never;
|
|
59
|
-
};
|
|
60
|
-
type OnlyAlias = {
|
|
61
|
-
key?: never;
|
|
62
|
-
alias: string;
|
|
63
|
-
};
|
|
64
|
-
type KeyOrAliasType = OnlyKey | OnlyAlias;
|
|
65
|
-
declare const KeyOrAlias: {
|
|
66
|
-
key: (key: string) => OnlyKey;
|
|
67
|
-
alias: (alias: string) => OnlyAlias;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
interface Alias {
|
|
71
|
-
alias: string;
|
|
72
|
-
}
|
|
73
|
-
declare abstract class SigningKey {
|
|
74
|
-
readonly type: SigningKeyType;
|
|
75
|
-
constructor(type: SigningKeyType);
|
|
76
|
-
abstract sign(data: Uint8Array): Promise<ArrayBuffer>;
|
|
77
|
-
}
|
|
78
|
-
declare class RSASigningKey extends SigningKey {
|
|
79
|
-
private readonly privateKey;
|
|
80
|
-
private readonly cryptoImpl;
|
|
81
|
-
constructor(privateKey: CryptoKey | Alias, cryptoImpl: CryptoInterface);
|
|
82
|
-
sign(data: Uint8Array): Promise<ArrayBuffer>;
|
|
83
|
-
}
|
|
84
|
-
declare class Secp256k1SigningKey extends SigningKey {
|
|
85
|
-
private readonly privateKey;
|
|
86
|
-
constructor(privateKey: string);
|
|
87
|
-
sign(data: Uint8Array): Promise<Uint8Array>;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
declare enum SigningKeyType {
|
|
91
|
-
RSASigningKey = "RSASigningKey",
|
|
92
|
-
Secp256k1SigningKey = "Secp256k1SigningKey"
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
declare class NodeKeyCache {
|
|
96
|
-
private readonly cryptoImpl;
|
|
97
|
-
private idToKey;
|
|
98
|
-
constructor(cryptoImpl?: CryptoInterface);
|
|
99
|
-
loadKey(id: string, keyOrAlias: KeyOrAliasType, signingKeyType: SigningKeyType): Promise<SigningKey | null>;
|
|
100
|
-
getKey(id: string): SigningKey | undefined;
|
|
101
|
-
hasKey(id: string): boolean;
|
|
102
|
-
private stripPemTags;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
type GetLoggingEnabled = (() => Promise<boolean> | boolean) | undefined;
|
|
106
|
-
declare enum LoggingLevel {
|
|
107
|
-
Trace = 0,
|
|
108
|
-
Info = 1
|
|
109
|
-
}
|
|
110
|
-
declare class Logger {
|
|
111
|
-
context: string;
|
|
112
|
-
loggingEnabled: boolean;
|
|
113
|
-
loggingLevel: LoggingLevel;
|
|
114
|
-
constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled);
|
|
115
|
-
setLevel(level: LoggingLevel): void;
|
|
116
|
-
setEnabled(enabled: boolean, level?: LoggingLevel): void;
|
|
117
|
-
updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled): Promise<void>;
|
|
118
|
-
trace(message: string, ...rest: unknown[]): void;
|
|
119
|
-
info(message: string, ...rest: unknown[]): void;
|
|
120
|
-
}
|
|
121
|
-
declare const logger: Logger;
|
|
122
|
-
|
|
123
|
-
type Query<T> = {
|
|
124
|
-
/** The string representation of the query payload for graphQL. **/
|
|
125
|
-
queryPayload: string;
|
|
126
|
-
/** The variables that will be passed to the query. **/
|
|
127
|
-
variables?: {
|
|
128
|
-
[key: string]: unknown;
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* The function that will be called to construct the object from the
|
|
132
|
-
* response. *
|
|
133
|
-
*/
|
|
134
|
-
constructObject: (rawData: any) => T | null;
|
|
135
|
-
/** The id of the node that will be used to sign the query. **/
|
|
136
|
-
signingNodeId?: string;
|
|
137
|
-
/** True if auth headers should be omitted for this query. **/
|
|
138
|
-
skipAuth?: boolean;
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
declare class Requester {
|
|
142
|
-
private readonly nodeKeyCache;
|
|
143
|
-
private readonly schemaEndpoint;
|
|
144
|
-
private readonly sdkUserAgent;
|
|
145
|
-
private readonly authProvider;
|
|
146
|
-
private readonly baseUrl;
|
|
147
|
-
private readonly cryptoImpl;
|
|
148
|
-
private readonly signingKey?;
|
|
149
|
-
private readonly fetchImpl;
|
|
150
|
-
private wsClient;
|
|
151
|
-
private resolveWsClient;
|
|
152
|
-
constructor(nodeKeyCache: NodeKeyCache, schemaEndpoint: string, sdkUserAgent: string, authProvider?: AuthProvider, baseUrl?: string, cryptoImpl?: CryptoInterface, signingKey?: SigningKey | undefined, fetchImpl?: typeof fetch);
|
|
153
|
-
private initWsClient;
|
|
154
|
-
executeQuery<T>(query: Query<T>): Promise<T | null>;
|
|
155
|
-
subscribe<T>(queryPayload: string, variables?: {
|
|
156
|
-
[key: string]: unknown;
|
|
157
|
-
}): Observable<{
|
|
158
|
-
data: T;
|
|
159
|
-
}>;
|
|
160
|
-
makeRawRequest(queryPayload: string, variables?: {
|
|
161
|
-
[key: string]: unknown;
|
|
162
|
-
}, signingNodeId?: string | undefined, skipAuth?: boolean): Promise<any>;
|
|
163
|
-
private getSdkUserAgent;
|
|
164
|
-
private stripProtocol;
|
|
165
|
-
private addSigningDataIfNeeded;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
declare enum ServerEnvironment {
|
|
169
|
-
PRODUCTION = "production",
|
|
170
|
-
DEV = "dev"
|
|
171
|
-
}
|
|
172
|
-
declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
|
|
173
|
-
|
|
174
|
-
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 };
|
|
11
|
+
export { AuthProvider, DefaultRequester as Requester };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,174 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
import * as graphql_ws from 'graphql-ws';
|
|
2
|
+
import { Requester, AuthProvider } from './react-native/index.js';
|
|
3
|
+
export { CryptoInterface, DefaultCrypto, GeneratedKeyPair, KeyOrAlias, KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, LoggingLevel, NodeKeyCache, Query, RSASigningKey, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment, logger } from './react-native/index.js';
|
|
4
|
+
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';
|
|
5
|
+
import 'zen-observable-ts';
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
interface AuthProvider {
|
|
7
|
-
addAuthHeaders(headers: Headers): Promise<Headers>;
|
|
8
|
-
isAuthorized(): Promise<boolean>;
|
|
9
|
-
addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
|
|
7
|
+
declare class DefaultRequester extends Requester {
|
|
8
|
+
protected initWsClient(baseUrl: string, authProvider: AuthProvider): Promise<graphql_ws.Client | null>;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
code: string;
|
|
14
|
-
message: string;
|
|
15
|
-
extraInfo: Record<string, unknown> | undefined;
|
|
16
|
-
constructor(code: string, message: string, extraInfo?: Record<string, unknown>);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
declare class LightsparkAuthException extends LightsparkException {
|
|
20
|
-
constructor(message: string, extraInfo?: Record<string, unknown>);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
declare class StubAuthProvider implements AuthProvider {
|
|
24
|
-
addAuthHeaders(headers: Headers): Promise<Headers>;
|
|
25
|
-
isAuthorized(): Promise<boolean>;
|
|
26
|
-
addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
declare class LightsparkSigningException extends LightsparkException {
|
|
30
|
-
constructor(message: string, extraInfo?: Record<string, unknown>);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
type GeneratedKeyPair = {
|
|
34
|
-
publicKey: CryptoKey | string;
|
|
35
|
-
privateKey: CryptoKey | string;
|
|
36
|
-
keyAlias?: string;
|
|
37
|
-
};
|
|
38
|
-
type CryptoInterface = {
|
|
39
|
-
decryptSecretWithNodePassword: (cipher: string, encryptedSecret: string, nodePassword: string) => Promise<ArrayBuffer | null>;
|
|
40
|
-
generateSigningKeyPair: () => Promise<GeneratedKeyPair>;
|
|
41
|
-
serializeSigningKey: (key: CryptoKey | string, format: "pkcs8" | "spki") => Promise<ArrayBuffer>;
|
|
42
|
-
getNonce: () => Promise<number>;
|
|
43
|
-
sign: (keyOrAlias: CryptoKey | string, data: Uint8Array) => Promise<ArrayBuffer>;
|
|
44
|
-
importPrivateSigningKey: (keyData: Uint8Array) => Promise<CryptoKey | string>;
|
|
45
|
-
};
|
|
46
|
-
declare function decryptSecretWithNodePassword(cipher: string, encryptedSecret: string, nodePassword: string): Promise<ArrayBuffer | null>;
|
|
47
|
-
declare const DefaultCrypto: {
|
|
48
|
-
decryptSecretWithNodePassword: typeof decryptSecretWithNodePassword;
|
|
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
|
-
|
|
56
|
-
type OnlyKey = {
|
|
57
|
-
key: string;
|
|
58
|
-
alias?: never;
|
|
59
|
-
};
|
|
60
|
-
type OnlyAlias = {
|
|
61
|
-
key?: never;
|
|
62
|
-
alias: string;
|
|
63
|
-
};
|
|
64
|
-
type KeyOrAliasType = OnlyKey | OnlyAlias;
|
|
65
|
-
declare const KeyOrAlias: {
|
|
66
|
-
key: (key: string) => OnlyKey;
|
|
67
|
-
alias: (alias: string) => OnlyAlias;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
interface Alias {
|
|
71
|
-
alias: string;
|
|
72
|
-
}
|
|
73
|
-
declare abstract class SigningKey {
|
|
74
|
-
readonly type: SigningKeyType;
|
|
75
|
-
constructor(type: SigningKeyType);
|
|
76
|
-
abstract sign(data: Uint8Array): Promise<ArrayBuffer>;
|
|
77
|
-
}
|
|
78
|
-
declare class RSASigningKey extends SigningKey {
|
|
79
|
-
private readonly privateKey;
|
|
80
|
-
private readonly cryptoImpl;
|
|
81
|
-
constructor(privateKey: CryptoKey | Alias, cryptoImpl: CryptoInterface);
|
|
82
|
-
sign(data: Uint8Array): Promise<ArrayBuffer>;
|
|
83
|
-
}
|
|
84
|
-
declare class Secp256k1SigningKey extends SigningKey {
|
|
85
|
-
private readonly privateKey;
|
|
86
|
-
constructor(privateKey: string);
|
|
87
|
-
sign(data: Uint8Array): Promise<Uint8Array>;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
declare enum SigningKeyType {
|
|
91
|
-
RSASigningKey = "RSASigningKey",
|
|
92
|
-
Secp256k1SigningKey = "Secp256k1SigningKey"
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
declare class NodeKeyCache {
|
|
96
|
-
private readonly cryptoImpl;
|
|
97
|
-
private idToKey;
|
|
98
|
-
constructor(cryptoImpl?: CryptoInterface);
|
|
99
|
-
loadKey(id: string, keyOrAlias: KeyOrAliasType, signingKeyType: SigningKeyType): Promise<SigningKey | null>;
|
|
100
|
-
getKey(id: string): SigningKey | undefined;
|
|
101
|
-
hasKey(id: string): boolean;
|
|
102
|
-
private stripPemTags;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
type GetLoggingEnabled = (() => Promise<boolean> | boolean) | undefined;
|
|
106
|
-
declare enum LoggingLevel {
|
|
107
|
-
Trace = 0,
|
|
108
|
-
Info = 1
|
|
109
|
-
}
|
|
110
|
-
declare class Logger {
|
|
111
|
-
context: string;
|
|
112
|
-
loggingEnabled: boolean;
|
|
113
|
-
loggingLevel: LoggingLevel;
|
|
114
|
-
constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled);
|
|
115
|
-
setLevel(level: LoggingLevel): void;
|
|
116
|
-
setEnabled(enabled: boolean, level?: LoggingLevel): void;
|
|
117
|
-
updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled): Promise<void>;
|
|
118
|
-
trace(message: string, ...rest: unknown[]): void;
|
|
119
|
-
info(message: string, ...rest: unknown[]): void;
|
|
120
|
-
}
|
|
121
|
-
declare const logger: Logger;
|
|
122
|
-
|
|
123
|
-
type Query<T> = {
|
|
124
|
-
/** The string representation of the query payload for graphQL. **/
|
|
125
|
-
queryPayload: string;
|
|
126
|
-
/** The variables that will be passed to the query. **/
|
|
127
|
-
variables?: {
|
|
128
|
-
[key: string]: unknown;
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* The function that will be called to construct the object from the
|
|
132
|
-
* response. *
|
|
133
|
-
*/
|
|
134
|
-
constructObject: (rawData: any) => T | null;
|
|
135
|
-
/** The id of the node that will be used to sign the query. **/
|
|
136
|
-
signingNodeId?: string;
|
|
137
|
-
/** True if auth headers should be omitted for this query. **/
|
|
138
|
-
skipAuth?: boolean;
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
declare class Requester {
|
|
142
|
-
private readonly nodeKeyCache;
|
|
143
|
-
private readonly schemaEndpoint;
|
|
144
|
-
private readonly sdkUserAgent;
|
|
145
|
-
private readonly authProvider;
|
|
146
|
-
private readonly baseUrl;
|
|
147
|
-
private readonly cryptoImpl;
|
|
148
|
-
private readonly signingKey?;
|
|
149
|
-
private readonly fetchImpl;
|
|
150
|
-
private wsClient;
|
|
151
|
-
private resolveWsClient;
|
|
152
|
-
constructor(nodeKeyCache: NodeKeyCache, schemaEndpoint: string, sdkUserAgent: string, authProvider?: AuthProvider, baseUrl?: string, cryptoImpl?: CryptoInterface, signingKey?: SigningKey | undefined, fetchImpl?: typeof fetch);
|
|
153
|
-
private initWsClient;
|
|
154
|
-
executeQuery<T>(query: Query<T>): Promise<T | null>;
|
|
155
|
-
subscribe<T>(queryPayload: string, variables?: {
|
|
156
|
-
[key: string]: unknown;
|
|
157
|
-
}): Observable<{
|
|
158
|
-
data: T;
|
|
159
|
-
}>;
|
|
160
|
-
makeRawRequest(queryPayload: string, variables?: {
|
|
161
|
-
[key: string]: unknown;
|
|
162
|
-
}, signingNodeId?: string | undefined, skipAuth?: boolean): Promise<any>;
|
|
163
|
-
private getSdkUserAgent;
|
|
164
|
-
private stripProtocol;
|
|
165
|
-
private addSigningDataIfNeeded;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
declare enum ServerEnvironment {
|
|
169
|
-
PRODUCTION = "production",
|
|
170
|
-
DEV = "dev"
|
|
171
|
-
}
|
|
172
|
-
declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
|
|
173
|
-
|
|
174
|
-
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 };
|
|
11
|
+
export { AuthProvider, DefaultRequester as Requester };
|