jose 1.27.3 → 1.28.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/CHANGELOG.md +9 -0
- package/lib/jwe/encrypt.js +5 -1
- package/lib/jws/sign.js +12 -17
- package/lib/jwt/verify.js +6 -3
- package/package.json +1 -1
- package/types/index.d.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
# [1.28.0](https://github.com/panva/jose/compare/v1.27.3...v1.28.0) (2020-08-10)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* support for validating issuer from a list of values ([#91](https://github.com/panva/jose/issues/91)) ([ce6836a](https://github.com/panva/jose/commit/ce6836af88c9e73c29560233f15ed1760c7dcc13))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
5
14
|
## [1.27.3](https://github.com/panva/jose/compare/v1.27.2...v1.27.3) (2020-08-04)
|
|
6
15
|
|
|
7
16
|
|
package/lib/jwe/encrypt.js
CHANGED
|
@@ -190,7 +190,11 @@ class Encrypt {
|
|
|
190
190
|
let aad
|
|
191
191
|
if (this._aad) {
|
|
192
192
|
final.aad = base64url.encode(this._aad)
|
|
193
|
-
aad = Buffer.concat([
|
|
193
|
+
aad = Buffer.concat([
|
|
194
|
+
Buffer.from(final.protected || ''),
|
|
195
|
+
Buffer.from('.'),
|
|
196
|
+
Buffer.from(final.aad)
|
|
197
|
+
])
|
|
194
198
|
} else {
|
|
195
199
|
aad = Buffer.from(final.protected || '')
|
|
196
200
|
}
|
package/lib/jws/sign.js
CHANGED
|
@@ -87,26 +87,21 @@ class Sign {
|
|
|
87
87
|
recipient.header = unprotectedHeader
|
|
88
88
|
recipient.protected = Object.keys(joseHeader.protected).length ? base64url.JSON.encode(joseHeader.protected) : ''
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
} else {
|
|
96
|
-
this._payload = base64url.decode(this._payload)
|
|
97
|
-
}
|
|
90
|
+
if (first && joseHeader.protected.crit && joseHeader.protected.crit.includes('b64') && joseHeader.protected.b64 === false) {
|
|
91
|
+
if (this._binary) {
|
|
92
|
+
this._payload = base64url.decodeToBuffer(this._payload)
|
|
93
|
+
} else {
|
|
94
|
+
this._payload = base64url.decode(this._payload)
|
|
98
95
|
}
|
|
99
|
-
|
|
100
|
-
toBeSigned = Buffer.concat([
|
|
101
|
-
Buffer.from(recipient.protected || ''),
|
|
102
|
-
Buffer.from('.'),
|
|
103
|
-
Buffer.isBuffer(this._payload) ? this._payload : Buffer.from(this._payload)
|
|
104
|
-
])
|
|
105
|
-
} else {
|
|
106
|
-
toBeSigned = `${recipient.protected || ''}.${this._payload}`
|
|
107
96
|
}
|
|
108
97
|
|
|
109
|
-
|
|
98
|
+
const data = Buffer.concat([
|
|
99
|
+
Buffer.from(recipient.protected || ''),
|
|
100
|
+
Buffer.from('.'),
|
|
101
|
+
Buffer.from(this._payload)
|
|
102
|
+
])
|
|
103
|
+
|
|
104
|
+
recipient.signature = base64url.encodeBuffer(sign(alg, key, data))
|
|
110
105
|
}
|
|
111
106
|
|
|
112
107
|
/*
|
package/lib/jwt/verify.js
CHANGED
|
@@ -63,12 +63,15 @@ const validateOptions = ({
|
|
|
63
63
|
|
|
64
64
|
isOptionString(maxTokenAge, 'options.maxTokenAge')
|
|
65
65
|
isOptionString(subject, 'options.subject')
|
|
66
|
-
isOptionString(issuer, 'options.issuer')
|
|
67
66
|
isOptionString(maxAuthAge, 'options.maxAuthAge')
|
|
68
67
|
isOptionString(jti, 'options.jti')
|
|
69
68
|
isOptionString(clockTolerance, 'options.clockTolerance')
|
|
70
69
|
isOptionString(typ, 'options.typ')
|
|
71
70
|
|
|
71
|
+
if (issuer !== undefined && (isNotString(issuer) && isNotArrayOfStrings(issuer))) {
|
|
72
|
+
throw new TypeError('options.issuer must be a string or an array of strings')
|
|
73
|
+
}
|
|
74
|
+
|
|
72
75
|
if (audience !== undefined && (isNotString(audience) && isNotArrayOfStrings(audience))) {
|
|
73
76
|
throw new TypeError('options.audience must be a string or an array of strings')
|
|
74
77
|
}
|
|
@@ -161,7 +164,7 @@ const validateTypes = ({ header, payload }, profile, options) => {
|
|
|
161
164
|
isPayloadString(payload.jti, '"jti" claim', 'jti', profile === LOGOUTTOKEN || profile === ATJWT || !!options.jti)
|
|
162
165
|
isPayloadString(payload.acr, '"acr" claim', 'acr')
|
|
163
166
|
isPayloadString(payload.nonce, '"nonce" claim', 'nonce', !!options.nonce)
|
|
164
|
-
|
|
167
|
+
isStringOrArrayOfStrings(payload.iss, 'iss', !!options.issuer)
|
|
165
168
|
isPayloadString(payload.sub, '"sub" claim', 'sub', profile === IDTOKEN || profile === ATJWT || !!options.subject)
|
|
166
169
|
isStringOrArrayOfStrings(payload.aud, 'aud', !!options.audience)
|
|
167
170
|
isPayloadString(payload.azp, '"azp" claim', 'azp', profile === IDTOKEN && Array.isArray(payload.aud) && payload.aud.length > 1)
|
|
@@ -235,7 +238,7 @@ module.exports = (token, key, options = {}) => {
|
|
|
235
238
|
const unix = epoch(now)
|
|
236
239
|
validateTypes(decoded, profile, options)
|
|
237
240
|
|
|
238
|
-
if (issuer && decoded.payload.iss !== issuer) {
|
|
241
|
+
if (issuer && (typeof decoded.payload.iss !== 'string' || !(typeof issuer === 'string' ? [issuer] : issuer).includes(decoded.payload.iss))) {
|
|
239
242
|
throw new JWTClaimInvalid('unexpected "iss" claim value', 'iss', 'check_failed')
|
|
240
243
|
}
|
|
241
244
|
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -444,7 +444,7 @@ export namespace JWT {
|
|
|
444
444
|
ignoreIat?: boolean;
|
|
445
445
|
maxTokenAge?: string;
|
|
446
446
|
subject?: string;
|
|
447
|
-
issuer?: string;
|
|
447
|
+
issuer?: string | string[];
|
|
448
448
|
maxAuthAge?: string;
|
|
449
449
|
jti?: string;
|
|
450
450
|
clockTolerance?: string;
|
|
@@ -479,7 +479,7 @@ export namespace JWT {
|
|
|
479
479
|
function sign(payload: object, key: ProduceKeyInputWithNone, options?: SignOptions): string;
|
|
480
480
|
|
|
481
481
|
interface VerifyProfileOptions<profile> {
|
|
482
|
-
issuer: string;
|
|
482
|
+
issuer: string | string[];
|
|
483
483
|
audience: string | string[];
|
|
484
484
|
profile?: profile;
|
|
485
485
|
}
|