Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update prettier #897

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .grenrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
},
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ app.post(
}),
function (req, res) {
res.redirect("/");
}
},
);
```

Expand All @@ -187,7 +187,7 @@ app.get(
passport.authenticate("saml", { failureRedirect: "/", failureFlash: true }),
function (req, res) {
res.redirect("/");
}
},
);
```

Expand All @@ -201,7 +201,7 @@ app.get(
}),
function (req, res) {
res.redirect("/");
}
},
);
```

Expand Down
4 changes: 2 additions & 2 deletions docs/xml-signing-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ console.log(
verified: verified,
},
null,
2
)
2,
),
);
61 changes: 43 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions src/multiSamlStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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) {
Expand All @@ -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.");
Expand All @@ -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),
);
});
}
Expand Down
14 changes: 7 additions & 7 deletions src/strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -90,15 +90,15 @@ 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(
profile,
RelayState,
options,
userMatch,
redirectIfSuccess
redirectIfSuccess,
);
}

Expand Down Expand Up @@ -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);
Expand All @@ -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.");
Expand All @@ -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);
}
Expand Down
11 changes: 7 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -38,7 +38,7 @@ export type PassportSamlConfig = SamlConfig & StrategyOptions;

export type StrategyOptionsCallback = (
err: Error | null,
samlOptions?: Partial<PassportSamlConfig>
samlOptions?: Partial<PassportSamlConfig>,
) => void;

interface BaseMultiStrategyConfig {
Expand All @@ -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);
}
}
8 changes: 4 additions & 4 deletions test/multiSamlStrategy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe("MultiSamlStrategy()", function () {
getSamlOptions,
},
noop,
noop
noop,
);
// @ts-expect-error
strategy.authenticate("random", "random");
Expand Down Expand Up @@ -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) {
Expand All @@ -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");
Expand Down Expand Up @@ -371,7 +371,7 @@ describe("MultiSamlStrategy()", function () {
} catch (err2) {
done(err2);
}
}
},
);
});
});
Expand Down
Loading
Loading