@sphereon/ssi-sdk-ext.identifier-resolution 0.26.1-feature.SPRIND.116.7 → 0.26.1-feature.SPRIND.124.esim.28
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/IdentifierResolution.d.ts.map +1 -1
- package/dist/agent/IdentifierResolution.js +2 -2
- package/dist/agent/IdentifierResolution.js.map +1 -1
- package/dist/functions/externalIdentifierFunctions.d.ts.map +1 -1
- package/dist/functions/externalIdentifierFunctions.js +2 -2
- package/dist/functions/externalIdentifierFunctions.js.map +1 -1
- package/dist/functions/externalOIDFIdentifier.d.ts.map +1 -1
- package/dist/functions/externalOIDFIdentifier.js +4 -6
- package/dist/functions/externalOIDFIdentifier.js.map +1 -1
- package/dist/functions/managedIdentifierFunctions.d.ts.map +1 -1
- package/dist/functions/managedIdentifierFunctions.js +18 -17
- package/dist/functions/managedIdentifierFunctions.js.map +1 -1
- package/dist/types/IIdentifierResolution.d.ts.map +1 -1
- package/dist/types/externalIdentifierTypes.d.ts +0 -1
- package/dist/types/externalIdentifierTypes.d.ts.map +1 -1
- package/dist/types/externalIdentifierTypes.js +1 -1
- package/dist/types/externalIdentifierTypes.js.map +1 -1
- package/package.json +9 -9
- package/plugin.schema.json +12 -6
- package/src/agent/IdentifierResolution.ts +17 -10
- package/src/functions/externalIdentifierFunctions.ts +2 -3
- package/src/functions/externalOIDFIdentifier.ts +5 -14
- package/src/functions/managedIdentifierFunctions.ts +21 -18
- package/src/types/IIdentifierResolution.ts +9 -3
- package/src/types/IJwtService.d.ts +189 -165
- package/src/types/common.ts +1 -1
- package/src/types/externalIdentifierTypes.ts +10 -4
- package/src/types/managedIdentifierTypes.ts +1 -1
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ErrorMessage,
|
|
3
|
-
ExternalIdentifierOIDFEntityIdOpts,
|
|
4
|
-
ExternalIdentifierOIDFEntityIdResult,
|
|
5
|
-
ExternalJwkInfo,
|
|
6
|
-
TrustedAnchor,
|
|
7
|
-
} from '../types'
|
|
1
|
+
import { ErrorMessage, ExternalIdentifierOIDFEntityIdOpts, ExternalIdentifierOIDFEntityIdResult, ExternalJwkInfo, TrustedAnchor } from '../types'
|
|
8
2
|
import { IAgentContext } from '@veramo/core'
|
|
9
3
|
import { IOIDFClient } from '@sphereon/ssi-sdk.oidf-client'
|
|
10
4
|
import { contextHasPlugin } from '@sphereon/ssi-sdk.agent-config'
|
|
11
5
|
import { IJwsValidationResult } from '../types/IJwtService'
|
|
12
|
-
import {decodeBase64url} from "@veramo/utils";
|
|
13
6
|
|
|
14
7
|
/**
|
|
15
8
|
* Resolves an OIDF Entity ID against multiple trust anchors to establish trusted relationships
|
|
@@ -43,11 +36,10 @@ export async function resolveExternalOIDFEntityIdIdentifier(
|
|
|
43
36
|
const errorList: Record<TrustedAnchor, ErrorMessage> = {}
|
|
44
37
|
const jwkInfos: Array<ExternalJwkInfo> = []
|
|
45
38
|
|
|
46
|
-
let payload: string | undefined
|
|
47
39
|
for (const trustAnchor of trustAnchors) {
|
|
48
40
|
const resolveResult = await context.agent.resolveTrustChain({
|
|
49
41
|
entityIdentifier: identifier,
|
|
50
|
-
trustAnchors: [trustAnchor]
|
|
42
|
+
trustAnchors: [trustAnchor],
|
|
51
43
|
})
|
|
52
44
|
|
|
53
45
|
if (resolveResult.error || !resolveResult.trustChain) {
|
|
@@ -58,7 +50,7 @@ export async function resolveExternalOIDFEntityIdIdentifier(
|
|
|
58
50
|
errorList[trustAnchor] = 'Trust chain is empty'
|
|
59
51
|
continue
|
|
60
52
|
}
|
|
61
|
-
|
|
53
|
+
|
|
62
54
|
const jwt = trustChain[0]
|
|
63
55
|
const jwtVerifyResult: IJwsValidationResult = await context.agent.jwtVerifyJwsSignature({ jws: jwt })
|
|
64
56
|
|
|
@@ -72,14 +64,14 @@ export async function resolveExternalOIDFEntityIdIdentifier(
|
|
|
72
64
|
continue
|
|
73
65
|
}
|
|
74
66
|
|
|
75
|
-
payload = JSON.parse(decodeBase64url(jwtVerifyResult.jws.payload))
|
|
76
67
|
const signature = jwtVerifyResult.jws.signatures[0]
|
|
77
68
|
if (signature.identifier.jwks.length === 0) {
|
|
78
69
|
errorList[trustAnchor] = 'No JWK was present in the trust anchor signature'
|
|
79
70
|
continue
|
|
80
71
|
}
|
|
81
72
|
|
|
82
|
-
if(jwkInfos.length === 0) {
|
|
73
|
+
if (jwkInfos.length === 0) {
|
|
74
|
+
// We need the entity JWK only once
|
|
83
75
|
jwkInfos.push(...signature.identifier.jwks)
|
|
84
76
|
}
|
|
85
77
|
trustedAnchors.add(trustAnchor)
|
|
@@ -91,7 +83,6 @@ export async function resolveExternalOIDFEntityIdIdentifier(
|
|
|
91
83
|
trustedAnchors: Array.from(trustedAnchors),
|
|
92
84
|
...(Object.keys(errorList).length > 0 && { errorList }),
|
|
93
85
|
jwks: jwkInfos,
|
|
94
|
-
jwtPayload: payload,
|
|
95
86
|
trustEstablished: trustedAnchors.size > 0,
|
|
96
87
|
}
|
|
97
88
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getFirstKeyWithRelation } from '@sphereon/ssi-sdk-ext.did-utils'
|
|
2
|
-
import {
|
|
2
|
+
import {calculateJwkThumbprint, coseKeyToJwk, globalCrypto, toJwk} from '@sphereon/ssi-sdk-ext.key-utils'
|
|
3
3
|
import { pemOrDerToX509Certificate } from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
4
4
|
import { contextHasDidManager, contextHasKeyManager } from '@sphereon/ssi-sdk.agent-config'
|
|
5
5
|
import { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
|
|
@@ -246,7 +246,7 @@ export async function getManagedX5cIdentifier(
|
|
|
246
246
|
} else if (!contextHasKeyManager(context)) {
|
|
247
247
|
return Promise.reject(Error(`Cannot get X5c identifier if KeyManager plugin is not enabled!`))
|
|
248
248
|
}
|
|
249
|
-
const cryptoImpl = opts.crypto
|
|
249
|
+
const cryptoImpl = globalCrypto(false, opts.crypto)
|
|
250
250
|
const certificate = pemOrDerToX509Certificate(x5c[0])
|
|
251
251
|
const cryptoEngine = new CryptoEngine({ name: 'identifier_resolver_managed', crypto: cryptoImpl })
|
|
252
252
|
setEngine(cryptoEngine.name, cryptoEngine)
|
|
@@ -274,32 +274,32 @@ export async function getManagedX5cIdentifier(
|
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
export async function getManagedOID4VCIssuerIdentifier(
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
opts: ManagedIdentifierOID4VCIssuerOpts,
|
|
278
|
+
context: IAgentContext<IKeyManager>
|
|
279
279
|
): Promise<ManagedIdentifierOID4VCIssuerResult> {
|
|
280
280
|
const { identifier } = opts
|
|
281
281
|
const method = 'oid4vci-issuer'
|
|
282
282
|
// FIXME: We need to eventually determine the JWK based on the issuer. Using a dummy JWK for now
|
|
283
283
|
const jwk = {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
284
|
+
kty: 'RSA',
|
|
285
|
+
kid: 'dummy-jwk-for-vci-issuer-signing',
|
|
286
|
+
use: 'sig',
|
|
287
|
+
n: 'pjdss8ZaDfEH6K6U7GeW2nxDqR4IP049fk1fK0lndimbMMVBdPv_hSpm8T8EtBDxrUdi1OHZfMhUixGaut-3nQ4GG9nM249oxhCtxqqNvEXrmQRGqczyLxuh-fKn9Fg--hS9UpazHpfVAFnB5aCfXoNhPuI8oByyFKMKaOVgHNqP5NBEqabiLftZD3W_lsFCPGuzr4Vp0YS7zS2hDYScC2oOMu4rGU1LcMZf39p3153Cq7bS2Xh6Y-vw5pwzFYZdjQxDn8x8BG3fJ6j8TGLXQsbKH1218_HcUJRvMwdpbUQG5nvA2GXVqLqdwp054Lzk9_B_f1lVrmOKuHjTNHq48w',
|
|
288
|
+
e: 'AQAB',
|
|
289
|
+
d: 'ksDmucdMJXkFGZxiomNHnroOZxe8AmDLDGO1vhs-POa5PZM7mtUPonxwjVmthmpbZzla-kg55OFfO7YcXhg-Hm2OWTKwm73_rLh3JavaHjvBqsVKuorX3V3RYkSro6HyYIzFJ1Ek7sLxbjDRcDOj4ievSX0oN9l-JZhaDYlPlci5uJsoqro_YrE0PRRWVhtGynd-_aWgQv1YzkfZuMD-hJtDi1Im2humOWxA4eZrFs9eG-whXcOvaSwO4sSGbS99ecQZHM2TcdXeAs1PvjVgQ_dKnZlGN3lTWoWfQP55Z7Tgt8Nf1q4ZAKd-NlMe-7iqCFfsnFwXjSiaOa2CRGZn-Q',
|
|
290
|
+
p: '4A5nU4ahEww7B65yuzmGeCUUi8ikWzv1C81pSyUKvKzu8CX41hp9J6oRaLGesKImYiuVQK47FhZ--wwfpRwHvSxtNU9qXb8ewo-BvadyO1eVrIk4tNV543QlSe7pQAoJGkxCia5rfznAE3InKF4JvIlchyqs0RQ8wx7lULqwnn0',
|
|
291
|
+
q: 'ven83GM6SfrmO-TBHbjTk6JhP_3CMsIvmSdo4KrbQNvp4vHO3w1_0zJ3URkmkYGhz2tgPlfd7v1l2I6QkIh4Bumdj6FyFZEBpxjE4MpfdNVcNINvVj87cLyTRmIcaGxmfylY7QErP8GFA-k4UoH_eQmGKGK44TRzYj5hZYGWIC8',
|
|
292
|
+
dp: 'lmmU_AG5SGxBhJqb8wxfNXDPJjf__i92BgJT2Vp4pskBbr5PGoyV0HbfUQVMnw977RONEurkR6O6gxZUeCclGt4kQlGZ-m0_XSWx13v9t9DIbheAtgVJ2mQyVDvK4m7aRYlEceFh0PsX8vYDS5o1txgPwb3oXkPTtrmbAGMUBpE',
|
|
293
|
+
dq: 'mxRTU3QDyR2EnCv0Nl0TCF90oliJGAHR9HJmBe__EjuCBbwHfcT8OG3hWOv8vpzokQPRl5cQt3NckzX3fs6xlJN4Ai2Hh2zduKFVQ2p-AF2p6Yfahscjtq-GY9cB85NxLy2IXCC0PF--Sq9LOrTE9QV988SJy_yUrAjcZ5MmECk',
|
|
294
|
+
qi: 'ldHXIrEmMZVaNwGzDF9WG8sHj2mOZmQpw9yrjLK9hAsmsNr5LTyqWAqJIYZSwPTYWhY4nu2O0EY9G9uYiqewXfCKw_UngrJt8Xwfq1Zruz0YY869zPN4GiE9-9rzdZB33RBw8kIOquY3MK74FMwCihYx_LiU2YTHkaoJ3ncvtvg',
|
|
295
295
|
} as JWK
|
|
296
296
|
const jwkThumbprint = calculateJwkThumbprint({ jwk })
|
|
297
297
|
|
|
298
298
|
const key = {
|
|
299
299
|
kid: 'dummy-key-for-vci-issuer-signing',
|
|
300
300
|
kms: 'local',
|
|
301
|
-
type:
|
|
302
|
-
publicKeyHex: '9a3f75b2e4d8b91128fc6e9a8f6782e5a4f1cba3718e58b5d0a789d6e5f52b3a'
|
|
301
|
+
type: 'RSA',
|
|
302
|
+
publicKeyHex: '9a3f75b2e4d8b91128fc6e9a8f6782e5a4f1cba3718e58b5d0a789d6e5f52b3a',
|
|
303
303
|
} as IKey
|
|
304
304
|
|
|
305
305
|
return {
|
|
@@ -344,7 +344,10 @@ export async function getManagedIdentifier(
|
|
|
344
344
|
return Promise.reject(Error(`Could not determine identifier method. Please provide explicitly`))
|
|
345
345
|
}
|
|
346
346
|
const { key } = resolutionResult
|
|
347
|
-
if (
|
|
347
|
+
if (
|
|
348
|
+
(!key && !isManagedIdentifierOID4VCIssuerOpts(opts)) ||
|
|
349
|
+
(isManagedIdentifierDidOpts(opts) && isManagedIdentifierDidResult(resolutionResult) && !resolutionResult.identifier)
|
|
350
|
+
) {
|
|
348
351
|
console.log(`Cannot find identifier`, opts.identifier)
|
|
349
352
|
return Promise.reject(`Cannot find identifier ${opts.identifier}`)
|
|
350
353
|
}
|
|
@@ -83,7 +83,10 @@ export interface IIdentifierResolution extends IPluginMethodMap {
|
|
|
83
83
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
84
84
|
): Promise<ManagedIdentifierCoseKeyResult>
|
|
85
85
|
|
|
86
|
-
identifierManagedGetByOID4VCIssuer(
|
|
86
|
+
identifierManagedGetByOID4VCIssuer(
|
|
87
|
+
args: ManagedIdentifierOID4VCIssuerOpts,
|
|
88
|
+
context: IAgentContext<any>
|
|
89
|
+
): Promise<ManagedIdentifierOID4VCIssuerResult>
|
|
87
90
|
|
|
88
91
|
// TODO: We can create a custom managed identifier method allowing developers to register a callback function to get their implementation hooked up. Needs more investigation as it would also impact the KMS
|
|
89
92
|
|
|
@@ -102,6 +105,9 @@ export interface IIdentifierResolution extends IPluginMethodMap {
|
|
|
102
105
|
identifierExternalResolveByCoseKey(args: ExternalIdentifierCoseKeyOpts, context: IAgentContext<any>): Promise<ExternalIdentifierCoseKeyResult>
|
|
103
106
|
|
|
104
107
|
identifierExternalResolveByX5c(args: ExternalIdentifierX5cOpts, context: IAgentContext<any>): Promise<ExternalIdentifierX5cResult>
|
|
105
|
-
|
|
106
|
-
identifierExternalResolveByOIDFEntityId(
|
|
108
|
+
|
|
109
|
+
identifierExternalResolveByOIDFEntityId(
|
|
110
|
+
args: ExternalIdentifierOIDFEntityIdOpts,
|
|
111
|
+
context: IAgentContext<any>
|
|
112
|
+
): Promise<ExternalIdentifierOIDFEntityIdResult>
|
|
107
113
|
}
|
|
@@ -1,225 +1,249 @@
|
|
|
1
|
-
|
|
2
1
|
// Copy of jwt-service typings since we cannot include that as devDependency due to cyclic dep
|
|
3
2
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import {
|
|
4
|
+
ExternalIdentifierDidOpts,
|
|
5
|
+
ExternalIdentifierResult,
|
|
6
|
+
ExternalIdentifierX5cOpts,
|
|
7
|
+
IIdentifierResolution,
|
|
8
|
+
ManagedIdentifierOptsOrResult,
|
|
9
|
+
ManagedIdentifierResult,
|
|
10
|
+
} from '@sphereon/ssi-sdk-ext.identifier-resolution'
|
|
11
|
+
import { ClientIdScheme } from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
12
|
+
import { BaseJWK, IValidationResult, JoseSignatureAlgorithm, JoseSignatureAlgorithmString, JWK } from '@sphereon/ssi-types'
|
|
13
|
+
import { IAgentContext, IKeyManager, IPluginMethodMap } from '@veramo/core'
|
|
14
|
+
export type IRequiredContext = IAgentContext<IIdentifierResolution & IKeyManager>
|
|
15
|
+
export declare const jwtServiceContextMethods: Array<string>
|
|
10
16
|
export interface IJwtService extends IPluginMethodMap {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
jwtPrepareJws(args: CreateJwsJsonArgs, context: IRequiredContext): Promise<PreparedJwsObject>
|
|
18
|
+
jwtCreateJwsJsonGeneralSignature(args: CreateJwsJsonArgs, context: IRequiredContext): Promise<JwsJsonGeneral>
|
|
19
|
+
jwtCreateJwsJsonFlattenedSignature(args: CreateJwsFlattenedArgs, context: IRequiredContext): Promise<JwsJsonFlattened>
|
|
20
|
+
jwtCreateJwsCompactSignature(args: CreateJwsCompactArgs, context: IRequiredContext): Promise<JwtCompactResult>
|
|
21
|
+
jwtVerifyJwsSignature(args: VerifyJwsArgs, context: IRequiredContext): Promise<IJwsValidationResult>
|
|
22
|
+
jwtEncryptJweCompactJwt(args: EncryptJweCompactJwtArgs, context: IRequiredContext): Promise<JwtCompactResult>
|
|
23
|
+
jwtDecryptJweCompactJwt(args: DecryptJweCompactJwtArgs, context: IRequiredContext): Promise<JwtCompactResult>
|
|
18
24
|
}
|
|
19
25
|
export type IJwsValidationResult = IValidationResult & {
|
|
20
|
-
|
|
21
|
-
}
|
|
26
|
+
jws: JwsJsonGeneralWithIdentifiers
|
|
27
|
+
}
|
|
22
28
|
export interface PreparedJws {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
protectedHeader: JwsHeader
|
|
30
|
+
payload: Uint8Array
|
|
31
|
+
unprotectedHeader?: JwsHeader
|
|
32
|
+
existingSignatures?: Array<JwsJsonSignature>
|
|
27
33
|
}
|
|
28
34
|
export interface JwsJsonSignature {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
protected: string
|
|
36
|
+
header?: JwsHeader
|
|
37
|
+
signature: string
|
|
32
38
|
}
|
|
33
39
|
/**
|
|
34
40
|
* The JWK representation of an ephemeral public key.
|
|
35
41
|
* See https://www.rfc-editor.org/rfc/rfc7518.html#section-6
|
|
36
42
|
*/
|
|
37
|
-
export type EphemeralPublicKey = Omit<BaseJWK, 'alg'
|
|
43
|
+
export type EphemeralPublicKey = Omit<BaseJWK, 'alg'>
|
|
38
44
|
export interface JweHeader extends Omit<BaseJwtHeader, 'alg'> {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
alg: string
|
|
46
|
+
enc: string
|
|
47
|
+
jku?: string
|
|
48
|
+
jwk?: BaseJWK
|
|
49
|
+
epk?: EphemeralPublicKey
|
|
50
|
+
x5u?: string
|
|
51
|
+
x5c?: string[]
|
|
52
|
+
x5t?: string
|
|
53
|
+
cty?: string
|
|
54
|
+
crit?: string[]
|
|
55
|
+
[k: string]: any
|
|
50
56
|
}
|
|
51
57
|
export interface JweRecipientUnprotectedHeader {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
alg: string
|
|
59
|
+
iv: string
|
|
60
|
+
tag: string
|
|
61
|
+
epk?: EphemeralPublicKey
|
|
62
|
+
kid?: string
|
|
63
|
+
apv?: string
|
|
64
|
+
apu?: string
|
|
59
65
|
}
|
|
60
66
|
export interface JweProtectedHeader extends Partial<JweHeader> {
|
|
61
|
-
|
|
67
|
+
zip?: 'DEF' | string
|
|
62
68
|
}
|
|
63
|
-
export type Jws = JwsCompact | JwsJsonFlattened | JwsJsonGeneral
|
|
64
|
-
export type JwsCompact = string
|
|
69
|
+
export type Jws = JwsCompact | JwsJsonFlattened | JwsJsonGeneral
|
|
70
|
+
export type JwsCompact = string
|
|
65
71
|
export interface JwsJsonFlattened {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
payload: string
|
|
73
|
+
protected: string
|
|
74
|
+
header?: JwsHeader
|
|
75
|
+
signature: string
|
|
70
76
|
}
|
|
71
77
|
export interface JwsJsonGeneral {
|
|
72
|
-
|
|
73
|
-
|
|
78
|
+
payload: string
|
|
79
|
+
signatures: Array<JwsJsonSignature>
|
|
74
80
|
}
|
|
75
81
|
export interface JwsJsonGeneralWithIdentifiers extends JwsJsonGeneral {
|
|
76
|
-
|
|
82
|
+
signatures: Array<JwsJsonSignatureWithIdentifier>
|
|
77
83
|
}
|
|
78
84
|
export interface JwsJsonSignatureWithIdentifier extends JwsJsonSignature {
|
|
79
|
-
|
|
85
|
+
identifier: ExternalIdentifierResult
|
|
80
86
|
}
|
|
81
|
-
export type Jwe = JweCompact | JweJsonFlattened | JweJsonGeneral
|
|
82
|
-
export type JweCompact = string
|
|
87
|
+
export type Jwe = JweCompact | JweJsonFlattened | JweJsonGeneral
|
|
88
|
+
export type JweCompact = string
|
|
83
89
|
export interface JweJsonFlattened {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
protected: string
|
|
91
|
+
unprotected: JweHeader
|
|
92
|
+
header: JweHeader | JweRecipientUnprotectedHeader
|
|
93
|
+
encrypted_key?: string
|
|
94
|
+
aad?: string
|
|
95
|
+
iv: string
|
|
96
|
+
ciphertext: string
|
|
97
|
+
tag?: string
|
|
92
98
|
}
|
|
93
99
|
export interface JweRecipient {
|
|
94
|
-
|
|
95
|
-
|
|
100
|
+
header?: JweRecipientUnprotectedHeader
|
|
101
|
+
encrypted_key?: string
|
|
96
102
|
}
|
|
97
103
|
export interface JweJsonGeneral {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
protected: string
|
|
105
|
+
unprotected?: JweHeader
|
|
106
|
+
recipients: Array<JweRecipient>
|
|
107
|
+
aad?: string
|
|
108
|
+
iv: string
|
|
109
|
+
ciphertext: string
|
|
110
|
+
tag?: string
|
|
105
111
|
}
|
|
106
112
|
export interface PreparedJwsObject {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
jws: PreparedJws
|
|
114
|
+
b64: {
|
|
115
|
+
payload: string
|
|
116
|
+
protectedHeader: string
|
|
117
|
+
}
|
|
118
|
+
identifier: ManagedIdentifierResult
|
|
113
119
|
}
|
|
114
120
|
export interface BaseJwtHeader {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
typ?: string
|
|
122
|
+
alg?: string
|
|
123
|
+
kid?: string
|
|
118
124
|
}
|
|
119
125
|
export interface BaseJwtPayload {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
iss?: string
|
|
127
|
+
sub?: string
|
|
128
|
+
aud?: string[] | string
|
|
129
|
+
exp?: number
|
|
130
|
+
nbf?: number
|
|
131
|
+
iat?: number
|
|
132
|
+
jti?: string
|
|
127
133
|
}
|
|
128
134
|
export interface JwsHeader extends BaseJwtHeader {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
135
|
+
kid?: string
|
|
136
|
+
jwk?: JWK
|
|
137
|
+
x5c?: string[]
|
|
138
|
+
[key: string]: unknown
|
|
133
139
|
}
|
|
134
140
|
export interface JwsPayload extends BaseJwtPayload {
|
|
135
|
-
|
|
141
|
+
[key: string]: unknown
|
|
136
142
|
}
|
|
137
143
|
export interface JwsHeaderOpts {
|
|
138
|
-
|
|
144
|
+
alg: JoseSignatureAlgorithm | JoseSignatureAlgorithmString
|
|
139
145
|
}
|
|
140
|
-
export type JwsIdentifierMode = 'x5c' | 'kid' | 'jwk' | 'did' | 'auto'
|
|
146
|
+
export type JwsIdentifierMode = 'x5c' | 'kid' | 'jwk' | 'did' | 'auto'
|
|
141
147
|
export type EncryptJweCompactJwtArgs = {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
148
|
+
payload: JwsPayload
|
|
149
|
+
protectedHeader?: JweProtectedHeader | undefined
|
|
150
|
+
aad?: Uint8Array | undefined
|
|
151
|
+
recipientKey: ExternalIdentifierResult & {
|
|
152
|
+
kid?: string
|
|
153
|
+
}
|
|
154
|
+
alg?: JweAlg
|
|
155
|
+
enc?: JweEnc
|
|
156
|
+
apu?: string
|
|
157
|
+
apv?: string
|
|
158
|
+
expirationTime?: number | string | Date
|
|
159
|
+
issuer?: string
|
|
160
|
+
audience?: string | string[]
|
|
161
|
+
}
|
|
156
162
|
export type DecryptJweCompactJwtArgs = {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
163
|
+
jwe: JweCompact
|
|
164
|
+
idOpts: ManagedIdentifierOptsOrResult
|
|
165
|
+
}
|
|
160
166
|
export type CreateJwsArgs = {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
167
|
+
mode?: JwsIdentifierMode
|
|
168
|
+
issuer: ManagedIdentifierOptsOrResult & {
|
|
169
|
+
noIssPayloadUpdate?: boolean
|
|
170
|
+
noIdentifierInHeader?: boolean
|
|
171
|
+
}
|
|
172
|
+
clientId?: string
|
|
173
|
+
clientIdScheme?: ClientIdScheme | 'did' | string
|
|
174
|
+
protectedHeader: JwsHeader
|
|
175
|
+
payload: JwsPayload | Uint8Array | string
|
|
176
|
+
}
|
|
171
177
|
export type CreateJweArgs = {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
export type CreateJwsCompactArgs = CreateJwsArgs
|
|
184
|
-
export type CreateJwsFlattenedArgs = Exclude<CreateJwsJsonArgs, 'existingSignatures'
|
|
178
|
+
mode?: JwsIdentifierMode
|
|
179
|
+
issuer: ManagedIdentifierOptsOrResult & {
|
|
180
|
+
noIssPayloadUpdate?: boolean
|
|
181
|
+
noIdentifierInHeader?: boolean
|
|
182
|
+
}
|
|
183
|
+
protectedHeader: JweProtectedHeader
|
|
184
|
+
encryptedKey: string | EphemeralPublicKey
|
|
185
|
+
iv: string
|
|
186
|
+
ciphertext: string
|
|
187
|
+
tag: string
|
|
188
|
+
}
|
|
189
|
+
export type CreateJwsCompactArgs = CreateJwsArgs
|
|
190
|
+
export type CreateJwsFlattenedArgs = Exclude<CreateJwsJsonArgs, 'existingSignatures'>
|
|
185
191
|
export type VerifyJwsArgs = {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
192
|
+
jws: Jws
|
|
193
|
+
jwk?: JWK
|
|
194
|
+
opts?: {
|
|
195
|
+
x5c?: Omit<ExternalIdentifierX5cOpts, 'identifier'>
|
|
196
|
+
did?: Omit<ExternalIdentifierDidOpts, 'identifier'>
|
|
197
|
+
}
|
|
198
|
+
}
|
|
193
199
|
/**
|
|
194
200
|
* @public
|
|
195
201
|
*/
|
|
196
202
|
export type CreateJwsJsonArgs = CreateJwsArgs & {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
203
|
+
unprotectedHeader?: JwsHeader
|
|
204
|
+
existingSignatures?: Array<JwsJsonSignature>
|
|
205
|
+
}
|
|
200
206
|
export type CreateJweJsonArgs = CreateJweArgs & {
|
|
201
|
-
|
|
202
|
-
}
|
|
207
|
+
unprotectedHeader?: JweHeader
|
|
208
|
+
}
|
|
203
209
|
/**
|
|
204
210
|
* @public
|
|
205
211
|
*/
|
|
206
212
|
export interface JwtCompactResult {
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
export declare function isJwsCompact(jws: Jws): jws is JwsCompact
|
|
210
|
-
export declare function isJweCompact(jwe: Jwe): jwe is JweCompact
|
|
211
|
-
export declare function isJwsJsonFlattened(jws: Jws): jws is JwsJsonFlattened
|
|
212
|
-
export declare function isJwsJsonGeneral(jws: Jws): jws is JwsJsonGeneral
|
|
213
|
-
export declare function isJweJsonFlattened(jwe: Jwe): jwe is JweJsonFlattened
|
|
214
|
-
export declare function isJweJsonGeneral(jwe: Jwe): jwe is JweJsonGeneral
|
|
215
|
-
export declare function isJwsHeader(header: BaseJwtHeader & Record<string, any>): header is JwsHeader
|
|
216
|
-
export declare function isJweHeader(header: BaseJwtHeader & Record<string, any>): header is JweHeader
|
|
217
|
-
export declare const COMPACT_JWS_REGEX: RegExp
|
|
218
|
-
export declare const COMPACT_JWE_REGEX: RegExp
|
|
219
|
-
export declare const JweAlgs: readonly [
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
213
|
+
jwt: JwsCompact | JweCompact
|
|
214
|
+
}
|
|
215
|
+
export declare function isJwsCompact(jws: Jws): jws is JwsCompact
|
|
216
|
+
export declare function isJweCompact(jwe: Jwe): jwe is JweCompact
|
|
217
|
+
export declare function isJwsJsonFlattened(jws: Jws): jws is JwsJsonFlattened
|
|
218
|
+
export declare function isJwsJsonGeneral(jws: Jws): jws is JwsJsonGeneral
|
|
219
|
+
export declare function isJweJsonFlattened(jwe: Jwe): jwe is JweJsonFlattened
|
|
220
|
+
export declare function isJweJsonGeneral(jwe: Jwe): jwe is JweJsonGeneral
|
|
221
|
+
export declare function isJwsHeader(header: BaseJwtHeader & Record<string, any>): header is JwsHeader
|
|
222
|
+
export declare function isJweHeader(header: BaseJwtHeader & Record<string, any>): header is JweHeader
|
|
223
|
+
export declare const COMPACT_JWS_REGEX: RegExp
|
|
224
|
+
export declare const COMPACT_JWE_REGEX: RegExp
|
|
225
|
+
export declare const JweAlgs: readonly [
|
|
226
|
+
'RSA1_5',
|
|
227
|
+
'RSA-OAEP',
|
|
228
|
+
'RSA-OAEP-256',
|
|
229
|
+
'A128KW',
|
|
230
|
+
'A192KW',
|
|
231
|
+
'A256KW',
|
|
232
|
+
'dir',
|
|
233
|
+
'ECDH-ES',
|
|
234
|
+
'ECDH-ES+A128KW',
|
|
235
|
+
'ECDH-ES+A192KW',
|
|
236
|
+
'ECDH-ES+A256KW',
|
|
237
|
+
'A128GCMKW',
|
|
238
|
+
'A192GCMKW',
|
|
239
|
+
'A256GCMKW',
|
|
240
|
+
'PBES2-HS256+A128KW',
|
|
241
|
+
'PBES2-HS384+A192KW',
|
|
242
|
+
'PBES2-HS512+A256KW'
|
|
243
|
+
]
|
|
244
|
+
export type JweAlg = (typeof JweAlgs)[number]
|
|
245
|
+
export declare function jweAlg(alg?: string | JweAlg): JweAlg | undefined
|
|
246
|
+
export declare const JweEncs: readonly ['A128CBC-HS256', 'A192CBC-HS384', 'A256CBC-HS512', 'A128GCM', 'A192GCM', 'A256GCM']
|
|
247
|
+
export type JweEnc = (typeof JweEncs)[number]
|
|
248
|
+
export declare function jweEnc(alg?: string | JweEnc): JweEnc | undefined
|
|
225
249
|
//# sourceMappingURL=IJwtService.d.ts.map
|
package/src/types/common.ts
CHANGED
|
@@ -51,7 +51,7 @@ export function isCoseKeyIdentifier(identifier: ManagedIdentifierType): identifi
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export function isOIDFEntityIdIdentifier(identifier: ManagedIdentifierType): identifier is string {
|
|
54
|
-
return typeof identifier === 'string' && identifier.startsWith('https://')
|
|
54
|
+
return typeof identifier === 'string' && identifier.startsWith('https://')
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
export function isX5cIdentifier(identifier: ManagedIdentifierType | ExternalIdentifierType): identifier is string[] {
|
|
@@ -5,7 +5,8 @@ import { IParsedDID } from '@sphereon/ssi-types'
|
|
|
5
5
|
import { DIDDocument, DIDDocumentSection, DIDResolutionResult } from '@veramo/core'
|
|
6
6
|
import {
|
|
7
7
|
isCoseKeyIdentifier,
|
|
8
|
-
isDidIdentifier,
|
|
8
|
+
isDidIdentifier,
|
|
9
|
+
isOIDFEntityIdIdentifier,
|
|
9
10
|
isJwkIdentifier,
|
|
10
11
|
isJwksUrlIdentifier,
|
|
11
12
|
isKidIdentifier,
|
|
@@ -110,7 +111,7 @@ export type ExternalIdentifierOIDFEntityIdOpts = Omit<ExternalIdentifierOptsBase
|
|
|
110
111
|
|
|
111
112
|
export function isExternalIdentifierOIDFEntityIdOpts(opts: ExternalIdentifierOptsBase): opts is ExternalIdentifierOIDFEntityIdOpts {
|
|
112
113
|
const { identifier } = opts
|
|
113
|
-
return ('method' in opts && opts.method === 'entity_id' || 'trustAnchors' in opts) && isOIDFEntityIdIdentifier(identifier)
|
|
114
|
+
return (('method' in opts && opts.method === 'entity_id') || 'trustAnchors' in opts) && isOIDFEntityIdIdentifier(identifier)
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
export type ExternalIdentifierX5cOpts = Omit<ExternalIdentifierOptsBase, 'method'> &
|
|
@@ -130,7 +131,13 @@ export function isExternalIdentifierX5cOpts(opts: ExternalIdentifierOptsBase): o
|
|
|
130
131
|
export type ExternalIdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid' | 'cose_key' | 'oidc-discovery' | 'jwks-url' | 'oid4vci-issuer' | 'entity_id'
|
|
131
132
|
|
|
132
133
|
export type ExternalIdentifierResult = IExternalIdentifierResultBase &
|
|
133
|
-
(
|
|
134
|
+
(
|
|
135
|
+
| ExternalIdentifierDidResult
|
|
136
|
+
| ExternalIdentifierX5cResult
|
|
137
|
+
| ExternalIdentifierJwkResult
|
|
138
|
+
| ExternalIdentifierOIDFEntityIdResult
|
|
139
|
+
| ExternalIdentifierCoseKeyResult
|
|
140
|
+
)
|
|
134
141
|
|
|
135
142
|
export interface IExternalIdentifierResultBase {
|
|
136
143
|
method: ExternalIdentifierMethod
|
|
@@ -165,7 +172,6 @@ export interface ExternalIdentifierOIDFEntityIdResult extends IExternalIdentifie
|
|
|
165
172
|
method: 'entity_id'
|
|
166
173
|
trustedAnchors: Array<TrustedAnchor>
|
|
167
174
|
errorList?: Record<TrustedAnchor, ErrorMessage>
|
|
168
|
-
jwtPayload?: string
|
|
169
175
|
trustEstablished: boolean
|
|
170
176
|
}
|
|
171
177
|
|