@0xsequence/metadata 1.9.8 → 1.9.9
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.
|
@@ -506,7 +506,7 @@ class SequenceMetadata extends Metadata {
|
|
|
506
506
|
this.jwtAuth = jwtAuth;
|
|
507
507
|
this._fetch = (input, init) => {
|
|
508
508
|
// automatically include jwt and access key auth header to requests
|
|
509
|
-
// if its been set on the
|
|
509
|
+
// if its been set on the client
|
|
510
510
|
const headers = {};
|
|
511
511
|
const jwtAuth = this.jwtAuth;
|
|
512
512
|
const projectAccessKey = this.projectAccessKey;
|
|
@@ -524,11 +524,35 @@ class SequenceMetadata extends Metadata {
|
|
|
524
524
|
this.fetch = this._fetch;
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
|
+
class SequenceCollections extends Collections {
|
|
528
|
+
constructor(hostname = 'https://metadata.sequence.app', jwtAuth) {
|
|
529
|
+
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
|
|
530
|
+
this.jwtAuth = jwtAuth;
|
|
531
|
+
this._fetch = (input, init) => {
|
|
532
|
+
// automatically include jwt auth header to requests
|
|
533
|
+
// if its been set on the client
|
|
534
|
+
const headers = {};
|
|
535
|
+
const jwtAuth = this.jwtAuth;
|
|
536
|
+
if (jwtAuth && jwtAuth.length > 0) {
|
|
537
|
+
headers['Authorization'] = `BEARER ${jwtAuth}`;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// before the request is made
|
|
541
|
+
init.headers = _extends({}, init.headers, headers);
|
|
542
|
+
return fetch(input, init);
|
|
543
|
+
};
|
|
544
|
+
this.fetch = this._fetch;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// TODO: add uploadAsset() method similar to,
|
|
548
|
+
// https://github.com/0xsequence/go-sequence/blob/master/metadata/collections.go#L52
|
|
549
|
+
}
|
|
527
550
|
|
|
528
551
|
exports.Collections = Collections;
|
|
529
552
|
exports.ContractType = ContractType;
|
|
530
553
|
exports.Metadata = Metadata;
|
|
531
554
|
exports.PropertyType = PropertyType;
|
|
555
|
+
exports.SequenceCollections = SequenceCollections;
|
|
532
556
|
exports.SequenceMetadata = SequenceMetadata;
|
|
533
557
|
exports.SwapType = SwapType;
|
|
534
558
|
exports.TaskStatus = TaskStatus;
|
|
@@ -506,7 +506,7 @@ class SequenceMetadata extends Metadata {
|
|
|
506
506
|
this.jwtAuth = jwtAuth;
|
|
507
507
|
this._fetch = (input, init) => {
|
|
508
508
|
// automatically include jwt and access key auth header to requests
|
|
509
|
-
// if its been set on the
|
|
509
|
+
// if its been set on the client
|
|
510
510
|
const headers = {};
|
|
511
511
|
const jwtAuth = this.jwtAuth;
|
|
512
512
|
const projectAccessKey = this.projectAccessKey;
|
|
@@ -524,11 +524,35 @@ class SequenceMetadata extends Metadata {
|
|
|
524
524
|
this.fetch = this._fetch;
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
|
+
class SequenceCollections extends Collections {
|
|
528
|
+
constructor(hostname = 'https://metadata.sequence.app', jwtAuth) {
|
|
529
|
+
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
|
|
530
|
+
this.jwtAuth = jwtAuth;
|
|
531
|
+
this._fetch = (input, init) => {
|
|
532
|
+
// automatically include jwt auth header to requests
|
|
533
|
+
// if its been set on the client
|
|
534
|
+
const headers = {};
|
|
535
|
+
const jwtAuth = this.jwtAuth;
|
|
536
|
+
if (jwtAuth && jwtAuth.length > 0) {
|
|
537
|
+
headers['Authorization'] = `BEARER ${jwtAuth}`;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// before the request is made
|
|
541
|
+
init.headers = _extends({}, init.headers, headers);
|
|
542
|
+
return fetch(input, init);
|
|
543
|
+
};
|
|
544
|
+
this.fetch = this._fetch;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// TODO: add uploadAsset() method similar to,
|
|
548
|
+
// https://github.com/0xsequence/go-sequence/blob/master/metadata/collections.go#L52
|
|
549
|
+
}
|
|
527
550
|
|
|
528
551
|
exports.Collections = Collections;
|
|
529
552
|
exports.ContractType = ContractType;
|
|
530
553
|
exports.Metadata = Metadata;
|
|
531
554
|
exports.PropertyType = PropertyType;
|
|
555
|
+
exports.SequenceCollections = SequenceCollections;
|
|
532
556
|
exports.SequenceMetadata = SequenceMetadata;
|
|
533
557
|
exports.SwapType = SwapType;
|
|
534
558
|
exports.TaskStatus = TaskStatus;
|
|
@@ -502,7 +502,7 @@ class SequenceMetadata extends Metadata {
|
|
|
502
502
|
this.jwtAuth = jwtAuth;
|
|
503
503
|
this._fetch = (input, init) => {
|
|
504
504
|
// automatically include jwt and access key auth header to requests
|
|
505
|
-
// if its been set on the
|
|
505
|
+
// if its been set on the client
|
|
506
506
|
const headers = {};
|
|
507
507
|
const jwtAuth = this.jwtAuth;
|
|
508
508
|
const projectAccessKey = this.projectAccessKey;
|
|
@@ -520,5 +520,28 @@ class SequenceMetadata extends Metadata {
|
|
|
520
520
|
this.fetch = this._fetch;
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
|
+
class SequenceCollections extends Collections {
|
|
524
|
+
constructor(hostname = 'https://metadata.sequence.app', jwtAuth) {
|
|
525
|
+
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
|
|
526
|
+
this.jwtAuth = jwtAuth;
|
|
527
|
+
this._fetch = (input, init) => {
|
|
528
|
+
// automatically include jwt auth header to requests
|
|
529
|
+
// if its been set on the client
|
|
530
|
+
const headers = {};
|
|
531
|
+
const jwtAuth = this.jwtAuth;
|
|
532
|
+
if (jwtAuth && jwtAuth.length > 0) {
|
|
533
|
+
headers['Authorization'] = `BEARER ${jwtAuth}`;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// before the request is made
|
|
537
|
+
init.headers = _extends({}, init.headers, headers);
|
|
538
|
+
return fetch(input, init);
|
|
539
|
+
};
|
|
540
|
+
this.fetch = this._fetch;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// TODO: add uploadAsset() method similar to,
|
|
544
|
+
// https://github.com/0xsequence/go-sequence/blob/master/metadata/collections.go#L52
|
|
545
|
+
}
|
|
523
546
|
|
|
524
|
-
export { Collections, ContractType, Metadata, PropertyType, SequenceMetadata, SwapType, TaskStatus, WebRPCSchemaHash, WebRPCSchemaVersion, WebRPCVersion };
|
|
547
|
+
export { Collections, ContractType, Metadata, PropertyType, SequenceCollections, SequenceMetadata, SwapType, TaskStatus, WebRPCSchemaHash, WebRPCSchemaVersion, WebRPCVersion };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
export * from "./metadata.gen.js";
|
|
2
|
-
import { Metadata as MetadataRpc } from "./metadata.gen.js";
|
|
2
|
+
import { Metadata as MetadataRpc, Collections as CollectionsRpc } from "./metadata.gen.js";
|
|
3
3
|
export declare class SequenceMetadata extends MetadataRpc {
|
|
4
4
|
projectAccessKey?: string | undefined;
|
|
5
5
|
jwtAuth?: string | undefined;
|
|
6
6
|
constructor(hostname?: string, projectAccessKey?: string | undefined, jwtAuth?: string | undefined);
|
|
7
7
|
_fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
8
8
|
}
|
|
9
|
+
export declare class SequenceCollections extends CollectionsRpc {
|
|
10
|
+
jwtAuth?: string | undefined;
|
|
11
|
+
constructor(hostname?: string, jwtAuth?: string | undefined);
|
|
12
|
+
_fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
13
|
+
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export * from './metadata.gen'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
Metadata as MetadataRpc,
|
|
5
|
+
Collections as CollectionsRpc,
|
|
6
|
+
} from './metadata.gen'
|
|
4
7
|
|
|
5
8
|
const fetch = typeof global === 'object' ? global.fetch : window.fetch
|
|
6
9
|
|
|
@@ -16,7 +19,7 @@ export class SequenceMetadata extends MetadataRpc {
|
|
|
16
19
|
|
|
17
20
|
_fetch = (input: RequestInfo, init?: RequestInit): Promise<Response> => {
|
|
18
21
|
// automatically include jwt and access key auth header to requests
|
|
19
|
-
// if its been set on the
|
|
22
|
+
// if its been set on the client
|
|
20
23
|
const headers: { [key: string]: any } = {}
|
|
21
24
|
|
|
22
25
|
const jwtAuth = this.jwtAuth
|
|
@@ -36,3 +39,33 @@ export class SequenceMetadata extends MetadataRpc {
|
|
|
36
39
|
return fetch(input, init)
|
|
37
40
|
}
|
|
38
41
|
}
|
|
42
|
+
|
|
43
|
+
export class SequenceCollections extends CollectionsRpc {
|
|
44
|
+
constructor(
|
|
45
|
+
hostname: string = 'https://metadata.sequence.app',
|
|
46
|
+
public jwtAuth?: string
|
|
47
|
+
) {
|
|
48
|
+
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch)
|
|
49
|
+
this.fetch = this._fetch
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_fetch = (input: RequestInfo, init?: RequestInit): Promise<Response> => {
|
|
53
|
+
// automatically include jwt auth header to requests
|
|
54
|
+
// if its been set on the client
|
|
55
|
+
const headers: { [key: string]: any } = {}
|
|
56
|
+
|
|
57
|
+
const jwtAuth = this.jwtAuth
|
|
58
|
+
|
|
59
|
+
if (jwtAuth && jwtAuth.length > 0) {
|
|
60
|
+
headers['Authorization'] = `BEARER ${jwtAuth}`
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// before the request is made
|
|
64
|
+
init!.headers = { ...init!.headers, ...headers }
|
|
65
|
+
|
|
66
|
+
return fetch(input, init)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// TODO: add uploadAsset() method similar to,
|
|
70
|
+
// https://github.com/0xsequence/go-sequence/blob/master/metadata/collections.go#L52
|
|
71
|
+
}
|