@0xsequence/api 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.
|
@@ -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,
|
|
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
|
-
|
|
610
|
-
|
|
609
|
+
const {
|
|
610
|
+
jwtAuth,
|
|
611
|
+
accessKey
|
|
612
|
+
} = this.authorization || {};
|
|
613
|
+
if (jwtAuth && jwtAuth.length > 0) {
|
|
614
|
+
headers['Authorization'] = `BEARER ${jwtAuth}`;
|
|
615
|
+
}
|
|
616
|
+
if (accessKey && accessKey.length > 0) {
|
|
617
|
+
headers['X-Access-Key'] = `${accessKey}`;
|
|
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.
|
|
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,
|
|
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
|
-
|
|
610
|
-
|
|
609
|
+
const {
|
|
610
|
+
jwtAuth,
|
|
611
|
+
accessKey
|
|
612
|
+
} = this.authorization || {};
|
|
613
|
+
if (jwtAuth && jwtAuth.length > 0) {
|
|
614
|
+
headers['Authorization'] = `BEARER ${jwtAuth}`;
|
|
615
|
+
}
|
|
616
|
+
if (accessKey && accessKey.length > 0) {
|
|
617
|
+
headers['X-Access-Key'] = `${accessKey}`;
|
|
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.
|
|
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,
|
|
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
|
-
|
|
606
|
-
|
|
605
|
+
const {
|
|
606
|
+
jwtAuth,
|
|
607
|
+
accessKey
|
|
608
|
+
} = this.authorization || {};
|
|
609
|
+
if (jwtAuth && jwtAuth.length > 0) {
|
|
610
|
+
headers['Authorization'] = `BEARER ${jwtAuth}`;
|
|
611
|
+
}
|
|
612
|
+
if (accessKey && accessKey.length > 0) {
|
|
613
|
+
headers['X-Access-Key'] = `${accessKey}`;
|
|
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.
|
|
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
|
-
|
|
5
|
-
|
|
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);
|
|
6
12
|
_fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
7
13
|
}
|
package/package.json
CHANGED
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
|
|
10
|
+
public authorization?: {
|
|
11
|
+
jwtAuth?: string
|
|
12
|
+
accessKey?: 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
|
-
|
|
21
|
-
|
|
23
|
+
|
|
24
|
+
const { jwtAuth, accessKey } = this.authorization || {}
|
|
25
|
+
|
|
26
|
+
if (jwtAuth && jwtAuth.length > 0) {
|
|
27
|
+
headers['Authorization'] = `BEARER ${jwtAuth}`
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (accessKey && accessKey.length > 0) {
|
|
31
|
+
headers['X-Access-Key'] = `${accessKey}`
|
|
22
32
|
}
|
|
23
33
|
|
|
24
34
|
// before the request is made
|