From 3e8a7844fd0060839a5617cccbc40ec75d38f480 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Thu, 2 May 2024 10:26:13 +0200 Subject: [PATCH] refactor: deprecate FAPI 1.0 ID2, lax request objects, plain PKCE --- lib/helpers/configuration.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/helpers/configuration.js b/lib/helpers/configuration.js index 9d317c615..949239c39 100644 --- a/lib/helpers/configuration.js +++ b/lib/helpers/configuration.js @@ -1,3 +1,5 @@ +import { deprecate } from 'node:util'; + import { JWA } from '../consts/index.js'; import get from './_/get.js'; @@ -24,6 +26,21 @@ function filterHS(alg) { return alg.startsWith('HS'); } +const deprecations = { + lax: deprecate( + () => {}, + 'The "lax" Request Object mode is deprecated and will be removed in the next major revision.', + ), + ID2: deprecate( + () => {}, + 'The "1.0 ID2" FAPI Profile is deprecated and will be removed in the next major revision.', + ), + plain: deprecate( + () => {}, + 'The "plain" PKCE method is deprecated and will be removed in the next major revision.', + ), +}; + const filterAsymmetricSig = RegExp.prototype.test.bind(/^(?:PS(?:256|384|512)|RS(?:256|384|512)|ES(?:256K?|384|512)|EdDSA)$/); const supportedResponseTypes = new Set(['none', 'code', 'id_token', 'token']); @@ -341,6 +358,9 @@ class Configuration { if (!['plain', 'S256'].includes(type)) { throw new TypeError('only plain and S256 code challenge methods are supported'); } + if (type === 'plain') { + deprecations.plain(); + } }); } @@ -397,6 +417,10 @@ class Configuration { if (!requestObjectStrategies.has(this.features.requestObjects.mode)) { throw new TypeError(`'mode' must be ${formatters.formatList([...requestObjectStrategies], { type: 'disjunction' })}`); } + + if (this.features.requestObjects.mode === 'lax') { + deprecations.lax(); + } } checkFapiProfile() { @@ -409,12 +433,18 @@ class Configuration { if (profile && !fapiProfiles.has(profile)) { throw new TypeError(`'profile' must be ${formatters.formatList([...fapiProfiles], { type: 'disjunction' })}`); } + if (profile === '1.0 ID2') { + deprecations.ID2(); + } return profile || undefined; }; } else if (!fapiProfiles.has(this.features.fapi.profile)) { throw new TypeError(`'profile' must be ${formatters.formatList([...fapiProfiles], { type: 'disjunction' })}`); } else { const value = this.features.fapi.profile; + if (value === '1.0 ID2') { + deprecations.ID2(); + } this.features.fapi.profile = () => value; } }