Skip to content

Commit 6acd384

Browse files
authored
chore: #7 mixed
* test(mock): move files * chore(workflow): add codeql * docs: update docs * chore(deps): bump dependencies * chore: add yarn.lock and check at pr * chore(workflow): refactor workflows * test: fix intergration test to use consoleLogger * test: fix mock server to use random ports * test: fix possible updateSession failure * chore(workflow): add workflow to test redis adapter
1 parent 156e54f commit 6acd384

28 files changed

+2592
-174
lines changed

.github/workflows/checks-pr.yml .github/workflows/checks.yml

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
1-
name: Checks (PR)
1+
name: Checks (Push/PR - Conditional)
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches:
67
- main
78
paths:
89
- '**.ts'
910
- 'biome.json'
1011
- 'package.json'
11-
- 'tsconfig.json'
12-
- '!**/*.config.ts'
13-
- '!**/.*/**'
14-
- '!**/__*__/**'
15-
- '**/__test__/**'
12+
- 'bun.lockb'
13+
- 'yan.lock'
14+
- '!**/__examples__/**'
15+
- '!**/__scripts__/**'
1616
pull_request:
1717
branches:
1818
- main
19+
paths:
20+
- '**.ts'
21+
- 'biome.json'
22+
- 'package.json'
23+
- 'bun.lockb'
24+
- 'yan.lock'
25+
- '!**/__examples__/**'
26+
- '!**/__scripts__/**'
1927
types: [opened, reopened, synchronize]
2028

2129
defaults:
@@ -28,6 +36,7 @@ jobs:
2836
steps:
2937
- uses: actions/checkout@v4
3038
- uses: oven-sh/setup-bun@v1
39+
- run: diff <(bun bun.lockb) yarn.lock
3140
- run: bun install
3241
- run: bun check:apply
3342
- run: bun type-check

.github/workflows/codeql.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CodeQL (Cron)
2+
3+
on:
4+
workflow_dispatch:
5+
# release:
6+
# types: [prereleased]
7+
schedule:
8+
- cron: '19 5 * * 6'
9+
10+
defaults:
11+
run:
12+
shell: bash
13+
14+
jobs:
15+
analyze:
16+
name: Analyze (${{ matrix.language }})
17+
runs-on: 'ubuntu-latest'
18+
timeout-minutes: 30
19+
permissions:
20+
security-events: write
21+
packages: read
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
include:
26+
- language: javascript-typescript
27+
build-mode: none
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
32+
- name: Initialize CodeQL
33+
uses: github/codeql-action/init@v3
34+
with:
35+
languages: ${{ matrix.language }}
36+
build-mode: ${{ matrix.build-mode }}
37+
# queries: +security-and-quality
38+
39+
- name: Perform CodeQL Analysis
40+
uses: github/codeql-action/analyze@v3
41+
with:
42+
category: "/language:${{matrix.language}}"

.github/workflows/fallback.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Fallback jobs for pull-request
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
defaults:
9+
run:
10+
shell: bash
11+
12+
jobs:
13+
checks:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- run: echo "Fallback job of \"$GITHUB_JOB\""

.github/workflows/publish-dry-run.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish (Manual/Dry-run)
1+
name: Publish Dry-run
22

33
on:
44
workflow_dispatch:

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish
1+
name: Publish (Released)
22

33
on:
44
release:

.github/workflows/redis.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Test for Redis
2+
3+
on:
4+
workflow_dispatch:
5+
# push:
6+
# branches:
7+
# - main
8+
# paths:
9+
# - '**/Redis*.ts'
10+
# - '**/redis*.ts'
11+
12+
defaults:
13+
run:
14+
shell: bash
15+
16+
jobs:
17+
checks:
18+
runs-on: ubuntu-latest
19+
services:
20+
redis:
21+
image: redis:7-alpine
22+
ports:
23+
- 6379:6379
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: oven-sh/setup-bun@v1
27+
- run: bun install
28+
- run: bun test redis
29+
env:
30+
REDIS_HOST: localhost
31+
REDIS_PORT: 6379

.github/workflows/release-drafter-sync-manual.yml

-119
This file was deleted.

.github/workflows/release-drafter-sync-push.yml .github/workflows/release-drafter-version-sync.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Release Drafter with Version Sync (Push)
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches:
67
- main
@@ -10,7 +11,7 @@ defaults:
1011
shell: bash
1112

1213
jobs:
13-
update_release_draft_and_version_sync:
14+
update_release_draft:
1415
env:
1516
BLANCH: main
1617
CURRENT_VERSION: null

.github/workflows/release-drafter-pr.yml .github/workflows/release-drafter.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
name: Release Drafter (PR)
1+
name: Release Drafter (PR - Conditional)
22

33
on:
4+
workflow_dispatch:
45
pull_request:
56
branches:
67
- main

README.ja.md

+8
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ const rp = await OidcClient.create(options);
158158

159159
`onBeforeHandle` フックでCookieを元にセッションが有効かどうかを判断し、 [`resolve` フック](https://elysiajs.com/life-cycle/before-handle.html#resolve)から `sessionStatus``sessionClaims` を返す。
160160

161+
```typescript
162+
const rp = await OidcClient.create({ ... });
163+
const hookOptions: AuthHookOptions = { ... };
164+
const hook = rp.getAuthHook(hookOptions);
165+
```
166+
161167
- セッションが有効な場合
162168
- `sessionStatus` : セッションステータス
163169
- 参照: [OIDCClientSessionStatus](https://macropygia.github.io/elysia-openid-client/interfaces/types.OIDCClientSessionStatus.html)
@@ -310,6 +316,8 @@ const rp = await OidcClient.create({
310316
- 関数やメソッドの呼び出し時に名称を表示
311317
- `debug`:
312318
- デバッグ情報
319+
- `info`:
320+
- (TBA)
313321
- `warn`:
314322
- 予期しない呼び出し・不正な操作・攻撃などの可能性がある操作の情報
315323
- `error`:

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ const rp = await OidcClient.create(options);
158158

159159
Determine the validity of the session in `onBeforeHandle`, and return `sessionStatus` and `sessionClaims` from the [`resolve` hook](https://elysiajs.com/life-cycle/before-handle.html#resolve).
160160

161+
```typescript
162+
const rp = await OidcClient.create({ ... });
163+
const hookOptions: AuthHookOptions = { ... };
164+
const hook = rp.getAuthHook(hookOptions);
165+
```
166+
161167
- If the session is valid:
162168
- `sessionStatus`: Session status
163169
- Ref: [OIDCClientSessionStatus](https://macropygia.github.io/elysia-openid-client/interfaces/types.OIDCClientSessionStatus.html)
@@ -298,7 +304,7 @@ const rp = await OidcClient.create({
298304
- Optimized for [pino](https://getpino.io/).
299305
- Other loggers can be used if converted.
300306
- If omitted, use `consoleLogger("info")`.
301-
- If set `null`, disable logging.
307+
- If set to `null`, disable logging.
302308
- Ref: [OIDCClientLogger](https://macropygia.github.io/elysia-openid-client/interfaces/types.OIDCClientLogger.html)
303309

304310
### Log level policy
@@ -309,6 +315,8 @@ const rp = await OidcClient.create({
309315
- Functions and methods executed.
310316
- `debug`:
311317
- Debug info.
318+
- `info`:
319+
- (TBA)
312320
- `warn`:
313321
- Outputs for unexpected calls, tampering, and possible attacks.
314322
- `error`:

__mock__/getRandomPort.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export function getRandomPort() {
2+
const server = Bun.serve({
3+
fetch() {
4+
return new Response("Bun!");
5+
},
6+
port: 0,
7+
});
8+
const currentPort = server.port;
9+
server.stop();
10+
return currentPort;
11+
}

__mock__/issuerMetadata.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { opPort } from "./const";
2-
3-
export const mockIssuerMetadata = {
1+
export const mockIssuerMetadata = (opPort: number) => ({
42
issuer: `http://localhost:${opPort}`,
53
authorization_endpoint: `http://localhost:${opPort}/oauth2/authorize`,
64
token_endpoint: `http://localhost:${opPort}/oauth2/token`,
@@ -100,4 +98,4 @@ export const mockIssuerMetadata = {
10098
"ES384",
10199
"ES512",
102100
],
103-
};
101+
});

0 commit comments

Comments
 (0)