feat(ap1): add vanilla SPA PKCE login
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { webcrypto } from "node:crypto";
|
||||
import test from "node:test";
|
||||
|
||||
globalThis.btoa = (value) => Buffer.from(value, "binary").toString("base64");
|
||||
|
||||
const { createPkcePair } = await import("../src/pkce.js");
|
||||
|
||||
test("manual PKCE helper creates an RFC 7636 S256 pair", async () => {
|
||||
const pair = await createPkcePair(webcrypto);
|
||||
|
||||
assert.equal(pair.method, "S256");
|
||||
assert.equal(pair.verifier.length, 43);
|
||||
assert.equal(pair.challenge.length, 43);
|
||||
assert.match(pair.verifier, /^[A-Za-z0-9_-]+$/u);
|
||||
assert.match(pair.challenge, /^[A-Za-z0-9_-]+$/u);
|
||||
assert.notEqual(pair.verifier, pair.challenge);
|
||||
});
|
||||
Reference in New Issue
Block a user