@nevermined-io/payments 0.4.2 → 0.5.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.
- package/README.md +19 -15
- package/dist/api/nvm-backend.d.ts +113 -0
- package/dist/api/nvm-backend.d.ts.map +1 -0
- package/dist/api/nvm-backend.js +248 -0
- package/dist/api/nvm-backend.js.map +1 -0
- package/dist/api/query-api.d.ts +264 -0
- package/dist/api/query-api.d.ts.map +1 -0
- package/dist/api/query-api.js +265 -0
- package/dist/api/query-api.js.map +1 -0
- package/dist/common/payments.error.d.ts +4 -0
- package/dist/common/payments.error.d.ts.map +1 -0
- package/dist/common/payments.error.js +7 -0
- package/dist/common/payments.error.js.map +1 -0
- package/dist/common/types.d.ts +141 -0
- package/dist/common/types.d.ts.map +1 -0
- package/dist/common/types.js +29 -0
- package/dist/common/types.js.map +1 -0
- package/dist/common/utils.d.ts +8 -0
- package/dist/common/utils.d.ts.map +1 -0
- package/dist/common/utils.js +10 -0
- package/dist/common/utils.js.map +1 -0
- package/dist/environments.d.ts +4 -1
- package/dist/environments.d.ts.map +1 -1
- package/dist/environments.js +32 -8
- package/dist/environments.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -18
- package/dist/index.js.map +1 -1
- package/dist/payments.d.ts +232 -121
- package/dist/payments.d.ts.map +1 -1
- package/dist/payments.js +486 -227
- package/dist/payments.js.map +1 -1
- package/package.json +15 -1
package/dist/payments.d.ts
CHANGED
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
import { EnvironmentInfo, EnvironmentName } from './environments';
|
|
2
|
+
import { AIQueryApi } from './api/query-api';
|
|
2
3
|
/**
|
|
3
4
|
* Options to initialize the Payments class.
|
|
4
5
|
*/
|
|
5
6
|
export interface PaymentOptions {
|
|
6
7
|
/**
|
|
7
|
-
* The
|
|
8
|
+
* The Nevermined environment to connect to.
|
|
9
|
+
* If you are developing an agent it's recommended to use the "testing" environment.
|
|
10
|
+
* When deploying to production use the "arbitrum" environment.
|
|
8
11
|
*/
|
|
9
|
-
|
|
12
|
+
environment: EnvironmentName;
|
|
10
13
|
/**
|
|
11
|
-
* The
|
|
14
|
+
* The Nevermined API Key. This key identify your user and is required to interact with the Nevermined API.
|
|
15
|
+
* You can get your API key by logging in to the Nevermined App.
|
|
16
|
+
* @see https://docs.nevermined.app/docs/tutorials/integration/nvm-api-keys
|
|
12
17
|
*/
|
|
13
|
-
|
|
18
|
+
nvmApiKey?: string;
|
|
14
19
|
/**
|
|
15
|
-
* The app
|
|
20
|
+
* The URL to return to the app after a successful login.
|
|
21
|
+
*/
|
|
22
|
+
returnUrl?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The app id. This attribute is optional and helps to associate assets registered into Nevermined with a common identifier.
|
|
16
25
|
*/
|
|
17
26
|
appId?: string;
|
|
18
27
|
/**
|
|
19
|
-
* The version of the
|
|
28
|
+
* The version of the API to use.
|
|
20
29
|
*/
|
|
21
30
|
version?: string;
|
|
22
31
|
}
|
|
@@ -25,32 +34,71 @@ export interface Endpoint {
|
|
|
25
34
|
}
|
|
26
35
|
/**
|
|
27
36
|
* Main class that interacts with the Nevermined payments API.
|
|
37
|
+
* To get an instance of this class use the `getInstance` method.
|
|
28
38
|
*/
|
|
29
39
|
export declare class Payments {
|
|
40
|
+
query: AIQueryApi;
|
|
30
41
|
returnUrl: string;
|
|
31
42
|
environment: EnvironmentInfo;
|
|
32
43
|
appId?: string;
|
|
33
44
|
version?: string;
|
|
34
45
|
accountAddress?: string;
|
|
35
46
|
private nvmApiKey?;
|
|
47
|
+
isBrowserInstance: boolean;
|
|
36
48
|
/**
|
|
37
|
-
*
|
|
49
|
+
* The options get's an instance of the payments class.
|
|
50
|
+
*
|
|
51
|
+
* @param options - The options to initialize the payments class.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```
|
|
55
|
+
* const payments = Payments.getInstance({
|
|
56
|
+
* nvmApiKey: 'kjdfaofakdoasdkoas',
|
|
57
|
+
* environment: 'testing'
|
|
58
|
+
* })
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @returns An instance of {@link Payments}
|
|
62
|
+
*/
|
|
63
|
+
static getInstance(options: PaymentOptions): Payments;
|
|
64
|
+
/**
|
|
65
|
+
* The options get's an instance of the payments class to be used in the browser.
|
|
66
|
+
*
|
|
67
|
+
* @remarks
|
|
68
|
+
*
|
|
69
|
+
* This is a browser only function.
|
|
38
70
|
*
|
|
39
71
|
* @param options - The options to initialize the payments class.
|
|
40
72
|
*
|
|
41
73
|
* @example
|
|
42
74
|
* ```
|
|
43
|
-
* const payments =
|
|
44
|
-
* returnUrl: 'https://mysite.example'
|
|
45
|
-
* environment: '
|
|
46
|
-
* appId: 'my-app-id'
|
|
75
|
+
* const payments = Payments.getBrowserInstance({
|
|
76
|
+
* returnUrl: 'https://mysite.example',
|
|
77
|
+
* environment: 'testing',
|
|
78
|
+
* appId: 'my-app-id',
|
|
47
79
|
* version: '1.0.0'
|
|
48
80
|
* })
|
|
49
81
|
* ```
|
|
50
82
|
*
|
|
51
83
|
* @returns An instance of {@link Payments}
|
|
52
84
|
*/
|
|
53
|
-
|
|
85
|
+
static getBrowserInstance(options: PaymentOptions): Payments;
|
|
86
|
+
/**
|
|
87
|
+
* Initialize the payments class.
|
|
88
|
+
*
|
|
89
|
+
* @param options - The options to initialize the payments class.
|
|
90
|
+
*
|
|
91
|
+
* @returns An instance of {@link Payments}
|
|
92
|
+
*/
|
|
93
|
+
private constructor();
|
|
94
|
+
/**
|
|
95
|
+
* It parses the NVM API Key to get the account address.
|
|
96
|
+
*/
|
|
97
|
+
private parseNvmApiKey;
|
|
98
|
+
/**
|
|
99
|
+
* Initializes the AI Query Protocol API.
|
|
100
|
+
*/
|
|
101
|
+
private initializeApi;
|
|
54
102
|
/**
|
|
55
103
|
* Initiate the connect flow. The user's browser will be redirected to
|
|
56
104
|
* the Nevermined App login page.
|
|
@@ -117,60 +165,74 @@ export declare class Payments {
|
|
|
117
165
|
get isLoggedIn(): boolean;
|
|
118
166
|
/**
|
|
119
167
|
*
|
|
120
|
-
*
|
|
168
|
+
* It allows to an AI Builder to create a Payment Plan on Nevermined based on Credits.
|
|
169
|
+
* A Nevermined Credits Plan limits the access by the access/usage of the Plan.
|
|
170
|
+
* With them, AI Builders control the number of requests that can be made to an agent or service.
|
|
171
|
+
* Every time a user accesses any resouce associated to the Payment Plan, the usage consumes from a capped amount of credits.
|
|
172
|
+
* When the user consumes all the credits, the plan automatically expires and the user needs to top up to continue using the service.
|
|
173
|
+
*
|
|
174
|
+
* @remarks
|
|
175
|
+
*
|
|
176
|
+
* This method is oriented to AI Builders
|
|
121
177
|
*
|
|
122
|
-
* @
|
|
123
|
-
*
|
|
124
|
-
* @param
|
|
125
|
-
* @param
|
|
126
|
-
*
|
|
127
|
-
* @param
|
|
178
|
+
* @see https://docs.nevermined.app/docs/tutorials/builders/create-plan
|
|
179
|
+
*
|
|
180
|
+
* @param name - The name of the plan.
|
|
181
|
+
* @param description - A description of what the plan offers.
|
|
182
|
+
* @param price - The price of the plan. It must be given in the lowest denomination of the currency.
|
|
183
|
+
* @param tokenAddress - The address of the ERC20 contract used for the payment. Using the `ZeroAddress` will use the chain's native currency instead.
|
|
184
|
+
* @param amountOfCredits - The number of credits that are transferred to the user when purchases the plan.
|
|
128
185
|
* @param tags - An array of tags or keywords that best fit the subscription.
|
|
129
|
-
* @param nvmApiKey - The NVM API key to use for the request.
|
|
130
186
|
*
|
|
131
187
|
* @example
|
|
132
188
|
* ```
|
|
133
|
-
* const { did } = await payments.
|
|
134
|
-
* name: "
|
|
135
|
-
* description: "
|
|
189
|
+
* const { did } = await payments.createCreditsPlan({
|
|
190
|
+
* name: "My AI Payments Plan",
|
|
191
|
+
* description: "AI stuff",
|
|
136
192
|
* price: 10000000n,
|
|
137
193
|
* tokenAddress: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
|
|
138
|
-
*
|
|
194
|
+
* amountOfCredits: 30,
|
|
139
195
|
* tags: ["test"]
|
|
140
196
|
* }
|
|
141
197
|
* ```
|
|
142
198
|
*
|
|
143
|
-
* @returns The DID of the newly created
|
|
199
|
+
* @returns The unique identifier of the plan (Plan DID) of the newly created plan.
|
|
144
200
|
*/
|
|
145
|
-
|
|
201
|
+
createCreditsPlan({ name, description, price, tokenAddress, amountOfCredits, tags, }: {
|
|
146
202
|
name: string;
|
|
147
203
|
description: string;
|
|
148
204
|
price: bigint;
|
|
149
205
|
tokenAddress: string;
|
|
150
206
|
amountOfCredits: number;
|
|
151
207
|
tags?: string[];
|
|
152
|
-
nvmApiKey?: string;
|
|
153
208
|
}): Promise<{
|
|
154
209
|
did: string;
|
|
155
210
|
}>;
|
|
156
211
|
/**
|
|
157
212
|
*
|
|
158
|
-
*
|
|
213
|
+
* It allows to an AI Builder to create a Payment Plan on Nevermined based on Time.
|
|
214
|
+
* A Nevermined Time Plan limits the access by the a specific amount of time.
|
|
215
|
+
* With them, AI Builders can specify the duration of the Payment Plan (1 month, 1 year, etc.).
|
|
216
|
+
* When the time period is over, the plan automatically expires and the user needs to renew it.
|
|
217
|
+
*
|
|
218
|
+
* @remarks
|
|
219
|
+
*
|
|
220
|
+
* This method is oriented to AI Builders
|
|
221
|
+
*
|
|
222
|
+
* @see https://docs.nevermined.app/docs/tutorials/builders/create-plan
|
|
159
223
|
*
|
|
160
|
-
* @param name - The name of the
|
|
161
|
-
* @param description - A description of what the
|
|
162
|
-
* @param price - The price of the
|
|
163
|
-
* @param tokenAddress - The
|
|
164
|
-
*
|
|
165
|
-
* @param duration - The duration of the
|
|
166
|
-
* If `duration` is left undefined an unlimited time duration subscription will be created.
|
|
224
|
+
* @param name - The name of the plan.
|
|
225
|
+
* @param description - A description of what the plan offers.
|
|
226
|
+
* @param price - The price of the plan. It must be given in the lowest denomination of the currency.
|
|
227
|
+
* @param tokenAddress - The address of the ERC20 contract used for the payment. Using the `ZeroAddress` will use the chain's native currency instead.
|
|
228
|
+
* @param tags - An array of tags or keywords that best fit the subscription.
|
|
229
|
+
* @param duration - The duration of the plan in days. If `duration` is left undefined an unlimited time duration subscription will be created.
|
|
167
230
|
* @param tags - An array of tags or keywords that best fit the subscription.
|
|
168
|
-
* @param nvmApiKey - The NVM API key to use for the request.
|
|
169
231
|
*
|
|
170
232
|
* @example
|
|
171
233
|
* ```
|
|
172
|
-
* const { did } = await payments.
|
|
173
|
-
* name: "
|
|
234
|
+
* const { did } = await payments.createTimePlan({
|
|
235
|
+
* name: "My 1 year Plan",
|
|
174
236
|
* description: "test",
|
|
175
237
|
* price: 10000000n,
|
|
176
238
|
* tokenAddress: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
|
|
@@ -179,50 +241,59 @@ export declare class Payments {
|
|
|
179
241
|
* }
|
|
180
242
|
* ```
|
|
181
243
|
*
|
|
182
|
-
* @returns The DID of the newly created
|
|
244
|
+
* @returns The unique identifier of the plan (Plan DID) of the newly created plan.
|
|
183
245
|
*/
|
|
184
|
-
|
|
246
|
+
createTimePlan({ name, description, price, tokenAddress, duration, tags, }: {
|
|
185
247
|
name: string;
|
|
186
248
|
description: string;
|
|
187
249
|
price: bigint;
|
|
188
250
|
tokenAddress: string;
|
|
189
251
|
duration?: number;
|
|
190
252
|
tags?: string[];
|
|
191
|
-
nvmApiKey?: string;
|
|
192
253
|
}): Promise<{
|
|
193
254
|
did: string;
|
|
194
255
|
}>;
|
|
195
256
|
/**
|
|
196
|
-
*
|
|
257
|
+
* It creates a new AI Agent or Service on Nevermined.
|
|
258
|
+
* The agent/service must be associated to a Payment Plan. Users that are subscribers of a payment plan can access the agent/service.
|
|
259
|
+
* Depending on the Payment Plan and the configuration of the agent/service, the usage of the agent/service will consume credits.
|
|
260
|
+
* When the plan expires (because the time is over or the credits are consumed), the user needs to renew the plan to continue using the agent/service.
|
|
261
|
+
*
|
|
262
|
+
* @remarks
|
|
263
|
+
*
|
|
264
|
+
* This method is oriented to AI Builders
|
|
197
265
|
*
|
|
198
|
-
* @
|
|
199
|
-
*
|
|
200
|
-
* @param
|
|
201
|
-
* @param
|
|
202
|
-
* @param
|
|
266
|
+
* @see https://docs.nevermined.app/docs/tutorials/builders/register-agent
|
|
267
|
+
*
|
|
268
|
+
* @param planDID - The plan unique identifier of the Plan (DID). @see {@link createCreditsPlan} or {@link createTimePlan}
|
|
269
|
+
* @param name - The name of the AI Agent/Service.
|
|
270
|
+
* @param description - The description of the AI Agent/Service.
|
|
271
|
+
* @param tags - The tags describing the AI Agent/Service.
|
|
272
|
+
* @param serviceType - The service type ('service', 'agent', or 'assistant').
|
|
203
273
|
* @param serviceChargeType - The service charge type ('fixed' or 'dynamic').
|
|
274
|
+
* @param amountOfCredits - The amount of credits to charge per request to the agent.
|
|
204
275
|
* @param minCreditsToCharge - The minimum credits to charge.
|
|
205
276
|
* @param maxCreditsToCharge - The maximum credits to charge.
|
|
206
|
-
* @param authType - The authentication type ('none', 'basic', or 'oauth').
|
|
207
|
-
* @param username - The username for authentication.
|
|
208
|
-
* @param password - The password for authentication.
|
|
209
|
-
* @param token - The token for authentication.
|
|
210
|
-
* @param endpoints - The endpoints of the service.
|
|
211
|
-
* @param openEndpoints - The
|
|
212
|
-
* @param openApiUrl - The OpenAPI
|
|
213
|
-
* @param integration -
|
|
214
|
-
* @param sampleLink -
|
|
215
|
-
* @param apiDescription -
|
|
277
|
+
* @param authType - The upstream agent/service authentication type ('none', 'basic', 'bearer' or 'oauth').
|
|
278
|
+
* @param username - The upstream agent/service username for authentication. Only if `authType` is 'basic'.
|
|
279
|
+
* @param password - The upstream agent/service password for authentication. Only if `authType` is 'basic'.
|
|
280
|
+
* @param token - The upstream agent/service bearer token for authentication. Only if `authType` is 'bearer' or 'oauth'.
|
|
281
|
+
* @param endpoints - The list endpoints of the upstream service. All these endpoints are protected and only accessible to subscribers of the Payment Plan.
|
|
282
|
+
* @param openEndpoints - The list of endpoints of the upstream service that publicly available. The access to these endpoints don't require subscription to the Payment Plan. They are useful to expose documentation, etc.
|
|
283
|
+
* @param openApiUrl - The URL to the OpenAPI description of the Upstream API. The access to the OpenAPI definition don't require subscription to the Payment Plan.
|
|
284
|
+
* @param integration - Some description or instructions about how to integrate the Agent.
|
|
285
|
+
* @param sampleLink - A link to some same usage of the Agent.
|
|
286
|
+
* @param apiDescription - Text describing the API of the Agent.
|
|
216
287
|
* @param curation - The curation details.
|
|
217
|
-
* @
|
|
218
|
-
* @returns A promise that resolves to the created service DID.
|
|
288
|
+
* @returns A promise that resolves to the created agent DID.
|
|
219
289
|
*/
|
|
220
|
-
createService({
|
|
221
|
-
|
|
290
|
+
createService({ planDID, name, description, amountOfCredits, tags, serviceType, serviceChargeType, minCreditsToCharge, maxCreditsToCharge, authType, username, password, token, endpoints, openEndpoints, openApiUrl, integration, sampleLink, apiDescription, curation, }: {
|
|
291
|
+
planDID: string;
|
|
222
292
|
name: string;
|
|
223
293
|
description: string;
|
|
294
|
+
serviceType: 'service' | 'agent' | 'assistant';
|
|
224
295
|
serviceChargeType: 'fixed' | 'dynamic';
|
|
225
|
-
authType: 'none' | 'basic' | 'oauth';
|
|
296
|
+
authType: 'none' | 'basic' | 'oauth' | 'bearer';
|
|
226
297
|
amountOfCredits?: number;
|
|
227
298
|
minCreditsToCharge?: number;
|
|
228
299
|
maxCreditsToCharge?: number;
|
|
@@ -237,40 +308,44 @@ export declare class Payments {
|
|
|
237
308
|
apiDescription?: string;
|
|
238
309
|
curation?: object;
|
|
239
310
|
tags?: string[];
|
|
240
|
-
nvmApiKey?: string;
|
|
241
311
|
}): Promise<{
|
|
242
312
|
did: string;
|
|
243
313
|
}>;
|
|
244
314
|
/**
|
|
245
|
-
*
|
|
315
|
+
* It creates a new asset with file associated to it.
|
|
316
|
+
* The file asset must be associated to a Payment Plan. Users that are subscribers of a payment plan can download the files attached to it.
|
|
317
|
+
* Depending on the Payment Plan and the configuration of the file asset, the download will consume credits.
|
|
318
|
+
* When the plan expires (because the time is over or the credits are consumed), the user needs to renew the plan to continue downloading the files.
|
|
319
|
+
*
|
|
320
|
+
* @remarks
|
|
321
|
+
*
|
|
322
|
+
* This method is oriented to AI Builders
|
|
323
|
+
*
|
|
324
|
+
* @see https://docs.nevermined.app/docs/tutorials/builders/register-file-asset
|
|
246
325
|
*
|
|
247
|
-
* @param
|
|
248
|
-
* @param assetType - The type of asset
|
|
326
|
+
* @param planDID - The plan unique identifier of the Plan (DID). @see {@link createCreditsPlan} or {@link createTimePlan}
|
|
327
|
+
* @param assetType - The type of asset ('dataset' | 'algorithm' | 'model' | 'file' | 'other')
|
|
249
328
|
* @param name - The name of the file.
|
|
250
329
|
* @param description - The description of the file.
|
|
251
|
-
* @param files - The array of files.
|
|
252
|
-
* @param amountOfCredits - The
|
|
253
|
-
* @param
|
|
254
|
-
* @param
|
|
255
|
-
* @param
|
|
256
|
-
* @param sampleCode - The sample code.
|
|
330
|
+
* @param files - The array of files that can be downloaded for users that are subscribers of the Payment Plan.
|
|
331
|
+
* @param amountOfCredits - The cost in credits of downloading a file. This parameter is only required if the Payment Plan attached to the file is based on credits.
|
|
332
|
+
* @param tags - The array of tags describing the file.
|
|
333
|
+
* @param dataSchema - The data schema of the files.
|
|
334
|
+
* @param sampleCode - Some sample code related to the file.
|
|
257
335
|
* @param filesFormat - The format of the files.
|
|
258
336
|
* @param usageExample - The usage example.
|
|
259
|
-
* @param programmingLanguage - The programming language.
|
|
260
|
-
* @param framework - The framework.
|
|
261
|
-
* @param task - The task.
|
|
337
|
+
* @param programmingLanguage - The programming language used in the files.
|
|
338
|
+
* @param framework - The framework used for creating the file.
|
|
339
|
+
* @param task - The task creating the file.
|
|
262
340
|
* @param trainingDetails - The training details.
|
|
263
341
|
* @param variations - The variations.
|
|
264
342
|
* @param fineTunable - Indicates if the file is fine-tunable.
|
|
265
|
-
* @param minCreditsToCharge - The minimum credits to charge.
|
|
266
|
-
* @param maxCreditsToCharge - The maximum credits to charge.
|
|
267
343
|
* @param curation - The curation object.
|
|
268
|
-
* @param nvmApiKey - The NVM API key to use for the request.
|
|
269
344
|
* @returns The promise that resolves to the created file's DID.
|
|
270
345
|
*/
|
|
271
|
-
createFile({
|
|
272
|
-
|
|
273
|
-
assetType:
|
|
346
|
+
createFile({ planDID, assetType, name, description, files, amountOfCredits, tags, dataSchema, sampleCode, filesFormat, usageExample, programmingLanguage, framework, task, trainingDetails, variations, fineTunable, curation, }: {
|
|
347
|
+
planDID: string;
|
|
348
|
+
assetType: 'dataset' | 'algorithm' | 'model' | 'file' | 'other';
|
|
274
349
|
name: string;
|
|
275
350
|
description: string;
|
|
276
351
|
files: object[];
|
|
@@ -289,66 +364,77 @@ export declare class Payments {
|
|
|
289
364
|
maxCreditsToCharge?: number;
|
|
290
365
|
curation?: object;
|
|
291
366
|
tags?: string[];
|
|
292
|
-
nvmApiKey?: string;
|
|
293
367
|
}): Promise<{
|
|
294
368
|
did: string;
|
|
295
369
|
}>;
|
|
296
370
|
/**
|
|
297
|
-
* Get the DDO for a given DID.
|
|
371
|
+
* Get the Metadata (aka Decentralized Document or DDO) for a given asset identifier (DID).
|
|
372
|
+
*
|
|
373
|
+
* @see https://docs.nevermined.io/docs/architecture/specs/Spec-DID
|
|
374
|
+
* @see https://docs.nevermined.io/docs/architecture/specs/Spec-METADATA
|
|
298
375
|
*
|
|
299
|
-
* @param did - The DID of the asset.
|
|
376
|
+
* @param did - The unique identifier (aka DID) of the asset (payment plan, agent, file, etc).
|
|
300
377
|
* @returns A promise that resolves to the DDO.
|
|
301
378
|
*/
|
|
302
379
|
getAssetDDO(did: string): Promise<any>;
|
|
303
380
|
/**
|
|
304
|
-
* Get array of services DIDs associated with a
|
|
381
|
+
* Get array of services/agent DIDs associated with a payment plan.
|
|
305
382
|
*
|
|
306
|
-
* @param
|
|
307
|
-
* @returns A promise that resolves to the array of services DIDs.
|
|
383
|
+
* @param planDID - The DID of the Payment Plan.
|
|
384
|
+
* @returns A promise that resolves to the array of services/agents DIDs.
|
|
308
385
|
*/
|
|
309
|
-
|
|
386
|
+
getPlanAssociatedServices(planDID: string): Promise<any>;
|
|
310
387
|
/**
|
|
311
|
-
* Get array of files DIDs associated with a
|
|
388
|
+
* Get array of files DIDs associated with a payment plan.
|
|
312
389
|
*
|
|
313
|
-
* @param
|
|
390
|
+
* @param planDID - The DID of the Payment Plan.
|
|
314
391
|
* @returns A promise that resolves to array of files DIDs.
|
|
315
392
|
*/
|
|
316
|
-
|
|
393
|
+
getPlanAssociatedFiles(planDID: string): Promise<any>;
|
|
317
394
|
/**
|
|
318
|
-
* Get the balance of an account for a
|
|
395
|
+
* Get the balance of an account for a Payment Plan.
|
|
319
396
|
*
|
|
320
|
-
* @param
|
|
397
|
+
* @param planDID - The Payment Plan DID of the service to be published.
|
|
321
398
|
* @param accountAddress - The address of the account to get the balance.
|
|
322
|
-
* @param nvmApiKey - The NVM API key to use for the request.
|
|
323
399
|
* @returns A promise that resolves to the balance result.
|
|
324
400
|
*/
|
|
325
|
-
|
|
401
|
+
getPlanBalance(planDID: string, accountAddress?: string): Promise<{
|
|
326
402
|
subscriptionType: string;
|
|
327
403
|
isOwner: boolean;
|
|
328
404
|
balance: bigint;
|
|
329
405
|
isSubscriptor: boolean;
|
|
330
406
|
}>;
|
|
331
407
|
/**
|
|
332
|
-
* Get the
|
|
408
|
+
* Get the required configuration for accessing a remote service agent.
|
|
409
|
+
* This configuration includes:
|
|
410
|
+
* - The JWT access token
|
|
411
|
+
* - The Proxy url that can be used to query the agent/service.
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
* ```
|
|
415
|
+
* const accessConfig = await payments.getServiceAccessConfig(agentDID)
|
|
416
|
+
* console.log(`Agent JWT Token: ${accessConfig.accessToken}`)
|
|
417
|
+
* console.log(`Agent Proxy URL: ${accessConfig.neverminedProxyUri}`)
|
|
418
|
+
* ```
|
|
333
419
|
*
|
|
334
|
-
* @param did - The DID of the service.
|
|
420
|
+
* @param did - The DID of the agent/service.
|
|
335
421
|
* @returns A promise that resolves to the service token.
|
|
336
422
|
*/
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
neverminedProxyUri: string;
|
|
341
|
-
};
|
|
423
|
+
getServiceAccessConfig(did: string): Promise<{
|
|
424
|
+
accessToken: string;
|
|
425
|
+
neverminedProxyUri: string;
|
|
342
426
|
}>;
|
|
343
427
|
/**
|
|
344
|
-
* Orders a
|
|
428
|
+
* Orders a Payment Plan. The user needs to have enough balance in the token selected by the owner of the Payment Plan.
|
|
345
429
|
*
|
|
346
|
-
* @
|
|
347
|
-
*
|
|
348
|
-
*
|
|
430
|
+
* @remarks
|
|
431
|
+
* The payment is done using Crypto. Payments using Fiat can be done via the Nevermined App.
|
|
432
|
+
*
|
|
433
|
+
* @param planDID - The Payment Plan DID of the service to be published.
|
|
434
|
+
* @param agreementId - The unique identifier of the purchase transaction (aka agreement ID). When this parameter is given, it assumes there is a previous payment step and will request the payment plan.
|
|
349
435
|
* @returns A promise that resolves to the agreement ID and a boolean indicating if the operation was successful.
|
|
350
436
|
*/
|
|
351
|
-
orderSubscription(
|
|
437
|
+
orderSubscription(planDID: string, agreementId?: string): Promise<{
|
|
352
438
|
agreementId: string;
|
|
353
439
|
success: boolean;
|
|
354
440
|
}>;
|
|
@@ -356,49 +442,74 @@ export declare class Payments {
|
|
|
356
442
|
* Downloads files for a given DID asset.
|
|
357
443
|
*
|
|
358
444
|
* @param did - The DID of the file.
|
|
359
|
-
* @param nvmApiKey - The NVM API key to use for the request.
|
|
360
445
|
* @returns A promise that resolves to the JSON response from the server.
|
|
361
446
|
*/
|
|
362
|
-
downloadFiles(fileDid: string
|
|
447
|
+
downloadFiles(fileDid: string): Promise<string>;
|
|
363
448
|
/**
|
|
364
449
|
* Redirects the user to the subscription details for a given DID.
|
|
365
|
-
* @
|
|
450
|
+
* @remarks
|
|
451
|
+
*
|
|
452
|
+
* This method is only for browser instances.
|
|
453
|
+
*
|
|
454
|
+
* @param planDID - The DID (Decentralized Identifier) of the plan.
|
|
366
455
|
*/
|
|
367
|
-
|
|
456
|
+
getPlanDetails(planDID: string): void;
|
|
368
457
|
/**
|
|
369
458
|
* Redirects the user to the service details for a given DID.
|
|
459
|
+
*
|
|
460
|
+
* @remarks
|
|
461
|
+
*
|
|
462
|
+
* This method is only for browser instances.
|
|
463
|
+
*
|
|
370
464
|
* @param did - The DID (Decentralized Identifier) of the service.
|
|
371
465
|
*/
|
|
372
466
|
getServiceDetails(did: string): void;
|
|
373
467
|
/**
|
|
374
468
|
* Redirects the user to the file details for the specified DID (Decentralized Identifier).
|
|
469
|
+
*
|
|
470
|
+
* @remarks
|
|
471
|
+
*
|
|
472
|
+
* This method is only for browser instances.
|
|
473
|
+
*
|
|
375
474
|
* @param did - The DID of the file.
|
|
376
475
|
*/
|
|
377
476
|
getFileDetails(did: string): void;
|
|
378
477
|
/**
|
|
379
478
|
* Redirects the user to the subscription checkout page for the specified DID.
|
|
479
|
+
*
|
|
480
|
+
* @remarks
|
|
481
|
+
*
|
|
482
|
+
* This method is only for browser instances.
|
|
483
|
+
*
|
|
380
484
|
* @param did - The DID (Decentralized Identifier) of the item to be subscribed to.
|
|
381
485
|
*/
|
|
382
486
|
checkoutSubscription(did: string): void;
|
|
383
487
|
/**
|
|
384
|
-
* Mint credits for a given DID and transfer them to a receiver.
|
|
385
|
-
*
|
|
386
|
-
* @
|
|
488
|
+
* Mint credits for a given Payment Plan DID and transfer them to a receiver.
|
|
489
|
+
*
|
|
490
|
+
* @remarks
|
|
491
|
+
*
|
|
492
|
+
* This method is only can be called by the owner of the Payment Plan.
|
|
493
|
+
*
|
|
494
|
+
* @param planDID - The DID (Decentralized Identifier) of the asset.
|
|
495
|
+
* @param creditsAmount - The amount of NFT (Non-Fungible Token) credits to mint.
|
|
387
496
|
* @param receiver - The address of the receiver where the credits will be transferred.
|
|
388
|
-
* @param nvmApiKey - (Optional) The NVM (Nevermined Vault Manager) API key to use for authorization.
|
|
389
497
|
* @returns A Promise that resolves to the JSON response from the server.
|
|
390
498
|
* @throws Error if the server response is not successful.
|
|
391
499
|
*/
|
|
392
|
-
mintCredits(
|
|
500
|
+
mintCredits(planDID: string, creditsAmount: string, receiver: string): Promise<any>;
|
|
393
501
|
/**
|
|
394
|
-
* Burn credits for a given DID.
|
|
502
|
+
* Burn credits for a given Payment Plan DID.
|
|
503
|
+
*
|
|
504
|
+
* @remarks
|
|
505
|
+
*
|
|
506
|
+
* This method is only can be called by the owner of the Payment Plan.
|
|
395
507
|
*
|
|
396
|
-
* @param
|
|
397
|
-
* @param
|
|
398
|
-
* @param nvmApiKey - (Optional) The NVM (Nevermined Vault Manager) API key to use for authorization.
|
|
508
|
+
* @param planDID - The DID (Decentralized Identifier) of the asset.
|
|
509
|
+
* @param creditsAmount - The amount of NFT (Non-Fungible Token) credits to burn.
|
|
399
510
|
* @returns A Promise that resolves to the JSON response from the server.
|
|
400
511
|
* @throws Error if the server response is not successful.
|
|
401
512
|
*/
|
|
402
|
-
burnCredits(
|
|
513
|
+
burnCredits(planDID: string, creditsAmount: string): Promise<any>;
|
|
403
514
|
}
|
|
404
515
|
//# sourceMappingURL=payments.d.ts.map
|
package/dist/payments.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payments.d.ts","sourceRoot":"","sources":["../src/payments.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAgB,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"payments.d.ts","sourceRoot":"","sources":["../src/payments.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAgB,MAAM,gBAAgB,CAAA;AAG/E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,WAAW,EAAE,eAAe,CAAA;IAE5B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OA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