@sphereon/ssi-sdk-ext.jwt-service 0.28.1-feature.oyd.cmsm.improv.21 → 0.28.1-next.54

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.
@@ -0,0 +1,278 @@
1
+ import * as _sphereon_ssi_types from '@sphereon/ssi-types';
2
+ import { JWK, IValidationResult, BaseJWK, JoseSignatureAlgorithm, JoseSignatureAlgorithmString } from '@sphereon/ssi-types';
3
+ import { IAgentPlugin, IPluginMethodMap, IAgentContext, IKeyManager } from '@veramo/core';
4
+ import { ManagedIdentifierOptsOrResult, IIdentifierResolution, ManagedIdentifierResult, ExternalIdentifierX5cOpts, ExternalIdentifierDidOpts, ExternalIdentifierResult } from '@sphereon/ssi-sdk-ext.identifier-resolution';
5
+ import { ClientIdScheme } from '@sphereon/ssi-sdk-ext.x509-utils';
6
+
7
+ /**
8
+ * @public
9
+ */
10
+ declare class JwtService implements IAgentPlugin {
11
+ readonly schema: any;
12
+ readonly methods: IJwtService;
13
+ private jwtPrepareJws;
14
+ private jwtCreateJwsJsonGeneralSignature;
15
+ private jwtCreateJwsJsonFlattenedSignature;
16
+ private jwtCreateJwsCompactSignature;
17
+ private jwtVerifyJwsSignature;
18
+ private jwtEncryptJweCompactJwt;
19
+ private jwtDecryptJweCompactJwt;
20
+ }
21
+
22
+ type IRequiredContext = IAgentContext<IIdentifierResolution & IKeyManager>;
23
+ declare const jwtServiceContextMethods: Array<string>;
24
+ interface IJwtService extends IPluginMethodMap {
25
+ jwtPrepareJws(args: CreateJwsJsonArgs, context: IRequiredContext): Promise<PreparedJwsObject>;
26
+ jwtCreateJwsJsonGeneralSignature(args: CreateJwsJsonArgs, context: IRequiredContext): Promise<JwsJsonGeneral>;
27
+ jwtCreateJwsJsonFlattenedSignature(args: CreateJwsFlattenedArgs, context: IRequiredContext): Promise<JwsJsonFlattened>;
28
+ jwtCreateJwsCompactSignature(args: CreateJwsCompactArgs, context: IRequiredContext): Promise<JwtCompactResult>;
29
+ jwtVerifyJwsSignature(args: VerifyJwsArgs, context: IRequiredContext): Promise<IJwsValidationResult>;
30
+ jwtEncryptJweCompactJwt(args: EncryptJweCompactJwtArgs, context: IRequiredContext): Promise<JwtCompactResult>;
31
+ jwtDecryptJweCompactJwt(args: DecryptJweCompactJwtArgs, context: IRequiredContext): Promise<JwtCompactResult>;
32
+ }
33
+ type IJwsValidationResult = IValidationResult & {
34
+ jws: JwsJsonGeneralWithIdentifiers;
35
+ };
36
+ interface PreparedJws {
37
+ protectedHeader: JwsHeader;
38
+ payload: Uint8Array;
39
+ unprotectedHeader?: JwsHeader;
40
+ existingSignatures?: Array<JwsJsonSignature>;
41
+ }
42
+ interface JwsJsonSignature {
43
+ protected: string;
44
+ header?: JwsHeader;
45
+ signature: string;
46
+ }
47
+ /**
48
+ * The JWK representation of an ephemeral public key.
49
+ * See https://www.rfc-editor.org/rfc/rfc7518.html#section-6
50
+ */
51
+ type EphemeralPublicKey = Omit<BaseJWK, 'alg'>;
52
+ interface JweHeader extends Omit<BaseJwtHeader, 'alg'> {
53
+ alg: string;
54
+ enc: string;
55
+ jku?: string;
56
+ jwk?: BaseJWK;
57
+ epk?: EphemeralPublicKey;
58
+ x5u?: string;
59
+ x5c?: string[];
60
+ x5t?: string;
61
+ cty?: string;
62
+ crit?: string[];
63
+ [k: string]: any;
64
+ }
65
+ interface JweRecipientUnprotectedHeader {
66
+ alg: string;
67
+ iv: string;
68
+ tag: string;
69
+ epk?: EphemeralPublicKey;
70
+ kid?: string;
71
+ apv?: string;
72
+ apu?: string;
73
+ }
74
+ interface JweProtectedHeader extends Partial<JweHeader> {
75
+ zip?: 'DEF' | string;
76
+ }
77
+ type Jws = JwsCompact | JwsJsonFlattened | JwsJsonGeneral;
78
+ type JwsCompact = string;
79
+ interface JwsJsonFlattened {
80
+ payload: string;
81
+ protected: string;
82
+ header?: JwsHeader;
83
+ signature: string;
84
+ }
85
+ interface JwsJsonGeneral {
86
+ payload: string;
87
+ signatures: Array<JwsJsonSignature>;
88
+ }
89
+ interface JwsJsonGeneralWithIdentifiers extends JwsJsonGeneral {
90
+ signatures: Array<JwsJsonSignatureWithIdentifier>;
91
+ }
92
+ interface JwsJsonSignatureWithIdentifier extends JwsJsonSignature {
93
+ identifier: ExternalIdentifierResult;
94
+ }
95
+ type Jwe = JweCompact | JweJsonFlattened | JweJsonGeneral;
96
+ type JweCompact = string;
97
+ interface JweJsonFlattened {
98
+ protected: string;
99
+ unprotected: JweHeader;
100
+ header: JweHeader | JweRecipientUnprotectedHeader;
101
+ encrypted_key?: string;
102
+ aad?: string;
103
+ iv: string;
104
+ ciphertext: string;
105
+ tag?: string;
106
+ }
107
+ interface JweRecipient {
108
+ header?: JweRecipientUnprotectedHeader;
109
+ encrypted_key?: string;
110
+ }
111
+ interface JweJsonGeneral {
112
+ protected: string;
113
+ unprotected?: JweHeader;
114
+ recipients: Array<JweRecipient>;
115
+ aad?: string;
116
+ iv: string;
117
+ ciphertext: string;
118
+ tag?: string;
119
+ }
120
+ interface PreparedJwsObject {
121
+ jws: PreparedJws;
122
+ b64: {
123
+ payload: string;
124
+ protectedHeader: string;
125
+ };
126
+ identifier: ManagedIdentifierResult;
127
+ }
128
+ interface BaseJwtHeader {
129
+ typ?: string;
130
+ alg?: string;
131
+ kid?: string;
132
+ }
133
+ interface BaseJwtPayload {
134
+ iss?: string;
135
+ sub?: string;
136
+ aud?: string[] | string;
137
+ exp?: number;
138
+ nbf?: number;
139
+ iat?: number;
140
+ jti?: string;
141
+ }
142
+ interface JwsHeader extends BaseJwtHeader {
143
+ kid?: string;
144
+ jwk?: JWK;
145
+ x5c?: string[];
146
+ [key: string]: unknown;
147
+ }
148
+ interface JwsPayload extends BaseJwtPayload {
149
+ [key: string]: unknown;
150
+ }
151
+ interface JwsHeaderOpts {
152
+ alg: JoseSignatureAlgorithm | JoseSignatureAlgorithmString;
153
+ }
154
+ type JwsIdentifierMode = 'x5c' | 'kid' | 'jwk' | 'did' | 'auto';
155
+ type EncryptJweCompactJwtArgs = {
156
+ payload: JwsPayload;
157
+ protectedHeader?: JweProtectedHeader | undefined;
158
+ aad?: Uint8Array | undefined;
159
+ recipientKey: ExternalIdentifierResult & {
160
+ kid?: string;
161
+ };
162
+ alg?: JweAlg;
163
+ enc?: JweEnc;
164
+ apu?: string;
165
+ apv?: string;
166
+ expirationTime?: number | string | Date;
167
+ issuer?: string;
168
+ audience?: string | string[];
169
+ };
170
+ type DecryptJweCompactJwtArgs = {
171
+ jwe: JweCompact;
172
+ idOpts: ManagedIdentifierOptsOrResult;
173
+ };
174
+ type CreateJwsArgs = {
175
+ mode?: JwsIdentifierMode;
176
+ issuer: ManagedIdentifierOptsOrResult & {
177
+ noIssPayloadUpdate?: boolean;
178
+ noIdentifierInHeader?: boolean;
179
+ };
180
+ clientId?: string;
181
+ clientIdScheme?: ClientIdScheme | 'did' | string;
182
+ protectedHeader: JwsHeader;
183
+ payload: JwsPayload | Uint8Array | string;
184
+ };
185
+ type CreateJweArgs = {
186
+ mode?: JwsIdentifierMode;
187
+ issuer: ManagedIdentifierOptsOrResult & {
188
+ noIssPayloadUpdate?: boolean;
189
+ noIdentifierInHeader?: boolean;
190
+ };
191
+ protectedHeader: JweProtectedHeader;
192
+ encryptedKey: string | EphemeralPublicKey;
193
+ iv: string;
194
+ ciphertext: string;
195
+ tag: string;
196
+ };
197
+ type CreateJwsCompactArgs = CreateJwsArgs;
198
+ type CreateJwsFlattenedArgs = Exclude<CreateJwsJsonArgs, 'existingSignatures'>;
199
+ type VerifyJwsArgs = {
200
+ jws: Jws;
201
+ jwk?: JWK;
202
+ opts?: {
203
+ x5c?: Omit<ExternalIdentifierX5cOpts, 'identifier'>;
204
+ did?: Omit<ExternalIdentifierDidOpts, 'identifier'>;
205
+ };
206
+ };
207
+ /**
208
+ * @public
209
+ */
210
+ type CreateJwsJsonArgs = CreateJwsArgs & {
211
+ unprotectedHeader?: JwsHeader;
212
+ existingSignatures?: Array<JwsJsonSignature>;
213
+ };
214
+ type CreateJweJsonArgs = CreateJweArgs & {
215
+ unprotectedHeader?: JweHeader;
216
+ };
217
+ /**
218
+ * @public
219
+ */
220
+ interface JwtCompactResult {
221
+ jwt: JwsCompact | JweCompact;
222
+ }
223
+ declare function isJwsCompact(jws: Jws): jws is JwsCompact;
224
+ declare function isJweCompact(jwe: Jwe): jwe is JweCompact;
225
+ declare function isJwsJsonFlattened(jws: Jws): jws is JwsJsonFlattened;
226
+ declare function isJwsJsonGeneral(jws: Jws): jws is JwsJsonGeneral;
227
+ declare function isJweJsonFlattened(jwe: Jwe): jwe is JweJsonFlattened;
228
+ declare function isJweJsonGeneral(jwe: Jwe): jwe is JweJsonGeneral;
229
+ declare function isJwsHeader(header: BaseJwtHeader & Record<string, any>): header is JwsHeader;
230
+ declare function isJweHeader(header: BaseJwtHeader & Record<string, any>): header is JweHeader;
231
+ declare const COMPACT_JWS_REGEX: RegExp;
232
+ declare const COMPACT_JWE_REGEX: RegExp;
233
+ declare const JweAlgs: readonly ["RSA1_5", "RSA-OAEP", "RSA-OAEP-256", "A128KW", "A192KW", "A256KW", "dir", "ECDH-ES", "ECDH-ES+A128KW", "ECDH-ES+A192KW", "ECDH-ES+A256KW", "A128GCMKW", "A192GCMKW", "A256GCMKW", "PBES2-HS256+A128KW", "PBES2-HS384+A192KW", "PBES2-HS512+A256KW"];
234
+ type JweAlg = (typeof JweAlgs)[number];
235
+ declare function jweAlg(alg?: string | JweAlg): JweAlg | undefined;
236
+ declare const JweEncs: readonly ["A128CBC-HS256", "A192CBC-HS384", "A256CBC-HS512", "A128GCM", "A192GCM", "A256GCM"];
237
+ type JweEnc = (typeof JweEncs)[number];
238
+ declare function jweEnc(alg?: string | JweEnc): JweEnc | undefined;
239
+
240
+ declare const prepareJwsObject: (args: CreateJwsJsonArgs, context: IRequiredContext) => Promise<PreparedJwsObject>;
241
+ declare const createJwsCompact: (args: CreateJwsCompactArgs, context: IRequiredContext) => Promise<JwsCompact>;
242
+ declare const createJwsJsonFlattened: (args: CreateJwsFlattenedArgs, context: IRequiredContext) => Promise<JwsJsonFlattened>;
243
+ declare const createJwsJsonGeneral: (args: CreateJwsJsonArgs, context: IRequiredContext) => Promise<JwsJsonGeneral>;
244
+ /**
245
+ * Updates the JWT header to include x5c, kid, jwk objects using the supplied issuer identifier that will be used to sign. If not present will automatically make the header objects available
246
+ * @param mode The type of header to check or include
247
+ * @param identifier The identifier of the signer. This identifier will be used later to sign
248
+ * @param header The JWT header
249
+ * @param noIdentifierInHeader
250
+ * @param context
251
+ */
252
+ declare const checkAndUpdateJwsHeader: ({ mode, identifier, header, noIdentifierInHeader, }: {
253
+ mode?: JwsIdentifierMode;
254
+ identifier: ManagedIdentifierResult;
255
+ noIdentifierInHeader?: boolean;
256
+ header: JwsHeader;
257
+ }, context: IRequiredContext) => Promise<undefined>;
258
+ declare const verifyJws: (args: VerifyJwsArgs, context: IAgentContext<IIdentifierResolution>) => Promise<IJwsValidationResult>;
259
+ declare const toJwsJsonGeneral: ({ jws }: {
260
+ jws: Jws;
261
+ }, context: IAgentContext<any>) => Promise<JwsJsonGeneral>;
262
+ declare const toJwsJsonGeneralWithIdentifiers: (args: {
263
+ jws: Jws;
264
+ jwk?: JWK;
265
+ opts?: {
266
+ x5c?: Omit<ExternalIdentifierX5cOpts, "identifier">;
267
+ did?: Omit<ExternalIdentifierDidOpts, "identifier">;
268
+ };
269
+ }, context: IAgentContext<IIdentifierResolution>) => Promise<JwsJsonGeneralWithIdentifiers>;
270
+
271
+ /**
272
+ * @internal
273
+ */
274
+ declare const schema: any;
275
+
276
+ declare const JwtLogger: _sphereon_ssi_types.ISimpleLogger<unknown>;
277
+
278
+ export { type BaseJwtHeader, type BaseJwtPayload, COMPACT_JWE_REGEX, COMPACT_JWS_REGEX, type CreateJweArgs, type CreateJweJsonArgs, type CreateJwsArgs, type CreateJwsCompactArgs, type CreateJwsFlattenedArgs, type CreateJwsJsonArgs, type DecryptJweCompactJwtArgs, type EncryptJweCompactJwtArgs, type EphemeralPublicKey, type IJwsValidationResult, type IJwtService, type IRequiredContext, type Jwe, type JweAlg, JweAlgs, type JweCompact, type JweEnc, JweEncs, type JweHeader, type JweJsonFlattened, type JweJsonGeneral, type JweProtectedHeader, type JweRecipient, type JweRecipientUnprotectedHeader, type Jws, type JwsCompact, type JwsHeader, type JwsHeaderOpts, type JwsIdentifierMode, type JwsJsonFlattened, type JwsJsonGeneral, type JwsJsonGeneralWithIdentifiers, type JwsJsonSignature, type JwsJsonSignatureWithIdentifier, type JwsPayload, type JwtCompactResult, JwtLogger, JwtService, type PreparedJws, type PreparedJwsObject, type VerifyJwsArgs, checkAndUpdateJwsHeader, createJwsCompact, createJwsJsonFlattened, createJwsJsonGeneral, isJweCompact, isJweHeader, isJweJsonFlattened, isJweJsonGeneral, isJwsCompact, isJwsHeader, isJwsJsonFlattened, isJwsJsonGeneral, jweAlg, jweEnc, jwtServiceContextMethods, prepareJwsObject, schema, toJwsJsonGeneral, toJwsJsonGeneralWithIdentifiers, verifyJws };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,278 @@
1
+ import * as _sphereon_ssi_types from '@sphereon/ssi-types';
2
+ import { JWK, IValidationResult, BaseJWK, JoseSignatureAlgorithm, JoseSignatureAlgorithmString } from '@sphereon/ssi-types';
3
+ import { IAgentPlugin, IPluginMethodMap, IAgentContext, IKeyManager } from '@veramo/core';
4
+ import { ManagedIdentifierOptsOrResult, IIdentifierResolution, ManagedIdentifierResult, ExternalIdentifierX5cOpts, ExternalIdentifierDidOpts, ExternalIdentifierResult } from '@sphereon/ssi-sdk-ext.identifier-resolution';
5
+ import { ClientIdScheme } from '@sphereon/ssi-sdk-ext.x509-utils';
6
+
1
7
  /**
2
- * @internal
8
+ * @public
3
9
  */
4
- declare const schema: any;
5
- export { schema };
6
- export declare const JwtLogger: import("@sphereon/ssi-types").ISimpleLogger<unknown>;
10
+ declare class JwtService implements IAgentPlugin {
11
+ readonly schema: any;
12
+ readonly methods: IJwtService;
13
+ private jwtPrepareJws;
14
+ private jwtCreateJwsJsonGeneralSignature;
15
+ private jwtCreateJwsJsonFlattenedSignature;
16
+ private jwtCreateJwsCompactSignature;
17
+ private jwtVerifyJwsSignature;
18
+ private jwtEncryptJweCompactJwt;
19
+ private jwtDecryptJweCompactJwt;
20
+ }
21
+
22
+ type IRequiredContext = IAgentContext<IIdentifierResolution & IKeyManager>;
23
+ declare const jwtServiceContextMethods: Array<string>;
24
+ interface IJwtService extends IPluginMethodMap {
25
+ jwtPrepareJws(args: CreateJwsJsonArgs, context: IRequiredContext): Promise<PreparedJwsObject>;
26
+ jwtCreateJwsJsonGeneralSignature(args: CreateJwsJsonArgs, context: IRequiredContext): Promise<JwsJsonGeneral>;
27
+ jwtCreateJwsJsonFlattenedSignature(args: CreateJwsFlattenedArgs, context: IRequiredContext): Promise<JwsJsonFlattened>;
28
+ jwtCreateJwsCompactSignature(args: CreateJwsCompactArgs, context: IRequiredContext): Promise<JwtCompactResult>;
29
+ jwtVerifyJwsSignature(args: VerifyJwsArgs, context: IRequiredContext): Promise<IJwsValidationResult>;
30
+ jwtEncryptJweCompactJwt(args: EncryptJweCompactJwtArgs, context: IRequiredContext): Promise<JwtCompactResult>;
31
+ jwtDecryptJweCompactJwt(args: DecryptJweCompactJwtArgs, context: IRequiredContext): Promise<JwtCompactResult>;
32
+ }
33
+ type IJwsValidationResult = IValidationResult & {
34
+ jws: JwsJsonGeneralWithIdentifiers;
35
+ };
36
+ interface PreparedJws {
37
+ protectedHeader: JwsHeader;
38
+ payload: Uint8Array;
39
+ unprotectedHeader?: JwsHeader;
40
+ existingSignatures?: Array<JwsJsonSignature>;
41
+ }
42
+ interface JwsJsonSignature {
43
+ protected: string;
44
+ header?: JwsHeader;
45
+ signature: string;
46
+ }
47
+ /**
48
+ * The JWK representation of an ephemeral public key.
49
+ * See https://www.rfc-editor.org/rfc/rfc7518.html#section-6
50
+ */
51
+ type EphemeralPublicKey = Omit<BaseJWK, 'alg'>;
52
+ interface JweHeader extends Omit<BaseJwtHeader, 'alg'> {
53
+ alg: string;
54
+ enc: string;
55
+ jku?: string;
56
+ jwk?: BaseJWK;
57
+ epk?: EphemeralPublicKey;
58
+ x5u?: string;
59
+ x5c?: string[];
60
+ x5t?: string;
61
+ cty?: string;
62
+ crit?: string[];
63
+ [k: string]: any;
64
+ }
65
+ interface JweRecipientUnprotectedHeader {
66
+ alg: string;
67
+ iv: string;
68
+ tag: string;
69
+ epk?: EphemeralPublicKey;
70
+ kid?: string;
71
+ apv?: string;
72
+ apu?: string;
73
+ }
74
+ interface JweProtectedHeader extends Partial<JweHeader> {
75
+ zip?: 'DEF' | string;
76
+ }
77
+ type Jws = JwsCompact | JwsJsonFlattened | JwsJsonGeneral;
78
+ type JwsCompact = string;
79
+ interface JwsJsonFlattened {
80
+ payload: string;
81
+ protected: string;
82
+ header?: JwsHeader;
83
+ signature: string;
84
+ }
85
+ interface JwsJsonGeneral {
86
+ payload: string;
87
+ signatures: Array<JwsJsonSignature>;
88
+ }
89
+ interface JwsJsonGeneralWithIdentifiers extends JwsJsonGeneral {
90
+ signatures: Array<JwsJsonSignatureWithIdentifier>;
91
+ }
92
+ interface JwsJsonSignatureWithIdentifier extends JwsJsonSignature {
93
+ identifier: ExternalIdentifierResult;
94
+ }
95
+ type Jwe = JweCompact | JweJsonFlattened | JweJsonGeneral;
96
+ type JweCompact = string;
97
+ interface JweJsonFlattened {
98
+ protected: string;
99
+ unprotected: JweHeader;
100
+ header: JweHeader | JweRecipientUnprotectedHeader;
101
+ encrypted_key?: string;
102
+ aad?: string;
103
+ iv: string;
104
+ ciphertext: string;
105
+ tag?: string;
106
+ }
107
+ interface JweRecipient {
108
+ header?: JweRecipientUnprotectedHeader;
109
+ encrypted_key?: string;
110
+ }
111
+ interface JweJsonGeneral {
112
+ protected: string;
113
+ unprotected?: JweHeader;
114
+ recipients: Array<JweRecipient>;
115
+ aad?: string;
116
+ iv: string;
117
+ ciphertext: string;
118
+ tag?: string;
119
+ }
120
+ interface PreparedJwsObject {
121
+ jws: PreparedJws;
122
+ b64: {
123
+ payload: string;
124
+ protectedHeader: string;
125
+ };
126
+ identifier: ManagedIdentifierResult;
127
+ }
128
+ interface BaseJwtHeader {
129
+ typ?: string;
130
+ alg?: string;
131
+ kid?: string;
132
+ }
133
+ interface BaseJwtPayload {
134
+ iss?: string;
135
+ sub?: string;
136
+ aud?: string[] | string;
137
+ exp?: number;
138
+ nbf?: number;
139
+ iat?: number;
140
+ jti?: string;
141
+ }
142
+ interface JwsHeader extends BaseJwtHeader {
143
+ kid?: string;
144
+ jwk?: JWK;
145
+ x5c?: string[];
146
+ [key: string]: unknown;
147
+ }
148
+ interface JwsPayload extends BaseJwtPayload {
149
+ [key: string]: unknown;
150
+ }
151
+ interface JwsHeaderOpts {
152
+ alg: JoseSignatureAlgorithm | JoseSignatureAlgorithmString;
153
+ }
154
+ type JwsIdentifierMode = 'x5c' | 'kid' | 'jwk' | 'did' | 'auto';
155
+ type EncryptJweCompactJwtArgs = {
156
+ payload: JwsPayload;
157
+ protectedHeader?: JweProtectedHeader | undefined;
158
+ aad?: Uint8Array | undefined;
159
+ recipientKey: ExternalIdentifierResult & {
160
+ kid?: string;
161
+ };
162
+ alg?: JweAlg;
163
+ enc?: JweEnc;
164
+ apu?: string;
165
+ apv?: string;
166
+ expirationTime?: number | string | Date;
167
+ issuer?: string;
168
+ audience?: string | string[];
169
+ };
170
+ type DecryptJweCompactJwtArgs = {
171
+ jwe: JweCompact;
172
+ idOpts: ManagedIdentifierOptsOrResult;
173
+ };
174
+ type CreateJwsArgs = {
175
+ mode?: JwsIdentifierMode;
176
+ issuer: ManagedIdentifierOptsOrResult & {
177
+ noIssPayloadUpdate?: boolean;
178
+ noIdentifierInHeader?: boolean;
179
+ };
180
+ clientId?: string;
181
+ clientIdScheme?: ClientIdScheme | 'did' | string;
182
+ protectedHeader: JwsHeader;
183
+ payload: JwsPayload | Uint8Array | string;
184
+ };
185
+ type CreateJweArgs = {
186
+ mode?: JwsIdentifierMode;
187
+ issuer: ManagedIdentifierOptsOrResult & {
188
+ noIssPayloadUpdate?: boolean;
189
+ noIdentifierInHeader?: boolean;
190
+ };
191
+ protectedHeader: JweProtectedHeader;
192
+ encryptedKey: string | EphemeralPublicKey;
193
+ iv: string;
194
+ ciphertext: string;
195
+ tag: string;
196
+ };
197
+ type CreateJwsCompactArgs = CreateJwsArgs;
198
+ type CreateJwsFlattenedArgs = Exclude<CreateJwsJsonArgs, 'existingSignatures'>;
199
+ type VerifyJwsArgs = {
200
+ jws: Jws;
201
+ jwk?: JWK;
202
+ opts?: {
203
+ x5c?: Omit<ExternalIdentifierX5cOpts, 'identifier'>;
204
+ did?: Omit<ExternalIdentifierDidOpts, 'identifier'>;
205
+ };
206
+ };
207
+ /**
208
+ * @public
209
+ */
210
+ type CreateJwsJsonArgs = CreateJwsArgs & {
211
+ unprotectedHeader?: JwsHeader;
212
+ existingSignatures?: Array<JwsJsonSignature>;
213
+ };
214
+ type CreateJweJsonArgs = CreateJweArgs & {
215
+ unprotectedHeader?: JweHeader;
216
+ };
7
217
  /**
8
218
  * @public
9
219
  */
10
- export { JwtService } from './agent/JwtService';
11
- export * from './functions';
12
- export * from './types/IJwtService';
13
- //# sourceMappingURL=index.d.ts.map
220
+ interface JwtCompactResult {
221
+ jwt: JwsCompact | JweCompact;
222
+ }
223
+ declare function isJwsCompact(jws: Jws): jws is JwsCompact;
224
+ declare function isJweCompact(jwe: Jwe): jwe is JweCompact;
225
+ declare function isJwsJsonFlattened(jws: Jws): jws is JwsJsonFlattened;
226
+ declare function isJwsJsonGeneral(jws: Jws): jws is JwsJsonGeneral;
227
+ declare function isJweJsonFlattened(jwe: Jwe): jwe is JweJsonFlattened;
228
+ declare function isJweJsonGeneral(jwe: Jwe): jwe is JweJsonGeneral;
229
+ declare function isJwsHeader(header: BaseJwtHeader & Record<string, any>): header is JwsHeader;
230
+ declare function isJweHeader(header: BaseJwtHeader & Record<string, any>): header is JweHeader;
231
+ declare const COMPACT_JWS_REGEX: RegExp;
232
+ declare const COMPACT_JWE_REGEX: RegExp;
233
+ declare const JweAlgs: readonly ["RSA1_5", "RSA-OAEP", "RSA-OAEP-256", "A128KW", "A192KW", "A256KW", "dir", "ECDH-ES", "ECDH-ES+A128KW", "ECDH-ES+A192KW", "ECDH-ES+A256KW", "A128GCMKW", "A192GCMKW", "A256GCMKW", "PBES2-HS256+A128KW", "PBES2-HS384+A192KW", "PBES2-HS512+A256KW"];
234
+ type JweAlg = (typeof JweAlgs)[number];
235
+ declare function jweAlg(alg?: string | JweAlg): JweAlg | undefined;
236
+ declare const JweEncs: readonly ["A128CBC-HS256", "A192CBC-HS384", "A256CBC-HS512", "A128GCM", "A192GCM", "A256GCM"];
237
+ type JweEnc = (typeof JweEncs)[number];
238
+ declare function jweEnc(alg?: string | JweEnc): JweEnc | undefined;
239
+
240
+ declare const prepareJwsObject: (args: CreateJwsJsonArgs, context: IRequiredContext) => Promise<PreparedJwsObject>;
241
+ declare const createJwsCompact: (args: CreateJwsCompactArgs, context: IRequiredContext) => Promise<JwsCompact>;
242
+ declare const createJwsJsonFlattened: (args: CreateJwsFlattenedArgs, context: IRequiredContext) => Promise<JwsJsonFlattened>;
243
+ declare const createJwsJsonGeneral: (args: CreateJwsJsonArgs, context: IRequiredContext) => Promise<JwsJsonGeneral>;
244
+ /**
245
+ * Updates the JWT header to include x5c, kid, jwk objects using the supplied issuer identifier that will be used to sign. If not present will automatically make the header objects available
246
+ * @param mode The type of header to check or include
247
+ * @param identifier The identifier of the signer. This identifier will be used later to sign
248
+ * @param header The JWT header
249
+ * @param noIdentifierInHeader
250
+ * @param context
251
+ */
252
+ declare const checkAndUpdateJwsHeader: ({ mode, identifier, header, noIdentifierInHeader, }: {
253
+ mode?: JwsIdentifierMode;
254
+ identifier: ManagedIdentifierResult;
255
+ noIdentifierInHeader?: boolean;
256
+ header: JwsHeader;
257
+ }, context: IRequiredContext) => Promise<undefined>;
258
+ declare const verifyJws: (args: VerifyJwsArgs, context: IAgentContext<IIdentifierResolution>) => Promise<IJwsValidationResult>;
259
+ declare const toJwsJsonGeneral: ({ jws }: {
260
+ jws: Jws;
261
+ }, context: IAgentContext<any>) => Promise<JwsJsonGeneral>;
262
+ declare const toJwsJsonGeneralWithIdentifiers: (args: {
263
+ jws: Jws;
264
+ jwk?: JWK;
265
+ opts?: {
266
+ x5c?: Omit<ExternalIdentifierX5cOpts, "identifier">;
267
+ did?: Omit<ExternalIdentifierDidOpts, "identifier">;
268
+ };
269
+ }, context: IAgentContext<IIdentifierResolution>) => Promise<JwsJsonGeneralWithIdentifiers>;
270
+
271
+ /**
272
+ * @internal
273
+ */
274
+ declare const schema: any;
275
+
276
+ declare const JwtLogger: _sphereon_ssi_types.ISimpleLogger<unknown>;
277
+
278
+ export { type BaseJwtHeader, type BaseJwtPayload, COMPACT_JWE_REGEX, COMPACT_JWS_REGEX, type CreateJweArgs, type CreateJweJsonArgs, type CreateJwsArgs, type CreateJwsCompactArgs, type CreateJwsFlattenedArgs, type CreateJwsJsonArgs, type DecryptJweCompactJwtArgs, type EncryptJweCompactJwtArgs, type EphemeralPublicKey, type IJwsValidationResult, type IJwtService, type IRequiredContext, type Jwe, type JweAlg, JweAlgs, type JweCompact, type JweEnc, JweEncs, type JweHeader, type JweJsonFlattened, type JweJsonGeneral, type JweProtectedHeader, type JweRecipient, type JweRecipientUnprotectedHeader, type Jws, type JwsCompact, type JwsHeader, type JwsHeaderOpts, type JwsIdentifierMode, type JwsJsonFlattened, type JwsJsonGeneral, type JwsJsonGeneralWithIdentifiers, type JwsJsonSignature, type JwsJsonSignatureWithIdentifier, type JwsPayload, type JwtCompactResult, JwtLogger, JwtService, type PreparedJws, type PreparedJwsObject, type VerifyJwsArgs, checkAndUpdateJwsHeader, createJwsCompact, createJwsJsonFlattened, createJwsJsonGeneral, isJweCompact, isJweHeader, isJweJsonFlattened, isJweJsonGeneral, isJwsCompact, isJwsHeader, isJwsJsonFlattened, isJwsJsonGeneral, jweAlg, jweEnc, jwtServiceContextMethods, prepareJwsObject, schema, toJwsJsonGeneral, toJwsJsonGeneralWithIdentifiers, verifyJws };