@ampless/backend 1.0.0-beta.76 → 1.0.0-beta.78
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 +2 -2
- package/README.md +2 -2
- package/dist/index.d.ts +20 -1
- package/dist/index.js +24 -11
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -64,7 +64,7 @@ amplessAuthConfig({ // カスタム
|
|
|
64
64
|
amplessAuthConfig({ postConfirmation, webAuthn: false }) // パスワードのみのサインイン
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
Amplify Hosting パイプラインビルドでは、テンプレートが `cms.config.ts` の `site.url` から `resolveWebAuthn({ override, siteUrl, isPipeline })` を通じて Relying Party ID を自動導出します。最も一般的なケースでは手動設定不要です。`ampx sandbox` では RP ID は `localhost` のまま(Amplify が自動解決)です。管理画面を `site.url` と**異なるサブドメイン**で配信している場合は、`amplify/auth/resource.custom.ts` でオペレーターがアクセスする bare domain を `relyingPartyId` に固定してください。パスキー登録後に RP ID を変更すると、登録済みの認証情報がすべて無効化されます。[docs/passkeys.ja.md](https://github.com/heavymoons/ampless/blob/main/docs/passkeys.ja.md) を参照してください。
|
|
68
68
|
|
|
69
69
|
### `amplify/data/resource.ts`
|
|
70
70
|
|
|
@@ -127,7 +127,7 @@ export { handler } from '@ampless/backend/functions/api-key-renewer'
|
|
|
127
127
|
|
|
128
128
|
## サブパス
|
|
129
129
|
|
|
130
|
-
- `@ampless/backend` — `defineAmplessBackend`、`amplessAuthConfig`、`amplessStorageConfig`、`amplessSchemaModels`、`extendAmplessSchema`、`defaultAuthorizationModes`
|
|
130
|
+
- `@ampless/backend` — `defineAmplessBackend`、`amplessAuthConfig`、`resolveWebAuthn`、`amplessStorageConfig`、`amplessSchemaModels`、`extendAmplessSchema`、`defaultAuthorizationModes`
|
|
131
131
|
- `@ampless/backend/auth/post-confirmation` — Lambda ハンドラー
|
|
132
132
|
- `@ampless/backend/events/dispatcher` — Lambda ハンドラー
|
|
133
133
|
- `@ampless/backend/events/processor-trusted` — `createProcessorTrustedHandler({ plugins, site })`
|
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ amplessAuthConfig({ // pin the Relyin
|
|
|
64
64
|
amplessAuthConfig({ postConfirmation, webAuthn: false }) // password-only sign-in
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
In Amplify Hosting pipeline builds the template auto-derives the Relying Party ID from `site.url` in `cms.config.ts` via `resolveWebAuthn({ override, siteUrl, isPipeline })` — no manual configuration needed for the common case. In `ampx sandbox` the RP ID stays `localhost` (auto-resolved by Amplify). If the admin is served from a **different subdomain** than `site.url`, pin `relyingPartyId` to the bare domain operators visit in `amplify/auth/resource.custom.ts`. Changing the RP ID after passkeys exist invalidates every registered credential. See [docs/passkeys.md](https://github.com/heavymoons/ampless/blob/main/docs/passkeys.md).
|
|
68
68
|
|
|
69
69
|
### `amplify/data/resource.ts`
|
|
70
70
|
|
|
@@ -127,7 +127,7 @@ export { handler } from '@ampless/backend/functions/api-key-renewer'
|
|
|
127
127
|
|
|
128
128
|
## Sub-paths
|
|
129
129
|
|
|
130
|
-
- `@ampless/backend` — `defineAmplessBackend`, `amplessAuthConfig`, `amplessStorageConfig`, `amplessSchemaModels`, `extendAmplessSchema`, `defaultAuthorizationModes`
|
|
130
|
+
- `@ampless/backend` — `defineAmplessBackend`, `amplessAuthConfig`, `resolveWebAuthn`, `amplessStorageConfig`, `amplessSchemaModels`, `extendAmplessSchema`, `defaultAuthorizationModes`
|
|
131
131
|
- `@ampless/backend/auth/post-confirmation` — Lambda handler
|
|
132
132
|
- `@ampless/backend/events/dispatcher` — Lambda handler
|
|
133
133
|
- `@ampless/backend/events/processor-trusted` — `createProcessorTrustedHandler({ plugins, site })`
|
package/dist/index.d.ts
CHANGED
|
@@ -120,6 +120,25 @@ interface AmplessAuthConfigOpts {
|
|
|
120
120
|
*/
|
|
121
121
|
webAuthn?: AmplessWebAuthnOption | false;
|
|
122
122
|
}
|
|
123
|
+
interface ResolveWebAuthnOpts {
|
|
124
|
+
/** Explicit override from resource.custom.ts. When present, takes precedence. */
|
|
125
|
+
override?: AmplessWebAuthnOption | false;
|
|
126
|
+
/** `site.url` from cms.config — used to derive hostname in pipeline builds. */
|
|
127
|
+
siteUrl: string;
|
|
128
|
+
/** True only in Amplify Hosting pipeline builds (`Boolean(process.env.AWS_BRANCH)`). */
|
|
129
|
+
isPipeline: boolean;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Single source of truth for the WebAuthn relying-party configuration.
|
|
133
|
+
*
|
|
134
|
+
* Priority:
|
|
135
|
+
* 1. `override !== undefined` → return it verbatim (supports `false` to disable).
|
|
136
|
+
* 2. Not a pipeline build (sandbox / local) → return `true` so Amplify
|
|
137
|
+
* auto-resolves the RP ID from `localhost` (no RP ID needed in dev).
|
|
138
|
+
* 3. Pipeline build → derive `{ relyingPartyId }` from `siteUrl`.
|
|
139
|
+
* Falls back to `true` if `siteUrl` is not a valid URL (logs a warning).
|
|
140
|
+
*/
|
|
141
|
+
declare function resolveWebAuthn(opts: ResolveWebAuthnOpts): AmplessWebAuthnOption | false;
|
|
123
142
|
/**
|
|
124
143
|
* Build the ampless Cognito configuration (User Pool + Identity Pool
|
|
125
144
|
* with the three role groups and the optional post-confirmation
|
|
@@ -327,4 +346,4 @@ declare function amplessSchemaAuthorization(allow: any, opts?: AmplessSchemaAuth
|
|
|
327
346
|
*/
|
|
328
347
|
declare const defaultAuthorizationModes: Parameters<typeof defineData>[0]['authorizationModes'];
|
|
329
348
|
|
|
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 };
|
|
349
|
+
export { type AmplessAuthConfigOpts, type AmplessBackend, type AmplessResolverPaths, type AmplessSchemaAuthorizationOpts, type AmplessSchemaModelsOpts, type AmplessWebAuthnOption, DEFAULT_RESOLVER_PATHS, type DefineAmplessBackendOpts, type ResolveWebAuthnOpts, amplessAuthConfig, amplessSchemaAuthorization, amplessSchemaModels, amplessStorageConfig, defaultAuthorizationModes, defineAmplessBackend, extendAmplessSchema, resolveWebAuthn };
|
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,
|
|
@@ -266,6 +264,20 @@ function defineAmplessBackend(opts) {
|
|
|
266
264
|
}
|
|
267
265
|
|
|
268
266
|
// src/auth/index.ts
|
|
267
|
+
function resolveWebAuthn(opts) {
|
|
268
|
+
if (opts.override !== void 0) return opts.override;
|
|
269
|
+
if (!opts.isPipeline) return true;
|
|
270
|
+
try {
|
|
271
|
+
const hostname = new URL(opts.siteUrl).hostname;
|
|
272
|
+
return { relyingPartyId: hostname };
|
|
273
|
+
} catch {
|
|
274
|
+
console.warn(
|
|
275
|
+
"[ampless] invalid site.url for WebAuthn relying party, falling back to auto:",
|
|
276
|
+
opts.siteUrl
|
|
277
|
+
);
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
269
281
|
function amplessAuthConfig(opts = {}) {
|
|
270
282
|
return {
|
|
271
283
|
loginWith: {
|
|
@@ -751,5 +763,6 @@ export {
|
|
|
751
763
|
amplessStorageConfig,
|
|
752
764
|
defaultAuthorizationModes,
|
|
753
765
|
defineAmplessBackend,
|
|
754
|
-
extendAmplessSchema
|
|
766
|
+
extendAmplessSchema,
|
|
767
|
+
resolveWebAuthn
|
|
755
768
|
};
|
package/package.json
CHANGED