@0xsequence/api 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.
@@ -600,21 +600,28 @@ const buildResponse = res => {
600
600
 
601
601
  const fetch = typeof global === 'object' ? global.fetch : window.fetch;
602
602
  class SequenceAPIClient extends API {
603
- constructor(hostname, jwtAuth) {
603
+ constructor(hostname, authorization) {
604
604
  super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
605
605
  this._fetch = (input, init) => {
606
606
  // automatically include jwt auth header to requests
607
607
  // if its been set on the api client
608
608
  const headers = {};
609
- if (this.jwtAuth && this.jwtAuth.length > 0) {
610
- headers['Authorization'] = `BEARER ${this.jwtAuth}`;
609
+ const {
610
+ jwtAuth,
611
+ tokenKey
612
+ } = this.authorization || {};
613
+ if (jwtAuth && jwtAuth.length > 0) {
614
+ headers['Authorization'] = `BEARER ${jwtAuth}`;
615
+ }
616
+ if (tokenKey && tokenKey.length > 0) {
617
+ headers['X-Sequence-Token-Key'] = `${tokenKey}`;
611
618
  }
612
619
 
613
620
  // before the request is made
614
621
  init.headers = _extends({}, init.headers, headers);
615
622
  return fetch(input, init);
616
623
  };
617
- this.jwtAuth = jwtAuth;
624
+ this.authorization = authorization;
618
625
  this.fetch = this._fetch;
619
626
  }
620
627
  }
@@ -600,21 +600,28 @@ const buildResponse = res => {
600
600
 
601
601
  const fetch = typeof global === 'object' ? global.fetch : window.fetch;
602
602
  class SequenceAPIClient extends API {
603
- constructor(hostname, jwtAuth) {
603
+ constructor(hostname, authorization) {
604
604
  super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
605
605
  this._fetch = (input, init) => {
606
606
  // automatically include jwt auth header to requests
607
607
  // if its been set on the api client
608
608
  const headers = {};
609
- if (this.jwtAuth && this.jwtAuth.length > 0) {
610
- headers['Authorization'] = `BEARER ${this.jwtAuth}`;
609
+ const {
610
+ jwtAuth,
611
+ tokenKey
612
+ } = this.authorization || {};
613
+ if (jwtAuth && jwtAuth.length > 0) {
614
+ headers['Authorization'] = `BEARER ${jwtAuth}`;
615
+ }
616
+ if (tokenKey && tokenKey.length > 0) {
617
+ headers['X-Sequence-Token-Key'] = `${tokenKey}`;
611
618
  }
612
619
 
613
620
  // before the request is made
614
621
  init.headers = _extends({}, init.headers, headers);
615
622
  return fetch(input, init);
616
623
  };
617
- this.jwtAuth = jwtAuth;
624
+ this.authorization = authorization;
618
625
  this.fetch = this._fetch;
619
626
  }
620
627
  }
@@ -596,21 +596,28 @@ const buildResponse = res => {
596
596
 
597
597
  const fetch = typeof global === 'object' ? global.fetch : window.fetch;
598
598
  class SequenceAPIClient extends API {
599
- constructor(hostname, jwtAuth) {
599
+ constructor(hostname, authorization) {
600
600
  super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
601
601
  this._fetch = (input, init) => {
602
602
  // automatically include jwt auth header to requests
603
603
  // if its been set on the api client
604
604
  const headers = {};
605
- if (this.jwtAuth && this.jwtAuth.length > 0) {
606
- headers['Authorization'] = `BEARER ${this.jwtAuth}`;
605
+ const {
606
+ jwtAuth,
607
+ tokenKey
608
+ } = this.authorization || {};
609
+ if (jwtAuth && jwtAuth.length > 0) {
610
+ headers['Authorization'] = `BEARER ${jwtAuth}`;
611
+ }
612
+ if (tokenKey && tokenKey.length > 0) {
613
+ headers['X-Sequence-Token-Key'] = `${tokenKey}`;
607
614
  }
608
615
 
609
616
  // before the request is made
610
617
  init.headers = _extends({}, init.headers, headers);
611
618
  return fetch(input, init);
612
619
  };
613
- this.jwtAuth = jwtAuth;
620
+ this.authorization = authorization;
614
621
  this.fetch = this._fetch;
615
622
  }
616
623
  }
@@ -1,7 +1,13 @@
1
1
  export * from "./api.gen.js";
2
2
  import { API as ApiRpc } from "./api.gen.js";
3
3
  export declare class SequenceAPIClient extends ApiRpc {
4
- jwtAuth?: string | undefined;
5
- constructor(hostname: string, jwtAuth?: string | undefined);
4
+ authorization?: {
5
+ jwtAuth?: string | undefined;
6
+ tokenKey?: string | undefined;
7
+ } | undefined;
8
+ constructor(hostname: string, authorization?: {
9
+ jwtAuth?: string | undefined;
10
+ tokenKey?: string | undefined;
11
+ } | undefined);
6
12
  _fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
7
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/api",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "api sub-package for Sequence",
5
5
  "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/api",
6
6
  "source": "src/index.ts",
package/src/index.ts CHANGED
@@ -7,7 +7,10 @@ const fetch = typeof global === 'object' ? global.fetch : window.fetch
7
7
  export class SequenceAPIClient extends ApiRpc {
8
8
  constructor(
9
9
  hostname: string,
10
- public jwtAuth?: string
10
+ public authorization?: {
11
+ jwtAuth?: string
12
+ tokenKey?: string
13
+ }
11
14
  ) {
12
15
  super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch)
13
16
  this.fetch = this._fetch
@@ -17,8 +20,15 @@ export class SequenceAPIClient extends ApiRpc {
17
20
  // automatically include jwt auth header to requests
18
21
  // if its been set on the api client
19
22
  const headers: { [key: string]: any } = {}
20
- if (this.jwtAuth && this.jwtAuth.length > 0) {
21
- headers['Authorization'] = `BEARER ${this.jwtAuth}`
23
+
24
+ const {jwtAuth, tokenKey} = this.authorization || {}
25
+
26
+ if (jwtAuth && jwtAuth.length > 0) {
27
+ headers['Authorization'] = `BEARER ${jwtAuth}`
28
+ }
29
+
30
+ if (tokenKey && tokenKey.length > 0) {
31
+ headers['X-Sequence-Token-Key'] = `${tokenKey}`
22
32
  }
23
33
 
24
34
  // before the request is made