@0xsequence/indexer 1.2.6 → 1.2.7
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.
|
@@ -262,21 +262,28 @@ let SequenceIndexerServices = /*#__PURE__*/function (SequenceIndexerServices) {
|
|
|
262
262
|
}({});
|
|
263
263
|
const fetch = typeof global === 'object' ? global.fetch : window.fetch;
|
|
264
264
|
class SequenceIndexerClient extends Indexer {
|
|
265
|
-
constructor(hostname,
|
|
265
|
+
constructor(hostname, authorization) {
|
|
266
266
|
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
|
|
267
267
|
this._fetch = (input, init) => {
|
|
268
268
|
// automatically include jwt auth header to requests
|
|
269
269
|
// if its been set on the api client
|
|
270
270
|
const headers = {};
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
const {
|
|
272
|
+
jwtAuth,
|
|
273
|
+
tokenKey
|
|
274
|
+
} = this.authorization || {};
|
|
275
|
+
if (jwtAuth && jwtAuth.length > 0) {
|
|
276
|
+
headers['Authorization'] = `BEARER ${jwtAuth}`;
|
|
277
|
+
}
|
|
278
|
+
if (tokenKey && tokenKey.length > 0) {
|
|
279
|
+
headers['X-Sequence-Token-Key'] = `${tokenKey}`;
|
|
273
280
|
}
|
|
274
281
|
|
|
275
282
|
// before the request is made
|
|
276
283
|
init.headers = _extends({}, init.headers, headers);
|
|
277
284
|
return fetch(input, init);
|
|
278
285
|
};
|
|
279
|
-
this.
|
|
286
|
+
this.authorization = authorization;
|
|
280
287
|
this.fetch = this._fetch;
|
|
281
288
|
}
|
|
282
289
|
}
|
|
@@ -262,21 +262,28 @@ let SequenceIndexerServices = /*#__PURE__*/function (SequenceIndexerServices) {
|
|
|
262
262
|
}({});
|
|
263
263
|
const fetch = typeof global === 'object' ? global.fetch : window.fetch;
|
|
264
264
|
class SequenceIndexerClient extends Indexer {
|
|
265
|
-
constructor(hostname,
|
|
265
|
+
constructor(hostname, authorization) {
|
|
266
266
|
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
|
|
267
267
|
this._fetch = (input, init) => {
|
|
268
268
|
// automatically include jwt auth header to requests
|
|
269
269
|
// if its been set on the api client
|
|
270
270
|
const headers = {};
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
const {
|
|
272
|
+
jwtAuth,
|
|
273
|
+
tokenKey
|
|
274
|
+
} = this.authorization || {};
|
|
275
|
+
if (jwtAuth && jwtAuth.length > 0) {
|
|
276
|
+
headers['Authorization'] = `BEARER ${jwtAuth}`;
|
|
277
|
+
}
|
|
278
|
+
if (tokenKey && tokenKey.length > 0) {
|
|
279
|
+
headers['X-Sequence-Token-Key'] = `${tokenKey}`;
|
|
273
280
|
}
|
|
274
281
|
|
|
275
282
|
// before the request is made
|
|
276
283
|
init.headers = _extends({}, init.headers, headers);
|
|
277
284
|
return fetch(input, init);
|
|
278
285
|
};
|
|
279
|
-
this.
|
|
286
|
+
this.authorization = authorization;
|
|
280
287
|
this.fetch = this._fetch;
|
|
281
288
|
}
|
|
282
289
|
}
|
|
@@ -258,21 +258,28 @@ let SequenceIndexerServices = /*#__PURE__*/function (SequenceIndexerServices) {
|
|
|
258
258
|
}({});
|
|
259
259
|
const fetch = typeof global === 'object' ? global.fetch : window.fetch;
|
|
260
260
|
class SequenceIndexerClient extends Indexer {
|
|
261
|
-
constructor(hostname,
|
|
261
|
+
constructor(hostname, authorization) {
|
|
262
262
|
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
|
|
263
263
|
this._fetch = (input, init) => {
|
|
264
264
|
// automatically include jwt auth header to requests
|
|
265
265
|
// if its been set on the api client
|
|
266
266
|
const headers = {};
|
|
267
|
-
|
|
268
|
-
|
|
267
|
+
const {
|
|
268
|
+
jwtAuth,
|
|
269
|
+
tokenKey
|
|
270
|
+
} = this.authorization || {};
|
|
271
|
+
if (jwtAuth && jwtAuth.length > 0) {
|
|
272
|
+
headers['Authorization'] = `BEARER ${jwtAuth}`;
|
|
273
|
+
}
|
|
274
|
+
if (tokenKey && tokenKey.length > 0) {
|
|
275
|
+
headers['X-Sequence-Token-Key'] = `${tokenKey}`;
|
|
269
276
|
}
|
|
270
277
|
|
|
271
278
|
// before the request is made
|
|
272
279
|
init.headers = _extends({}, init.headers, headers);
|
|
273
280
|
return fetch(input, init);
|
|
274
281
|
};
|
|
275
|
-
this.
|
|
282
|
+
this.authorization = authorization;
|
|
276
283
|
this.fetch = this._fetch;
|
|
277
284
|
}
|
|
278
285
|
}
|
|
@@ -15,7 +15,13 @@ export declare enum SequenceIndexerServices {
|
|
|
15
15
|
GOERLI = "https://goerli-indexer.sequence.app"
|
|
16
16
|
}
|
|
17
17
|
export declare class SequenceIndexerClient extends IndexerRpc {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
authorization?: {
|
|
19
|
+
jwtAuth?: string | undefined;
|
|
20
|
+
tokenKey?: string | undefined;
|
|
21
|
+
} | undefined;
|
|
22
|
+
constructor(hostname: string, authorization?: {
|
|
23
|
+
jwtAuth?: string | undefined;
|
|
24
|
+
tokenKey?: string | undefined;
|
|
25
|
+
} | undefined);
|
|
20
26
|
_fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
21
27
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -29,7 +29,10 @@ const fetch = typeof global === 'object' ? global.fetch : window.fetch
|
|
|
29
29
|
export class SequenceIndexerClient extends IndexerRpc {
|
|
30
30
|
constructor(
|
|
31
31
|
hostname: string,
|
|
32
|
-
public
|
|
32
|
+
public authorization?: {
|
|
33
|
+
jwtAuth?: string
|
|
34
|
+
tokenKey?: string
|
|
35
|
+
}
|
|
33
36
|
) {
|
|
34
37
|
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch)
|
|
35
38
|
this.fetch = this._fetch
|
|
@@ -39,8 +42,15 @@ export class SequenceIndexerClient extends IndexerRpc {
|
|
|
39
42
|
// automatically include jwt auth header to requests
|
|
40
43
|
// if its been set on the api client
|
|
41
44
|
const headers: { [key: string]: any } = {}
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
|
|
46
|
+
const {jwtAuth, tokenKey} = this.authorization || {}
|
|
47
|
+
|
|
48
|
+
if (jwtAuth && jwtAuth.length > 0) {
|
|
49
|
+
headers['Authorization'] = `BEARER ${jwtAuth}`
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (tokenKey && tokenKey.length > 0) {
|
|
53
|
+
headers['X-Sequence-Token-Key'] = `${tokenKey}`
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
// before the request is made
|