@nevermined-io/payments 0.1.2 → 0.1.4

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 CHANGED
@@ -4,3 +4,68 @@
4
4
 
5
5
  > Typescript SDK to interact with the Nevermined Payments Protocol
6
6
  > [nevermined.io](https://nevermined.io)
7
+
8
+ ## Quickstart
9
+
10
+ ```
11
+ # yarn
12
+ yarn add @nevermined-io/payments
13
+
14
+ # npm
15
+
16
+ npm install @nevermined-io/payments
17
+ ```
18
+
19
+ ### Initialize the payments library
20
+
21
+ This is a browser only method. Here we have an example using react.
22
+ For a full example please refer to [payments-nextjs-example](https://github.com/nevermined-io/tutorials/tree/main/payments-nextjs-example)
23
+
24
+ ```typescript
25
+ import { useEffect } from "react";
26
+ import { Payments } from "@nevermined-io/payments";
27
+
28
+ export default function Home() {
29
+ const payments = new Payments({
30
+ returnUrl: "http://localhost:8080",
31
+ environment: "staging",
32
+ });
33
+
34
+ const onLogin = () => {
35
+ payments.connect();
36
+ };
37
+
38
+ useEffect(() => {
39
+ payments.init();
40
+ }, []);
41
+
42
+ return (
43
+ <main>
44
+ <div>
45
+ <button onClick={onLogin}>Login</button>
46
+ </div>
47
+ </main>
48
+ );
49
+ }
50
+ ```
51
+
52
+ The `init()` method should be called immediately after the app returns the user to `returnUrl`.
53
+
54
+ ### Create a subscription
55
+
56
+ Once the app is initialized we can create a subscription:
57
+
58
+ ```typescript
59
+ async function createSubscription() {
60
+ if (payments.isLoggedIn) {
61
+ const { did } = await payments.createSubscription({
62
+ name: 'test subscription',
63
+ description: 'test',
64
+ price: 10000000n,
65
+ tokenAddress: '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d',
66
+ duration: 30,
67
+ tags: ['test'],
68
+ })
69
+ }
70
+ }
71
+ ```
@@ -2,6 +2,6 @@ export interface EnvironmentInfo {
2
2
  frontend: string;
3
3
  backend: string;
4
4
  }
5
- export type EnvironmentName = 'staging';
5
+ export type EnvironmentName = 'appStaging' | 'appTesting' | 'appArbitrum' | 'appGnosis' | 'appMatic';
6
6
  export declare const Environments: Record<EnvironmentName, EnvironmentInfo>;
7
7
  //# sourceMappingURL=environments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"environments.d.ts","sourceRoot":"","sources":["../src/environments.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,MAAM,eAAe,GAAG,SAAS,CAAA;AAEvC,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,eAAe,EAAE,eAAe,CAKjE,CAAA"}
1
+ {"version":3,"file":"environments.d.ts","sourceRoot":"","sources":["../src/environments.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,YAAY,GAAG,aAAa,GAAG,WAAW,GAAG,UAAU,CAAA;AAEpG,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,eAAe,EAAE,eAAe,CAqBjE,CAAA"}
@@ -2,9 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Environments = void 0;
4
4
  exports.Environments = {
5
- staging: {
5
+ appStaging: {
6
6
  frontend: 'https://staging.nevermined.app',
7
7
  backend: 'https://one-backend.staging.nevermined.app',
8
8
  },
9
+ appTesting: {
10
+ frontend: 'https://testing.nevermined.app',
11
+ backend: 'https://one-backend.testing.nevermined.app',
12
+ },
13
+ appArbitrum: {
14
+ frontend: 'https://nevermined.app',
15
+ backend: 'https://one-backend.arbitrum.nevermined.app',
16
+ },
17
+ appGnosis: {
18
+ frontend: 'https://gnosis.nevermined.app',
19
+ backend: 'https://one-backend.gnosis.nevermined.app',
20
+ },
21
+ appMatic: {
22
+ frontend: 'https://matic.nevermined.app',
23
+ backend: 'https://one-backend.matic.nevermined.app',
24
+ },
9
25
  };
10
26
  //# sourceMappingURL=environments.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"environments.js","sourceRoot":"","sources":["../src/environments.ts"],"names":[],"mappings":";;;AAOa,QAAA,YAAY,GAA6C;IACpE,OAAO,EAAE;QACP,QAAQ,EAAE,gCAAgC;QAC1C,OAAO,EAAE,4CAA4C;KACtD;CACF,CAAA"}
1
+ {"version":3,"file":"environments.js","sourceRoot":"","sources":["../src/environments.ts"],"names":[],"mappings":";;;AAOa,QAAA,YAAY,GAA6C;IACpE,UAAU,EAAE;QACV,QAAQ,EAAE,gCAAgC;QAC1C,OAAO,EAAE,4CAA4C;KACtD;IACD,UAAU,EAAE;QACV,QAAQ,EAAE,gCAAgC;QAC1C,OAAO,EAAE,4CAA4C;KACtD;IACD,WAAW,EAAE;QACX,QAAQ,EAAE,wBAAwB;QAClC,OAAO,EAAE,6CAA6C;KACvD;IACD,SAAS,EAAE;QACT,QAAQ,EAAE,+BAA+B;QACzC,OAAO,EAAE,2CAA2C;KACrD;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,8BAA8B;QACxC,OAAO,EAAE,0CAA0C;KACpD;CACF,CAAA"}
@@ -1,19 +1,149 @@
1
1
  import { EnvironmentInfo, EnvironmentName } from './environments';
2
+ /**
3
+ * Options to initialize the Payments class.
4
+ */
2
5
  export interface PaymentOptions {
6
+ /**
7
+ * The URL to return to the app after a successful login.
8
+ */
3
9
  returnUrl: string;
10
+ /**
11
+ * The environment to connect to.
12
+ */
4
13
  environment: EnvironmentName;
14
+ /**
15
+ * The app id.
16
+ */
17
+ appId?: string;
18
+ /**
19
+ * The version of the library.
20
+ */
21
+ version?: string;
5
22
  }
6
23
  export interface Endpoint {
7
24
  [verb: string]: string;
8
25
  }
26
+ /**
27
+ * Main class that interacts with the Nevermined payments API.
28
+ */
9
29
  export declare class Payments {
10
30
  returnUrl: string;
11
31
  environment: EnvironmentInfo;
32
+ appId?: string;
33
+ version?: string;
12
34
  private sessionKey?;
35
+ /**
36
+ * Initialize the payments class.
37
+ *
38
+ * @param options - The options to initialize the payments class.
39
+ *
40
+ * @example
41
+ * ```
42
+ * const payments = new Payments({
43
+ * returnUrl: 'https://mysite.example'
44
+ * environment: 'staging'
45
+ * appId: 'my-app-id'
46
+ * version: '1.0.0'
47
+ * })
48
+ * ```
49
+ *
50
+ * @returns An instance of {@link Payments}
51
+ */
13
52
  constructor(options: PaymentOptions);
14
- init(): void;
53
+ /**
54
+ * Initiate the connect flow. The user's browser will be redirected to
55
+ * the Nevermined App login page.
56
+ *
57
+ * @remarks
58
+ *
59
+ * This is a browser only function.
60
+ *
61
+ * @example
62
+ * ```
63
+ * payments.connect()
64
+ * ```
65
+ */
15
66
  connect(): void;
67
+ /**
68
+ * Method to initialize the class once the user has been logged in.
69
+ * This method should be called has soon as the user has been redirected
70
+ * back to the app ({@link returnUrl}).
71
+ *
72
+ * @remarks
73
+ *
74
+ * This is a browser only function.
75
+ *
76
+ * @example
77
+ * ```
78
+ * payments.init()
79
+ * ```
80
+ *
81
+ * @example Using react
82
+ *
83
+ * You may want to use `useEffect` on the route that matches the passed
84
+ * {@link returnUrl}
85
+ *
86
+ * ```
87
+ * useEffect(() => {
88
+ * payments.init()
89
+ * })
90
+ * ```
91
+ */
92
+ init(): void;
93
+ /**
94
+ * Logout the user by removing the session key.
95
+ *
96
+ * @remarks
97
+ *
98
+ * This is a browser only function.
99
+ *
100
+ * @example
101
+ * ```
102
+ * payments.logout()
103
+ * ```
104
+ */
105
+ logout(): void;
106
+ /**
107
+ * Property to check if a user logged in.
108
+ *
109
+ * @example
110
+ * ```
111
+ * payments.isLoggedIn
112
+ * ```
113
+ *
114
+ * @returns True if the user is logged in.
115
+ */
16
116
  get isLoggedIn(): boolean;
117
+ /**
118
+ *
119
+ * Create a subscription on Nevermined.
120
+ *
121
+ * @param name - The name of the subscription.
122
+ * @param description - A description of what the subscription offers.
123
+ * @param price - The price of the subscription.
124
+ * @param tokenAddress - The ERC-20 token address of the currency used to price the subscription.
125
+ * Using the zero address will use the chain's native currency instead.
126
+ * @param amountOfCredits - The amount of credits associated with the credit based subscription.
127
+ * Leave unset to use time limited time subscriptions instead.
128
+ * @param duration - The duration of the subscription in days.
129
+ * If `amountOfCredits` and `duration` is left undefined an unlimited time duration subscription
130
+ * will be created.
131
+ * @param tags - An array of tags or keywords that best fit the subscription.
132
+ *
133
+ * @example
134
+ * ```
135
+ * const { did } = await payments.createSubscription({
136
+ * name: "test subscription",
137
+ * description: "test",
138
+ * price: 10000000n,
139
+ * tokenAddress: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
140
+ * duration: 30,
141
+ * tags: ["test"]
142
+ * }
143
+ * ```
144
+ *
145
+ * @returns The DID of the newly created subscription.
146
+ */
17
147
  createSubscription({ name, description, price, tokenAddress, amountOfCredits, duration, tags, }: {
18
148
  name: string;
19
149
  description: string;
@@ -25,7 +155,34 @@ export declare class Payments {
25
155
  }): Promise<{
26
156
  did: string;
27
157
  }>;
28
- createWebservice({ subscriptionDid, name, description, price, tokenAddress, amountOfCredits, duration, tags, serviceChargeType, minCreditsToCharge, maxCreditsToCharge, authType, username, password, token, endpoints, openEndpoints, openApiUrl, integration, sampleLink, apiDescription, curation, }: {
158
+ /**
159
+ * Creates a service.
160
+ *
161
+ * @param subscriptionDid - The subscription DID.
162
+ * @param name - The name of the service.
163
+ * @param description - The description of the service.
164
+ * @param price - The price of the service.
165
+ * @param tokenAddress - The token address.
166
+ * @param amountOfCredits - The amount of credits.
167
+ * @param duration - The duration of the service.
168
+ * @param tags - The tags associated with the service.
169
+ * @param serviceChargeType - The service charge type ('fixed' or 'dynamic').
170
+ * @param minCreditsToCharge - The minimum credits to charge.
171
+ * @param maxCreditsToCharge - The maximum credits to charge.
172
+ * @param authType - The authentication type ('none', 'basic', or 'oauth').
173
+ * @param username - The username for authentication.
174
+ * @param password - The password for authentication.
175
+ * @param token - The token for authentication.
176
+ * @param endpoints - The endpoints of the service.
177
+ * @param openEndpoints - The open endpoints of the service.
178
+ * @param openApiUrl - The OpenAPI URL.
179
+ * @param integration - The integration details.
180
+ * @param sampleLink - The sample link.
181
+ * @param apiDescription - The API description.
182
+ * @param curation - The curation details.
183
+ * @returns A promise that resolves to the created service DID.
184
+ */
185
+ createService({ subscriptionDid, name, description, price, tokenAddress, amountOfCredits, duration, tags, serviceChargeType, minCreditsToCharge, maxCreditsToCharge, authType, username, password, token, endpoints, openEndpoints, openApiUrl, integration, sampleLink, apiDescription, curation, }: {
29
186
  subscriptionDid: string;
30
187
  name: string;
31
188
  description: string;
@@ -51,5 +208,80 @@ export declare class Payments {
51
208
  }): Promise<{
52
209
  did: string;
53
210
  }>;
211
+ /**
212
+ * Creates a file with the specified parameters.
213
+ *
214
+ * @param subscriptionDid - The subscription DID.
215
+ * @param assetType - The type of asset.
216
+ * @param name - The name of the file.
217
+ * @param description - The description of the file.
218
+ * @param files - The array of files.
219
+ * @param price - The price of the file.
220
+ * @param tokenAddress - The token address.
221
+ * @param amountOfCredits - The amount of credits.
222
+ * @param duration - The duration of the file.
223
+ * @param tags - The array of tags.
224
+ * @param dataSchema - The data schema.
225
+ * @param sampleCode - The sample code.
226
+ * @param filesFormat - The format of the files.
227
+ * @param usageExample - The usage example.
228
+ * @param programmingLanguage - The programming language.
229
+ * @param framework - The framework.
230
+ * @param task - The task.
231
+ * @param trainingDetails - The training details.
232
+ * @param variations - The variations.
233
+ * @param fineTunable - Indicates if the file is fine-tunable.
234
+ * @param minCreditsToCharge - The minimum credits to charge.
235
+ * @param maxCreditsToCharge - The maximum credits to charge.
236
+ * @param curation - The curation object.
237
+ * @returns The promise that resolves to the created file's DID.
238
+ */
239
+ createFile({ subscriptionDid, assetType, name, description, files, price, tokenAddress, amountOfCredits, duration, tags, dataSchema, sampleCode, filesFormat, usageExample, programmingLanguage, framework, task, trainingDetails, variations, fineTunable, minCreditsToCharge, maxCreditsToCharge, curation, }: {
240
+ subscriptionDid: string;
241
+ assetType: string;
242
+ name: string;
243
+ description: string;
244
+ files: object[];
245
+ price: bigint;
246
+ tokenAddress: string;
247
+ dataSchema?: string;
248
+ sampleCode?: string;
249
+ filesFormat?: string;
250
+ usageExample?: string;
251
+ programmingLanguage?: string;
252
+ framework?: string;
253
+ task?: string;
254
+ trainingDetails?: string;
255
+ variations?: string;
256
+ fineTunable?: boolean;
257
+ amountOfCredits?: number;
258
+ minCreditsToCharge?: number;
259
+ maxCreditsToCharge?: number;
260
+ curation?: object;
261
+ duration?: number;
262
+ tags?: string[];
263
+ }): Promise<{
264
+ did: string;
265
+ }>;
266
+ /**
267
+ * Redirects the user to the subscription details for a given DID.
268
+ * @param did - The DID (Decentralized Identifier) of the subscription.
269
+ */
270
+ getSubscriptionDetails(did: string): void;
271
+ /**
272
+ * Redirects the user to the service details for a given DID.
273
+ * @param did - The DID (Decentralized Identifier) of the service.
274
+ */
275
+ getServiceDetails(did: string): void;
276
+ /**
277
+ * Redirects the user to the file details for the specified DID (Decentralized Identifier).
278
+ * @param did - The DID of the file.
279
+ */
280
+ getFileDetails(did: string): void;
281
+ /**
282
+ * Redirects the user to the subscription checkout page for the specified DID.
283
+ * @param did - The DID (Decentralized Identifier) of the item to be subscribed to.
284
+ */
285
+ checkoutSubscription(did: string): void;
54
286
  }
55
287
  //# sourceMappingURL=payments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"payments.d.ts","sourceRoot":"","sources":["../src/payments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAgB,MAAM,gBAAgB,CAAA;AAE/E,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,eAAe,CAAA;CAC7B;AAED,MAAM,WAAW,QAAQ;IACvB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CACvB;AAED,qBAAa,QAAQ;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,eAAe,CAAA;IACnC,OAA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AA;QACpB,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,mBAAmB,CAAC,EAAE,MAAM,CAAA;QAC5B,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,eAAe,CAAC,EAAE,MAAM,CAAA;QACxB,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,WAAW,CAAC,EAAE,OAAO,CAAA;QACrB,eAAe,CAAC,EAAE,MAAM,CAAA;QACxB,kBAAkB,CAAC,EAAE,MAAM,CAAA;QAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAA;QAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAChB,GAAG,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IA6C5B;;;OAGG;IACI,sBAAsB,CAAC,GAAG,EAAE,MAAM;IAKzC;;;OAGG;IACI,iBAAiB,CAAC,GAAG,EAAE,MAAM;IAKpC;;;OAGG;IACI,cAAc,CAAC,GAAG,EAAE,MAAM;IAKjC;;;OAGG;IACI,oBAAoB,CAAC,GAAG,EAAE,MAAM;CAIxC"}
package/dist/payments.js CHANGED
@@ -1,29 +1,145 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Payments = void 0;
4
+ const jose_1 = require("jose");
4
5
  const environments_1 = require("./environments");
6
+ /**
7
+ * Main class that interacts with the Nevermined payments API.
8
+ */
5
9
  class Payments {
10
+ /**
11
+ * Initialize the payments class.
12
+ *
13
+ * @param options - The options to initialize the payments class.
14
+ *
15
+ * @example
16
+ * ```
17
+ * const payments = new Payments({
18
+ * returnUrl: 'https://mysite.example'
19
+ * environment: 'staging'
20
+ * appId: 'my-app-id'
21
+ * version: '1.0.0'
22
+ * })
23
+ * ```
24
+ *
25
+ * @returns An instance of {@link Payments}
26
+ */
6
27
  constructor(options) {
7
28
  this.returnUrl = options.returnUrl;
8
29
  this.environment = environments_1.Environments[options.environment];
30
+ this.appId = options.appId;
31
+ this.version = options.version;
9
32
  }
33
+ /**
34
+ * Initiate the connect flow. The user's browser will be redirected to
35
+ * the Nevermined App login page.
36
+ *
37
+ * @remarks
38
+ *
39
+ * This is a browser only function.
40
+ *
41
+ * @example
42
+ * ```
43
+ * payments.connect()
44
+ * ```
45
+ */
46
+ connect() {
47
+ const url = new URL(`/en/login?nvm-export=session-key&returnUrl=${this.returnUrl}`, this.environment.frontend);
48
+ window.location.href = url.toString();
49
+ }
50
+ /**
51
+ * Method to initialize the class once the user has been logged in.
52
+ * This method should be called has soon as the user has been redirected
53
+ * back to the app ({@link returnUrl}).
54
+ *
55
+ * @remarks
56
+ *
57
+ * This is a browser only function.
58
+ *
59
+ * @example
60
+ * ```
61
+ * payments.init()
62
+ * ```
63
+ *
64
+ * @example Using react
65
+ *
66
+ * You may want to use `useEffect` on the route that matches the passed
67
+ * {@link returnUrl}
68
+ *
69
+ * ```
70
+ * useEffect(() => {
71
+ * payments.init()
72
+ * })
73
+ * ```
74
+ */
10
75
  init() {
11
76
  const url = new URL(window.location.href);
12
- const sessionKey = url.searchParams.get('sessionKey');
13
- if (sessionKey) {
14
- this.sessionKey = sessionKey;
15
- console.log('sessionKey:', sessionKey);
77
+ const sessionKeyJwt = url.searchParams.get('sessionKey');
78
+ if (sessionKeyJwt) {
79
+ const jwtDecoded = (0, jose_1.decodeJwt)(sessionKeyJwt);
80
+ this.sessionKey = jwtDecoded.sessionKey;
16
81
  url.searchParams.delete('sessionKey');
17
82
  history.replaceState(history.state, '', url.toString());
18
83
  }
19
84
  }
20
- connect() {
21
- const url = new URL(`/en/login?nvm-export=session-key&returnUrl=${this.returnUrl}`, this.environment.frontend);
22
- window.location.href = url.toString();
85
+ /**
86
+ * Logout the user by removing the session key.
87
+ *
88
+ * @remarks
89
+ *
90
+ * This is a browser only function.
91
+ *
92
+ * @example
93
+ * ```
94
+ * payments.logout()
95
+ * ```
96
+ */
97
+ logout() {
98
+ this.sessionKey = undefined;
23
99
  }
100
+ /**
101
+ * Property to check if a user logged in.
102
+ *
103
+ * @example
104
+ * ```
105
+ * payments.isLoggedIn
106
+ * ```
107
+ *
108
+ * @returns True if the user is logged in.
109
+ */
24
110
  get isLoggedIn() {
25
111
  return !!this.sessionKey;
26
112
  }
113
+ /**
114
+ *
115
+ * Create a subscription on Nevermined.
116
+ *
117
+ * @param name - The name of the subscription.
118
+ * @param description - A description of what the subscription offers.
119
+ * @param price - The price of the subscription.
120
+ * @param tokenAddress - The ERC-20 token address of the currency used to price the subscription.
121
+ * Using the zero address will use the chain's native currency instead.
122
+ * @param amountOfCredits - The amount of credits associated with the credit based subscription.
123
+ * Leave unset to use time limited time subscriptions instead.
124
+ * @param duration - The duration of the subscription in days.
125
+ * If `amountOfCredits` and `duration` is left undefined an unlimited time duration subscription
126
+ * will be created.
127
+ * @param tags - An array of tags or keywords that best fit the subscription.
128
+ *
129
+ * @example
130
+ * ```
131
+ * const { did } = await payments.createSubscription({
132
+ * name: "test subscription",
133
+ * description: "test",
134
+ * price: 10000000n,
135
+ * tokenAddress: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
136
+ * duration: 30,
137
+ * tags: ["test"]
138
+ * }
139
+ * ```
140
+ *
141
+ * @returns The DID of the newly created subscription.
142
+ */
27
143
  async createSubscription({ name, description, price, tokenAddress, amountOfCredits, duration, tags, }) {
28
144
  const body = {
29
145
  sessionKey: this.sessionKey,
@@ -50,7 +166,34 @@ class Payments {
50
166
  }
51
167
  return response.json();
52
168
  }
53
- async createWebservice({ subscriptionDid, name, description, price, tokenAddress, amountOfCredits, duration, tags, serviceChargeType, minCreditsToCharge, maxCreditsToCharge, authType, username, password, token, endpoints, openEndpoints, openApiUrl, integration, sampleLink, apiDescription, curation, }) {
169
+ /**
170
+ * Creates a service.
171
+ *
172
+ * @param subscriptionDid - The subscription DID.
173
+ * @param name - The name of the service.
174
+ * @param description - The description of the service.
175
+ * @param price - The price of the service.
176
+ * @param tokenAddress - The token address.
177
+ * @param amountOfCredits - The amount of credits.
178
+ * @param duration - The duration of the service.
179
+ * @param tags - The tags associated with the service.
180
+ * @param serviceChargeType - The service charge type ('fixed' or 'dynamic').
181
+ * @param minCreditsToCharge - The minimum credits to charge.
182
+ * @param maxCreditsToCharge - The maximum credits to charge.
183
+ * @param authType - The authentication type ('none', 'basic', or 'oauth').
184
+ * @param username - The username for authentication.
185
+ * @param password - The password for authentication.
186
+ * @param token - The token for authentication.
187
+ * @param endpoints - The endpoints of the service.
188
+ * @param openEndpoints - The open endpoints of the service.
189
+ * @param openApiUrl - The OpenAPI URL.
190
+ * @param integration - The integration details.
191
+ * @param sampleLink - The sample link.
192
+ * @param apiDescription - The API description.
193
+ * @param curation - The curation details.
194
+ * @returns A promise that resolves to the created service DID.
195
+ */
196
+ async createService({ subscriptionDid, name, description, price, tokenAddress, amountOfCredits, duration, tags, serviceChargeType, minCreditsToCharge, maxCreditsToCharge, authType, username, password, token, endpoints, openEndpoints, openApiUrl, integration, sampleLink, apiDescription, curation, }) {
54
197
  const body = {
55
198
  sessionKey: this.sessionKey,
56
199
  name,
@@ -76,7 +219,6 @@ class Payments {
76
219
  apiDescription,
77
220
  curation,
78
221
  };
79
- console.log(body);
80
222
  const options = {
81
223
  method: 'POST',
82
224
  headers: {
@@ -85,13 +227,115 @@ class Payments {
85
227
  },
86
228
  body: JSON.stringify(body),
87
229
  };
88
- const url = new URL('/api/v1/payments/webservice', this.environment.backend);
230
+ const url = new URL('/api/v1/payments/service', this.environment.backend);
89
231
  const response = await fetch(url, options);
90
232
  if (!response.ok) {
91
233
  throw Error(response.statusText);
92
234
  }
93
235
  return response.json();
94
236
  }
237
+ /**
238
+ * Creates a file with the specified parameters.
239
+ *
240
+ * @param subscriptionDid - The subscription DID.
241
+ * @param assetType - The type of asset.
242
+ * @param name - The name of the file.
243
+ * @param description - The description of the file.
244
+ * @param files - The array of files.
245
+ * @param price - The price of the file.
246
+ * @param tokenAddress - The token address.
247
+ * @param amountOfCredits - The amount of credits.
248
+ * @param duration - The duration of the file.
249
+ * @param tags - The array of tags.
250
+ * @param dataSchema - The data schema.
251
+ * @param sampleCode - The sample code.
252
+ * @param filesFormat - The format of the files.
253
+ * @param usageExample - The usage example.
254
+ * @param programmingLanguage - The programming language.
255
+ * @param framework - The framework.
256
+ * @param task - The task.
257
+ * @param trainingDetails - The training details.
258
+ * @param variations - The variations.
259
+ * @param fineTunable - Indicates if the file is fine-tunable.
260
+ * @param minCreditsToCharge - The minimum credits to charge.
261
+ * @param maxCreditsToCharge - The maximum credits to charge.
262
+ * @param curation - The curation object.
263
+ * @returns The promise that resolves to the created file's DID.
264
+ */
265
+ async createFile({ subscriptionDid, assetType, name, description, files, price, tokenAddress, amountOfCredits, duration, tags, dataSchema, sampleCode, filesFormat, usageExample, programmingLanguage, framework, task, trainingDetails, variations, fineTunable, minCreditsToCharge, maxCreditsToCharge, curation, }) {
266
+ const body = {
267
+ sessionKey: this.sessionKey,
268
+ assetType,
269
+ name,
270
+ description,
271
+ files,
272
+ price: price.toString(),
273
+ tokenAddress,
274
+ amountOfCredits,
275
+ duration,
276
+ tags,
277
+ subscriptionDid,
278
+ dataSchema,
279
+ sampleCode,
280
+ filesFormat,
281
+ usageExample,
282
+ programmingLanguage,
283
+ framework,
284
+ task,
285
+ trainingDetails,
286
+ variations,
287
+ fineTunable,
288
+ minCreditsToCharge,
289
+ maxCreditsToCharge,
290
+ curation,
291
+ };
292
+ const options = {
293
+ method: 'POST',
294
+ headers: {
295
+ Accept: 'application/json',
296
+ 'Content-Type': 'application/json',
297
+ },
298
+ body: JSON.stringify(body),
299
+ };
300
+ const url = new URL('/api/v1/payments/file', this.environment.backend);
301
+ const response = await fetch(url, options);
302
+ if (!response.ok) {
303
+ throw Error(response.statusText);
304
+ }
305
+ return response.json();
306
+ }
307
+ /**
308
+ * Redirects the user to the subscription details for a given DID.
309
+ * @param did - The DID (Decentralized Identifier) of the subscription.
310
+ */
311
+ getSubscriptionDetails(did) {
312
+ const url = new URL(`/en/subscription/${did}`, this.environment.frontend);
313
+ window.location.href = url.toString();
314
+ }
315
+ /**
316
+ * Redirects the user to the service details for a given DID.
317
+ * @param did - The DID (Decentralized Identifier) of the service.
318
+ */
319
+ getServiceDetails(did) {
320
+ const url = new URL(`/en/webservice/${did}`, this.environment.frontend);
321
+ window.location.href = url.toString();
322
+ }
323
+ /**
324
+ * Redirects the user to the file details for the specified DID (Decentralized Identifier).
325
+ * @param did - The DID of the file.
326
+ */
327
+ getFileDetails(did) {
328
+ const url = new URL(`/en/file/${did}`, this.environment.frontend);
329
+ window.location.href = url.toString();
330
+ }
331
+ /**
332
+ * Redirects the user to the subscription checkout page for the specified DID.
333
+ * @param did - The DID (Decentralized Identifier) of the item to be subscribed to.
334
+ */
335
+ checkoutSubscription(did) {
336
+ const url = new URL(`/en/subscription/checkout/${did}`, this.environment.frontend);
337
+ window.location.href = url.toString();
338
+ }
95
339
  }
96
340
  exports.Payments = Payments;
97
341
  //# sourceMappingURL=payments.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"payments.js","sourceRoot":"","sources":["../src/payments.ts"],"names":[],"mappings":";;;AAAA,iDAA+E;AAW/E,MAAa,QAAQ;IAKnB,YAAY,OAAuB;QACjC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;QAClC,IAAI,CAAC,WAAW,GAAG,2BAAY,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IACtD,CAAC;IAEM,IAAI;QACT,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QACzC,MAAM,UAAU,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QACrD,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;YAC5B,OAAO,CAAC,GAAG,CAAC,aAAa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AC;IAED;;;OAGG;IACI,sBAAsB,CAAC,GAAW;QACvC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,oBAAoB,GAAG,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QACzE,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAA;IACvC,CAAC;IAED;;;OAGG;IACI,iBAAiB,CAAC,GAAW;QAClC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,kBAAkB,GAAG,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QACvE,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAA;IACvC,CAAC;IAED;;;OAGG;IACI,cAAc,CAAC,GAAW;QAC/B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,YAAY,GAAG,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QACjE,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAA;IACvC,CAAC;IAED;;;OAGG;IACI,oBAAoB,CAAC,GAAW;QACrC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,6BAA6B,GAAG,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QAClF,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAA;IACvC,CAAC;CACF;AAldD,4BAkdC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nevermined-io/payments",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Typescript SDK to interact with the Nevermined Payments Protocol",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -20,7 +20,9 @@
20
20
  "format": "prettier --check ./src",
21
21
  "prepublishOnly": "yarn build"
22
22
  },
23
- "dependencies": {},
23
+ "dependencies": {
24
+ "jose": "^5.2.2"
25
+ },
24
26
  "devDependencies": {
25
27
  "@types/node": "^20.11.19",
26
28
  "@typescript-eslint/eslint-plugin": "^7.0.2",
@@ -29,6 +31,7 @@
29
31
  "eslint-config-nevermined": "^0.2.0",
30
32
  "eslint-config-next": "^14.1.0",
31
33
  "eslint-config-prettier": "^9.1.0",
34
+ "eslint-plugin-tsdoc": "^0.2.17",
32
35
  "prettier": "^3.2.5",
33
36
  "ts-node": "^10.9.2",
34
37
  "tslib": "^2.6.2",