@lightsparkdev/core 0.3.4 → 0.3.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.
package/CHANGELOG.md CHANGED
@@ -1,10 +1,17 @@
1
1
  # @lightsparkdev/core
2
2
 
3
+ ## 0.3.5
4
+
5
+ ### Patch Changes
6
+
7
+ - c92f1d8: Force patch to sync with npm versions
8
+
3
9
  ## 0.3.4
4
10
 
5
11
  ### Patch Changes
6
12
 
7
- - 3092c6b: Add crypto polyfill fixes for node 16.
13
+ - 1528704: Allow setting a protocol manually in the js sdk
14
+ - 44be15f: Add the LNURL docs for JS
8
15
 
9
16
  ## 0.3.3
10
17
 
package/dist/index.cjs CHANGED
@@ -410,7 +410,7 @@ var Requester = class {
410
410
  websocketImpl = import_ws.default;
411
411
  }
412
412
  this.wsClient = (0, import_graphql_ws.createClient)({
413
- url: `wss://${this.baseUrl}/${this.schemaEndpoint}`,
413
+ url: `wss://${this.stripProtocol(this.baseUrl)}/${this.schemaEndpoint}`,
414
414
  connectionParams: () => authProvider.addWsConnectionParams({}),
415
415
  webSocketImpl: websocketImpl
416
416
  });
@@ -496,14 +496,15 @@ var Requester = class {
496
496
  headers,
497
497
  signingNodeId
498
498
  );
499
- const response = await fetch(
500
- `https://${this.baseUrl}/${this.schemaEndpoint}`,
501
- {
502
- method: "POST",
503
- headers,
504
- body: JSON.stringify(bodyData)
505
- }
506
- );
499
+ let urlWithProtocol = this.baseUrl;
500
+ if (!urlWithProtocol.startsWith("https://") && !urlWithProtocol.startsWith("http://")) {
501
+ urlWithProtocol = `https://${urlWithProtocol}`;
502
+ }
503
+ const response = await fetch(`${urlWithProtocol}/${this.schemaEndpoint}`, {
504
+ method: "POST",
505
+ headers,
506
+ body: JSON.stringify(bodyData)
507
+ });
507
508
  if (!response.ok) {
508
509
  throw new LightsparkException_default(
509
510
  "RequestFailed",
@@ -525,6 +526,9 @@ var Requester = class {
525
526
  const platformVersion = isNode ? process.version : "";
526
527
  return `${this.sdkUserAgent} ${platform}/${platformVersion}`;
527
528
  }
529
+ stripProtocol(url) {
530
+ return url.replace(/.*?:\/\//g, "");
531
+ }
528
532
  async addSigningDataIfNeeded(queryPayload, headers, signingNodeId) {
529
533
  if (!signingNodeId) {
530
534
  return queryPayload;
package/dist/index.d.ts CHANGED
@@ -106,6 +106,7 @@ declare class Requester {
106
106
  [key: string]: any;
107
107
  }, signingNodeId?: string | undefined, skipAuth?: boolean): Promise<any | null>;
108
108
  private getSdkUserAgent;
109
+ private stripProtocol;
109
110
  private addSigningDataIfNeeded;
110
111
  }
111
112
 
package/dist/index.js CHANGED
@@ -358,7 +358,7 @@ var Requester = class {
358
358
  websocketImpl = NodeWebSocket;
359
359
  }
360
360
  this.wsClient = createClient({
361
- url: `wss://${this.baseUrl}/${this.schemaEndpoint}`,
361
+ url: `wss://${this.stripProtocol(this.baseUrl)}/${this.schemaEndpoint}`,
362
362
  connectionParams: () => authProvider.addWsConnectionParams({}),
363
363
  webSocketImpl: websocketImpl
364
364
  });
@@ -444,14 +444,15 @@ var Requester = class {
444
444
  headers,
445
445
  signingNodeId
446
446
  );
447
- const response = await fetch(
448
- `https://${this.baseUrl}/${this.schemaEndpoint}`,
449
- {
450
- method: "POST",
451
- headers,
452
- body: JSON.stringify(bodyData)
453
- }
454
- );
447
+ let urlWithProtocol = this.baseUrl;
448
+ if (!urlWithProtocol.startsWith("https://") && !urlWithProtocol.startsWith("http://")) {
449
+ urlWithProtocol = `https://${urlWithProtocol}`;
450
+ }
451
+ const response = await fetch(`${urlWithProtocol}/${this.schemaEndpoint}`, {
452
+ method: "POST",
453
+ headers,
454
+ body: JSON.stringify(bodyData)
455
+ });
455
456
  if (!response.ok) {
456
457
  throw new LightsparkException_default(
457
458
  "RequestFailed",
@@ -473,6 +474,9 @@ var Requester = class {
473
474
  const platformVersion = isNode ? process.version : "";
474
475
  return `${this.sdkUserAgent} ${platform}/${platformVersion}`;
475
476
  }
477
+ stripProtocol(url) {
478
+ return url.replace(/.*?:\/\//g, "");
479
+ }
476
480
  async addSigningDataIfNeeded(queryPayload, headers, signingNodeId) {
477
481
  if (!signingNodeId) {
478
482
  return queryPayload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightsparkdev/core",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Lightspark JS SDK",
5
5
  "author": "Lightspark Inc.",
6
6
  "keywords": [
@@ -42,7 +42,7 @@ class Requester {
42
42
  websocketImpl = NodeWebSocket;
43
43
  }
44
44
  this.wsClient = createClient({
45
- url: `wss://${this.baseUrl}/${this.schemaEndpoint}`,
45
+ url: `wss://${this.stripProtocol(this.baseUrl)}/${this.schemaEndpoint}`,
46
46
  connectionParams: () => authProvider.addWsConnectionParams({}),
47
47
  webSocketImpl: websocketImpl,
48
48
  });
@@ -145,14 +145,18 @@ class Requester {
145
145
  signingNodeId
146
146
  );
147
147
 
148
- const response = await fetch(
149
- `https://${this.baseUrl}/${this.schemaEndpoint}`,
150
- {
151
- method: "POST",
152
- headers: headers,
153
- body: JSON.stringify(bodyData),
154
- }
155
- );
148
+ let urlWithProtocol = this.baseUrl;
149
+ if (
150
+ !urlWithProtocol.startsWith("https://") &&
151
+ !urlWithProtocol.startsWith("http://")
152
+ ) {
153
+ urlWithProtocol = `https://${urlWithProtocol}`;
154
+ }
155
+ const response = await fetch(`${urlWithProtocol}/${this.schemaEndpoint}`, {
156
+ method: "POST",
157
+ headers: headers,
158
+ body: JSON.stringify(bodyData),
159
+ });
156
160
  if (!response.ok) {
157
161
  throw new LightsparkException(
158
162
  "RequestFailed",
@@ -176,6 +180,10 @@ class Requester {
176
180
  return `${this.sdkUserAgent} ${platform}/${platformVersion}`;
177
181
  }
178
182
 
183
+ private stripProtocol(url: string): string {
184
+ return url.replace(/.*?:\/\//g, "");
185
+ }
186
+
179
187
  private async addSigningDataIfNeeded(
180
188
  queryPayload: { query: string; variables: any; operationName: string },
181
189
  headers: { [key: string]: string },