@sphereon/ssi-sdk.ebsi-support 0.26.1-unstable.101

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 (68) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +13 -0
  3. package/dist/agent/EbsiSupport.d.ts +12 -0
  4. package/dist/agent/EbsiSupport.d.ts.map +1 -0
  5. package/dist/agent/EbsiSupport.js +202 -0
  6. package/dist/agent/EbsiSupport.js.map +1 -0
  7. package/dist/did/EbsiDidProvider.d.ts +47 -0
  8. package/dist/did/EbsiDidProvider.d.ts.map +1 -0
  9. package/dist/did/EbsiDidProvider.js +172 -0
  10. package/dist/did/EbsiDidProvider.js.map +1 -0
  11. package/dist/did/EbsiDidResolver.d.ts +5 -0
  12. package/dist/did/EbsiDidResolver.d.ts.map +1 -0
  13. package/dist/did/EbsiDidResolver.js +10 -0
  14. package/dist/did/EbsiDidResolver.js.map +1 -0
  15. package/dist/did/functions.d.ts +66 -0
  16. package/dist/did/functions.d.ts.map +1 -0
  17. package/dist/did/functions.js +416 -0
  18. package/dist/did/functions.js.map +1 -0
  19. package/dist/did/index.d.ts +6 -0
  20. package/dist/did/index.d.ts.map +1 -0
  21. package/dist/did/index.js +6 -0
  22. package/dist/did/index.js.map +1 -0
  23. package/dist/did/services/EbsiRPCService.d.ts +13 -0
  24. package/dist/did/services/EbsiRPCService.d.ts.map +1 -0
  25. package/dist/did/services/EbsiRPCService.js +64 -0
  26. package/dist/did/services/EbsiRPCService.js.map +1 -0
  27. package/dist/did/services/EbsiRestService.d.ts +37 -0
  28. package/dist/did/services/EbsiRestService.d.ts.map +1 -0
  29. package/dist/did/services/EbsiRestService.js +90 -0
  30. package/dist/did/services/EbsiRestService.js.map +1 -0
  31. package/dist/did/types.d.ts +386 -0
  32. package/dist/did/types.d.ts.map +1 -0
  33. package/dist/did/types.js +47 -0
  34. package/dist/did/types.js.map +1 -0
  35. package/dist/functions/Attestation.d.ts +32 -0
  36. package/dist/functions/Attestation.d.ts.map +1 -0
  37. package/dist/functions/Attestation.js +182 -0
  38. package/dist/functions/Attestation.js.map +1 -0
  39. package/dist/functions/AttestationHeadlessCallbacks.d.ts +17 -0
  40. package/dist/functions/AttestationHeadlessCallbacks.d.ts.map +1 -0
  41. package/dist/functions/AttestationHeadlessCallbacks.js +194 -0
  42. package/dist/functions/AttestationHeadlessCallbacks.js.map +1 -0
  43. package/dist/functions/index.d.ts +7 -0
  44. package/dist/functions/index.d.ts.map +1 -0
  45. package/dist/functions/index.js +8 -0
  46. package/dist/functions/index.js.map +1 -0
  47. package/dist/index.d.ts +7 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +8 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/types/IEbsiSupport.d.ts +211 -0
  52. package/dist/types/IEbsiSupport.d.ts.map +1 -0
  53. package/dist/types/IEbsiSupport.js +5 -0
  54. package/dist/types/IEbsiSupport.js.map +1 -0
  55. package/package.json +86 -0
  56. package/src/agent/EbsiSupport.ts +250 -0
  57. package/src/did/EbsiDidProvider.ts +269 -0
  58. package/src/did/EbsiDidResolver.ts +16 -0
  59. package/src/did/functions.ts +528 -0
  60. package/src/did/index.ts +5 -0
  61. package/src/did/services/EbsiRPCService.ts +68 -0
  62. package/src/did/services/EbsiRestService.ts +117 -0
  63. package/src/did/types.ts +449 -0
  64. package/src/functions/Attestation.ts +262 -0
  65. package/src/functions/AttestationHeadlessCallbacks.ts +242 -0
  66. package/src/functions/index.ts +15 -0
  67. package/src/index.ts +8 -0
  68. package/src/types/IEbsiSupport.ts +241 -0
@@ -0,0 +1,117 @@
1
+ import fetch from 'cross-fetch'
2
+ import { DIDDocument } from 'did-resolver'
3
+ import { wait } from '../../functions'
4
+ import { logger } from '../../index'
5
+ import { ApiOpts } from '../../types/IEbsiSupport'
6
+ import { ebsiGetRegistryAPIUrls } from '../functions'
7
+ import { GetDidDocumentParams, GetDidDocumentsParams, GetDidDocumentsResponse } from '../types'
8
+
9
+ /**
10
+ * Gets the DID document corresponding to the DID.
11
+ * @param {{ params: GetDidDocumentParams, apiOpts?: ApiOpts }} args
12
+ * @returns a did document
13
+ */
14
+ export const ebsiGetDidDocument = async (args: { params: GetDidDocumentParams; apiOpts?: ApiOpts }): Promise<DIDDocument> => {
15
+ const { params, apiOpts } = args
16
+ const { did, validAt } = params
17
+ if (!did) {
18
+ throw new Error('did parameter is required')
19
+ }
20
+ const query = validAt ? `?valid_at=${validAt}` : ''
21
+ const response = await fetch(`${ebsiGetRegistryAPIUrls({ ...apiOpts }).query}/${did}${query}`)
22
+ const textBody = await response.text()
23
+ const json = textBody.startsWith('{') ? JSON.parse(textBody) : undefined
24
+
25
+ if (response.status >= 300 || !json) {
26
+ return Promise.reject(new Error(json ?? textBody))
27
+ }
28
+ return json
29
+ }
30
+
31
+ /**
32
+ * 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
33
+ * @param args
34
+ */
35
+ export const ebsiWaitTillDocumentAnchored = async (
36
+ args: GetDidDocumentParams &
37
+ ApiOpts & {
38
+ startIntervalMS?: number
39
+ minIntervalMS?: number
40
+ decreaseIntervalMSPerStep?: number
41
+ maxWaitTime?: number
42
+ searchForObject?: Record<string, any>
43
+ },
44
+ ): Promise<{
45
+ totalWaitTime: number
46
+ count: number
47
+ didDocument: DIDDocument | undefined
48
+ }> => {
49
+ const {
50
+ did,
51
+ startIntervalMS = 2000,
52
+ minIntervalMS = 500,
53
+ decreaseIntervalMSPerStep = 250,
54
+ maxWaitTime = 60_000,
55
+ version = 'v5',
56
+ environment = 'pilot',
57
+ searchForObject,
58
+ } = args
59
+
60
+ if (startIntervalMS < minIntervalMS) {
61
+ return Promise.reject(Error(`min interval ${minIntervalMS} needs to be smaller or equal to the start interval ${startIntervalMS}`))
62
+ } else if (decreaseIntervalMSPerStep < 0) {
63
+ return Promise.reject(Error(`decrease interval per step ${decreaseIntervalMSPerStep} needs to be bigger than zero`))
64
+ }
65
+ let interval = startIntervalMS
66
+ let totalWaitTime = 0
67
+ let didDocument: DIDDocument | undefined
68
+ let count = 0
69
+ function logCalback() {
70
+ logger.debug(`Get DID Document; count ${count}: wait time: ${totalWaitTime}, ${did}`)
71
+ }
72
+ while (!didDocument && totalWaitTime <= maxWaitTime) {
73
+ ++count
74
+ try {
75
+ logCalback()
76
+ didDocument = await ebsiGetDidDocument({ params: { did }, apiOpts: { environment, version } })
77
+ if (searchForObject!! && didDocument) {
78
+ const didDocAsStr = JSON.stringify(didDocument)
79
+ const search = JSON.stringify(searchForObject)
80
+ const found = didDocAsStr.includes(search.substring(1, search.length - 1))
81
+ if (!found) {
82
+ logger.debug(`We did not find VM relationship or key ${JSON.stringify(searchForObject)} in DID document ${did}`)
83
+ didDocument = undefined
84
+ }
85
+ }
86
+ } catch (e) {}
87
+ if (!didDocument) {
88
+ await wait(interval)
89
+ totalWaitTime += interval
90
+ interval = Math.max(interval - decreaseIntervalMSPerStep, minIntervalMS)
91
+ }
92
+ }
93
+ logCalback()
94
+ return { didDocument, totalWaitTime, count }
95
+ }
96
+
97
+ /**
98
+ * listDidDocuments - Returns a list of identifiers.
99
+ * @param {{ params: GetDidDocumentsParams; apiOpts?: ApiOpts }} args
100
+ * @returns a list of identifiers
101
+ */
102
+ export const ebsiListDidDocuments = async (args: { params: GetDidDocumentsParams; apiOpts?: ApiOpts }): Promise<GetDidDocumentsResponse> => {
103
+ const { params, apiOpts } = args
104
+ const { offset, size, controller } = params
105
+ const queryParams: string[] = []
106
+ if (offset) {
107
+ queryParams.push(`page[after]=${offset}`)
108
+ }
109
+ if (size) {
110
+ queryParams.push(`page[size]=${size}`)
111
+ }
112
+ if (controller) {
113
+ queryParams.push(`controller=${controller}`)
114
+ }
115
+ const query = `?${queryParams.filter(Boolean).join('&')}`
116
+ return await (await fetch(`${ebsiGetRegistryAPIUrls({ ...apiOpts }).query}/${query}`)).json()
117
+ }
@@ -0,0 +1,449 @@
1
+ import { W3CVerifiableCredential } from '@sphereon/ssi-types'
2
+ import { IAgentContext, IIdentifier, IKeyManager, MinimalImportableKey, TKeyType } from '@veramo/core'
3
+ import { IService } from '@veramo/core/build/types/IIdentifier'
4
+ import { DIDDocument } from 'did-resolver'
5
+ import { AccessListish, BigNumberish, BytesLike } from 'ethers'
6
+ import { ApiOpts, EbsiEnvironment } from '../types/IEbsiSupport'
7
+
8
+ export type IContext = IAgentContext<IKeyManager>
9
+
10
+ /**
11
+ * The type of the DID to be created
12
+ * @readonly
13
+ * @enum {string}
14
+ */
15
+ export type EbsiDIDType = 'NATURAL_PERSON' | 'LEGAL_ENTITY'
16
+
17
+ /**
18
+ * The DID method to use
19
+ * @readonly
20
+ * @enum {string}
21
+ */
22
+ export type EbsiDIDPrefix = 'did:ebsi:' | 'did:key:'
23
+
24
+ /**
25
+ * @typedef EbsiDidSpecInfo
26
+ * @type {object}
27
+ * @property {EbsiDIDType} type - The type of the DID
28
+ * @property {EbsiDIDPrefix} method - The method of the DID
29
+ * @property {number} version - The version of the specs
30
+ * @property {number} didLength - The length of the DID
31
+ * @property {number} privateKeyLength The private key length
32
+ */
33
+ export interface EbsiDidSpecInfo {
34
+ type: EbsiDIDType
35
+ method: EbsiDIDPrefix
36
+ version?: number
37
+ didLength?: number
38
+ privateKeyLength?: number
39
+ }
40
+
41
+ export const EBSI_DID_SPEC_INFOS: Record<string, EbsiDidSpecInfo> = {
42
+ V1: {
43
+ type: 'LEGAL_ENTITY',
44
+ method: 'did:ebsi:',
45
+ version: 0x01,
46
+ didLength: 16,
47
+ privateKeyLength: 32,
48
+ },
49
+ KEY: {
50
+ type: 'NATURAL_PERSON',
51
+ method: 'did:key:',
52
+ },
53
+ }
54
+
55
+ /**
56
+ * A minimal importable key with restricted types to choose from and purposes of the public key
57
+ * @typedef IKeyOpts
58
+ * @extends MinimalImportableKey
59
+ * @property {EbsiKeyType} type
60
+ * @property {EbsiPublicKeyPurpose[]} purposes
61
+ */
62
+ export interface IKeyOpts extends WithRequiredProperty<Partial<MinimalImportableKey>, 'privateKeyHex'> {
63
+ type?: EbsiKeyType
64
+ purposes?: EbsiPublicKeyPurpose[]
65
+ }
66
+
67
+ // Needed to make a single property required
68
+ type WithRequiredProperty<Type, Key extends keyof Type> = Type & {
69
+ [Property in Key]-?: Type[Property]
70
+ }
71
+
72
+ export type RpcMethodArgs = {
73
+ params: RPCParams[]
74
+ rpcId: number
75
+ accessToken: string
76
+ rpcMethod: EbsiRpcMethod
77
+ apiOpts?: ApiOpts
78
+ doNotThrowErrors?: boolean
79
+ }
80
+
81
+ export type EbsiCreateIdentifierOpts = {
82
+ methodSpecificId?: string
83
+ rpcId?: number
84
+ secp256k1Key?: IKeyOpts
85
+ secp256r1Key?: IKeyOpts
86
+ executeLedgerOperation?: boolean // Whether to persist on the EBSI ledger. By default looks at whether access token opts are set or not
87
+ baseDocument?: string
88
+ notBefore?: number
89
+ notAfter?: number
90
+ accessTokenOpts: EbsiAccessTokenOpts
91
+ services?: IService[]
92
+ }
93
+
94
+ /**
95
+ * @typedef ICreateIdentifierArgs
96
+ * @type {object}
97
+ * @property {string} kms - The kms to use
98
+ * @property {string} alias - The alias of the DID
99
+ * @property {EbsiDidSpecInfo} type
100
+ * @property {string} options.methodSpecificId - method specific id for import
101
+ * @property {IKeyOpts} secp256k1Key - The options to create the key
102
+ * @property {IKeyOpts} secp256r1Key - The options to create the key
103
+ */
104
+ export interface ICreateIdentifierArgs {
105
+ kms?: string
106
+ alias?: string
107
+ type?: EbsiDidSpecInfo
108
+ options: EbsiCreateIdentifierOpts
109
+ }
110
+
111
+ /**
112
+ * The Ebsi allowed key types - Secp256k1 and Secp256r1
113
+ * @readonly
114
+ * @enum {string}
115
+ */
116
+ export type EbsiKeyType = Extract<TKeyType, 'Secp256k1' | 'Secp256r1'>
117
+
118
+ /**
119
+ * The purpose of the public keys
120
+ * @readonly
121
+ * @enum {string}
122
+ */
123
+ export enum EbsiPublicKeyPurpose {
124
+ Authentication = 'authentication',
125
+ AssertionMethod = 'assertionMethod',
126
+ CapabilityInvocation = 'capabilityInvocation',
127
+ }
128
+
129
+ /**
130
+ * @typedef InsertDidDocumentParams
131
+ * @type {object}
132
+ * @property {string} from - Ethereum address of the signer
133
+ * @property {string} did - DID to insert. It must be for a legal entity (DID v1)
134
+ * @property {string} BASE_CONTEXT_DOC - JSON string containing the @context of the DID document
135
+ * @property {string} vMethodId - Thumbprint of the public key
136
+ * @property {string} publicKey - Public key for secp256k1 in uncompressed format prefixed with "0x04"
137
+ * @property {boolean} isSecp256k1 - It must be true
138
+ * @property {number} notBefore - Capability invocation is valid from this time
139
+ * @property {number} notAfter - Expiration of the capability invocation
140
+ */
141
+ export type InsertDidDocumentParams = {
142
+ from: string
143
+ did: string
144
+ baseDocument: string
145
+ vMethodId: string
146
+ publicKey: string
147
+ isSecp256k1: boolean
148
+ notBefore: number
149
+ notAfter: number
150
+ }
151
+
152
+ /**
153
+ * @typedef UpdateBaseDocumentParams
154
+ * @type {object}
155
+ * @property {string} from - Ethereum address of the signer
156
+ * @property {string} did - Existing DID
157
+ * @property {string} BASE_CONTEXT_DOC - JSON string containing the @context of the DID document
158
+ */
159
+ export type UpdateBaseDocumentParams = Pick<InsertDidDocumentParams, 'from' | 'did' | 'baseDocument'>
160
+
161
+ /**
162
+ * @typedef UpdateIdentifierParams
163
+ * @type {object}
164
+ * @property {string} did - A DID
165
+ * @property {Partial<DIDDocument>} document - The partial DID document
166
+ * @property {{ [p: string]: any }} [options] - Any additional options
167
+ */
168
+ export type UpdateIdentifierParams = {
169
+ did: string
170
+ document: Partial<DIDDocument>
171
+ options?: { [p: string]: any }
172
+ }
173
+
174
+ export type AddServiceParams = {
175
+ from: string
176
+ did: string
177
+ service: IService
178
+ }
179
+
180
+ /**
181
+ * @typedef AddVerificationMethodParams
182
+ * @type {object}
183
+ * @property {string} from - Ethereum address of the signer
184
+ * @property {string} did - Existing DID
185
+ * @property {string} vMethodId - New verification method id
186
+ * @property {boolean} isSecp256k1 - Boolean defining if the public key is for secp256k1 curve or not
187
+ * @property {string} publicKey - Public key as hex string. For an ES256K key, it must be in uncompressed format
188
+ * prefixed with "0x04". For other algorithms, it must be the JWK transformed to string and then to hex format.
189
+ */
190
+ export type AddVerificationMethodParams = Pick<InsertDidDocumentParams, 'from' | 'did' | 'vMethodId' | 'isSecp256k1' | 'publicKey'>
191
+
192
+ /**
193
+ * @typedef AddVerificationMethodRelationshipParams
194
+ * @type {object}
195
+ * @property {string} from - Ethereum address of the signer
196
+ * @property {string} did - Existing DID
197
+ * @property {string} name - Name of the verification relationship
198
+ * @property {string} vMethodId - Reference to the verification method
199
+ * @property {number} notBefore - Verification relationship is valid from this time
200
+ * @property {number} notAfter - Expiration of the verification relationship
201
+ */
202
+ export type AddVerificationMethodRelationshipParams = Pick<InsertDidDocumentParams, 'from' | 'did' | 'vMethodId' | 'notBefore' | 'notAfter'> & {
203
+ name: string
204
+ }
205
+
206
+ /**
207
+ * @typedef UnsignedTransaction
208
+ * @type {object}
209
+ * @property {string} from - The sending address.
210
+ * @property {string} to - The receiving address (if EOA, the transaction will transfer value. If a smart contract
211
+ * account, the transaction will use contract code).
212
+ * @property {string} data - Can contain code or a message to the recipient.
213
+ * @property {string} nonce - A number used to track ordering of transactions and prevent replay attacks
214
+ * @property {string} chainId - The Ethereum Network ID (ex: 1 - Ethereum Mainnet).
215
+ * @property {string} gasLimit - The maximum amount of gas units that can be used.
216
+ * @property {string} gasPrice - Gas price provided by the sender in Wei.
217
+ * @property {string} value - The amount of ETH to be sent from the sending address (denominated in Wei)
218
+ */
219
+ export type UnsignedTransaction = {
220
+ to?: string
221
+ nonce?: number
222
+
223
+ gasLimit?: BigNumberish
224
+ gasPrice?: BigNumberish
225
+
226
+ data?: BytesLike
227
+ value?: BigNumberish
228
+ chainId?: number
229
+
230
+ // Typed-Transaction features
231
+ type?: number | null
232
+
233
+ // EIP-2930; Type 1 & EIP-1559; Type 2
234
+ accessList?: AccessListish
235
+
236
+ // EIP-1559; Type 2
237
+ maxPriorityFeePerGas?: BigNumberish
238
+ maxFeePerGas?: BigNumberish
239
+ /*from: string
240
+ to: string
241
+ data: string
242
+ nonce: string
243
+ chainId: string
244
+ gasLimit: string
245
+ gasPrice: string
246
+ value: string*/
247
+ }
248
+ /**
249
+ * @typedef SendSignedTransactionParams
250
+ * @type {object}
251
+ * @property {string} protocol - Example: eth
252
+ * @property {UnsignedTransaction} unsignedTransaction - The unsigned transaction
253
+ * @property {string} r - ECDSA signature r
254
+ * @property {string} s - ECDSA signature s
255
+ * @property {string} v - ECDSA recovery id
256
+ * @property {string} signedRawTransaction - The signed raw transaction
257
+ */
258
+ export type SendSignedTransactionParams = {
259
+ protocol: string
260
+ unsignedTransaction: UnsignedTransaction
261
+ r: string
262
+ s: string
263
+ v: string
264
+ signedRawTransaction: string
265
+ }
266
+
267
+ /**
268
+ * @typedef RpcOkResponse
269
+ * @type {object}
270
+ * @property {string} JSON_RPC_VERSION - Must be exactly "2.0"
271
+ * @property {number} id - Same identifier established by the client in the call
272
+ * @property {object} result - Result of the transaction
273
+ */
274
+ export type RpcOkResponse = {
275
+ jsonrpc: string
276
+ id: number
277
+ result: any
278
+ }
279
+
280
+ export type RpcErrorResponse = {
281
+ jsonrpc: string
282
+ id: number
283
+ error: {
284
+ code: number
285
+ message: string
286
+ }
287
+ }
288
+
289
+ /**
290
+ * @typedef ResponseNot200
291
+ * @type {object}
292
+ * @property {URL | string} type - An absolute URI that identifies the problem type. When dereferenced,
293
+ * it SHOULD provide human-readable documentation for the problem type.
294
+ * @property {string} title - A short summary of the problem type.
295
+ * @property {number} status - The HTTP status code generated by the origin server for this occurrence of the problem.
296
+ * @property {string} detail - A human-readable explanation specific to this occurrence of the problem.
297
+ * @property {URL | string} instance An absolute URI that identifies the specific occurrence of the problem.
298
+ * It may or may not yield further information if dereferenced.
299
+ */
300
+ export type ResponseNot200 = {
301
+ type: URL | string
302
+ id?: number
303
+ title: string
304
+ error?: {
305
+ code: number
306
+ message: string
307
+ }
308
+ status: number
309
+ detail: string
310
+ instance: URL | string
311
+ }
312
+
313
+ /**
314
+ * @typedef GetDidDocumentParams
315
+ * @type {object}
316
+ * @property {string} did
317
+ * @property {string} validAt
318
+ */
319
+ export type GetDidDocumentParams = {
320
+ did: string
321
+ validAt?: string
322
+ }
323
+
324
+ /**
325
+ * @typedef GetDidDocumentsParams
326
+ * @type {object}
327
+ * @property {string} offset Originally page[after] Cursor that points to the end of the page of data that has been returned.
328
+ * @property {number} size Originally page[size] Defines the maximum number of objects that may be returned.
329
+ * @property {string} controller Filter by controller DID.
330
+ */
331
+ export type GetDidDocumentsParams = {
332
+ offset?: string
333
+ size?: number
334
+ controller?: string
335
+ }
336
+
337
+ /**
338
+ * Result of listing dids
339
+ * @typedef {Item}
340
+ * @type {object}
341
+ * @property {string} did - The DID
342
+ * @property {string} href - The referrer of the DID
343
+ */
344
+ export type Item = {
345
+ did: string
346
+ href: string
347
+ }
348
+
349
+ /**
350
+ * The links related to pagination
351
+ * @typedef Links
352
+ * @type {object}
353
+ * @property {string} first - The link to the first page
354
+ * @property {string} prev - The link ot the previous page
355
+ * @property {string} next - The link to the next page
356
+ * @property {string} last - The link to the last page
357
+ */
358
+ export type Links = {
359
+ first: string
360
+ prev: string
361
+ next: string
362
+ last: string
363
+ }
364
+
365
+ /**
366
+ * @typedef GetDidDocumentResponse
367
+ * @type {object}
368
+ * @property {string} self - Absolute path to the collection (consult)
369
+ * @property {Item[]} items - List of DIDs and their referrers
370
+ * @property {number} total - Total number of items across all pages.
371
+ * @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.
372
+ * @property {Links} links - The links related to pagination
373
+ */
374
+ export type GetDidDocumentsResponse = {
375
+ self: string
376
+ items: Item[]
377
+ total: number
378
+ pageSize: number
379
+ links: Links
380
+ }
381
+
382
+ type EbsiAccessTokenOpts = {
383
+ attestationToOnboard?: W3CVerifiableCredential
384
+ jwksUri?: string
385
+ redirectUri: string
386
+ credentialIssuer: string
387
+ clientId: string
388
+ environment: EbsiEnvironment
389
+ }
390
+ /**
391
+ * @typedef CreateEbsiDidParams
392
+ * @type {object}
393
+ * @property {Omit<IIdentifier, 'provider'>} identifier An identifier without the provider
394
+ * @property {ManagedKeyInfo} secp256k1ManagedKeyInfo A Secp256k1 managed key
395
+ * @property {ManagedKeyInfo} secp256r1ManagedKeyInfo A Secp256r1 managed key
396
+ * @property {number} id A client created id
397
+ * @property {string} from The wallet eth like address
398
+ * @property {string} [baseDocument] The base DID document
399
+ * @property {number} notBefore Date of issuance of the identifier
400
+ * @property {number} notAfter Date of expiration of the identifier
401
+ * @property {ApiOpts} [apiOpts] The EBSI API options
402
+ */
403
+ export type CreateEbsiDidParams = {
404
+ identifier: IIdentifier
405
+ rpcId?: number
406
+ notBefore?: number
407
+ notAfter?: number
408
+ baseDocument?: string
409
+ accessTokenOpts: EbsiAccessTokenOpts
410
+ }
411
+
412
+ /**
413
+ * @constant JSON_RPC_VERSION
414
+ */
415
+ export const JSON_RPC_VERSION = '2.0'
416
+
417
+ /**
418
+ * @constant BASE_CONTEXT_DOC
419
+ */
420
+ export const BASE_CONTEXT_DOC = JSON.stringify({ '@context': ['https://www.w3.org/ns/did/v1', 'https://w3id.org/security/suites/jws-2020/v1'] })
421
+
422
+ export interface EbsiDidRegistryAPIEndpoints {
423
+ mutate: string
424
+ query: string
425
+ }
426
+
427
+ /**
428
+ * The EBSI RPC operations
429
+ * @readonly
430
+ * @enum {string}
431
+ */
432
+ export enum EbsiRpcMethod {
433
+ INSERT_DID_DOCUMENT = 'insertDidDocument',
434
+ UPDATE_DID_DOCUMENT = 'updateBaseDocument',
435
+ ADD_VERIFICATION_METHOD = 'addVerificationMethod',
436
+ ADD_VERIFICATION_RELATIONSHIP = 'addVerificationRelationship',
437
+ ADD_SERVICE = 'addService',
438
+ SEND_SIGNED_TRANSACTION = 'sendSignedTransaction',
439
+ }
440
+
441
+ export type RPCParams =
442
+ | InsertDidDocumentParams
443
+ | UpdateBaseDocumentParams
444
+ | AddVerificationMethodParams
445
+ | AddVerificationMethodRelationshipParams
446
+ | SendSignedTransactionParams
447
+ | AddServiceParams
448
+
449
+ export type EbsiRPCResponse = RpcOkResponse | (RpcErrorResponse & { nonce: string })