create-ampless 1.0.0-beta.155 → 1.0.0-beta.158

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.
@@ -9,21 +9,22 @@
9
9
  //
10
10
  // ── Passkeys (WebAuthn) ──────────────────────────────────────────────
11
11
  //
12
- // Passkeys are ENABLED BY DEFAULT (the empty object below). With the
13
- // default, Amplify auto-resolves the WebAuthn Relying Party ID from the
14
- // deployment domain, which works on Amplify Hosting domains and on a
15
- // `localhost` sandbox.
12
+ // Passkeys are ENABLED BY DEFAULT. `amplify/auth/resource.ts` auto-
13
+ // derives the WebAuthn Relying Party ID from `cms.config.ts` `site.url`
14
+ // in Amplify Hosting pipeline builds, and uses `localhost` (auto-
15
+ // resolved by Amplify) in `ampx sandbox`. This file is usually unneeded
16
+ // for passkeys.
16
17
  //
17
- // If you serve the admin from a CUSTOM DOMAIN behind a CDN, the
18
- // auto-resolved RP ID won't match the URL the browser sees and passkey
19
- // sign-in fails with a `SecurityError`. Pin the RP ID to the bare
20
- // domain (no protocol, no path) the operators visit:
18
+ // Set `webAuthn: { relyingPartyId: 'admin.example.com' }` ONLY when the
19
+ // admin is served from a different subdomain than `site.url` (e.g. site
20
+ // is at `example.com` but the admin CDN origin is `admin.example.com`).
21
21
  //
22
22
  // export const authCustomizations: Pick<AmplessAuthConfigOpts, 'webAuthn'> = {
23
23
  // webAuthn: { relyingPartyId: 'admin.example.com' },
24
24
  // }
25
25
  //
26
- // To turn passkeys off entirely (password-only sign-in):
26
+ // To turn passkeys off entirely (password-only sign-in AND removes the
27
+ // passkey UI from the admin completely):
27
28
  //
28
29
  // export const authCustomizations: Pick<AmplessAuthConfigOpts, 'webAuthn'> = {
29
30
  // webAuthn: false,
@@ -33,6 +34,9 @@
33
34
  // invalidates every existing credential — they'll have to register
34
35
  // again from the account page. The password flow always stays available
35
36
  // as the fallback. See `docs/passkeys.md`.
37
+ //
38
+ // ⚠️ cms.config.ts must not import theme CSS or browser-only modules —
39
+ // it is loaded at CDK synth time when deriving the RP ID.
36
40
 
37
41
  import type { AmplessAuthConfigOpts } from '@ampless/backend'
38
42
 
@@ -1,5 +1,5 @@
1
1
  import { defineAuth } from '@aws-amplify/backend'
2
- import { amplessAuthConfig } from '@ampless/backend'
2
+ import { amplessAuthConfig, resolveWebAuthn } from '@ampless/backend'
3
3
  import { postConfirmation } from './post-confirmation/resource.js'
4
4
  import { authCustomizations } from './resource.custom.js'
5
5
 
@@ -12,9 +12,23 @@ import { authCustomizations } from './resource.custom.js'
12
12
  // import-path verifier requires it to live at amplify/auth/resource.ts.
13
13
  // `amplessAuthConfig` just returns the props object.
14
14
  //
15
- // Per-site auth knobs (e.g. passkey Relying Party ID on a custom
16
- // domain) live in `resource.custom.ts` that file is yours to edit and
17
- // is never overwritten by `update-ampless`.
15
+ // The WebAuthn Relying Party ID is auto-derived from `cms.config.ts`
16
+ // `site.url` in Amplify Hosting pipeline builds. In sandbox (`ampx
17
+ // sandbox`) the RP ID stays `localhost` (Amplify auto-resolves it).
18
+ // Override with `webAuthn: { relyingPartyId }` in resource.custom.ts
19
+ // only when the admin is served from a different subdomain than site.url.
20
+ import cmsConfig from '../../cms.config'
21
+
22
+ const { webAuthn: webAuthnOverride, ...otherAuthCustomizations } = authCustomizations
23
+
18
24
  export const auth = defineAuth(
19
- amplessAuthConfig({ postConfirmation, ...authCustomizations })
25
+ amplessAuthConfig({
26
+ postConfirmation,
27
+ ...otherAuthCustomizations,
28
+ webAuthn: resolveWebAuthn({
29
+ override: webAuthnOverride,
30
+ siteUrl: cmsConfig.site.url,
31
+ isPipeline: Boolean(process.env.AWS_BRANCH),
32
+ }),
33
+ })
20
34
  )
@@ -36,8 +36,8 @@
36
36
  "@ampless/plugin-schema-jsonld": "^0.1.1-beta.31",
37
37
  "@ampless/plugin-seo": "^0.2.0-beta.52",
38
38
  "@ampless/plugin-webhook": "^0.2.0-beta.53",
39
- "@ampless/admin": "^1.0.0-beta.91",
40
- "@ampless/backend": "^1.0.0-beta.77",
39
+ "@ampless/admin": "^1.0.0-beta.93",
40
+ "@ampless/backend": "^1.0.0-beta.78",
41
41
  "@ampless/runtime": "^1.0.0-beta.61",
42
42
  "@digital-go-jp/tailwind-theme-plugin": "^0.3.4",
43
43
  "ampless": "^1.0.0-beta.52",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ampless",
3
- "version": "1.0.0-beta.155",
3
+ "version": "1.0.0-beta.158",
4
4
  "description": "Create a new ampless project",
5
5
  "license": "MIT",
6
6
  "type": "module",