Contracts 1.5.0: OIDC client paths, client secret from the link, church.changed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { createHmac, generateKeyPairSync } from "node:crypto";
|
||||
import { hub, linkConnectSchema, linkConnectedSchema } from "../src";
|
||||
import { hub, linkConnectSchema, linkConnectedSchema, oidcClientAddresses } from "../src";
|
||||
import * as s from "../src/signing";
|
||||
import { HUB_HEADERS, LINK_HEADERS, sign, signedHeaders, verify } from "../src/signing";
|
||||
import { sample } from "./helpers";
|
||||
@@ -139,3 +139,21 @@ describe("product links (crosscode.link/1)", () => {
|
||||
expect(hub.heartbeatRequestSchema.safeParse({ ...sample("hub-heartbeat-events.json"), publicKey: "nope" }).success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("signing in through Accounts (contracts 1.5.0)", () => {
|
||||
it("derives the OIDC client secret from the link secret, stably and per link", () => {
|
||||
const a = s.newLinkSecret();
|
||||
expect(s.oidcClientSecret(a)).toBe(s.oidcClientSecret(a));
|
||||
expect(s.oidcClientSecret(a)).toMatch(/^[A-Za-z0-9_-]{43}$/);
|
||||
expect(s.oidcClientSecret(a)).not.toBe(s.oidcClientSecret(s.newLinkSecret()));
|
||||
expect(s.oidcClientSecret(a)).not.toBe(a);
|
||||
});
|
||||
|
||||
it("gives every product the same fixed addresses", () => {
|
||||
expect(oidcClientAddresses("https://www.hope.co.za/")).toEqual({
|
||||
redirectUri: "https://www.hope.co.za/api/auth/callback",
|
||||
postLogoutRedirectUri: "https://www.hope.co.za/",
|
||||
backchannelLogoutUri: "https://www.hope.co.za/api/auth/backchannel-logout",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -36,6 +36,7 @@ const SAMPLE_SCHEMA: Record<string, string> = {
|
||||
"hub-heartbeat-response.json": "hub-heartbeat-response",
|
||||
"hub-licence-payload.json": "hub-licence-payload",
|
||||
"church-export.json": "church-export",
|
||||
"church-changed.json": "church-changed",
|
||||
"link-connect.json": "link-connect",
|
||||
"link-connected.json": "link-connected",
|
||||
"link-disconnect.json": "link-disconnect",
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
eventFeedSchema,
|
||||
eventSchema,
|
||||
hub,
|
||||
churchChangedSchema,
|
||||
linkConnectSchema,
|
||||
linkConnectedSchema,
|
||||
linkDisconnectSchema,
|
||||
@@ -39,6 +40,7 @@ const SCHEMAS: Record<string, z.ZodType> = {
|
||||
"hub-heartbeat-response.json": hub.heartbeatResponseSchema,
|
||||
"hub-licence-payload.json": hub.licencePayloadSchema,
|
||||
"church-export.json": churchExportSchema,
|
||||
"church-changed.json": churchChangedSchema,
|
||||
"link-connect.json": linkConnectSchema,
|
||||
"link-connected.json": linkConnectedSchema,
|
||||
"link-disconnect.json": linkDisconnectSchema,
|
||||
|
||||
Reference in New Issue
Block a user