@sphereon/ssi-sdk-ext.jwt-service 0.24.1-unstable.89 → 0.24.1-unstable.92

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,4 +1,4 @@
1
- import {IAgentPlugin} from '@veramo/core'
1
+ import { IAgentPlugin } from '@veramo/core'
2
2
  import {
3
3
  createJwsCompact,
4
4
  CreateJwsCompactArgs,
@@ -7,7 +7,8 @@ import {
7
7
  createJwsJsonFlattened,
8
8
  createJwsJsonGeneral,
9
9
  IJwtService,
10
- IRequiredContext, JwsCompactResult,
10
+ IRequiredContext,
11
+ JwsCompactResult,
11
12
  JwsJsonFlattened,
12
13
  JwsJsonGeneral,
13
14
  PreparedJwsObject,
@@ -15,7 +16,6 @@ import {
15
16
  schema,
16
17
  } from '..'
17
18
 
18
-
19
19
  /**
20
20
  * @public
21
21
  */
@@ -40,10 +40,7 @@ export class JwtService implements IAgentPlugin {
40
40
  return await createJwsJsonFlattened(args, context)
41
41
  }
42
42
 
43
- private async jwtCreateJwsCompactSignature(
44
- args: CreateJwsCompactArgs,
45
- context: IRequiredContext
46
- ): Promise<JwsCompactResult> {
43
+ private async jwtCreateJwsCompactSignature(args: CreateJwsCompactArgs, context: IRequiredContext): Promise<JwsCompactResult> {
47
44
  // We wrap it in a json object for remote REST calls
48
45
  return { jwt: await createJwsCompact(args, context) }
49
46
  }
@@ -1,113 +1,107 @@
1
1
  import {
2
- isManagedIdentifierDidResult,
3
- isManagedIdentifierX5cResult,
4
- ManagedIdentifierMethod,
5
- ManagedIdentifierResult, ensureManagedIdentifierResult,
2
+ isManagedIdentifierDidResult,
3
+ isManagedIdentifierX5cResult,
4
+ ManagedIdentifierMethod,
5
+ ManagedIdentifierResult,
6
+ ensureManagedIdentifierResult,
6
7
  } from '@sphereon/ssi-sdk-ext.identifier-resolution'
7
- import {bytesToBase64url, encodeJoseBlob} from '@veramo/utils'
8
+ import { bytesToBase64url, encodeJoseBlob } from '@veramo/utils'
8
9
  import * as u8a from 'uint8arrays'
9
10
  import {
10
- CreateJwsCompactArgs,
11
- CreateJwsFlattenedArgs,
12
- CreateJwsJsonArgs,
13
- CreateJwsMode,
14
- IRequiredContext,
15
- JwsCompact,
16
- JwsJsonFlattened,
17
- JwsJsonGeneral,
18
- JwsJsonSignature,
19
- JwtHeader,
20
- PreparedJwsObject,
11
+ CreateJwsCompactArgs,
12
+ CreateJwsFlattenedArgs,
13
+ CreateJwsJsonArgs,
14
+ CreateJwsMode,
15
+ IRequiredContext,
16
+ JwsCompact,
17
+ JwsJsonFlattened,
18
+ JwsJsonGeneral,
19
+ JwsJsonSignature,
20
+ JwtHeader,
21
+ PreparedJwsObject,
21
22
  } from '../types/IJwtService'
22
23
 
23
24
  export const prepareJwsObject = async (args: CreateJwsJsonArgs, context: IRequiredContext): Promise<PreparedJwsObject> => {
24
- const {
25
- existingSignatures,
26
- protectedHeader,
27
- unprotectedHeader,
28
- issuer,
29
- payload,
30
- mode = 'auto'
31
- } = args
25
+ const { existingSignatures, protectedHeader, unprotectedHeader, issuer, payload, mode = 'auto' } = args
32
26
 
33
- const {noIdentifierInHeader = false} = issuer
34
- const combinedHeader = {...unprotectedHeader, ...protectedHeader}
35
- if (!combinedHeader.alg) {
36
- return Promise.reject(`No 'alg' key present in the JWS header`)
37
- }
38
- const identifier = await ensureManagedIdentifierResult(issuer, context)
39
- await checkAndUpdateJwtHeader({mode, identifier, noIdentifierInHeader, header: protectedHeader}, context)
27
+ const { noIdentifierInHeader = false } = issuer
28
+ const combinedHeader = { ...unprotectedHeader, ...protectedHeader }
29
+ if (!combinedHeader.alg) {
30
+ return Promise.reject(`No 'alg' key present in the JWS header`)
31
+ }
32
+ const identifier = await ensureManagedIdentifierResult(issuer, context)
33
+ await checkAndUpdateJwtHeader({ mode, identifier, noIdentifierInHeader, header: protectedHeader }, context)
40
34
 
41
- const isBytes = payload instanceof Uint8Array
42
- const isString = typeof payload === 'string'
43
- if (!isBytes && !isString) {
44
- if (issuer.noIssPayloadUpdate !== true && !payload.iss && identifier.issuer) {
45
- payload.iss = identifier.issuer
46
- }
35
+ const isBytes = payload instanceof Uint8Array
36
+ const isString = typeof payload === 'string'
37
+ if (!isBytes && !isString) {
38
+ if (issuer.noIssPayloadUpdate !== true && !payload.iss && identifier.issuer) {
39
+ payload.iss = identifier.issuer
47
40
  }
48
- const payloadBytes = isBytes ? payload : (isString ? u8a.fromString(payload, 'base64url') : u8a.fromString(JSON.stringify(payload), 'utf-8'))
49
- const base64urlHeader = encodeJoseBlob(protectedHeader)
50
- const base64urlPayload = bytesToBase64url(payloadBytes)
41
+ }
42
+ const payloadBytes = isBytes ? payload : isString ? u8a.fromString(payload, 'base64url') : u8a.fromString(JSON.stringify(payload), 'utf-8')
43
+ const base64urlHeader = encodeJoseBlob(protectedHeader)
44
+ const base64urlPayload = bytesToBase64url(payloadBytes)
51
45
 
52
- return {
53
- jws: {
54
- unprotectedHeader,
55
- protectedHeader,
56
- payload: payloadBytes,
57
- existingSignatures,
58
- },
59
- b64: {
60
- protectedHeader: base64urlHeader,
61
- payload: base64urlPayload,
62
- },
63
- identifier,
64
- }
46
+ return {
47
+ jws: {
48
+ unprotectedHeader,
49
+ protectedHeader,
50
+ payload: payloadBytes,
51
+ existingSignatures,
52
+ },
53
+ b64: {
54
+ protectedHeader: base64urlHeader,
55
+ payload: base64urlPayload,
56
+ },
57
+ identifier,
58
+ }
65
59
  }
66
60
 
67
61
  export const createJwsCompact = async (args: CreateJwsCompactArgs, context: IRequiredContext): Promise<JwsCompact> => {
68
- const {protected: protectedHeader, payload, signature} = await createJwsJsonFlattened(args, context)
69
- return `${protectedHeader}.${payload}.${signature}`
62
+ const { protected: protectedHeader, payload, signature } = await createJwsJsonFlattened(args, context)
63
+ return `${protectedHeader}.${payload}.${signature}`
70
64
  }
71
65
 
72
66
  export const createJwsJsonFlattened = async (args: CreateJwsFlattenedArgs, context: IRequiredContext): Promise<JwsJsonFlattened> => {
73
- const jws = await createJwsJsonGeneral(args, context)
74
- if (jws.signatures.length !== 1) {
75
- return Promise.reject(Error(`JWS flattened signature can only contain 1 signature. Found ${jws.signatures.length}`))
76
- }
77
- return {
78
- ...jws.signatures[0],
79
- payload: jws.payload,
80
- } satisfies JwsJsonFlattened
67
+ const jws = await createJwsJsonGeneral(args, context)
68
+ if (jws.signatures.length !== 1) {
69
+ return Promise.reject(Error(`JWS flattened signature can only contain 1 signature. Found ${jws.signatures.length}`))
70
+ }
71
+ return {
72
+ ...jws.signatures[0],
73
+ payload: jws.payload,
74
+ } satisfies JwsJsonFlattened
81
75
  }
82
76
 
83
77
  export const createJwsJsonGeneral = async (args: CreateJwsJsonArgs, context: IRequiredContext): Promise<JwsJsonGeneral> => {
84
- const {payload, protectedHeader, unprotectedHeader, existingSignatures, issuer, mode} = args
85
- const {b64, identifier} = await prepareJwsObject(
86
- {
87
- protectedHeader,
88
- unprotectedHeader,
89
- payload,
90
- existingSignatures,
91
- issuer,
92
- mode,
93
- },
94
- context
95
- )
96
- // const algorithm = await signatureAlgorithmFromKey({ key: identifier.key })
97
- const signature = await context.agent.keyManagerSign({
98
- keyRef: identifier.kmsKeyRef,
99
- data: `${b64.protectedHeader}.${b64.payload}`,
100
- encoding: undefined
101
- })
102
- const jsonSignature = {
103
- protected: b64.protectedHeader,
104
- header: unprotectedHeader,
105
- signature,
106
- } satisfies JwsJsonSignature
107
- return {
108
- payload: b64.payload,
109
- signatures: [...(existingSignatures ?? []), jsonSignature],
110
- } satisfies JwsJsonGeneral
78
+ const { payload, protectedHeader, unprotectedHeader, existingSignatures, mode, issuer } = args
79
+ const { b64, identifier } = await prepareJwsObject(
80
+ {
81
+ protectedHeader,
82
+ unprotectedHeader,
83
+ payload,
84
+ existingSignatures,
85
+ issuer,
86
+ mode,
87
+ },
88
+ context
89
+ )
90
+ // const algorithm = await signatureAlgorithmFromKey({ key: identifier.key })
91
+ const signature = await context.agent.keyManagerSign({
92
+ keyRef: identifier.kmsKeyRef,
93
+ data: `${b64.protectedHeader}.${b64.payload}`,
94
+ encoding: undefined,
95
+ })
96
+ const jsonSignature = {
97
+ protected: b64.protectedHeader,
98
+ header: unprotectedHeader,
99
+ signature,
100
+ } satisfies JwsJsonSignature
101
+ return {
102
+ payload: b64.payload,
103
+ signatures: [...(existingSignatures ?? []), jsonSignature],
104
+ } satisfies JwsJsonGeneral
111
105
  }
112
106
 
113
107
  /**
@@ -120,166 +114,166 @@ export const createJwsJsonGeneral = async (args: CreateJwsJsonArgs, context: IRe
120
114
  */
121
115
 
122
116
  export const checkAndUpdateJwtHeader = async (
123
- {
124
- mode = 'auto',
125
- identifier,
126
- header,
127
- noIdentifierInHeader = false
128
- }: {
129
- mode?: CreateJwsMode
130
- identifier: ManagedIdentifierResult
131
- noIdentifierInHeader?: boolean
132
- header: JwtHeader
133
- },
134
- context: IRequiredContext
117
+ {
118
+ mode = 'auto',
119
+ identifier,
120
+ header,
121
+ noIdentifierInHeader = false,
122
+ }: {
123
+ mode?: CreateJwsMode
124
+ identifier: ManagedIdentifierResult
125
+ noIdentifierInHeader?: boolean
126
+ header: JwtHeader
127
+ },
128
+ context: IRequiredContext
135
129
  ) => {
136
- if (isMode(mode, identifier.method, 'did')) {
137
- // kid is VM of the DID
138
- // @see https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.4
139
- await checkAndUpdateDidHeader({header, identifier, noIdentifierInHeader}, context)
140
- } else if (isMode(mode, identifier.method, 'x5c')) {
141
- // Include the x5c in the header. No kid
142
- // @see https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.6
143
- await checkAndUpdateX5cHeader({header, identifier, noIdentifierInHeader}, context)
144
- } else if (isMode(mode, identifier.method, 'kid', false)) {
145
- await checkAndUpdateKidHeader({header, identifier, noIdentifierInHeader}, context)
146
- } else if (isMode(mode, identifier.method, 'jwk', false)) {
147
- // Include the JWK in the header as well as its kid if present
148
- // @see https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.3
149
- // @see https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.4
150
- await checkAndUpdateJwkHeader({header, identifier, noIdentifierInHeader}, context)
151
- } else {
152
- // Better safe than sorry. We could let it pass, but we want to force implementers to make a conscious choice
153
- return Promise.reject(`Invalid combination of JWS creation mode ${mode} and identifier method ${identifier.method} chosen`)
154
- }
130
+ if (isMode(mode, identifier.method, 'did')) {
131
+ // kid is VM of the DID
132
+ // @see https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.4
133
+ await checkAndUpdateDidHeader({ header, identifier, noIdentifierInHeader }, context)
134
+ } else if (isMode(mode, identifier.method, 'x5c')) {
135
+ // Include the x5c in the header. No kid
136
+ // @see https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.6
137
+ await checkAndUpdateX5cHeader({ header, identifier, noIdentifierInHeader }, context)
138
+ } else if (isMode(mode, identifier.method, 'kid', false)) {
139
+ await checkAndUpdateKidHeader({ header, identifier, noIdentifierInHeader }, context)
140
+ } else if (isMode(mode, identifier.method, 'jwk', false)) {
141
+ // Include the JWK in the header as well as its kid if present
142
+ // @see https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.3
143
+ // @see https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.4
144
+ await checkAndUpdateJwkHeader({ header, identifier, noIdentifierInHeader }, context)
145
+ } else {
146
+ // Better safe than sorry. We could let it pass, but we want to force implementers to make a conscious choice
147
+ return Promise.reject(`Invalid combination of JWS creation mode ${mode} and identifier method ${identifier.method} chosen`)
148
+ }
155
149
  }
156
150
 
157
151
  const checkAndUpdateX5cHeader = async (
158
- {
159
- header,
160
- identifier,
161
- noIdentifierInHeader = false
162
- }: {
163
- header: JwtHeader
164
- identifier: ManagedIdentifierResult
165
- noIdentifierInHeader?: boolean
166
- },
167
- context: IRequiredContext
152
+ {
153
+ header,
154
+ identifier,
155
+ noIdentifierInHeader = false,
156
+ }: {
157
+ header: JwtHeader
158
+ identifier: ManagedIdentifierResult
159
+ noIdentifierInHeader?: boolean
160
+ },
161
+ context: IRequiredContext
168
162
  ) => {
169
- const {x5c} = header
170
- if (x5c) {
171
- // let's resolve the provided x5c to be sure
172
- const x5cIdentifier = await context.agent.identifierManagedGetByX5c({identifier: x5c})
173
- if (x5cIdentifier.kmsKeyRef !== identifier.kmsKeyRef) {
174
- return Promise.reject(Error(`An x5c header was present, but its issuer public key did not match the provided signing public key!`))
175
- }
176
- } else if (!noIdentifierInHeader) {
177
- if (!isManagedIdentifierX5cResult(identifier)) {
178
- return Promise.reject(Error('No x5c header in the JWT, but mode was x5c and also no x5x identifier was provided!'))
179
- } else if (header.jwk || header.kid) {
180
- return Promise.reject(Error('x5c mode was choosen, but jwk or kid headers were provided. These cannot be used together!'))
181
- }
182
- header.x5c = identifier.x5c
163
+ const { x5c } = header
164
+ if (x5c) {
165
+ // let's resolve the provided x5c to be sure
166
+ const x5cIdentifier = await context.agent.identifierManagedGetByX5c({ identifier: x5c })
167
+ if (x5cIdentifier.kmsKeyRef !== identifier.kmsKeyRef) {
168
+ return Promise.reject(Error(`An x5c header was present, but its issuer public key did not match the provided signing public key!`))
169
+ }
170
+ } else if (!noIdentifierInHeader) {
171
+ if (!isManagedIdentifierX5cResult(identifier)) {
172
+ return Promise.reject(Error('No x5c header in the JWT, but mode was x5c and also no x5x identifier was provided!'))
173
+ } else if (header.jwk || header.kid) {
174
+ return Promise.reject(Error('x5c mode was choosen, but jwk or kid headers were provided. These cannot be used together!'))
183
175
  }
176
+ header.x5c = identifier.x5c
177
+ }
184
178
  }
185
179
 
186
180
  const checkAndUpdateDidHeader = async (
187
- {
188
- header,
189
- identifier,
190
- noIdentifierInHeader = false
191
- }: {
192
- header: JwtHeader
193
- identifier: ManagedIdentifierResult
194
- noIdentifierInHeader?: boolean
195
- },
196
- context: IRequiredContext
181
+ {
182
+ header,
183
+ identifier,
184
+ noIdentifierInHeader = false,
185
+ }: {
186
+ header: JwtHeader
187
+ identifier: ManagedIdentifierResult
188
+ noIdentifierInHeader?: boolean
189
+ },
190
+ context: IRequiredContext
197
191
  ) => {
198
- const {kid} = header
199
- if (kid) {
200
- // let's resolve the provided x5c to be sure
201
- const vmIdentifier = await context.agent.identifierManagedGetByDid({identifier: kid})
202
- if (vmIdentifier.kmsKeyRef !== identifier.kmsKeyRef) {
203
- return Promise.reject(Error(`A kid header was present, but its value did not match the provided signing kid!`))
204
- }
205
- } else if (!noIdentifierInHeader) {
206
- if (!isManagedIdentifierDidResult(identifier)) {
207
- return Promise.reject(Error('No kid header in the JWT, but mode was did and also no DID identifier was provided!'))
208
- } else if (header.jwk || header.x5c) {
209
- return Promise.reject(Error('did mode was chosen, but jwk or x5c headers were provided. These cannot be used together!'))
210
- }
211
- header.kid = identifier.kid
192
+ const { kid } = header
193
+ if (kid) {
194
+ // let's resolve the provided x5c to be sure
195
+ const vmIdentifier = await context.agent.identifierManagedGetByDid({ identifier: kid })
196
+ if (vmIdentifier.kmsKeyRef !== identifier.kmsKeyRef) {
197
+ return Promise.reject(Error(`A kid header was present, but its value did not match the provided signing kid!`))
198
+ }
199
+ } else if (!noIdentifierInHeader) {
200
+ if (!isManagedIdentifierDidResult(identifier)) {
201
+ return Promise.reject(Error('No kid header in the JWT, but mode was did and also no DID identifier was provided!'))
202
+ } else if (header.jwk || header.x5c) {
203
+ return Promise.reject(Error('did mode was chosen, but jwk or x5c headers were provided. These cannot be used together!'))
212
204
  }
205
+ header.kid = identifier.kid
206
+ }
213
207
  }
214
208
 
215
209
  const checkAndUpdateJwkHeader = async (
216
- {
217
- header,
218
- identifier,
219
- noIdentifierInHeader = false
220
- }: {
221
- header: JwtHeader
222
- identifier: ManagedIdentifierResult
223
- noIdentifierInHeader?: boolean
224
- },
225
- context: IRequiredContext
210
+ {
211
+ header,
212
+ identifier,
213
+ noIdentifierInHeader = false,
214
+ }: {
215
+ header: JwtHeader
216
+ identifier: ManagedIdentifierResult
217
+ noIdentifierInHeader?: boolean
218
+ },
219
+ context: IRequiredContext
226
220
  ) => {
227
- const {jwk} = header
228
- if (jwk) {
229
- // let's resolve the provided x5c to be sure
230
- const jwkIdentifier = await context.agent.identifierManagedGetByJwk({identifier: jwk})
231
- if (jwkIdentifier.kmsKeyRef !== identifier.kmsKeyRef) {
232
- return Promise.reject(Error(`A jwk header was present, but its value did not match the provided signing jwk or kid!`))
233
- }
234
- } else if (!noIdentifierInHeader) {
235
- // We basically accept everything for this mode, as we can always create JWKs from any key
236
- if (header.x5c) {
237
- return Promise.reject(Error('jwk mode was chosen, but x5c headers were provided. These cannot be used together!'))
238
- }
239
- header.jwk = identifier.jwk
221
+ const { jwk } = header
222
+ if (jwk) {
223
+ // let's resolve the provided x5c to be sure
224
+ const jwkIdentifier = await context.agent.identifierManagedGetByJwk({ identifier: jwk })
225
+ if (jwkIdentifier.kmsKeyRef !== identifier.kmsKeyRef) {
226
+ return Promise.reject(Error(`A jwk header was present, but its value did not match the provided signing jwk or kid!`))
227
+ }
228
+ } else if (!noIdentifierInHeader) {
229
+ // We basically accept everything for this mode, as we can always create JWKs from any key
230
+ if (header.x5c) {
231
+ return Promise.reject(Error('jwk mode was chosen, but x5c headers were provided. These cannot be used together!'))
240
232
  }
233
+ header.jwk = identifier.jwk
234
+ }
241
235
  }
242
236
 
243
237
  const checkAndUpdateKidHeader = async (
244
- {
245
- header,
246
- identifier,
247
- noIdentifierInHeader = false
248
- }: {
249
- header: JwtHeader
250
- identifier: ManagedIdentifierResult
251
- noIdentifierInHeader?: boolean
252
- },
253
- context: IRequiredContext
238
+ {
239
+ header,
240
+ identifier,
241
+ noIdentifierInHeader = false,
242
+ }: {
243
+ header: JwtHeader
244
+ identifier: ManagedIdentifierResult
245
+ noIdentifierInHeader?: boolean
246
+ },
247
+ context: IRequiredContext
254
248
  ) => {
255
- const {kid} = header
256
- if (kid) {
257
- // let's resolve the provided x5c to be sure
258
- const kidIdentifier = await context.agent.identifierManagedGetByKid({identifier: kid})
259
- if (kidIdentifier.kmsKeyRef !== identifier.kmsKeyRef) {
260
- return Promise.reject(Error(`A kid header was present, but its value did not match the provided signing kid!`))
261
- }
262
- } else if (!noIdentifierInHeader) {
263
- // We basically accept everything for this mode, as we can always create JWKs from any key
264
- if (header.x5c) {
265
- return Promise.reject(Error('kid mode was chosen, but x5c headers were provided. These cannot be used together!'))
266
- }
267
- header.kid = identifier.kid
249
+ const { kid } = header
250
+ if (kid) {
251
+ // let's resolve the provided x5c to be sure
252
+ const kidIdentifier = await context.agent.identifierManagedGetByKid({ identifier: kid })
253
+ if (kidIdentifier.kmsKeyRef !== identifier.kmsKeyRef) {
254
+ return Promise.reject(Error(`A kid header was present, but its value did not match the provided signing kid!`))
255
+ }
256
+ } else if (!noIdentifierInHeader) {
257
+ // We basically accept everything for this mode, as we can always create JWKs from any key
258
+ if (header.x5c) {
259
+ return Promise.reject(Error('kid mode was chosen, but x5c headers were provided. These cannot be used together!'))
268
260
  }
261
+ header.kid = identifier.kid
262
+ }
269
263
  }
270
264
 
271
265
  const isMode = (mode: CreateJwsMode, identifierMethod: ManagedIdentifierMethod, checkMode: CreateJwsMode, loose = true) => {
272
- if (loose && (checkMode === 'jwk' || checkMode === 'kid')) {
273
- // we always have the kid and jwk at hand no matter the identifier method, so we are okay with that
274
- // todo: check the impact on the above expressions, as this will now always return true for the both of them
275
- return true
276
- }
277
- if (mode === checkMode) {
278
- if (checkMode !== 'auto' && mode !== identifierMethod) {
279
- throw Error(`Provided mode ${mode} conflicts with identifier method ${identifierMethod}`)
280
- }
281
- return true
282
- }
266
+ if (loose && (checkMode === 'jwk' || checkMode === 'kid')) {
283
267
  // we always have the kid and jwk at hand no matter the identifier method, so we are okay with that
284
- return mode === 'auto' && identifierMethod === checkMode
268
+ // todo: check the impact on the above expressions, as this will now always return true for the both of them
269
+ return true
270
+ }
271
+ if (mode === checkMode) {
272
+ if (checkMode !== 'auto' && mode !== identifierMethod) {
273
+ throw Error(`Provided mode ${mode} conflicts with identifier method ${identifierMethod}`)
274
+ }
275
+ return true
276
+ }
277
+ // we always have the kid and jwk at hand no matter the identifier method, so we are okay with that
278
+ return mode === 'auto' && identifierMethod === checkMode
285
279
  }
@@ -1,11 +1,7 @@
1
- import {
2
- IIdentifierResolution,
3
- ManagedIdentifierOpts,
4
- ManagedIdentifierResult
5
- } from '@sphereon/ssi-sdk-ext.identifier-resolution'
6
- import {ISphereonKeyManager} from '@sphereon/ssi-sdk-ext.key-manager'
7
- import {JWK, SignatureAlgorithmJwa} from '@sphereon/ssi-sdk-ext.key-utils'
8
- import {IAgentContext, IPluginMethodMap} from '@veramo/core'
1
+ import { IIdentifierResolution, ManagedIdentifierOptsOrResult, ManagedIdentifierResult } from '@sphereon/ssi-sdk-ext.identifier-resolution'
2
+ import { ISphereonKeyManager } from '@sphereon/ssi-sdk-ext.key-manager'
3
+ import { JWK, SignatureAlgorithmJwa } from '@sphereon/ssi-sdk-ext.key-utils'
4
+ import { IAgentContext, IPluginMethodMap } from '@veramo/core'
9
5
 
10
6
  export type IRequiredContext = IAgentContext<IIdentifierResolution & ISphereonKeyManager> // could we still interop with Veramo?
11
7
  export interface IJwtService extends IPluginMethodMap {
@@ -56,18 +52,18 @@ export interface PreparedJwsObject {
56
52
  }
57
53
 
58
54
  export interface BaseJwtHeader {
59
- typ?: string;
60
- alg?: string;
61
- kid?: string;
55
+ typ?: string
56
+ alg?: string
57
+ kid?: string
62
58
  }
63
59
  export interface BaseJwtPayload {
64
- iss?: string;
65
- sub?: string;
66
- aud?: string[] | string;
67
- exp?: number;
68
- nbf?: number;
69
- iat?: number;
70
- jti?: string;
60
+ iss?: string
61
+ sub?: string
62
+ aud?: string[] | string
63
+ exp?: number
64
+ nbf?: number
65
+ iat?: number
66
+ jti?: string
71
67
  }
72
68
 
73
69
  export interface JwtHeader extends BaseJwtHeader {
@@ -90,7 +86,7 @@ export type CreateJwsMode = 'x5c' | 'kid' | 'jwk' | 'did' | 'auto'
90
86
 
91
87
  export type CreateJwsArgs = {
92
88
  mode?: CreateJwsMode
93
- issuer: (ManagedIdentifierOpts | ManagedIdentifierResult) & { noIssPayloadUpdate?: boolean, noIdentifierInHeader?: boolean }
89
+ issuer: ManagedIdentifierOptsOrResult & { noIssPayloadUpdate?: boolean; noIdentifierInHeader?: boolean }
94
90
  protectedHeader: JwtHeader
95
91
  payload: JwtPayload | Uint8Array | string
96
92
  }
@@ -111,7 +107,7 @@ export type CreateJwsJsonArgs = CreateJwsArgs & {
111
107
  * @public
112
108
  */
113
109
  export interface JwsCompactResult {
114
- jwt: JwsCompact;
110
+ jwt: JwsCompact
115
111
  }
116
112
 
117
113
  // export const COMPACT_JWS_REGEX = /^([a-zA-Z0-9_=-]+)\.([a-zA-Z0-9_=-]+)?\.([a-zA-Z0-9_=-]+)$/