Skip to content

Commit

Permalink
refactor: deprecate FAPI 1.0 ID2, lax request objects, plain PKCE
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed May 2, 2024
1 parent cd7e0f4 commit 3e8a784
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/helpers/configuration.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { deprecate } from 'node:util';

import { JWA } from '../consts/index.js';

import get from './_/get.js';
Expand All @@ -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']);
Expand Down Expand Up @@ -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();
}
});
}

Expand Down Expand Up @@ -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() {
Expand All @@ -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;
}
}
Expand Down

0 comments on commit 3e8a784

Please sign in to comment.