@nevermined-io/core-kit 0.1.1 → 0.1.3

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 (139) hide show
  1. package/package.json +1 -1
  2. package/dist/Instantiable.abstract.d.ts +0 -33
  3. package/dist/Instantiable.abstract.d.ts.map +0 -1
  4. package/dist/Instantiable.abstract.js +0 -98
  5. package/dist/artifacts/generated.d.ts +0 -39371
  6. package/dist/artifacts/generated.d.ts.map +0 -1
  7. package/dist/artifacts/generated.js +0 -21448
  8. package/dist/contracts/AccessManager.d.ts +0 -17
  9. package/dist/contracts/AccessManager.d.ts.map +0 -1
  10. package/dist/contracts/AccessManager.js +0 -15
  11. package/dist/contracts/AssetRegistry.d.ts +0 -105
  12. package/dist/contracts/AssetRegistry.d.ts.map +0 -1
  13. package/dist/contracts/AssetRegistry.js +0 -155
  14. package/dist/contracts/ContractBase.d.ts +0 -33
  15. package/dist/contracts/ContractBase.d.ts.map +0 -1
  16. package/dist/contracts/ContractBase.js +0 -413
  17. package/dist/contracts/ContractsApi.d.ts +0 -69
  18. package/dist/contracts/ContractsApi.d.ts.map +0 -1
  19. package/dist/contracts/ContractsApi.js +0 -73
  20. package/dist/contracts/FiatPaymentTemplate.d.ts +0 -10
  21. package/dist/contracts/FiatPaymentTemplate.d.ts.map +0 -1
  22. package/dist/contracts/FiatPaymentTemplate.js +0 -14
  23. package/dist/contracts/FiatSettlementCondition.d.ts +0 -11
  24. package/dist/contracts/FiatSettlementCondition.d.ts.map +0 -1
  25. package/dist/contracts/FiatSettlementCondition.js +0 -18
  26. package/dist/contracts/FixedPaymentTemplate.d.ts +0 -14
  27. package/dist/contracts/FixedPaymentTemplate.d.ts.map +0 -1
  28. package/dist/contracts/FixedPaymentTemplate.js +0 -63
  29. package/dist/contracts/NFT1155Base.d.ts +0 -50
  30. package/dist/contracts/NFT1155Base.d.ts.map +0 -1
  31. package/dist/contracts/NFT1155Base.js +0 -24
  32. package/dist/contracts/NFT1155Credits.d.ts +0 -6
  33. package/dist/contracts/NFT1155Credits.d.ts.map +0 -1
  34. package/dist/contracts/NFT1155Credits.js +0 -9
  35. package/dist/contracts/NFT1155ExpirableCredits.d.ts +0 -34
  36. package/dist/contracts/NFT1155ExpirableCredits.d.ts.map +0 -1
  37. package/dist/contracts/NFT1155ExpirableCredits.js +0 -18
  38. package/dist/contracts/NVMConfig.d.ts +0 -10
  39. package/dist/contracts/NVMConfig.d.ts.map +0 -1
  40. package/dist/contracts/NVMConfig.js +0 -18
  41. package/dist/contracts/PayAsYouGoTemplate.d.ts +0 -13
  42. package/dist/contracts/PayAsYouGoTemplate.d.ts.map +0 -1
  43. package/dist/contracts/PayAsYouGoTemplate.js +0 -59
  44. package/dist/contracts/ProtocolStandardFees.d.ts +0 -9
  45. package/dist/contracts/ProtocolStandardFees.d.ts.map +0 -1
  46. package/dist/contracts/ProtocolStandardFees.js +0 -15
  47. package/dist/contracts/Roles.d.ts +0 -13
  48. package/dist/contracts/Roles.d.ts.map +0 -1
  49. package/dist/contracts/Roles.js +0 -12
  50. package/dist/contracts/index.d.ts +0 -3
  51. package/dist/contracts/index.d.ts.map +0 -1
  52. package/dist/contracts/index.js +0 -2
  53. package/dist/errors/NeverminedErrors.d.ts +0 -74
  54. package/dist/errors/NeverminedErrors.d.ts.map +0 -1
  55. package/dist/errors/NeverminedErrors.js +0 -128
  56. package/dist/errors/index.d.ts +0 -2
  57. package/dist/errors/index.d.ts.map +0 -1
  58. package/dist/errors/index.js +0 -1
  59. package/dist/index.d.ts +0 -8
  60. package/dist/index.d.ts.map +0 -1
  61. package/dist/index.js +0 -8
  62. package/dist/models/AgentAccessToken.d.ts +0 -123
  63. package/dist/models/AgentAccessToken.d.ts.map +0 -1
  64. package/dist/models/AgentAccessToken.js +0 -164
  65. package/dist/models/AgentX402AccessToken.d.ts +0 -59
  66. package/dist/models/AgentX402AccessToken.d.ts.map +0 -1
  67. package/dist/models/AgentX402AccessToken.js +0 -78
  68. package/dist/models/Logger.d.ts +0 -9
  69. package/dist/models/Logger.d.ts.map +0 -1
  70. package/dist/models/Logger.js +0 -27
  71. package/dist/models/NeverminedOptions.d.ts +0 -30
  72. package/dist/models/NeverminedOptions.d.ts.map +0 -1
  73. package/dist/models/NeverminedOptions.js +0 -28
  74. package/dist/models/NvmApiKey.d.ts +0 -137
  75. package/dist/models/NvmApiKey.d.ts.map +0 -1
  76. package/dist/models/NvmApiKey.js +0 -235
  77. package/dist/models/Transactions.d.ts +0 -11
  78. package/dist/models/Transactions.d.ts.map +0 -1
  79. package/dist/models/Transactions.js +0 -1
  80. package/dist/models/index.d.ts +0 -7
  81. package/dist/models/index.d.ts.map +0 -1
  82. package/dist/models/index.js +0 -6
  83. package/dist/nevermined/Nevermined.d.ts +0 -48
  84. package/dist/nevermined/Nevermined.d.ts.map +0 -1
  85. package/dist/nevermined/Nevermined.js +0 -72
  86. package/dist/nevermined/api/PaymentsApi.d.ts +0 -25
  87. package/dist/nevermined/api/PaymentsApi.d.ts.map +0 -1
  88. package/dist/nevermined/api/PaymentsApi.js +0 -177
  89. package/dist/nevermined/api/ServicesApi.d.ts +0 -23
  90. package/dist/nevermined/api/ServicesApi.d.ts.map +0 -1
  91. package/dist/nevermined/api/ServicesApi.js +0 -27
  92. package/dist/nevermined/api/UtilsApi.d.ts +0 -28
  93. package/dist/nevermined/api/UtilsApi.d.ts.map +0 -1
  94. package/dist/nevermined/api/UtilsApi.js +0 -33
  95. package/dist/nevermined/index.d.ts +0 -3
  96. package/dist/nevermined/index.d.ts.map +0 -1
  97. package/dist/nevermined/index.js +0 -2
  98. package/dist/nevermined/utils/AgentUtils.d.ts +0 -8
  99. package/dist/nevermined/utils/AgentUtils.d.ts.map +0 -1
  100. package/dist/nevermined/utils/AgentUtils.js +0 -56
  101. package/dist/nevermined/utils/BlockchainViemUtils.d.ts +0 -280
  102. package/dist/nevermined/utils/BlockchainViemUtils.d.ts.map +0 -1
  103. package/dist/nevermined/utils/BlockchainViemUtils.js +0 -408
  104. package/dist/nevermined/utils/JwtUtils.d.ts +0 -27
  105. package/dist/nevermined/utils/JwtUtils.d.ts.map +0 -1
  106. package/dist/nevermined/utils/JwtUtils.js +0 -161
  107. package/dist/nevermined/utils/SignatureUtils.d.ts +0 -14
  108. package/dist/nevermined/utils/SignatureUtils.d.ts.map +0 -1
  109. package/dist/nevermined/utils/SignatureUtils.js +0 -99
  110. package/dist/nevermined/utils/WebServiceConnector.d.ts +0 -30
  111. package/dist/nevermined/utils/WebServiceConnector.d.ts.map +0 -1
  112. package/dist/nevermined/utils/WebServiceConnector.js +0 -170
  113. package/dist/nevermined/utils/ZeroDevPolicies.d.ts +0 -36
  114. package/dist/nevermined/utils/ZeroDevPolicies.d.ts.map +0 -1
  115. package/dist/nevermined/utils/ZeroDevPolicies.js +0 -152
  116. package/dist/nevermined/utils/index.d.ts +0 -7
  117. package/dist/nevermined/utils/index.d.ts.map +0 -1
  118. package/dist/nevermined/utils/index.js +0 -6
  119. package/dist/services/Api.d.ts +0 -7
  120. package/dist/services/Api.d.ts.map +0 -1
  121. package/dist/services/Api.js +0 -25
  122. package/dist/services/Profiles.d.ts +0 -16
  123. package/dist/services/Profiles.d.ts.map +0 -1
  124. package/dist/services/Profiles.js +0 -84
  125. package/dist/services/index.d.ts +0 -3
  126. package/dist/services/index.d.ts.map +0 -1
  127. package/dist/services/index.js +0 -2
  128. package/dist/utils/ConversionTypeHelpers.d.ts +0 -5
  129. package/dist/utils/ConversionTypeHelpers.d.ts.map +0 -1
  130. package/dist/utils/ConversionTypeHelpers.js +0 -30
  131. package/dist/utils/Network.d.ts +0 -5
  132. package/dist/utils/Network.d.ts.map +0 -1
  133. package/dist/utils/Network.js +0 -224
  134. package/dist/utils/helpers.d.ts +0 -23
  135. package/dist/utils/helpers.d.ts.map +0 -1
  136. package/dist/utils/helpers.js +0 -161
  137. package/dist/utils/index.d.ts +0 -4
  138. package/dist/utils/index.d.ts.map +0 -1
  139. package/dist/utils/index.js +0 -3
@@ -1,137 +0,0 @@
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
- export declare class NvmApiKey implements JWTPayload {
6
- /**
7
- * The public address of the account issuing the key.
8
- */
9
- iss?: string;
10
- /**
11
- * The chain id of the network the key is valid for. If zero the key is not having any network limitation
12
- */
13
- aud?: string;
14
- /**
15
- * The public address of the account the key is issued for.
16
- */
17
- sub?: string;
18
- /**
19
- * The version of the key
20
- */
21
- ver: string;
22
- /**
23
- * The ZeroDev session key
24
- */
25
- zsk?: string;
26
- /**
27
- * The Marketplace auth token
28
- */
29
- /**
30
- * JWT Expiration Time
31
- *
32
- * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.4 RFC7519#section-4.1.4}
33
- */
34
- exp?: number;
35
- /**
36
- * JWT Issued At
37
- *
38
- * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.6 RFC7519#section-4.1.6}
39
- */
40
- iat?: number;
41
- /**
42
- * Additional attributes
43
- */
44
- [propName: string]: any;
45
- /**
46
- * It generates a new serialized and encrypted NvmApiKey including the ZeroDev session key and the Marketplace auth token.
47
- * The string representing this key can be used to authenticate against the Nevermined API.
48
- * @param signatureUtils The SignatureUtils instance
49
- * @param issuerAccount The account issuing the key
50
- * @param zeroDevSessionKey The ZeroDev session key
51
- * @param receiverAddress The address of the account the key is issued for
52
- * @param receiverPublicKey The public key of the account the key is issued for
53
- * @param chainId The chain id of the network the key is valid for
54
- * @param additionalParams Addintional params to be added to the Key generated
55
- * @returns The encrypted string representing the @see {@link NvmApiKey}
56
- */
57
- static generate(signatureUtils: SignatureUtils, issuerAccount: Account | SmartAccount, zeroDevSessionKey: string | undefined, receiverAddress: string, receiverPublicKey: string, expirationTime?: number | string, additionalParams?: {}, nvmApiKeyVersion?: string): Promise<string>;
58
- /**
59
- * Given an encrypted JWT and a private key, it decrypts and decodes the JWT into a NvmApiKey
60
- * @param encryptedJwt The encrypted JWT
61
- * @param privateKey The private key representing the account
62
- * @returns The @see {@link NvmApiKey}
63
- */
64
- static decryptAndDecode(encryptedJwt: string, privateKey: string): Promise<NvmApiKey>;
65
- /**
66
- * Given a signed JWT, it recovers the signer address
67
- * @param jwtString The signed JWT
68
- * @returns The signer address
69
- */
70
- static getSignerAddress(jwtString: string): Promise<string>;
71
- /**
72
- * It checks if the NVM API Key attributes are valid
73
- * @param chainId The chain id of the network the key is valid for
74
- * @returns true if the key is valid, false otherwise
75
- */
76
- isValid(chainId?: number): boolean;
77
- /**
78
- * It generates a signed JWT from the NvmApiKey
79
- * @param signatureUtils The SignatureUtils instance
80
- * @param issuerAccount The account issuing the key
81
- * @returns the string in JWT format represeting the NvmApiKey
82
- */
83
- toJWT(signatureUtils: SignatureUtils, issuerAccount: Account | SmartAccount): Promise<string>;
84
- /**
85
- * It generates the hash in JWT format of the NvmApiKey
86
- * @param signatureUtils the SignatureUtils instance
87
- * @param issuerAccount the account issuing the key
88
- * @returns a JWT string representing the hash of the NvmApiKey
89
- */
90
- hashJWT(signatureUtils: SignatureUtils, issuerAccount: Account | SmartAccount, heliconeApiKey?: string): Promise<string>;
91
- /**
92
- * It regenerates the NvmApiKey from a JSON object
93
- * @param jwt JWTPayload in JSON format
94
- * @returns the @see {@link NvmApiKey}
95
- */
96
- static fromJSON(jwt: JWTPayload): NvmApiKey;
97
- /**
98
- * It regenerates the NvmApiKey from a JWT
99
- * @param jwtString the string in JWT format represeting the NvmApiKey
100
- * @returns the @see {@link NvmApiKey}
101
- */
102
- static fromJWT(jwtString: string): NvmApiKey;
103
- /**
104
- * It regenerates the NvmApiKey from a string
105
- * @param str the string represeting the NvmApiKey
106
- * @returns the @see {@link NvmApiKey}
107
- */
108
- static deserialize(str: string): NvmApiKey;
109
- /**
110
- * It serializes the NVM Api Key into a string
111
- * @returns a string representing the NVM API Key
112
- */
113
- serialize(): string;
114
- /**
115
- * It serializes the NVM Api Key into a string
116
- * @returns a string representing the NVM API Key
117
- */
118
- toString(): string;
119
- /**
120
- * It decodes a string JWT into a JWTPayload
121
- * @param str jwt string
122
- * @returns the JWTPayload
123
- */
124
- static decodeJWT(str: string): JWTPayload;
125
- /**
126
- * It generates the hash of the NvmApiKey
127
- * @returns a string representing the hash of the NvmApiKey
128
- */
129
- hash(): string;
130
- /**
131
- * Given a serialized string, it generates the hash
132
- * @param serialized the serialized string
133
- * @returns the hash
134
- */
135
- static hash(serialized: string): string;
136
- }
137
- //# sourceMappingURL=NvmApiKey.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NvmApiKey.d.ts","sourceRoot":"","sources":["../../src/models/NvmApiKey.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;AAIvD,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAA;AAGtE,qBAAa,SAAU,YAAW,UAAU;IAC1C;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,GAAG,SAAO;IAEV;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;OAEG;IAGH;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAA;IAEvB;;;;;;;;;;;OAWG;WACiB,QAAQ,CAC1B,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,OAAO,GAAG,YAAY,EACrC,iBAAiB,EAAE,MAAM,GAAG,SAAS,EACrC,eAAe,EAAE,MAAM,EACvB,iBAAiB,EAAE,MAAM,EACzB,cAAc,GAAE,MAAM,GAAG,MAAa,EACtC,gBAAgB,KAAK,EACrB,gBAAgB,SAAO,GACtB,OAAO,CAAC,MAAM,CAAC;IA4BlB;;;;;OAKG;WACiB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAK7E;;;;OAIG;WACiB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAcxE;;;;OAIG;IACI,OAAO,CAAC,OAAO,SAAI,GAAG,OAAO;IAWpC;;;;;OAKG;IACU,KAAK,CAChB,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,OAAO,GAAG,YAAY,GACpC,OAAO,CAAC,MAAM,CAAC;IAalB;;;;;OAKG;IACU,OAAO,CAClB,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,OAAO,GAAG,YAAY,EACrC,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,MAAM,CAAC;IAiBlB;;;;OAIG;WACW,QAAQ,CAAC,GAAG,EAAE,UAAU,GAAG,SAAS;IAYlD;;;;OAIG;WACW,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;IAKnD;;;;OAIG;WACW,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS;IAIjD;;;OAGG;IACI,SAAS,IAAI,MAAM;IAI1B;;;OAGG;IACI,QAAQ,IAAI,MAAM;IAIzB;;;;OAIG;WACW,SAAS,CAAC,GAAG,EAAE,MAAM;IAInC;;;OAGG;IACI,IAAI;IAIX;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM;CAG/B"}
@@ -1,235 +0,0 @@
1
- import { decodeJwt } from 'jose';
2
- import { bytesToHex } from 'viem/utils';
3
- import { getChecksumAddress } from '../nevermined/utils/BlockchainViemUtils.js';
4
- import { EthSignJWT } from '../nevermined/utils/JwtUtils.js';
5
- import { SignatureUtils } from '../nevermined/utils/SignatureUtils.js';
6
- import { decryptMessage, encryptMessage, urlSafeBase64Decode } from '../utils/helpers.js';
7
- export class NvmApiKey {
8
- /**
9
- * The public address of the account issuing the key.
10
- */
11
- iss;
12
- /**
13
- * The chain id of the network the key is valid for. If zero the key is not having any network limitation
14
- */
15
- aud;
16
- /**
17
- * The public address of the account the key is issued for.
18
- */
19
- sub;
20
- /**
21
- * The version of the key
22
- */
23
- ver = 'v1';
24
- /**
25
- * The ZeroDev session key
26
- */
27
- zsk;
28
- /**
29
- * The Marketplace auth token
30
- */
31
- // nvt?: string
32
- /**
33
- * JWT Expiration Time
34
- *
35
- * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.4 RFC7519#section-4.1.4}
36
- */
37
- exp;
38
- /**
39
- * JWT Issued At
40
- *
41
- * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.6 RFC7519#section-4.1.6}
42
- */
43
- iat;
44
- /**
45
- * It generates a new serialized and encrypted NvmApiKey including the ZeroDev session key and the Marketplace auth token.
46
- * The string representing this key can be used to authenticate against the Nevermined API.
47
- * @param signatureUtils The SignatureUtils instance
48
- * @param issuerAccount The account issuing the key
49
- * @param zeroDevSessionKey The ZeroDev session key
50
- * @param receiverAddress The address of the account the key is issued for
51
- * @param receiverPublicKey The public key of the account the key is issued for
52
- * @param chainId The chain id of the network the key is valid for
53
- * @param additionalParams Addintional params to be added to the Key generated
54
- * @returns The encrypted string representing the @see {@link NvmApiKey}
55
- */
56
- static async generate(signatureUtils, issuerAccount, zeroDevSessionKey, receiverAddress, receiverPublicKey, expirationTime = '1y', additionalParams = {}, nvmApiKeyVersion = 'v1') {
57
- const issuerAddress = getChecksumAddress(issuerAccount.address);
58
- const chainId = signatureUtils.client.chain?.id || 0;
59
- const sub = getChecksumAddress(receiverAddress);
60
- const eip712Data = {
61
- message: 'Sign this message to generate the Encrypted Nevermined API Key',
62
- ...(chainId > 0 && { chainId }),
63
- };
64
- const params = {
65
- iss: issuerAddress,
66
- aud: chainId.toString(),
67
- sub,
68
- ver: nvmApiKeyVersion,
69
- zsk: zeroDevSessionKey,
70
- eip712Data,
71
- ...additionalParams,
72
- };
73
- const signedJWT = await new EthSignJWT(params)
74
- .setProtectedHeader({ alg: 'ES256K' })
75
- .setIssuedAt()
76
- .setExpirationTime(expirationTime)
77
- .ethSign(signatureUtils, issuerAccount);
78
- return encryptMessage(signedJWT, receiverPublicKey);
79
- }
80
- /**
81
- * Given an encrypted JWT and a private key, it decrypts and decodes the JWT into a NvmApiKey
82
- * @param encryptedJwt The encrypted JWT
83
- * @param privateKey The private key representing the account
84
- * @returns The @see {@link NvmApiKey}
85
- */
86
- static async decryptAndDecode(encryptedJwt, privateKey) {
87
- const decrypted = await decryptMessage(encryptedJwt, privateKey);
88
- return NvmApiKey.fromJWT(decrypted);
89
- }
90
- /**
91
- * Given a signed JWT, it recovers the signer address
92
- * @param jwtString The signed JWT
93
- * @returns The signer address
94
- */
95
- static async getSignerAddress(jwtString) {
96
- try {
97
- const tokens = jwtString.split('.');
98
- const signature = bytesToHex(urlSafeBase64Decode(tokens[2]));
99
- return SignatureUtils.recoverSignerAddress(`${tokens[0]}.${tokens[1]}`, signature);
100
- }
101
- catch (e) {
102
- if (e instanceof Error) {
103
- throw new Error(`Error recovering signer address: ${e.message}`);
104
- }
105
- else {
106
- throw new Error(`Error recovering signer address`);
107
- }
108
- }
109
- }
110
- /**
111
- * It checks if the NVM API Key attributes are valid
112
- * @param chainId The chain id of the network the key is valid for
113
- * @returns true if the key is valid, false otherwise
114
- */
115
- isValid(chainId = 0) {
116
- if (this.exp) {
117
- const now = new Date();
118
- if (now.getTime() > Number(this.exp) * 1000)
119
- return false;
120
- }
121
- if (chainId !== 0) {
122
- if (Number(this.aud) !== chainId)
123
- return false;
124
- }
125
- return true;
126
- }
127
- /**
128
- * It generates a signed JWT from the NvmApiKey
129
- * @param signatureUtils The SignatureUtils instance
130
- * @param issuerAccount The account issuing the key
131
- * @returns the string in JWT format represeting the NvmApiKey
132
- */
133
- async toJWT(signatureUtils, issuerAccount) {
134
- const params = {};
135
- Object.keys(this)
136
- .filter((val) => val !== undefined)
137
- .forEach((key) => {
138
- if (!key.startsWith('_'))
139
- params[key] = this[key];
140
- });
141
- const jwt = new EthSignJWT(params).setProtectedHeader({ alg: 'ES256K' }).setIssuedAt(this.iat);
142
- if (this.exp)
143
- jwt.setExpirationTime(this.exp);
144
- return jwt.ethSign(signatureUtils, issuerAccount);
145
- }
146
- /**
147
- * It generates the hash in JWT format of the NvmApiKey
148
- * @param signatureUtils the SignatureUtils instance
149
- * @param issuerAccount the account issuing the key
150
- * @returns a JWT string representing the hash of the NvmApiKey
151
- */
152
- async hashJWT(signatureUtils, issuerAccount, heliconeApiKey) {
153
- const issuerAddress = getChecksumAddress(issuerAccount.address);
154
- return (new EthSignJWT({
155
- iss: issuerAddress, // the account generating the hash (node/provider, etc) is the issuer of the hash
156
- sub: this.iss, // the issuer of the NVMApiKey (the user) is the subject of the hash
157
- jti: this.hash(),
158
- exp: this.exp,
159
- o11y: heliconeApiKey,
160
- })
161
- .setProtectedHeader({ alg: 'ES256K' })
162
- // .setIssuedAt() // WARNING: If enabled, the hash will change for the same NvmApiKey
163
- .ethSign(signatureUtils, issuerAccount));
164
- }
165
- /**
166
- * It regenerates the NvmApiKey from a JSON object
167
- * @param jwt JWTPayload in JSON format
168
- * @returns the @see {@link NvmApiKey}
169
- */
170
- static fromJSON(jwt) {
171
- const nvmKey = new NvmApiKey();
172
- const str = JSON.stringify(jwt);
173
- const _obj = JSON.parse(str);
174
- Object.keys(_obj)
175
- .filter((val) => val !== undefined)
176
- .forEach((key) => {
177
- nvmKey[key] = _obj[key];
178
- });
179
- return nvmKey;
180
- }
181
- /**
182
- * It regenerates the NvmApiKey from a JWT
183
- * @param jwtString the string in JWT format represeting the NvmApiKey
184
- * @returns the @see {@link NvmApiKey}
185
- */
186
- static fromJWT(jwtString) {
187
- const jwt = NvmApiKey.decodeJWT(jwtString);
188
- return NvmApiKey.fromJSON(jwt);
189
- }
190
- /**
191
- * It regenerates the NvmApiKey from a string
192
- * @param str the string represeting the NvmApiKey
193
- * @returns the @see {@link NvmApiKey}
194
- */
195
- static deserialize(str) {
196
- return NvmApiKey.fromJSON(JSON.parse(str));
197
- }
198
- /**
199
- * It serializes the NVM Api Key into a string
200
- * @returns a string representing the NVM API Key
201
- */
202
- serialize() {
203
- return this.toString();
204
- }
205
- /**
206
- * It serializes the NVM Api Key into a string
207
- * @returns a string representing the NVM API Key
208
- */
209
- toString() {
210
- return JSON.stringify(this);
211
- }
212
- /**
213
- * It decodes a string JWT into a JWTPayload
214
- * @param str jwt string
215
- * @returns the JWTPayload
216
- */
217
- static decodeJWT(str) {
218
- return decodeJwt(str);
219
- }
220
- /**
221
- * It generates the hash of the NvmApiKey
222
- * @returns a string representing the hash of the NvmApiKey
223
- */
224
- hash() {
225
- return SignatureUtils.hash(this.serialize());
226
- }
227
- /**
228
- * Given a serialized string, it generates the hash
229
- * @param serialized the serialized string
230
- * @returns the hash
231
- */
232
- static hash(serialized) {
233
- return SignatureUtils.hash(serialized);
234
- }
235
- }
@@ -1,11 +0,0 @@
1
- export interface TxParameters {
2
- value?: bigint;
3
- gasLimit?: bigint;
4
- gasMultiplier?: number;
5
- gasPrice?: string;
6
- maxPriorityFeePerGas?: string;
7
- maxFeePerGas?: string;
8
- nonce?: number;
9
- progress?: (data: any) => void;
10
- }
11
- //# sourceMappingURL=Transactions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../src/models/Transactions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAA;CAC/B"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- export * from './Logger.js';
2
- export * from './NeverminedOptions.js';
3
- export * from './NvmApiKey.js';
4
- export * from './Transactions.js';
5
- export * from './AgentAccessToken.js';
6
- export * from './AgentX402AccessToken.js';
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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;AACrC,cAAc,2BAA2B,CAAA"}
@@ -1,6 +0,0 @@
1
- export * from './Logger.js';
2
- export * from './NeverminedOptions.js';
3
- export * from './NvmApiKey.js';
4
- export * from './Transactions.js';
5
- export * from './AgentAccessToken.js';
6
- export * from './AgentX402AccessToken.js';
@@ -1,48 +0,0 @@
1
- import { Instantiable } from '../Instantiable.abstract.js';
2
- import { NeverminedOptions } from '../models/NeverminedOptions.js';
3
- import { UtilsApi } from '../nevermined/api/UtilsApi.js';
4
- import { ServicesApi } from './api/ServicesApi.js';
5
- import { ContractsApi } from '../contracts/ContractsApi.js';
6
- import { PaymentsApi } from './api/PaymentsApi.js';
7
- /**
8
- * Main interface for Nevermined Protocol.
9
- */
10
- export declare class Nevermined extends Instantiable {
11
- /**
12
- * Returns the instance of Nevermined.
13
- *
14
- * @example
15
- * ```ts
16
- * import { Nevermined, Config } from '@nevermined-io/sdk'
17
- *
18
- * const config: Config = {...}
19
- * const nevermined = await Nevermined.getInstance(config)
20
- * ```
21
- *
22
- * @param config - Nevermined instance configuration.
23
- * @returns A {@link Nevermined} instance
24
- */
25
- static getInstance(config: NeverminedOptions): Promise<Nevermined>;
26
- /**
27
- * ContractsApi instance.
28
- */
29
- contracts: ContractsApi;
30
- /**
31
- * SearchApi API
32
- */
33
- services: ServicesApi;
34
- /**
35
- * Utils submodule
36
- */
37
- utils: UtilsApi;
38
- payments: PaymentsApi;
39
- /**
40
- * Web3 Clients
41
- */
42
- /**
43
- * If contracts are initialized
44
- */
45
- contractsInitialized: boolean | undefined;
46
- private constructor();
47
- }
48
- //# sourceMappingURL=Nevermined.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Nevermined.d.ts","sourceRoot":"","sources":["../../src/nevermined/Nevermined.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwC,MAAM,6BAA6B,CAAA;AAChG,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAElD;;GAEG;AACH,qBAAa,UAAW,SAAQ,YAAY;IAC1C;;;;;;;;;;;;;OAaG;WAC0B,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;IAgCxF;;OAEG;IACI,SAAS,EAAG,YAAY,CAAA;IAE/B;;OAEG;IACI,QAAQ,EAAG,WAAW,CAAA;IAE7B;;OAEG;IACI,KAAK,EAAG,QAAQ,CAAA;IAEhB,QAAQ,EAAG,WAAW,CAAA;IAE7B;;OAEG;IAGH;;OAEG;IACI,oBAAoB,EAAE,OAAO,GAAG,SAAS,CAAA;IAEhD,OAAO;CAGR"}
@@ -1,72 +0,0 @@
1
- import { Instantiable, generateInstantiableConfigFromConfig } from '../Instantiable.abstract.js';
2
- import { UtilsApi } from '../nevermined/api/UtilsApi.js';
3
- import { ServicesApi } from './api/ServicesApi.js';
4
- import { ContractsApi } from '../contracts/ContractsApi.js';
5
- import { PaymentsApi } from './api/PaymentsApi.js';
6
- /**
7
- * Main interface for Nevermined Protocol.
8
- */
9
- export class Nevermined extends Instantiable {
10
- /**
11
- * Returns the instance of Nevermined.
12
- *
13
- * @example
14
- * ```ts
15
- * import { Nevermined, Config } from '@nevermined-io/sdk'
16
- *
17
- * const config: Config = {...}
18
- * const nevermined = await Nevermined.getInstance(config)
19
- * ```
20
- *
21
- * @param config - Nevermined instance configuration.
22
- * @returns A {@link Nevermined} instance
23
- */
24
- static async getInstance(config) {
25
- const instance = new Nevermined();
26
- // Nevermined main API
27
- try {
28
- const instanceConfig = {
29
- ...(await generateInstantiableConfigFromConfig(config, true)),
30
- nevermined: instance,
31
- };
32
- instance.setInstanceConfig(instanceConfig);
33
- // instance.search = new SearchApi(instanceConfig)
34
- instance.services = new ServicesApi(instanceConfig);
35
- instance.utils = new UtilsApi(instanceConfig);
36
- instance.contracts = await ContractsApi.getInstance(instanceConfig);
37
- await instance.contracts.init();
38
- instance.payments = new PaymentsApi(instanceConfig);
39
- instance.contractsInitialized = true;
40
- }
41
- catch (error) {
42
- instance.contractsInitialized = false;
43
- instance.logger.error(error);
44
- instance.logger.error("Contracts didn't initialize because for the above mentioned reason. Loading SDK in offchain mode...");
45
- }
46
- return instance;
47
- }
48
- /**
49
- * ContractsApi instance.
50
- */
51
- contracts;
52
- /**
53
- * SearchApi API
54
- */
55
- services;
56
- /**
57
- * Utils submodule
58
- */
59
- utils;
60
- payments;
61
- /**
62
- * Web3 Clients
63
- */
64
- // public web3: Web3Clients
65
- /**
66
- * If contracts are initialized
67
- */
68
- contractsInitialized;
69
- constructor() {
70
- super();
71
- }
72
- }
@@ -1,25 +0,0 @@
1
- import { OrderResult, Plan } from '@nvm-monorepo/commons';
2
- import { Account, Address } from 'viem';
3
- import { SmartAccount } from 'viem/account-abstraction';
4
- import { Instantiable, InstantiableConfig } from '../../Instantiable.abstract.js';
5
- export declare class PaymentsApi extends Instantiable {
6
- /**
7
- * Creates a new PaymentsApi
8
- * @param config - Configuration of the Nevermined instance
9
- * @returns {@link PaymentsApi}
10
- */
11
- constructor(config: InstantiableConfig);
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
- ownerAmount: bigint;
19
- }>;
20
- orderFiatPayment(planId: bigint, planReceiver: Address, from: Account | SmartAccount, numberOfPurchases?: bigint): Promise<OrderResult>;
21
- orderCryptoPlan(planId: bigint, plan: Plan, from: Account | SmartAccount, planReceiver?: Address, numberOfPurchases?: bigint): Promise<OrderResult>;
22
- orderPayAsYouGoPlan(planId: bigint, plan: Plan, from: Account | SmartAccount): Promise<OrderResult>;
23
- private _orderCryptoPlan;
24
- }
25
- //# sourceMappingURL=PaymentsApi.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PaymentsApi.d.ts","sourceRoot":"","sources":["../../../src/nevermined/api/PaymentsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAA8B,MAAM,uBAAuB,CAAA;AACrF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAoC,MAAM,MAAM,CAAA;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAOjF,qBAAa,WAAY,SAAQ,YAAY;IAC3C;;;;OAIG;gBACS,MAAM,EAAE,kBAAkB;IAKzB,eAAe,CAAC,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAgB7E,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAChD,aAAa,EAAE,MAAM,CAAA;QACrB,WAAW,EAAE,MAAM,CAAA;QACnB,cAAc,EAAE,MAAM,CAAA;QACtB,WAAW,EAAE,MAAM,CAAA;QACnB,WAAW,EAAE,MAAM,CAAA;KACpB,CAAC;IA4CW,gBAAgB,CAC3B,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,OAAO,EACrB,IAAI,EAAE,OAAO,GAAG,YAAY,EAC5B,iBAAiB,SAAK,GACrB,OAAO,CAAC,WAAW,CAAC;IA0BV,eAAe,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,OAAO,GAAG,YAAY,EAC5B,YAAY,CAAC,EAAE,OAAO,EACtB,iBAAiB,SAAK,GACrB,OAAO,CAAC,WAAW,CAAC;IAKV,mBAAmB,CAC9B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,OAAO,GAAG,YAAY,GAC3B,OAAO,CAAC,WAAW,CAAC;YAKT,gBAAgB;CAqH/B"}