Skip to content
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
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,26 @@ The input schema for the policy is defined as follows:

```json5
{
// Can be empty if not provided.
config: {
key: "value",
},
target: {
owner: "owner",
repository: "repository",
ref: "ref",
workflow: "workflow",
// Can be empty if none are required.
inputs: {
key: "value",
},
},
caller: {
owner: "owner",
repository: "repository",
ref: "ref",
workflow: "workflow",
},
// Can be empty if not provided.
config: {
key: "value",
},
target: {
owner: "owner",
repository: "repository",
ref: "ref",
workflow: "workflow",
// Can be empty if none are required.
inputs: {
key: "value",
},
},
caller: {
owner: "owner",
repository: "repository",
ref: "ref",
workflow: "workflow",
},
}
```

Expand Down
2 changes: 1 addition & 1 deletion etsc.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default {
const fsp = await import("node:fs/promises");
await fsp.writeFile(
"dist/package.json",
JSON.stringify({ type: "module" })
JSON.stringify({ type: "module" }),
);
},
};
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@
"zod": "^3.24.1"
},
"devDependencies": {
"@abinnovision/commitlint-config": "^2.2.0",
"@abinnovision/eslint-config-base": "^2.1.0",
"@abinnovision/eslint-config-typescript": "^2.1.0",
"@abinnovision/prettier-config": "^2.1.0",
"@abinnovision/commitlint-config": "^2.2.1",
"@abinnovision/eslint-config-base": "^2.2.0",
"@abinnovision/eslint-config-typescript": "^2.2.1",
"@abinnovision/prettier-config": "^2.1.3",
"@commitlint/cli": "^19.7.1",
"@types/body-parser": "^1",
"@types/express": "^4",
Expand All @@ -81,16 +81,16 @@
"dotenv-cli": "^8.0.0",
"esbuild": "^0.25.0",
"esbuild-node-tsc": "^2.0.5",
"eslint": "^9.13.0",
"eslint": "^9.20.1",
"get-port-please": "^3.1.2",
"globals": "^15.11.0",
"husky": "^9.1.6",
"globals": "^15.15.0",
"husky": "^9.1.7",
"lint-staged": "^15.4.3",
"nock": "^14.0.0-beta.6",
"nodemon": "^3.1.4",
"oauth2-mock-server": "^7.2.0",
"prettier": "^3.3.3",
"sort-package-json": "^2.10.1",
"prettier": "^3.5.1",
"sort-package-json": "^2.14.0",
"supertest": "^7.0.0",
"ts-node": "^10.9.2",
"typescript": "^5.7.3",
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const bootstrap = (async (): Promise<BootstrapResult> => {
.status(200)
.header(
"cache-control",
"public, max-age 172800, stale-while-revalidate 172800"
"public, max-age 172800, stale-while-revalidate 172800",
)
.header("content-type", "application/yaml")
.send(content);
Expand All @@ -91,7 +91,7 @@ export const bootstrap = (async (): Promise<BootstrapResult> => {
.status(200)
.header(
"cache-control",
"public, max-age 172800, stale-while-revalidate 172800"
"public, max-age 172800, stale-while-revalidate 172800",
)
.header("content-type", "application/json")
.send(content);
Expand Down
1 change: 0 additions & 1 deletion src/dispatch/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@
let body;
try {
body = await bodySchema.parseAsync(await req.body);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {

Check warning on line 76 in src/dispatch/controller.ts

View workflow job for this annotation

GitHub Actions / Check

'e' is defined but never used
return res
.status(400)
.header("content-type", responseContentType)
Expand Down
14 changes: 7 additions & 7 deletions src/dispatch/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ let _baseOctokit = new Octokit({
*/
async function runOctokit<T>(
token: string,
callback: (octokit: Octokit) => Promise<T>
callback: (octokit: Octokit) => Promise<T>,
): Promise<T> {
return await _authCallbackAls.run(
token,
async () => await callback(_baseOctokit)
async () => await callback(_baseOctokit),
);
}

Expand Down Expand Up @@ -83,7 +83,7 @@ async function resolveAccessToken(id: RepositoryIdentity): Promise<string> {
});

return data.id;
}
},
);

const installationAuth = await createAppAuth({
Expand All @@ -99,7 +99,7 @@ async function resolveAccessToken(id: RepositoryIdentity): Promise<string> {
} catch (e) {
throw new GitHubAuthError(
"Failed to resolve access token",
e instanceof Error ? e : undefined
e instanceof Error ? e : undefined,
);
}
}
Expand All @@ -114,7 +114,7 @@ async function resolveAccessToken(id: RepositoryIdentity): Promise<string> {
* @param id Identification of the repository.
*/
export async function getRepositoryDefaultBranch(
id: RepositoryIdentity
id: RepositoryIdentity,
): Promise<string> {
try {
const { data } = await _baseOctokit.rest.repos.get({
Expand All @@ -126,7 +126,7 @@ export async function getRepositoryDefaultBranch(
} catch (e) {
throw new GitHubAuthError(
"Failed to resolve default branch",
e instanceof Error ? e : undefined
e instanceof Error ? e : undefined,
);
}
}
Expand All @@ -150,7 +150,7 @@ export async function sendWorkflowDispatch(opts: WorkflowDispatchOpts) {
} catch (e) {
throw new GitHubDispatchError(
"Failed to dispatch workflow",
e instanceof Error ? e : undefined
e instanceof Error ? e : undefined,
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/dispatch/id-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const getJwtVerifier = async (): Promise<JWTVerifyGetKey> => {
} catch (e) {
throw new IdTokenError(
"Failed to discover issuer",
e instanceof Error ? e : undefined
e instanceof Error ? e : undefined,
);
}

Expand All @@ -75,7 +75,7 @@ export const getJwtVerifier = async (): Promise<JWTVerifyGetKey> => {
*/
export const decodeIdToken = async (
jwtVerifier: JWTVerifyGetKey,
token: string
token: string,
): Promise<IdTokenClaims> => {
const config = getConfig();

Expand All @@ -89,7 +89,7 @@ export const decodeIdToken = async (
} catch (e) {
throw new IdTokenError(
"Failed to decode/verify IdToken",
e instanceof Error ? e : undefined
e instanceof Error ? e : undefined,
);
}
};
6 changes: 3 additions & 3 deletions src/dispatch/policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function getPolicyPath(): string {
} else {
policyPath = path.join(
process.env.POLICY_DIR as string,
builtInPolicyMapping[config.POLICY_TYPE]
builtInPolicyMapping[config.POLICY_TYPE],
);
}

Expand Down Expand Up @@ -60,7 +60,7 @@ const crossPolicy = createCrossPolicy({
* @param value
*/
async function parsePolicyConfig(
value: string
value: string,
): Promise<Record<string, string>> {
const config: Record<string, string> = {};

Expand All @@ -78,7 +78,7 @@ export type PolicyInput = Pick<z.infer<typeof schema>, "caller" | "target">;
* Evaluates the given policy using the inputs provided.
*/
export async function evaluatePolicyForRequest(
input: Pick<PolicyInput, "target" | "caller">
input: Pick<PolicyInput, "target" | "caller">,
): Promise<boolean> {
const config = getConfig();

Expand Down
4 changes: 2 additions & 2 deletions src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const githubAuthSchema = z.discriminatedUnion("GH_AUTH_TYPE", [

const configSchema = z.intersection(
baseSchema,
z.intersection(policySchema, githubAuthSchema)
z.intersection(policySchema, githubAuthSchema),
);

/**
Expand Down Expand Up @@ -73,7 +73,7 @@ function parseConfig(): z.infer<typeof configSchema> {
Object.entries(process.env)
.filter(([key]) => key.startsWith(PREFIX))
.filter((it): it is [string, string] => it[1] !== undefined)
.map(([key, value]) => [key.slice(PREFIX.length), value])
.map(([key, value]) => [key.slice(PREFIX.length), value]),
);

// Apply the defaults to the environment variables.
Expand Down
6 changes: 3 additions & 3 deletions test/integration/dispatch-handler.spec-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("dispatch-handler", () => {

nock("https://api.github.com")
.post(
"/repos/octo-org/octo-repo/actions/workflows/example-workflow/dispatches"
"/repos/octo-org/octo-repo/actions/workflows/example-workflow/dispatches",
)
.reply(200);

Expand Down Expand Up @@ -77,7 +77,7 @@ describe("dispatch-handler", () => {

const dispatchScope = nock("https://api.github.com")
.post(
"/repos/octo-org/octo-repo/actions/workflows/example-workflow/dispatches"
"/repos/octo-org/octo-repo/actions/workflows/example-workflow/dispatches",
)
.reply((uri, body) => {
if ((body as any).ref !== _testDefaultBranch) {
Expand Down Expand Up @@ -117,7 +117,7 @@ describe("dispatch-handler", () => {

const dispatchScope = nock("https://api.github.com")
.post(
"/repos/octo-org/octo-repo/actions/workflows/example-workflow/dispatches"
"/repos/octo-org/octo-repo/actions/workflows/example-workflow/dispatches",
)
.reply(200);

Expand Down
2 changes: 1 addition & 1 deletion test/utils/setup-oauth-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface SetupOAuthServerHolder {
* @returns The OAuth server holder.
*/
export const setupOAuthServer = (
opts?: SetupOAuthServerOpts
opts?: SetupOAuthServerOpts,
): SetupOAuthServerHolder => {
let oAuthServer: OAuth2Server | undefined;

Expand Down
Loading
Loading