graphlit-client 1.0.20240418011 → 1.0.20240418013
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/README.md +2 -3
- package/dist/client.js +11 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -1,13 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# JavaScript Client for Graphlit Platform
|
2
2
|
## Overview
|
3
3
|
|
4
|
-
The Graphlit Client for
|
4
|
+
The Graphlit Client for JavaScript enables straightforward interactions with the Graphlit API, allowing developers to execute GraphQL queries and mutations against the Graphlit service. This document outlines the setup process and provides a basic example of using the client.
|
5
5
|
|
6
6
|
## Prerequisites
|
7
7
|
|
8
8
|
Before you begin, ensure you have the following:
|
9
9
|
|
10
|
-
- Node.js installed on your system (recommended version 20.x or higher).
|
11
10
|
- An active account on the [Graphlit Platform](https://portal.graphlit.dev) with access to the API settings dashboard.
|
12
11
|
|
13
12
|
## Installation
|
package/dist/client.js
CHANGED
@@ -96,9 +96,19 @@ class Graphlit {
|
|
96
96
|
iss: "graphlit",
|
97
97
|
aud: "https://portal.graphlit.io",
|
98
98
|
};
|
99
|
+
function uint8ArrayToBase64(buffer) {
|
100
|
+
var binary = '';
|
101
|
+
var bytes = new Uint8Array(buffer);
|
102
|
+
var len = bytes.byteLength;
|
103
|
+
for (var i = 0; i < len; i++) {
|
104
|
+
binary += String.fromCharCode(bytes[i]);
|
105
|
+
}
|
106
|
+
return window.btoa(binary);
|
107
|
+
}
|
108
|
+
// NOTE: not using Buffer, so we don't require Node.js
|
99
109
|
const secretKeyJWK = yield (0, jose_1.importJWK)({
|
100
110
|
kty: 'oct',
|
101
|
-
k:
|
111
|
+
k: uint8ArrayToBase64(new TextEncoder().encode(this.jwtSecret)),
|
102
112
|
alg: 'HS256'
|
103
113
|
}, 'HS256');
|
104
114
|
this.token = yield new jose_1.SignJWT(payload)
|