@sphereon/ssi-sdk.oid4vci-holder 0.32.0 → 0.32.1-next.12
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/agent/OID4VCIHolder.d.ts +1 -1
- package/dist/agent/OID4VCIHolder.d.ts.map +1 -1
- package/dist/agent/OID4VCIHolder.js +17 -9
- package/dist/agent/OID4VCIHolder.js.map +1 -1
- package/dist/agent/OID4VCIHolderService.d.ts.map +1 -1
- package/dist/agent/OID4VCIHolderService.js +28 -7
- package/dist/agent/OID4VCIHolderService.js.map +1 -1
- package/dist/agent/OIDC4VCIBrandingMapper.d.ts +14 -4
- package/dist/agent/OIDC4VCIBrandingMapper.d.ts.map +1 -1
- package/dist/agent/OIDC4VCIBrandingMapper.js +123 -53
- package/dist/agent/OIDC4VCIBrandingMapper.js.map +1 -1
- package/dist/types/IOID4VCIHolder.d.ts +23 -6
- package/dist/types/IOID4VCIHolder.d.ts.map +1 -1
- package/dist/types/IOID4VCIHolder.js.map +1 -1
- package/package.json +13 -13
- package/src/agent/OID4VCIHolder.ts +18 -3
- package/src/agent/OID4VCIHolderService.ts +33 -10
- package/src/agent/OIDC4VCIBrandingMapper.ts +189 -81
- package/src/types/IOID4VCIHolder.ts +30 -6
|
@@ -1,16 +1,82 @@
|
|
|
1
1
|
import { CredentialsSupportedDisplay, NameAndLocale } from '@sphereon/oid4vci-common'
|
|
2
|
-
import { IBasicCredentialClaim, IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding } from '@sphereon/ssi-sdk.data-store'
|
|
3
2
|
import {
|
|
4
|
-
|
|
3
|
+
IBasicCredentialClaim,
|
|
4
|
+
IBasicCredentialLocaleBranding,
|
|
5
|
+
IBasicIssuerLocaleBranding
|
|
6
|
+
} from '@sphereon/ssi-sdk.data-store'
|
|
7
|
+
import {
|
|
8
|
+
SdJwtClaimDisplayMetadata,
|
|
9
|
+
SdJwtClaimMetadata,
|
|
10
|
+
SdJwtClaimPath,
|
|
11
|
+
SdJwtTypeDisplayMetadata
|
|
12
|
+
} from '@sphereon/ssi-types'
|
|
13
|
+
import {
|
|
5
14
|
IssuerLocaleBrandingFromArgs,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
15
|
+
Oid4vciCombineDisplayLocalesFromArgs,
|
|
16
|
+
Oid4vciCredentialDisplayLocalesFromArgs,
|
|
17
|
+
Oid4vciCredentialLocaleBrandingFromArgs,
|
|
18
|
+
Oid4vciGetCredentialBrandingFromArgs,
|
|
19
|
+
Oid4vciIssuerCredentialSubjectLocalesFromArgs,
|
|
20
|
+
SdJwtCombineDisplayLocalesFromArgs,
|
|
21
|
+
SdJwtCredentialClaimLocalesFromArgs,
|
|
22
|
+
SdJwtCredentialDisplayLocalesFromArgs,
|
|
23
|
+
SdJwtCredentialLocaleBrandingFromArgs,
|
|
24
|
+
SdJwtGetCredentialBrandingFromArgs,
|
|
10
25
|
} from '../types/IOID4VCIHolder'
|
|
11
26
|
|
|
12
27
|
// FIXME should we not move this to the branding plugin?
|
|
13
|
-
|
|
28
|
+
|
|
29
|
+
export const oid4vciGetCredentialBrandingFrom = async (args: Oid4vciGetCredentialBrandingFromArgs): Promise<Array<IBasicCredentialLocaleBranding>> => {
|
|
30
|
+
const { credentialDisplay, issuerCredentialSubject } = args
|
|
31
|
+
|
|
32
|
+
return oid4vciCombineDisplayLocalesFrom({
|
|
33
|
+
...(issuerCredentialSubject && { issuerCredentialSubjectLocales: await oid4vciIssuerCredentialSubjectLocalesFrom({ issuerCredentialSubject }) }),
|
|
34
|
+
...(credentialDisplay && { credentialDisplayLocales: await oid4vciCredentialDisplayLocalesFrom({ credentialDisplay }) }),
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const oid4vciCredentialDisplayLocalesFrom = async (args: Oid4vciCredentialDisplayLocalesFromArgs): Promise<Map<string, CredentialsSupportedDisplay>> => {
|
|
39
|
+
const { credentialDisplay } = args
|
|
40
|
+
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
41
|
+
const localeKey = display.locale || ''
|
|
42
|
+
localeDisplays.set(localeKey, display)
|
|
43
|
+
return localeDisplays
|
|
44
|
+
}, new Map<string, CredentialsSupportedDisplay>())
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const oid4vciIssuerCredentialSubjectLocalesFrom = async (args: Oid4vciIssuerCredentialSubjectLocalesFromArgs): Promise<Map<string, Array<IBasicCredentialClaim>>> => {
|
|
48
|
+
const { issuerCredentialSubject } = args
|
|
49
|
+
const localeClaims = new Map<string, Array<IBasicCredentialClaim>>()
|
|
50
|
+
|
|
51
|
+
const processClaimObject = (claim: any, parentKey: string = ''): void => {
|
|
52
|
+
Object.entries(claim).forEach(([key, value]): void => {
|
|
53
|
+
if (key === 'mandatory' || key === 'value_type') {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (key === 'display' && Array.isArray(value)) {
|
|
58
|
+
value.forEach(({ name, locale = '' }: NameAndLocale): void => {
|
|
59
|
+
if (!name) {
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//const localeKey = locale || ''
|
|
64
|
+
if (!localeClaims.has(locale)) {
|
|
65
|
+
localeClaims.set(locale, [])
|
|
66
|
+
}
|
|
67
|
+
localeClaims.get(locale)!.push({ key: parentKey, name })
|
|
68
|
+
})
|
|
69
|
+
} else if (typeof value === 'object' && value !== null) {
|
|
70
|
+
processClaimObject(value, parentKey ? `${parentKey}.${key}` : key)
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
processClaimObject(issuerCredentialSubject)
|
|
76
|
+
return localeClaims
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const oid4vciCredentialLocaleBrandingFrom = async (args: Oid4vciCredentialLocaleBrandingFromArgs): Promise<IBasicCredentialLocaleBranding> => {
|
|
14
80
|
const { credentialDisplay } = args
|
|
15
81
|
|
|
16
82
|
return {
|
|
@@ -59,6 +125,122 @@ export const credentialLocaleBrandingFrom = async (args: CredentialLocaleBrandin
|
|
|
59
125
|
}
|
|
60
126
|
}
|
|
61
127
|
|
|
128
|
+
export const oid4vciCombineDisplayLocalesFrom = async (args: Oid4vciCombineDisplayLocalesFromArgs): Promise<Array<IBasicCredentialLocaleBranding>> => {
|
|
129
|
+
const {
|
|
130
|
+
credentialDisplayLocales = new Map<string, CredentialsSupportedDisplay>(),
|
|
131
|
+
issuerCredentialSubjectLocales = new Map<string, Array<IBasicCredentialClaim>>(),
|
|
132
|
+
} = args
|
|
133
|
+
|
|
134
|
+
const locales: Array<string> = Array.from(new Set([...issuerCredentialSubjectLocales.keys(), ...credentialDisplayLocales.keys()]))
|
|
135
|
+
|
|
136
|
+
return Promise.all(
|
|
137
|
+
locales.map(async (locale: string): Promise<IBasicCredentialLocaleBranding> => {
|
|
138
|
+
const display = credentialDisplayLocales.get(locale)
|
|
139
|
+
const claims = issuerCredentialSubjectLocales.get(locale)
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
...(display && (await oid4vciCredentialLocaleBrandingFrom({ credentialDisplay: display }))),
|
|
143
|
+
...(locale.length > 0 && { locale }),
|
|
144
|
+
claims,
|
|
145
|
+
}
|
|
146
|
+
}),
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export const sdJwtGetCredentialBrandingFrom = async (args: SdJwtGetCredentialBrandingFromArgs): Promise<Array<IBasicCredentialLocaleBranding>> => {
|
|
151
|
+
const { credentialDisplay, claimsMetadata } = args
|
|
152
|
+
|
|
153
|
+
return sdJwtCombineDisplayLocalesFrom({
|
|
154
|
+
...(claimsMetadata && { claimsMetadata: await sdJwtCredentialClaimLocalesFrom({ claimsMetadata }) }),
|
|
155
|
+
...(credentialDisplay && { credentialDisplayLocales: await sdJwtCredentialDisplayLocalesFrom({ credentialDisplay }) }),
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export const sdJwtCredentialDisplayLocalesFrom = async (args: SdJwtCredentialDisplayLocalesFromArgs): Promise<Map<string, SdJwtTypeDisplayMetadata>> => {
|
|
160
|
+
const { credentialDisplay } = args
|
|
161
|
+
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
162
|
+
const localeKey = display.lang || ''
|
|
163
|
+
localeDisplays.set(localeKey, display)
|
|
164
|
+
return localeDisplays
|
|
165
|
+
}, new Map<string, SdJwtTypeDisplayMetadata>())
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export const sdJwtCredentialClaimLocalesFrom = async (args: SdJwtCredentialClaimLocalesFromArgs): Promise<Map<string, Array<IBasicCredentialClaim>>> => {
|
|
169
|
+
const { claimsMetadata } = args
|
|
170
|
+
const localeClaims = new Map<string, Array<IBasicCredentialClaim>>()
|
|
171
|
+
|
|
172
|
+
claimsMetadata.forEach((claim: SdJwtClaimMetadata): void => {
|
|
173
|
+
claim.display?.forEach((display: SdJwtClaimDisplayMetadata): void => {
|
|
174
|
+
const { lang = '', label } = display;
|
|
175
|
+
const key = claim.path.map((value: SdJwtClaimPath) => String(value)).join('.');
|
|
176
|
+
if (!localeClaims.has(lang)) {
|
|
177
|
+
localeClaims.set(lang, [])
|
|
178
|
+
}
|
|
179
|
+
localeClaims.get(lang)!.push({ key, name: label })
|
|
180
|
+
})
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
return localeClaims;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export const sdJwtCredentialLocaleBrandingFrom = async (args: SdJwtCredentialLocaleBrandingFromArgs): Promise<IBasicCredentialLocaleBranding> => {
|
|
187
|
+
const { credentialDisplay } = args
|
|
188
|
+
|
|
189
|
+
return {
|
|
190
|
+
...(credentialDisplay.name && {
|
|
191
|
+
alias: credentialDisplay.name,
|
|
192
|
+
}),
|
|
193
|
+
...(credentialDisplay.lang && {
|
|
194
|
+
locale: credentialDisplay.lang,
|
|
195
|
+
}),
|
|
196
|
+
...(credentialDisplay.rendering?.simple?.logo && {
|
|
197
|
+
logo: {
|
|
198
|
+
...(credentialDisplay.rendering.simple.logo.uri && {
|
|
199
|
+
uri: credentialDisplay.rendering.simple.logo.uri,
|
|
200
|
+
}),
|
|
201
|
+
...(credentialDisplay.rendering.simple.logo.alt_text && {
|
|
202
|
+
alt: credentialDisplay.rendering.simple.logo.alt_text,
|
|
203
|
+
}),
|
|
204
|
+
},
|
|
205
|
+
}),
|
|
206
|
+
...(credentialDisplay.description && {
|
|
207
|
+
description: credentialDisplay.description,
|
|
208
|
+
}),
|
|
209
|
+
...(credentialDisplay.rendering?.simple?.text_color && {
|
|
210
|
+
text: {
|
|
211
|
+
color: credentialDisplay.rendering.simple.text_color,
|
|
212
|
+
},
|
|
213
|
+
}),
|
|
214
|
+
...(credentialDisplay.rendering?.simple?.background_color && {
|
|
215
|
+
background: {
|
|
216
|
+
color: credentialDisplay.rendering.simple.background_color ,
|
|
217
|
+
},
|
|
218
|
+
}),
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export const sdJwtCombineDisplayLocalesFrom = async (args: SdJwtCombineDisplayLocalesFromArgs): Promise<Array<IBasicCredentialLocaleBranding>> => {
|
|
223
|
+
const {
|
|
224
|
+
credentialDisplayLocales = new Map<string, SdJwtTypeDisplayMetadata>(),
|
|
225
|
+
claimsMetadata = new Map<string, Array<IBasicCredentialClaim>>(),
|
|
226
|
+
} = args
|
|
227
|
+
|
|
228
|
+
const locales: Array<string> = Array.from(new Set([...claimsMetadata.keys(), ...credentialDisplayLocales.keys()]))
|
|
229
|
+
|
|
230
|
+
return Promise.all(
|
|
231
|
+
locales.map(async (locale: string): Promise<IBasicCredentialLocaleBranding> => {
|
|
232
|
+
const display = credentialDisplayLocales.get(locale)
|
|
233
|
+
const claims = claimsMetadata.get(locale)
|
|
234
|
+
|
|
235
|
+
return {
|
|
236
|
+
...(display && (await sdJwtCredentialLocaleBrandingFrom({ credentialDisplay: display }))),
|
|
237
|
+
...(locale.length > 0 && { locale }),
|
|
238
|
+
claims,
|
|
239
|
+
}
|
|
240
|
+
}),
|
|
241
|
+
)
|
|
242
|
+
}
|
|
243
|
+
|
|
62
244
|
// TODO since dynamicRegistrationClientMetadata can also be on a RP, we should start using this mapper in a more general way
|
|
63
245
|
export const issuerLocaleBrandingFrom = async (args: IssuerLocaleBrandingFromArgs): Promise<IBasicIssuerLocaleBranding> => {
|
|
64
246
|
const { issuerDisplay, dynamicRegistrationClientMetadata } = args
|
|
@@ -108,77 +290,3 @@ export const issuerLocaleBrandingFrom = async (args: IssuerLocaleBrandingFromArg
|
|
|
108
290
|
}),
|
|
109
291
|
}
|
|
110
292
|
}
|
|
111
|
-
|
|
112
|
-
export const getCredentialBrandingFrom = async (args: CredentialBrandingFromArgs): Promise<Array<IBasicCredentialLocaleBranding>> => {
|
|
113
|
-
const { credentialDisplay, issuerCredentialSubject } = args
|
|
114
|
-
|
|
115
|
-
return combineDisplayLocalesFrom({
|
|
116
|
-
...(issuerCredentialSubject && { issuerCredentialSubjectLocales: await issuerCredentialSubjectLocalesFrom({ issuerCredentialSubject }) }),
|
|
117
|
-
...(credentialDisplay && { credentialDisplayLocales: await credentialDisplayLocalesFrom({ credentialDisplay }) }),
|
|
118
|
-
})
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const credentialDisplayLocalesFrom = async (args: CredentialDisplayLocalesFromArgs): Promise<Map<string, CredentialsSupportedDisplay>> => {
|
|
122
|
-
const { credentialDisplay } = args
|
|
123
|
-
return credentialDisplay.reduce((localeDisplays, display) => {
|
|
124
|
-
const localeKey = display.locale || ''
|
|
125
|
-
localeDisplays.set(localeKey, display)
|
|
126
|
-
return localeDisplays
|
|
127
|
-
}, new Map<string, CredentialsSupportedDisplay>())
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const issuerCredentialSubjectLocalesFrom = async (
|
|
131
|
-
args: IssuerCredentialSubjectLocalesFromArgs,
|
|
132
|
-
): Promise<Map<string, Array<IBasicCredentialClaim>>> => {
|
|
133
|
-
const { issuerCredentialSubject } = args
|
|
134
|
-
const localeClaims = new Map<string, Array<IBasicCredentialClaim>>()
|
|
135
|
-
|
|
136
|
-
const processClaimObject = (claim: any, parentKey: string = ''): void => {
|
|
137
|
-
Object.entries(claim).forEach(([key, value]): void => {
|
|
138
|
-
if (key === 'mandatory' || key === 'value_type') {
|
|
139
|
-
return
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (key === 'display' && Array.isArray(value)) {
|
|
143
|
-
value.forEach(({ name, locale }: NameAndLocale): void => {
|
|
144
|
-
if (!name) {
|
|
145
|
-
return
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const localeKey = locale || ''
|
|
149
|
-
if (!localeClaims.has(localeKey)) {
|
|
150
|
-
localeClaims.set(localeKey, [])
|
|
151
|
-
}
|
|
152
|
-
localeClaims.get(localeKey)!.push({ key: parentKey, name })
|
|
153
|
-
})
|
|
154
|
-
} else if (typeof value === 'object' && value !== null) {
|
|
155
|
-
processClaimObject(value, parentKey ? `${parentKey}.${key}` : key)
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
processClaimObject(issuerCredentialSubject)
|
|
161
|
-
return localeClaims
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
const combineDisplayLocalesFrom = async (args: CombineLocalesFromArgs): Promise<Array<IBasicCredentialLocaleBranding>> => {
|
|
165
|
-
const {
|
|
166
|
-
credentialDisplayLocales = new Map<string, CredentialsSupportedDisplay>(),
|
|
167
|
-
issuerCredentialSubjectLocales = new Map<string, Array<IBasicCredentialClaim>>(),
|
|
168
|
-
} = args
|
|
169
|
-
|
|
170
|
-
const locales: Array<string> = Array.from(new Set([...issuerCredentialSubjectLocales.keys(), ...credentialDisplayLocales.keys()]))
|
|
171
|
-
|
|
172
|
-
return Promise.all(
|
|
173
|
-
locales.map(async (locale: string): Promise<IBasicCredentialLocaleBranding> => {
|
|
174
|
-
const display = credentialDisplayLocales.get(locale)
|
|
175
|
-
const claims = issuerCredentialSubjectLocales.get(locale)
|
|
176
|
-
|
|
177
|
-
return {
|
|
178
|
-
...(display && (await credentialLocaleBrandingFrom({ credentialDisplay: display }))),
|
|
179
|
-
...(locale.length > 0 && { locale }),
|
|
180
|
-
claims,
|
|
181
|
-
}
|
|
182
|
-
}),
|
|
183
|
-
)
|
|
184
|
-
}
|
|
@@ -43,9 +43,11 @@ import {
|
|
|
43
43
|
JoseSignatureAlgorithm,
|
|
44
44
|
JoseSignatureAlgorithmString,
|
|
45
45
|
OriginalVerifiableCredential,
|
|
46
|
+
SdJwtTypeDisplayMetadata,
|
|
47
|
+
SdJwtClaimMetadata,
|
|
46
48
|
W3CVerifiableCredential,
|
|
47
49
|
WrappedVerifiableCredential,
|
|
48
|
-
WrappedVerifiablePresentation
|
|
50
|
+
WrappedVerifiablePresentation
|
|
49
51
|
} from '@sphereon/ssi-types'
|
|
50
52
|
import {
|
|
51
53
|
IAgentContext,
|
|
@@ -667,33 +669,55 @@ export type VerifyEBSICredentialIssuerResult = {
|
|
|
667
669
|
attributes: Attribute[]
|
|
668
670
|
}
|
|
669
671
|
|
|
670
|
-
export type
|
|
672
|
+
export type Oid4vciCredentialLocaleBrandingFromArgs = {
|
|
671
673
|
credentialDisplay: CredentialsSupportedDisplay
|
|
672
674
|
}
|
|
673
675
|
|
|
676
|
+
export type SdJwtCredentialLocaleBrandingFromArgs = {
|
|
677
|
+
credentialDisplay: SdJwtTypeDisplayMetadata
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
export type SdJwtGetCredentialBrandingFromArgs = {
|
|
681
|
+
credentialDisplay?: Array<SdJwtTypeDisplayMetadata>
|
|
682
|
+
claimsMetadata?: Array<SdJwtClaimMetadata>
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
export type SdJwtCredentialClaimLocalesFromArgs = {
|
|
686
|
+
claimsMetadata: Array<SdJwtClaimMetadata>
|
|
687
|
+
}
|
|
688
|
+
|
|
674
689
|
export type IssuerLocaleBrandingFromArgs = {
|
|
675
690
|
issuerDisplay: MetadataDisplay
|
|
676
691
|
dynamicRegistrationClientMetadata?: DynamicRegistrationClientMetadataDisplay
|
|
677
692
|
}
|
|
678
693
|
|
|
679
|
-
export type
|
|
694
|
+
export type Oid4vciGetCredentialBrandingFromArgs = {
|
|
680
695
|
credentialDisplay?: Array<CredentialsSupportedDisplay>
|
|
681
696
|
issuerCredentialSubject?: IssuerCredentialSubject
|
|
682
697
|
}
|
|
683
698
|
|
|
684
|
-
export type
|
|
699
|
+
export type Oid4vciCredentialDisplayLocalesFromArgs = {
|
|
685
700
|
credentialDisplay: Array<CredentialsSupportedDisplay>
|
|
686
701
|
}
|
|
687
702
|
|
|
688
|
-
export type
|
|
703
|
+
export type SdJwtCredentialDisplayLocalesFromArgs = {
|
|
704
|
+
credentialDisplay: Array<SdJwtTypeDisplayMetadata>
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
export type Oid4vciIssuerCredentialSubjectLocalesFromArgs = {
|
|
689
708
|
issuerCredentialSubject: IssuerCredentialSubject
|
|
690
709
|
}
|
|
691
710
|
|
|
692
|
-
export type
|
|
711
|
+
export type Oid4vciCombineDisplayLocalesFromArgs = {
|
|
693
712
|
credentialDisplayLocales?: Map<string, CredentialsSupportedDisplay>
|
|
694
713
|
issuerCredentialSubjectLocales?: Map<string, Array<IBasicCredentialClaim>>
|
|
695
714
|
}
|
|
696
715
|
|
|
716
|
+
export type SdJwtCombineDisplayLocalesFromArgs = {
|
|
717
|
+
credentialDisplayLocales?: Map<string, SdJwtTypeDisplayMetadata>
|
|
718
|
+
claimsMetadata?: Map<string, Array<IBasicCredentialClaim>>
|
|
719
|
+
}
|
|
720
|
+
|
|
697
721
|
export type DynamicRegistrationClientMetadataDisplay = Pick<
|
|
698
722
|
DynamicRegistrationClientMetadata,
|
|
699
723
|
'client_name' | 'client_uri' | 'contacts' | 'tos_uri' | 'policy_uri' | 'logo_uri'
|