@nevermined-io/core-kit 0.2.5 → 0.2.7
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/contracts/FiatPaymentTemplate.d.ts +1 -1
- package/dist/contracts/FiatSettlementCondition.d.ts +1 -1
- package/dist/contracts/FixedPaymentTemplate.d.ts +1 -1
- package/dist/contracts/NFT1155Base.d.ts +4 -4
- package/dist/contracts/NFT1155ExpirableCredits.d.ts +3 -3
- package/dist/contracts/PayAsYouGoTemplate.d.ts +1 -1
- package/dist/nevermined/utils/WebServiceConnector.d.ts +0 -5
- package/dist/nevermined/utils/WebServiceConnector.d.ts.map +1 -1
- package/dist/nevermined/utils/WebServiceConnector.js +2 -79
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/utils/helpers.js +4 -6
- package/package.json +6 -3
|
@@ -5,6 +5,6 @@ import { TxParameters } from '../models/Transactions.js';
|
|
|
5
5
|
import { ContractBase } from './ContractBase.js';
|
|
6
6
|
export declare class FiatPaymentTemplate extends ContractBase {
|
|
7
7
|
static getInstance(config: InstantiableConfig): Promise<FiatPaymentTemplate>;
|
|
8
|
-
order(planId: bigint, creditsReceiver: Address, owner: Account | SmartAccount, numberOfPurchases?: bigint, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | import("viem
|
|
8
|
+
order(planId: bigint, creditsReceiver: Address, owner: Account | SmartAccount, numberOfPurchases?: bigint, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | import("viem").UserOperationReceipt>;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=FiatPaymentTemplate.d.ts.map
|
|
@@ -6,6 +6,6 @@ import { TxParameters } from '../models/Transactions.js';
|
|
|
6
6
|
export declare class FiatSettlementCondition extends ContractBase {
|
|
7
7
|
static getInstance(config: InstantiableConfig): Promise<FiatSettlementCondition>;
|
|
8
8
|
getFiatSettlementRole(): Promise<bigint>;
|
|
9
|
-
order(planId: bigint, planReceiver: Address, owner: Account | SmartAccount, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | import("viem
|
|
9
|
+
order(planId: bigint, planReceiver: Address, owner: Account | SmartAccount, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | import("viem").UserOperationReceipt>;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=FiatSettlementCondition.d.ts.map
|
|
@@ -5,7 +5,7 @@ import { TxParameters } from '../models/Transactions.js';
|
|
|
5
5
|
import { CryptoTemplateBase } from './CryptoTemplateBase.js';
|
|
6
6
|
export declare class FixedPaymentTemplate extends CryptoTemplateBase {
|
|
7
7
|
static getInstance(config: InstantiableConfig): Promise<FixedPaymentTemplate>;
|
|
8
|
-
order(planId: bigint, owner: Account | SmartAccount, creditsReceiver?: Address, numberOfPurchases?: bigint, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | import("viem
|
|
8
|
+
order(planId: bigint, owner: Account | SmartAccount, creditsReceiver?: Address, numberOfPurchases?: bigint, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | import("viem").UserOperationReceipt>;
|
|
9
9
|
simulateOrder(planId: bigint, owner: Account | SmartAccount, tokenAddress: Address, totalAmount: bigint, creditsReceiver?: Address, numberOfPurchases?: bigint, txParams?: TxParameters): Promise<boolean>;
|
|
10
10
|
orderWithApprovals(planId: bigint, totalAmount: bigint, tokenAddress: Address, owner: Account | SmartAccount, creditsReceiver?: Address, numberOfPurchases?: bigint, txParams?: TxParameters): Promise<import("viem").TransactionReceipt>;
|
|
11
11
|
}
|
|
@@ -12,7 +12,7 @@ export declare abstract class NFT1155Base extends ContractBase {
|
|
|
12
12
|
owner: Account | SmartAccount;
|
|
13
13
|
data?: string;
|
|
14
14
|
txParams?: TxParameters;
|
|
15
|
-
}): Promise<import("viem").TransactionReceipt | import("viem
|
|
15
|
+
}): Promise<import("viem").TransactionReceipt | import("viem").UserOperationReceipt>;
|
|
16
16
|
mintBatch({ to, planIds, amounts, data, owner, txParams, }: {
|
|
17
17
|
to: Address[];
|
|
18
18
|
planIds: bigint[];
|
|
@@ -20,7 +20,7 @@ export declare abstract class NFT1155Base extends ContractBase {
|
|
|
20
20
|
owner: Account | SmartAccount;
|
|
21
21
|
data?: string;
|
|
22
22
|
txParams?: TxParameters;
|
|
23
|
-
}): Promise<import("viem").TransactionReceipt | import("viem
|
|
23
|
+
}): Promise<import("viem").TransactionReceipt | import("viem").UserOperationReceipt>;
|
|
24
24
|
simulateCreditsRedemption({ from, planId, amount, keyspace, signature, owner, txParams, }: {
|
|
25
25
|
from: Address;
|
|
26
26
|
planId: bigint;
|
|
@@ -38,13 +38,13 @@ export declare abstract class NFT1155Base extends ContractBase {
|
|
|
38
38
|
signature?: string;
|
|
39
39
|
owner: Account | SmartAccount;
|
|
40
40
|
txParams?: TxParameters;
|
|
41
|
-
}): Promise<import("viem").TransactionReceipt | import("viem
|
|
41
|
+
}): Promise<import("viem").TransactionReceipt | import("viem").UserOperationReceipt>;
|
|
42
42
|
burnBatch({ from, planIds, amounts, owner, txParams, }: {
|
|
43
43
|
from: Address[];
|
|
44
44
|
planIds: bigint[];
|
|
45
45
|
amounts: bigint[];
|
|
46
46
|
owner: Account | SmartAccount;
|
|
47
47
|
txParams?: TxParameters;
|
|
48
|
-
}): Promise<import("viem").TransactionReceipt | import("viem
|
|
48
|
+
}): Promise<import("viem").TransactionReceipt | import("viem").UserOperationReceipt>;
|
|
49
49
|
}
|
|
50
50
|
//# sourceMappingURL=NFT1155Base.d.ts.map
|
|
@@ -13,7 +13,7 @@ export declare class NFT1155ExpirableCredits extends NFT1155Base {
|
|
|
13
13
|
data?: string;
|
|
14
14
|
owner: Account | SmartAccount;
|
|
15
15
|
txParams?: TxParameters;
|
|
16
|
-
}): Promise<import("viem").TransactionReceipt | import("viem
|
|
16
|
+
}): Promise<import("viem").TransactionReceipt | import("viem").UserOperationReceipt>;
|
|
17
17
|
mintBatch({ to, planIds, amounts, secsDuration, data, owner, txParams, }: {
|
|
18
18
|
to: Address[];
|
|
19
19
|
planIds: bigint[];
|
|
@@ -22,7 +22,7 @@ export declare class NFT1155ExpirableCredits extends NFT1155Base {
|
|
|
22
22
|
owner: Account | SmartAccount;
|
|
23
23
|
data?: string;
|
|
24
24
|
txParams?: TxParameters;
|
|
25
|
-
}): Promise<import("viem").TransactionReceipt | import("viem
|
|
25
|
+
}): Promise<import("viem").TransactionReceipt | import("viem").UserOperationReceipt>;
|
|
26
26
|
burn({ from, planId, amount, keyspace, signature, owner, txParams, }: {
|
|
27
27
|
from: Address;
|
|
28
28
|
planId: bigint;
|
|
@@ -31,6 +31,6 @@ export declare class NFT1155ExpirableCredits extends NFT1155Base {
|
|
|
31
31
|
signature?: string;
|
|
32
32
|
owner: Account | SmartAccount;
|
|
33
33
|
txParams?: TxParameters;
|
|
34
|
-
}): Promise<import("viem").TransactionReceipt | import("viem
|
|
34
|
+
}): Promise<import("viem").TransactionReceipt | import("viem").UserOperationReceipt>;
|
|
35
35
|
}
|
|
36
36
|
//# sourceMappingURL=NFT1155ExpirableCredits.d.ts.map
|
|
@@ -5,7 +5,7 @@ import { TxParameters } from '../models/Transactions.js';
|
|
|
5
5
|
import { CryptoTemplateBase } from './CryptoTemplateBase.js';
|
|
6
6
|
export declare class PayAsYouGoTemplate extends CryptoTemplateBase {
|
|
7
7
|
static getInstance(config: InstantiableConfig): Promise<PayAsYouGoTemplate>;
|
|
8
|
-
order(planId: bigint, owner: Account | SmartAccount, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | import("viem
|
|
8
|
+
order(planId: bigint, owner: Account | SmartAccount, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | import("viem").UserOperationReceipt>;
|
|
9
9
|
simulateOrder(planId: bigint, owner: Account | SmartAccount, tokenAddress: Address, totalAmount: bigint, txParams?: TxParameters): Promise<boolean>;
|
|
10
10
|
orderWithApprovals(planId: bigint, totalAmount: bigint, tokenAddress: Address, owner: Account | SmartAccount, txParams?: TxParameters): Promise<import("viem").TransactionReceipt>;
|
|
11
11
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { BodyInit, Response } from 'node-fetch';
|
|
2
|
-
import { ReadStream } from 'fs';
|
|
3
|
-
import { URL } from 'whatwg-url';
|
|
4
1
|
import { InstantiableConfig } from '../../Instantiable.abstract.js';
|
|
5
2
|
/**
|
|
6
3
|
* Provides a common interface to web services.
|
|
@@ -21,8 +18,6 @@ export declare class WebServiceConnector {
|
|
|
21
18
|
[header: string]: string;
|
|
22
19
|
}): Promise<Response>;
|
|
23
20
|
downloadUrl(url: string, headers?: any): Promise<string>;
|
|
24
|
-
uploadMessage(url: string, data: string, encrypt?: boolean): Promise<any>;
|
|
25
|
-
uploadFile(url: string, data: ReadStream, encrypt?: boolean): Promise<any>;
|
|
26
21
|
fetchToken(url: string, grantToken: string, sessionKey?: string, numberTries?: number, apiKeyHash?: string): Promise<Response>;
|
|
27
22
|
private fetch;
|
|
28
23
|
private _sleep;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebServiceConnector.d.ts","sourceRoot":"","sources":["../../../src/nevermined/utils/WebServiceConnector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WebServiceConnector.d.ts","sourceRoot":"","sources":["../../../src/nevermined/utils/WebServiceConnector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAGnE;;GAEG;AACH,qBAAa,mBAAmB;IAG9B,MAAM,EAAE,kBAAkB,CAAA;gBAEd,MAAM,EAAE,kBAAkB;IAM/B,IAAI,CACT,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,QAAQ,EACjB,OAAO,GAAE;QAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;KAAO,GACzC,OAAO,CAAC,QAAQ,CAAC;IAWb,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,GAAE;QAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IASrF,GAAG,CACR,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,QAAQ,EACjB,OAAO,GAAE;QAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;KAAO,GACzC,OAAO,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;IAWP,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAQxD,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"}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
import FormData from 'form-data';
|
|
2
1
|
import { HttpError } from '../../errors/NeverminedErrors.js';
|
|
3
2
|
import { JwtUtils } from '../../nevermined/utils/JwtUtils.js';
|
|
4
|
-
let fetch;
|
|
5
|
-
async function initializeFetch() {
|
|
6
|
-
if (typeof window !== 'undefined') {
|
|
7
|
-
fetch = window.fetch.bind(window);
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
const nodeFetch = await import('node-fetch');
|
|
11
|
-
fetch = nodeFetch.default;
|
|
12
|
-
}
|
|
13
|
-
return fetch;
|
|
14
|
-
}
|
|
15
|
-
fetch = initializeFetch();
|
|
16
3
|
/**
|
|
17
4
|
* Provides a common interface to web services.
|
|
18
5
|
*/
|
|
@@ -62,54 +49,6 @@ export class WebServiceConnector {
|
|
|
62
49
|
},
|
|
63
50
|
});
|
|
64
51
|
}
|
|
65
|
-
// public async downloadFile(
|
|
66
|
-
// url: string,
|
|
67
|
-
// destination?: string,
|
|
68
|
-
// index?: number,
|
|
69
|
-
// headers?: { [key: string]: string },
|
|
70
|
-
// ): Promise<string> {
|
|
71
|
-
// const { response, name } = await this.getFileResponse(url, index, headers)
|
|
72
|
-
// if (destination) {
|
|
73
|
-
// await new Promise((resolve, reject) => {
|
|
74
|
-
// // @ts-ignore
|
|
75
|
-
// fs.mkdirSync(destination, { recursive: true })
|
|
76
|
-
// const fileStream = fs.createWriteStream(`${destination}${name}`)
|
|
77
|
-
// response.body.pipe(fileStream)
|
|
78
|
-
// response.body.on('error', reject)
|
|
79
|
-
// fileStream.on('finish', resolve)
|
|
80
|
-
// fileStream.on('close', resolve)
|
|
81
|
-
// })
|
|
82
|
-
// } else {
|
|
83
|
-
// const buff = await response.arrayBuffer()
|
|
84
|
-
// fileDownload(buff, name)
|
|
85
|
-
// destination = process.cwd()
|
|
86
|
-
// }
|
|
87
|
-
// const d = path.join(destination, name)
|
|
88
|
-
// return d
|
|
89
|
-
// }
|
|
90
|
-
// private async getFileResponse(
|
|
91
|
-
// url: string,
|
|
92
|
-
// index?: number,
|
|
93
|
-
// headers?: { [key: string]: string },
|
|
94
|
-
// ): Promise<{ response: Response; name: string }> {
|
|
95
|
-
// const response = await this.get(url, headers)
|
|
96
|
-
// if (!response.ok) {
|
|
97
|
-
// throw new Error('Response error.')
|
|
98
|
-
// }
|
|
99
|
-
// let name: string
|
|
100
|
-
// try {
|
|
101
|
-
// // @ts-ignore
|
|
102
|
-
// ;[, name] = response.headers.get('content-disposition').match(/attachment;filename=(.+)/)
|
|
103
|
-
// } catch {
|
|
104
|
-
// try {
|
|
105
|
-
// // @ts-ignore
|
|
106
|
-
// name = url.split('/').pop()
|
|
107
|
-
// } catch {
|
|
108
|
-
// name = `file${index}`
|
|
109
|
-
// }
|
|
110
|
-
// }
|
|
111
|
-
// return { response, name }
|
|
112
|
-
// }
|
|
113
52
|
async downloadUrl(url, headers) {
|
|
114
53
|
const response = await this.get(url, headers);
|
|
115
54
|
if (!response.ok) {
|
|
@@ -117,22 +56,6 @@ export class WebServiceConnector {
|
|
|
117
56
|
}
|
|
118
57
|
return await response.text();
|
|
119
58
|
}
|
|
120
|
-
async uploadMessage(url, data, encrypt) {
|
|
121
|
-
const form = new FormData();
|
|
122
|
-
form.append('message', data);
|
|
123
|
-
if (encrypt) {
|
|
124
|
-
form.append('encrypt', 'true');
|
|
125
|
-
}
|
|
126
|
-
return this.fetch(url, { method: 'POST', body: form });
|
|
127
|
-
}
|
|
128
|
-
async uploadFile(url, data, encrypt) {
|
|
129
|
-
const form = new FormData();
|
|
130
|
-
form.append('file', data);
|
|
131
|
-
if (encrypt) {
|
|
132
|
-
form.append('encrypt', 'true');
|
|
133
|
-
}
|
|
134
|
-
return this.fetch(url, { method: 'POST', body: form });
|
|
135
|
-
}
|
|
136
59
|
async fetchToken(url, grantToken, sessionKey, numberTries = 1, apiKeyHash) {
|
|
137
60
|
const bodyParams = new URLSearchParams({
|
|
138
61
|
client_assertion_type: JwtUtils.CLIENT_ASSERTION_TYPE,
|
|
@@ -144,7 +67,7 @@ export class WebServiceConnector {
|
|
|
144
67
|
if (apiKeyHash) {
|
|
145
68
|
bodyParams.append('nvm_key_hash', apiKeyHash);
|
|
146
69
|
}
|
|
147
|
-
return await fetch(url, {
|
|
70
|
+
return await this.fetch(url, {
|
|
148
71
|
method: 'POST',
|
|
149
72
|
body: bodyParams.toString(),
|
|
150
73
|
headers: {
|
|
@@ -156,7 +79,7 @@ export class WebServiceConnector {
|
|
|
156
79
|
let counterTries = 1;
|
|
157
80
|
let result;
|
|
158
81
|
while (counterTries <= numberTries) {
|
|
159
|
-
result = await fetch(url, opts);
|
|
82
|
+
result = await fetch(url.toString(), opts);
|
|
160
83
|
if (result.ok)
|
|
161
84
|
return result;
|
|
162
85
|
counterTries++;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils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BAiB9E;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,UAoB1C;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,CAyB1D;AAED,wBAAsB,cAAc,CAAC,gBAAgB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,GAAG,mBAqBtF"}
|
package/dist/utils/helpers.js
CHANGED
|
@@ -106,14 +106,12 @@ export async function encryptMessage(message, receiverPublicKey) {
|
|
|
106
106
|
const messageBuffer = Buffer.from(message);
|
|
107
107
|
try {
|
|
108
108
|
const ecies = await encrypt(publicKeyBuffer, messageBuffer);
|
|
109
|
-
// Handle both cases: when encrypt returns a Buffer or an ECIES object
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
// This might be the case with some versions of eciesjs
|
|
113
|
-
return ecies.toString('base64');
|
|
109
|
+
// Handle both cases: when encrypt returns a Buffer/Uint8Array or an ECIES object
|
|
110
|
+
if (ecies instanceof Uint8Array) {
|
|
111
|
+
return Buffer.from(ecies).toString('base64');
|
|
114
112
|
}
|
|
115
113
|
else {
|
|
116
|
-
//
|
|
114
|
+
// Legacy eciesjs versions returned an ECIES object
|
|
117
115
|
return serializeECIES(ecies);
|
|
118
116
|
}
|
|
119
117
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nevermined-io/core-kit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
"default": "./dist/index.js"
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@nevermined-io/commons": "workspace:*"
|
|
22
|
+
},
|
|
20
23
|
"include": [
|
|
21
24
|
"./artifacts"
|
|
22
25
|
],
|
|
@@ -29,7 +32,7 @@
|
|
|
29
32
|
"e2e": {
|
|
30
33
|
"executor": "nx:run-commands",
|
|
31
34
|
"options": {
|
|
32
|
-
"command": "tsx ../../node_modules
|
|
35
|
+
"command": "tsx ../../node_modules/mocha/bin/mocha.js --config ./tests/integration/.mocharc.json",
|
|
33
36
|
"cwd": "packages/core-kit"
|
|
34
37
|
},
|
|
35
38
|
"dependsOn": [
|
|
@@ -45,7 +48,7 @@
|
|
|
45
48
|
"e2e:external": {
|
|
46
49
|
"executor": "nx:run-commands",
|
|
47
50
|
"options": {
|
|
48
|
-
"command": "tsx ../../node_modules
|
|
51
|
+
"command": "tsx ../../node_modules/mocha/bin/mocha.js --config ./tests/external/.mocharc.json",
|
|
49
52
|
"cwd": "packages/core-kit"
|
|
50
53
|
},
|
|
51
54
|
"dependsOn": [
|