@structured-id/ui-core 4.7.1 → 4.8.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@structured-id/ui-core",
3
- "version": "4.7.1",
3
+ "version": "4.8.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -42,7 +42,7 @@
42
42
  "@protobuf-ts/grpcweb-transport": "^2.11.1",
43
43
  "@protobuf-ts/runtime": "^2.11.1",
44
44
  "@protobuf-ts/runtime-rpc": "^2.11.1",
45
- "@structured-id/proto": "^0.6.0",
45
+ "@structured-id/proto": "^0.8.0",
46
46
  "@structured-world/structured-email-address-ts": "^0.0.22",
47
47
  "@structured-world/structured-public-domains": "0.0.x",
48
48
  "libphonenumber-js": "^1.13.15"
@@ -6,6 +6,16 @@ import { GrantOutcome } from "@structured-id/proto/sid/v1/authn/application_sess
6
6
  const host = vi.hoisted(() => ({
7
7
  getApplicationSession: vi.fn(),
8
8
  endApplicationSession: vi.fn(),
9
+ /** The base URL of the transport last made. */
10
+ transportBase: undefined as string | undefined,
11
+ }));
12
+
13
+ vi.mock("@protobuf-ts/grpcweb-transport", () => ({
14
+ GrpcWebFetchTransport: class {
15
+ constructor(options: { baseUrl: string }) {
16
+ host.transportBase = options.baseUrl;
17
+ }
18
+ },
9
19
  }));
10
20
 
11
21
  vi.mock("@structured-id/proto/sid/v1/authn/application_session.client", () => ({
@@ -40,6 +50,27 @@ const LIVE = {
40
50
  csrfToken: "token-1",
41
51
  };
42
52
 
53
+ describe("the session service's address", () => {
54
+ // The host serves a page's calls only under its API mount: a call at the
55
+ // root is refused, and the page cannot read a session it has.
56
+ it("is the API mount of the page's own origin", () => {
57
+ initBff("");
58
+ expect(host.transportBase).toBe("/api");
59
+ });
60
+
61
+ it("is the API mount of a configured host", () => {
62
+ initBff("https://host.sid.example.com");
63
+ expect(host.transportBase).toBe("https://host.sid.example.com/api");
64
+ });
65
+
66
+ it("is the API mount of a host named for one call", async () => {
67
+ initBff("");
68
+ host.getApplicationSession.mockReturnValue(answers(LIVE));
69
+ await checkBffSession("https://other.sid.example.com");
70
+ expect(host.transportBase).toBe("https://other.sid.example.com/api");
71
+ });
72
+ });
73
+
43
74
  describe("checkBffSession", () => {
44
75
  beforeEach(() => {
45
76
  vi.clearAllMocks();
@@ -43,10 +43,13 @@ let _session: ApplicationSessionServiceClient | null = null;
43
43
  */
44
44
  let _csrfToken: string | null = null;
45
45
 
46
- /** The session service at `baseUrl`; the cookie never travels to another origin. */
46
+ /**
47
+ * The session service of the host at `baseUrl`, under the `/api` mount that
48
+ * serves a page's calls; the cookie never travels to another origin.
49
+ */
47
50
  function sessionClient(baseUrl: string): ApplicationSessionServiceClient {
48
51
  const transport: RpcTransport = new GrpcWebFetchTransport({
49
- baseUrl,
52
+ baseUrl: `${baseUrl}/api`,
50
53
  fetchInit: { credentials: "same-origin" },
51
54
  });
52
55
  return new ApplicationSessionServiceClient(transport);
@@ -126,6 +126,8 @@ describe("createAuth prewarm", () => {
126
126
  api.loginFinish.mockResolvedValue({
127
127
  sessionId: "s",
128
128
  expiresIn: 60n,
129
+ secondFactors: [],
130
+ enrollableFactors: [],
129
131
  });
130
132
  });
131
133
 
@@ -688,6 +690,8 @@ describe("createAuth login", () => {
688
690
  api.loginFinish.mockResolvedValue({
689
691
  sessionId: "sess-1",
690
692
  expiresIn: BigInt(3600),
693
+ secondFactors: [],
694
+ enrollableFactors: [],
691
695
  });
692
696
  });
693
697
 
@@ -186,6 +186,7 @@ export const REFUSAL_TEXTS: Readonly<
186
186
  [ErrorReason.INVALID_STATE]: "This cannot be done in its current state.",
187
187
  [ErrorReason.FEATURE_NOT_CONFIGURED]:
188
188
  "This feature is not configured; an administrator can enable it.",
189
+ [ErrorReason.REGISTRATION_DISABLED]: "Registration is closed right now.",
189
190
  [ErrorReason.RATE_LIMIT_EXCEEDED]: "Too many attempts; try again later.",
190
191
  [ErrorReason.QUOTA_EXCEEDED]: "A limit is reached; remove something first.",
191
192
  [ErrorReason.CONCURRENT_MODIFICATION]: