Skip to content

Commit 71b35d7

Browse files
committed
chore: fixed spread operator
1 parent 4e18635 commit 71b35d7

File tree

1 file changed

+29
-36
lines changed

1 file changed

+29
-36
lines changed

packages/oid4vci-issuer/src/functions.ts

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,12 @@ import {
44
IssuerMetadata,
55
Jwt,
66
JwtVerifyResult,
7-
OID4VCICredentialFormat
7+
OID4VCICredentialFormat,
88
} from '@sphereon/oid4vci-common'
99
import { JWTHeader, JWTPayload } from '@sphereon/oid4vci-common/lib/types'
10-
import {
11-
CredentialDataSupplier,
12-
CredentialIssuanceInput,
13-
CredentialSignerCallback,
14-
VcIssuer,
15-
VcIssuerBuilder
16-
} from '@sphereon/oid4vci-issuer'
10+
import { CredentialDataSupplier, CredentialIssuanceInput, CredentialSignerCallback, VcIssuer, VcIssuerBuilder } from '@sphereon/oid4vci-issuer'
1711
import { getAgentResolver, IDIDOptions } from '@sphereon/ssi-sdk-ext.did-utils'
18-
import {
19-
legacyKeyRefsToIdentifierOpts,
20-
ManagedIdentifierOptsOrResult
21-
} from '@sphereon/ssi-sdk-ext.identifier-resolution'
12+
import { legacyKeyRefsToIdentifierOpts, ManagedIdentifierOptsOrResult } from '@sphereon/ssi-sdk-ext.identifier-resolution'
2213
import { contextHasPlugin } from '@sphereon/ssi-sdk.agent-config'
2314
import { SdJwtVcPayload } from '@sphereon/ssi-sdk.sd-jwt/dist'
2415
import { IStatusListPlugin } from '@sphereon/ssi-sdk.vc-status-list'
@@ -35,7 +26,7 @@ export function getJwtVerifyCallback({ verifyOpts }: { verifyOpts?: JWTVerifyOpt
3526
const resolver = getAgentResolver(_context, {
3627
resolverResolution: true,
3728
uniresolverResolution: true,
38-
localResolution: true
29+
localResolution: true,
3930
})
4031
verifyOpts = { ...verifyOpts, resolver: verifyOpts?.resolver } // Resolver separately as that is a function
4132
if (!verifyOpts?.resolver || typeof verifyOpts?.resolver?.resolve !== 'function') {
@@ -60,25 +51,23 @@ export function getJwtVerifyCallback({ verifyOpts }: { verifyOpts?: JWTVerifyOpt
6051
const payload = jwtDecode<JWTPayload>(args.jwt, { header: false })
6152
return {
6253
alg,
63-
...{ identifier },
64-
jwt: { header, payload }
54+
...identifier,
55+
jwt: { header, payload },
6556
} as JwtVerifyResult<DIDDocument>
6657
}
6758

68-
6959
const decodedJwt = (await decodeJWT(args.jwt)) as Jwt
7060
const kid = args.kid ?? decodedJwt.header.kid
7161

7262
if (!kid || !kid.startsWith('did:')) {
7363
// No DID method present in header. We already performed the validation above. So return that
7464
return {
7565
alg: decodedJwt.header.alg,
76-
jwt: decodedJwt
66+
jwt: decodedJwt,
7767
} as JwtVerifyResult<DIDDocument>
7868
}
7969
const did = kid.split('#')[0]
8070

81-
8271
const didResult = await verifyJWT(args.jwt, verifyOpts)
8372
if (!didResult.verified) {
8473
console.log(`JWT invalid: ${args.jwt}`)
@@ -96,9 +85,8 @@ export function getJwtVerifyCallback({ verifyOpts }: { verifyOpts?: JWTVerifyOpt
9685
kid,
9786
did,
9887
didDocument: didResolution.didDocument,
99-
jwt: decodedJwt
88+
jwt: decodedJwt,
10089
}
101-
10290
}
10391
}
10492

@@ -121,7 +109,7 @@ export async function getAccessTokenKeyRef(
121109
*/
122110
didOpts?: IDIDOptions
123111
},
124-
context: IRequiredContext
112+
context: IRequiredContext,
125113
) {
126114
let identifier = legacyKeyRefsToIdentifierOpts(opts)
127115
return await context.agent.identifierManagedGet(identifier)
@@ -146,7 +134,7 @@ export async function getAccessTokenSignerCallback(
146134
*/
147135
didOpts?: IDIDOptions
148136
},
149-
context: IRequiredContext
137+
context: IRequiredContext,
150138
) {
151139
const signer = async (data: string | Uint8Array) => {
152140
let dataString, encoding: 'base64' | undefined
@@ -181,7 +169,7 @@ export async function getCredentialSignerCallback(
181169
idOpts: ManagedIdentifierOptsOrResult & {
182170
crypto?: Crypto
183171
},
184-
context: IRequiredContext
172+
context: IRequiredContext,
185173
): Promise<CredentialSignerCallback<DIDDocument>> {
186174
async function issueVCCallback(args: {
187175
credentialRequest: CredentialRequest
@@ -228,7 +216,7 @@ export async function getCredentialSignerCallback(
228216
removeOriginalFields: false,
229217
fetchRemoteContexts: true,
230218
domain: typeof credential.issuer === 'object' ? credential.issuer.id : credential.issuer,
231-
...(resolution.kid && { header: { kid: resolution.kid } })
219+
...(resolution.kid && { header: { kid: resolution.kid } }),
232220
})
233221
return (proofFormat === 'jwt' && 'jwt' in result.proof ? result.proof.jwt : result) as W3CVerifiableCredential
234222
} else if (CredentialMapper.isSdJwtDecodedCredentialPayload(credential)) {
@@ -246,13 +234,13 @@ export async function getCredentialSignerCallback(
246234
delete credential['disclosureFrame']
247235
} else {
248236
disclosureFrame = {
249-
_sd: credential['_sd']
237+
_sd: credential['_sd'],
250238
}
251239
}
252240
const result = await context.agent.createSdJwtVc({
253241
credentialPayload: sdJwtPayload,
254242
disclosureFrame: disclosureFrame,
255-
resolution
243+
resolution,
256244
})
257245
return result.credential
258246
} /*else if (CredentialMapper.isMsoMdocDecodedCredential(credential)) {
@@ -272,7 +260,7 @@ export async function createVciIssuerBuilder(
272260
resolver?: Resolvable
273261
credentialDataSupplier?: CredentialDataSupplier
274262
},
275-
context: IRequiredContext
263+
context: IRequiredContext,
276264
): Promise<VcIssuerBuilder<DIDDocument>> {
277265
const { issuerOpts, issuerMetadata, authorizationServerMetadata } = args
278266

@@ -291,7 +279,7 @@ export async function createVciIssuerBuilder(
291279
...issuerOpts?.didOpts?.resolveOpts?.jwtVerifyOpts,
292280
...args?.issuerOpts?.resolveOpts?.jwtVerifyOpts,
293281
resolver,
294-
audience: issuerMetadata.credential_issuer as string // FIXME legacy version had {display: NameAndLocale | NameAndLocale[]} as credential_issuer
282+
audience: issuerMetadata.credential_issuer as string, // FIXME legacy version had {display: NameAndLocale | NameAndLocale[]} as credential_issuer
295283
}
296284
builder.withIssuerMetadata(issuerMetadata)
297285
builder.withAuthorizationMetadata(authorizationServerMetadata)
@@ -314,19 +302,24 @@ export async function createVciIssuer(
314302
issuerOpts,
315303
issuerMetadata,
316304
authorizationServerMetadata,
317-
credentialDataSupplier
305+
credentialDataSupplier,
318306
}: {
319307
issuerOpts: IIssuerOptions
320308
issuerMetadata: IssuerMetadata
321309
authorizationServerMetadata: AuthorizationServerMetadata
322310
credentialDataSupplier?: CredentialDataSupplier
323311
},
324-
context: IRequiredContext
312+
context: IRequiredContext,
325313
): Promise<VcIssuer<DIDDocument>> {
326-
return (await createVciIssuerBuilder({
327-
issuerOpts,
328-
issuerMetadata,
329-
authorizationServerMetadata,
330-
credentialDataSupplier
331-
}, context)).build()
314+
return (
315+
await createVciIssuerBuilder(
316+
{
317+
issuerOpts,
318+
issuerMetadata,
319+
authorizationServerMetadata,
320+
credentialDataSupplier,
321+
},
322+
context,
323+
)
324+
).build()
332325
}

0 commit comments

Comments
 (0)