feat: add signed SPA account-linking helper
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
const { createAccountLinkUrl } = await import("../src/account-linking.js");
|
||||
|
||||
test("creates a signed client-initiated account-link URL", async () => {
|
||||
const url = await createAccountLinkUrl({
|
||||
keycloakBaseUrl: "https://auth.example.test",
|
||||
realm: "keycloak-patterns",
|
||||
provider: "google",
|
||||
clientId: "spa-public",
|
||||
redirectUri: "https://app.example.test/settings/identity",
|
||||
sessionState: "session-state",
|
||||
issuedFor: "spa-public",
|
||||
nonce: "fixed-nonce",
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
url.pathname,
|
||||
"/realms/keycloak-patterns/broker/google/link",
|
||||
);
|
||||
assert.equal(url.searchParams.get("client_id"), "spa-public");
|
||||
assert.equal(url.searchParams.get("nonce"), "fixed-nonce");
|
||||
assert.match(url.searchParams.get("hash"), /^[A-Za-z0-9_-]{43}$/u);
|
||||
});
|
||||
Reference in New Issue
Block a user