@lightsparkdev/core 1.2.7 → 1.2.8
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 +6 -0
- package/dist/index.cjs +5 -3
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +5 -3
- package/package.json +1 -1
- package/src/requester/Requester.ts +5 -2
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1588,13 +1588,15 @@ var import_zen_observable_ts = require("zen-observable-ts");
|
|
|
1588
1588
|
var DEFAULT_BASE_URL = "api.lightspark.com";
|
|
1589
1589
|
import_dayjs.default.extend(import_utc.default);
|
|
1590
1590
|
var Requester = class {
|
|
1591
|
-
constructor(nodeKeyCache, schemaEndpoint, sdkUserAgent, authProvider = new StubAuthProvider(), baseUrl = DEFAULT_BASE_URL, cryptoImpl = DefaultCrypto) {
|
|
1591
|
+
constructor(nodeKeyCache, schemaEndpoint, sdkUserAgent, authProvider = new StubAuthProvider(), baseUrl = DEFAULT_BASE_URL, cryptoImpl = DefaultCrypto, signingKey, fetchImpl = fetch) {
|
|
1592
1592
|
this.nodeKeyCache = nodeKeyCache;
|
|
1593
1593
|
this.schemaEndpoint = schemaEndpoint;
|
|
1594
1594
|
this.sdkUserAgent = sdkUserAgent;
|
|
1595
1595
|
this.authProvider = authProvider;
|
|
1596
1596
|
this.baseUrl = baseUrl;
|
|
1597
1597
|
this.cryptoImpl = cryptoImpl;
|
|
1598
|
+
this.signingKey = signingKey;
|
|
1599
|
+
this.fetchImpl = fetchImpl;
|
|
1598
1600
|
let websocketImpl;
|
|
1599
1601
|
if (typeof WebSocket === "undefined" && typeof window === "undefined") {
|
|
1600
1602
|
websocketImpl = import_ws.default;
|
|
@@ -1714,7 +1716,7 @@ var Requester = class {
|
|
|
1714
1716
|
variables,
|
|
1715
1717
|
headers
|
|
1716
1718
|
});
|
|
1717
|
-
const response = await
|
|
1719
|
+
const response = await this.fetchImpl(url, {
|
|
1718
1720
|
method: "POST",
|
|
1719
1721
|
headers,
|
|
1720
1722
|
body: bodyData
|
|
@@ -1759,7 +1761,7 @@ var Requester = class {
|
|
|
1759
1761
|
nonce,
|
|
1760
1762
|
expires_at: expiration
|
|
1761
1763
|
};
|
|
1762
|
-
const key = this.nodeKeyCache.getKey(signingNodeId);
|
|
1764
|
+
const key = this.signingKey ?? this.nodeKeyCache.getKey(signingNodeId);
|
|
1763
1765
|
if (!key) {
|
|
1764
1766
|
throw new LightsparkSigningException_default(
|
|
1765
1767
|
"Missing node of encrypted_signing_private_key"
|
package/dist/index.d.cts
CHANGED
|
@@ -145,8 +145,10 @@ declare class Requester {
|
|
|
145
145
|
private readonly authProvider;
|
|
146
146
|
private readonly baseUrl;
|
|
147
147
|
private readonly cryptoImpl;
|
|
148
|
+
private readonly signingKey?;
|
|
149
|
+
private readonly fetchImpl;
|
|
148
150
|
private readonly wsClient;
|
|
149
|
-
constructor(nodeKeyCache: NodeKeyCache, schemaEndpoint: string, sdkUserAgent: string, authProvider?: AuthProvider, baseUrl?: string, cryptoImpl?: CryptoInterface);
|
|
151
|
+
constructor(nodeKeyCache: NodeKeyCache, schemaEndpoint: string, sdkUserAgent: string, authProvider?: AuthProvider, baseUrl?: string, cryptoImpl?: CryptoInterface, signingKey?: SigningKey | undefined, fetchImpl?: typeof fetch);
|
|
150
152
|
executeQuery<T>(query: Query<T>): Promise<T | null>;
|
|
151
153
|
subscribe<T>(queryPayload: string, variables?: {
|
|
152
154
|
[key: string]: unknown;
|
package/dist/index.d.ts
CHANGED
|
@@ -145,8 +145,10 @@ declare class Requester {
|
|
|
145
145
|
private readonly authProvider;
|
|
146
146
|
private readonly baseUrl;
|
|
147
147
|
private readonly cryptoImpl;
|
|
148
|
+
private readonly signingKey?;
|
|
149
|
+
private readonly fetchImpl;
|
|
148
150
|
private readonly wsClient;
|
|
149
|
-
constructor(nodeKeyCache: NodeKeyCache, schemaEndpoint: string, sdkUserAgent: string, authProvider?: AuthProvider, baseUrl?: string, cryptoImpl?: CryptoInterface);
|
|
151
|
+
constructor(nodeKeyCache: NodeKeyCache, schemaEndpoint: string, sdkUserAgent: string, authProvider?: AuthProvider, baseUrl?: string, cryptoImpl?: CryptoInterface, signingKey?: SigningKey | undefined, fetchImpl?: typeof fetch);
|
|
150
152
|
executeQuery<T>(query: Query<T>): Promise<T | null>;
|
|
151
153
|
subscribe<T>(queryPayload: string, variables?: {
|
|
152
154
|
[key: string]: unknown;
|
package/dist/index.js
CHANGED
|
@@ -491,13 +491,15 @@ import { Observable } from "zen-observable-ts";
|
|
|
491
491
|
var DEFAULT_BASE_URL = "api.lightspark.com";
|
|
492
492
|
dayjs.extend(utc);
|
|
493
493
|
var Requester = class {
|
|
494
|
-
constructor(nodeKeyCache, schemaEndpoint, sdkUserAgent, authProvider = new StubAuthProvider(), baseUrl = DEFAULT_BASE_URL, cryptoImpl = DefaultCrypto) {
|
|
494
|
+
constructor(nodeKeyCache, schemaEndpoint, sdkUserAgent, authProvider = new StubAuthProvider(), baseUrl = DEFAULT_BASE_URL, cryptoImpl = DefaultCrypto, signingKey, fetchImpl = fetch) {
|
|
495
495
|
this.nodeKeyCache = nodeKeyCache;
|
|
496
496
|
this.schemaEndpoint = schemaEndpoint;
|
|
497
497
|
this.sdkUserAgent = sdkUserAgent;
|
|
498
498
|
this.authProvider = authProvider;
|
|
499
499
|
this.baseUrl = baseUrl;
|
|
500
500
|
this.cryptoImpl = cryptoImpl;
|
|
501
|
+
this.signingKey = signingKey;
|
|
502
|
+
this.fetchImpl = fetchImpl;
|
|
501
503
|
let websocketImpl;
|
|
502
504
|
if (typeof WebSocket === "undefined" && typeof window === "undefined") {
|
|
503
505
|
websocketImpl = NodeWebSocket;
|
|
@@ -617,7 +619,7 @@ var Requester = class {
|
|
|
617
619
|
variables,
|
|
618
620
|
headers
|
|
619
621
|
});
|
|
620
|
-
const response = await
|
|
622
|
+
const response = await this.fetchImpl(url, {
|
|
621
623
|
method: "POST",
|
|
622
624
|
headers,
|
|
623
625
|
body: bodyData
|
|
@@ -662,7 +664,7 @@ var Requester = class {
|
|
|
662
664
|
nonce,
|
|
663
665
|
expires_at: expiration
|
|
664
666
|
};
|
|
665
|
-
const key = this.nodeKeyCache.getKey(signingNodeId);
|
|
667
|
+
const key = this.signingKey ?? this.nodeKeyCache.getKey(signingNodeId);
|
|
666
668
|
if (!key) {
|
|
667
669
|
throw new LightsparkSigningException_default(
|
|
668
670
|
"Missing node of encrypted_signing_private_key"
|
package/package.json
CHANGED
|
@@ -15,6 +15,7 @@ import StubAuthProvider from "../auth/StubAuthProvider.js";
|
|
|
15
15
|
import type { CryptoInterface } from "../crypto/crypto.js";
|
|
16
16
|
import { DefaultCrypto, LightsparkSigningException } from "../crypto/crypto.js";
|
|
17
17
|
import type NodeKeyCache from "../crypto/NodeKeyCache.js";
|
|
18
|
+
import type { SigningKey } from "../crypto/SigningKey.js";
|
|
18
19
|
import LightsparkException from "../LightsparkException.js";
|
|
19
20
|
import { logger } from "../Logger.js";
|
|
20
21
|
import { b64encode } from "../utils/base64.js";
|
|
@@ -40,6 +41,8 @@ class Requester {
|
|
|
40
41
|
private readonly authProvider: AuthProvider = new StubAuthProvider(),
|
|
41
42
|
private readonly baseUrl: string = DEFAULT_BASE_URL,
|
|
42
43
|
private readonly cryptoImpl: CryptoInterface = DefaultCrypto,
|
|
44
|
+
private readonly signingKey?: SigningKey,
|
|
45
|
+
private readonly fetchImpl: typeof fetch = fetch,
|
|
43
46
|
) {
|
|
44
47
|
let websocketImpl;
|
|
45
48
|
if (typeof WebSocket === "undefined" && typeof window === "undefined") {
|
|
@@ -188,7 +191,7 @@ class Requester {
|
|
|
188
191
|
variables,
|
|
189
192
|
headers,
|
|
190
193
|
});
|
|
191
|
-
const response = await
|
|
194
|
+
const response = await this.fetchImpl(url, {
|
|
192
195
|
method: "POST",
|
|
193
196
|
headers,
|
|
194
197
|
body: bodyData,
|
|
@@ -248,7 +251,7 @@ class Requester {
|
|
|
248
251
|
expires_at: expiration,
|
|
249
252
|
};
|
|
250
253
|
|
|
251
|
-
const key = this.nodeKeyCache.getKey(signingNodeId);
|
|
254
|
+
const key = this.signingKey ?? this.nodeKeyCache.getKey(signingNodeId);
|
|
252
255
|
if (!key) {
|
|
253
256
|
throw new LightsparkSigningException(
|
|
254
257
|
"Missing node of encrypted_signing_private_key",
|