@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/models/NvmApiKey.js
DELETED
|
@@ -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 {};
|
package/dist/models/index.d.ts
DELETED
|
@@ -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"}
|
package/dist/models/index.js
DELETED
|
@@ -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;IAOV,mBAAmB,CAC9B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,OAAO,GAAG,YAAY,GAC3B,OAAO,CAAC,WAAW,CAAC;YAKT,gBAAgB;CAsH/B"}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { PlanTransactionPaymentType } from '@nvm-monorepo/commons';
|
|
2
|
-
import { isAddress, parseAbi, zeroAddress } from 'viem';
|
|
3
|
-
import { NotEnoughBalance } from '../../errors/NeverminedErrors.js';
|
|
4
|
-
import { Instantiable } from '../../Instantiable.abstract.js';
|
|
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
|
-
]);
|
|
9
|
-
export class PaymentsApi extends Instantiable {
|
|
10
|
-
/**
|
|
11
|
-
* Creates a new PaymentsApi
|
|
12
|
-
* @param config - Configuration of the Nevermined instance
|
|
13
|
-
* @returns {@link PaymentsApi}
|
|
14
|
-
*/
|
|
15
|
-
constructor(config) {
|
|
16
|
-
super();
|
|
17
|
-
this.setInstanceConfig(config);
|
|
18
|
-
}
|
|
19
|
-
async getERC20Balance(userAddress, tokenAddress) {
|
|
20
|
-
try {
|
|
21
|
-
return this.client.public.readContract({
|
|
22
|
-
address: tokenAddress,
|
|
23
|
-
abi: TOKEN_BALANCE_ABI,
|
|
24
|
-
functionName: 'balanceOf',
|
|
25
|
-
args: [userAddress],
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
this.logger.debug(`Error fetching ERC20 balance for ${userAddress} in ${tokenAddress}: ${error}`);
|
|
30
|
-
}
|
|
31
|
-
return 0n;
|
|
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 feeReceiver = await this.nevermined.contracts.nvmConfig.getFeeReceiver();
|
|
52
|
-
let amountToReward = 0n;
|
|
53
|
-
plan.price.receivers.map((r, i) => {
|
|
54
|
-
if (r.toLowerCase() !== feeReceiver.toLowerCase()) {
|
|
55
|
-
amountToReward += plan.price.amounts[i];
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
const totalAmount = plan.price.amounts.reduce((a, b) => a + b, 0n);
|
|
59
|
-
return {
|
|
60
|
-
cryptoFeeRate: result[0],
|
|
61
|
-
fiatFeeRate: result[1],
|
|
62
|
-
feeDenominator: result[2],
|
|
63
|
-
ownerAmount: amountToReward,
|
|
64
|
-
totalAmount,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
this.logger.error(`Error fetching plan fee for planId ${planId}: ${String(error)}`);
|
|
69
|
-
throw error;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
async orderFiatPayment(planId, planReceiver, from, numberOfPurchases = 1n) {
|
|
73
|
-
const plan = await this.nevermined.contracts.assetRegistry.getPlan(planId);
|
|
74
|
-
const totalAmount = plan.price.amounts.reduce((a, b) => a + b, 0n);
|
|
75
|
-
this.logger.info(`Ordering fiat payment for planId ${planId} to ${planReceiver} from account ${from.address} `);
|
|
76
|
-
const txHash = await this.nevermined.contracts.fiatPaymentTemplate.order(planId, planReceiver, from, numberOfPurchases);
|
|
77
|
-
const txReceipt = await this.nevermined.contracts.assetRegistry.getTransactionReceipt(txHash);
|
|
78
|
-
return {
|
|
79
|
-
txHash: txReceipt.transactionHash,
|
|
80
|
-
planId,
|
|
81
|
-
planReceiver: from.address,
|
|
82
|
-
totalAmount,
|
|
83
|
-
numCredits: plan.credits.amount,
|
|
84
|
-
paymentMethod: PlanTransactionPaymentType.Fiat,
|
|
85
|
-
currency: 'USD',
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
async orderCryptoPlan(planId, plan, from, planReceiver, numberOfPurchases = 1n) {
|
|
89
|
-
this.logger.debug(`Setting up Fixed Payment order...`);
|
|
90
|
-
return this._orderCryptoPlan(planId, plan, from, 'fixed', planReceiver, numberOfPurchases);
|
|
91
|
-
}
|
|
92
|
-
// simulateCreditsRedemption
|
|
93
|
-
async orderPayAsYouGoPlan(planId, plan, from) {
|
|
94
|
-
this.logger.debug(`Setting up Pay-As-You-Go order...`);
|
|
95
|
-
return this._orderCryptoPlan(planId, plan, from, 'payAsYouGo');
|
|
96
|
-
}
|
|
97
|
-
async _orderCryptoPlan(planId, plan, from, planType, planReceiver, numberOfPurchases = 1n) {
|
|
98
|
-
try {
|
|
99
|
-
// const plan = await this.nevermined.contracts.assetRegistry.getPlan(planId)
|
|
100
|
-
const tokenAddress = plan.price.tokenAddress;
|
|
101
|
-
const totalAmount = plan.price.amounts.reduce((a, b) => a + b, 0n) * numberOfPurchases;
|
|
102
|
-
this.logger.debug(`Ordering ${tokenAddress} ${totalAmount}`);
|
|
103
|
-
let txHash;
|
|
104
|
-
if (tokenAddress && tokenAddress !== zeroAddress) {
|
|
105
|
-
this.logger.debug(`Processing ERC20 payment...`);
|
|
106
|
-
// ERC20 token payment
|
|
107
|
-
if (totalAmount > 0n) {
|
|
108
|
-
const erc20Balance = await this.getERC20Balance(from.address, tokenAddress);
|
|
109
|
-
this.logger.debug(`ERC20 balance for ${from.address} in ${tokenAddress}: balance = ${erc20Balance} - total amount = ${totalAmount}`);
|
|
110
|
-
if (erc20Balance < totalAmount) {
|
|
111
|
-
throw new NotEnoughBalance(`Insufficient balance (${erc20Balance} < ${totalAmount}) for ERC20 ${tokenAddress}`);
|
|
112
|
-
}
|
|
113
|
-
if (planType === 'payAsYouGo') {
|
|
114
|
-
txHash = await this.nevermined.contracts.payAsYouGoTemplate.orderWithApprovals(planId, totalAmount, tokenAddress, from);
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
txHash = await this.nevermined.contracts.fixedPaymentTemplate.orderWithApprovals(planId, totalAmount, tokenAddress, from, planReceiver || from.address, numberOfPurchases);
|
|
118
|
-
}
|
|
119
|
-
this.logger.debug(`Token approved + Agreement Created: ${txHash}`);
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
if (planType === 'payAsYouGo') {
|
|
123
|
-
txHash = await this.nevermined.contracts.payAsYouGoTemplate.order(planId, from);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
txHash = await this.nevermined.contracts.fixedPaymentTemplate.order(planId, from, planReceiver || from.address);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
if (!txHash) {
|
|
130
|
-
this.logger.error('Error in PaymentsApi order method: txHash not defined');
|
|
131
|
-
throw new Error('txHash not defined');
|
|
132
|
-
}
|
|
133
|
-
const txReceipt = await this.nevermined.contracts.assetRegistry.getTransactionReceipt(txHash);
|
|
134
|
-
return {
|
|
135
|
-
txHash: txReceipt.transactionHash,
|
|
136
|
-
planId,
|
|
137
|
-
planReceiver: from.address,
|
|
138
|
-
totalAmount,
|
|
139
|
-
numCredits: plan.credits.amount * numberOfPurchases,
|
|
140
|
-
paymentMethod: PlanTransactionPaymentType.Crypto,
|
|
141
|
-
currency: 'USDC',
|
|
142
|
-
tokenAddress,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
// Native token payment
|
|
147
|
-
const nativeTokenBalance = await this.client.public.getBalance({ address: from.address });
|
|
148
|
-
if (nativeTokenBalance < totalAmount) {
|
|
149
|
-
throw new NotEnoughBalance(`Insufficient balance (${nativeTokenBalance} < ${totalAmount}) for native token payment`);
|
|
150
|
-
}
|
|
151
|
-
if (planType === 'payAsYouGo') {
|
|
152
|
-
txHash = await this.nevermined.contracts.payAsYouGoTemplate.order(planId, from, {
|
|
153
|
-
value: totalAmount,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
txHash = await this.nevermined.contracts.fixedPaymentTemplate.order(planId, from, planReceiver || from.address, numberOfPurchases, {
|
|
158
|
-
value: totalAmount,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
const txReceipt = await this.nevermined.contracts.assetRegistry.getTransactionReceipt(txHash);
|
|
162
|
-
return {
|
|
163
|
-
txHash: txReceipt.transactionHash,
|
|
164
|
-
planId,
|
|
165
|
-
planReceiver: from.address,
|
|
166
|
-
totalAmount,
|
|
167
|
-
numCredits: plan.credits.amount * numberOfPurchases,
|
|
168
|
-
paymentMethod: PlanTransactionPaymentType.Crypto,
|
|
169
|
-
currency: 'Native',
|
|
170
|
-
tokenAddress: zeroAddress,
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
catch (error) {
|
|
175
|
-
this.logger.error(`Error in PaymentsApi order method: ${String(error)}`);
|
|
176
|
-
throw error;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Instantiable, InstantiableConfig } from '../../Instantiable.abstract.js';
|
|
2
|
-
import { Api } from '../../services/Api.js';
|
|
3
|
-
import { Profiles } from '../../services/Profiles.js';
|
|
4
|
-
/**
|
|
5
|
-
* Utils internal submodule of Nevermined.
|
|
6
|
-
*/
|
|
7
|
-
export declare class ServicesApi extends Instantiable {
|
|
8
|
-
/**
|
|
9
|
-
* Nevermined Node Service
|
|
10
|
-
*/
|
|
11
|
-
api: Api;
|
|
12
|
-
/**
|
|
13
|
-
* Profiles instance
|
|
14
|
-
*/
|
|
15
|
-
profiles: Profiles;
|
|
16
|
-
/**
|
|
17
|
-
* Creates a new ServicesApi
|
|
18
|
-
* @param config - Configuration of the Nevermined instance
|
|
19
|
-
* @returns {@link ServicesApi}
|
|
20
|
-
*/
|
|
21
|
-
constructor(config: InstantiableConfig);
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=ServicesApi.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ServicesApi.d.ts","sourceRoot":"","sources":["../../../src/nevermined/api/ServicesApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACjF,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAErD;;GAEG;AACH,qBAAa,WAAY,SAAQ,YAAY;IAC3C;;OAEG;IACI,GAAG,EAAE,GAAG,CAAA;IAEf;;OAEG;IACI,QAAQ,EAAE,QAAQ,CAAA;IAEzB;;;;OAIG;gBACS,MAAM,EAAE,kBAAkB;CAOvC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Instantiable } from '../../Instantiable.abstract.js';
|
|
2
|
-
import { Api } from '../../services/Api.js';
|
|
3
|
-
import { Profiles } from '../../services/Profiles.js';
|
|
4
|
-
/**
|
|
5
|
-
* Utils internal submodule of Nevermined.
|
|
6
|
-
*/
|
|
7
|
-
export class ServicesApi extends Instantiable {
|
|
8
|
-
/**
|
|
9
|
-
* Nevermined Node Service
|
|
10
|
-
*/
|
|
11
|
-
api;
|
|
12
|
-
/**
|
|
13
|
-
* Profiles instance
|
|
14
|
-
*/
|
|
15
|
-
profiles;
|
|
16
|
-
/**
|
|
17
|
-
* Creates a new ServicesApi
|
|
18
|
-
* @param config - Configuration of the Nevermined instance
|
|
19
|
-
* @returns {@link ServicesApi}
|
|
20
|
-
*/
|
|
21
|
-
constructor(config) {
|
|
22
|
-
super();
|
|
23
|
-
this.setInstanceConfig(config);
|
|
24
|
-
this.api = new Api(config);
|
|
25
|
-
this.profiles = new Profiles(config);
|
|
26
|
-
}
|
|
27
|
-
}
|