@0xsequence/indexer 2.1.7 → 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/dist/0xsequence-indexer.cjs.dev.js +935 -225
- package/dist/0xsequence-indexer.cjs.prod.js +935 -225
- package/dist/0xsequence-indexer.esm.js +895 -187
- package/dist/declarations/src/index.d.ts +8 -0
- package/dist/declarations/src/indexergw.gen.d.ts +697 -0
- package/package.json +1 -1
- package/src/index.ts +35 -0
- package/src/indexergw.gen.ts +1419 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './indexer.gen'
|
|
2
|
+
export * as IndexerGateway from './indexergw.gen'
|
|
2
3
|
|
|
3
4
|
import { Indexer as IndexerRpc } from './indexer.gen'
|
|
5
|
+
import { IndexerGateway as IndexerGatewayRpc } from './indexergw.gen'
|
|
4
6
|
|
|
5
7
|
export class SequenceIndexer extends IndexerRpc {
|
|
6
8
|
constructor(
|
|
@@ -34,3 +36,36 @@ export class SequenceIndexer extends IndexerRpc {
|
|
|
34
36
|
return fetch(input, init)
|
|
35
37
|
}
|
|
36
38
|
}
|
|
39
|
+
|
|
40
|
+
export class SequenceIndexerGateway extends IndexerGatewayRpc {
|
|
41
|
+
constructor(
|
|
42
|
+
hostname: string,
|
|
43
|
+
public projectAccessKey?: string,
|
|
44
|
+
public jwtAuth?: string
|
|
45
|
+
) {
|
|
46
|
+
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch)
|
|
47
|
+
this.fetch = this._fetch
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
_fetch = (input: RequestInfo, init?: RequestInit): Promise<Response> => {
|
|
51
|
+
// automatically include jwt and access key auth header to requests
|
|
52
|
+
// if its been set on the api client
|
|
53
|
+
const headers: { [key: string]: any } = {}
|
|
54
|
+
|
|
55
|
+
const jwtAuth = this.jwtAuth
|
|
56
|
+
const projectAccessKey = this.projectAccessKey
|
|
57
|
+
|
|
58
|
+
if (jwtAuth && jwtAuth.length > 0) {
|
|
59
|
+
headers['Authorization'] = `BEARER ${jwtAuth}`
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (projectAccessKey && projectAccessKey.length > 0) {
|
|
63
|
+
headers['X-Access-Key'] = projectAccessKey
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// before the request is made
|
|
67
|
+
init!.headers = { ...init!.headers, ...headers }
|
|
68
|
+
|
|
69
|
+
return fetch(input, init)
|
|
70
|
+
}
|
|
71
|
+
}
|