@sphereon/ssi-sdk-ext.identifier-resolution 0.24.1-unstable.75 → 0.24.1-unstable.77

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 (48) hide show
  1. package/README.md +380 -1
  2. package/dist/agent/IdentifierResolution.d.ts +9 -1
  3. package/dist/agent/IdentifierResolution.d.ts.map +1 -1
  4. package/dist/agent/IdentifierResolution.js +22 -3
  5. package/dist/agent/IdentifierResolution.js.map +1 -1
  6. package/dist/functions/externalIdentifierFunctions.d.ts +10 -0
  7. package/dist/functions/externalIdentifierFunctions.d.ts.map +1 -0
  8. package/dist/functions/externalIdentifierFunctions.js +167 -0
  9. package/dist/functions/externalIdentifierFunctions.js.map +1 -0
  10. package/dist/functions/index.d.ts +2 -12
  11. package/dist/functions/index.d.ts.map +1 -1
  12. package/dist/functions/index.js +15 -237
  13. package/dist/functions/index.js.map +1 -1
  14. package/dist/functions/managedIdentifierFunctions.d.ts +12 -0
  15. package/dist/functions/managedIdentifierFunctions.d.ts.map +1 -0
  16. package/dist/functions/managedIdentifierFunctions.js +168 -0
  17. package/dist/functions/managedIdentifierFunctions.js.map +1 -0
  18. package/dist/types/IIdentifierResolution.d.ts +18 -159
  19. package/dist/types/IIdentifierResolution.d.ts.map +1 -1
  20. package/dist/types/IIdentifierResolution.js +0 -95
  21. package/dist/types/IIdentifierResolution.js.map +1 -1
  22. package/dist/types/common.d.ts +16 -0
  23. package/dist/types/common.d.ts.map +1 -0
  24. package/dist/types/common.js +32 -0
  25. package/dist/types/common.js.map +1 -0
  26. package/dist/types/externalIdentifierTypes.d.ts +80 -0
  27. package/dist/types/externalIdentifierTypes.d.ts.map +1 -0
  28. package/dist/types/externalIdentifierTypes.js +35 -0
  29. package/dist/types/externalIdentifierTypes.js.map +1 -0
  30. package/dist/types/index.d.ts +5 -0
  31. package/dist/types/index.d.ts.map +1 -0
  32. package/dist/types/index.js +21 -0
  33. package/dist/types/index.js.map +1 -0
  34. package/dist/types/managedIdentifierTypes.d.ts +81 -0
  35. package/dist/types/managedIdentifierTypes.d.ts.map +1 -0
  36. package/dist/types/managedIdentifierTypes.js +41 -0
  37. package/dist/types/managedIdentifierTypes.js.map +1 -0
  38. package/package.json +13 -11
  39. package/plugin.schema.json +1209 -222
  40. package/src/agent/IdentifierResolution.ts +31 -8
  41. package/src/functions/externalIdentifierFunctions.ts +183 -0
  42. package/src/functions/index.ts +2 -267
  43. package/src/functions/managedIdentifierFunctions.ts +178 -0
  44. package/src/types/IIdentifierResolution.ts +35 -278
  45. package/src/types/common.ts +37 -0
  46. package/src/types/externalIdentifierTypes.ts +119 -0
  47. package/src/types/index.ts +4 -0
  48. package/src/types/managedIdentifierTypes.ts +126 -0
@@ -0,0 +1,126 @@
1
+ import { JWK } from '@sphereon/ssi-sdk-ext.key-utils'
2
+ import { DIDDocumentSection, IIdentifier, IKey, TKeyType } from '@veramo/core'
3
+ import { isDidIdentifier, isJwkIdentifier, isKidIdentifier, isX5cIdentifier, JwkInfo } from './common'
4
+
5
+ /**
6
+ * Use whenever we need to pass in an identifier. We can pass in kids, DIDs, IIdentifier objects and x5chains
7
+ *
8
+ * The functions below can be used to check the type, and they also provide the proper runtime types
9
+ */
10
+ export type ManagedIdentifierType = IIdentifier /*did*/ | string /*did or kid*/ | string[] /*x5c*/ | JWK
11
+
12
+ export type ManagedIdentifierOpts = (ManagedIdentifierJwkOpts | ManagedIdentifierX5cOpts | ManagedIdentifierDidOpts | ManagedIdentifierKidOpts) &
13
+ ManagedIdentifierOptsBase
14
+
15
+ export type ManagedIdentifierOptsBase = {
16
+ method?: ManagedIdentifierMethod // If provided always takes precedences otherwise it will be inferred from the identifier
17
+ identifier: ManagedIdentifierType
18
+ kmsKeyRef?: string
19
+ issuer?: string // can be used when a specific issuer needs to end up, for instance when signing JWTs. Will be returned or inferred if not provided
20
+ kid?: string // can be used when a specific kid value needs to be used. For instance when signing JWTs. Will be returned or inferred if not provided
21
+ }
22
+
23
+ export type ManagedIdentifierDidOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
24
+ method?: 'did'
25
+ identifier: IIdentifier | string
26
+ keyType?: TKeyType
27
+ offlineWhenNoDIDRegistered?: boolean
28
+ noVerificationMethodFallback?: boolean
29
+ controllerKey?: boolean
30
+ vmRelationship?: DIDDocumentSection
31
+ }
32
+
33
+ export function isManagedIdentifierDidOpts(opts: ManagedIdentifierOptsBase): opts is ManagedIdentifierDidOpts {
34
+ const { identifier } = opts
35
+ return ('method' in opts && opts.method === 'did') || isDidIdentifier(identifier)
36
+ }
37
+
38
+ export type ManagedIdentifierKidOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
39
+ method?: 'kid'
40
+ identifier: string
41
+ }
42
+
43
+ export function isManagedIdentifierKidOpts(opts: ManagedIdentifierOptsBase): opts is ManagedIdentifierKidOpts {
44
+ const { identifier } = opts
45
+ return ('method' in opts && opts.method === 'kid') || isKidIdentifier(identifier)
46
+ }
47
+
48
+ export type ManagedIdentifierJwkOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
49
+ method?: 'jwk'
50
+ identifier: JWK
51
+ }
52
+
53
+ export function isManagedIdentifierJwkOpts(opts: ManagedIdentifierOptsBase): opts is ManagedIdentifierJwkOpts {
54
+ const { identifier } = opts
55
+ return ('method' in opts && opts.method === 'jwk') || isJwkIdentifier(identifier)
56
+ }
57
+
58
+ export type ManagedIdentifierX5cOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
59
+ method?: 'x5c'
60
+ identifier: string[]
61
+ }
62
+
63
+ export function isManagedIdentifierX5cOpts(opts: ManagedIdentifierOptsBase): opts is ManagedIdentifierX5cOpts {
64
+ const { identifier } = opts
65
+ return ('method' in opts && opts.method === 'x5c') || isX5cIdentifier(identifier)
66
+ }
67
+
68
+ export interface ManagedJwkInfo extends JwkInfo {
69
+ kmsKeyRef: string
70
+ }
71
+
72
+ export interface IManagedIdentifierResultBase extends ManagedJwkInfo {
73
+ method: ManagedIdentifierMethod
74
+ key: IKey
75
+ kid?: string
76
+ issuer?: string
77
+ }
78
+
79
+ export function isManagedIdentifierDidResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierDidResult {
80
+ return object!! && typeof object === 'object' && 'method' in object && object.method === 'did'
81
+ }
82
+
83
+ export function isManagedIdentifierX5cResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierDidResult {
84
+ return object!! && typeof object === 'object' && 'method' in object && object.method === 'x5c'
85
+ }
86
+
87
+ export function isManagedIdentifierJwkResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierJwkResult {
88
+ return object!! && typeof object === 'object' && 'method' in object && object.method === 'jwk'
89
+ }
90
+
91
+ export function isManagedIdentifierKidResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierKidResult {
92
+ return object!! && typeof object === 'object' && 'method' in object && object.method === 'kid'
93
+ }
94
+
95
+ export interface ManagedIdentifierDidResult extends IManagedIdentifierResultBase {
96
+ method: 'did'
97
+ identifier: IIdentifier
98
+ did: string
99
+ // key: IKey // The key associated with the requested did method sections. Controller key in case of no DID method section requested
100
+ keys: Array<IKey> // If there is more than one key for the VM relationship.
101
+ verificationMethodSection?: DIDDocumentSection
102
+ controllerKeyId?: string
103
+ issuer: string
104
+ kid: string
105
+ }
106
+
107
+ export interface ManagedIdentifierJwkResult extends IManagedIdentifierResultBase {
108
+ method: 'jwk'
109
+ }
110
+
111
+ export interface ManagedIdentifierKidResult extends IManagedIdentifierResultBase {
112
+ method: 'kid'
113
+ issuer: string
114
+ kid: string
115
+ }
116
+
117
+ export interface ManagedIdentifierX5cResult extends IManagedIdentifierResultBase {
118
+ method: 'x5c'
119
+ x5c: string[]
120
+ certificate: any // Certificate(JSON_, but trips schema generator. Probably want to create our own DTO
121
+ }
122
+
123
+ export type ManagedIdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid'
124
+
125
+ export type ManagedIdentifierResult = IManagedIdentifierResultBase &
126
+ (ManagedIdentifierX5cResult | ManagedIdentifierDidResult | ManagedIdentifierJwkResult | ManagedIdentifierKidResult)