@sphereon/ssi-sdk-ext.identifier-resolution 0.29.1-next.3 → 0.34.1-feature.merge.crypto.extensions.modules.33

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.
@@ -1,8 +1,16 @@
1
- import type { ErrorMessage, ExternalIdentifierOIDFEntityIdOpts, ExternalIdentifierOIDFEntityIdResult, ExternalJwkInfo, TrustedAnchor } from '../types'
1
+ import type {
2
+ ErrorMessage,
3
+ ExternalIdentifierOIDFEntityIdOpts,
4
+ ExternalIdentifierOIDFEntityIdResult,
5
+ ExternalJwkInfo,
6
+ IJwsValidationResult,
7
+ JwtPayload,
8
+ TrustedAnchor,
9
+ } from '../types'
2
10
  import type { IAgentContext } from '@veramo/core'
3
11
  import type { IOIDFClient } from '@sphereon/ssi-sdk.oidf-client'
4
12
  import { contextHasPlugin } from '@sphereon/ssi-sdk.agent-config'
5
- import type { IJwsValidationResult, JwsPayload } from '../types/IJwtService'
13
+
6
14
  // @ts-ignore
7
15
  import * as u8a from 'uint8arrays'
8
16
  const { fromString, toString } = u8a
@@ -38,7 +46,7 @@ export async function resolveExternalOIDFEntityIdIdentifier(
38
46
  const errorList: Record<TrustedAnchor, ErrorMessage> = {}
39
47
  const jwkInfos: Array<ExternalJwkInfo> = []
40
48
 
41
- let payload: JwsPayload | undefined
49
+ let payload: JwtPayload | undefined
42
50
  for (const trustAnchor of trustAnchors) {
43
51
  const resolveResult = await context.agent.resolveTrustChain({
44
52
  entityIdentifier: identifier,
@@ -1,5 +1,5 @@
1
1
  import type { DidDocumentJwks } from '@sphereon/ssi-sdk-ext.did-utils'
2
- import type { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
2
+ import type { ICoseKeyJson, IValidationResult, JWK } from '@sphereon/ssi-types'
3
3
  import type { X509CertificateChainValidationOpts, X509ValidationResult } from '@sphereon/ssi-sdk-ext.x509-utils'
4
4
  import type { IParsedDID } from '@sphereon/ssi-types'
5
5
  import type { DIDDocument, DIDDocumentSection, DIDResolutionResult } from '@veramo/core'
@@ -14,7 +14,7 @@ import {
14
14
  isX5cIdentifier,
15
15
  type JwkInfo,
16
16
  } from './common'
17
- import type { JwsPayload } from './IJwtService'
17
+ // import type { JwsPayload } from './IJwtService'
18
18
 
19
19
  /**
20
20
  * Use whenever we need to resolve an external identifier. We can pass in kids, DIDs, and x5chains
@@ -173,7 +173,7 @@ export interface ExternalIdentifierOIDFEntityIdResult extends IExternalIdentifie
173
173
  method: 'entity_id'
174
174
  trustedAnchors: Array<TrustedAnchor>
175
175
  errorList?: Record<TrustedAnchor, ErrorMessage>
176
- jwtPayload?: JwsPayload
176
+ jwtPayload?: JwtPayload
177
177
  trustEstablished: boolean
178
178
  }
179
179
 
@@ -190,3 +190,19 @@ export interface ExternalIdentifierDidResult extends IExternalIdentifierResultBa
190
190
  didResolutionResult: Omit<DIDResolutionResult, 'didDocument'> // we already provide that directly
191
191
  didParsed: IParsedDID
192
192
  }
193
+
194
+ export interface JwtPayload {
195
+ iss?: string
196
+ sub?: string
197
+ aud?: string[] | string
198
+ exp?: number
199
+ nbf?: number
200
+ iat?: number
201
+ jti?: string
202
+ [key: string]: unknown
203
+ }
204
+
205
+
206
+ export type IJwsValidationResult = IValidationResult & {
207
+ jws: any
208
+ }
@@ -1,250 +0,0 @@
1
- // Copy of jwt-service typings since we cannot include that as devDependency due to cyclic dep
2
- /*
3
- import {
4
- ExternalIdentifierDidOpts,
5
- ExternalIdentifierResult,
6
- ExternalIdentifierX5cOpts,
7
- IIdentifierResolution,
8
- ManagedIdentifierOptsOrResult,
9
- ManagedIdentifierResult,
10
- } from '../types'*/
11
- import type { ClientIdScheme } from '@sphereon/ssi-sdk-ext.x509-utils'
12
- import type { BaseJWK, IValidationResult, JoseSignatureAlgorithm, JoseSignatureAlgorithmString, JWK } from '@sphereon/ssi-types'
13
- import type { IAgentContext, IKeyManager, IPluginMethodMap } from '@veramo/core'
14
- export type IRequiredContext = IAgentContext<IIdentifierResolution & IKeyManager>
15
- export declare const jwtServiceContextMethods: Array<string>
16
- export interface IJwtService extends IPluginMethodMap {
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>
24
- }
25
- export type IJwsValidationResult = IValidationResult & {
26
- jws: JwsJsonGeneralWithIdentifiers
27
- }
28
-
29
- export interface PreparedJws {
30
- protectedHeader: JwsHeader
31
- payload: Uint8Array
32
- unprotectedHeader?: JwsHeader
33
- existingSignatures?: Array<JwsJsonSignature>
34
- }
35
- export interface JwsJsonSignature {
36
- protected: string
37
- header?: JwsHeader
38
- signature: string
39
- }
40
- /**
41
- * The JWK representation of an ephemeral public key.
42
- * See https://www.rfc-editor.org/rfc/rfc7518.html#section-6
43
- */
44
- export type EphemeralPublicKey = Omit<BaseJWK, 'alg'>
45
- export interface JweHeader extends Omit<BaseJwtHeader, 'alg'> {
46
- alg: string
47
- enc: string
48
- jku?: string
49
- jwk?: BaseJWK
50
- epk?: EphemeralPublicKey
51
- x5u?: string
52
- x5c?: string[]
53
- x5t?: string
54
- cty?: string
55
- crit?: string[]
56
- [k: string]: any
57
- }
58
- export interface JweRecipientUnprotectedHeader {
59
- alg: string
60
- iv: string
61
- tag: string
62
- epk?: EphemeralPublicKey
63
- kid?: string
64
- apv?: string
65
- apu?: string
66
- }
67
- export interface JweProtectedHeader extends Partial<JweHeader> {
68
- zip?: 'DEF' | string
69
- }
70
- export type Jws = JwsCompact | JwsJsonFlattened | JwsJsonGeneral
71
- export type JwsCompact = string
72
- export interface JwsJsonFlattened {
73
- payload: string
74
- protected: string
75
- header?: JwsHeader
76
- signature: string
77
- }
78
- export interface JwsJsonGeneral {
79
- payload: string
80
- signatures: Array<JwsJsonSignature>
81
- }
82
- export interface JwsJsonGeneralWithIdentifiers extends JwsJsonGeneral {
83
- signatures: Array<JwsJsonSignatureWithIdentifier>
84
- }
85
- export interface JwsJsonSignatureWithIdentifier extends JwsJsonSignature {
86
- identifier: ExternalIdentifierResult
87
- }
88
- export type Jwe = JweCompact | JweJsonFlattened | JweJsonGeneral
89
- export type JweCompact = string
90
- export interface JweJsonFlattened {
91
- protected: string
92
- unprotected: JweHeader
93
- header: JweHeader | JweRecipientUnprotectedHeader
94
- encrypted_key?: string
95
- aad?: string
96
- iv: string
97
- ciphertext: string
98
- tag?: string
99
- }
100
- export interface JweRecipient {
101
- header?: JweRecipientUnprotectedHeader
102
- encrypted_key?: string
103
- }
104
- export interface JweJsonGeneral {
105
- protected: string
106
- unprotected?: JweHeader
107
- recipients: Array<JweRecipient>
108
- aad?: string
109
- iv: string
110
- ciphertext: string
111
- tag?: string
112
- }
113
- export interface PreparedJwsObject {
114
- jws: PreparedJws
115
- b64: {
116
- payload: string
117
- protectedHeader: string
118
- }
119
- identifier: ManagedIdentifierResult
120
- }
121
- export interface BaseJwtHeader {
122
- typ?: string
123
- alg?: string
124
- kid?: string
125
- }
126
- export interface BaseJwtPayload {
127
- iss?: string
128
- sub?: string
129
- aud?: string[] | string
130
- exp?: number
131
- nbf?: number
132
- iat?: number
133
- jti?: string
134
- }
135
- export interface JwsHeader extends BaseJwtHeader {
136
- kid?: string
137
- jwk?: JWK
138
- x5c?: string[]
139
- [key: string]: unknown
140
- }
141
- export interface JwsPayload extends BaseJwtPayload {
142
- [key: string]: unknown
143
- }
144
- export interface JwsHeaderOpts {
145
- alg: JoseSignatureAlgorithm | JoseSignatureAlgorithmString
146
- }
147
- export type JwsIdentifierMode = 'x5c' | 'kid' | 'jwk' | 'did' | 'auto'
148
- export type EncryptJweCompactJwtArgs = {
149
- payload: JwsPayload
150
- protectedHeader?: JweProtectedHeader | undefined
151
- aad?: Uint8Array | undefined
152
- recipientKey: ExternalIdentifierResult & {
153
- kid?: string
154
- }
155
- alg?: JweAlg
156
- enc?: JweEnc
157
- apu?: string
158
- apv?: string
159
- expirationTime?: number | string | Date
160
- issuer?: string
161
- audience?: string | string[]
162
- }
163
- export type DecryptJweCompactJwtArgs = {
164
- jwe: JweCompact
165
- idOpts: ManagedIdentifierOptsOrResult
166
- }
167
- export type CreateJwsArgs = {
168
- mode?: JwsIdentifierMode
169
- issuer: ManagedIdentifierOptsOrResult & {
170
- noIssPayloadUpdate?: boolean
171
- noIdentifierInHeader?: boolean
172
- }
173
- clientId?: string
174
- clientIdScheme?: ClientIdScheme | 'did' | string
175
- protectedHeader: JwsHeader
176
- payload: JwsPayload | Uint8Array | string
177
- }
178
- export type CreateJweArgs = {
179
- mode?: JwsIdentifierMode
180
- issuer: ManagedIdentifierOptsOrResult & {
181
- noIssPayloadUpdate?: boolean
182
- noIdentifierInHeader?: boolean
183
- }
184
- protectedHeader: JweProtectedHeader
185
- encryptedKey: string | EphemeralPublicKey
186
- iv: string
187
- ciphertext: string
188
- tag: string
189
- }
190
- export type CreateJwsCompactArgs = CreateJwsArgs
191
- export type CreateJwsFlattenedArgs = Exclude<CreateJwsJsonArgs, 'existingSignatures'>
192
- export type VerifyJwsArgs = {
193
- jws: Jws
194
- jwk?: JWK
195
- opts?: {
196
- x5c?: Omit<ExternalIdentifierX5cOpts, 'identifier'>
197
- did?: Omit<ExternalIdentifierDidOpts, 'identifier'>
198
- }
199
- }
200
- /**
201
- * @public
202
- */
203
- export type CreateJwsJsonArgs = CreateJwsArgs & {
204
- unprotectedHeader?: JwsHeader
205
- existingSignatures?: Array<JwsJsonSignature>
206
- }
207
- export type CreateJweJsonArgs = CreateJweArgs & {
208
- unprotectedHeader?: JweHeader
209
- }
210
- /**
211
- * @public
212
- */
213
- export interface JwtCompactResult {
214
- jwt: JwsCompact | JweCompact
215
- }
216
- export declare function isJwsCompact(jws: Jws): jws is JwsCompact
217
- export declare function isJweCompact(jwe: Jwe): jwe is JweCompact
218
- export declare function isJwsJsonFlattened(jws: Jws): jws is JwsJsonFlattened
219
- export declare function isJwsJsonGeneral(jws: Jws): jws is JwsJsonGeneral
220
- export declare function isJweJsonFlattened(jwe: Jwe): jwe is JweJsonFlattened
221
- export declare function isJweJsonGeneral(jwe: Jwe): jwe is JweJsonGeneral
222
- export declare function isJwsHeader(header: BaseJwtHeader & Record<string, any>): header is JwsHeader
223
- export declare function isJweHeader(header: BaseJwtHeader & Record<string, any>): header is JweHeader
224
- export declare const COMPACT_JWS_REGEX: RegExp
225
- export declare const COMPACT_JWE_REGEX: RegExp
226
- export declare const JweAlgs: readonly [
227
- 'RSA1_5',
228
- 'RSA-OAEP',
229
- 'RSA-OAEP-256',
230
- 'A128KW',
231
- 'A192KW',
232
- 'A256KW',
233
- 'dir',
234
- 'ECDH-ES',
235
- 'ECDH-ES+A128KW',
236
- 'ECDH-ES+A192KW',
237
- 'ECDH-ES+A256KW',
238
- 'A128GCMKW',
239
- 'A192GCMKW',
240
- 'A256GCMKW',
241
- 'PBES2-HS256+A128KW',
242
- 'PBES2-HS384+A192KW',
243
- 'PBES2-HS512+A256KW'
244
- ]
245
- export type JweAlg = (typeof JweAlgs)[number]
246
- export declare function jweAlg(alg?: string | JweAlg): JweAlg | undefined
247
- export declare const JweEncs: readonly ['A128CBC-HS256', 'A192CBC-HS384', 'A256CBC-HS512', 'A128GCM', 'A192GCM', 'A256GCM']
248
- export type JweEnc = (typeof JweEncs)[number]
249
- export declare function jweEnc(alg?: string | JweEnc): JweEnc | undefined
250
- //# sourceMappingURL=IJwtService.d.ts.map