@0xsequence/indexer 1.2.6 → 1.2.8

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, jwtAuth) {
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
- if (this.jwtAuth && this.jwtAuth.length > 0) {
272
- headers['Authorization'] = `BEARER ${this.jwtAuth}`;
271
+ const {
272
+ jwtAuth,
273
+ accessKey
274
+ } = this.authorization || {};
275
+ if (jwtAuth && jwtAuth.length > 0) {
276
+ headers['Authorization'] = `BEARER ${jwtAuth}`;
277
+ }
278
+ if (accessKey && accessKey.length > 0) {
279
+ headers['X-Access-Key'] = `${accessKey}`;
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.jwtAuth = jwtAuth;
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, jwtAuth) {
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
- if (this.jwtAuth && this.jwtAuth.length > 0) {
272
- headers['Authorization'] = `BEARER ${this.jwtAuth}`;
271
+ const {
272
+ jwtAuth,
273
+ accessKey
274
+ } = this.authorization || {};
275
+ if (jwtAuth && jwtAuth.length > 0) {
276
+ headers['Authorization'] = `BEARER ${jwtAuth}`;
277
+ }
278
+ if (accessKey && accessKey.length > 0) {
279
+ headers['X-Access-Key'] = `${accessKey}`;
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.jwtAuth = jwtAuth;
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, jwtAuth) {
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
- if (this.jwtAuth && this.jwtAuth.length > 0) {
268
- headers['Authorization'] = `BEARER ${this.jwtAuth}`;
267
+ const {
268
+ jwtAuth,
269
+ accessKey
270
+ } = this.authorization || {};
271
+ if (jwtAuth && jwtAuth.length > 0) {
272
+ headers['Authorization'] = `BEARER ${jwtAuth}`;
273
+ }
274
+ if (accessKey && accessKey.length > 0) {
275
+ headers['X-Access-Key'] = `${accessKey}`;
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.jwtAuth = jwtAuth;
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
- jwtAuth?: string | undefined;
19
- constructor(hostname: string, jwtAuth?: string | undefined);
18
+ authorization?: {
19
+ jwtAuth?: string | undefined;
20
+ accessKey?: string | undefined;
21
+ } | undefined;
22
+ constructor(hostname: string, authorization?: {
23
+ jwtAuth?: string | undefined;
24
+ accessKey?: string | undefined;
25
+ } | undefined);
20
26
  _fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
21
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/indexer",
3
- "version": "1.2.6",
3
+ "version": "1.2.8",
4
4
  "description": "indexer sub-package for Sequence",
5
5
  "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/indexer",
6
6
  "source": "src/index.ts",
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 jwtAuth?: string
32
+ public authorization?: {
33
+ jwtAuth?: string
34
+ accessKey?: 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
- if (this.jwtAuth && this.jwtAuth.length > 0) {
43
- headers['Authorization'] = `BEARER ${this.jwtAuth}`
45
+
46
+ const { jwtAuth, accessKey } = this.authorization || {}
47
+
48
+ if (jwtAuth && jwtAuth.length > 0) {
49
+ headers['Authorization'] = `BEARER ${jwtAuth}`
50
+ }
51
+
52
+ if (accessKey && accessKey.length > 0) {
53
+ headers['X-Access-Key'] = `${accessKey}`
44
54
  }
45
55
 
46
56
  // before the request is made