instant-cli 1.0.22 → 1.0.23-branch-cli-codex-update.25390647417.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/.turbo/turbo-build.log +1 -1
- package/__tests__/authClientAddGoogle.test.ts +92 -0
- package/__tests__/authClientList.test.ts +90 -0
- package/__tests__/authClientUpdate.test.ts +583 -0
- package/__tests__/oauthMock.ts +9 -1
- package/__tests__/redirectUriPrompt.test.ts +27 -0
- package/dist/commands/auth/client/add.d.ts +1 -2
- package/dist/commands/auth/client/add.d.ts.map +1 -1
- package/dist/commands/auth/client/add.js +173 -276
- package/dist/commands/auth/client/add.js.map +1 -1
- package/dist/commands/auth/client/delete.d.ts +1 -2
- package/dist/commands/auth/client/delete.d.ts.map +1 -1
- package/dist/commands/auth/client/delete.js +8 -18
- package/dist/commands/auth/client/delete.js.map +1 -1
- package/dist/commands/auth/client/list.d.ts.map +1 -1
- package/dist/commands/auth/client/list.js +11 -2
- package/dist/commands/auth/client/list.js.map +1 -1
- package/dist/commands/auth/client/shared.d.ts +72 -0
- package/dist/commands/auth/client/shared.d.ts.map +1 -0
- package/dist/commands/auth/client/shared.js +145 -0
- package/dist/commands/auth/client/shared.js.map +1 -0
- package/dist/commands/auth/client/update.d.ts +8 -0
- package/dist/commands/auth/client/update.d.ts.map +1 -0
- package/dist/commands/auth/client/update.js +515 -0
- package/dist/commands/auth/client/update.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +60 -13
- package/dist/index.js.map +1 -1
- package/dist/lib/oauth.d.ts +114 -7
- package/dist/lib/oauth.d.ts.map +1 -1
- package/dist/lib/oauth.js +51 -1
- package/dist/lib/oauth.js.map +1 -1
- package/package.json +4 -4
- package/src/commands/auth/client/add.ts +251 -330
- package/src/commands/auth/client/delete.ts +8 -20
- package/src/commands/auth/client/list.ts +21 -2
- package/src/commands/auth/client/shared.ts +195 -0
- package/src/commands/auth/client/update.ts +853 -0
- package/src/index.ts +74 -13
- package/src/lib/oauth.ts +83 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -240,6 +240,98 @@ describe('web: success', () => {
|
|
|
240
240
|
});
|
|
241
241
|
});
|
|
242
242
|
|
|
243
|
+
// -- web: dev credentials --
|
|
244
|
+
|
|
245
|
+
const webDevFlags = new Map([
|
|
246
|
+
['type', 'google'],
|
|
247
|
+
['app-type', 'web'],
|
|
248
|
+
['name', 'google-web'],
|
|
249
|
+
]);
|
|
250
|
+
|
|
251
|
+
describe('web: dev credentials', () => {
|
|
252
|
+
test('--dev-credentials → creates dev credentials client', async () => {
|
|
253
|
+
await run(withEntry(webDevFlags, 'dev-credentials', 'true'), { yes: true });
|
|
254
|
+
expect(addedClients).toHaveLength(1);
|
|
255
|
+
expect(addedClients[0]).toMatchObject({
|
|
256
|
+
clientName: 'google-web',
|
|
257
|
+
useSharedCredentials: true,
|
|
258
|
+
discoveryEndpoint:
|
|
259
|
+
'https://accounts.google.com/.well-known/openid-configuration',
|
|
260
|
+
});
|
|
261
|
+
expect(addedClients[0].clientId).toBeUndefined();
|
|
262
|
+
expect(addedClients[0].clientSecret).toBeUndefined();
|
|
263
|
+
expect(addedClients[0].redirectTo).toBeUndefined();
|
|
264
|
+
const output = logs.join('\n');
|
|
265
|
+
expect(output).toContain('Credentials: Instant dev credentials');
|
|
266
|
+
expect(output).toContain('No Google Console setup required');
|
|
267
|
+
expect(output).toContain('Ready for production? Run:');
|
|
268
|
+
expect(output).not.toContain('For production');
|
|
269
|
+
expect(output).toContain(
|
|
270
|
+
'instant-cli auth client update --name google-web',
|
|
271
|
+
);
|
|
272
|
+
expect(output).not.toContain('Add this redirect URI in Google Console');
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
test('--yes with no Google credentials → creates dev credentials client', async () => {
|
|
276
|
+
await run(webDevFlags, { yes: true });
|
|
277
|
+
expect(addedClients).toHaveLength(1);
|
|
278
|
+
expect(addedClients[0]).toMatchObject({
|
|
279
|
+
clientName: 'google-web',
|
|
280
|
+
useSharedCredentials: true,
|
|
281
|
+
discoveryEndpoint:
|
|
282
|
+
'https://accounts.google.com/.well-known/openid-configuration',
|
|
283
|
+
});
|
|
284
|
+
expect(addedClients[0].clientId).toBeUndefined();
|
|
285
|
+
expect(addedClients[0].clientSecret).toBeUndefined();
|
|
286
|
+
expect(addedClients[0].redirectTo).toBeUndefined();
|
|
287
|
+
const output = logs.join('\n');
|
|
288
|
+
expect(output).toContain('Credentials: Instant dev credentials');
|
|
289
|
+
expect(output).toContain('No Google Console setup required');
|
|
290
|
+
expect(output).toContain(
|
|
291
|
+
'instant-cli auth client update --name google-web',
|
|
292
|
+
);
|
|
293
|
+
expect(output).not.toContain('Add this redirect URI in Google Console');
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
test('--dev-credentials with custom credential flags → error', async () => {
|
|
297
|
+
await run(
|
|
298
|
+
new Map([...webDevFlags, ['dev-credentials', 'true'], ['client-id', '']]),
|
|
299
|
+
{ yes: true },
|
|
300
|
+
);
|
|
301
|
+
expect(logs.join('\n')).toContain(
|
|
302
|
+
'--dev-credentials cannot be combined with --client-id',
|
|
303
|
+
);
|
|
304
|
+
expect(addedClients).toHaveLength(0);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
test('--dev-credentials with native app type → error', async () => {
|
|
308
|
+
await run(
|
|
309
|
+
new Map([
|
|
310
|
+
['type', 'google'],
|
|
311
|
+
['app-type', 'ios'],
|
|
312
|
+
['name', 'google-ios'],
|
|
313
|
+
['dev-credentials', 'true'],
|
|
314
|
+
]),
|
|
315
|
+
{ yes: true },
|
|
316
|
+
);
|
|
317
|
+
expect(logs.join('\n')).toContain(
|
|
318
|
+
'--dev-credentials is only supported for --app-type web',
|
|
319
|
+
);
|
|
320
|
+
expect(addedClients).toHaveLength(0);
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
test('interactive with no Google credentials → prompts for credential mode', async () => {
|
|
324
|
+
mockPromptReturn = 'dev';
|
|
325
|
+
await run(webDevFlags, { yes: false });
|
|
326
|
+
expect(prompts).toHaveLength(1);
|
|
327
|
+
expect((prompts[0] as any).params.promptText).toBe(
|
|
328
|
+
'Select Google credential mode:',
|
|
329
|
+
);
|
|
330
|
+
expect(addedClients).toHaveLength(1);
|
|
331
|
+
expect(addedClients[0].useSharedCredentials).toBe(true);
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
|
|
243
335
|
// -- ios: forbidden flags and success --
|
|
244
336
|
|
|
245
337
|
describe('ios', () => {
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { test, expect, describe, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { Effect, Layer, Logger } from 'effect';
|
|
3
|
+
import { CurrentApp } from '../src/context/currentApp.ts';
|
|
4
|
+
import { InstantHttpAuthed } from '../src/lib/http.ts';
|
|
5
|
+
|
|
6
|
+
vi.mock('../src/index.ts', () => ({}));
|
|
7
|
+
|
|
8
|
+
const authResponse = {
|
|
9
|
+
oauth_service_providers: [
|
|
10
|
+
{ id: 'prov-google', provider_name: 'google' },
|
|
11
|
+
{ id: 'prov-github', provider_name: 'github' },
|
|
12
|
+
],
|
|
13
|
+
oauth_clients: [
|
|
14
|
+
{
|
|
15
|
+
id: 'google-shared',
|
|
16
|
+
provider_id: 'prov-google',
|
|
17
|
+
client_name: 'google-shared',
|
|
18
|
+
client_id: null,
|
|
19
|
+
redirect_to: null,
|
|
20
|
+
meta: { appType: 'web' },
|
|
21
|
+
use_shared_credentials: true,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 'github',
|
|
25
|
+
provider_id: 'prov-github',
|
|
26
|
+
client_name: 'github',
|
|
27
|
+
client_id: 'gh-id',
|
|
28
|
+
redirect_to: 'https://api.instantdb.com/runtime/oauth/callback',
|
|
29
|
+
meta: {},
|
|
30
|
+
use_shared_credentials: false,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
vi.mock('../src/lib/oauth.ts', () => ({
|
|
36
|
+
getAppsAuth: () => Effect.succeed(authResponse),
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
const { authClientListCmd } = await import(
|
|
40
|
+
'../src/commands/auth/client/list.ts'
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
let logs: string[] = [];
|
|
44
|
+
|
|
45
|
+
const run = (opts: { json?: boolean }) =>
|
|
46
|
+
Effect.runPromise(
|
|
47
|
+
authClientListCmd(opts as any).pipe(
|
|
48
|
+
Effect.provide(
|
|
49
|
+
Layer.mergeAll(
|
|
50
|
+
Layer.succeed(CurrentApp, { appId: 'test-app', source: 'env' }),
|
|
51
|
+
Layer.succeed(InstantHttpAuthed, {} as any),
|
|
52
|
+
Logger.replace(
|
|
53
|
+
Logger.defaultLogger,
|
|
54
|
+
Logger.make(({ message }) => {
|
|
55
|
+
logs.push(String(message));
|
|
56
|
+
}),
|
|
57
|
+
),
|
|
58
|
+
),
|
|
59
|
+
),
|
|
60
|
+
),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
beforeEach(() => {
|
|
64
|
+
logs = [];
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('auth client list', () => {
|
|
68
|
+
test('shows shared dev credentials clearly', async () => {
|
|
69
|
+
await run({});
|
|
70
|
+
const output = logs.join('\n');
|
|
71
|
+
expect(output).toContain('google-shared');
|
|
72
|
+
expect(output).toContain('App type: web');
|
|
73
|
+
expect(output).toContain('Credentials: Instant dev credentials');
|
|
74
|
+
expect(output).toContain('Client id: managed by Instant');
|
|
75
|
+
expect(output).toContain(
|
|
76
|
+
'Redirect URL: localhost and Expo allowed automatically',
|
|
77
|
+
);
|
|
78
|
+
expect(output).toContain('Credentials: custom');
|
|
79
|
+
expect(output).toContain('Client id: gh-id');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('--json prints raw clients', async () => {
|
|
83
|
+
await run({ json: true });
|
|
84
|
+
const parsed = JSON.parse(logs.join('\n'));
|
|
85
|
+
expect(parsed[0]).toMatchObject({
|
|
86
|
+
client_name: 'google-shared',
|
|
87
|
+
use_shared_credentials: true,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|