@0xsequence/api 1.3.0 → 1.4.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.
@@ -600,28 +600,27 @@ 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, authorization) {
603
+ constructor(hostname, _projectAccessKey, _jwtAuth) {
604
604
  super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
605
605
  this._fetch = (input, init) => {
606
- // automatically include jwt auth header to requests
606
+ // automatically include jwt and access key auth header to requests
607
607
  // if its been set on the api client
608
608
  const headers = {};
609
- const {
610
- jwtAuth,
611
- accessKey
612
- } = this.authorization || {};
609
+ const jwtAuth = this.jwtAuth;
610
+ const projectAccessKey = this.projectAccessKey;
613
611
  if (jwtAuth && jwtAuth.length > 0) {
614
612
  headers['Authorization'] = `BEARER ${jwtAuth}`;
615
613
  }
616
- if (accessKey && accessKey.length > 0) {
617
- headers['X-Access-Key'] = `${accessKey}`;
614
+ if (projectAccessKey && projectAccessKey.length > 0) {
615
+ headers['X-Access-Key'] = projectAccessKey;
618
616
  }
619
617
 
620
618
  // before the request is made
621
619
  init.headers = _extends({}, init.headers, headers);
622
620
  return fetch(input, init);
623
621
  };
624
- this.authorization = authorization;
622
+ this.projectAccessKey = _projectAccessKey;
623
+ this.jwtAuth = _jwtAuth;
625
624
  this.fetch = this._fetch;
626
625
  }
627
626
  }
@@ -600,28 +600,27 @@ 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, authorization) {
603
+ constructor(hostname, _projectAccessKey, _jwtAuth) {
604
604
  super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
605
605
  this._fetch = (input, init) => {
606
- // automatically include jwt auth header to requests
606
+ // automatically include jwt and access key auth header to requests
607
607
  // if its been set on the api client
608
608
  const headers = {};
609
- const {
610
- jwtAuth,
611
- accessKey
612
- } = this.authorization || {};
609
+ const jwtAuth = this.jwtAuth;
610
+ const projectAccessKey = this.projectAccessKey;
613
611
  if (jwtAuth && jwtAuth.length > 0) {
614
612
  headers['Authorization'] = `BEARER ${jwtAuth}`;
615
613
  }
616
- if (accessKey && accessKey.length > 0) {
617
- headers['X-Access-Key'] = `${accessKey}`;
614
+ if (projectAccessKey && projectAccessKey.length > 0) {
615
+ headers['X-Access-Key'] = projectAccessKey;
618
616
  }
619
617
 
620
618
  // before the request is made
621
619
  init.headers = _extends({}, init.headers, headers);
622
620
  return fetch(input, init);
623
621
  };
624
- this.authorization = authorization;
622
+ this.projectAccessKey = _projectAccessKey;
623
+ this.jwtAuth = _jwtAuth;
625
624
  this.fetch = this._fetch;
626
625
  }
627
626
  }
@@ -596,28 +596,27 @@ 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, authorization) {
599
+ constructor(hostname, _projectAccessKey, _jwtAuth) {
600
600
  super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
601
601
  this._fetch = (input, init) => {
602
- // automatically include jwt auth header to requests
602
+ // automatically include jwt and access key auth header to requests
603
603
  // if its been set on the api client
604
604
  const headers = {};
605
- const {
606
- jwtAuth,
607
- accessKey
608
- } = this.authorization || {};
605
+ const jwtAuth = this.jwtAuth;
606
+ const projectAccessKey = this.projectAccessKey;
609
607
  if (jwtAuth && jwtAuth.length > 0) {
610
608
  headers['Authorization'] = `BEARER ${jwtAuth}`;
611
609
  }
612
- if (accessKey && accessKey.length > 0) {
613
- headers['X-Access-Key'] = `${accessKey}`;
610
+ if (projectAccessKey && projectAccessKey.length > 0) {
611
+ headers['X-Access-Key'] = projectAccessKey;
614
612
  }
615
613
 
616
614
  // before the request is made
617
615
  init.headers = _extends({}, init.headers, headers);
618
616
  return fetch(input, init);
619
617
  };
620
- this.authorization = authorization;
618
+ this.projectAccessKey = _projectAccessKey;
619
+ this.jwtAuth = _jwtAuth;
621
620
  this.fetch = this._fetch;
622
621
  }
623
622
  }
@@ -1,13 +1,8 @@
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
- authorization?: {
5
- jwtAuth?: string | undefined;
6
- accessKey?: string | undefined;
7
- } | undefined;
8
- constructor(hostname: string, authorization?: {
9
- jwtAuth?: string | undefined;
10
- accessKey?: string | undefined;
11
- } | undefined);
4
+ projectAccessKey?: string | undefined;
5
+ jwtAuth?: string | undefined;
6
+ constructor(hostname: string, projectAccessKey?: string | undefined, jwtAuth?: string | undefined);
12
7
  _fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
13
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/api",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
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,28 +7,27 @@ 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 authorization?: {
11
- jwtAuth?: string
12
- accessKey?: string
13
- }
10
+ public projectAccessKey?: string,
11
+ public jwtAuth?: string
14
12
  ) {
15
13
  super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch)
16
14
  this.fetch = this._fetch
17
15
  }
18
16
 
19
17
  _fetch = (input: RequestInfo, init?: RequestInit): Promise<Response> => {
20
- // automatically include jwt auth header to requests
18
+ // automatically include jwt and access key auth header to requests
21
19
  // if its been set on the api client
22
20
  const headers: { [key: string]: any } = {}
23
21
 
24
- const { jwtAuth, accessKey } = this.authorization || {}
22
+ const jwtAuth = this.jwtAuth
23
+ const projectAccessKey = this.projectAccessKey
25
24
 
26
25
  if (jwtAuth && jwtAuth.length > 0) {
27
26
  headers['Authorization'] = `BEARER ${jwtAuth}`
28
27
  }
29
28
 
30
- if (accessKey && accessKey.length > 0) {
31
- headers['X-Access-Key'] = `${accessKey}`
29
+ if (projectAccessKey && projectAccessKey.length > 0) {
30
+ headers['X-Access-Key'] = projectAccessKey
32
31
  }
33
32
 
34
33
  // before the request is made