@0xsequence/userdata 0.0.0-20260210155835

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/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@0xsequence/userdata",
3
+ "version": "0.0.0-20260210155835",
4
+ "description": "userdata sub-package for Sequence",
5
+ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/services/userdata",
6
+ "author": "Sequence Platforms Inc.",
7
+ "license": "Apache-2.0",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.js"
15
+ }
16
+ },
17
+ "devDependencies": {
18
+ "@types/node": "^25.0.2",
19
+ "typescript": "^5.9.3",
20
+ "@repo/typescript-config": "^0.0.0-20260210155835"
21
+ },
22
+ "scripts": {
23
+ "build": "tsc",
24
+ "dev": "tsc --watch",
25
+ "test": "echo",
26
+ "typecheck": "tsc --noEmit"
27
+ }
28
+ }
package/src/index.ts ADDED
@@ -0,0 +1,36 @@
1
+ export * from './userdata.gen'
2
+
3
+ import { UserData as UserdataRpc } from './userdata.gen'
4
+
5
+ export class SequenceUserdataClient extends UserdataRpc {
6
+ constructor(
7
+ hostname: string,
8
+ public projectAccessKey?: string,
9
+ public jwtAuth?: string,
10
+ ) {
11
+ super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch)
12
+ this.fetch = this._fetch
13
+ }
14
+
15
+ _fetch = (input: RequestInfo, init?: RequestInit): Promise<Response> => {
16
+ // automatically include jwt and access key auth header to requests
17
+ // if its been set on the api client
18
+ const headers: { [key: string]: any } = {}
19
+
20
+ const jwtAuth = this.jwtAuth
21
+ const projectAccessKey = this.projectAccessKey
22
+
23
+ if (jwtAuth && jwtAuth.length > 0) {
24
+ headers['Authorization'] = `BEARER ${jwtAuth}`
25
+ }
26
+
27
+ if (projectAccessKey && projectAccessKey.length > 0) {
28
+ headers['X-Access-Key'] = projectAccessKey
29
+ }
30
+
31
+ // before the request is made
32
+ init!.headers = { ...init!.headers, ...headers }
33
+
34
+ return fetch(input, init)
35
+ }
36
+ }