@nevermined-io/core-kit 0.4.5 → 0.5.1

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 (105) hide show
  1. package/dist/Instantiable.abstract.js +15 -13
  2. package/dist/Instantiable.abstract.js.map +1 -0
  3. package/dist/artifacts/generated.d.ts +174 -40
  4. package/dist/artifacts/generated.d.ts.map +1 -1
  5. package/dist/artifacts/generated.js +22805 -7111
  6. package/dist/artifacts/generated.js.map +1 -0
  7. package/dist/contracts/AccessManager.js +12 -3
  8. package/dist/contracts/AccessManager.js.map +1 -0
  9. package/dist/contracts/AssetRegistry.d.ts +1 -0
  10. package/dist/contracts/AssetRegistry.d.ts.map +1 -1
  11. package/dist/contracts/AssetRegistry.js +134 -69
  12. package/dist/contracts/AssetRegistry.js.map +1 -0
  13. package/dist/contracts/ContractBase.d.ts.map +1 -1
  14. package/dist/contracts/ContractBase.js +173 -140
  15. package/dist/contracts/ContractBase.js.map +1 -0
  16. package/dist/contracts/ContractsApi.js +6 -54
  17. package/dist/contracts/ContractsApi.js.map +1 -0
  18. package/dist/contracts/CryptoTemplateBase.js +23 -11
  19. package/dist/contracts/CryptoTemplateBase.js.map +1 -0
  20. package/dist/contracts/FiatPaymentTemplate.js +9 -1
  21. package/dist/contracts/FiatPaymentTemplate.js.map +1 -0
  22. package/dist/contracts/FiatSettlementCondition.js +8 -1
  23. package/dist/contracts/FiatSettlementCondition.js.map +1 -0
  24. package/dist/contracts/FixedPaymentTemplate.js +42 -10
  25. package/dist/contracts/FixedPaymentTemplate.js.map +1 -0
  26. package/dist/contracts/NFT1155Base.js +48 -12
  27. package/dist/contracts/NFT1155Base.js.map +1 -0
  28. package/dist/contracts/NFT1155Credits.js +2 -0
  29. package/dist/contracts/NFT1155Credits.js.map +1 -0
  30. package/dist/contracts/NFT1155ExpirableCredits.js +26 -6
  31. package/dist/contracts/NFT1155ExpirableCredits.js.map +1 -0
  32. package/dist/contracts/NVMConfig.js +2 -0
  33. package/dist/contracts/NVMConfig.js.map +1 -0
  34. package/dist/contracts/PayAsYouGoTemplate.js +36 -10
  35. package/dist/contracts/PayAsYouGoTemplate.js.map +1 -0
  36. package/dist/contracts/ProtocolStandardFees.js +7 -1
  37. package/dist/contracts/ProtocolStandardFees.js.map +1 -0
  38. package/dist/contracts/Roles.js +2 -0
  39. package/dist/contracts/Roles.js.map +1 -0
  40. package/dist/contracts/index.js +2 -0
  41. package/dist/contracts/index.js.map +1 -0
  42. package/dist/errors/NeverminedErrors.js +27 -26
  43. package/dist/errors/NeverminedErrors.js.map +1 -0
  44. package/dist/errors/index.js +2 -0
  45. package/dist/errors/index.js.map +1 -0
  46. package/dist/index.js +2 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/models/AgentX402AccessToken.js +78 -46
  49. package/dist/models/AgentX402AccessToken.js.map +1 -0
  50. package/dist/models/Logger.js +12 -12
  51. package/dist/models/Logger.js.map +1 -0
  52. package/dist/models/NeverminedOptions.d.ts +3 -3
  53. package/dist/models/NeverminedOptions.d.ts.map +1 -1
  54. package/dist/models/NeverminedOptions.js +3 -28
  55. package/dist/models/NeverminedOptions.js.map +1 -0
  56. package/dist/models/NvmApiKey.js +96 -147
  57. package/dist/models/NvmApiKey.js.map +1 -0
  58. package/dist/models/Transactions.js +3 -1
  59. package/dist/models/Transactions.js.map +1 -0
  60. package/dist/models/index.js +2 -0
  61. package/dist/models/index.js.map +1 -0
  62. package/dist/nevermined/Nevermined.js +20 -42
  63. package/dist/nevermined/Nevermined.js.map +1 -0
  64. package/dist/nevermined/api/PaymentsApi.js +38 -43
  65. package/dist/nevermined/api/PaymentsApi.js.map +1 -0
  66. package/dist/nevermined/api/ServicesApi.js +7 -15
  67. package/dist/nevermined/api/ServicesApi.js.map +1 -0
  68. package/dist/nevermined/api/UtilsApi.js +7 -19
  69. package/dist/nevermined/api/UtilsApi.js.map +1 -0
  70. package/dist/nevermined/index.js +2 -0
  71. package/dist/nevermined/index.js.map +1 -0
  72. package/dist/nevermined/utils/AgentUtils.js +25 -23
  73. package/dist/nevermined/utils/AgentUtils.js.map +1 -0
  74. package/dist/nevermined/utils/AnvilHelpers.js +34 -19
  75. package/dist/nevermined/utils/AnvilHelpers.js.map +1 -0
  76. package/dist/nevermined/utils/BlockchainViemUtils.d.ts +4 -4
  77. package/dist/nevermined/utils/BlockchainViemUtils.js +102 -108
  78. package/dist/nevermined/utils/BlockchainViemUtils.js.map +1 -0
  79. package/dist/nevermined/utils/JwtUtils.js +33 -28
  80. package/dist/nevermined/utils/JwtUtils.js.map +1 -0
  81. package/dist/nevermined/utils/SignatureUtils.js +23 -27
  82. package/dist/nevermined/utils/SignatureUtils.js.map +1 -0
  83. package/dist/nevermined/utils/WebServiceConnector.js +18 -20
  84. package/dist/nevermined/utils/WebServiceConnector.js.map +1 -0
  85. package/dist/nevermined/utils/ZeroDevPolicies.js +115 -75
  86. package/dist/nevermined/utils/ZeroDevPolicies.js.map +1 -0
  87. package/dist/nevermined/utils/index.js +2 -0
  88. package/dist/nevermined/utils/index.js.map +1 -0
  89. package/dist/services/Api.js +11 -5
  90. package/dist/services/Api.js.map +1 -0
  91. package/dist/services/Profiles.js +15 -20
  92. package/dist/services/Profiles.js.map +1 -0
  93. package/dist/services/index.js +2 -0
  94. package/dist/services/index.js.map +1 -0
  95. package/dist/utils/ConversionTypeHelpers.js +13 -6
  96. package/dist/utils/ConversionTypeHelpers.js.map +1 -0
  97. package/dist/utils/DeploymentInfo.js +12 -7
  98. package/dist/utils/DeploymentInfo.js.map +1 -0
  99. package/dist/utils/Network.js +27 -19
  100. package/dist/utils/Network.js.map +1 -0
  101. package/dist/utils/helpers.js +42 -31
  102. package/dist/utils/helpers.js.map +1 -0
  103. package/dist/utils/index.js +2 -0
  104. package/dist/utils/index.js.map +1 -0
  105. package/package.json +17 -1
@@ -6,7 +6,6 @@ import { urlSafeBase64Decode, urlSafeBase64Encode } from '../../utils/helpers.js
6
6
  import { getChecksumAddress } from './BlockchainViemUtils.js';
7
7
  import { SignatureUtils } from './SignatureUtils.js';
8
8
  export class EthSignJWT extends SignJWT {
9
- protectedHeader;
10
9
  setProtectedHeader(protectedHeader) {
11
10
  this.protectedHeader = protectedHeader;
12
11
  return this;
@@ -18,7 +17,7 @@ export class EthSignJWT extends SignJWT {
18
17
  if (eip712Data) {
19
18
  payload = {
20
19
  ...payload,
21
- eip712Data,
20
+ eip712Data
22
21
  };
23
22
  }
24
23
  const encodedPayload = encoder.encode(this.base64url(JSON.stringify(payload)));
@@ -30,23 +29,31 @@ export class EthSignJWT extends SignJWT {
30
29
  const domain = {
31
30
  name: 'Nevermined',
32
31
  version: '1',
33
- chainId: eip712Data.chainId,
32
+ chainId: eip712Data.chainId
34
33
  };
35
34
  const types = {
36
35
  Nevermined: [
37
- { name: 'from', type: 'address' },
38
- { name: 'message', type: 'string' },
39
- { name: 'token', type: 'string' },
40
- ],
36
+ {
37
+ name: 'from',
38
+ type: 'address'
39
+ },
40
+ {
41
+ name: 'message',
42
+ type: 'string'
43
+ },
44
+ {
45
+ name: 'token',
46
+ type: 'string'
47
+ }
48
+ ]
41
49
  };
42
50
  const value = {
43
51
  from: account.address,
44
52
  message: eip712Data.message,
45
- token: decoder.decode(data),
53
+ token: decoder.decode(data)
46
54
  };
47
55
  sign = await signatureUtils.signTypedData(domain, types, value, account);
48
- }
49
- else {
56
+ } else {
50
57
  sign = await signatureUtils.signText(decoder.decode(data), account);
51
58
  }
52
59
  const input = hexToBytes(sign);
@@ -58,10 +65,9 @@ export class EthSignJWT extends SignJWT {
58
65
  try {
59
66
  const message = typeof text === 'string' ? text : toHex(text);
60
67
  return account.signMessage({
61
- message: message,
68
+ message: message
62
69
  });
63
- }
64
- catch (e) {
70
+ } catch (e) {
65
71
  console.error('Error signing message:', e);
66
72
  return undefined;
67
73
  }
@@ -71,10 +77,10 @@ export class EthSignJWT extends SignJWT {
71
77
  return buffer.toString('base64').replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
72
78
  }
73
79
  concat(...buffers) {
74
- const size = buffers.reduce((acc, { length }) => acc + length, 0);
80
+ const size = buffers.reduce((acc, { length })=>acc + length, 0);
75
81
  const buf = new Uint8Array(size);
76
82
  let i = 0;
77
- buffers.forEach((buffer) => {
83
+ buffers.forEach((buffer)=>{
78
84
  buf.set(buffer, i);
79
85
  i += buffer.length;
80
86
  });
@@ -82,11 +88,10 @@ export class EthSignJWT extends SignJWT {
82
88
  }
83
89
  }
84
90
  export class JwtUtils extends Instantiable {
85
- static CLIENT_ASSERTION_TYPE = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';
86
- // BASE_AUD = '/api/v1/node/services'
87
- tokenCache;
88
- signatureUtils;
89
- constructor(config) {
91
+ static{
92
+ this.CLIENT_ASSERTION_TYPE = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';
93
+ }
94
+ constructor(config){
90
95
  super();
91
96
  this.setInstanceConfig(config);
92
97
  this.tokenCache = new Map();
@@ -110,7 +115,7 @@ export class JwtUtils extends Instantiable {
110
115
  kty: 'EC',
111
116
  d: privateKey.toString('base64'),
112
117
  x: publicKey.slice(0, 32).toString('base64'),
113
- y: publicKey.slice(32, 64).toString('base64'),
118
+ y: publicKey.slice(32, 64).toString('base64')
114
119
  });
115
120
  }
116
121
  async generateClientAssertion(account, message) {
@@ -118,7 +123,7 @@ export class JwtUtils extends Instantiable {
118
123
  if (message) {
119
124
  eip712Data = {
120
125
  message,
121
- chainId: await this.publicClient.getChainId(),
126
+ chainId: await this.publicClient.getChainId()
122
127
  };
123
128
  }
124
129
  const address = getChecksumAddress(account.address);
@@ -130,12 +135,10 @@ export class JwtUtils extends Instantiable {
130
135
  return new EthSignJWT({
131
136
  iss: address,
132
137
  // roles: isAdmin[0] ? ['admin'] : [],
133
- roles: [],
134
- })
135
- .setProtectedHeader({ alg: 'ES256K' })
136
- .setIssuedAt()
137
- .setExpirationTime('1h')
138
- .ethSign(this.signatureUtils, account, eip712Data);
138
+ roles: []
139
+ }).setProtectedHeader({
140
+ alg: 'ES256K'
141
+ }).setIssuedAt().setExpirationTime('1h').ethSign(this.signatureUtils, account, eip712Data);
139
142
  }
140
143
  isTokenValid(token) {
141
144
  const decodedToken = decodeJwt(token);
@@ -159,3 +162,5 @@ export class JwtUtils extends Instantiable {
159
162
  return new TextDecoder().decode(decompressed);
160
163
  }
161
164
  }
165
+
166
+ //# sourceMappingURL=JwtUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/nevermined/utils/JwtUtils.ts"],"sourcesContent":["import type { Eip712Data } from '@nevermined-io/commons'\nimport { deflateSync, inflateSync } from 'fflate'\nimport { type JWSHeaderParameters, SignJWT, decodeJwt, importJWK } from 'jose'\nimport { type Account, type Hash, type LocalAccount, hexToBytes, toHex } from 'viem'\nimport { SmartAccount } from 'viem/account-abstraction'\nimport { Instantiable, InstantiableConfig } from '../../Instantiable.abstract.js'\nimport { urlSafeBase64Decode, urlSafeBase64Encode } from '../../utils/helpers.js'\nimport { getChecksumAddress } from './BlockchainViemUtils.js'\nimport { SignatureUtils } from './SignatureUtils.js'\n\nexport class EthSignJWT extends SignJWT {\n protectedHeader: JWSHeaderParameters | undefined\n\n override setProtectedHeader(protectedHeader: JWSHeaderParameters) {\n this.protectedHeader = protectedHeader\n return this\n }\n\n public async ethSign(\n signatureUtils: SignatureUtils,\n account: Account | SmartAccount,\n eip712Data?: Eip712Data,\n ): Promise<string> {\n const encoder = new TextEncoder()\n const decoder = new TextDecoder()\n\n let payload = this._payload\n if (eip712Data) {\n payload = {\n ...payload,\n eip712Data,\n }\n }\n\n const encodedPayload = encoder.encode(this.base64url(JSON.stringify(payload)))\n const encodedHeader = encoder.encode(this.base64url(JSON.stringify(this.protectedHeader)))\n const data = this.concat(encodedHeader, encoder.encode('.'), encodedPayload)\n\n // EIP-712 signature\n let sign: Hash\n if (eip712Data) {\n const domain = {\n name: 'Nevermined',\n version: '1',\n chainId: eip712Data.chainId,\n }\n\n const types = {\n Nevermined: [\n { name: 'from', type: 'address' },\n { name: 'message', type: 'string' },\n { name: 'token', type: 'string' },\n ],\n }\n\n const value = {\n from: account.address,\n message: eip712Data.message,\n token: decoder.decode(data),\n }\n\n sign = await signatureUtils.signTypedData(domain, types, value, account)\n } else {\n sign = await signatureUtils.signText(decoder.decode(data), account)\n }\n const input = hexToBytes(sign)\n\n const signed = this.base64url(input)\n const grantToken = `${decoder.decode(encodedHeader)}.${decoder.decode(\n encodedPayload,\n )}.${signed}`\n return grantToken\n }\n\n public static async signText(\n text: string | Uint8Array,\n account: Account,\n ): Promise<string | undefined> {\n try {\n const message = typeof text === 'string' ? text : toHex(text)\n return (account as LocalAccount).signMessage({\n message: message as `0x${string}`,\n })\n } catch (e) {\n console.error('Error signing message:', e)\n return undefined\n }\n }\n\n private base64url(input: Uint8Array | string): string {\n const buffer = typeof input === 'string' ? Buffer.from(input, 'utf-8') : Buffer.from(input)\n return buffer.toString('base64').replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_')\n }\n\n private concat(...buffers: Uint8Array[]): Uint8Array {\n const size = buffers.reduce((acc, { length }) => acc + length, 0)\n const buf = new Uint8Array(size)\n let i = 0\n buffers.forEach((buffer) => {\n buf.set(buffer, i)\n i += buffer.length\n })\n return buf\n }\n}\n\nexport class JwtUtils extends Instantiable {\n static CLIENT_ASSERTION_TYPE = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer'\n // BASE_AUD = '/api/v1/node/services'\n\n tokenCache: Map<string, string>\n signatureUtils: SignatureUtils\n\n constructor(config: InstantiableConfig) {\n super()\n this.setInstanceConfig(config)\n this.tokenCache = new Map()\n this.signatureUtils = new SignatureUtils(config)\n }\n\n public generateCacheKey(...args: string[]): string {\n return args.join()\n }\n\n public async accountToJwk(account: Account | SmartAccount): Promise<any> {\n const address = account.address.toLowerCase()\n\n // Currently only works with HDWalletProvider\n // eslint-disable-next-line\n // @ts-ignore\n const publicKey = this.web3.currentProvider.wallets[address].getPublicKey()\n // eslint-disable-next-line\n // @ts-ignore\n const privateKey = this.web3.currentProvider.wallets[address].getPrivateKey()\n\n return importJWK({\n alg: 'ES256K',\n crv: 'secp256k1',\n kty: 'EC',\n d: privateKey.toString('base64'),\n x: publicKey.slice(0, 32).toString('base64'),\n y: publicKey.slice(32, 64).toString('base64'),\n })\n }\n\n public async generateClientAssertion(account: Account | SmartAccount, message?: string) {\n let eip712Data\n if (message) {\n eip712Data = {\n message,\n chainId: await this.publicClient.getChainId(),\n }\n }\n const address = getChecksumAddress(account.address)\n\n // Not need it, but stay commented. If we need to bring back roles to update endpoints based on wallet with roles.\n // const isAdmin = await this.nevermined.contracts.accessManager.hasRole(\n // NVM_INFRA_ADMIN_ROLE,\n // address as Address,\n // )\n\n return new EthSignJWT({\n iss: address,\n // roles: isAdmin[0] ? ['admin'] : [],\n roles: [],\n })\n .setProtectedHeader({ alg: 'ES256K' })\n .setIssuedAt()\n .setExpirationTime('1h')\n .ethSign(this.signatureUtils, account, eip712Data)\n }\n\n public isTokenValid(token: string): boolean {\n const decodedToken = decodeJwt(token)\n if (!decodedToken) {\n return false\n }\n const expiry = decodedToken.exp\n if (expiry) {\n const now = new Date()\n return now.getTime() < Number(expiry) * 1000\n }\n\n return false\n }\n\n static createCompressedJwt(token: string) {\n const compressed = deflateSync(new TextEncoder().encode(token))\n return urlSafeBase64Encode(compressed)\n }\n\n static decompressJwt(compressedJwt: string) {\n const decoded = urlSafeBase64Decode(compressedJwt)\n const decompressed = inflateSync(decoded)\n return new TextDecoder().decode(decompressed)\n }\n}\n"],"names":["deflateSync","inflateSync","SignJWT","decodeJwt","importJWK","hexToBytes","toHex","Instantiable","urlSafeBase64Decode","urlSafeBase64Encode","getChecksumAddress","SignatureUtils","EthSignJWT","setProtectedHeader","protectedHeader","ethSign","signatureUtils","account","eip712Data","encoder","TextEncoder","decoder","TextDecoder","payload","_payload","encodedPayload","encode","base64url","JSON","stringify","encodedHeader","data","concat","sign","domain","name","version","chainId","types","Nevermined","type","value","from","address","message","token","decode","signTypedData","signText","input","signed","grantToken","text","signMessage","e","console","error","undefined","buffer","Buffer","toString","replace","buffers","size","reduce","acc","length","buf","Uint8Array","i","forEach","set","JwtUtils","CLIENT_ASSERTION_TYPE","config","setInstanceConfig","tokenCache","Map","generateCacheKey","args","join","accountToJwk","toLowerCase","publicKey","web3","currentProvider","wallets","getPublicKey","privateKey","getPrivateKey","alg","crv","kty","d","x","slice","y","generateClientAssertion","publicClient","getChainId","iss","roles","setIssuedAt","setExpirationTime","isTokenValid","decodedToken","expiry","exp","now","Date","getTime","Number","createCompressedJwt","compressed","decompressJwt","compressedJwt","decoded","decompressed"],"mappings":"AACA,SAASA,WAAW,EAAEC,WAAW,QAAQ,SAAQ;AACjD,SAAmCC,OAAO,EAAEC,SAAS,EAAEC,SAAS,QAAQ,OAAM;AAC9E,SAAqDC,UAAU,EAAEC,KAAK,QAAQ,OAAM;AAEpF,SAASC,YAAY,QAA4B,iCAAgC;AACjF,SAASC,mBAAmB,EAAEC,mBAAmB,QAAQ,yBAAwB;AACjF,SAASC,kBAAkB,QAAQ,2BAA0B;AAC7D,SAASC,cAAc,QAAQ,sBAAqB;AAEpD,OAAO,MAAMC,mBAAmBV;IAGrBW,mBAAmBC,eAAoC,EAAE;QAChE,IAAI,CAACA,eAAe,GAAGA;QACvB,OAAO,IAAI;IACb;IAEA,MAAaC,QACXC,cAA8B,EAC9BC,OAA+B,EAC/BC,UAAuB,EACN;QACjB,MAAMC,UAAU,IAAIC;QACpB,MAAMC,UAAU,IAAIC;QAEpB,IAAIC,UAAU,IAAI,CAACC,QAAQ;QAC3B,IAAIN,YAAY;YACdK,UAAU;gBACR,GAAGA,OAAO;gBACVL;YACF;QACF;QAEA,MAAMO,iBAAiBN,QAAQO,MAAM,CAAC,IAAI,CAACC,SAAS,CAACC,KAAKC,SAAS,CAACN;QACpE,MAAMO,gBAAgBX,QAAQO,MAAM,CAAC,IAAI,CAACC,SAAS,CAACC,KAAKC,SAAS,CAAC,IAAI,CAACf,eAAe;QACvF,MAAM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,GAAGb,UAAUY,KAAK,CAAC,IAAI,IAAInC,QAAQ,CAAC;QACtC;IACF;IAEA,MAAaqC,wBAAwBhF,OAA+B,EAAE2B,OAAgB,EAAE;QACtF,IAAI1B;QACJ,IAAI0B,SAAS;YACX1B,aAAa;gBACX0B;gBACAP,SAAS,MAAM,IAAI,CAAC6D,YAAY,CAACC,UAAU;YAC7C;QACF;QACA,MAAMxD,UAAUjC,mBAAmBO,QAAQ0B,OAAO;QAElD,kHAAkH;QAClH,yEAAyE;QACzE,0BAA0B;QAC1B,wBAAwB;QACxB,IAAI;QAEJ,OAAO,IAAI/B,WAAW;YACpBwF,KAAKzD;YACL,sCAAsC;YACtC0D,OAAO,EAAE;QACX,GACGxF,kBAAkB,CAAC;YAAE6E,KAAK;QAAS,GACnCY,WAAW,GACXC,iBAAiB,CAAC,MAClBxF,OAAO,CAAC,IAAI,CAACC,cAAc,EAAEC,SAASC;IAC3C;IAEOsF,aAAa3D,KAAa,EAAW;QAC1C,MAAM4D,eAAetG,UAAU0C;QAC/B,IAAI,CAAC4D,cAAc;YACjB,OAAO;QACT;QACA,MAAMC,SAASD,aAAaE,GAAG;QAC/B,IAAID,QAAQ;YACV,MAAME,MAAM,IAAIC;YAChB,OAAOD,IAAIE,OAAO,KAAKC,OAAOL,UAAU;QAC1C;QAEA,OAAO;IACT;IAEA,OAAOM,oBAAoBnE,KAAa,EAAE;QACxC,MAAMoE,aAAajH,YAAY,IAAIoB,cAAcM,MAAM,CAACmB;QACxD,OAAOpC,oBAAoBwG;IAC7B;IAEA,OAAOC,cAAcC,aAAqB,EAAE;QAC1C,MAAMC,UAAU5G,oBAAoB2G;QACpC,MAAME,eAAepH,YAAYmH;QACjC,OAAO,IAAI9F,cAAcwB,MAAM,CAACuE;IAClC;AACF"}
@@ -3,29 +3,28 @@ import { Instantiable } from '../../Instantiable.abstract.js';
3
3
  import { NvmAccountError } from '../../errors/NeverminedErrors.js';
4
4
  import { keccak256 } from './BlockchainViemUtils.js';
5
5
  export class SignatureUtils extends Instantiable {
6
- constructor(config) {
6
+ constructor(config){
7
7
  super();
8
8
  this.setInstanceConfig(config);
9
9
  }
10
10
  async signText(text, account) {
11
11
  const message = typeof text === 'string' ? text : toHex(text);
12
12
  if (account.type === 'smart') {
13
- const result = await account.signMessage({ message });
13
+ const result = await account.signMessage({
14
+ message
15
+ });
14
16
  return result;
15
- }
16
- else if (account.type === 'local') {
17
+ } else if (account.type === 'local') {
17
18
  return account.signMessage({
18
- message: message,
19
+ message: message
19
20
  });
20
- }
21
- else if (account.type === 'json-rpc') {
21
+ } else if (account.type === 'json-rpc') {
22
22
  const message = typeof text === 'string' ? text : toHex(text);
23
23
  return await this.walletClient.signMessage({
24
24
  account: account.address,
25
- message: message,
25
+ message: message
26
26
  });
27
- }
28
- else {
27
+ } else {
29
28
  throw new NvmAccountError('The account type is not supported for signing');
30
29
  }
31
30
  }
@@ -35,28 +34,25 @@ export class SignatureUtils extends Instantiable {
35
34
  domain,
36
35
  types: types,
37
36
  message: value,
38
- primaryType: 'Nevermined',
37
+ primaryType: 'Nevermined'
39
38
  });
40
39
  return signature;
41
- }
42
- else if (account.type === 'local') {
40
+ } else if (account.type === 'local') {
43
41
  return await account.signTypedData({
44
42
  domain,
45
43
  types: types,
46
44
  message: value,
47
- primaryType: 'Nevermined',
45
+ primaryType: 'Nevermined'
48
46
  });
49
- }
50
- else if (account.type === 'json-rpc') {
47
+ } else if (account.type === 'json-rpc') {
51
48
  return await this.walletClient.signTypedData({
52
49
  domain,
53
50
  types: types,
54
51
  message: value,
55
52
  primaryType: 'Nevermined',
56
- account: account.address,
53
+ account: account.address
57
54
  });
58
- }
59
- else {
55
+ } else {
60
56
  throw new NvmAccountError('The account type is not supported for typed signing');
61
57
  }
62
58
  }
@@ -66,17 +62,15 @@ export class SignatureUtils extends Instantiable {
66
62
  // }
67
63
  if (account.type === 'local') {
68
64
  return account.signTransaction({
69
- data: tx,
65
+ data: tx
70
66
  });
71
- }
72
- else if (account.type === 'json-rpc') {
67
+ } else if (account.type === 'json-rpc') {
73
68
  return await this.walletClient.signTransaction({
74
69
  data: tx,
75
70
  account: account.address,
76
- chain: this.client.chain,
71
+ chain: this.client.chain
77
72
  });
78
- }
79
- else {
73
+ } else {
80
74
  throw new NvmAccountError('The account type is not supported for signing');
81
75
  }
82
76
  }
@@ -84,16 +78,18 @@ export class SignatureUtils extends Instantiable {
84
78
  return this.client.public.verifyMessage({
85
79
  message: text,
86
80
  signature: signature,
87
- address: signerAddress,
81
+ address: signerAddress
88
82
  });
89
83
  }
90
84
  static async recoverSignerAddress(message, signature) {
91
85
  return recoverMessageAddress({
92
86
  message,
93
- signature: signature,
87
+ signature: signature
94
88
  });
95
89
  }
96
90
  static hash(seed) {
97
91
  return keccak256(seed).replace(/^0x([a-f0-9]{64})(:!.+)?$/i, '0x$1');
98
92
  }
99
93
  }
94
+
95
+ //# sourceMappingURL=SignatureUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/nevermined/utils/SignatureUtils.ts"],"sourcesContent":["import type { TypedDataDomain, TypedDataTypes } from '@nevermined-io/commons'\nimport { Account, type Hash, type LocalAccount, recoverMessageAddress, toHex } from 'viem'\nimport { SmartAccount } from 'viem/account-abstraction'\nimport { Instantiable, InstantiableConfig } from '../../Instantiable.abstract.js'\nimport { NvmAccountError } from '../../errors/NeverminedErrors.js'\nimport { keccak256 } from './BlockchainViemUtils.js'\n\nexport class SignatureUtils extends Instantiable {\n constructor(config: InstantiableConfig) {\n super()\n this.setInstanceConfig(config)\n }\n\n public async signText(text: string | Uint8Array, account: Account | SmartAccount): Promise<Hash> {\n const message = typeof text === 'string' ? text : toHex(text)\n\n if (account.type === 'smart') {\n const result = await account.signMessage({ message })\n return result\n } else if (account.type === 'local') {\n return (account as LocalAccount).signMessage({\n message: message as `0x${string}`,\n })\n } else if (account.type === 'json-rpc') {\n const message = typeof text === 'string' ? text : toHex(text)\n return await this.walletClient.signMessage({\n account: account.address as `0x${string}`,\n message: message as `0x${string}`,\n })\n } else {\n throw new NvmAccountError('The account type is not supported for signing')\n }\n }\n\n public async signTypedData(\n domain: TypedDataDomain,\n types: TypedDataTypes,\n value: Record<string, any>,\n account: Account | SmartAccount,\n ): Promise<Hash> {\n if (account.type === 'smart') {\n const signature = await account.signTypedData({\n domain,\n types: types as any,\n message: value,\n primaryType: 'Nevermined',\n })\n return signature\n } else if (account.type === 'local') {\n return await (account as LocalAccount).signTypedData({\n domain,\n types: types as any,\n message: value,\n primaryType: 'Nevermined',\n })\n } else if (account.type === 'json-rpc') {\n return await this.walletClient.signTypedData({\n domain,\n types: types as any,\n message: value,\n primaryType: 'Nevermined',\n account: account.address as `0x${string}`,\n })\n } else {\n throw new NvmAccountError('The account type is not supported for typed signing')\n }\n }\n\n public async signTransaction(\n tx: `0x${string}`,\n account: Account | SmartAccount,\n ): Promise<string> {\n // if (account.type === 'smart') {\n // return await account?.signTransaction({ data: tx })\n // }\n if (account.type === 'local') {\n return (account as LocalAccount).signTransaction({\n data: tx,\n })\n } else if (account.type === 'json-rpc') {\n return await this.walletClient.signTransaction({\n data: tx,\n account: account.address as `0x${string}`,\n chain: this.client.chain,\n })\n } else {\n throw new NvmAccountError('The account type is not supported for signing')\n }\n }\n\n public async verifyIsSigner(\n text: string,\n signature: string,\n signerAddress: string,\n ): Promise<boolean> {\n return this.client.public.verifyMessage({\n message: text,\n signature: signature as `0x${string}`,\n address: signerAddress as `0x${string}`,\n })\n }\n\n static async recoverSignerAddress(message: string, signature: string): Promise<string> {\n return recoverMessageAddress({\n message,\n signature: signature as `0x${string}`,\n })\n }\n\n static hash(seed: string): string {\n return keccak256(seed).replace(/^0x([a-f0-9]{64})(:!.+)?$/i, '0x$1')\n }\n}\n"],"names":["recoverMessageAddress","toHex","Instantiable","NvmAccountError","keccak256","SignatureUtils","config","setInstanceConfig","signText","text","account","message","type","result","signMessage","walletClient","address","signTypedData","domain","types","value","signature","primaryType","signTransaction","tx","data","chain","client","verifyIsSigner","signerAddress","public","verif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;QACF,OAAO,IAAIZ,QAAQE,IAAI,KAAK,YAAY;YACtC,OAAO,MAAM,IAAI,CAACG,YAAY,CAACE,aAAa,CAAC;gBAC3CC;gBACAC,OAAOA;gBACPR,SAASS;gBACTE,aAAa;gBACbZ,SAASA,QAAQM,OAAO;YAC1B;QACF,OAAO;YACL,MAAM,IAAIb,gBAAgB;QAC5B;IACF;IAEA,MAAaoB,gBACXC,EAAiB,EACjBd,OAA+B,EACd;QACjB,kCAAkC;QAClC,wDAAwD;QACxD,IAAI;QACJ,IAAIA,QAAQE,IAAI,KAAK,SAAS;YAC5B,OAAO,AAACF,QAAyBa,eAAe,CAAC;gBAC/CE,MAAMD;YACR;QACF,OAAO,IAAId,QAAQE,IAAI,KAAK,YAAY;YACtC,OAAO,MAAM,IAAI,CAACG,YAAY,CAACQ,eAAe,CAAC;gBAC7CE,MAAMD;gBACNd,SAASA,QAAQM,OAAO;gBACxBU,OAAO,IAAI,CAACC,MAAM,CAACD,KAAK;YAC1B;QACF,OAAO;YACL,MAAM,IAAIvB,gBAAgB;QAC5B;IACF;IAEA,MAAayB,eACXnB,IAAY,EACZY,SAAiB,EACjBQ,aAAqB,EACH;QAClB,OAAO,IAAI,CAACF,MAAM,CAACG,MAAM,CAACC,aAAa,CAAC;YACtCpB,SAASF;YACTY,WAAWA;YACXL,SAASa;QACX;IACF;IAEA,aAAaG,qBAAqBrB,OAAe,EAAEU,SAAiB,EAAmB;QACrF,OAAOrB,sBAAsB;YAC3BW;YACAU,WAAWA;QACb;IACF;IAEA,OAAOY,KAAKC,IAAY,EAAU;QAChC,OAAO9B,UAAU8B,MAAMC,OAAO,CAAC,8BAA8B;IAC/D;AACF"}
@@ -2,11 +2,8 @@ import { HttpError } from '../../errors/NeverminedErrors.js';
2
2
  import { JwtUtils } from '../../nevermined/utils/JwtUtils.js';
3
3
  /**
4
4
  * Provides a common interface to web services.
5
- */
6
- export class WebServiceConnector {
7
- // extends Instantiable {
8
- config;
9
- constructor(config) {
5
+ */ export class WebServiceConnector {
6
+ constructor(config){
10
7
  // super()
11
8
  // this.setInstanceConfig(config)
12
9
  this.config = config;
@@ -17,16 +14,16 @@ export class WebServiceConnector {
17
14
  body: payload,
18
15
  headers: {
19
16
  'Content-type': 'application/json',
20
- ...headers,
21
- },
17
+ ...headers
18
+ }
22
19
  });
23
20
  }
24
21
  get(url, headers = {}) {
25
22
  return this.fetch(url, {
26
23
  method: 'GET',
27
24
  headers: {
28
- ...headers,
29
- },
25
+ ...headers
26
+ }
30
27
  });
31
28
  }
32
29
  put(url, payload, headers = {}) {
@@ -35,8 +32,8 @@ export class WebServiceConnector {
35
32
  body: payload,
36
33
  headers: {
37
34
  'Content-type': 'application/json',
38
- ...headers,
39
- },
35
+ ...headers
36
+ }
40
37
  });
41
38
  }
42
39
  delete(url, payload, headers = {}) {
@@ -45,8 +42,8 @@ export class WebServiceConnector {
45
42
  body: payload,
46
43
  headers: {
47
44
  'Content-type': 'application/json',
48
- ...headers,
49
- },
45
+ ...headers
46
+ }
50
47
  });
51
48
  }
52
49
  async downloadUrl(url, headers) {
@@ -59,7 +56,7 @@ export class WebServiceConnector {
59
56
  async fetchToken(url, grantToken, sessionKey, numberTries = 1, apiKeyHash) {
60
57
  const bodyParams = new URLSearchParams({
61
58
  client_assertion_type: JwtUtils.CLIENT_ASSERTION_TYPE,
62
- client_assertion: grantToken,
59
+ client_assertion: grantToken
63
60
  });
64
61
  if (sessionKey) {
65
62
  bodyParams.append('sessionKey', sessionKey);
@@ -71,23 +68,24 @@ export class WebServiceConnector {
71
68
  method: 'POST',
72
69
  body: bodyParams.toString(),
73
70
  headers: {
74
- 'Content-type': 'application/x-www-form-urlencoded',
75
- },
71
+ 'Content-type': 'application/x-www-form-urlencoded'
72
+ }
76
73
  }, numberTries);
77
74
  }
78
75
  async fetch(url, opts, numberTries = 1) {
79
76
  let counterTries = 1;
80
77
  let result;
81
- while (counterTries <= numberTries) {
78
+ while(counterTries <= numberTries){
82
79
  result = await fetch(url.toString(), opts);
83
- if (result.ok)
84
- return result;
80
+ if (result.ok) return result;
85
81
  counterTries++;
86
82
  await this._sleep(500);
87
83
  }
88
84
  throw new HttpError(`Request ${opts.method} ${url} fail - ${await result.clone().text()}`, result.status);
89
85
  }
90
86
  _sleep(ms) {
91
- return new Promise((resolve) => setTimeout(resolve, ms));
87
+ return new Promise((resolve)=>setTimeout(resolve, ms));
92
88
  }
93
89
  }
90
+
91
+ //# sourceMappingURL=WebServiceConnector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/nevermined/utils/WebServiceConnector.ts"],"sourcesContent":["import { HttpError } from '../../errors/NeverminedErrors.js'\nimport { InstantiableConfig } from '../../Instantiable.abstract.js'\nimport { JwtUtils } from '../../nevermined/utils/JwtUtils.js'\n\n/**\n * Provides a common interface to web services.\n */\nexport class WebServiceConnector {\n // extends Instantiable {\n\n config: InstantiableConfig\n\n constructor(config: InstantiableConfig) {\n // super()\n // this.setInstanceConfig(config)\n this.config = config\n }\n\n public post(\n url: string,\n payload: BodyInit,\n headers: { [header: string]: string } = {},\n ): Promise<Response> {\n return this.fetch(url, {\n method: 'POST',\n body: payload,\n headers: {\n 'Content-type': 'application/json',\n ...headers,\n },\n })\n }\n\n public get(url: string | URL, headers: { [header: string]: string } = {}): Promise<Response> {\n return this.fetch(url, {\n method: 'GET',\n headers: {\n ...headers,\n },\n })\n }\n\n public put(\n url: string,\n payload: BodyInit,\n headers: { [header: string]: string } = {},\n ): Promise<Response> {\n return this.fetch(url, {\n method: 'PUT',\n body: payload,\n headers: {\n 'Content-type': 'application/json',\n ...headers,\n },\n })\n }\n\n public delete(\n url: string,\n payload?: BodyInit,\n headers: { [header: string]: string } = {},\n ): Promise<Response> {\n return this.fetch(url, {\n method: 'DELETE',\n body: payload,\n headers: {\n 'Content-type': 'application/json',\n ...headers,\n },\n })\n }\n\n public async downloadUrl(url: string, headers?: any): Promise<string> {\n const response = await this.get(url, headers)\n if (!response.ok) {\n throw new Error('Response error.')\n }\n return await response.text()\n }\n\n public async fetchToken(\n url: string,\n grantToken: string,\n sessionKey?: string,\n numberTries = 1,\n apiKeyHash?: string,\n ): Promise<Response> {\n const bodyParams = new URLSearchParams({\n client_assertion_type: JwtUtils.CLIENT_ASSERTION_TYPE,\n client_assertion: grantToken,\n })\n\n if (sessionKey) {\n bodyParams.append('sessionKey', sessionKey)\n }\n\n if (apiKeyHash) {\n bodyParams.append('nvm_key_hash', apiKeyHash)\n }\n\n return await this.fetch(\n url,\n {\n method: 'POST',\n body: bodyParams.toString(),\n headers: {\n 'Content-type': 'application/x-www-form-urlencoded',\n },\n },\n numberTries,\n )\n }\n\n private async fetch(url: string | URL, opts: RequestInit, numberTries = 1): Promise<Response> {\n let counterTries = 1\n let result: Response | undefined\n while (counterTries <= numberTries) {\n result = await fetch(url.toString(), opts)\n if (result.ok) return result\n\n counterTries++\n await this._sleep(500)\n }\n\n throw new HttpError(\n `Request ${opts.method} ${url} fail - ${await result!.clone().text()}`,\n result!.status,\n )\n }\n\n private _sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms))\n }\n}\n"],"names":["HttpError","JwtUtils","WebServiceConnector","config","post","url","payload","headers","fetch","method","body","get","put","delete","downloadUrl","response","ok","Error","text","fetchToken","grantToken","sessionKey","numberTries","apiKeyHash","bodyParams","URLSearchParams","client_assertion_type","CLIENT_ASSERTION_TYPE","client_assertion","append","toString","opts","counterTries","result","_sleep","clone","status","ms","Promise","resolve","setTimeout"],"mappings":"AAAA,SAASA,SAAS,QAAQ,mCAAkC;AAE5D,SAASC,QAAQ,QAAQ,qCAAoC;AAE7D;;CAEC,GACD,OAAO,MAAMC;IAKX,YAAYC,MAA0B,CAAE;QACtC,UAAU;QACV,iCAAiC;QACjC,IAAI,CAACA,MAAM,GAAGA;IAChB;IAEOC,KACLC,GAAW,EACXC,OAAiB,EACjBC,UAAwC,CAAC,CAAC,EACvB;QACnB,OAAO,IAAI,CAACC,KAAK,CAACH,KAAK;YACrBI,QAAQ;YACRC,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