@0xsequence/builder 2.2.0
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/LICENSE +219 -0
- package/README.md +4 -0
- package/dist/0xsequence-builder.cjs.d.ts +2 -0
- package/dist/0xsequence-builder.cjs.dev.js +487 -0
- package/dist/0xsequence-builder.cjs.js +7 -0
- package/dist/0xsequence-builder.cjs.prod.js +487 -0
- package/dist/0xsequence-builder.esm.js +449 -0
- package/dist/declarations/src/builder.gen.d.ts +222 -0
- package/dist/declarations/src/index.d.ts +7 -0
- package/package.json +22 -0
- package/src/builder.gen.ts +683 -0
- package/src/index.ts +30 -0
package/src/index.ts
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
export * from './builder.gen'
|
2
|
+
|
3
|
+
import { Builder as BuilderRpc } from './builder.gen'
|
4
|
+
|
5
|
+
export class SequenceBuilderClient extends BuilderRpc {
|
6
|
+
constructor(
|
7
|
+
public projectAccessKey: string,
|
8
|
+
apiUrl?: string
|
9
|
+
) {
|
10
|
+
const hostname = apiUrl ?? 'https://api.sequence.build'
|
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 access key auth header to requests
|
17
|
+
// if its been set on the api client
|
18
|
+
const headers: { [key: string]: any } = {}
|
19
|
+
|
20
|
+
const projectAccessKey = this.projectAccessKey
|
21
|
+
if (projectAccessKey && projectAccessKey.length > 0) {
|
22
|
+
headers['X-Access-Key'] = projectAccessKey
|
23
|
+
}
|
24
|
+
|
25
|
+
// before the request is made
|
26
|
+
init!.headers = { ...init!.headers, ...headers }
|
27
|
+
|
28
|
+
return fetch(input, init)
|
29
|
+
}
|
30
|
+
}
|