@sphereon/ssi-sdk-ext.did-utils 0.28.1-feature.oyd.cmsm.improv.21 → 0.28.1-next.53

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.ts CHANGED
@@ -1,3 +1,272 @@
1
- export * from './did-functions';
2
- export * from './types';
3
- //# sourceMappingURL=index.d.ts.map
1
+ import { TKeyType, JwkKeyUse } from '@sphereon/ssi-sdk-ext.key-utils';
2
+ import { JWK } from '@sphereon/ssi-types';
3
+ import { IIdentifier, IAgentContext, IKeyManager, IDIDManager, IResolver, DIDDocumentSection, DIDDocument, IKey, DIDResolutionResult } from '@veramo/core';
4
+ import { _ExtendedIKey, _NormalizedVerificationMethod, _ExtendedVerificationMethod } from '@veramo/utils';
5
+ import { JWTVerifyOptions, JWTHeader, JWTPayload, Signer } from 'did-jwt';
6
+ import { Resolvable, VerificationMethod, DIDResolutionOptions } from 'did-resolver';
7
+
8
+ declare enum SupportedDidMethodEnum {
9
+ DID_ETHR = "ethr",
10
+ DID_KEY = "key",
11
+ DID_LTO = "lto",
12
+ DID_ION = "ion",
13
+ DID_EBSI = "ebsi",
14
+ DID_JWK = "jwk",
15
+ DID_OYD = "oyd"
16
+ }
17
+ declare enum IdentifierAliasEnum {
18
+ PRIMARY = "primary"
19
+ }
20
+ interface ResolveOpts {
21
+ jwtVerifyOpts?: JWTVerifyOptions;
22
+ resolver?: Resolvable;
23
+ resolveUrl?: string;
24
+ noUniversalResolverFallback?: boolean;
25
+ subjectSyntaxTypesSupported?: string[];
26
+ }
27
+ /**
28
+ * @deprecated Replaced by the identifier resolution service
29
+ */
30
+ interface IDIDOptions {
31
+ resolveOpts?: ResolveOpts;
32
+ idOpts: LegacyIIdentifierOpts;
33
+ supportedDIDMethods?: string[];
34
+ }
35
+ type IdentifierProviderOpts = {
36
+ type?: TKeyType;
37
+ use?: string;
38
+ method?: SupportedDidMethodEnum;
39
+ [x: string]: any;
40
+ };
41
+ type CreateIdentifierOpts = {
42
+ method: SupportedDidMethodEnum;
43
+ createOpts?: CreateIdentifierCreateOpts;
44
+ };
45
+ type CreateIdentifierCreateOpts = {
46
+ kms?: string;
47
+ alias?: string;
48
+ options?: IdentifierProviderOpts;
49
+ };
50
+ type CreateOrGetIdentifierOpts = {
51
+ method: SupportedDidMethodEnum;
52
+ createOpts?: CreateIdentifierCreateOpts;
53
+ };
54
+ declare const DID_PREFIX = "did:";
55
+ interface GetOrCreateResult<T> {
56
+ created: boolean;
57
+ result: T;
58
+ }
59
+ /**
60
+ * @deprecated Replaced by new signer
61
+ */
62
+ type SignJwtArgs = {
63
+ idOpts: LegacyIIdentifierOpts;
64
+ header: Partial<JWTHeader>;
65
+ payload: Partial<JWTPayload>;
66
+ options: {
67
+ issuer: string;
68
+ expiresIn?: number;
69
+ canonicalize?: boolean;
70
+ };
71
+ context: IRequiredSignAgentContext;
72
+ };
73
+ /**
74
+ * @deprecated Replaced by new signer
75
+ */
76
+ type GetSignerArgs = {
77
+ idOpts: LegacyIIdentifierOpts;
78
+ context: IRequiredSignAgentContext;
79
+ };
80
+ /**
81
+ * @deprecated Replaced by the identifier resolution service
82
+ */
83
+ type LegacyIIdentifierOpts = {
84
+ identifier: IIdentifier | string;
85
+ };
86
+ type IRequiredSignAgentContext = IAgentContext<IKeyManager & IDIDManager & IResolver>;
87
+
88
+ declare const getAuthenticationKey: ({ identifier, offlineWhenNoDIDRegistered, noVerificationMethodFallback, keyType, controllerKey, }: {
89
+ identifier: IIdentifier;
90
+ keyType?: TKeyType;
91
+ offlineWhenNoDIDRegistered?: boolean;
92
+ noVerificationMethodFallback?: boolean;
93
+ controllerKey?: boolean;
94
+ }, context: IAgentContext<IResolver & IDIDManager>) => Promise<_ExtendedIKey>;
95
+ declare const getFirstKeyWithRelation: ({ identifier, offlineWhenNoDIDRegistered, noVerificationMethodFallback, keyType, controllerKey, vmRelationship, }: {
96
+ identifier: IIdentifier;
97
+ keyType?: TKeyType;
98
+ offlineWhenNoDIDRegistered?: boolean;
99
+ noVerificationMethodFallback?: boolean;
100
+ controllerKey?: boolean;
101
+ vmRelationship: DIDDocumentSection;
102
+ }, context: IAgentContext<IResolver & IDIDManager>) => Promise<_ExtendedIKey>;
103
+ declare const getOrCreatePrimaryIdentifier: (context: IAgentContext<IDIDManager>, opts?: CreateOrGetIdentifierOpts) => Promise<GetOrCreateResult<IIdentifier>>;
104
+ declare const getPrimaryIdentifier: (context: IAgentContext<IDIDManager>, opts?: IdentifierProviderOpts) => Promise<IIdentifier | undefined>;
105
+ declare const createIdentifier: (context: IAgentContext<IDIDManager>, opts?: CreateIdentifierOpts) => Promise<IIdentifier>;
106
+ declare const getFirstKeyWithRelationFromDIDDoc: ({ identifier, vmRelationship, keyType, errorOnNotFound, didDocument, controllerKey, }: {
107
+ identifier: IIdentifier;
108
+ controllerKey?: boolean;
109
+ vmRelationship?: DIDDocumentSection;
110
+ keyType?: TKeyType;
111
+ errorOnNotFound?: boolean;
112
+ didDocument?: DIDDocument;
113
+ }, context: IAgentContext<IResolver & IDIDManager>) => Promise<_ExtendedIKey | undefined>;
114
+ declare const getEthereumAddressFromKey: ({ key }: {
115
+ key: IKey;
116
+ }) => any;
117
+ declare const getControllerKey: ({ identifier }: {
118
+ identifier: IIdentifier;
119
+ }) => IKey;
120
+ declare const getKeys: ({ jwkThumbprint, kms, identifier, kmsKeyRef, keyType, controllerKey, }: {
121
+ identifier: IIdentifier;
122
+ kmsKeyRef?: string;
123
+ keyType?: TKeyType;
124
+ kms?: string;
125
+ jwkThumbprint?: string;
126
+ controllerKey?: boolean;
127
+ }) => IKey[];
128
+ /**
129
+ * Dereferences keys from DID document and normalizes them for easy comparison.
130
+ *
131
+ * When dereferencing keyAgreement keys, only Ed25519 and X25519 curves are supported.
132
+ * Other key types are omitted from the result and Ed25519 keys are converted to X25519
133
+ *
134
+ * @returns a Promise that resolves to the list of dereferenced keys.
135
+ *
136
+ * @beta This API may change without a BREAKING CHANGE notice.
137
+ */
138
+ declare function dereferenceDidKeysWithJwkSupport(didDocument: DIDDocument, section: DIDDocumentSection | undefined, context: IAgentContext<IResolver>): Promise<_NormalizedVerificationMethod[]>;
139
+ declare function jwkTtoPublicKeyHex(jwk: JWK): string;
140
+ /**
141
+ * Converts the publicKey of a VerificationMethod to hex encoding (publicKeyHex)
142
+ *
143
+ * @param pk - the VerificationMethod to be converted
144
+ * @param convert - when this flag is set to true, Ed25519 keys are converted to their X25519 pairs
145
+ * @returns the hex encoding of the public key
146
+ *
147
+ * @beta This API may change without a BREAKING CHANGE notice.
148
+ */
149
+ declare function extractPublicKeyHexWithJwkSupport(pk: _ExtendedVerificationMethod, convert?: boolean): string;
150
+ declare function isEvenHexString(hex: string): boolean;
151
+ /**
152
+ * Converts the publicKey of a VerificationMethod to hex encoding (publicKeyHex)
153
+ *
154
+ * @param pk - the VerificationMethod to be converted
155
+ * @param convert - when this flag is set to true, Ed25519 keys are converted to their X25519 pairs
156
+ * @returns the hex encoding of the public key
157
+ *
158
+ * @beta This API may change without a BREAKING CHANGE notice.
159
+ */
160
+ declare function extractPublicKeyHex(pk: _ExtendedVerificationMethod, convert?: boolean): string;
161
+ declare function verificationMethodToJwk(vm: VerificationMethod, errorOnNotFound?: boolean): JWK | null;
162
+ type DidDocumentJwks = Record<Exclude<DIDDocumentSection, 'publicKey' | 'service'>, Array<JWK>>;
163
+ declare function didDocumentToJwks(didDocument: DIDDocument): DidDocumentJwks;
164
+ /**
165
+ * Maps the keys of a locally managed {@link @veramo/core#IIdentifier | IIdentifier} to the corresponding
166
+ * {@link did-resolver#VerificationMethod | VerificationMethod} entries from the DID document.
167
+ *
168
+ * @param identifier - the identifier to be mapped
169
+ * @param section - the section of the DID document to be mapped (see
170
+ * {@link https://www.w3.org/TR/did-core/#verification-relationships | verification relationships}), but can also be
171
+ * `verificationMethod` to map all the keys.
172
+ * @param didDocument
173
+ * @param context - the veramo agent context, which must contain a {@link @veramo/core#IResolver | IResolver}
174
+ * implementation that can resolve the DID document of the identifier.
175
+ *
176
+ * @returns an array of mapped keys. The corresponding verification method is added to the `meta.verificationMethod`
177
+ * property of the key.
178
+ *
179
+ * @beta This API may change without a BREAKING CHANGE notice.
180
+ */
181
+ declare function mapIdentifierKeysToDocWithJwkSupport({ identifier, vmRelationship, didDocument, kmsKeyRef, }: {
182
+ identifier: IIdentifier;
183
+ vmRelationship?: DIDDocumentSection;
184
+ didDocument?: DIDDocument;
185
+ kmsKeyRef?: string;
186
+ }, context: IAgentContext<IResolver & IDIDManager>): Promise<_ExtendedIKey[]>;
187
+ declare function getAgentDIDMethods(context: IAgentContext<IDIDManager>): Promise<string[]>;
188
+ declare function getDID(idOpts: {
189
+ identifier: IIdentifier | string;
190
+ }): string;
191
+ declare function toDID(identifier: string | IIdentifier | Partial<IIdentifier>): string;
192
+ declare function toDIDs(identifiers?: (string | IIdentifier | Partial<IIdentifier>)[]): string[];
193
+ declare function getKey({ identifier, vmRelationship, kmsKeyRef, }: {
194
+ identifier: IIdentifier;
195
+ vmRelationship?: DIDDocumentSection;
196
+ kmsKeyRef?: string;
197
+ }, context: IAgentContext<IResolver & IDIDManager>): Promise<_ExtendedIKey>;
198
+ /**
199
+ * Get the real kid as used in JWTs. This is the kid in the VM or in the JWT, not the kid in the Veramo/Sphereon keystore. That was just a poorly chosen name
200
+ * @param key
201
+ * @param idOpts
202
+ * @param context
203
+ */
204
+ declare function determineKid({ key, idOpts, }: {
205
+ key: IKey;
206
+ idOpts: {
207
+ identifier: IIdentifier | string;
208
+ kmsKeyRef?: string;
209
+ };
210
+ }, context: IAgentContext<IResolver & IDIDManager>): Promise<string>;
211
+ declare function getSupportedDIDMethods(didOpts: IDIDOptions, context: IAgentContext<IDIDManager>): Promise<string[]>;
212
+ declare function getAgentResolver(context: IAgentContext<IResolver & IDIDManager>, opts?: {
213
+ localResolution?: boolean;
214
+ uniresolverResolution?: boolean;
215
+ resolverResolution?: boolean;
216
+ }): Resolvable;
217
+ declare class AgentDIDResolver implements Resolvable {
218
+ private readonly context;
219
+ private readonly resolverResolution;
220
+ private readonly uniresolverResolution;
221
+ private readonly localResolution;
222
+ constructor(context: IAgentContext<IResolver & IDIDManager>, opts?: {
223
+ uniresolverResolution?: boolean;
224
+ localResolution?: boolean;
225
+ resolverResolution?: boolean;
226
+ });
227
+ resolve(didUrl: string, options?: DIDResolutionOptions): Promise<DIDResolutionResult>;
228
+ }
229
+ /**
230
+ * Please note that this is not an exact representation of the actual DID Document.
231
+ *
232
+ * We try to do our best, to map keys onto relevant verification methods and relationships, but we simply lack the context
233
+ * of the actual DID method here. Do not relly on this method for DID resolution. It is only handy for offline use cases
234
+ * when no DID Document is cached. For DID:WEB it does provide an accurate representation!
235
+ *
236
+ * @param identifier
237
+ * @param opts
238
+ */
239
+ declare function toDidDocument(identifier?: IIdentifier, opts?: {
240
+ did?: string;
241
+ use?: JwkKeyUse[];
242
+ }): DIDDocument | undefined;
243
+ declare function toDidResolutionResult(identifier?: IIdentifier, opts?: {
244
+ did?: string;
245
+ supportedMethods?: string[];
246
+ }): DIDResolutionResult;
247
+ declare function asDidWeb(hostnameOrDID: string): Promise<string>;
248
+ /**
249
+ * @deprecated Replaced by the new signer service
250
+ */
251
+ declare const signDidJWT: (args: SignJwtArgs) => Promise<string>;
252
+ /**
253
+ * @deprecated Replaced by the new signer service
254
+ */
255
+ declare const getDidSigner: (args: GetSignerArgs & {
256
+ idOpts: {
257
+ /**
258
+ * @deprecated
259
+ */
260
+ identifier: IIdentifier | string;
261
+ /**
262
+ * @deprecated
263
+ */
264
+ verificationMethodSection?: DIDDocumentSection;
265
+ /**
266
+ * @deprecated
267
+ */
268
+ kmsKeyRef?: string;
269
+ };
270
+ }) => Promise<Signer>;
271
+
272
+ export { AgentDIDResolver, type CreateIdentifierCreateOpts, type CreateIdentifierOpts, type CreateOrGetIdentifierOpts, DID_PREFIX, type DidDocumentJwks, type GetOrCreateResult, type GetSignerArgs, type IDIDOptions, type IRequiredSignAgentContext, IdentifierAliasEnum, type IdentifierProviderOpts, type ResolveOpts, type SignJwtArgs, SupportedDidMethodEnum, asDidWeb, createIdentifier, dereferenceDidKeysWithJwkSupport, determineKid, didDocumentToJwks, extractPublicKeyHex, extractPublicKeyHexWithJwkSupport, getAgentDIDMethods, getAgentResolver, getAuthenticationKey, getControllerKey, getDID, getDidSigner, getEthereumAddressFromKey, getFirstKeyWithRelation, getFirstKeyWithRelationFromDIDDoc, getKey, getKeys, getOrCreatePrimaryIdentifier, getPrimaryIdentifier, getSupportedDIDMethods, isEvenHexString, jwkTtoPublicKeyHex, mapIdentifierKeysToDocWithJwkSupport, signDidJWT, toDID, toDIDs, toDidDocument, toDidResolutionResult, verificationMethodToJwk };