mirror of
https://github.com/hanzoai/passport-saml.git
synced 2026-09-24 17:01:45 +00:00
Update prettier (#897)
This commit is contained in:
+1
-1
@@ -45,7 +45,7 @@ module.exports = {
|
||||
release: function (placeholders) {
|
||||
placeholders.body = placeholders.body.replace(
|
||||
"*No changelog for this release.*",
|
||||
"\n_No changelog for this release._"
|
||||
"\n_No changelog for this release._",
|
||||
);
|
||||
return `## ${placeholders.release} (${placeholders.date})\n${placeholders.body}`;
|
||||
},
|
||||
|
||||
@@ -173,7 +173,7 @@ app.post(
|
||||
}),
|
||||
function (req, res) {
|
||||
res.redirect("/");
|
||||
}
|
||||
},
|
||||
);
|
||||
```
|
||||
|
||||
@@ -187,7 +187,7 @@ app.get(
|
||||
passport.authenticate("saml", { failureRedirect: "/", failureFlash: true }),
|
||||
function (req, res) {
|
||||
res.redirect("/");
|
||||
}
|
||||
},
|
||||
);
|
||||
```
|
||||
|
||||
@@ -201,7 +201,7 @@ app.get(
|
||||
}),
|
||||
function (req, res) {
|
||||
res.redirect("/");
|
||||
}
|
||||
},
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@@ -42,6 +42,6 @@ console.log(
|
||||
verified: verified,
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
2,
|
||||
),
|
||||
);
|
||||
|
||||
Generated
+43
-18
@@ -29,12 +29,12 @@
|
||||
"choma": "^1.2.1",
|
||||
"concurrently": "^8.2.2",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^8.10.0",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"mocha": "^10.3.0",
|
||||
"nyc": "^15.1.0",
|
||||
"onchange": "^7.1.0",
|
||||
"prettier": "^2.8.8",
|
||||
"prettier": "^3.2.5",
|
||||
"prettier-plugin-packagejson": "^2.4.12",
|
||||
"release-it": "^17.1.1",
|
||||
"sinon": "^17.0.1",
|
||||
@@ -3534,9 +3534,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-config-prettier": {
|
||||
"version": "8.10.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.10.0.tgz",
|
||||
"integrity": "sha512-SM8AMJdeQqRYT9O9zguiruQZaN7+z+E4eAP9oiLNGKMtomwaB1E9dcgUD6ZAn/eQAb52USbvezbiljfZUhbJcg==",
|
||||
"version": "9.1.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz",
|
||||
"integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"eslint-config-prettier": "bin/cli.js"
|
||||
@@ -3546,26 +3546,51 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-prettier": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz",
|
||||
"integrity": "sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ==",
|
||||
"version": "5.1.3",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.1.3.tgz",
|
||||
"integrity": "sha512-C9GCVAs4Eq7ZC/XFQHITLiHJxQngdtraXaM+LoUFoFp/lHNl2Zn8f3WQbe9HvTBBQ9YnKFB0/2Ajdqwo5D1EAw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"prettier-linter-helpers": "^1.0.0"
|
||||
"prettier-linter-helpers": "^1.0.0",
|
||||
"synckit": "^0.8.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
"node": "^14.18.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/eslint-plugin-prettier"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": ">=7.28.0",
|
||||
"prettier": ">=2.0.0"
|
||||
"@types/eslint": ">=8.0.0",
|
||||
"eslint": ">=8.0.0",
|
||||
"eslint-config-prettier": "*",
|
||||
"prettier": ">=3.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/eslint": {
|
||||
"optional": true
|
||||
},
|
||||
"eslint-config-prettier": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-prettier/node_modules/synckit": {
|
||||
"version": "0.8.8",
|
||||
"resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.8.tgz",
|
||||
"integrity": "sha512-HwOKAP7Wc5aRGYdKH+dw0PRRpbO841v2DENBtjnR5HFWoiNByAl7vrx3p0G/rCyYXQsrxqtX48TImFtPcIHSpQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@pkgr/core": "^0.1.0",
|
||||
"tslib": "^2.6.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/unts"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-visitor-keys": {
|
||||
"version": "3.4.3",
|
||||
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz",
|
||||
@@ -9644,15 +9669,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "2.8.8",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
|
||||
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
|
||||
"version": "3.2.5",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz",
|
||||
"integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
|
||||
+3
-3
@@ -73,12 +73,12 @@
|
||||
"choma": "^1.2.1",
|
||||
"concurrently": "^8.2.2",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^8.10.0",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"mocha": "^10.3.0",
|
||||
"nyc": "^15.1.0",
|
||||
"onchange": "^7.1.0",
|
||||
"prettier": "^2.8.8",
|
||||
"prettier": "^3.2.5",
|
||||
"prettier-plugin-packagejson": "^2.4.12",
|
||||
"release-it": "^17.1.1",
|
||||
"sinon": "^17.0.1",
|
||||
|
||||
@@ -17,12 +17,12 @@ export class MultiSamlStrategy extends AbstractStrategy {
|
||||
constructor(
|
||||
options: MultiStrategyConfig,
|
||||
signonVerify: VerifyWithRequest,
|
||||
logoutVerify: VerifyWithRequest
|
||||
logoutVerify: VerifyWithRequest,
|
||||
);
|
||||
constructor(
|
||||
options: MultiStrategyConfig,
|
||||
signonVerify: VerifyWithoutRequest,
|
||||
logoutVerify: VerifyWithoutRequest
|
||||
logoutVerify: VerifyWithoutRequest,
|
||||
);
|
||||
constructor(options: MultiStrategyConfig, signonVerify: never, logoutVerify: never) {
|
||||
if (!options || typeof options.getSamlOptions !== "function") {
|
||||
@@ -55,7 +55,7 @@ export class MultiSamlStrategy extends AbstractStrategy {
|
||||
|
||||
logout(
|
||||
req: RequestWithUser,
|
||||
callback: (err: Error | null, url?: string | null | undefined) => void
|
||||
callback: (err: Error | null, url?: string | null | undefined) => void,
|
||||
): void {
|
||||
this._options.getSamlOptions(req, (err, samlOptions) => {
|
||||
if (err) {
|
||||
@@ -73,7 +73,7 @@ export class MultiSamlStrategy extends AbstractStrategy {
|
||||
req: Request,
|
||||
decryptionCert: string | null,
|
||||
signingCert: string | string[] | null,
|
||||
callback: (err: Error | null, metadata?: string) => void
|
||||
callback: (err: Error | null, metadata?: string) => void,
|
||||
): void {
|
||||
if (typeof callback !== "function") {
|
||||
throw new Error("Metadata can't be provided synchronously for MultiSamlStrategy.");
|
||||
@@ -89,7 +89,7 @@ export class MultiSamlStrategy extends AbstractStrategy {
|
||||
Object.setPrototypeOf(strategy, this);
|
||||
return callback(
|
||||
null,
|
||||
this._generateServiceProviderMetadata.call(strategy, decryptionCert, signingCert)
|
||||
this._generateServiceProviderMetadata.call(strategy, decryptionCert, signingCert),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
+7
-7
@@ -25,12 +25,12 @@ export abstract class AbstractStrategy extends PassportStrategy {
|
||||
constructor(
|
||||
options: PassportSamlConfig,
|
||||
signonVerify: VerifyWithRequest,
|
||||
logoutVerify: VerifyWithRequest
|
||||
logoutVerify: VerifyWithRequest,
|
||||
);
|
||||
constructor(
|
||||
options: PassportSamlConfig,
|
||||
signonVerify: VerifyWithoutRequest,
|
||||
logoutVerify: VerifyWithoutRequest
|
||||
logoutVerify: VerifyWithoutRequest,
|
||||
);
|
||||
constructor(options: PassportSamlConfig, signonVerify: never, logoutVerify: never) {
|
||||
super();
|
||||
@@ -90,7 +90,7 @@ export abstract class AbstractStrategy extends PassportStrategy {
|
||||
const RelayState = req.query?.RelayState || req.body?.RelayState;
|
||||
if (this._saml == null) {
|
||||
return this.error(
|
||||
new Error("Can't get logout response URL without a SAML provider defined.")
|
||||
new Error("Can't get logout response URL without a SAML provider defined."),
|
||||
);
|
||||
} else {
|
||||
this._saml.getLogoutResponseUrl(
|
||||
@@ -98,7 +98,7 @@ export abstract class AbstractStrategy extends PassportStrategy {
|
||||
RelayState,
|
||||
options,
|
||||
userMatch,
|
||||
redirectIfSuccess
|
||||
redirectIfSuccess,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ export abstract class AbstractStrategy extends PassportStrategy {
|
||||
(req.query && req.query.RelayState) || (req.body && req.body.RelayState);
|
||||
// Defaults to HTTP-Redirect
|
||||
this.redirect(
|
||||
await this._saml.getLogoutUrlAsync(req.user as Profile, RelayState, options)
|
||||
await this._saml.getLogoutUrlAsync(req.user as Profile, RelayState, options),
|
||||
);
|
||||
} catch (err) {
|
||||
this.error(err as Error);
|
||||
@@ -242,7 +242,7 @@ export abstract class AbstractStrategy extends PassportStrategy {
|
||||
|
||||
protected _generateServiceProviderMetadata(
|
||||
decryptionCert: string | null,
|
||||
signingCert?: string | string[] | null
|
||||
signingCert?: string | string[] | null,
|
||||
): string {
|
||||
if (this._saml == null) {
|
||||
throw new Error("Can't generate service provider metadata without a SAML provider defined.");
|
||||
@@ -268,7 +268,7 @@ export class Strategy extends AbstractStrategy {
|
||||
|
||||
generateServiceProviderMetadata(
|
||||
decryptionCert: string | null,
|
||||
signingCert?: string | string[] | null
|
||||
signingCert?: string | string[] | null,
|
||||
): string {
|
||||
return this._generateServiceProviderMetadata(decryptionCert, signingCert);
|
||||
}
|
||||
|
||||
+7
-4
@@ -23,13 +23,13 @@ export interface RequestWithUser extends express.Request {
|
||||
export type VerifiedCallback = (
|
||||
err: Error | null,
|
||||
user?: Record<string, unknown>,
|
||||
info?: Record<string, unknown>
|
||||
info?: Record<string, unknown>,
|
||||
) => void;
|
||||
|
||||
export type VerifyWithRequest = (
|
||||
req: express.Request,
|
||||
profile: Profile | null,
|
||||
done: VerifiedCallback
|
||||
done: VerifiedCallback,
|
||||
) => void;
|
||||
|
||||
export type VerifyWithoutRequest = (profile: Profile | null, done: VerifiedCallback) => void;
|
||||
@@ -38,7 +38,7 @@ export type PassportSamlConfig = SamlConfig & StrategyOptions;
|
||||
|
||||
export type StrategyOptionsCallback = (
|
||||
err: Error | null,
|
||||
samlOptions?: Partial<PassportSamlConfig>
|
||||
samlOptions?: Partial<PassportSamlConfig>,
|
||||
) => void;
|
||||
|
||||
interface BaseMultiStrategyConfig {
|
||||
@@ -50,7 +50,10 @@ export type MultiStrategyConfig = Partial<PassportSamlConfig> &
|
||||
BaseMultiStrategyConfig;
|
||||
|
||||
export class ErrorWithXmlStatus extends Error {
|
||||
constructor(message: string, public readonly xmlStatus: string) {
|
||||
constructor(
|
||||
message: string,
|
||||
public readonly xmlStatus: string,
|
||||
) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ describe("MultiSamlStrategy()", function () {
|
||||
getSamlOptions,
|
||||
},
|
||||
noop,
|
||||
noop
|
||||
noop,
|
||||
);
|
||||
// @ts-expect-error
|
||||
strategy.authenticate("random", "random");
|
||||
@@ -120,7 +120,7 @@ describe("MultiSamlStrategy()", function () {
|
||||
fn(null, samlOptions);
|
||||
sinon.assert.calledOnce(superAuthenticateStub);
|
||||
superAuthenticateStub.calledWith(
|
||||
Object.assign({}, { cacheProvider: "mock cache provider" }, samlOptions)
|
||||
Object.assign({}, { cacheProvider: "mock cache provider" }, samlOptions),
|
||||
);
|
||||
done();
|
||||
} catch (err2) {
|
||||
@@ -132,7 +132,7 @@ describe("MultiSamlStrategy()", function () {
|
||||
// @ts-expect-error
|
||||
{ getSamlOptions, cacheProvider: "mock cache provider" },
|
||||
noop,
|
||||
noop
|
||||
noop,
|
||||
);
|
||||
// @ts-expect-error
|
||||
strategy.authenticate("random", "random");
|
||||
@@ -371,7 +371,7 @@ describe("MultiSamlStrategy()", function () {
|
||||
} catch (err2) {
|
||||
done(err2);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
+12
-12
@@ -24,7 +24,7 @@ describe("Strategy()", function () {
|
||||
it("should require that `signonVerify` be a function", function () {
|
||||
// @ts-ignore
|
||||
expect(() => new SamlStrategy({}, {})).to.throw(
|
||||
"SAML authentication strategy requires a verify function"
|
||||
"SAML authentication strategy requires a verify function",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -108,7 +108,7 @@ describe("Strategy()", function () {
|
||||
callbackUrl: "https://www.example.com",
|
||||
},
|
||||
noop,
|
||||
noop
|
||||
noop,
|
||||
);
|
||||
|
||||
// This returns immediately, but calls async functions; need to turn event loop
|
||||
@@ -129,7 +129,7 @@ describe("Strategy()", function () {
|
||||
callbackUrl: "https://www.example.com",
|
||||
},
|
||||
noop,
|
||||
noop
|
||||
noop,
|
||||
);
|
||||
|
||||
// This returns immediately, but calls async functions; need to turn event loop
|
||||
@@ -146,7 +146,7 @@ describe("Strategy()", function () {
|
||||
const strategy = new SamlStrategy(
|
||||
{ idpCert: FAKE_CERT, issuer: "onesaml_login", callbackUrl: "https://www.example.com" },
|
||||
noop,
|
||||
noop
|
||||
noop,
|
||||
);
|
||||
|
||||
// This returns immediately, but calls async functions; need to turn event loop
|
||||
@@ -177,7 +177,7 @@ describe("Strategy()", function () {
|
||||
if (_profile) {
|
||||
cb(null, { name: _profile.nameID });
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
validatePostResponseAsyncStub.resolves({
|
||||
@@ -207,7 +207,7 @@ describe("Strategy()", function () {
|
||||
sinon.match.any,
|
||||
sinon.match.any,
|
||||
false,
|
||||
sinon.match.func
|
||||
sinon.match.func,
|
||||
);
|
||||
sinon.assert.calledOnce(getLogoutResponseUrlStub);
|
||||
sinon.assert.calledOnce(logoutSpy);
|
||||
@@ -227,7 +227,7 @@ describe("Strategy()", function () {
|
||||
if (_profile) {
|
||||
cb(null, { name: _profile.nameID });
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
validateRedirectAsyncStub.resolves({
|
||||
@@ -259,7 +259,7 @@ describe("Strategy()", function () {
|
||||
sinon.match.any,
|
||||
sinon.match.any,
|
||||
true,
|
||||
sinon.match.func
|
||||
sinon.match.func,
|
||||
);
|
||||
sinon.assert.calledOnce(getLogoutResponseUrlStub);
|
||||
sinon.assert.calledOnceWithMatch(redirectStub, requestWithUserGetResponse.url);
|
||||
@@ -280,7 +280,7 @@ describe("Strategy()", function () {
|
||||
function (_profile: Profile | null, cb: VerifiedCallback) {
|
||||
// for logout
|
||||
cb(new Error("Signon shouldn't call logout."));
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
validatePostRequestAsyncStub.resolves({
|
||||
@@ -324,13 +324,13 @@ describe("Strategy()", function () {
|
||||
new SamlStrategy(
|
||||
{ idpCert: FAKE_CERT, issuer: "onesaml_login", callbackUrl: "https://www.example.com" },
|
||||
noop,
|
||||
noop
|
||||
noop,
|
||||
).logout(
|
||||
{
|
||||
// @ts-expect-error
|
||||
query: "",
|
||||
},
|
||||
noop
|
||||
noop,
|
||||
);
|
||||
sinon.assert.calledOnce(getLogoutUrlAsyncStub);
|
||||
});
|
||||
@@ -342,7 +342,7 @@ describe("Strategy()", function () {
|
||||
beforeEach(function () {
|
||||
generateServiceProviderMetadataStub = sinon.stub(
|
||||
SAML.prototype,
|
||||
"generateServiceProviderMetadata"
|
||||
"generateServiceProviderMetadata",
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user