jose 5.8.0 → 5.9.0
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/README.md +21 -17
- package/dist/browser/jwks/remote.js +1 -1
- package/dist/browser/jws/flattened/sign.js +2 -2
- package/dist/browser/jws/flattened/verify.js +10 -2
- package/dist/browser/lib/check_key_type.js +40 -9
- package/dist/browser/lib/invalid_key_input.js +1 -0
- package/dist/browser/lib/is_jwk.js +13 -0
- package/dist/browser/runtime/get_sign_verify_key.js +1 -1
- package/dist/browser/runtime/normalize_key.js +21 -4
- package/dist/node/cjs/jwks/remote.js +1 -1
- package/dist/node/cjs/jws/flattened/sign.js +1 -1
- package/dist/node/cjs/jws/flattened/verify.js +9 -1
- package/dist/node/cjs/lib/check_key_type.js +41 -9
- package/dist/node/cjs/lib/invalid_key_input.js +1 -0
- package/dist/node/cjs/lib/is_jwk.js +20 -0
- package/dist/node/cjs/runtime/base64url.js +1 -1
- package/dist/node/cjs/runtime/check_key_length.js +11 -1
- package/dist/node/cjs/runtime/get_named_curve.js +4 -0
- package/dist/node/cjs/runtime/get_sign_verify_key.js +8 -1
- package/dist/node/cjs/runtime/node_key.js +51 -14
- package/dist/node/cjs/runtime/sign.js +3 -3
- package/dist/node/cjs/runtime/verify.js +3 -3
- package/dist/node/esm/jwks/remote.js +1 -1
- package/dist/node/esm/jws/flattened/sign.js +2 -2
- package/dist/node/esm/jws/flattened/verify.js +10 -2
- package/dist/node/esm/lib/check_key_type.js +40 -9
- package/dist/node/esm/lib/invalid_key_input.js +1 -0
- package/dist/node/esm/lib/is_jwk.js +13 -0
- package/dist/node/esm/runtime/base64url.js +1 -1
- package/dist/node/esm/runtime/check_key_length.js +11 -1
- package/dist/node/esm/runtime/get_named_curve.js +4 -0
- package/dist/node/esm/runtime/get_sign_verify_key.js +8 -1
- package/dist/node/esm/runtime/node_key.js +52 -15
- package/dist/node/esm/runtime/sign.js +3 -3
- package/dist/node/esm/runtime/verify.js +3 -3
- package/dist/types/jws/compact/sign.d.ts +2 -2
- package/dist/types/jws/compact/verify.d.ts +3 -3
- package/dist/types/jws/flattened/sign.d.ts +2 -2
- package/dist/types/jws/flattened/verify.d.ts +3 -3
- package/dist/types/jws/general/sign.d.ts +2 -2
- package/dist/types/jws/general/verify.d.ts +3 -3
- package/dist/types/jwt/sign.d.ts +2 -2
- package/dist/types/jwt/verify.d.ts +3 -3
- package/dist/types/types.d.ts +129 -29
- package/package.json +1 -1
package/dist/types/types.d.ts
CHANGED
|
@@ -29,59 +29,153 @@
|
|
|
29
29
|
*/
|
|
30
30
|
export type KeyLike = { type: string }
|
|
31
31
|
|
|
32
|
+
/** Generic JSON Web Key Parameters. */
|
|
33
|
+
export interface JWKParameters {
|
|
34
|
+
/** JWK "kty" (Key Type) Parameter. */
|
|
35
|
+
kty: string
|
|
36
|
+
/** JWK "alg" (Algorithm) Parameter. */
|
|
37
|
+
alg?: string
|
|
38
|
+
/** JWK "key_ops" (Key Operations) Parameter. */
|
|
39
|
+
key_ops?: string[]
|
|
40
|
+
/** JWK "ext" (Extractable) Parameter. */
|
|
41
|
+
ext?: boolean
|
|
42
|
+
/** JWK "use" (Public Key Use) Parameter. */
|
|
43
|
+
use?: string
|
|
44
|
+
/** JWK "x5c" (X.509 Certificate Chain) Parameter. */
|
|
45
|
+
x5c?: string[]
|
|
46
|
+
/** JWK "x5t" (X.509 Certificate SHA-1 Thumbprint) Parameter. */
|
|
47
|
+
x5t?: string
|
|
48
|
+
/** "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Parameter. */
|
|
49
|
+
'x5t#S256'?: string
|
|
50
|
+
/** JWK "x5u" (X.509 URL) Parameter. */
|
|
51
|
+
x5u?: string
|
|
52
|
+
/** JWK "kid" (Key ID) Parameter. */
|
|
53
|
+
kid?: string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Convenience interface for Public OKP JSON Web Keys */
|
|
57
|
+
export interface JWK_OKP_Public extends JWKParameters {
|
|
58
|
+
/** The Subtype of Key Pair */
|
|
59
|
+
crv: string
|
|
60
|
+
/** The public key */
|
|
61
|
+
x: string
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Convenience interface for Private OKP JSON Web Keys */
|
|
65
|
+
export interface JWK_OKP_Private extends JWK_OKP_Public, JWKParameters {
|
|
66
|
+
/** The Private Key */
|
|
67
|
+
d: string
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Convenience interface for Public EC JSON Web Keys */
|
|
71
|
+
export interface JWK_EC_Public extends JWKParameters {
|
|
72
|
+
/** Curve */
|
|
73
|
+
crv: string
|
|
74
|
+
/** X Coordinate */
|
|
75
|
+
x: string
|
|
76
|
+
/** Y Coordinate */
|
|
77
|
+
y: string
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Convenience interface for Private EC JSON Web Keys */
|
|
81
|
+
export interface JWK_EC_Private extends JWK_EC_Public, JWKParameters {
|
|
82
|
+
/** ECC Private Key */
|
|
83
|
+
d: string
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Convenience interface for Public RSA JSON Web Keys */
|
|
87
|
+
export interface JWK_RSA_Public extends JWKParameters {
|
|
88
|
+
/** Exponent */
|
|
89
|
+
e: string
|
|
90
|
+
/** Modulus */
|
|
91
|
+
n: string
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Convenience interface for Private RSA JSON Web Keys */
|
|
95
|
+
export interface JWK_RSA_Private extends JWK_RSA_Public, JWKParameters {
|
|
96
|
+
/** Private Exponent */
|
|
97
|
+
d: string
|
|
98
|
+
/** First Factor CRT Exponent */
|
|
99
|
+
dp: string
|
|
100
|
+
/** Second Factor CRT Exponent */
|
|
101
|
+
dq: string
|
|
102
|
+
/** Other Primes Info. This parameter is not supported. */
|
|
103
|
+
oth?: Array<{
|
|
104
|
+
d?: string
|
|
105
|
+
r?: string
|
|
106
|
+
t?: string
|
|
107
|
+
}>
|
|
108
|
+
/** First Prime Factor */
|
|
109
|
+
p: string
|
|
110
|
+
/** Second Prime Factor */
|
|
111
|
+
q: string
|
|
112
|
+
/** First CRT Coefficient */
|
|
113
|
+
qi: string
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Convenience interface for oct JSON Web Keys
|
|
118
|
+
*/
|
|
119
|
+
export interface JWK_oct extends JWKParameters {
|
|
120
|
+
/** Key Value */
|
|
121
|
+
k: string
|
|
122
|
+
}
|
|
123
|
+
|
|
32
124
|
/**
|
|
33
125
|
* JSON Web Key ({@link https://www.rfc-editor.org/rfc/rfc7517 JWK}). "RSA", "EC", "OKP", and "oct"
|
|
34
126
|
* key types are supported.
|
|
35
127
|
*/
|
|
36
|
-
export interface JWK {
|
|
37
|
-
/**
|
|
38
|
-
|
|
128
|
+
export interface JWK extends JWKParameters {
|
|
129
|
+
/**
|
|
130
|
+
* - (EC) Curve
|
|
131
|
+
* - (OKP) The Subtype of Key Pair
|
|
132
|
+
*/
|
|
39
133
|
crv?: string
|
|
134
|
+
/**
|
|
135
|
+
* - (Private RSA) Private Exponent
|
|
136
|
+
* - (Private EC) ECC Private Key
|
|
137
|
+
* - (Private OKP) The Private Key
|
|
138
|
+
*/
|
|
40
139
|
d?: string
|
|
140
|
+
/** (Private RSA) First Factor CRT Exponent */
|
|
41
141
|
dp?: string
|
|
142
|
+
/** (Private RSA) Second Factor CRT Exponent */
|
|
42
143
|
dq?: string
|
|
144
|
+
/** (RSA) Exponent */
|
|
43
145
|
e?: string
|
|
44
|
-
/**
|
|
45
|
-
ext?: boolean
|
|
146
|
+
/** (oct) Key Value */
|
|
46
147
|
k?: string
|
|
47
|
-
/**
|
|
48
|
-
key_ops?: string[]
|
|
49
|
-
/** JWK "kid" (Key ID) Parameter. */
|
|
50
|
-
kid?: string
|
|
51
|
-
/** JWK "kty" (Key Type) Parameter. */
|
|
52
|
-
kty?: string
|
|
148
|
+
/** (RSA) Modulus */
|
|
53
149
|
n?: string
|
|
150
|
+
/** (Private RSA) Other Primes Info. This parameter is not supported. */
|
|
54
151
|
oth?: Array<{
|
|
55
152
|
d?: string
|
|
56
153
|
r?: string
|
|
57
154
|
t?: string
|
|
58
155
|
}>
|
|
156
|
+
/** (Private RSA) First Prime Factor */
|
|
59
157
|
p?: string
|
|
158
|
+
/** (Private RSA) Second Prime Factor */
|
|
60
159
|
q?: string
|
|
160
|
+
/** (Private RSA) First CRT Coefficient */
|
|
61
161
|
qi?: string
|
|
62
|
-
/**
|
|
63
|
-
|
|
162
|
+
/**
|
|
163
|
+
* - (EC) X Coordinate
|
|
164
|
+
* - (OKP) The public key
|
|
165
|
+
*/
|
|
64
166
|
x?: string
|
|
167
|
+
/** (EC) Y Coordinate */
|
|
65
168
|
y?: string
|
|
66
|
-
/** JWK "x5c" (X.509 Certificate Chain) Parameter. */
|
|
67
|
-
x5c?: string[]
|
|
68
|
-
/** JWK "x5t" (X.509 Certificate SHA-1 Thumbprint) Parameter. */
|
|
69
|
-
x5t?: string
|
|
70
|
-
/** "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Parameter. */
|
|
71
|
-
'x5t#S256'?: string
|
|
72
|
-
/** JWK "x5u" (X.509 URL) Parameter. */
|
|
73
|
-
x5u?: string
|
|
74
169
|
|
|
75
170
|
[propName: string]: unknown
|
|
76
171
|
}
|
|
77
172
|
|
|
78
173
|
/**
|
|
79
|
-
*
|
|
174
|
+
* @private
|
|
80
175
|
*
|
|
81
|
-
* @
|
|
82
|
-
* @param IToken Type definition of the consumed JWE or JWS token.
|
|
176
|
+
* @internal
|
|
83
177
|
*/
|
|
84
|
-
export interface
|
|
178
|
+
export interface GenericGetKeyFunction<IProtectedHeader, IToken, ReturnKeyTypes> {
|
|
85
179
|
/**
|
|
86
180
|
* Dynamic key resolution function. No token components have been verified at the time of this
|
|
87
181
|
* function call.
|
|
@@ -91,12 +185,18 @@ export interface GetKeyFunction<IProtectedHeader, IToken> {
|
|
|
91
185
|
* @param protectedHeader JWE or JWS Protected Header.
|
|
92
186
|
* @param token The consumed JWE or JWS token.
|
|
93
187
|
*/
|
|
94
|
-
(
|
|
95
|
-
protectedHeader: IProtectedHeader,
|
|
96
|
-
token: IToken,
|
|
97
|
-
): Promise<KeyLike | Uint8Array> | KeyLike | Uint8Array
|
|
188
|
+
(protectedHeader: IProtectedHeader, token: IToken): Promise<ReturnKeyTypes> | ReturnKeyTypes
|
|
98
189
|
}
|
|
99
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Generic Interface for consuming operations dynamic key resolution.
|
|
193
|
+
*
|
|
194
|
+
* @param IProtectedHeader Type definition of the JWE or JWS Protected Header.
|
|
195
|
+
* @param IToken Type definition of the consumed JWE or JWS token.
|
|
196
|
+
*/
|
|
197
|
+
export interface GetKeyFunction<IProtectedHeader, IToken>
|
|
198
|
+
extends GenericGetKeyFunction<IProtectedHeader, IToken, KeyLike | Uint8Array> {}
|
|
199
|
+
|
|
100
200
|
/**
|
|
101
201
|
* Flattened JWS definition for verify function inputs, allows payload as Uint8Array for detached
|
|
102
202
|
* signature validation.
|