@0xsequence/api 0.0.0-20231121142317 → 0.0.0-20231124180941

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