@sphereon/ssi-sdk.ebsi-support 0.34.1-next.29 → 0.34.1-next.299

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/dist/index.d.cts CHANGED
@@ -1,19 +1,21 @@
1
1
  import * as _sphereon_ssi_types from '@sphereon/ssi-types';
2
- import { W3CVerifiableCredential, PresentationSubmission } from '@sphereon/ssi-types';
3
- import { IIdentifier, MinimalImportableKey, TKeyType, IService, IKey, IAgentContext, IKeyManager, IDIDManager, IPluginMethodMap, IResolver, IAgentPlugin } from '@veramo/core';
2
+ import { W3CVerifiableCredential, CredentialRole, PresentationSubmission } from '@sphereon/ssi-types';
3
+ import { IIdentifier, MinimalImportableKey, TKeyType, IService, IAgentContext, IKeyManager, IKey, IDIDManager, IPluginMethodMap, IResolver, IAgentPlugin } from '@veramo/core';
4
4
  import { DiscoveryMetadataPayload, JWK } from '@sphereon/did-auth-siop';
5
5
  import { RequestObjectOpts, OID4VCICredentialFormat } from '@sphereon/oid4vci-common';
6
6
  import { PresentationDefinitionV2, Format } from '@sphereon/pex-models';
7
7
  import { ManagedIdentifierDidResult, IIdentifierResolution, ManagedIdentifierDidOpts } from '@sphereon/ssi-sdk-ext.identifier-resolution';
8
8
  import { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service';
9
- import { CredentialRole, Party, IBasicCredentialLocaleBranding } from '@sphereon/ssi-sdk.data-store';
9
+ import { Party, IBasicCredentialLocaleBranding } from '@sphereon/ssi-sdk.data-store-types';
10
10
  import { PrepareStartArgs, IssuanceOpts, IOID4VCIHolder, ErrorDetails, MappedCredentialToAccept } from '@sphereon/ssi-sdk.oid4vci-holder';
11
11
  import { IPresentationExchange } from '@sphereon/ssi-sdk.presentation-exchange';
12
12
  import { IDidAuthSiopOpAuthenticator } from '@sphereon/ssi-sdk.siopv2-oid4vp-op-auth';
13
13
  import { _ExtendedIKey } from '@veramo/utils';
14
- import { DIDDocument } from 'did-resolver';
14
+ import { DIDDocument, DIDResolver } from 'did-resolver';
15
+ import { BigNumberish, BytesLike, AccessListish } from 'ethers';
15
16
  import { AbstractIdentifierProvider } from '@veramo/did-manager';
16
17
 
18
+ type IContext = IAgentContext<IKeyManager>;
17
19
  /**
18
20
  * The type of the DID to be created
19
21
  * @readonly
@@ -42,6 +44,7 @@ interface EbsiDidSpecInfo {
42
44
  didLength?: number;
43
45
  privateKeyLength?: number;
44
46
  }
47
+ declare const EBSI_DID_SPEC_INFOS: Record<string, EbsiDidSpecInfo>;
45
48
  /**
46
49
  * A minimal importable key with restricted types to choose from and purposes of the public key
47
50
  * @typedef IKeyOpts
@@ -56,6 +59,14 @@ interface IKeyOpts extends WithRequiredProperty<Partial<MinimalImportableKey>, '
56
59
  type WithRequiredProperty<Type, Key extends keyof Type> = Type & {
57
60
  [Property in Key]-?: Type[Property];
58
61
  };
62
+ type RpcMethodArgs = {
63
+ params: RPCParams[];
64
+ rpcId: number;
65
+ accessToken: string;
66
+ rpcMethod: EbsiRpcMethod;
67
+ apiOpts?: ApiOpts;
68
+ doNotThrowErrors?: boolean;
69
+ };
59
70
  type EbsiCreateIdentifierOpts = {
60
71
  methodSpecificId?: string;
61
72
  rpcId?: number;
@@ -102,6 +113,36 @@ declare enum EbsiPublicKeyPurpose {
102
113
  AssertionMethod = "assertionMethod",
103
114
  CapabilityInvocation = "capabilityInvocation"
104
115
  }
116
+ /**
117
+ * @typedef InsertDidDocumentParams
118
+ * @type {object}
119
+ * @property {string} from - Ethereum address of the signer
120
+ * @property {string} did - DID to insert. It must be for a legal entity (DID v1)
121
+ * @property {string} BASE_CONTEXT_DOC - JSON string containing the @context of the DID document
122
+ * @property {string} vMethodId - Thumbprint of the public key
123
+ * @property {string} publicKey - Public key for secp256k1 in uncompressed format prefixed with "0x04"
124
+ * @property {boolean} isSecp256k1 - It must be true
125
+ * @property {number} notBefore - Capability invocation is valid from this time
126
+ * @property {number} notAfter - Expiration of the capability invocation
127
+ */
128
+ type InsertDidDocumentParams = {
129
+ from: string;
130
+ did: string;
131
+ baseDocument: string;
132
+ vMethodId: string;
133
+ publicKey: string;
134
+ isSecp256k1: boolean;
135
+ notBefore: number;
136
+ notAfter: number;
137
+ };
138
+ /**
139
+ * @typedef UpdateBaseDocumentParams
140
+ * @type {object}
141
+ * @property {string} from - Ethereum address of the signer
142
+ * @property {string} did - Existing DID
143
+ * @property {string} BASE_CONTEXT_DOC - JSON string containing the @context of the DID document
144
+ */
145
+ type UpdateBaseDocumentParams = Pick<InsertDidDocumentParams, 'from' | 'did' | 'baseDocument'>;
105
146
  /**
106
147
  * @typedef UpdateIdentifierParams
107
148
  * @type {object}
@@ -116,6 +157,79 @@ type UpdateIdentifierParams = {
116
157
  [p: string]: any;
117
158
  };
118
159
  };
160
+ type AddServiceParams = {
161
+ from: string;
162
+ did: string;
163
+ service: IService;
164
+ };
165
+ /**
166
+ * @typedef AddVerificationMethodParams
167
+ * @type {object}
168
+ * @property {string} from - Ethereum address of the signer
169
+ * @property {string} did - Existing DID
170
+ * @property {string} vMethodId - New verification method id
171
+ * @property {boolean} isSecp256k1 - Boolean defining if the public key is for secp256k1 curve or not
172
+ * @property {string} publicKey - Public key as hex string. For an ES256K key, it must be in uncompressed format
173
+ * prefixed with "0x04". For other algorithms, it must be the JWK transformed to string and then to hex format.
174
+ */
175
+ type AddVerificationMethodParams = Pick<InsertDidDocumentParams, 'from' | 'did' | 'vMethodId' | 'isSecp256k1' | 'publicKey'>;
176
+ /**
177
+ * @typedef AddVerificationMethodRelationshipParams
178
+ * @type {object}
179
+ * @property {string} from - Ethereum address of the signer
180
+ * @property {string} did - Existing DID
181
+ * @property {string} name - Name of the verification relationship
182
+ * @property {string} vMethodId - Reference to the verification method
183
+ * @property {number} notBefore - Verification relationship is valid from this time
184
+ * @property {number} notAfter - Expiration of the verification relationship
185
+ */
186
+ type AddVerificationMethodRelationshipParams = Pick<InsertDidDocumentParams, 'from' | 'did' | 'vMethodId' | 'notBefore' | 'notAfter'> & {
187
+ name: string;
188
+ };
189
+ /**
190
+ * @typedef UnsignedTransaction
191
+ * @type {object}
192
+ * @property {string} from - The sending address.
193
+ * @property {string} to - The receiving address (if EOA, the transaction will transfer value. If a smart contract
194
+ * account, the transaction will use contract code).
195
+ * @property {string} data - Can contain code or a message to the recipient.
196
+ * @property {string} nonce - A number used to track ordering of transactions and prevent replay attacks
197
+ * @property {string} chainId - The Ethereum Network ID (ex: 1 - Ethereum Mainnet).
198
+ * @property {string} gasLimit - The maximum amount of gas units that can be used.
199
+ * @property {string} gasPrice - Gas price provided by the sender in Wei.
200
+ * @property {string} value - The amount of ETH to be sent from the sending address (denominated in Wei)
201
+ */
202
+ type UnsignedTransaction = {
203
+ to?: string;
204
+ nonce?: number;
205
+ gasLimit?: BigNumberish;
206
+ gasPrice?: BigNumberish;
207
+ data?: BytesLike;
208
+ value?: BigNumberish;
209
+ chainId?: number;
210
+ type?: number | null;
211
+ accessList?: AccessListish;
212
+ maxPriorityFeePerGas?: BigNumberish;
213
+ maxFeePerGas?: BigNumberish;
214
+ };
215
+ /**
216
+ * @typedef SendSignedTransactionParams
217
+ * @type {object}
218
+ * @property {string} protocol - Example: eth
219
+ * @property {UnsignedTransaction} unsignedTransaction - The unsigned transaction
220
+ * @property {string} r - ECDSA signature r
221
+ * @property {string} s - ECDSA signature s
222
+ * @property {string} v - ECDSA recovery id
223
+ * @property {string} signedRawTransaction - The signed raw transaction
224
+ */
225
+ type SendSignedTransactionParams = {
226
+ protocol: string;
227
+ unsignedTransaction: UnsignedTransaction;
228
+ r: string;
229
+ s: string;
230
+ v: string;
231
+ signedRawTransaction: string;
232
+ };
119
233
  /**
120
234
  * @typedef RpcOkResponse
121
235
  * @type {object}
@@ -136,6 +250,93 @@ type RpcErrorResponse = {
136
250
  message: string;
137
251
  };
138
252
  };
253
+ /**
254
+ * @typedef ResponseNot200
255
+ * @type {object}
256
+ * @property {URL | string} type - An absolute URI that identifies the problem type. When dereferenced,
257
+ * it SHOULD provide human-readable documentation for the problem type.
258
+ * @property {string} title - A short summary of the problem type.
259
+ * @property {number} status - The HTTP status code generated by the origin server for this occurrence of the problem.
260
+ * @property {string} detail - A human-readable explanation specific to this occurrence of the problem.
261
+ * @property {URL | string} instance An absolute URI that identifies the specific occurrence of the problem.
262
+ * It may or may not yield further information if dereferenced.
263
+ */
264
+ type ResponseNot200 = {
265
+ type: URL | string;
266
+ id?: number;
267
+ title: string;
268
+ error?: {
269
+ code: number;
270
+ message: string;
271
+ };
272
+ status: number;
273
+ detail: string;
274
+ instance: URL | string;
275
+ };
276
+ /**
277
+ * @typedef GetDidDocumentParams
278
+ * @type {object}
279
+ * @property {string} did
280
+ * @property {string} validAt
281
+ */
282
+ type GetDidDocumentParams = {
283
+ did: string;
284
+ validAt?: string;
285
+ };
286
+ /**
287
+ * @typedef GetDidDocumentsParams
288
+ * @type {object}
289
+ * @property {string} offset Originally page[after] Cursor that points to the end of the page of data that has been returned.
290
+ * @property {number} size Originally page[size] Defines the maximum number of objects that may be returned.
291
+ * @property {string} controller Filter by controller DID.
292
+ */
293
+ type GetDidDocumentsParams = {
294
+ offset?: string;
295
+ size?: number;
296
+ controller?: string;
297
+ };
298
+ /**
299
+ * Result of listing dids
300
+ * @typedef {Item}
301
+ * @type {object}
302
+ * @property {string} did - The DID
303
+ * @property {string} href - The referrer of the DID
304
+ */
305
+ type Item = {
306
+ did: string;
307
+ href: string;
308
+ };
309
+ /**
310
+ * The links related to pagination
311
+ * @typedef Links
312
+ * @type {object}
313
+ * @property {string} first - The link to the first page
314
+ * @property {string} prev - The link ot the previous page
315
+ * @property {string} next - The link to the next page
316
+ * @property {string} last - The link to the last page
317
+ */
318
+ type Links = {
319
+ first: string;
320
+ prev: string;
321
+ next: string;
322
+ last: string;
323
+ };
324
+ /**
325
+ * @typedef GetDidDocumentResponse
326
+ * @type {object}
327
+ * @property {string} self - Absolute path to the collection (consult)
328
+ * @property {Item[]} items - List of DIDs and their referrers
329
+ * @property {number} total - Total number of items across all pages.
330
+ * @property {pageSize} number - Maximum number of items per page. For the last page, its value should be independent of the number of actually returned items.
331
+ * @property {Links} links - The links related to pagination
332
+ */
333
+ type GetDidDocumentsResponse = {
334
+ self: string;
335
+ items: Item[];
336
+ total: number;
337
+ pageSize: number;
338
+ links: Links;
339
+ };
139
340
  type EbsiAccessTokenOpts = {
140
341
  attestationToOnboard?: W3CVerifiableCredential;
141
342
  attestationToOnboardCredentialRole: CredentialRole;
@@ -173,6 +374,32 @@ interface CreateEbsiDidOnLedgerResult {
173
374
  addAssertionMethodRelationship: EbsiRPCResponse;
174
375
  addAuthenticationRelationship: EbsiRPCResponse;
175
376
  }
377
+ /**
378
+ * @constant JSON_RPC_VERSION
379
+ */
380
+ declare const JSON_RPC_VERSION = "2.0";
381
+ /**
382
+ * @constant BASE_CONTEXT_DOC
383
+ */
384
+ declare const BASE_CONTEXT_DOC: string;
385
+ interface EbsiDidRegistryAPIEndpoints {
386
+ mutate: string;
387
+ query: string;
388
+ }
389
+ /**
390
+ * The EBSI RPC operations
391
+ * @readonly
392
+ * @enum {string}
393
+ */
394
+ declare enum EbsiRpcMethod {
395
+ INSERT_DID_DOCUMENT = "insertDidDocument",
396
+ UPDATE_DID_DOCUMENT = "updateBaseDocument",
397
+ ADD_VERIFICATION_METHOD = "addVerificationMethod",
398
+ ADD_VERIFICATION_RELATIONSHIP = "addVerificationRelationship",
399
+ ADD_SERVICE = "addService",
400
+ SEND_SIGNED_TRANSACTION = "sendSignedTransaction"
401
+ }
402
+ type RPCParams = InsertDidDocumentParams | UpdateBaseDocumentParams | AddVerificationMethodParams | AddVerificationMethodRelationshipParams | SendSignedTransactionParams | AddServiceParams;
176
403
  type EbsiRPCResponse = RpcOkResponse | (RpcErrorResponse & {
177
404
  nonce: string;
178
405
  });
@@ -219,6 +446,101 @@ declare class EbsiDidProvider extends AbstractIdentifierProvider {
219
446
  updateIdentifier(args: UpdateIdentifierParams, context: IAgentContext<IKeyManager & IDIDManager>): Promise<IIdentifier>;
220
447
  }
221
448
 
449
+ declare function getDidEbsiResolver(): {
450
+ key: DIDResolver;
451
+ };
452
+
453
+ declare function generateEbsiMethodSpecificId(specInfo?: EbsiDidSpecInfo): string;
454
+ declare function generateOrUseProvidedEbsiPrivateKeyHex(specInfo?: EbsiDidSpecInfo, privateKeyBytes?: Uint8Array): string;
455
+ /**
456
+ * Returns the public key in the correct format to be used with the did registry v5
457
+ * - in case of Secp256k1 - returns the uncompressed public key as hex string prefixed with 0x04
458
+ * - in case of Secp256r1 - returns the jwk public key as hex string
459
+ * @param {{ key: IKey, type: EbsiKeyType }} args
460
+ * - key is the cryptographic key containing the public key
461
+ * - type is the type of the key which can be Secp256k1 or Secp256r1
462
+ * @returns {string} The properly formatted public key
463
+ * @throws {Error} If the key type is invalid
464
+ */
465
+ declare const formatEbsiPublicKey: (args: {
466
+ key: IKey;
467
+ type: TKeyType;
468
+ }) => string;
469
+ declare const ebsiGetIssuerMock: (args: {
470
+ environment?: EbsiEnvironment;
471
+ version?: EbsiApiVersion;
472
+ }) => string;
473
+ declare const ebsiGetAuthorisationServer: (args: {
474
+ environment?: EbsiEnvironment;
475
+ version?: EbsiApiVersion;
476
+ }) => string;
477
+ declare const ebsiGetRegistryAPIUrls: (args: {
478
+ environment?: EbsiEnvironment;
479
+ version?: EbsiApiVersion;
480
+ }) => EbsiDidRegistryAPIEndpoints;
481
+ declare const determineWellknownEndpoint: ({ environment, version, type, system, mock }: WellknownOpts) => string;
482
+ declare const ebsiSignAndSendTransaction: (args: {
483
+ rpcRequest: RpcMethodArgs;
484
+ previousTxResponse?: EbsiRPCResponse;
485
+ kid: string;
486
+ accessToken: string;
487
+ apiOpts?: ApiOpts;
488
+ }, context: IContext) => Promise<EbsiRPCResponse>;
489
+ declare const ebsiGenerateOrUseKeyPair: (args: {
490
+ keyOpts?: IKeyOpts;
491
+ keyType: EbsiKeyType;
492
+ kms: string;
493
+ controllerKey?: boolean;
494
+ }, context: IAgentContext<IKeyManager>) => Promise<MinimalImportableKey>;
495
+ declare const toMinimalImportableKey: (args: {
496
+ key?: IKeyOpts;
497
+ type: EbsiKeyType;
498
+ kms: string;
499
+ }) => Promise<MinimalImportableKey>;
500
+ declare const assertedPurposes: (args: {
501
+ key?: IKeyOpts;
502
+ }) => EbsiPublicKeyPurpose[] | undefined;
503
+ declare const setPurposes: (args: {
504
+ key?: IKeyOpts;
505
+ type: EbsiKeyType;
506
+ }) => EbsiPublicKeyPurpose[];
507
+ declare const randomRpcId: () => number;
508
+ declare const ebsiCreateDidOnLedger: (args: CreateEbsiDidParams, context: IRequiredContext) => Promise<CreateEbsiDidOnLedgerResult>;
509
+
510
+ /**
511
+ * Gets the DID document corresponding to the DID.
512
+ * @param {{ params: GetDidDocumentParams, apiOpts?: ApiOpts }} args
513
+ * @returns a did document
514
+ */
515
+ declare const ebsiGetDidDocument: (args: {
516
+ params: GetDidDocumentParams;
517
+ apiOpts?: ApiOpts;
518
+ }) => Promise<DIDDocument>;
519
+ /**
520
+ * Wait up to the number of MS for a DID Document or Verification methods and relationships to be registered. This is needed, as the EBSI blockchain does not directly propagate across all nodes, since it needs to mine for consensus first
521
+ * @param args
522
+ */
523
+ declare const ebsiWaitTillDocumentAnchored: (args: GetDidDocumentParams & ApiOpts & {
524
+ startIntervalMS?: number;
525
+ minIntervalMS?: number;
526
+ decreaseIntervalMSPerStep?: number;
527
+ maxWaitTime?: number;
528
+ searchForObject?: Record<string, any>;
529
+ }) => Promise<{
530
+ totalWaitTime: number;
531
+ count: number;
532
+ didDocument: DIDDocument | undefined;
533
+ }>;
534
+ /**
535
+ * listDidDocuments - Returns a list of identifiers.
536
+ * @param {{ params: GetDidDocumentsParams; apiOpts?: ApiOpts }} args
537
+ * @returns a list of identifiers
538
+ */
539
+ declare const ebsiListDidDocuments: (args: {
540
+ params: GetDidDocumentsParams;
541
+ apiOpts?: ApiOpts;
542
+ }) => Promise<GetDidDocumentsResponse>;
543
+
222
544
  interface AttestationAuthRequestUrlResult extends Omit<Required<PrepareStartArgs>, 'issuanceOpt'> {
223
545
  issuanceOpt?: IssuanceOpts;
224
546
  authorizationCodeURL: string;
@@ -443,4 +765,4 @@ declare class EbsiSupport implements IAgentPlugin {
443
765
  declare const logger: _sphereon_ssi_types.ISimpleLogger<unknown>;
444
766
  declare const schema: any;
445
767
 
446
- export { type ApiOpts, type AttestationResult, type CreateAttestationAuthRequestURLArgs, type EBSIAuthAccessTokenGetArgs, type EBSIScope, type EbsiApiVersion, EbsiDidProvider, type EbsiEnvironment, type EbsiMock, type EbsiOpenIDMetadata, EbsiSupport, type EbsiSystem, type ExceptionResponse, type GetAccessTokenArgs, type GetAccessTokenResponse, type GetAccessTokenResult, type GetAccessTokenSuccessResponse, type GetAttestationArgs, type GetOIDProviderJwksResponse, type GetOIDProviderJwksSuccessResponse, type GetOIDProviderMetadataResponse, type GetPresentationDefinitionArgs, type GetPresentationDefinitionResponse, type GetPresentationDefinitionSuccessResponse, type IEbsiSupport, type IRequiredContext, TokenType, type WellknownOpts, type WellknownType, ebsiSupportMethods, logger, schema };
768
+ export { type AddServiceParams, type AddVerificationMethodParams, type AddVerificationMethodRelationshipParams, type ApiOpts, type AttestationResult, BASE_CONTEXT_DOC, type CreateAttestationAuthRequestURLArgs, type CreateEbsiDidOnLedgerResult, type CreateEbsiDidParams, type EBSIAuthAccessTokenGetArgs, type EBSIScope, EBSI_DID_SPEC_INFOS, type EbsiAccessTokenOpts, type EbsiApiVersion, type EbsiCreateIdentifierOpts, type EbsiDIDPrefix, type EbsiDIDType, EbsiDidProvider, type EbsiDidRegistryAPIEndpoints, type EbsiDidSpecInfo, type EbsiEnvironment, type EbsiKeyType, type EbsiMock, type EbsiOpenIDMetadata, EbsiPublicKeyPurpose, type EbsiRPCResponse, EbsiRpcMethod, EbsiSupport, type EbsiSystem, type ExceptionResponse, type GetAccessTokenArgs, type GetAccessTokenResponse, type GetAccessTokenResult, type GetAccessTokenSuccessResponse, type GetAttestationArgs, type GetDidDocumentParams, type GetDidDocumentsParams, type GetDidDocumentsResponse, type GetOIDProviderJwksResponse, type GetOIDProviderJwksSuccessResponse, type GetOIDProviderMetadataResponse, type GetPresentationDefinitionArgs, type GetPresentationDefinitionResponse, type GetPresentationDefinitionSuccessResponse, type IContext, type ICreateIdentifierArgs, type IEbsiSupport, type IKeyOpts, type IRequiredContext, type InsertDidDocumentParams, type Item, JSON_RPC_VERSION, type Links, type RPCParams, type ResponseNot200, type RpcErrorResponse, type RpcMethodArgs, type RpcOkResponse, type SendSignedTransactionParams, TokenType, type UnsignedTransaction, type UpdateBaseDocumentParams, type UpdateIdentifierParams, type WellknownOpts, type WellknownType, assertedPurposes, determineWellknownEndpoint, ebsiCreateDidOnLedger, ebsiGenerateOrUseKeyPair, ebsiGetAuthorisationServer, ebsiGetDidDocument, ebsiGetIssuerMock, ebsiGetRegistryAPIUrls, ebsiListDidDocuments, ebsiSignAndSendTransaction, ebsiSupportMethods, ebsiWaitTillDocumentAnchored, formatEbsiPublicKey, generateEbsiMethodSpecificId, generateOrUseProvidedEbsiPrivateKeyHex, getDidEbsiResolver, logger, randomRpcId, schema, setPurposes, toMinimalImportableKey };