@terreno/syncdb 58.0.6 → 58.1.1
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/CHANGELOG.md +58 -0
- package/dist/auth/TerrenoOAuthConsentScreen.d.ts +65 -0
- package/dist/auth/TerrenoOAuthConsentScreen.d.ts.map +1 -0
- package/dist/auth/TerrenoOAuthConsentScreen.js +119 -0
- package/dist/auth/TerrenoOAuthConsentScreen.js.map +1 -0
- package/dist/auth/auth.d.ts +2 -0
- package/dist/auth/auth.d.ts.map +1 -1
- package/dist/auth/auth.js +2 -0
- package/dist/auth/auth.js.map +1 -1
- package/dist/auth/useLoginController.d.ts +23 -1
- package/dist/auth/useLoginController.d.ts.map +1 -1
- package/dist/auth/useLoginController.js +14 -4
- package/dist/auth/useLoginController.js.map +1 -1
- package/dist/auth/useMcpOAuthConsent.d.ts +65 -0
- package/dist/auth/useMcpOAuthConsent.d.ts.map +1 -0
- package/dist/auth/useMcpOAuthConsent.js +133 -0
- package/dist/auth/useMcpOAuthConsent.js.map +1 -0
- package/dist/codegen/discoverOperations.test.d.ts +2 -0
- package/dist/codegen/discoverOperations.test.d.ts.map +1 -0
- package/dist/codegen/discoverOperations.test.js +66 -0
- package/dist/codegen/discoverOperations.test.js.map +1 -0
- package/dist/devMcpRegistry.d.ts.map +1 -1
- package/dist/devMcpRegistry.isolated.js +6 -0
- package/dist/devMcpRegistry.isolated.js.map +1 -1
- package/dist/devMcpRegistry.js +3 -1
- package/dist/devMcpRegistry.js.map +1 -1
- package/dist/isolated/TerrenoLoginScreen.isolated.js +59 -0
- package/dist/isolated/TerrenoLoginScreen.isolated.js.map +1 -1
- package/dist/isolated/TerrenoOAuthConsentScreen.isolated.d.ts +2 -0
- package/dist/isolated/TerrenoOAuthConsentScreen.isolated.d.ts.map +1 -0
- package/dist/isolated/TerrenoOAuthConsentScreen.isolated.js +532 -0
- package/dist/isolated/TerrenoOAuthConsentScreen.isolated.js.map +1 -0
- package/dist/isolated/useLoginController.isolated.js +94 -0
- package/dist/isolated/useLoginController.isolated.js.map +1 -1
- package/dist/isolated/useMcpOAuthConsent.isolated.d.ts +2 -0
- package/dist/isolated/useMcpOAuthConsent.isolated.d.ts.map +1 -0
- package/dist/isolated/useMcpOAuthConsent.isolated.js +273 -0
- package/dist/isolated/useMcpOAuthConsent.isolated.js.map +1 -0
- package/package.json +4 -4
- package/src/auth/TerrenoOAuthConsentScreen.tsx +365 -0
- package/src/auth/auth.ts +2 -0
- package/src/auth/useLoginController.ts +47 -3
- package/src/auth/useMcpOAuthConsent.ts +242 -0
- package/src/codegen/discoverOperations.test.ts +69 -0
- package/src/devMcpRegistry.isolated.ts +6 -0
- package/src/devMcpRegistry.ts +3 -1
- package/src/isolated/TerrenoLoginScreen.isolated.tsx +93 -0
- package/src/isolated/TerrenoOAuthConsentScreen.isolated.tsx +637 -0
- package/src/isolated/useLoginController.isolated.ts +109 -0
- package/src/isolated/useMcpOAuthConsent.isolated.ts +330 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {describe, expect, it} from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {discoverOperations} from "./discoverOperations";
|
|
4
|
+
import type {OpenApiDocument} from "./types";
|
|
5
|
+
|
|
6
|
+
// The shape @terreno/api documents for a modelRouter with `bulk: true` (api/src/bulkOpenApi.ts).
|
|
7
|
+
const bulkSpec = {
|
|
8
|
+
info: {title: "test", version: "1"},
|
|
9
|
+
openapi: "3.0.0",
|
|
10
|
+
paths: {
|
|
11
|
+
"/food/bulk": {
|
|
12
|
+
post: {
|
|
13
|
+
operationId: "foods_bulk",
|
|
14
|
+
requestBody: {
|
|
15
|
+
content: {
|
|
16
|
+
"application/json": {
|
|
17
|
+
schema: {
|
|
18
|
+
properties: {
|
|
19
|
+
atomic: {type: "boolean"},
|
|
20
|
+
operations: {
|
|
21
|
+
items: {
|
|
22
|
+
properties: {
|
|
23
|
+
body: {properties: {name: {type: "string"}}, type: "object"},
|
|
24
|
+
id: {type: "string"},
|
|
25
|
+
method: {enum: ["create", "update", "delete"], type: "string"},
|
|
26
|
+
},
|
|
27
|
+
required: ["method"],
|
|
28
|
+
type: "object",
|
|
29
|
+
},
|
|
30
|
+
type: "array",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
required: ["operations"],
|
|
34
|
+
type: "object",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
required: true,
|
|
39
|
+
},
|
|
40
|
+
responses: {
|
|
41
|
+
200: {
|
|
42
|
+
content: {
|
|
43
|
+
"application/json": {
|
|
44
|
+
schema: {
|
|
45
|
+
properties: {data: {items: {type: "object"}, type: "array"}},
|
|
46
|
+
type: "object",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
description: "One result per operation",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
tags: ["foods"],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
} as unknown as OpenApiDocument;
|
|
58
|
+
|
|
59
|
+
describe("discoverOperations with a modelRouter bulk route", () => {
|
|
60
|
+
it("discovers POST /food/bulk so the codegen emits a hook for it", () => {
|
|
61
|
+
const operations = discoverOperations({spec: bulkSpec});
|
|
62
|
+
const bulk = operations.find((operation) => operation.path === "/food/bulk");
|
|
63
|
+
expect(bulk).toBeDefined();
|
|
64
|
+
expect(bulk?.method).toBe("post");
|
|
65
|
+
expect(bulk?.name).toBe("foodsBulk");
|
|
66
|
+
expect(bulk?.body).toBeDefined();
|
|
67
|
+
expect(bulk?.response).toBeDefined();
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -46,6 +46,12 @@ describe("devMcpRegistry (module mocks)", () => {
|
|
|
46
46
|
name: "add",
|
|
47
47
|
});
|
|
48
48
|
expect(listTerrenoDevCommandSummaries().map((c) => c.name)).toEqual(["add"]);
|
|
49
|
+
registerTerrenoDevCommand({
|
|
50
|
+
description: "Adds again",
|
|
51
|
+
handler: () => 0,
|
|
52
|
+
name: "add",
|
|
53
|
+
});
|
|
54
|
+
expect(listTerrenoDevCommandSummaries().map((c) => c.description)).toEqual(["Adds"]);
|
|
49
55
|
await expect(runTerrenoDevCommand("add", {a: 1, b: 2})).resolves.toBe(3);
|
|
50
56
|
expect(getTerrenoDevClientDispatch()?.dispatch({type: "x"})).toEqual({type: "x"});
|
|
51
57
|
});
|
package/src/devMcpRegistry.ts
CHANGED
|
@@ -162,8 +162,10 @@ export const registerTerrenoDevCommand = (
|
|
|
162
162
|
if (!g.__TERRENO_DEV_COMMANDS__) {
|
|
163
163
|
g.__TERRENO_DEV_COMMANDS__ = {};
|
|
164
164
|
}
|
|
165
|
+
// Expo web SSR evaluates the app entry on every request while this map lives on
|
|
166
|
+
// globalThis. A second install of the same command keeps the first handler.
|
|
165
167
|
if (g.__TERRENO_DEV_COMMANDS__[name]) {
|
|
166
|
-
|
|
168
|
+
return;
|
|
167
169
|
}
|
|
168
170
|
g.__TERRENO_DEV_COMMANDS__[name] = rest;
|
|
169
171
|
};
|
|
@@ -72,6 +72,7 @@ const fakeClient = (methods: BetterAuthMethods = METHODS): LoginControllerClient
|
|
|
72
72
|
getSession: async () => ({data: null, error: null}),
|
|
73
73
|
signIn: {
|
|
74
74
|
email: async () => ({data: {twoFactorMethods: ["totp"], twoFactorRedirect: true}, error: null}),
|
|
75
|
+
passkey: async () => ({data: null, error: null}),
|
|
75
76
|
social: async () => ({data: null, error: null}),
|
|
76
77
|
},
|
|
77
78
|
twoFactor: {
|
|
@@ -253,4 +254,96 @@ describe("TerrenoLoginScreen", () => {
|
|
|
253
254
|
expect(onTwoFactorRequired).toHaveBeenCalledWith({method: "email", twoFactorMethods: ["totp"]});
|
|
254
255
|
expect(find("TwoFactorChallengeScreen")).toBeUndefined();
|
|
255
256
|
});
|
|
257
|
+
|
|
258
|
+
describe("methods allowlist", () => {
|
|
259
|
+
const renderScreen = async (
|
|
260
|
+
serverMethods: BetterAuthMethods,
|
|
261
|
+
methods?: {providers?: string[]; emailPassword?: boolean; passkey?: boolean}
|
|
262
|
+
): Promise<Record<string, unknown>> => {
|
|
263
|
+
await act(async () => {
|
|
264
|
+
renderer = create(
|
|
265
|
+
<TerrenoLoginScreen
|
|
266
|
+
client={fakeClient(serverMethods)}
|
|
267
|
+
methods={methods}
|
|
268
|
+
onSignedIn={mock(() => {})}
|
|
269
|
+
rememberedAccounts={memoryStore()}
|
|
270
|
+
webAuth="cookie"
|
|
271
|
+
/>
|
|
272
|
+
);
|
|
273
|
+
});
|
|
274
|
+
await flush();
|
|
275
|
+
return last("LoginScreen");
|
|
276
|
+
};
|
|
277
|
+
const branded = (login: Record<string, unknown>): string[] =>
|
|
278
|
+
((login.oauthProviders ?? []) as Array<{provider: string}>).map(({provider}) => provider);
|
|
279
|
+
const generic = (login: Record<string, unknown>): string[] =>
|
|
280
|
+
((login.genericProviders ?? []) as Array<{id: string}>).map(({id}) => id);
|
|
281
|
+
|
|
282
|
+
it("renders only the Google button when the server offers google, github, apple", async () => {
|
|
283
|
+
const login = await renderScreen(
|
|
284
|
+
{...METHODS, providers: ["google", "github", "apple"]},
|
|
285
|
+
{providers: ["google"]}
|
|
286
|
+
);
|
|
287
|
+
expect(branded(login)).toEqual(["google"]);
|
|
288
|
+
expect(generic(login)).toEqual([]);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it("renders only the mock-oidc generic button for providers mock-oidc and apple", async () => {
|
|
292
|
+
const login = await renderScreen(
|
|
293
|
+
{...METHODS, providers: ["google", "mock-oidc"]},
|
|
294
|
+
{providers: ["mock-oidc", "apple"]}
|
|
295
|
+
);
|
|
296
|
+
expect(branded(login)).toEqual([]);
|
|
297
|
+
expect(generic(login)).toEqual(["mock-oidc"]);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it("renders no social buttons but keeps the email form for providers []", async () => {
|
|
301
|
+
const login = await renderScreen(
|
|
302
|
+
{...METHODS, providers: ["google", "mock-oidc"]},
|
|
303
|
+
{providers: []}
|
|
304
|
+
);
|
|
305
|
+
expect(branded(login)).toEqual([]);
|
|
306
|
+
expect(generic(login)).toEqual([]);
|
|
307
|
+
expect(login.fields).toBe(DEFAULT_LOGIN_FIELDS);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it("renders no email form with emailPassword false while the server has it on", async () => {
|
|
311
|
+
const login = await renderScreen({...METHODS, emailPassword: true}, {emailPassword: false});
|
|
312
|
+
expect(login.fields).toEqual([]);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it("renders no email form with emailPassword true while the server has it off, and the form when both agree", async () => {
|
|
316
|
+
const off = await renderScreen({...METHODS, emailPassword: false}, {emailPassword: true});
|
|
317
|
+
expect(off.fields).toEqual([]);
|
|
318
|
+
act(() => renderer?.unmount());
|
|
319
|
+
rendered.length = 0;
|
|
320
|
+
const on = await renderScreen({...METHODS, emailPassword: true}, {emailPassword: true});
|
|
321
|
+
expect(on.fields).toBe(DEFAULT_LOGIN_FIELDS);
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it("renders no passkey button with passkey false while the server has it on", async () => {
|
|
325
|
+
const login = await renderScreen({...METHODS, passkey: true}, {passkey: false});
|
|
326
|
+
expect(login.onPasskeyPress).toBeUndefined();
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it("renders the passkey button with passkey true only when the server has it on", async () => {
|
|
330
|
+
const off = await renderScreen({...METHODS, passkey: false}, {passkey: true});
|
|
331
|
+
expect(off.onPasskeyPress).toBeUndefined();
|
|
332
|
+
act(() => renderer?.unmount());
|
|
333
|
+
rendered.length = 0;
|
|
334
|
+
const on = await renderScreen({...METHODS, passkey: true}, {passkey: true});
|
|
335
|
+
expect(on.onPasskeyPress).toBeDefined();
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
it("renders every server method when methods is undefined", async () => {
|
|
339
|
+
const login = await renderScreen(
|
|
340
|
+
{...METHODS, passkey: true, providers: ["google", "github", "mock-oidc"]},
|
|
341
|
+
undefined
|
|
342
|
+
);
|
|
343
|
+
expect(branded(login)).toEqual(["google", "github"]);
|
|
344
|
+
expect(generic(login)).toEqual(["mock-oidc"]);
|
|
345
|
+
expect(login.fields).toBe(DEFAULT_LOGIN_FIELDS);
|
|
346
|
+
expect(login.onPasskeyPress).toBeDefined();
|
|
347
|
+
});
|
|
348
|
+
});
|
|
256
349
|
});
|