Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/services/userdata/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @0xsequence/userdata
3 changes: 3 additions & 0 deletions packages/services/userdata/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @0xsequence/userdata

See [0xsequence project page](https://github.com/0xsequence/sequence.js).
28 changes: 28 additions & 0 deletions packages/services/userdata/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@0xsequence/userdata",
"version": "3.0.0-beta.4",
"description": "userdata sub-package for Sequence",
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/services/userdata",
"author": "Sequence Platforms Inc.",
"license": "Apache-2.0",
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "tsc",
"dev": "tsc --watch",
"test": "echo",
"typecheck": "tsc --noEmit"
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"devDependencies": {
"@repo/typescript-config": "workspace:^",
"@types/node": "^24.10.1",
"typescript": "^5.9.3"
}
}
36 changes: 36 additions & 0 deletions packages/services/userdata/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export * from './userdata.gen'

import { UserData as UserdataRpc } from './userdata.gen'

export class SequenceUserdataClient extends UserdataRpc {
constructor(
hostname: string,
public projectAccessKey?: string,
public jwtAuth?: string,
) {
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch)
this.fetch = this._fetch
}

_fetch = (input: RequestInfo, init?: RequestInit): Promise<Response> => {
// automatically include jwt and access key auth header to requests
// if its been set on the api client
const headers: { [key: string]: any } = {}

const jwtAuth = this.jwtAuth
const projectAccessKey = this.projectAccessKey

if (jwtAuth && jwtAuth.length > 0) {
headers['Authorization'] = `BEARER ${jwtAuth}`
}

if (projectAccessKey && projectAccessKey.length > 0) {
headers['X-Access-Key'] = projectAccessKey
}

// before the request is made
init!.headers = { ...init!.headers, ...headers }

return fetch(input, init)
}
}
Loading