@nevermined-io/core-kit 0.0.9 → 0.0.10
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.
- package/dist/Instantiable.abstract.d.ts +0 -2
- package/dist/Instantiable.abstract.d.ts.map +1 -1
- package/dist/Instantiable.abstract.js +2 -6
- package/dist/models/NeverminedOptions.d.ts +0 -12
- package/dist/models/NeverminedOptions.d.ts.map +1 -1
- package/dist/models/NeverminedOptions.js +0 -12
- package/dist/nevermined/utils/WebServiceConnector.d.ts +0 -2
- package/dist/nevermined/utils/WebServiceConnector.d.ts.map +1 -1
- package/dist/nevermined/utils/WebServiceConnector.js +0 -24
- package/dist/services/MetadataService.d.ts +0 -37
- package/dist/services/MetadataService.d.ts.map +1 -1
- package/dist/services/MetadataService.js +0 -122
- package/package.json +1 -1
|
@@ -8,7 +8,6 @@ export interface InstantiableConfig {
|
|
|
8
8
|
config?: NeverminedOptions;
|
|
9
9
|
client?: Web3Clients;
|
|
10
10
|
logger?: ReturnType<typeof LoggerInstance>;
|
|
11
|
-
artifactsFolder?: string;
|
|
12
11
|
}
|
|
13
12
|
export interface Web3Clients {
|
|
14
13
|
public: PublicClient;
|
|
@@ -25,7 +24,6 @@ export declare abstract class Instantiable {
|
|
|
25
24
|
protected get instantiableConfig(): InstantiableConfig | undefined;
|
|
26
25
|
protected get config(): NeverminedOptions;
|
|
27
26
|
protected get logger(): import("pino").Logger;
|
|
28
|
-
protected get artifactsFolder(): string | undefined;
|
|
29
27
|
protected get instanceConfig(): InstantiableConfig;
|
|
30
28
|
static getInstance(..._args: any): any;
|
|
31
29
|
protected static setInstanceConfig<T extends Instantiable>(instance: T, instantiableConfig: InstantiableConfig): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Instantiable.abstract.d.ts","sourceRoot":"","sources":["../src/Instantiable.abstract.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KA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AED,wBAAsB,kBAAkB,CACtC,MAAM,GAAE,OAAO,CAAC,iBAAiB,CAAM,GACtC,OAAO,CAAC,WAAW,CAAC,CAwBtB;AAED,8BAAsB,YAAY;IAChC,SAAS,KAAK,UAAU,eAMvB;IAED,IAAW,MAAM,gBAMhB;IAED,IAAW,YAAY,IAAI,YAAY,CAMtC;IAED,IAAW,YAAY,IAAI,YAAY,CAMtC;IAED,SAAS,KAAK,kBAAkB,mCAK/B;IAED,SAAS,KAAK,MAAM,sBAMnB;IAED,SAAS,KAAK,MAAM,0BAEnB;IAED,SAAS,KAAK,cAAc,IAAI,kBAAkB,CAGjD;WAEa,WAAW,CAAC,GAAG,KAAK,EAAE,GAAG,GAAG,GAAG;IAI7C,SAAS,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,SAAS,YAAY,EACvD,QAAQ,EAAE,CAAC,EACX,kBAAkB,EAAE,kBAAkB;IAKxC,OAAO,CAAC,mBAAmB,CAAC,CAAoB;IAEhD,SAAS,CAAC,iBAAiB,CAAC,MAAM,EAAE,kBAAkB;CAGvD"}
|
|
@@ -12,7 +12,6 @@ export async function generateInstantiableConfigFromConfig(config, loadClient =
|
|
|
12
12
|
config,
|
|
13
13
|
client: loadClient ? await getWeb3ViemClients(config) : undefined,
|
|
14
14
|
logger,
|
|
15
|
-
artifactsFolder: config.artifactsFolder,
|
|
16
15
|
};
|
|
17
16
|
}
|
|
18
17
|
export async function getWeb3ViemClients(config = {}) {
|
|
@@ -82,12 +81,9 @@ export class Instantiable {
|
|
|
82
81
|
get logger() {
|
|
83
82
|
return this._instantiableConfig?.logger || LoggerInstance();
|
|
84
83
|
}
|
|
85
|
-
get artifactsFolder() {
|
|
86
|
-
return this._instantiableConfig?.artifactsFolder;
|
|
87
|
-
}
|
|
88
84
|
get instanceConfig() {
|
|
89
|
-
const { nevermined, client, config, logger
|
|
90
|
-
return { nevermined, client, config, logger
|
|
85
|
+
const { nevermined, client, config, logger } = this;
|
|
86
|
+
return { nevermined, client, config, logger };
|
|
91
87
|
}
|
|
92
88
|
static getInstance(..._args) {
|
|
93
89
|
LoggerInstance().warn('getInstance() methods has needs to be added to child class.');
|
|
@@ -17,19 +17,7 @@ export declare class NeverminedOptions {
|
|
|
17
17
|
* Log level.
|
|
18
18
|
*/
|
|
19
19
|
logLevel: string;
|
|
20
|
-
/**
|
|
21
|
-
* The folder where the nevermined contract artifacts are located.
|
|
22
|
-
*/
|
|
23
|
-
artifactsFolder?: string;
|
|
24
20
|
accounts?: Account[];
|
|
25
|
-
/**
|
|
26
|
-
* IPFS variables enable the resolution of DDOs (via `assets.resolve`) from CID urls
|
|
27
|
-
* INFO: For performance purposes, it is recommended to setup a IPFS Infura endpoint to accelerate
|
|
28
|
-
* the asset resolution requests.
|
|
29
|
-
*/
|
|
30
|
-
ipfsGateway?: string;
|
|
31
|
-
ipfsProjectId?: string;
|
|
32
|
-
ipfsProjectSecret?: string;
|
|
33
21
|
/**
|
|
34
22
|
* ZeroDev project id
|
|
35
23
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeverminedOptions.d.ts","sourceRoot":"","sources":["../../src/models/NeverminedOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAE9B,qBAAa,iBAAiB;IACrB,OAAO,EAAE,MAAM,CAAA;IACtB;;;;OAIG;IACI,eAAe,CAAC,EAAE,MAAM,CAAA;IAE/B;;OAEG;IACI,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB,WAAW,CAAC,EAAE,MAAM,CAAA;IAE3B;;OAEG;IACI,QAAQ,SAAS;
|
|
1
|
+
{"version":3,"file":"NeverminedOptions.d.ts","sourceRoot":"","sources":["../../src/models/NeverminedOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAE9B,qBAAa,iBAAiB;IACrB,OAAO,EAAE,MAAM,CAAA;IACtB;;;;OAIG;IACI,eAAe,CAAC,EAAE,MAAM,CAAA;IAE/B;;OAEG;IACI,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB,WAAW,CAAC,EAAE,MAAM,CAAA;IAE3B;;OAEG;IACI,QAAQ,SAAS;IAEjB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;IAE3B;;OAEG;IACI,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEhC;;OAEG;IACI,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACjC"}
|
|
@@ -16,19 +16,7 @@ export class NeverminedOptions {
|
|
|
16
16
|
* Log level.
|
|
17
17
|
*/
|
|
18
18
|
logLevel = 'info';
|
|
19
|
-
/**
|
|
20
|
-
* The folder where the nevermined contract artifacts are located.
|
|
21
|
-
*/
|
|
22
|
-
artifactsFolder;
|
|
23
19
|
accounts;
|
|
24
|
-
/**
|
|
25
|
-
* IPFS variables enable the resolution of DDOs (via `assets.resolve`) from CID urls
|
|
26
|
-
* INFO: For performance purposes, it is recommended to setup a IPFS Infura endpoint to accelerate
|
|
27
|
-
* the asset resolution requests.
|
|
28
|
-
*/
|
|
29
|
-
ipfsGateway = 'https://ipfs.io';
|
|
30
|
-
ipfsProjectId;
|
|
31
|
-
ipfsProjectSecret;
|
|
32
20
|
/**
|
|
33
21
|
* ZeroDev project id
|
|
34
22
|
*/
|
|
@@ -24,8 +24,6 @@ export declare class WebServiceConnector {
|
|
|
24
24
|
uploadMessage(url: string, data: string, encrypt?: boolean): Promise<any>;
|
|
25
25
|
uploadFile(url: string, data: ReadStream, encrypt?: boolean): Promise<any>;
|
|
26
26
|
fetchToken(url: string, grantToken: string, sessionKey?: string, numberTries?: number, apiKeyHash?: string): Promise<Response>;
|
|
27
|
-
fetchCID(cid: string): Promise<string>;
|
|
28
|
-
private static getIPFSAuthToken;
|
|
29
27
|
private fetch;
|
|
30
28
|
private _sleep;
|
|
31
29
|
}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CAAC,QAAQ,CAAC;IAWb,MAAM,CACX,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,QAAQ,EAClB,OAAO,GAAE;QAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;KAAO,GACzC,OAAO,CAAC,QAAQ,CAAC;IAgEP,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAQxD,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IASzE,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IAS1E,UAAU,CACrB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,EACnB,WAAW,SAAI,EACf,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,QAAQ,CAAC;YA2BN,KAAK;IAiBnB,OAAO,CAAC,MAAM;CAGf"}
|
|
@@ -152,30 +152,6 @@ export class WebServiceConnector {
|
|
|
152
152
|
},
|
|
153
153
|
}, numberTries);
|
|
154
154
|
}
|
|
155
|
-
async fetchCID(cid) {
|
|
156
|
-
const url = `${this.config.config?.ipfsGateway}/api/v0/cat?arg=${cid.replace('cid://', '')}`;
|
|
157
|
-
const authToken = WebServiceConnector.getIPFSAuthToken();
|
|
158
|
-
const options = {
|
|
159
|
-
method: 'POST',
|
|
160
|
-
...(authToken && {
|
|
161
|
-
headers: { Authorization: `Basic ${authToken}` },
|
|
162
|
-
}),
|
|
163
|
-
};
|
|
164
|
-
return fetch(url, options).then(async (res) => {
|
|
165
|
-
if (!res.ok) {
|
|
166
|
-
throw new Error(`${res.status}: ${res.statusText} - ${await res.text()}`);
|
|
167
|
-
}
|
|
168
|
-
return res.text();
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
static getIPFSAuthToken() {
|
|
172
|
-
if (!process.env.IPFS_PROJECT_ID || !process.env.IPFS_PROJECT_SECRET) {
|
|
173
|
-
return undefined;
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
return Buffer.from(`${process.env.IPFS_PROJECT_ID}:${process.env.IPFS_PROJECT_SECRET}`).toString('base64');
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
155
|
async fetch(url, opts, numberTries = 1) {
|
|
180
156
|
let counterTries = 1;
|
|
181
157
|
let result;
|
|
@@ -11,20 +11,6 @@ export interface QueryResult {
|
|
|
11
11
|
[jsonPath: string]: any;
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
export interface DDOStatus {
|
|
15
|
-
internal: {
|
|
16
|
-
id: string;
|
|
17
|
-
type: string;
|
|
18
|
-
status: string;
|
|
19
|
-
url: string;
|
|
20
|
-
};
|
|
21
|
-
external: {
|
|
22
|
-
id: string;
|
|
23
|
-
type: string;
|
|
24
|
-
status: string;
|
|
25
|
-
url: string;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
14
|
export interface AuthToken {
|
|
29
15
|
access_token: string;
|
|
30
16
|
}
|
|
@@ -41,11 +27,6 @@ export declare class MetadataService extends Api {
|
|
|
41
27
|
* @returns A list of {@link QueryResult}s.
|
|
42
28
|
*/
|
|
43
29
|
queryMetadata(query: SearchQuery): Promise<QueryResult>;
|
|
44
|
-
/**
|
|
45
|
-
* Search over the Services using a query.
|
|
46
|
-
* @param query - Query to filter the Services.
|
|
47
|
-
* @returns A list of {@link ServiceSecondary}.
|
|
48
|
-
*/
|
|
49
30
|
/**
|
|
50
31
|
* Update a DDO in Metadata.
|
|
51
32
|
* @param ddo - DDO to be stored.assignable
|
|
@@ -65,26 +46,8 @@ export declare class MetadataService extends Api {
|
|
|
65
46
|
* @returns DDO of the asset.
|
|
66
47
|
*/
|
|
67
48
|
retrieveDDO(did?: DID | string, metadataServiceEndpoint?: string): Promise<DDO>;
|
|
68
|
-
retrieveDDOFromImmutableBackend(immutableUrl: string): Promise<DDO>;
|
|
69
49
|
delete(did: DID | string, backendAuthToken: string): Promise<import("node-fetch").Response>;
|
|
70
50
|
retrieveDDOByUrl(metadataServiceEndpoint?: string): Promise<DDO>;
|
|
71
|
-
/**
|
|
72
|
-
* Retrieves a DDO by DID.
|
|
73
|
-
* @param did - DID of the asset.
|
|
74
|
-
* @returns DDO of the asset.
|
|
75
|
-
*/
|
|
76
|
-
status(did: DID | string, metadataServiceEndpoint?: string): Promise<DDOStatus>;
|
|
77
|
-
/**
|
|
78
|
-
* Retrieves a service by its agreementId.
|
|
79
|
-
* @param agreementId - agreementId of the service.
|
|
80
|
-
* @returns Service object.
|
|
81
|
-
*/
|
|
82
|
-
/**
|
|
83
|
-
*
|
|
84
|
-
* @param agreementId - The agreement ID of the service.
|
|
85
|
-
* @param agreement - Stores the Service object with its agreementId
|
|
86
|
-
* @returns the newly stored service object
|
|
87
|
-
*/
|
|
88
51
|
getServiceEndpoint(did: DID): string;
|
|
89
52
|
}
|
|
90
53
|
//# sourceMappingURL=MetadataService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetadataService.d.ts","sourceRoot":"","sources":["../../src/services/MetadataService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAE9B,eAAO,MAAM,OAAO,4BAA4B,CAAA;AAChD,eAAO,MAAM,WAAW,oCAAoC,CAAA;AAE5D,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,GAAG,EAAE,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE;QAAE,CAA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G,MAAM,EAAE,uBAAuB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAgC/E,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,EAAE,gBAAgB,EAAE,MAAM;IAWlD,gBAAgB,CAAC,uBAAuB,CAAC,EAAE,MAAM;IAIvD,kBAAkB,CAAC,GAAG,EAAE,GAAG;CAGnC"}
|
|
@@ -57,30 +57,6 @@ export class MetadataService extends Api {
|
|
|
57
57
|
});
|
|
58
58
|
return result;
|
|
59
59
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Search over the Services using a query.
|
|
62
|
-
* @param query - Query to filter the Services.
|
|
63
|
-
* @returns A list of {@link ServiceSecondary}.
|
|
64
|
-
*/
|
|
65
|
-
// public async queryServiceMetadata(query: {
|
|
66
|
-
// [property: string]: string | number | string[] | number[] | object
|
|
67
|
-
// }): Promise<ServiceSecondary[]> {
|
|
68
|
-
// const result: ServiceSecondary[] = await this.nevermined.utils.fetch
|
|
69
|
-
// .post(`${this.url}${servicePath}/query`, JSON.stringify(query))
|
|
70
|
-
// .then((response: any) => {
|
|
71
|
-
// if (response.ok) {
|
|
72
|
-
// return response.json() as ServiceSecondary[]
|
|
73
|
-
// }
|
|
74
|
-
// throw new HttpError(
|
|
75
|
-
// `queryServicesMetadata failed - ${response.statusText} ${response.url}`,
|
|
76
|
-
// response.status,
|
|
77
|
-
// )
|
|
78
|
-
// })
|
|
79
|
-
// .catch((error) => {
|
|
80
|
-
// throw new ApiError(error)
|
|
81
|
-
// })
|
|
82
|
-
// return result
|
|
83
|
-
// }
|
|
84
60
|
/**
|
|
85
61
|
* Update a DDO in Metadata.
|
|
86
62
|
* @param ddo - DDO to be stored.assignable
|
|
@@ -164,18 +140,6 @@ export class MetadataService extends Api {
|
|
|
164
140
|
});
|
|
165
141
|
return result;
|
|
166
142
|
}
|
|
167
|
-
async retrieveDDOFromImmutableBackend(immutableUrl) {
|
|
168
|
-
if (!(immutableUrl && immutableUrl.length > 10))
|
|
169
|
-
throw new Error(`Invalid immutable url`);
|
|
170
|
-
if (immutableUrl.startsWith('cid://')) {
|
|
171
|
-
return await this.nevermined.utils.fetch.fetchCID(immutableUrl).then((response) => {
|
|
172
|
-
return DDO.deserialize(response);
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
throw new Error(`Invalid url`);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
143
|
async delete(did, backendAuthToken) {
|
|
180
144
|
const result = await this.nevermined.utils.fetch.delete(`${this.url}${apiPath}/${DID.parse(did).getDid()}`, undefined, {
|
|
181
145
|
Authorization: `Bearer ${backendAuthToken}`,
|
|
@@ -185,92 +149,6 @@ export class MetadataService extends Api {
|
|
|
185
149
|
async retrieveDDOByUrl(metadataServiceEndpoint) {
|
|
186
150
|
return this.retrieveDDO(undefined, metadataServiceEndpoint);
|
|
187
151
|
}
|
|
188
|
-
/**
|
|
189
|
-
* Retrieves a DDO by DID.
|
|
190
|
-
* @param did - DID of the asset.
|
|
191
|
-
* @returns DDO of the asset.
|
|
192
|
-
*/
|
|
193
|
-
async status(did, metadataServiceEndpoint) {
|
|
194
|
-
const fullUrl = metadataServiceEndpoint || `${this.url}${apiPath}/${DID.parse(did).getDid()}/status`;
|
|
195
|
-
const result = await this.nevermined.utils.fetch
|
|
196
|
-
.get(fullUrl)
|
|
197
|
-
.then((response) => {
|
|
198
|
-
if (response.ok) {
|
|
199
|
-
return response.json();
|
|
200
|
-
}
|
|
201
|
-
throw new HttpError(`status failed - ${response.statusText} ${response.url}`, response.status);
|
|
202
|
-
})
|
|
203
|
-
.then((response) => {
|
|
204
|
-
return response;
|
|
205
|
-
})
|
|
206
|
-
.catch((error) => {
|
|
207
|
-
throw new ApiError(error);
|
|
208
|
-
});
|
|
209
|
-
return result;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Retrieves a service by its agreementId.
|
|
213
|
-
* @param agreementId - agreementId of the service.
|
|
214
|
-
* @returns Service object.
|
|
215
|
-
*/
|
|
216
|
-
// public async retrieveService(
|
|
217
|
-
// agreementId: string,
|
|
218
|
-
// metadataServiceEndpoint?: string,
|
|
219
|
-
// ): Promise<ServiceSecondary> {
|
|
220
|
-
// const fullUrl = metadataServiceEndpoint || `${this.url}${servicePath}/${agreementId}`
|
|
221
|
-
// const result = await this.nevermined.utils.fetch
|
|
222
|
-
// .get(fullUrl)
|
|
223
|
-
// .then((response: any) => {
|
|
224
|
-
// if (response.ok) {
|
|
225
|
-
// return response.json()
|
|
226
|
-
// }
|
|
227
|
-
// throw new HttpError(
|
|
228
|
-
// `retrieveService failed - ${response.statusText} ${response.url}`,
|
|
229
|
-
// response.status,
|
|
230
|
-
// )
|
|
231
|
-
// })
|
|
232
|
-
// .then((response: ServiceSecondary) => {
|
|
233
|
-
// return response as ServiceSecondary
|
|
234
|
-
// })
|
|
235
|
-
// .catch((error) => {
|
|
236
|
-
// throw new ApiError(error)
|
|
237
|
-
// })
|
|
238
|
-
// return result
|
|
239
|
-
// }
|
|
240
|
-
/**
|
|
241
|
-
*
|
|
242
|
-
* @param agreementId - The agreement ID of the service.
|
|
243
|
-
* @param agreement - Stores the Service object with its agreementId
|
|
244
|
-
* @returns the newly stored service object
|
|
245
|
-
*/
|
|
246
|
-
// public async storeService(
|
|
247
|
-
// agreementId: string,
|
|
248
|
-
// agreement: ServiceSecondary,
|
|
249
|
-
// ): Promise<ServiceSecondary> {
|
|
250
|
-
// const fullUrl = `${this.url}${servicePath}`
|
|
251
|
-
// agreement['agreementId'] = agreementId
|
|
252
|
-
// const agreementStore = JSON.stringify(agreement)
|
|
253
|
-
// const result: ServiceSecondary = await this.nevermined.utils.fetch
|
|
254
|
-
// .post(fullUrl, agreementStore, {
|
|
255
|
-
// Authorization: `Bearer ${this.config.marketplaceAuthToken}`,
|
|
256
|
-
// })
|
|
257
|
-
// .then((response: any) => {
|
|
258
|
-
// if (response.ok) {
|
|
259
|
-
// return response.json()
|
|
260
|
-
// }
|
|
261
|
-
// throw new HttpError(
|
|
262
|
-
// `storeService failed - ${response.statusText} ${response.url}`,
|
|
263
|
-
// response.status,
|
|
264
|
-
// )
|
|
265
|
-
// })
|
|
266
|
-
// .then((response: ServiceSecondary) => {
|
|
267
|
-
// return response as ServiceSecondary
|
|
268
|
-
// })
|
|
269
|
-
// .catch((error) => {
|
|
270
|
-
// throw new ApiError(error)
|
|
271
|
-
// })
|
|
272
|
-
// return result
|
|
273
|
-
// }
|
|
274
152
|
getServiceEndpoint(did) {
|
|
275
153
|
return `${this.url}${apiPath}/did:nv:${did.getId()}`;
|
|
276
154
|
}
|