Skip to content

Commit d0ee50a

Browse files
committed
fix: ignore client metadata valued undefined when applying defualts
fixes #824
1 parent 216216f commit d0ee50a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/helpers/client_schema.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const instance = require('./weak_cache');
2424
const formatters = require('./formatters');
2525
const pick = require('./_/pick');
2626
const without = require('./_/without');
27+
const omitBy = require('./_/omit_by');
2728

2829
const clientAuthEndpoints = ['token', 'introspection', 'revocation'];
2930
// TODO: in v7.x remove the `introspection` and `revocation` metadata, only token endpoint will be
@@ -32,6 +33,10 @@ const W3CEmailRegExp = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a
3233
const encAlgRequiringJwks = /^(RSA|ECDH)/;
3334
const requestSignAlgRequiringJwks = /^(?:PS(?:256|384|512)|RS(?:256|384|512)|ES(?:256K?|384|512)|EdDSA)$/;
3435

36+
function isUndefined(value) {
37+
return value === undefined;
38+
}
39+
3540
function checkClientAuth(schema) {
3641
return !!clientAuthEndpoints.find((endpoint) => ['private_key_jwt', 'self_signed_tls_client_auth'].includes(schema[`${endpoint}_endpoint_auth_method`]));
3742
}
@@ -240,8 +245,14 @@ module.exports = function getSchema(provider) {
240245

241246
Object.assign(
242247
this,
243-
pick(DEFAULT, ...RECOGNIZED_METADATA),
244-
pick(metadata, ...RECOGNIZED_METADATA, ...configuration.extraClientMetadata.properties),
248+
omitBy(
249+
pick(DEFAULT, ...RECOGNIZED_METADATA),
250+
isUndefined,
251+
),
252+
omitBy(
253+
pick(metadata, ...RECOGNIZED_METADATA, ...configuration.extraClientMetadata.properties),
254+
isUndefined,
255+
),
245256
);
246257

247258
this.required();

test/configuration/client_metadata.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ describe('Client metadata validation', () => {
474474

475475
context('post_logout_redirect_uris', function () {
476476
defaultsTo(this.title, [], undefined);
477+
defaultsTo(this.title, [], { post_logout_redirect_uris: undefined });
477478
mustBeArray(this.title, undefined);
478479

479480
rejects(this.title, [123], /must only contain strings$/, undefined);

0 commit comments

Comments
 (0)