nid-webauthn-emulator 0.2.3 → 0.2.4
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.md
CHANGED
|
@@ -189,7 +189,7 @@ test.describe("Passkeys Tests", { tag: ["@daily"] }, () => {
|
|
|
189
189
|
- `window.webAuthnEmulatorSignalAllAcceptedCredentials`: `WebAuthnEmulator.signalAllAcceptedCredentials` の Exposed Function
|
|
190
190
|
- `window.webAuthnEmulatorSignalCurrentUserDetails`: `WebAuthnEmulator.signalCurrentUserDetails` の Exposed Function
|
|
191
191
|
|
|
192
|
-
さらに`startWebAuthnEmulator`関数は`relatedOrigins`パラメータをサポートしています。これにより、異なるオリジンからのリクエストでも同じRP IDを使用できるようになります。例えば、マルチドメイン環境(`example.com`と`sub.example.com`など)でPasskeys
|
|
192
|
+
さらに`startWebAuthnEmulator`関数は`relatedOrigins`パラメータをサポートしています。これにより、異なるオリジンからのリクエストでも同じRP IDを使用できるようになります。例えば、マルチドメイン環境(`example.com`と`sub.example.com`など)でPasskeysを使用する場合に便利です。`relatedOrigins` の値はRP IDで指定されたドメインでホストされた `/.well-known/webauthn` の内容と同じです。
|
|
193
193
|
|
|
194
194
|
これらは Page グローバルに定義されるため、Page インスタンスにつき 1 回だけ定義する必要があります。
|
|
195
195
|
|
|
@@ -343,7 +343,7 @@ const webauthn_test_server_1 = require("./webauthn-test-server");
|
|
|
343
343
|
const emulator = new src_1.default();
|
|
344
344
|
// Origin is different from the RP ID
|
|
345
345
|
const testServer = new webauthn_test_server_1.WebAuthnTestServer("https://test-rp.com", "test-rp2.com");
|
|
346
|
-
const relatedOrigins = ["https://test-
|
|
346
|
+
const relatedOrigins = ["https://test-rp-a.com", "https://test-rp-b.com", "https://test-rp.com"];
|
|
347
347
|
// Register a credential
|
|
348
348
|
const regOptions = await testServer.getRegistrationOptions(user);
|
|
349
349
|
const credential = emulator.createJSON(testServer.origin, regOptions, relatedOrigins);
|
|
@@ -26,17 +26,16 @@ class RpId {
|
|
|
26
26
|
}
|
|
27
27
|
/** @see https://www.w3.org/TR/webauthn-3/#sctn-validating-origin */
|
|
28
28
|
validate(origin, relatedOrigins = []) {
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
const parsedRpId = (0, tldts_1.parse)(this.value, { validHosts: ["localhost"] });
|
|
29
|
+
const parsedOrigin = (0, tldts_1.parse)(origin, { validHosts: ["localhost"] });
|
|
30
|
+
const expectedOrigins = [this.value, ...relatedOrigins];
|
|
32
31
|
// Check each origin using standard validation
|
|
33
|
-
for (const
|
|
34
|
-
const
|
|
32
|
+
for (const expectedOrigin of expectedOrigins) {
|
|
33
|
+
const parsedExpectedOrigin = (0, tldts_1.parse)(expectedOrigin, { validHosts: ["localhost"] });
|
|
35
34
|
const isValid = Boolean(parsedOrigin.domain &&
|
|
36
35
|
parsedOrigin.subdomain !== null &&
|
|
37
|
-
|
|
38
|
-
parsedOrigin.domain ===
|
|
39
|
-
parsedOrigin.subdomain.endsWith(
|
|
36
|
+
parsedExpectedOrigin.subdomain !== null &&
|
|
37
|
+
parsedOrigin.domain === parsedExpectedOrigin.domain &&
|
|
38
|
+
parsedOrigin.subdomain.endsWith(parsedExpectedOrigin.subdomain));
|
|
40
39
|
if (isValid) {
|
|
41
40
|
return true;
|
|
42
41
|
}
|