instant-cli 1.0.22 → 1.0.23-branch-cli-codex-update.25390498340.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.
Files changed (41) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/__tests__/authClientAddGoogle.test.ts +92 -0
  3. package/__tests__/authClientList.test.ts +90 -0
  4. package/__tests__/authClientUpdate.test.ts +583 -0
  5. package/__tests__/oauthMock.ts +9 -1
  6. package/__tests__/redirectUriPrompt.test.ts +26 -0
  7. package/dist/commands/auth/client/add.d.ts +1 -2
  8. package/dist/commands/auth/client/add.d.ts.map +1 -1
  9. package/dist/commands/auth/client/add.js +173 -276
  10. package/dist/commands/auth/client/add.js.map +1 -1
  11. package/dist/commands/auth/client/delete.d.ts +1 -2
  12. package/dist/commands/auth/client/delete.d.ts.map +1 -1
  13. package/dist/commands/auth/client/delete.js +8 -18
  14. package/dist/commands/auth/client/delete.js.map +1 -1
  15. package/dist/commands/auth/client/list.d.ts.map +1 -1
  16. package/dist/commands/auth/client/list.js +11 -2
  17. package/dist/commands/auth/client/list.js.map +1 -1
  18. package/dist/commands/auth/client/shared.d.ts +72 -0
  19. package/dist/commands/auth/client/shared.d.ts.map +1 -0
  20. package/dist/commands/auth/client/shared.js +145 -0
  21. package/dist/commands/auth/client/shared.js.map +1 -0
  22. package/dist/commands/auth/client/update.d.ts +8 -0
  23. package/dist/commands/auth/client/update.d.ts.map +1 -0
  24. package/dist/commands/auth/client/update.js +515 -0
  25. package/dist/commands/auth/client/update.js.map +1 -0
  26. package/dist/index.d.ts +5 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +60 -13
  29. package/dist/index.js.map +1 -1
  30. package/dist/lib/oauth.d.ts +114 -7
  31. package/dist/lib/oauth.d.ts.map +1 -1
  32. package/dist/lib/oauth.js +51 -1
  33. package/dist/lib/oauth.js.map +1 -1
  34. package/package.json +4 -4
  35. package/src/commands/auth/client/add.ts +251 -330
  36. package/src/commands/auth/client/delete.ts +8 -20
  37. package/src/commands/auth/client/list.ts +21 -2
  38. package/src/commands/auth/client/shared.ts +195 -0
  39. package/src/commands/auth/client/update.ts +853 -0
  40. package/src/index.ts +74 -13
  41. package/src/lib/oauth.ts +83 -1
package/src/index.ts CHANGED
@@ -29,6 +29,7 @@ import { PACKAGE_ALIAS_AND_FULL_NAMES } from './context/projectInfo.ts';
29
29
  import { authClientAddCmd } from './commands/auth/client/add.ts';
30
30
  import { authClientListCmd } from './commands/auth/client/list.ts';
31
31
  import { authClientDeleteCmd } from './commands/auth/client/delete.ts';
32
+ import { authClientUpdateCmd } from './commands/auth/client/update.ts';
32
33
  import { authOriginListCmd } from './commands/auth/origin/list.ts';
33
34
  import { authOriginDeleteCmd } from './commands/auth/origin/delete.ts';
34
35
  import { authOriginAddCmd } from './commands/auth/origin/add.ts';
@@ -109,28 +110,29 @@ export const authClientAddDef = authClient
109
110
  `
110
111
  Provider Specific Options:
111
112
  Google:
112
- --app-type web|ios|android|button-for-web
113
- --client-id
114
- --client-secret (web only)
115
- --custom-redirect-uri (optional, web only)
113
+ --app-type web|ios|android|button-for-web
114
+ --dev-credentials (optional, web only)
115
+ --client-id (required unless using dev credentials)
116
+ --client-secret (web only, unless using dev credentials)
117
+ --custom-redirect-uri (optional, web only)
116
118
  GitHub:
117
119
  --client-id
118
120
  --client-secret
119
- --custom-redirect-uri (optional)
121
+ --custom-redirect-uri (optional)
120
122
  Apple:
121
- --services-id (Services ID from ${link('https://developer.apple.com', 'developer.apple.com')})
122
- --team-id (optional, required for web redirect flow)
123
- --key-id (optional, required for web redirect flow)
124
- --private-key-file (optional, path to .p8 PEM; required for web redirect flow)
125
- --custom-redirect-uri (optional, web redirect flow only)
123
+ --services-id (Services ID from ${link('https://developer.apple.com', 'developer.apple.com')})
124
+ --team-id (optional, required for web redirect flow)
125
+ --key-id (optional, required for web redirect flow)
126
+ --private-key-file (optional, path to .p8 PEM; required for web redirect flow)
127
+ --custom-redirect-uri (optional, web redirect flow only)
126
128
  LinkedIn:
127
129
  --client-id
128
130
  --client-secret
129
- --custom-redirect-uri (optional)
131
+ --custom-redirect-uri (optional)
130
132
  Clerk:
131
- --publishable-key (Publishable Key from ${link('https://dashboard.clerk.com', 'dashboard.clerk.com')})
133
+ --publishable-key (Publishable Key from ${link('https://dashboard.clerk.com', 'dashboard.clerk.com')})
132
134
  Firebase:
133
- --project-id (Project ID from ${link('https://console.firebase.google.com', 'console.firebase.google.com')})
135
+ --project-id (Project ID from ${link('https://console.firebase.google.com', 'console.firebase.google.com')})
134
136
  `,
135
137
  )
136
138
  .action((opts) => {
@@ -197,6 +199,65 @@ export const authClientDeleteDef = authClient
197
199
  );
198
200
  });
199
201
 
202
+ export const authClientUpdateDef = authClient
203
+ .command('update')
204
+ .description('Update an OAuth client')
205
+ .allowExcessArguments(true)
206
+ .allowUnknownOption(true)
207
+ .option('--id <client-id>', 'Client ID to update')
208
+ .option('--name <client-name>', 'Client name to update')
209
+ .option(
210
+ '-a --app <app-id>',
211
+ 'App ID to update a client in. Defaults to *_INSTANT_APP_ID in .env',
212
+ )
213
+ .addHelpText(
214
+ 'after',
215
+ `
216
+ Provider Specific Options:
217
+ Google:
218
+ --dev-credentials (web only)
219
+ --client-id
220
+ --client-secret (web only)
221
+ --custom-redirect-uri (optional, web only)
222
+ GitHub:
223
+ --client-id
224
+ --client-secret
225
+ --custom-redirect-uri (optional)
226
+ Apple:
227
+ --services-id
228
+ --team-id (web redirect flow)
229
+ --key-id (web redirect flow)
230
+ --private-key-file (web redirect flow)
231
+ --custom-redirect-uri (optional, web redirect flow only)
232
+ LinkedIn:
233
+ --client-id
234
+ --client-secret
235
+ --custom-redirect-uri (optional)
236
+ Clerk:
237
+ --publishable-key
238
+ Firebase:
239
+ --project-id
240
+ `,
241
+ )
242
+ .action((opts) => {
243
+ opts = {
244
+ ...opts,
245
+ ...minimist(process.argv),
246
+ };
247
+
248
+ return runCommandEffect(
249
+ authClientUpdateCmd(opts).pipe(
250
+ Effect.provide(
251
+ WithAppLayer({
252
+ coerce: false,
253
+ appId: opts.app,
254
+ allowAdminToken: true,
255
+ }),
256
+ ),
257
+ ),
258
+ );
259
+ });
260
+
200
261
  const authOrigin = auth.command('origin');
201
262
  export const authOriginListDef = authOrigin
202
263
  .command('list')
package/src/lib/oauth.ts CHANGED
@@ -32,10 +32,30 @@ export const OAuthServiceProvider = Schema.Struct({
32
32
  provider_name: Schema.String,
33
33
  });
34
34
 
35
+ export const GoogleAppTypeSchema = Schema.Literal(
36
+ 'web',
37
+ 'ios',
38
+ 'android',
39
+ 'button-for-web',
40
+ );
41
+
35
42
  const NullableString = Schema.Union(Schema.String, Schema.Null).pipe(
36
43
  Schema.optional,
37
44
  );
38
45
 
46
+ const NullableBoolean = Schema.Union(Schema.Boolean, Schema.Null).pipe(
47
+ Schema.optional,
48
+ );
49
+
50
+ const OAuthClientMeta = Schema.Struct({
51
+ // Currently the CLI only reads Google app type from meta. Other providers store
52
+ // different meta shapes, so keep the rest open until we have a clean
53
+ // top-level discriminator for a full provider-specific union.
54
+ appType: GoogleAppTypeSchema.pipe(Schema.optional),
55
+ }).pipe(
56
+ Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Any })),
57
+ );
58
+
39
59
  export const OAuthClient = Schema.Struct({
40
60
  id: Schema.String,
41
61
  client_name: Schema.String,
@@ -45,7 +65,8 @@ export const OAuthClient = Schema.Struct({
45
65
  token_endpoint: NullableString,
46
66
  discovery_endpoint: NullableString,
47
67
  redirect_to: NullableString,
48
- meta: Schema.Any.pipe(Schema.optional),
68
+ meta: Schema.Union(OAuthClientMeta, Schema.Null).pipe(Schema.optional),
69
+ use_shared_credentials: NullableBoolean,
49
70
  });
50
71
 
51
72
  export const AddOAuthProviderResponse = Schema.Struct({
@@ -111,6 +132,7 @@ export const addOAuthClient = Effect.fn(function* (params: {
111
132
  discoveryEndpoint?: string;
112
133
  redirectTo?: string;
113
134
  meta?: unknown;
135
+ useSharedCredentials?: boolean;
114
136
  }) {
115
137
  const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));
116
138
  const targetAppId = params.appId ?? (yield* CurrentApp).appId;
@@ -127,6 +149,35 @@ export const addOAuthClient = Effect.fn(function* (params: {
127
149
  discovery_endpoint: params.discoveryEndpoint,
128
150
  redirect_to: params.redirectTo,
129
151
  meta: params.meta,
152
+ use_shared_credentials: params.useSharedCredentials,
153
+ }),
154
+ })
155
+ .pipe(
156
+ Effect.flatMap(HttpClientResponse.schemaBodyJson(AddOAuthClientResponse)),
157
+ );
158
+ });
159
+
160
+ export const updateOAuthClient = Effect.fn(function* (params: {
161
+ oauthClientId: string;
162
+ clientId?: string | null;
163
+ clientSecret?: string | null;
164
+ discoveryEndpoint?: string | null;
165
+ redirectTo?: string | null;
166
+ meta?: unknown;
167
+ useSharedCredentials?: boolean | null;
168
+ }) {
169
+ const http = (yield* InstantHttpAuthed).pipe(withCommand('auth'));
170
+ const targetAppId = (yield* CurrentApp).appId;
171
+
172
+ return yield* http
173
+ .post(`/dash/apps/${targetAppId}/oauth_clients/${params.oauthClientId}`, {
174
+ body: HttpBody.unsafeJson({
175
+ client_id: params.clientId,
176
+ client_secret: params.clientSecret,
177
+ discovery_endpoint: params.discoveryEndpoint,
178
+ redirect_to: params.redirectTo,
179
+ meta: params.meta,
180
+ use_shared_credentials: params.useSharedCredentials,
130
181
  }),
131
182
  })
132
183
  .pipe(
@@ -236,6 +287,37 @@ export const getClientNameAndProvider = Effect.fn(function* (
236
287
  return { provider, clientName };
237
288
  });
238
289
 
290
+ export const findClientByIdOrName = Effect.fn(function* (params: {
291
+ id?: string;
292
+ name?: string;
293
+ }) {
294
+ if (params.id && params.name) {
295
+ return yield* BadArgsError.make({
296
+ message: 'Cannot specify both --id and --name',
297
+ });
298
+ }
299
+ if (!params.id && !params.name) {
300
+ return yield* BadArgsError.make({
301
+ message: 'Must specify --id or --name',
302
+ });
303
+ }
304
+
305
+ const auth = yield* getAppsAuth();
306
+ const clients = auth.oauth_clients ?? [];
307
+ const client = params.id
308
+ ? clients.find((entry) => entry.id === params.id)
309
+ : clients.find((entry) => entry.client_name === params.name);
310
+
311
+ if (!client) {
312
+ const lookup = params.id ? `id ${params.id}` : `name ${params.name}`;
313
+ return yield* BadArgsError.make({
314
+ message: `OAuth client not found: ${lookup}`,
315
+ });
316
+ }
317
+
318
+ return { auth, client };
319
+ });
320
+
239
321
  export const removeAuthorizedOrigin = Effect.fn(function* (originId: string) {
240
322
  const http = (yield* InstantHttpAuthed).pipe(
241
323
  withCommand('auth origin delete'),