@nevermined-io/core-kit 0.0.2-rc22 → 0.0.4-rc0

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.
Files changed (43) hide show
  1. package/dist/artifacts/generated.d.ts +166 -32
  2. package/dist/artifacts/generated.d.ts.map +1 -1
  3. package/dist/artifacts/generated.js +124 -16
  4. package/dist/contracts/AssetRegistry.d.ts +4 -0
  5. package/dist/contracts/AssetRegistry.d.ts.map +1 -1
  6. package/dist/contracts/AssetRegistry.js +13 -1
  7. package/dist/contracts/ContractBase.d.ts +9 -0
  8. package/dist/contracts/ContractBase.d.ts.map +1 -1
  9. package/dist/contracts/ContractBase.js +102 -9
  10. package/dist/contracts/FixedPaymentTemplate.d.ts +4 -1
  11. package/dist/contracts/FixedPaymentTemplate.d.ts.map +1 -1
  12. package/dist/contracts/FixedPaymentTemplate.js +46 -1
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +0 -3
  15. package/dist/models/AgentAccessToken.d.ts +123 -0
  16. package/dist/models/AgentAccessToken.d.ts.map +1 -0
  17. package/dist/models/AgentAccessToken.js +164 -0
  18. package/dist/models/NeverminedOptions.d.ts +1 -14
  19. package/dist/models/NeverminedOptions.d.ts.map +1 -1
  20. package/dist/models/NeverminedOptions.js +1 -19
  21. package/dist/models/index.d.ts +1 -0
  22. package/dist/models/index.d.ts.map +1 -1
  23. package/dist/models/index.js +1 -0
  24. package/dist/nevermined/api/PaymentsApi.d.ts +6 -1
  25. package/dist/nevermined/api/PaymentsApi.d.ts.map +1 -1
  26. package/dist/nevermined/api/PaymentsApi.js +50 -32
  27. package/dist/nevermined/utils/AgentUtils.d.ts +8 -0
  28. package/dist/nevermined/utils/AgentUtils.d.ts.map +1 -0
  29. package/dist/nevermined/utils/AgentUtils.js +42 -0
  30. package/dist/nevermined/utils/JwtUtils.d.ts.map +1 -1
  31. package/dist/nevermined/utils/JwtUtils.js +7 -0
  32. package/dist/nevermined/utils/WebServiceConnector.d.ts +1 -1
  33. package/dist/nevermined/utils/WebServiceConnector.d.ts.map +1 -1
  34. package/dist/nevermined/utils/WebServiceConnector.js +4 -1
  35. package/dist/nevermined/utils/ZeroDevPolicies.d.ts.map +1 -1
  36. package/dist/nevermined/utils/ZeroDevPolicies.js +4 -1
  37. package/dist/nevermined/utils/index.d.ts +1 -0
  38. package/dist/nevermined/utils/index.d.ts.map +1 -1
  39. package/dist/nevermined/utils/index.js +1 -0
  40. package/dist/services/Api.d.ts +1 -1
  41. package/dist/services/Api.d.ts.map +1 -1
  42. package/dist/services/Api.js +3 -3
  43. package/package.json +1 -1
@@ -0,0 +1,123 @@
1
+ import { JWTPayload } from 'jose';
2
+ import { Account } from 'viem';
3
+ import { SmartAccount } from 'viem/account-abstraction';
4
+ import { SignatureUtils } from '../nevermined/utils/SignatureUtils.js';
5
+ /**
6
+ * The access to remote agents is granted through an authorization token.
7
+ * This token is generated using the AgentAccessToken JWT structure.
8
+ * AgentAccessToken:
9
+ * authToken: JWTAuthTokenParams
10
+ * proof: JWTRedemptionProofParams
11
+ */
12
+ export interface JWTAuthTokenParams {
13
+ /**
14
+ * The agent identifier related with the authorization token.
15
+ */
16
+ agentId: string;
17
+ /**
18
+ * The plan identifier related with the authorization token.
19
+ */
20
+ planId: string;
21
+ /**
22
+ * The public address of the account the key is issued for.
23
+ */
24
+ sub: `0x${string}`;
25
+ /**
26
+ * The public address of the account issuing the key.
27
+ */
28
+ iss?: `0x${string}`;
29
+ /**
30
+ * The chain id of the network the token is valid for. If zero the key is not having any network limitation
31
+ */
32
+ aud?: string;
33
+ /**
34
+ * JWT Expiration Time
35
+ *
36
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.4 RFC7519#section-4.1.4}
37
+ */
38
+ exp?: number;
39
+ /**
40
+ * JWT Issued At
41
+ *
42
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.6 RFC7519#section-4.1.6}
43
+ */
44
+ iat?: number;
45
+ [key: string]: unknown;
46
+ }
47
+ export interface JWTRedemptionProofParams {
48
+ keyspace: string;
49
+ nonce: string;
50
+ planIds: string[];
51
+ }
52
+ export declare class AgentAccessToken implements JWTPayload {
53
+ /**
54
+ * The version of the access token
55
+ */
56
+ ver?: string;
57
+ /**
58
+ * The authorization token used to query the agent.
59
+ * This token is validated by the agent or proxy to ensure the request is authorized
60
+ * {@see {@link AgentAuthTokenParams}}
61
+ */
62
+ authToken?: string;
63
+ /**
64
+ * The proof generated by the subscriber (sub) to prove the request to query the agent
65
+ * {@see {@link JWTRedemptionProofParams}
66
+ */
67
+ proof?: string;
68
+ iss?: string | undefined;
69
+ sub?: string | undefined;
70
+ aud?: string | string[] | undefined;
71
+ exp?: number;
72
+ iat?: number;
73
+ [propName: string]: unknown;
74
+ _signatureUtils: SignatureUtils;
75
+ _issuerAccount: Account | SmartAccount;
76
+ private constructor();
77
+ /**
78
+ * It generates a new serialized and encrypted NvmApiKey including the ZeroDev session key and the Marketplace auth token.
79
+ * The string representing this key can be used to authenticate against the Nevermined API.
80
+ * @param signatureUtils The SignatureUtils instance
81
+ * @param issuerAccount The account issuing the key
82
+
83
+ */
84
+ static generate(signatureUtils: SignatureUtils, issuerAccount: Account | SmartAccount, agentId: string, planId: string | bigint, subscriberAddress: `0x${string}`, expirationTime?: number | string, version?: string): Promise<AgentAccessToken>;
85
+ setRedemptionProof(keyspace: string, nonce: string): Promise<this>;
86
+ decodeAuthToken(): JWTAuthTokenParams;
87
+ /**
88
+ * It serializes the NVM Api Key into a string
89
+ * @returns a string representing the NVM API Key
90
+ */
91
+ serialize(): string;
92
+ /**
93
+ * It serializes the NVM Api Key into a string
94
+ * @returns a string representing the NVM API Key
95
+ */
96
+ toString(): string;
97
+ /**
98
+ * It generates a signed JWT from the NvmApiKey
99
+ * @param signatureUtils The SignatureUtils instance
100
+ * @param issuerAccount The account issuing the key
101
+ * @returns the string in JWT format represeting the NvmApiKey
102
+ */
103
+ toJWT(): Promise<string>;
104
+ static fromJWT(jwtString: string, signatureUtils: SignatureUtils, issuerAddress: Account | SmartAccount): AgentAccessToken;
105
+ /**
106
+ * It decodes a string JWT into a JWTPayload
107
+ * @param str jwt string
108
+ * @returns the JWTPayload
109
+ */
110
+ static decodeJWT(str: string): JWTPayload;
111
+ /**
112
+ * It generates the hash of the NvmApiKey
113
+ * @returns a string representing the hash of the NvmApiKey
114
+ */
115
+ hash(): string;
116
+ /**
117
+ * Given a serialized string, it generates the hash
118
+ * @param serialized the serialized string
119
+ * @returns the hash
120
+ */
121
+ static hash(serialized: string): string;
122
+ }
123
+ //# sourceMappingURL=AgentAccessToken.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentAccessToken.d.ts","sourceRoot":"","sources":["../../src/models/AgentAccessToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,MAAM,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAGvD,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAA;AAEtE;;;;;;GAMG;AAEH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,GAAG,EAAE,KAAK,MAAM,EAAE,CAAA;IAClB;;OAEG;IACH,GAAG,CAAC,EAAE,KAAK,MAAM,EAAE,CAAA;IACnB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,OAA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S,CAAC,GAAG,EAAE,MAAM;IAInC;;;OAGG;IACI,IAAI;IAIX;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM;CAG/B"}
@@ -0,0 +1,164 @@
1
+ import { decodeJwt } from 'jose';
2
+ import { getChecksumAddress } from '../nevermined/utils/BlockchainViemUtils.js';
3
+ import { EthSignJWT } from '../nevermined/utils/JwtUtils.js';
4
+ import { SignatureUtils } from '../nevermined/utils/SignatureUtils.js';
5
+ export class AgentAccessToken {
6
+ /**
7
+ * The version of the access token
8
+ */
9
+ ver;
10
+ /**
11
+ * The authorization token used to query the agent.
12
+ * This token is validated by the agent or proxy to ensure the request is authorized
13
+ * {@see {@link AgentAuthTokenParams}}
14
+ */
15
+ authToken;
16
+ /**
17
+ * The proof generated by the subscriber (sub) to prove the request to query the agent
18
+ * {@see {@link JWTRedemptionProofParams}
19
+ */
20
+ proof;
21
+ iss;
22
+ sub;
23
+ aud;
24
+ exp;
25
+ iat;
26
+ _signatureUtils;
27
+ _issuerAccount;
28
+ constructor(signatureUtils, issuerAccount) {
29
+ this.ver = '1';
30
+ this._signatureUtils = signatureUtils;
31
+ this._issuerAccount = issuerAccount;
32
+ }
33
+ /**
34
+ * It generates a new serialized and encrypted NvmApiKey including the ZeroDev session key and the Marketplace auth token.
35
+ * The string representing this key can be used to authenticate against the Nevermined API.
36
+ * @param signatureUtils The SignatureUtils instance
37
+ * @param issuerAccount The account issuing the key
38
+
39
+ */
40
+ static async generate(signatureUtils, issuerAccount, agentId, planId, subscriberAddress, expirationTime = '1y', version = '1') {
41
+ const issuerAddress = getChecksumAddress(issuerAccount.address);
42
+ const chainId = signatureUtils.client.chain?.id || 0;
43
+ const sub = getChecksumAddress(subscriberAddress);
44
+ const jwtAuth = {
45
+ iss: issuerAddress,
46
+ aud: chainId.toString(),
47
+ sub,
48
+ agentId,
49
+ planId: typeof planId === 'bigint' ? planId.toString() : planId,
50
+ };
51
+ const signedJWTAuth = await new EthSignJWT(jwtAuth)
52
+ .setProtectedHeader({ alg: 'ES256K' })
53
+ .setIssuedAt()
54
+ .setExpirationTime(expirationTime)
55
+ .ethSign(signatureUtils, issuerAccount);
56
+ // const jwtAccessToken: JWTAgentAccessToken = {
57
+ // ver: version,
58
+ // authToken: signedJWTAuth,
59
+ // proof: undefined, // This can be set later when the proof is generated
60
+ // }
61
+ const agentAccessToken = new AgentAccessToken(signatureUtils, issuerAccount);
62
+ agentAccessToken.ver = version;
63
+ agentAccessToken.authToken = signedJWTAuth;
64
+ agentAccessToken.proof = undefined; // This can be set later when the proof is generated
65
+ return agentAccessToken;
66
+ }
67
+ async setRedemptionProof(keyspace, nonce) {
68
+ const jwtPayload = decodeJwt(this.authToken);
69
+ const proofParams = {
70
+ keyspace,
71
+ nonce,
72
+ planIds: [String(jwtPayload.planId)],
73
+ };
74
+ this.proof = JSON.stringify(proofParams);
75
+ return this;
76
+ }
77
+ decodeAuthToken() {
78
+ if (!this.authToken) {
79
+ throw new Error('Auth token is not set');
80
+ }
81
+ const jwt = decodeJwt(this.authToken);
82
+ return {
83
+ agentId: jwt.agentId,
84
+ planId: jwt.planId,
85
+ sub: jwt.sub,
86
+ iss: jwt.iss,
87
+ aud: jwt.aud,
88
+ exp: jwt.exp,
89
+ iat: jwt.iat,
90
+ };
91
+ }
92
+ /**
93
+ * It serializes the NVM Api Key into a string
94
+ * @returns a string representing the NVM API Key
95
+ */
96
+ serialize() {
97
+ return this.toString();
98
+ }
99
+ /**
100
+ * It serializes the NVM Api Key into a string
101
+ * @returns a string representing the NVM API Key
102
+ */
103
+ toString() {
104
+ const params = {};
105
+ Object.keys(this)
106
+ .filter((val) => val !== undefined)
107
+ .forEach((key) => {
108
+ if (!key.startsWith('_'))
109
+ params[key] = this[key];
110
+ });
111
+ return JSON.stringify(params);
112
+ }
113
+ /**
114
+ * It generates a signed JWT from the NvmApiKey
115
+ * @param signatureUtils The SignatureUtils instance
116
+ * @param issuerAccount The account issuing the key
117
+ * @returns the string in JWT format represeting the NvmApiKey
118
+ */
119
+ async toJWT() {
120
+ const params = {};
121
+ Object.keys(this)
122
+ .filter((val) => val !== undefined)
123
+ .forEach((key) => {
124
+ if (!key.startsWith('_'))
125
+ params[key] = this[key];
126
+ });
127
+ const jwt = new EthSignJWT(params).setProtectedHeader({ alg: 'ES256K' });
128
+ return jwt.ethSign(this._signatureUtils, this._issuerAccount);
129
+ }
130
+ static fromJWT(jwtString, signatureUtils, issuerAddress) {
131
+ const jwt = AgentAccessToken.decodeJWT(jwtString);
132
+ const agentAccessToken = new AgentAccessToken(signatureUtils, issuerAddress);
133
+ Object.keys(jwt)
134
+ .filter((val) => val !== undefined)
135
+ .forEach((key) => {
136
+ if (!key.startsWith('_'))
137
+ agentAccessToken[key] = jwt[key];
138
+ });
139
+ return agentAccessToken;
140
+ }
141
+ /**
142
+ * It decodes a string JWT into a JWTPayload
143
+ * @param str jwt string
144
+ * @returns the JWTPayload
145
+ */
146
+ static decodeJWT(str) {
147
+ return decodeJwt(str);
148
+ }
149
+ /**
150
+ * It generates the hash of the NvmApiKey
151
+ * @returns a string representing the hash of the NvmApiKey
152
+ */
153
+ hash() {
154
+ return SignatureUtils.hash(this.serialize());
155
+ }
156
+ /**
157
+ * Given a serialized string, it generates the hash
158
+ * @param serialized the serialized string
159
+ * @returns the hash
160
+ */
161
+ static hash(serialized) {
162
+ return SignatureUtils.hash(serialized);
163
+ }
164
+ }
@@ -12,20 +12,11 @@ export declare class NeverminedOptions {
12
12
  */
13
13
  appUrl?: string;
14
14
  backendUrl?: string;
15
- /**
16
- * Web3 Provider.
17
- */
15
+ agentsProxy?: string;
18
16
  /**
19
17
  * Log level.
20
18
  */
21
19
  logLevel: string;
22
- /**
23
- * Gas multiplier for the fees.
24
- * Can be used to speed up the transactions.
25
- */
26
- /**
27
- * Enpoint for the graph-node http query
28
- */
29
20
  /**
30
21
  * The folder where the nevermined contract artifacts are located.
31
22
  */
@@ -39,10 +30,6 @@ export declare class NeverminedOptions {
39
30
  ipfsGateway?: string;
40
31
  ipfsProjectId?: string;
41
32
  ipfsProjectSecret?: string;
42
- /**
43
- * Use a gas station to calculate transaction fees
44
- */
45
- gasStationUri?: string;
46
33
  /**
47
34
  * ZeroDev project id
48
35
  */
@@ -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;IAI1B;;OAEG;IAGH;;OAEG;IACI,QAAQ,SAAS;IAGxB;;;OAGG;IAGH;;OAEG;IAGH;;OAEG;IACI,eAAe,CAAC,EAAE,MAAM,CAAA;IAExB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;IAE3B;;;;OAIG;IACI,WAAW,CAAC,EAAE,MAAM,CAAoB;IAExC,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAEjC;;OAEG;IACI,aAAa,CAAC,EAAE,MAAM,CAAA;IAE7B;;OAEG;IACI,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEhC;;OAEG;IACI,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACjC"}
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;IAExB;;OAEG;IACI,eAAe,CAAC,EAAE,MAAM,CAAA;IAExB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;IAE3B;;;;OAIG;IACI,WAAW,CAAC,EAAE,MAAM,CAAoB;IAExC,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAEjC;;OAEG;IACI,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEhC;;OAEG;IACI,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACjC"}
@@ -11,25 +11,11 @@ export class NeverminedOptions {
11
11
  */
12
12
  appUrl;
13
13
  backendUrl;
14
- // public backendAuthToken?: string
15
- /**
16
- * Web3 Provider.
17
- */
18
- // public web3Provider?: any
14
+ agentsProxy;
19
15
  /**
20
16
  * Log level.
21
17
  */
22
18
  logLevel = 'info';
23
- // public verbose?: boolean | LogLevel
24
- /**
25
- * Gas multiplier for the fees.
26
- * Can be used to speed up the transactions.
27
- */
28
- // public gasMultiplier?: number
29
- /**
30
- * Enpoint for the graph-node http query
31
- */
32
- // public graphHttpUri?: string
33
19
  /**
34
20
  * The folder where the nevermined contract artifacts are located.
35
21
  */
@@ -43,10 +29,6 @@ export class NeverminedOptions {
43
29
  ipfsGateway = 'https://ipfs.io';
44
30
  ipfsProjectId;
45
31
  ipfsProjectSecret;
46
- /**
47
- * Use a gas station to calculate transaction fees
48
- */
49
- gasStationUri;
50
32
  /**
51
33
  * ZeroDev project id
52
34
  */
@@ -2,4 +2,5 @@ export * from './Logger.js';
2
2
  export * from './NeverminedOptions.js';
3
3
  export * from './NvmApiKey.js';
4
4
  export * from './Transactions.js';
5
+ export * from './AgentAccessToken.js';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,wBAAwB,CAAA;AACtC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,wBAAwB,CAAA;AACtC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,uBAAuB,CAAA"}
@@ -2,3 +2,4 @@ export * from './Logger.js';
2
2
  export * from './NeverminedOptions.js';
3
3
  export * from './NvmApiKey.js';
4
4
  export * from './Transactions.js';
5
+ export * from './AgentAccessToken.js';
@@ -9,8 +9,13 @@ export declare class PaymentsApi extends Instantiable {
9
9
  * @returns {@link PaymentsApi}
10
10
  */
11
11
  constructor(config: InstantiableConfig);
12
- private getTokenContract;
13
12
  getERC20Balance(userAddress: Address, tokenAddress: Address): Promise<bigint>;
13
+ getPlanFees(planId: bigint): Promise<{
14
+ cryptoFeeRate: bigint;
15
+ fiatFeeRate: bigint;
16
+ feeDenominator: bigint;
17
+ totalAmount: bigint;
18
+ }>;
14
19
  orderFiatPayment(planId: bigint, planReceiver: Address, from: Account | SmartAccount): Promise<OrderResult>;
15
20
  orderCryptoPayment(planId: bigint, plan: Plan, from: Account | SmartAccount): Promise<OrderResult>;
16
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PaymentsApi.d.ts","sourceRoot":"","sources":["../../../src/nevermined/api/PaymentsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,OAAO,EAAE,OAAO,EAAsC,MAAM,MAAM,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,EAAE,WAAW,EAAE,IAAI,EAA8B,MAAM,uBAAuB,CAAA;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O,GAAG,YAAY,GAC3B,OAAO,CAAC,WAAW,CAAC;IA0BV,kBAAkB,CAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,OAAO,GAAG,YAAY,GAC3B,OAAO,CAAC,WAAW,CAAC;CAmFxB"}
@@ -1,12 +1,11 @@
1
- import { getContract, parseAbi, zeroAddress } from 'viem';
1
+ import { isAddress, parseAbi, zeroAddress } from 'viem';
2
2
  import { Instantiable } from '../../Instantiable.abstract.js';
3
- import { lockPaymentConditionAddress } from '../../artifacts/generated.js';
4
- import { createKernelClient } from '../utils/BlockchainViemUtils.js';
5
3
  import { PlanTransactionPaymentType } from '@nvm-monorepo/commons';
6
- const TOKEN_APPROVE_ABI = parseAbi([
7
- 'function approve(address spender, uint256 amount) external returns (bool)',
8
- ]);
4
+ import { NotEnoughBalance } from '../../errors/NeverminedErrors.js';
9
5
  const TOKEN_BALANCE_ABI = parseAbi(['function balanceOf(address) view returns (uint256)']);
6
+ const GET_FEE_RATES_ABI = parseAbi([
7
+ 'function getFeeRates() view returns (uint256, uint256, uint256)',
8
+ ]);
10
9
  export class PaymentsApi extends Instantiable {
11
10
  /**
12
11
  * Creates a new PaymentsApi
@@ -17,23 +16,6 @@ export class PaymentsApi extends Instantiable {
17
16
  super();
18
17
  this.setInstanceConfig(config);
19
18
  }
20
- async getTokenContract(token, from) {
21
- if (from.type === 'smart') {
22
- const kernelClient = await createKernelClient(from, this.config.chainId, this.config.zeroDevProjectId, this.nevermined.contracts.assetRegistry.publicClient);
23
- return getContract({
24
- address: token,
25
- abi: TOKEN_APPROVE_ABI,
26
- client: kernelClient,
27
- });
28
- }
29
- else {
30
- return getContract({
31
- address: token,
32
- abi: TOKEN_APPROVE_ABI,
33
- client: this.walletClient,
34
- });
35
- }
36
- }
37
19
  async getERC20Balance(userAddress, tokenAddress) {
38
20
  try {
39
21
  return this.client.public.readContract({
@@ -48,9 +30,42 @@ export class PaymentsApi extends Instantiable {
48
30
  }
49
31
  return 0n;
50
32
  }
33
+ async getPlanFees(planId) {
34
+ try {
35
+ const plan = await this.nevermined.contracts.assetRegistry.getPlan(planId);
36
+ let feeControllerAddress;
37
+ if (plan.price.feeController &&
38
+ isAddress(plan.price.feeController) &&
39
+ plan.price.feeController !== zeroAddress) {
40
+ feeControllerAddress = plan.price.feeController;
41
+ }
42
+ else {
43
+ feeControllerAddress = await this.nevermined.contracts.nvmConfig.getDefaultFeeController();
44
+ }
45
+ const result = await this.client.public.readContract({
46
+ address: feeControllerAddress,
47
+ abi: GET_FEE_RATES_ABI,
48
+ functionName: 'getFeeRates',
49
+ args: [],
50
+ });
51
+ const totalAmount = plan.price.amounts.reduce((a, b) => a + b, 0n);
52
+ return {
53
+ cryptoFeeRate: result[0],
54
+ fiatFeeRate: result[1],
55
+ feeDenominator: result[2],
56
+ totalAmount,
57
+ };
58
+ }
59
+ catch (error) {
60
+ this.logger.error(`Error fetching plan fee for planId ${planId}:`, error);
61
+ throw error;
62
+ }
63
+ }
51
64
  async orderFiatPayment(planId, planReceiver, from) {
52
65
  const plan = await this.nevermined.contracts.assetRegistry.getPlan(planId);
53
66
  const totalAmount = plan.price.amounts.reduce((a, b) => a + b, 0n);
67
+ // console.log(`Ordering fiat payment for planId ${planId} to ${planReceiver} from account ${from.address} `)
68
+ this.logger.info(`Ordering fiat payment for planId ${planId} to ${planReceiver} from account ${from.address} `);
54
69
  const txHash = await this.nevermined.contracts.fiatPaymentTemplate.createAgreement(planId, planReceiver, from);
55
70
  const txReceipt = await this.nevermined.contracts.assetRegistry.getTransactionReceipt(txHash);
56
71
  return {
@@ -69,20 +84,23 @@ export class PaymentsApi extends Instantiable {
69
84
  const tokenAddress = plan.price.tokenAddress;
70
85
  const totalAmount = plan.price.amounts.reduce((a, b) => a + b, 0n);
71
86
  this.logger.debug(`Ordering ${tokenAddress} ${totalAmount}`);
87
+ let txHash;
72
88
  if (tokenAddress && tokenAddress !== zeroAddress) {
89
+ this.logger.debug(`Processing ERC20 payment...`);
73
90
  // ERC20 token payment
74
91
  if (totalAmount > 0n) {
75
92
  const erc20Balance = await this.getERC20Balance(from.address, tokenAddress);
93
+ this.logger.debug(`ERC20 balance for ${from.address} in ${tokenAddress}: balance = ${erc20Balance} - total amount = ${totalAmount}`);
76
94
  if (erc20Balance < totalAmount) {
77
- throw new Error(`Insufficient balance (${erc20Balance} < ${totalAmount}) for ERC20 ${tokenAddress}`);
95
+ throw new NotEnoughBalance(`Insufficient balance (${erc20Balance} < ${totalAmount}) for ERC20 ${tokenAddress}`);
78
96
  }
79
- const tokenContract = await this.getTokenContract(tokenAddress, from);
80
- // Approve lockPayment contract
81
- const hash = await tokenContract.write.approve([lockPaymentConditionAddress, totalAmount]);
82
- const receipt = await this.nevermined.contracts.fixedPaymentTemplate.publicClient.waitForTransactionReceipt({ hash });
83
- this.logger.debug('Approving token transfer to lockPayment contract', receipt);
97
+ txHash =
98
+ await this.nevermined.contracts.fixedPaymentTemplate.createAgreementWithApprovals(planId, totalAmount, tokenAddress, from);
99
+ this.logger.debug(`Token approved + Agreement Created: ${txHash}`);
100
+ }
101
+ else {
102
+ txHash = await this.nevermined.contracts.fixedPaymentTemplate.createAgreement(planId, from);
84
103
  }
85
- const txHash = await this.nevermined.contracts.fixedPaymentTemplate.createAgreement(planId, from);
86
104
  const txReceipt = await this.nevermined.contracts.assetRegistry.getTransactionReceipt(txHash);
87
105
  return {
88
106
  txHash: txReceipt.transactionHash,
@@ -99,9 +117,9 @@ export class PaymentsApi extends Instantiable {
99
117
  // Native token payment
100
118
  const nativeTokenBalance = await this.client.public.getBalance({ address: from.address });
101
119
  if (nativeTokenBalance < totalAmount) {
102
- throw new Error(`Insufficient balance (${nativeTokenBalance} < ${totalAmount}) for native token payment`);
120
+ throw new NotEnoughBalance(`Insufficient balance (${nativeTokenBalance} < ${totalAmount}) for native token payment`);
103
121
  }
104
- const txHash = await this.nevermined.contracts.fixedPaymentTemplate.createAgreement(planId, from, {
122
+ txHash = await this.nevermined.contracts.fixedPaymentTemplate.createAgreement(planId, from, {
105
123
  value: totalAmount,
106
124
  });
107
125
  const txReceipt = await this.nevermined.contracts.assetRegistry.getTransactionReceipt(txHash);
@@ -0,0 +1,8 @@
1
+ import { ApiEndpoint } from '@nvm-monorepo/commons';
2
+ export declare function isEndpointRequestedIncluded(requestEndpoint: string, requestedHTTPVerb: string, agentEndpoints: ApiEndpoint[], agentOpenEndpoints?: string[]): {
3
+ matches: boolean;
4
+ urlMatching?: URL;
5
+ verbMatching?: string;
6
+ };
7
+ export declare function areUrlsEqualIgnoringQuery(url1: URL, url2: URL): boolean;
8
+ //# sourceMappingURL=AgentUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentUtils.d.ts","sourceRoot":"","sources":["../../../src/nevermined/utils/AgentUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAGnD,wBAAgB,2BAA2B,CACzC,eAAe,EAAE,MAAM,EACvB,iBAAiB,EAAE,MAAM,EACzB,cAAc,EAAE,WAAW,EAAE,EAC7B,kBAAkB,GAAE,MAAM,EAAO,GAChC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,GAAG,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAoChE;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAOvE"}
@@ -0,0 +1,42 @@
1
+ import { match } from 'path-to-regexp';
2
+ export function isEndpointRequestedIncluded(requestEndpoint, requestedHTTPVerb, agentEndpoints, agentOpenEndpoints = []) {
3
+ try {
4
+ let matches = false;
5
+ requestedHTTPVerb = requestedHTTPVerb.toLowerCase();
6
+ let urlMatching, verbMatching;
7
+ const requestedUrl = new URL(requestEndpoint);
8
+ // Is the endpoint an open endpoint?
9
+ agentOpenEndpoints.forEach((openEndpoint) => {
10
+ const agentUrl = new URL(openEndpoint);
11
+ if (areUrlsEqualIgnoringQuery(agentUrl, requestedUrl)) {
12
+ urlMatching = new URL(openEndpoint);
13
+ matches = true;
14
+ }
15
+ });
16
+ if (matches)
17
+ return { matches: true, urlMatching };
18
+ // check if the endpoint/verb is part of the list
19
+ agentEndpoints.forEach((ep) => {
20
+ const [verb, url] = Object.entries(ep)[0];
21
+ const _url = new URL(url);
22
+ const fn = match(_url.pathname, { decode: decodeURIComponent });
23
+ if (fn(requestedUrl.pathname) && (verb.toLowerCase() === requestedHTTPVerb || verb === '*')) {
24
+ matches = true;
25
+ urlMatching = _url;
26
+ verbMatching = verb;
27
+ return;
28
+ }
29
+ });
30
+ return { matches, urlMatching, verbMatching };
31
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
+ }
33
+ catch (error) {
34
+ return { matches: false };
35
+ }
36
+ }
37
+ export function areUrlsEqualIgnoringQuery(url1, url2) {
38
+ return (url1.protocol === url2.protocol &&
39
+ url1.hostname === url2.hostname &&
40
+ url1.port === url2.port &&
41
+ url1.pathname === url2.pathname);
42
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"JwtUtils.d.ts","sourceRoot":"","sources":["../../../src/nevermined/utils/JwtUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,KAAK,mBAAmB,EAAE,OAAO,EAAwB,MAAM,MAAM,CAAA;AAC9E,OAAO,EAAE,KAAK,OAAO,EAAmD,MAAM,MAAM,CAAA;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAGjF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,qBAAa,UAAW,SAAQ,OAAO;IACrC,eAAe,EAAE,mBAAmB,GAAG,SAAS,CAAA;IAEvC,kBAAkB,CAAC,eAAe,EAAE,mBAAmB;IAK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kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAGjF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,qBAAa,UAAW,SAAQ,OAAO;IACrC,eAAe,EAAE,mBAAmB,GAAG,SAAS,CAAA;IAEvC,kBAAkB,CAAC,eAAe,EAAE,mBAAmB;IAKnD,OAAO,CAClB,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO,GAAG,YAAY,EAC/B,UAAU,CAAC,EAAE,UAAU,GACtB,OAAO,CAAC,MAAM,CAAC;WAoDE,QAAQ,CAC1B,IAAI,EAAE,MAAM,GAAG,UAAU,EACzB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAY9B,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,MAAM;CAUf;AAED,qBAAa,QAAS,SAAQ,YAAY;IACxC,MAAM,CAAC,qBAAqB,SAA2D;IAGvF,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,cAAc,EAAE,cAAc,CAAA;gBAElB,MAAM,EAAE,kBAAkB;IAO/B,gBAAgB,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM;IAIrC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC;IAqB3D,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,EAAE,OAAO,CAAC,EAAE,MAAM;IA2B/E,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAc3C,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM;IAKxC,MAAM,CAAC,aAAa,CAAC,aAAa,EAAE,MAAM;CAK3C"}
@@ -122,8 +122,15 @@ export class JwtUtils extends Instantiable {
122
122
  };
123
123
  }
124
124
  const address = getChecksumAddress(account.address);
125
+ // Not need it, but stay commented. If we need to bring back roles to update endpoints based on wallet with roles.
126
+ // const isAdmin = await this.nevermined.contracts.accessManager.hasRole(
127
+ // NVM_INFRA_ADMIN_ROLE,
128
+ // address as Address,
129
+ // )
125
130
  return new EthSignJWT({
126
131
  iss: address,
132
+ // roles: isAdmin[0] ? ['admin'] : [],
133
+ roles: [],
127
134
  })
128
135
  .setProtectedHeader({ alg: 'ES256K' })
129
136
  .setIssuedAt()
@@ -23,7 +23,7 @@ export declare class WebServiceConnector {
23
23
  downloadUrl(url: string, headers?: any): Promise<string>;
24
24
  uploadMessage(url: string, data: string, encrypt?: boolean): Promise<any>;
25
25
  uploadFile(url: string, data: ReadStream, encrypt?: boolean): Promise<any>;
26
- fetchToken(url: string, grantToken: string, numberTries?: number, apiKeyHash?: string): Promise<Response>;
26
+ fetchToken(url: string, grantToken: string, sessionKey?: string, numberTries?: number, apiKeyHash?: string): Promise<Response>;
27
27
  fetchCID(cid: string): Promise<string>;
28
28
  private static getIPFSAuthToken;
29
29
  private fetch;
@@ -1 +1 @@
1
- {"version":3,"file":"WebServiceConnector.d.ts","sourceRoot":"","sources":["../../../src/nevermined/utils/WebServiceConnector.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAA;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAgBnE;;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;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AAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,EACnB,WAAW,SAAI,EACf,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,QAAQ,CAAC;IA2BP,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBnD,OAAO,CAAC,MAAM,CAAC,gBAAgB;YAUjB,KAAK;IAiBnB,OAAO,CAAC,MAAM;CAGf"}
@@ -133,11 +133,14 @@ export class WebServiceConnector {
133
133
  }
134
134
  return this.fetch(url, { method: 'POST', body: form });
135
135
  }
136
- async fetchToken(url, grantToken, numberTries = 1, apiKeyHash) {
136
+ async fetchToken(url, grantToken, sessionKey, numberTries = 1, apiKeyHash) {
137
137
  const bodyParams = new URLSearchParams({
138
138
  client_assertion_type: JwtUtils.CLIENT_ASSERTION_TYPE,
139
139
  client_assertion: grantToken,
140
140
  });
141
+ if (sessionKey) {
142
+ bodyParams.append('sessionKey', sessionKey);
143
+ }
141
144
  if (apiKeyHash) {
142
145
  bodyParams.append('nvm_key_hash', apiKeyHash);
143
146
  }