@o3co/create-auth-provider 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.ja.md +93 -47
  2. package/README.md +92 -46
  3. package/package.json +1 -1
  4. package/templates/standalone/.env.example +12 -0
  5. package/templates/standalone/Dockerfile +1 -1
  6. package/templates/standalone/README.ja.md +516 -154
  7. package/templates/standalone/README.md +218 -91
  8. package/templates/standalone/config/application.conf +26 -3
  9. package/templates/standalone/gitignore +3 -2
  10. package/templates/standalone/package.json +1 -1
  11. package/templates/standalone/src/__tests__/access-token-lifetime-alias.test.mts +49 -15
  12. package/templates/standalone/src/__tests__/all-modules-composition.fixture.mts +1103 -0
  13. package/templates/standalone/src/__tests__/all-modules-composition.multi.test.mts +241 -0
  14. package/templates/standalone/src/__tests__/all-modules-composition.test.mts +1100 -0
  15. package/templates/standalone/src/__tests__/documented-env-overrides.test.mts +19 -5
  16. package/templates/standalone/src/__tests__/federation-grants-composition.test.mts +64 -3
  17. package/templates/standalone/src/__tests__/federation-grants-survive-logout.test.mts +15 -0
  18. package/templates/standalone/src/__tests__/federation-token-refresh-outage.test.mts +133 -0
  19. package/templates/standalone/src/__tests__/google-federation-config-module.test.mts +28 -0
  20. package/templates/standalone/src/__tests__/google-session.fixture.mts +304 -0
  21. package/templates/standalone/src/__tests__/host-routes.test.mts +141 -0
  22. package/templates/standalone/src/__tests__/listen.test.mts +128 -0
  23. package/templates/standalone/src/__tests__/logger-projection.test.mts +77 -0
  24. package/templates/standalone/src/__tests__/metrics.test.mts +20 -5
  25. package/templates/standalone/src/__tests__/post-logout-redirect.test.mts +187 -0
  26. package/templates/standalone/src/__tests__/redis-connection-error-log.test.mts +139 -0
  27. package/templates/standalone/src/__tests__/replica-safety.test.mts +13 -3
  28. package/templates/standalone/src/__tests__/router-error-answers.test.mts +149 -0
  29. package/templates/standalone/src/__tests__/shutdown.test.mts +157 -20
  30. package/templates/standalone/src/__tests__/smoke.test.mts +39 -20
  31. package/templates/standalone/src/__tests__/store-credential.test.mts +276 -0
  32. package/templates/standalone/src/app.mts +21 -50
  33. package/templates/standalone/src/buildModules.mts +33 -16
  34. package/templates/standalone/src/listen.mts +66 -0
  35. package/templates/standalone/src/logger.mts +7 -4
  36. package/templates/standalone/src/modules.mts +42 -8
  37. package/templates/standalone/src/routes.mts +95 -0
  38. package/templates/standalone/src/shutdown.mts +20 -14
  39. package/templates/versions.json +15 -15
  40. package/templates/standalone/src/__tests__/terminal-error.test.mts +0 -96
  41. package/templates/standalone/src/terminalError.mts +0 -60
package/README.ja.md CHANGED
@@ -1,11 +1,35 @@
1
1
  # @o3co/create-auth-provider
2
2
 
3
- auth.provider 用の CLI スキャフォルダーです。standalone テンプレートから新しいプロジェクトを生成します。
3
+ 最終更新: 2026-09-24
4
+
5
+ auth.provider 用の CLI スキャフォルダーです。内包する standalone テンプレートから新しいサーバープロジェクトを生成します。
6
+
7
+ ## 責務と役割
8
+
9
+ **役割。** リポジトリ内のテンプレート
10
+ [`templates/standalone`](../templates/standalone) を、独立した新しいプロジェクトに
11
+ 変換する `npx` の入口です。運用者のマシン上で一度だけ実行されます。生成された
12
+ プロジェクトはこのパッケージを import せず、このパッケージも `packages/*` の
13
+ ライブラリを一切 import しません。
14
+
15
+ **担うもの。** プロジェクト名とディレクトリ名の検証、テンプレートのコピー、生成された
16
+ `package.json` の書き換え(名前、`workspace:*` → 公開バージョン)、プロジェクトの
17
+ `pnpm-workspace.yaml` の書き出し、そして一度きりの `pnpm-lock.yaml` の解決。
18
+
19
+ **担わないもの。** 生成されるプロジェクトの中身 — ソース、設定、Dockerfile、
20
+ テスト — はテンプレートのものです(このパッケージではなく `templates/standalone` を
21
+ 編集してください)。実行時の振る舞いは `@o3co/auth-provider-core` と、テンプレートが
22
+ 依存するライブラリのものです。
23
+
24
+ **別パッケージである理由。** `bin` 付きで単独公開されるため、provider をインストール
25
+ せずに `npx` で実行できます。公開 tarball にはモノレポが含まれないので、このパッケージは
26
+ テンプレートのコピーと、固定するライブラリのバージョンを自前で持ちます
27
+ ([テンプレートの同梱方法](#テンプレートの同梱方法))。
4
28
 
5
29
  ## 使い方
6
30
 
7
31
  ```bash
8
- npx @o3co/create-auth-provider <project-name> [--dir <dir-name>]
32
+ npx @o3co/create-auth-provider <project-name> [--dir <dir-name>] [--no-lockfile]
9
33
  ```
10
34
 
11
35
  `<project-name>` はスコープ付き npm 名 (`@scope/pkg`) とスコープなしの名前 (`pkg`) のどちらでも指定できます。
@@ -15,8 +39,7 @@ npx @o3co/create-auth-provider <project-name> [--dir <dir-name>]
15
39
  ```bash
16
40
  npx @o3co/create-auth-provider my-auth-server
17
41
  cd my-auth-server
18
- npm install
19
- npm run debug
42
+ pnpm install
20
43
  ```
21
44
 
22
45
  スコープ付きの例(ディレクトリ名はパッケージ部分 `auth.provider` がデフォルト):
@@ -24,8 +47,7 @@ npm run debug
24
47
  ```bash
25
48
  npx @o3co/create-auth-provider @my-org/auth.provider
26
49
  cd auth.provider
27
- npm install
28
- npm run debug
50
+ pnpm install
29
51
  ```
30
52
 
31
53
  `--dir` でディレクトリ名を明示指定:
@@ -35,18 +57,61 @@ npx @o3co/create-auth-provider @my-org/auth.provider --dir provider
35
57
  cd provider
36
58
  ```
37
59
 
60
+ `--no-lockfile` を付けると lockfile の生成(下記の手順 7)を省略します。
61
+
62
+ 生成されるプロジェクトは pnpm のプロジェクトです。`Dockerfile` は
63
+ `pnpm install --frozen-lockfile` でインストールし、ビルドの許可リストは
64
+ `pnpm-workspace.yaml` にあります。
65
+
66
+ CLI は最後のメッセージで次に `pnpm run debug` を実行するよう案内します。
67
+ スキャフォールドのデフォルトのままでは、これは起動しません: `.env` ファイルは
68
+ 読まず(読むのは compose ファイルだけ)、シェルの環境変数から issuer
69
+ (`OAUTH_JWT_ISSUER`)、署名鍵のペア、セッションシークレット、ユーザーサービスの
70
+ 2 つの URL(`CLIENT_USER_AUTHENTICATE_URL`、`CLIENT_USER_AUTHENTICATE_BY_TOKEN_URL`)、
71
+ そして `localhost:6379` の Redis を必要とします。コマンドは、プロジェクトに含まれる
72
+ テンプレートの README の[使い方](../templates/standalone/README.ja.md#使い方)にあります。
73
+
38
74
  ## 動作内容
39
75
 
40
- 1. `<project-name>` を検証する(バリデーションルール参照)。
76
+ 1. `<project-name>` を検証する([バリデーションルール](#バリデーションルール) 参照)。
41
77
  2. 生成先ディレクトリ名を決定する: `--dir <value>` が指定されていればその値、そうでなければスコープ付き名のパッケージ部分、最終的には入力値そのもの。
42
- 3. 生成先ディレクトリを `<cwd>/<dir-name>` として解決する。
43
- 4. ディレクトリがすでに存在する場合はエラーを出力して終了する。
44
- 5. `templates/standalone/` を生成先ディレクトリにコピーする(`node_modules/` と `dist/` は除外)。
45
- 6. 生成されたディレクトリの `package.json` を書き換える:
46
- - `name` を `<project-name>` をそのまま設定する(スコープを保持)。
47
- - `private` フィールドを削除する。
48
- - すべての `workspace:*` バージョン参照を `versions.json` の公開 semver バージョンに置き換える。
49
- 7. 次のステップを出力する。
78
+ 3. 生成先ディレクトリを `<cwd>/<dir-name>` として解決し、すでに存在する場合はエラーで終了する。
79
+ 4. 内包するテンプレートを生成先ディレクトリにコピーし(`node_modules/` と `dist/` は除外)、`.gitignore` を復元する(npm は公開パッケージから `.gitignore` という名前のファイルを落とすため、tarball には `gitignore` として入っている)。
80
+ 5. 生成されたディレクトリの `package.json` を書き換える:
81
+ - `name` を `<project-name>` そのままに設定する(スコープを保持)。
82
+ - `"private": true` は意図的に残す: スキャフォールドされた ID プロバイダーが誤って公開できてはならないため。本当に公開するつもりなら自分でこのフィールドを削除する。
83
+ - `dependencies`・`devDependencies`・`peerDependencies` の各 `workspace:*` を、内包する `versions.json` の `^<version>` に置き換える。
84
+ 6. `bcrypt` 用の `onlyBuiltDependencies` 許可リストを書いた `pnpm-workspace.yaml` を生成する — pnpm 10.29 以降はこの許可リストを、単一パッケージのプロジェクトであってもこのファイルからしか読まない。
85
+ 7. `--no-lockfile` が指定されていなければ、依存関係を `pnpm-lock.yaml` に解決する(`pnpm install --lockfile-only --ignore-workspace`。`pnpm` が `PATH` にない場合は `corepack pnpm` 経由)。到達可能なレジストリが必要で、失敗しても警告を出すだけでスキャフォールドは完了する。
86
+ 8. 次のステップを出力する。
87
+
88
+ ### 生成される `pnpm-lock.yaml`
89
+
90
+ テンプレートの `Dockerfile` は `pnpm install --frozen-lockfile` でインストール
91
+ するため、生成されたプロジェクトは lockfile がなければそもそもビルドできません。
92
+ lockfile をテンプレートに同梱することはできません: 手順 5 がすべての
93
+ `workspace:*` を公開バージョンに置き換えるまで、lockfile が固定すべき依存関係の
94
+ 集合が存在しないからです。そこで、書き換え後の `package.json` に対してここで
95
+ 一度だけ解決します。**コミットしてください** — `docker build` を再現可能にするのは
96
+ この lockfile です。手順 7 が失敗した、または省略した場合は、プロジェクト内で一度
97
+ `pnpm install` を実行して結果をコミットしてください。
98
+
99
+ ## テンプレートの同梱方法
100
+
101
+ パッケージの `prebuild` と `prepack` スクリプトが
102
+ [`scripts/copy-templates.mjs`](scripts/copy-templates.mjs) を実行し、
103
+ `templates/standalone` を `create-app/templates/standalone` にコピーし(git 管理外。
104
+ `node_modules/` と `dist/` は除外)、`create-app/templates/versions.json` —
105
+ 公開される `@o3co/auth-provider-*` 全パッケージの現在のバージョン — を書き出します。
106
+ tarball には両方が入り(`files: ["dist", "templates"]`)、`scaffold()` はそこから
107
+ 読みます。したがってスキャフォールドされるのは、このパッケージをビルドした時点の
108
+ テンプレートで、同じビルド時点のライブラリバージョンに固定されます。
109
+
110
+ CI は [`scripts/check-versions-json.mjs`](scripts/check-versions-json.mjs) を
111
+ 実行します。`packages/` 配下の公開パッケージが `copy-templates.mjs` のバージョン
112
+ 一覧に欠けているとき、または一覧がもう存在しないパッケージを挙げているときに
113
+ 失敗します — そうでなければスキャフォールドがそのパッケージの `workspace:*` の
114
+ バージョンを解決できずに失敗するためです。
50
115
 
51
116
  ## バリデーションルール
52
117
 
@@ -61,45 +126,26 @@ cd provider
61
126
 
62
127
  ## 既知の制約
63
128
 
64
- 内包されているテンプレートの `README.md` / `README.ja.md` の見出しは `@o3co/auth-provider-standalone` のままです。スコープ付きでプロジェクトを生成した場合、この見出しは生成された `package.json` の `name` と一致しません。必要に応じて手動で修正してください。
129
+ - 内包されているテンプレートの `README.md` / `README.ja.md` の見出しは上流の `@o3co/auth-provider-standalone` のままです。スコープ付きでプロジェクトを生成した場合、この見出しは `package.json` の名前と一致しません。必要に応じて手動で修正してください。
130
+ - テンプレートの README は、このリポジトリ内を相対パス(`../../docs/…`、`../../packages/…`)でリンクしています。これはモノレポ内では解決しますが、横に `docs/` も `packages/` もないスキャフォールド先のプロジェクトでは解決しません。GitHub 上で参照してください。
65
131
 
66
132
  ## 生成される構造
67
133
 
68
- ```
69
- <プロジェクト名>/
70
- ├── config/
71
- │ ├── application.conf # HOCON 設定(環境変数で上書き可能)
72
- │ ├── clients.yaml # OAuth クライアントレジストリ
73
- │ └── clients.yaml.example
74
- ├── src/
75
- │ └── app.mts # Composition root
76
- ├── tests/
77
- ├── .dockerignore
78
- ├── .env.example
79
- ├── Dockerfile
80
- ├── docker-compose.yml
81
- ├── docker-compose.test.yml
82
- ├── Makefile
83
- ├── package.json
84
- ├── tsconfig.json
85
- └── vitest.config.mts
86
- ```
87
-
88
- 生成後、`.env.example` をコピーして `.env` を作成し、必須の環境変数を設定してください。
134
+ 生成されるプロジェクトは [`templates/standalone`](../templates/standalone) の
135
+ 完全なコピー(`node_modules/` と `dist/` を除く)に、`pnpm-workspace.yaml`(手順 6)と、
136
+ `--no-lockfile` を指定せず lockfile の手順が失敗しなかった場合は `pnpm-lock.yaml`(手順 7)を加えたものです。どの
137
+ ファイルがモジュール構成で、どれがホストプロセスで、スキャフォールドが何を
138
+ 持つかは、テンプレートの README に記述されています。
89
139
 
90
140
  ## プログラマティック API
91
141
 
92
- ```typescript
93
- import { scaffold, main } from "@o3co/create-auth-provider";
94
-
95
- // 絶対パスにプロジェクトを生成する
96
- scaffold(targetDir: string, projectName: string): void;
97
-
98
- // CLI エントリーポイント — process.argv を読み取り、エラー時は終了する
99
- main(): void;
100
- ```
142
+ モジュールは CLI を構成する関数を export しています。シグネチャは
143
+ [`src/index.mts`](src/index.mts) にあります。
101
144
 
102
- テンプレートディレクトリが見つからない場合、または `workspace:*` 依存関係が `versions.json` で解決できない場合、`scaffold` はエラーをスローします。
145
+ - `scaffold(targetDir, projectName)` — 手順 4〜6。内包するテンプレートがない場合、または `workspace:*` 依存が `versions.json` に見つからない場合は例外を投げる。
146
+ - `generateLockfile(targetDir)` — 手順 7。例外を投げず、`{ ok: true, command }` か `{ ok: false, reason }` を返す。
147
+ - `main()` — CLI 本体。`process.argv` を読み、不正な引数や既存のディレクトリに対しては非ゼロで終了する。
148
+ - `isValidProjectName(name)` / `isValidDirName(name)` — [バリデーションルール](#バリデーションルール)。
103
149
 
104
150
  ## 関連
105
151
 
package/README.md CHANGED
@@ -1,11 +1,35 @@
1
1
  # @o3co/create-auth-provider
2
2
 
3
- CLI scaffolder for auth.provider. Generates a new project from the standalone template.
3
+ Last updated: 2026-09-24
4
+
5
+ CLI scaffolder for auth.provider. Generates a new standalone server project from the built-in template.
6
+
7
+ ## Responsibility
8
+
9
+ **Role.** The `npx` entry point that turns the in-repo template
10
+ [`templates/standalone`](../templates/standalone) into a new, independent
11
+ project. It runs once, on the operator's machine; nothing in the generated
12
+ project imports it, and it imports none of the `packages/*` libraries.
13
+
14
+ **Owns.** Project-name and directory validation, copying the template,
15
+ rewriting the generated `package.json` (name, `workspace:*` → published
16
+ versions), writing the project's `pnpm-workspace.yaml`, and the one-time
17
+ `pnpm-lock.yaml` resolution.
18
+
19
+ **Does not own.** The content of the generated project — source, config,
20
+ Dockerfile, tests — which is the template's (edit `templates/standalone`, not
21
+ this package). Runtime behaviour belongs to `@o3co/auth-provider-core` and the
22
+ libraries the template depends on.
23
+
24
+ **Why a separate package.** It is published on its own with a `bin`, so it can
25
+ be run with `npx` without installing the provider. The monorepo is not in the
26
+ published tarball, so the package carries its own copy of the template and of
27
+ the library versions it pins ([How the template is bundled](#how-the-template-is-bundled)).
4
28
 
5
29
  ## Usage
6
30
 
7
31
  ```bash
8
- npx @o3co/create-auth-provider <project-name> [--dir <dir-name>]
32
+ npx @o3co/create-auth-provider <project-name> [--dir <dir-name>] [--no-lockfile]
9
33
  ```
10
34
 
11
35
  `<project-name>` may be either a scoped npm name (`@scope/pkg`) or an unscoped name (`pkg`).
@@ -15,8 +39,7 @@ Unscoped example:
15
39
  ```bash
16
40
  npx @o3co/create-auth-provider my-auth-server
17
41
  cd my-auth-server
18
- npm install
19
- npm run debug
42
+ pnpm install
20
43
  ```
21
44
 
22
45
  Scoped example (directory defaults to the package portion `auth.provider`):
@@ -24,8 +47,7 @@ Scoped example (directory defaults to the package portion `auth.provider`):
24
47
  ```bash
25
48
  npx @o3co/create-auth-provider @my-org/auth.provider
26
49
  cd auth.provider
27
- npm install
28
- npm run debug
50
+ pnpm install
29
51
  ```
30
52
 
31
53
  Override the directory name with `--dir`:
@@ -35,18 +57,61 @@ npx @o3co/create-auth-provider @my-org/auth.provider --dir provider
35
57
  cd provider
36
58
  ```
37
59
 
60
+ `--no-lockfile` skips the lockfile step (step 7 below).
61
+
62
+ The generated project is a pnpm project: its `Dockerfile` installs with
63
+ `pnpm install --frozen-lockfile`, and its build allowlist lives in
64
+ `pnpm-workspace.yaml`.
65
+
66
+ The CLI's closing message suggests `pnpm run debug` next. On the scaffold's
67
+ defaults alone that does not boot: it reads no `.env` file (only the compose
68
+ files do), and needs from the shell's environment an issuer
69
+ (`OAUTH_JWT_ISSUER`), a signing key pair, a session secret, the two URLs of
70
+ your user service (`CLIENT_USER_AUTHENTICATE_URL`,
71
+ `CLIENT_USER_AUTHENTICATE_BY_TOKEN_URL`) and a Redis on `localhost:6379`. The
72
+ template's README, which the project carries, gives the commands under
73
+ [Usage](../templates/standalone/README.md#usage).
74
+
38
75
  ## What It Does
39
76
 
40
- 1. Validates `<project-name>` (see Validation Rules).
77
+ 1. Validates `<project-name>` (see [Validation Rules](#validation-rules)).
41
78
  2. Derives the target directory name: `--dir <value>` if given, else the unscoped part of a scoped name, else the name itself.
42
- 3. Resolves the target directory as `<cwd>/<dir-name>`.
43
- 4. Errors if the directory already exists.
44
- 5. Copies `templates/standalone/` to the target directory, excluding `node_modules/` and `dist/`.
45
- 6. Rewrites `package.json` in the generated directory:
79
+ 3. Resolves the target directory as `<cwd>/<dir-name>`, and errors if it already exists.
80
+ 4. Copies the bundled template to the target directory, excluding `node_modules/` and `dist/`, and restores its `.gitignore` (the tarball carries it as `gitignore`, because npm drops a file named `.gitignore` from a published package).
81
+ 5. Rewrites `package.json` in the generated directory:
46
82
  - Sets `name` to `<project-name>` verbatim (scope-preserving).
47
- - Removes the `private` field.
48
- - Replaces all `workspace:*` version references with published semver versions from `versions.json`.
49
- 7. Prints next-step instructions.
83
+ - Keeps `"private": true` on purpose: a scaffolded identity provider should not be publishable by accident. Remove the field yourself if you really intend to publish.
84
+ - Replaces each `workspace:*` version in `dependencies`, `devDependencies` and `peerDependencies` with `^<version>` from the bundled `versions.json`.
85
+ 6. Writes `pnpm-workspace.yaml` with the `onlyBuiltDependencies` allowlist for `bcrypt` — pnpm 10.29 and later read that allowlist only from this file, in a single-package project too.
86
+ 7. Resolves the dependency set into `pnpm-lock.yaml` (`pnpm install --lockfile-only --ignore-workspace`, through `corepack pnpm` when `pnpm` is not on `PATH`), unless `--no-lockfile` was passed. This needs a reachable registry; a failure prints a warning and the scaffold still completes.
87
+ 8. Prints next-step instructions.
88
+
89
+ ### The generated `pnpm-lock.yaml`
90
+
91
+ The template's `Dockerfile` installs with `pnpm install --frozen-lockfile`, so
92
+ the generated project needs a lockfile to build at all. It cannot ship with the
93
+ template: until step 5 has replaced every `workspace:*` with a published
94
+ version, the dependency set the lockfile would have to pin does not exist. So
95
+ it is resolved once, here, against the rewritten `package.json`. **Commit it** —
96
+ it is what makes `docker build` reproducible. If step 7 failed or was skipped,
97
+ run `pnpm install` in the project once and commit the result.
98
+
99
+ ## How the template is bundled
100
+
101
+ The package's `prebuild` and `prepack` scripts run
102
+ [`scripts/copy-templates.mjs`](scripts/copy-templates.mjs), which copies
103
+ `templates/standalone` into `create-app/templates/standalone` (git-ignored;
104
+ `node_modules/` and `dist/` excluded) and writes `create-app/templates/versions.json`,
105
+ the current version of every published `@o3co/auth-provider-*` package. The
106
+ tarball ships both (`files: ["dist", "templates"]`), and `scaffold()` reads
107
+ them from there. A scaffold is therefore the template as it was when this
108
+ package was built, pinned to the library versions of that same build.
109
+
110
+ CI runs [`scripts/check-versions-json.mjs`](scripts/check-versions-json.mjs),
111
+ which fails when a published package under `packages/` is missing from
112
+ `copy-templates.mjs`'s version list, or the list names one that no longer
113
+ exists — a scaffold would otherwise fail to resolve that package's
114
+ `workspace:*` version.
50
115
 
51
116
  ## Validation Rules
52
117
 
@@ -61,45 +126,26 @@ Both forms must be non-empty, not `.` or `..`, and ≤ 214 characters.
61
126
 
62
127
  ## Known Limitations
63
128
 
64
- The bundled template's `README.md` / `README.ja.md` still carry the upstream title `@o3co/auth-provider-standalone`. When generating a scoped project, that title will not match your `package.json` name; edit it manually if it matters for your use case.
129
+ - The bundled template's `README.md` / `README.ja.md` carry the upstream title `@o3co/auth-provider-standalone`. When generating a scoped project, that title will not match your `package.json` name; edit it manually if it matters for your use case.
130
+ - The template's README links into this repository with relative paths (`../../docs/…`, `../../packages/…`). Those resolve in the monorepo and not in a scaffolded project, where there is no `docs/` or `packages/` beside it; read them on GitHub instead.
65
131
 
66
132
  ## Generated Structure
67
133
 
68
- ```
69
- <project-name>/
70
- ├── config/
71
- │ ├── application.conf # HOCON config (overridable via env vars)
72
- │ ├── clients.yaml # OAuth client registry
73
- │ └── clients.yaml.example
74
- ├── src/
75
- │ └── app.mts # Composition root
76
- ├── tests/
77
- ├── .dockerignore
78
- ├── .env.example
79
- ├── Dockerfile
80
- ├── docker-compose.yml
81
- ├── docker-compose.test.yml
82
- ├── Makefile
83
- ├── package.json
84
- ├── tsconfig.json
85
- └── vitest.config.mts
86
- ```
87
-
88
- After generation, fill in the required environment variables in `.env` (copy from `.env.example`).
134
+ The generated project is a complete copy of
135
+ [`templates/standalone`](../templates/standalone) (without `node_modules/` and
136
+ `dist/`) plus `pnpm-workspace.yaml` (step 6) and, unless `--no-lockfile` was
137
+ given or the lockfile step failed, `pnpm-lock.yaml` (step 7). The template's README describes its layout — which file is
138
+ the composition, which is the host process, and what the scaffold owns.
89
139
 
90
140
  ## Programmatic API
91
141
 
92
- ```typescript
93
- import { scaffold, main } from "@o3co/create-auth-provider";
94
-
95
- // Generate a project at an absolute path
96
- scaffold(targetDir: string, projectName: string): void;
97
-
98
- // CLI entry point — reads process.argv and exits on error
99
- main(): void;
100
- ```
142
+ The module exports the functions the CLI is built from; their signatures are
143
+ in [`src/index.mts`](src/index.mts).
101
144
 
102
- `scaffold` throws if the template directory is missing or if a `workspace:*` dependency cannot be resolved in `versions.json`.
145
+ - `scaffold(targetDir, projectName)` — steps 4–6. Throws if the bundled template is missing or a `workspace:*` dependency has no entry in `versions.json`.
146
+ - `generateLockfile(targetDir)` — step 7. Returns `{ ok: true, command }` or `{ ok: false, reason }` rather than throwing.
147
+ - `main()` — the CLI: reads `process.argv`, and exits non-zero on an invalid argument or an existing directory.
148
+ - `isValidProjectName(name)` / `isValidDirName(name)` — the [Validation Rules](#validation-rules).
103
149
 
104
150
  ## See Also
105
151
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3co/create-auth-provider",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Scaffold a new o3co/auth.provider project from the standalone template",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -37,8 +37,20 @@ SESSION_SECRET=
37
37
  # be absolute https URLs. http:// is accepted only for a loopback host
38
38
  # (localhost, 127.0.0.0/8, [::1]) — a private-range address or a compose service
39
39
  # name such as http://user-service:8080 still needs https. Boot fails otherwise.
40
+ # Each must be the endpoint that answers: no request follows a 3xx, so a URL that
41
+ # redirects fails every call.
40
42
  CLIENT_USER_AUTHENTICATE_URL=
41
43
  CLIENT_USER_AUTHENTICATE_BY_TOKEN_URL=
44
+ # The credential this server presents to the Store: every Store request carries
45
+ # `Authorization: Bearer <token>`. Without one, anyone who can reach the Store
46
+ # can resolve an identity to its user, so your Store should refuse any request
47
+ # without it, with 401 and `WWW-Authenticate: Bearer error="invalid_token"`
48
+ # (which this server then reports as an outage naming the refused credential).
49
+ # The one token goes to every Store URL above: they must be one trust domain.
50
+ # At least 32 bytes, measured like SESSION_SECRET; boot fails on a weak or
51
+ # malformed value. Left commented out because a blank value is refused too:
52
+ # openssl rand -hex 32
53
+ # CLIENT_USER_BEARER_TOKEN=
42
54
 
43
55
  # --- Reverse proxy (required in production) -----------------------------------
44
56
  # Express `trust proxy`. Set this to the address or CIDR range of whatever
@@ -92,7 +92,7 @@ EXPOSE ${HTTP_PORT}
92
92
  # per-service, which keeps the restart-driving signal out of it.
93
93
  #
94
94
  # Use the shell form so ${HTTP_PORT} expands at probe time. The HOCON
95
- # config reads `${?HTTP_PORT}` for `http.port`, so app.listen() and the
95
+ # config reads `${?HTTP_PORT}` for `http.port`, so the listener and the
96
96
  # probe stay in sync regardless of the operator's port choice.
97
97
  HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
98
98
  CMD wget -q -O /dev/null "http://localhost:${HTTP_PORT}/_healthcheck" || exit 1