@nevermined-io/core-kit 0.1.0 → 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.
- package/package.json +3 -3
- package/dist/Instantiable.abstract.d.ts +0 -33
- package/dist/Instantiable.abstract.d.ts.map +0 -1
- package/dist/Instantiable.abstract.js +0 -98
- package/dist/artifacts/generated.d.ts +0 -39505
- package/dist/artifacts/generated.d.ts.map +0 -1
- package/dist/artifacts/generated.js +0 -21556
- package/dist/contracts/AccessManager.d.ts +0 -17
- package/dist/contracts/AccessManager.d.ts.map +0 -1
- package/dist/contracts/AccessManager.js +0 -15
- package/dist/contracts/AssetRegistry.d.ts +0 -105
- package/dist/contracts/AssetRegistry.d.ts.map +0 -1
- package/dist/contracts/AssetRegistry.js +0 -155
- package/dist/contracts/ContractBase.d.ts +0 -33
- package/dist/contracts/ContractBase.d.ts.map +0 -1
- package/dist/contracts/ContractBase.js +0 -413
- package/dist/contracts/ContractsApi.d.ts +0 -69
- package/dist/contracts/ContractsApi.d.ts.map +0 -1
- package/dist/contracts/ContractsApi.js +0 -73
- package/dist/contracts/FiatPaymentTemplate.d.ts +0 -10
- package/dist/contracts/FiatPaymentTemplate.d.ts.map +0 -1
- package/dist/contracts/FiatPaymentTemplate.js +0 -14
- package/dist/contracts/FiatSettlementCondition.d.ts +0 -11
- package/dist/contracts/FiatSettlementCondition.d.ts.map +0 -1
- package/dist/contracts/FiatSettlementCondition.js +0 -18
- package/dist/contracts/FixedPaymentTemplate.d.ts +0 -13
- package/dist/contracts/FixedPaymentTemplate.d.ts.map +0 -1
- package/dist/contracts/FixedPaymentTemplate.js +0 -59
- package/dist/contracts/NFT1155Base.d.ts +0 -50
- package/dist/contracts/NFT1155Base.d.ts.map +0 -1
- package/dist/contracts/NFT1155Base.js +0 -24
- package/dist/contracts/NFT1155Credits.d.ts +0 -6
- package/dist/contracts/NFT1155Credits.d.ts.map +0 -1
- package/dist/contracts/NFT1155Credits.js +0 -9
- package/dist/contracts/NFT1155ExpirableCredits.d.ts +0 -34
- package/dist/contracts/NFT1155ExpirableCredits.d.ts.map +0 -1
- package/dist/contracts/NFT1155ExpirableCredits.js +0 -18
- package/dist/contracts/NVMConfig.d.ts +0 -10
- package/dist/contracts/NVMConfig.d.ts.map +0 -1
- package/dist/contracts/NVMConfig.js +0 -18
- package/dist/contracts/PayAsYouGoTemplate.d.ts +0 -13
- package/dist/contracts/PayAsYouGoTemplate.d.ts.map +0 -1
- package/dist/contracts/PayAsYouGoTemplate.js +0 -59
- package/dist/contracts/ProtocolStandardFees.d.ts +0 -9
- package/dist/contracts/ProtocolStandardFees.d.ts.map +0 -1
- package/dist/contracts/ProtocolStandardFees.js +0 -15
- package/dist/contracts/Roles.d.ts +0 -13
- package/dist/contracts/Roles.d.ts.map +0 -1
- package/dist/contracts/Roles.js +0 -12
- package/dist/contracts/index.d.ts +0 -3
- package/dist/contracts/index.d.ts.map +0 -1
- package/dist/contracts/index.js +0 -2
- package/dist/errors/NeverminedErrors.d.ts +0 -74
- package/dist/errors/NeverminedErrors.d.ts.map +0 -1
- package/dist/errors/NeverminedErrors.js +0 -128
- package/dist/errors/index.d.ts +0 -2
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -8
- package/dist/models/AgentAccessToken.d.ts +0 -123
- package/dist/models/AgentAccessToken.d.ts.map +0 -1
- package/dist/models/AgentAccessToken.js +0 -164
- package/dist/models/Logger.d.ts +0 -9
- package/dist/models/Logger.d.ts.map +0 -1
- package/dist/models/Logger.js +0 -27
- package/dist/models/NeverminedOptions.d.ts +0 -30
- package/dist/models/NeverminedOptions.d.ts.map +0 -1
- package/dist/models/NeverminedOptions.js +0 -28
- package/dist/models/NvmApiKey.d.ts +0 -137
- package/dist/models/NvmApiKey.d.ts.map +0 -1
- package/dist/models/NvmApiKey.js +0 -235
- package/dist/models/Transactions.d.ts +0 -11
- package/dist/models/Transactions.d.ts.map +0 -1
- package/dist/models/Transactions.js +0 -1
- package/dist/models/index.d.ts +0 -6
- package/dist/models/index.d.ts.map +0 -1
- package/dist/models/index.js +0 -5
- package/dist/nevermined/Nevermined.d.ts +0 -48
- package/dist/nevermined/Nevermined.d.ts.map +0 -1
- package/dist/nevermined/Nevermined.js +0 -72
- package/dist/nevermined/api/PaymentsApi.d.ts +0 -25
- package/dist/nevermined/api/PaymentsApi.d.ts.map +0 -1
- package/dist/nevermined/api/PaymentsApi.js +0 -179
- package/dist/nevermined/api/ServicesApi.d.ts +0 -23
- package/dist/nevermined/api/ServicesApi.d.ts.map +0 -1
- package/dist/nevermined/api/ServicesApi.js +0 -27
- package/dist/nevermined/api/UtilsApi.d.ts +0 -28
- package/dist/nevermined/api/UtilsApi.d.ts.map +0 -1
- package/dist/nevermined/api/UtilsApi.js +0 -33
- package/dist/nevermined/index.d.ts +0 -3
- package/dist/nevermined/index.d.ts.map +0 -1
- package/dist/nevermined/index.js +0 -2
- package/dist/nevermined/utils/AgentUtils.d.ts +0 -8
- package/dist/nevermined/utils/AgentUtils.d.ts.map +0 -1
- package/dist/nevermined/utils/AgentUtils.js +0 -56
- package/dist/nevermined/utils/BlockchainViemUtils.d.ts +0 -280
- package/dist/nevermined/utils/BlockchainViemUtils.d.ts.map +0 -1
- package/dist/nevermined/utils/BlockchainViemUtils.js +0 -408
- package/dist/nevermined/utils/JwtUtils.d.ts +0 -27
- package/dist/nevermined/utils/JwtUtils.d.ts.map +0 -1
- package/dist/nevermined/utils/JwtUtils.js +0 -161
- package/dist/nevermined/utils/SignatureUtils.d.ts +0 -14
- package/dist/nevermined/utils/SignatureUtils.d.ts.map +0 -1
- package/dist/nevermined/utils/SignatureUtils.js +0 -99
- package/dist/nevermined/utils/WebServiceConnector.d.ts +0 -30
- package/dist/nevermined/utils/WebServiceConnector.d.ts.map +0 -1
- package/dist/nevermined/utils/WebServiceConnector.js +0 -170
- package/dist/nevermined/utils/ZeroDevPolicies.d.ts +0 -36
- package/dist/nevermined/utils/ZeroDevPolicies.d.ts.map +0 -1
- package/dist/nevermined/utils/ZeroDevPolicies.js +0 -152
- package/dist/nevermined/utils/index.d.ts +0 -7
- package/dist/nevermined/utils/index.d.ts.map +0 -1
- package/dist/nevermined/utils/index.js +0 -6
- package/dist/services/Api.d.ts +0 -7
- package/dist/services/Api.d.ts.map +0 -1
- package/dist/services/Api.js +0 -25
- package/dist/services/Profiles.d.ts +0 -16
- package/dist/services/Profiles.d.ts.map +0 -1
- package/dist/services/Profiles.js +0 -84
- package/dist/services/index.d.ts +0 -3
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/index.js +0 -2
- package/dist/utils/ConversionTypeHelpers.d.ts +0 -5
- package/dist/utils/ConversionTypeHelpers.d.ts.map +0 -1
- package/dist/utils/ConversionTypeHelpers.js +0 -30
- package/dist/utils/Network.d.ts +0 -5
- package/dist/utils/Network.d.ts.map +0 -1
- package/dist/utils/Network.js +0 -224
- package/dist/utils/helpers.d.ts +0 -23
- package/dist/utils/helpers.d.ts.map +0 -1
- package/dist/utils/helpers.js +0 -161
- package/dist/utils/index.d.ts +0 -4
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -3
package/dist/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from './contracts/index.js';
|
|
2
|
-
export * from './models/index.js';
|
|
3
|
-
export * from './nevermined/index.js';
|
|
4
|
-
export * from './nevermined/Nevermined.js';
|
|
5
|
-
export * from './errors/index.js';
|
|
6
|
-
export * from './Instantiable.abstract.js';
|
|
7
|
-
// Utils
|
|
8
|
-
export * from './utils/index.js';
|
|
@@ -1,123 +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
|
-
/**
|
|
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 | bigint, 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
|
|
@@ -1 +0,0 @@
|
|
|
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,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,qBAAa,gBAAiB,YAAW,UAAU;IACjD;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;IACnC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;IAE3B,eAAe,EAAE,cAAc,CAAA;IAC/B,cAAc,EAAE,OAAO,GAAG,YAAY,CAAA;IAEtC,OAAO;IAMP;;;;;;OAMG;WACiB,QAAQ,CAC1B,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,OAAO,GAAG,YAAY,EACrC,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,iBAAiB,EAAE,KAAK,MAAM,EAAE,EAChC,cAAc,GAAE,MAAM,GAAG,MAAa,EACtC,OAAO,SAAM,GACZ,OAAO,CAAC,gBAAgB,CAAC;IA8Bf,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAWxD,eAAe,IAAI,kBAAkB;IAiB5C;;;OAGG;IACI,SAAS,IAAI,MAAM;IAI1B;;;OAGG;IACI,QAAQ,IAAI,MAAM;IAUzB;;;;;OAKG;IACU,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;WAYvB,OAAO,CACnB,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,OAAO,GAAG,YAAY,GACpC,gBAAgB;IAWnB;;;;OAIG;WACW,SAAS,CAAC,GAAG,EAAE,MAAM;IAInC;;;OAGG;IACI,IAAI;IAIX;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM;CAG/B"}
|
|
@@ -1,164 +0,0 @@
|
|
|
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: typeof agentId === 'bigint' ? agentId.toString() : 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
|
-
}
|
package/dist/models/Logger.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Logger as PinoLogger } from 'pino';
|
|
2
|
-
export type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent';
|
|
3
|
-
export interface LoggerConfig {
|
|
4
|
-
level?: LogLevel;
|
|
5
|
-
pretty?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare const createLogger: (config?: LoggerConfig) => PinoLogger<never, boolean>;
|
|
8
|
-
export declare const LoggerInstance: () => PinoLogger;
|
|
9
|
-
//# sourceMappingURL=Logger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/models/Logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,IAAI,UAAU,EAAE,MAAM,MAAM,CAAA;AAEjD,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAA;AAEzF,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAID,eAAO,MAAM,YAAY,GAAI,SAAQ,YAAiB,+BAgBrD,CAAA;AAED,eAAO,MAAM,cAAc,kBAQ1B,CAAA"}
|
package/dist/models/Logger.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { pino } from 'pino';
|
|
2
|
-
let loggerInstance;
|
|
3
|
-
export const createLogger = (config = {}) => {
|
|
4
|
-
const { level = 'info', pretty = false } = config;
|
|
5
|
-
return pino({
|
|
6
|
-
level,
|
|
7
|
-
transport: pretty
|
|
8
|
-
? {
|
|
9
|
-
target: 'pino-pretty',
|
|
10
|
-
options: {
|
|
11
|
-
colorize: true,
|
|
12
|
-
translateTime: 'HH:MM:ss',
|
|
13
|
-
ignore: 'pid,hostname',
|
|
14
|
-
},
|
|
15
|
-
}
|
|
16
|
-
: undefined,
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
export const LoggerInstance = () => {
|
|
20
|
-
if (!loggerInstance) {
|
|
21
|
-
loggerInstance = createLogger({
|
|
22
|
-
level: 'debug',
|
|
23
|
-
pretty: true,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return loggerInstance;
|
|
27
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Account } from 'viem';
|
|
2
|
-
export declare class NeverminedOptions {
|
|
3
|
-
chainId: number;
|
|
4
|
-
/**
|
|
5
|
-
* Ethereum Web3 Provider URL. This Url allows the SDK to connect to a blockchain.
|
|
6
|
-
* This provider depends on the network where you want to connect (Ethereum Mainnet, Rinkeby, Polygon Matic, etc).
|
|
7
|
-
* It's possible to use a public available provider or a private/paid one like Infura, Alchemy, etc.
|
|
8
|
-
*/
|
|
9
|
-
web3ProviderUri?: string;
|
|
10
|
-
/**
|
|
11
|
-
* The Nevermined App URL.
|
|
12
|
-
*/
|
|
13
|
-
appUrl?: string;
|
|
14
|
-
backendUrl?: string;
|
|
15
|
-
agentsProxy?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Log level.
|
|
18
|
-
*/
|
|
19
|
-
logLevel: string;
|
|
20
|
-
accounts?: Account[];
|
|
21
|
-
/**
|
|
22
|
-
* ZeroDev project id
|
|
23
|
-
*/
|
|
24
|
-
zeroDevProjectId?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Contracts version
|
|
27
|
-
*/
|
|
28
|
-
contractsVersion?: string;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=NeverminedOptions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;IAEjB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;IAE3B;;OAEG;IACI,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEhC;;OAEG;IACI,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACjC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export class NeverminedOptions {
|
|
2
|
-
chainId;
|
|
3
|
-
/**
|
|
4
|
-
* Ethereum Web3 Provider URL. This Url allows the SDK to connect to a blockchain.
|
|
5
|
-
* This provider depends on the network where you want to connect (Ethereum Mainnet, Rinkeby, Polygon Matic, etc).
|
|
6
|
-
* It's possible to use a public available provider or a private/paid one like Infura, Alchemy, etc.
|
|
7
|
-
*/
|
|
8
|
-
web3ProviderUri;
|
|
9
|
-
/**
|
|
10
|
-
* The Nevermined App URL.
|
|
11
|
-
*/
|
|
12
|
-
appUrl;
|
|
13
|
-
backendUrl;
|
|
14
|
-
agentsProxy;
|
|
15
|
-
/**
|
|
16
|
-
* Log level.
|
|
17
|
-
*/
|
|
18
|
-
logLevel = 'info';
|
|
19
|
-
accounts;
|
|
20
|
-
/**
|
|
21
|
-
* ZeroDev project id
|
|
22
|
-
*/
|
|
23
|
-
zeroDevProjectId;
|
|
24
|
-
/**
|
|
25
|
-
* Contracts version
|
|
26
|
-
*/
|
|
27
|
-
contractsVersion;
|
|
28
|
-
}
|
|
@@ -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"}
|