@ampless/backend 1.0.0-beta.75 → 1.0.0-beta.77
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.
- package/README.ja.md +16 -0
- package/README.md +16 -0
- package/dist/index.d.ts +25 -1
- package/dist/index.js +12 -11
- package/package.json +2 -2
package/README.ja.md
CHANGED
|
@@ -50,6 +50,22 @@ export const auth = defineAuth(amplessAuthConfig({ postConfirmation }))
|
|
|
50
50
|
|
|
51
51
|
> `defineAuth` は `amplify/auth/resource.ts` 自体に記述する必要があります。Amplify Gen 2 のインポートパス検証機能が `defineAuth` / `defineData` / `defineStorage` の呼び出し元を検査し、他のファイル(`node_modules/@ampless/backend/...` 配下のラッパーを含む)から呼び出された場合に `Amplify Auth must be defined in amplify/auth/resource.ts` というエラーを投げます。`amplessAuthConfig` は props オブジェクトを返すため、ampless のデフォルト設定を失わずにこのファイルで `defineAuth(...)` を呼び出せます。
|
|
52
52
|
|
|
53
|
+
#### パスキー(WebAuthn)
|
|
54
|
+
|
|
55
|
+
`amplessAuthConfig` はデフォルトでパスキーサインインを有効化します。オペレーターは管理画面のアカウントページからパスキーを登録すると、Face ID / Touch ID / セキュリティキーでサインインできます。パスワードフローは初回ブートストラップ兼フォールバックとして常に利用可能なまま残ります。
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
amplessAuthConfig({ postConfirmation }) // パスキー有効・RP ID は自動解決
|
|
59
|
+
amplessAuthConfig({ postConfirmation, webAuthn: true }) // デフォルトと同じ
|
|
60
|
+
amplessAuthConfig({ // カスタムドメイン用に Relying Party ID を固定
|
|
61
|
+
postConfirmation,
|
|
62
|
+
webAuthn: { relyingPartyId: 'admin.example.com' }, // プロトコル・パスなしの bare domain
|
|
63
|
+
})
|
|
64
|
+
amplessAuthConfig({ postConfirmation, webAuthn: false }) // パスワードのみのサインイン
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
デフォルト(`true`)では Amplify がデプロイドメインから WebAuthn の Relying Party ID を自動解決します。これは Amplify Hosting ドメインと `localhost` サンドボックスで動作します。管理画面を **CDN 配下のカスタムドメイン** で配信している場合、自動解決された RP ID がブラウザの見る URL と一致せず、サインインが `SecurityError` で失敗します。その場合はオペレーターがアクセスする bare domain を `relyingPartyId` に固定してください。パスキー登録後に RP ID を変更すると、登録済みの認証情報がすべて無効化されます。テンプレートではこのノブを `amplify/auth/resource.custom.ts`(`webAuthn?: AmplessWebAuthnOption | false`)経由で設定します。[docs/passkeys.ja.md](https://github.com/heavymoons/ampless/blob/main/docs/passkeys.ja.md) を参照してください。
|
|
68
|
+
|
|
53
69
|
### `amplify/data/resource.ts`
|
|
54
70
|
|
|
55
71
|
```ts
|
package/README.md
CHANGED
|
@@ -50,6 +50,22 @@ export const auth = defineAuth(amplessAuthConfig({ postConfirmation }))
|
|
|
50
50
|
|
|
51
51
|
> `defineAuth` must live in `amplify/auth/resource.ts` itself. Amplify Gen 2's import-path verifier inspects the call site of `defineAuth` / `defineData` / `defineStorage` and throws `Amplify Auth must be defined in amplify/auth/resource.ts` if it's invoked from any other file (including a `node_modules/@ampless/backend/...` wrapper). `amplessAuthConfig` returns the props object so you can call `defineAuth(...)` here without losing the ampless defaults.
|
|
52
52
|
|
|
53
|
+
#### Passkeys (WebAuthn)
|
|
54
|
+
|
|
55
|
+
`amplessAuthConfig` enables passkey sign-in by default. Operators can register a passkey from the admin account page and then sign in with Face ID / Touch ID / a security key. The password flow always stays available as the bootstrap + fallback.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
amplessAuthConfig({ postConfirmation }) // passkeys on, RP ID auto-resolved
|
|
59
|
+
amplessAuthConfig({ postConfirmation, webAuthn: true }) // same as the default
|
|
60
|
+
amplessAuthConfig({ // pin the Relying Party ID for a custom domain
|
|
61
|
+
postConfirmation,
|
|
62
|
+
webAuthn: { relyingPartyId: 'admin.example.com' }, // bare domain, no protocol or path
|
|
63
|
+
})
|
|
64
|
+
amplessAuthConfig({ postConfirmation, webAuthn: false }) // password-only sign-in
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The default (`true`) lets Amplify auto-resolve the WebAuthn Relying Party ID from the deployment domain, which works on Amplify Hosting domains and on a `localhost` sandbox. If the admin is served from a **custom domain behind a CDN**, the auto-resolved RP ID won't match the URL the browser sees and sign-in fails with a `SecurityError` — pin `relyingPartyId` to the bare domain operators visit. Changing the RP ID after passkeys exist invalidates every registered credential. The template wires this knob through `amplify/auth/resource.custom.ts` (`webAuthn?: AmplessWebAuthnOption | false`). See [docs/passkeys.md](https://github.com/heavymoons/ampless/blob/main/docs/passkeys.md).
|
|
68
|
+
|
|
53
69
|
### `amplify/data/resource.ts`
|
|
54
70
|
|
|
55
71
|
```ts
|
package/dist/index.d.ts
CHANGED
|
@@ -82,6 +82,23 @@ type AmplessBackend = any;
|
|
|
82
82
|
*/
|
|
83
83
|
declare function defineAmplessBackend(opts: DefineAmplessBackendOpts): AmplessBackend;
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* WebAuthn (passkey) login knob. `true` lets Amplify auto-resolve the
|
|
87
|
+
* Relying Party ID from the deployment domain (works on Amplify Hosting
|
|
88
|
+
* domains and `localhost` sandboxes); the object form pins the RP ID
|
|
89
|
+
* explicitly, which is required when the admin is served from a custom
|
|
90
|
+
* domain behind a CDN (the auto-resolved RP ID would be the Amplify
|
|
91
|
+
* Hosting domain and the browser raises `SecurityError`).
|
|
92
|
+
*
|
|
93
|
+
* Changing the RP ID after passkeys exist invalidates every registered
|
|
94
|
+
* credential — operators have to re-register. The password flow always
|
|
95
|
+
* stays available as the fallback.
|
|
96
|
+
*
|
|
97
|
+
* Derived from `defineAuth`'s `loginWith.webAuthn` so it tracks the
|
|
98
|
+
* underlying Amplify type. The non-`undefined` branch is the shape we
|
|
99
|
+
* accept (`true | { relyingPartyId; userVerification? }`).
|
|
100
|
+
*/
|
|
101
|
+
type AmplessWebAuthnOption = NonNullable<NonNullable<Parameters<typeof defineAuth>[0]['loginWith']>['webAuthn']>;
|
|
85
102
|
interface AmplessAuthConfigOpts {
|
|
86
103
|
/**
|
|
87
104
|
* The `post-confirmation` Cognito Lambda trigger that promotes the
|
|
@@ -95,6 +112,13 @@ interface AmplessAuthConfigOpts {
|
|
|
95
112
|
* through without losing functionality.
|
|
96
113
|
*/
|
|
97
114
|
postConfirmation?: unknown;
|
|
115
|
+
/**
|
|
116
|
+
* Passkey (WebAuthn) login. Defaults to `true` (auto RP ID) so new
|
|
117
|
+
* sites get passkeys out of the box. Pass the object form to pin the
|
|
118
|
+
* Relying Party ID on a custom domain, or `false` to opt out entirely
|
|
119
|
+
* (the `webAuthn` key is then omitted from the Cognito config).
|
|
120
|
+
*/
|
|
121
|
+
webAuthn?: AmplessWebAuthnOption | false;
|
|
98
122
|
}
|
|
99
123
|
/**
|
|
100
124
|
* Build the ampless Cognito configuration (User Pool + Identity Pool
|
|
@@ -303,4 +327,4 @@ declare function amplessSchemaAuthorization(allow: any, opts?: AmplessSchemaAuth
|
|
|
303
327
|
*/
|
|
304
328
|
declare const defaultAuthorizationModes: Parameters<typeof defineData>[0]['authorizationModes'];
|
|
305
329
|
|
|
306
|
-
export { type AmplessAuthConfigOpts, type AmplessBackend, type AmplessResolverPaths, type AmplessSchemaAuthorizationOpts, type AmplessSchemaModelsOpts, DEFAULT_RESOLVER_PATHS, type DefineAmplessBackendOpts, amplessAuthConfig, amplessSchemaAuthorization, amplessSchemaModels, amplessStorageConfig, defaultAuthorizationModes, defineAmplessBackend, extendAmplessSchema };
|
|
330
|
+
export { type AmplessAuthConfigOpts, type AmplessBackend, type AmplessResolverPaths, type AmplessSchemaAuthorizationOpts, type AmplessSchemaModelsOpts, type AmplessWebAuthnOption, DEFAULT_RESOLVER_PATHS, type DefineAmplessBackendOpts, amplessAuthConfig, amplessSchemaAuthorization, amplessSchemaModels, amplessStorageConfig, defaultAuthorizationModes, defineAmplessBackend, extendAmplessSchema };
|
package/dist/index.js
CHANGED
|
@@ -57,16 +57,14 @@ function defineAmplessBackend(opts) {
|
|
|
57
57
|
})
|
|
58
58
|
);
|
|
59
59
|
const cfnUserPool = backend.auth.resources.cfnResources.cfnUserPool;
|
|
60
|
-
cfnUserPool.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
};
|
|
60
|
+
cfnUserPool.addPropertyOverride("Policies.PasswordPolicy", {
|
|
61
|
+
MinimumLength: 8,
|
|
62
|
+
RequireLowercase: false,
|
|
63
|
+
RequireUppercase: false,
|
|
64
|
+
RequireNumbers: false,
|
|
65
|
+
RequireSymbols: false,
|
|
66
|
+
TemporaryPasswordValidityDays: 7
|
|
67
|
+
});
|
|
70
68
|
backend.postConfirmation.resources.lambda.addToRolePolicy(
|
|
71
69
|
new PolicyStatement({
|
|
72
70
|
effect: Effect.ALLOW,
|
|
@@ -269,7 +267,10 @@ function defineAmplessBackend(opts) {
|
|
|
269
267
|
function amplessAuthConfig(opts = {}) {
|
|
270
268
|
return {
|
|
271
269
|
loginWith: {
|
|
272
|
-
email: true
|
|
270
|
+
email: true,
|
|
271
|
+
// Passkeys are on by default; `webAuthn: false` drops the key so
|
|
272
|
+
// Cognito provisions a password-only sign-in policy.
|
|
273
|
+
...opts.webAuthn === false ? {} : { webAuthn: opts.webAuthn ?? true }
|
|
273
274
|
},
|
|
274
275
|
groups: ["ampless-admin", "ampless-editor", "ampless-reader"],
|
|
275
276
|
triggers: opts.postConfirmation ? (
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ampless/backend",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.77",
|
|
4
4
|
"description": "Amplify Gen 2 backend factories for ampless: auth, data, storage, event processors, API key renewer",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"ampless": "1.0.0-beta.52"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@aws-amplify/backend": "^1",
|
|
76
|
+
"@aws-amplify/backend": "^1.19.0",
|
|
77
77
|
"aws-cdk-lib": "^2"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|