@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 CHANGED
@@ -16,7 +16,16 @@ yarn add @nevermined-io/payments
16
16
  npm install @nevermined-io/payments
17
17
  ```
18
18
 
19
- ### Initialize the payments library
19
+ ### Initialize the payments library (standalone)
20
+
21
+ ```typescript
22
+ const payments = Payments.getInstance({
23
+ nvmApiKey: myBuilderNvmApiKey,
24
+ environment: "testing",
25
+ })
26
+ ```
27
+
28
+ ### Initialize the payments library (browser)
20
29
 
21
30
  This is a browser only method. Here we have an example using react.
22
31
  For a full example please refer to [payments-nextjs-example](https://github.com/nevermined-io/tutorials/tree/main/payments-nextjs-example)
@@ -51,21 +60,16 @@ export default function Home() {
51
60
 
52
61
  The `init()` method should be called immediately after the app returns the user to `returnUrl`.
53
62
 
54
- ### Create a subscription
63
+ ### Create a plan
55
64
 
56
- Once the app is initialized we can create a subscription:
65
+ Once the app is initialized we can create a credits plan:
57
66
 
58
67
  ```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
- }
68
+ await paymentsBuilder.createCreditsPlan({
69
+ name: 'E2E Payments Plan',
70
+ description: 'description',
71
+ price: 0n,
72
+ tokenAddress: ERC20_ADDRESS,
73
+ amountOfCredits: 100
74
+ })
71
75
  ```
@@ -0,0 +1,113 @@
1
+ import { AgentExecutionStatus } from '../common/types';
2
+ export interface BackendApiOptions {
3
+ /**
4
+ * The host of the backend server
5
+ */
6
+ backendHost: string;
7
+ /**
8
+ * The Nevermined API Key. This key identify your user and is required to interact with the Nevermined API.
9
+ * You can get your API key by logging in to the Nevermined App.
10
+ * @see https://docs.nevermined.app/docs/tutorials/integration/nvm-api-keys
11
+ */
12
+ apiKey?: string;
13
+ /**
14
+ * The host of the websocket server
15
+ */
16
+ webSocketHost?: string;
17
+ /**
18
+ * The host of the Nevermined Proxy
19
+ */
20
+ proxyHost?: string;
21
+ /**
22
+ * Additional headers to send with the requests
23
+ */
24
+ headers?: {
25
+ [key: string]: string;
26
+ };
27
+ /**
28
+ * Configuration of the websocket connection
29
+ */
30
+ webSocketOptions?: BackendWebSocketOptions;
31
+ }
32
+ export interface BackendWebSocketOptions {
33
+ /**
34
+ * The path to connect to the websocket server
35
+ */
36
+ path?: string;
37
+ /**
38
+ * The websocket transports to use
39
+ */
40
+ transports?: string[];
41
+ /**
42
+ * The bearer token to use in the websocket connection
43
+ */
44
+ bearerToken?: string;
45
+ /**
46
+ * Additional options to pass to the websocket transport
47
+ */
48
+ transportOptions?: {
49
+ [key: string]: any;
50
+ };
51
+ }
52
+ export declare class HTTPRequestOptions {
53
+ sendThroughProxy: boolean;
54
+ proxyHost?: string;
55
+ headers?: {
56
+ [key: string]: string;
57
+ };
58
+ }
59
+ export declare class SubscriptionOptions {
60
+ joinAccountRoom: boolean;
61
+ joinAgentRooms: string[];
62
+ subscribeEventTypes: string[];
63
+ getPendingEventsOnSubscribe: boolean;
64
+ }
65
+ export declare const DefaultSubscriptionOptions: {
66
+ joinAccountRoom: boolean;
67
+ joinAgentRooms: never[];
68
+ subscribeEventTypes: string[];
69
+ getPendingEventsOnSubscribe: boolean;
70
+ };
71
+ export declare class NVMBackendApi {
72
+ private opts;
73
+ private socketClient;
74
+ private userRoomId;
75
+ private hasKey;
76
+ private _defaultSocketOptions;
77
+ constructor(opts: BackendApiOptions);
78
+ private connectSocket;
79
+ private disconnectSocket;
80
+ isWebSocketConnected(): any;
81
+ protected _subscribe(_callback: (err?: any) => any, opts: SubscriptionOptions): Promise<void>;
82
+ private eventHandler;
83
+ protected _emitStepEvents(status?: AgentExecutionStatus, dids?: string[]): Promise<void>;
84
+ disconnect(): void;
85
+ parseUrl(uri: string, reqOptions: HTTPRequestOptions): string;
86
+ parseHeaders(additionalHeaders: {
87
+ [key: string]: string;
88
+ }): {
89
+ [x: string]: string;
90
+ };
91
+ setBearerToken(token: string): void;
92
+ get(url: string, reqOptions?: HTTPRequestOptions): Promise<import("axios").AxiosResponse<any, any> | {
93
+ data: any;
94
+ status: any;
95
+ headers: any;
96
+ }>;
97
+ post(url: string, data: any, reqOptions: HTTPRequestOptions): Promise<import("axios").AxiosResponse<any, any> | {
98
+ data: any;
99
+ status: any;
100
+ headers: any;
101
+ }>;
102
+ put(url: string, data: any, reqOptions: HTTPRequestOptions): Promise<import("axios").AxiosResponse<any, any> | {
103
+ data: any;
104
+ status: any;
105
+ headers: any;
106
+ }>;
107
+ delete(url: string, data: any, reqOptions: HTTPRequestOptions): Promise<import("axios").AxiosResponse<any, any> | {
108
+ data: any;
109
+ status: any;
110
+ headers: any;
111
+ }>;
112
+ }
113
+ //# sourceMappingURL=nvm-backend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nvm-backend.d.ts","sourceRoot":"","sources":["../../src/api/nvm-backend.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAEtD,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IAEnC;;OAEG;IACH,gBAAgB,CAAC,EAAE,uBAAuB,CAAA;CAC3C;AAED,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,UAAU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M;IAOtB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,GAAE,kBAA+C;;;;;IAU5E,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,kBAAkB;;;;;IAc3D,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,kBAAkB;;;;;IAW1D,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,kBAAkB;;;;;CAUpE"}
@@ -0,0 +1,248 @@
1
+ import axios from 'axios';
2
+ import { io } from 'socket.io-client';
3
+ import { decodeJwt } from 'jose';
4
+ import { isEthereumAddress, sleep } from '../common/utils';
5
+ import { AgentExecutionStatus } from '../common/types';
6
+ export class HTTPRequestOptions {
7
+ constructor() {
8
+ this.sendThroughProxy = true;
9
+ this.proxyHost = undefined;
10
+ this.headers = {};
11
+ }
12
+ }
13
+ export class SubscriptionOptions {
14
+ constructor() {
15
+ this.joinAccountRoom = true;
16
+ this.joinAgentRooms = [];
17
+ this.subscribeEventTypes = ['step-updated'];
18
+ this.getPendingEventsOnSubscribe = true;
19
+ }
20
+ }
21
+ export const DefaultSubscriptionOptions = {
22
+ joinAccountRoom: true,
23
+ joinAgentRooms: [],
24
+ subscribeEventTypes: ['step-updated'],
25
+ getPendingEventsOnSubscribe: true,
26
+ };
27
+ export class NVMBackendApi {
28
+ constructor(opts) {
29
+ this.userRoomId = undefined;
30
+ this.hasKey = false;
31
+ this._defaultSocketOptions = {
32
+ // path: '',
33
+ transports: ['websocket'],
34
+ transportOptions: {
35
+ websocket: {
36
+ extraHeaders: {},
37
+ },
38
+ },
39
+ };
40
+ const defaultHeaders = {
41
+ Accept: 'application/json',
42
+ ...opts.headers,
43
+ ...(opts.apiKey && { Authorization: `Bearer ${opts.apiKey}` }),
44
+ };
45
+ if (opts.webSocketOptions?.bearerToken) {
46
+ // If the user pass a specific websocketoptions bearer token we use that one
47
+ opts.webSocketOptions = {
48
+ ...opts.webSocketOptions,
49
+ transportOptions: {
50
+ websocket: {
51
+ extraHeaders: { Authorization: `Bearer ${opts.webSocketOptions.bearerToken}` },
52
+ },
53
+ },
54
+ };
55
+ }
56
+ else if (opts.apiKey) {
57
+ // If not use the api key
58
+ opts.webSocketOptions = {
59
+ ...opts.webSocketOptions,
60
+ transportOptions: {
61
+ websocket: {
62
+ extraHeaders: { Authorization: `Bearer ${opts.apiKey}` },
63
+ },
64
+ },
65
+ };
66
+ }
67
+ this.opts = {
68
+ ...opts,
69
+ webSocketOptions: {
70
+ ...this._defaultSocketOptions,
71
+ ...opts.webSocketOptions,
72
+ },
73
+ headers: defaultHeaders,
74
+ };
75
+ try {
76
+ if (this.opts.apiKey && this.opts.apiKey.length > 0) {
77
+ const jwt = decodeJwt(this.opts.apiKey);
78
+ // if (jwt.sub && !jwt.sub.match(/^0x[a-fA-F0-9]{40}$/)) {
79
+ if (isEthereumAddress(jwt.sub)) {
80
+ this.userRoomId = `room:${jwt.sub}`;
81
+ this.hasKey = true;
82
+ }
83
+ }
84
+ }
85
+ catch {
86
+ this.hasKey = false;
87
+ this.userRoomId = undefined;
88
+ }
89
+ let backendUrl;
90
+ try {
91
+ backendUrl = new URL(this.opts.backendHost);
92
+ this.opts.backendHost = backendUrl.origin;
93
+ }
94
+ catch (error) {
95
+ throw new Error(`Invalid URL: ${this.opts.backendHost} - ${error.message}`);
96
+ }
97
+ }
98
+ async connectSocket() {
99
+ if (!this.hasKey)
100
+ throw new Error('Unable to subscribe to the server becase a key was not provided');
101
+ if (this.socketClient && this.socketClient.connected) {
102
+ console.log('nvm-backend:: Already connected to the websocket server');
103
+ return;
104
+ }
105
+ try {
106
+ console.log(`nvm-backend:: Connecting to websocket server: ${this.opts.webSocketHost}`);
107
+ console.log(JSON.stringify(this.opts.webSocketOptions));
108
+ this.socketClient = io(this.opts.webSocketHost, this.opts.webSocketOptions);
109
+ await this.socketClient.connect();
110
+ for (let i = 0; i < 5; i++) {
111
+ await sleep(1000);
112
+ if (this.socketClient.connected) {
113
+ break;
114
+ }
115
+ }
116
+ if (!this.socketClient.connected) {
117
+ throw new Error('Unable to connect to the websocket server');
118
+ }
119
+ console.log('is connected: ', this.socketClient.connected);
120
+ }
121
+ catch (error) {
122
+ throw new Error(`Unable to initialize websocket client: ${this.opts.webSocketHost} - ${error.message}`);
123
+ }
124
+ }
125
+ disconnectSocket() {
126
+ if (this.isWebSocketConnected()) {
127
+ this.socketClient.disconnect();
128
+ }
129
+ }
130
+ isWebSocketConnected() {
131
+ if (this.socketClient)
132
+ return this.socketClient.connected;
133
+ return false;
134
+ }
135
+ async _subscribe(_callback, opts) {
136
+ if (!opts.joinAccountRoom && opts.joinAgentRooms.length === 0) {
137
+ throw new Error('No rooms to join in configuration');
138
+ }
139
+ await this.connectSocket();
140
+ // await this.socketClient.emit('subscribe-agent', '')
141
+ await this.socketClient.on('connect', async () => {
142
+ console.log(`nvm-backend:: On:: ${this.socketClient.id} Connected to the server`);
143
+ });
144
+ console.log(`Subscription Options: ${JSON.stringify(opts)}`);
145
+ await this.socketClient.emit('_join-rooms', JSON.stringify(opts));
146
+ // await this.socketClient.on('task-updated', (data: any) => {
147
+ // console.log(`RECEIVED TASK data: ${JSON.stringify(data)}`)
148
+ // _callback(data)
149
+ // })
150
+ opts.subscribeEventTypes.forEach(async (eventType) => {
151
+ await this.socketClient.on(eventType, (data) => {
152
+ // console.log(`RECEIVED STEP data: ${JSON.stringify(data)}`)
153
+ _callback(data);
154
+ });
155
+ });
156
+ }
157
+ async eventHandler(data, _callback, _opts) {
158
+ _callback(data);
159
+ // if (opts.subscribeEventTypes.length > 0) {
160
+ // if (opts.subscribeEventTypes.includes(data.event)) {
161
+ // _callback(data)
162
+ // }
163
+ // } else {
164
+ // _callback(data)
165
+ // }
166
+ }
167
+ async _emitStepEvents(status = AgentExecutionStatus.Pending, dids = []) {
168
+ await this.connectSocket();
169
+ const message = {
170
+ status,
171
+ dids,
172
+ };
173
+ this.socketClient.emit('_emit-steps', JSON.stringify(message));
174
+ }
175
+ disconnect() {
176
+ this.disconnectSocket();
177
+ console.log('nvm-backend:: Disconnected from the server');
178
+ }
179
+ parseUrl(uri, reqOptions) {
180
+ let _host;
181
+ if (reqOptions.sendThroughProxy) {
182
+ if (reqOptions.proxyHost)
183
+ _host = new URL(reqOptions.proxyHost);
184
+ else if (this.opts.proxyHost)
185
+ _host = new URL(this.opts.proxyHost);
186
+ else
187
+ _host = new URL(this.opts.backendHost);
188
+ }
189
+ else
190
+ _host = new URL(this.opts.backendHost);
191
+ return `${_host.origin}${uri}`;
192
+ }
193
+ parseHeaders(additionalHeaders) {
194
+ return {
195
+ ...this.opts.headers,
196
+ ...additionalHeaders,
197
+ };
198
+ }
199
+ setBearerToken(token) {
200
+ this.opts.headers = {
201
+ ...this.opts.headers,
202
+ Authorization: `Bearer ${token}`,
203
+ };
204
+ }
205
+ async get(url, reqOptions = { sendThroughProxy: true }) {
206
+ return axios({
207
+ method: 'GET',
208
+ url: this.parseUrl(url, reqOptions),
209
+ headers: this.parseHeaders(reqOptions.headers || {}),
210
+ }).catch((err) => {
211
+ return { data: err.response.data, status: err.response.status, headers: err.response.headers };
212
+ });
213
+ }
214
+ async post(url, data, reqOptions) {
215
+ console.log('POST URL', this.parseUrl(url, reqOptions));
216
+ console.log('POST DATA', data);
217
+ console.log('POST HEADERS', this.parseHeaders(reqOptions.headers || {}));
218
+ return axios({
219
+ method: 'POST',
220
+ url: this.parseUrl(url, reqOptions),
221
+ headers: this.parseHeaders(reqOptions.headers || {}),
222
+ data: data,
223
+ }).catch((err) => {
224
+ return { data: err.response.data, status: err.response.status, headers: err.response.headers };
225
+ });
226
+ }
227
+ async put(url, data, reqOptions) {
228
+ return axios({
229
+ method: 'PUT',
230
+ url: this.parseUrl(url, reqOptions),
231
+ headers: this.parseHeaders(reqOptions.headers || {}),
232
+ data: data,
233
+ }).catch((err) => {
234
+ return { data: err.response.data, status: err.response.status, headers: err.response.headers };
235
+ });
236
+ }
237
+ async delete(url, data, reqOptions) {
238
+ return axios({
239
+ method: 'DELETE',
240
+ url: this.parseUrl(url, reqOptions),
241
+ headers: this.parseHeaders(reqOptions.headers || {}),
242
+ data: data,
243
+ }).catch((err) => {
244
+ return { data: err.response.data, status: err.response.status, headers: err.response.headers };
245
+ });
246
+ }
247
+ }
248
+ //# sourceMappingURL=nvm-backend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nvm-backend.js","sourceRoot":"","sources":["../../src/api/nvm-backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAChC,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AA0DtD,MAAM,OAAO,kBAAkB;IAA/B;QACE,qBAAgB,GAAY,IAAI,CAAA;QAChC,cAAS,GAAY,SAAS,CAAA;QAC9B,YAAO,GAA+B,EAAE,CAAA;IAC1C,CAAC;CAAA;AAED,MAAM,OAAO,mBAAmB;IAAhC;QACE,oBAAe,GAAY,IAAI,CAAA;QAC/B,mBAAc,GAAa,EAAE,CAAA;QAC7B,wBAAmB,GAAa,CAAC,cAAc,CAAC,CAAA;QAChD,gCAA2B,GAAY,IAAI,CAAA;IAC7C,CAAC;CAAA;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,eAAe,EAAE,IAAI;IACrB,cAAc,EAAE,EAAE;IAClB,mBAAmB,EAAE,CAAC,cAAc,CAAC;IACrC,2BAA2B,EAAE,IAAI;CAClC,CAAA;AAED,MAAM,OAAO,aAAa;IAexB,YAAY,IAAuB;QAZ3B,eAAU,GAAuB,SAAS,CAAA;QAC1C,WAAM,GAAG,KAAK,CAAA;QACd,0B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