@djangocfg/api 2.1.598 → 2.1.600

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 (61) hide show
  1. package/README.md +2 -1
  2. package/dist/OAuthProvidersResponse-QZ566OYR.mjs +25 -0
  3. package/dist/OAuthProvidersResponse-QZ566OYR.mjs.map +1 -0
  4. package/dist/auth.cjs +526 -288
  5. package/dist/auth.cjs.map +1 -1
  6. package/dist/auth.d.cts +144 -31
  7. package/dist/auth.d.ts +144 -31
  8. package/dist/auth.mjs +409 -213
  9. package/dist/auth.mjs.map +1 -1
  10. package/dist/cfg_accounts_oauth_connections_response_200_AutoRef-N532BRPN.mjs +28 -0
  11. package/dist/cfg_accounts_oauth_connections_response_200_AutoRef-N532BRPN.mjs.map +1 -0
  12. package/dist/chunk-PCOSFQTH.mjs +10 -0
  13. package/dist/chunk-PCOSFQTH.mjs.map +1 -0
  14. package/dist/clients.cjs +34 -3
  15. package/dist/clients.cjs.map +1 -1
  16. package/dist/clients.d.cts +135 -14
  17. package/dist/clients.d.ts +135 -14
  18. package/dist/clients.mjs +34 -3
  19. package/dist/clients.mjs.map +1 -1
  20. package/dist/hooks.cjs +1 -0
  21. package/dist/hooks.cjs.map +1 -1
  22. package/dist/hooks.mjs +1 -0
  23. package/dist/hooks.mjs.map +1 -1
  24. package/dist/index.cjs +34 -3
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +169 -17
  27. package/dist/index.d.ts +169 -17
  28. package/dist/index.mjs +34 -3
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/storage.cjs +1 -0
  31. package/dist/storage.cjs.map +1 -1
  32. package/dist/storage.d.cts +1 -0
  33. package/dist/storage.d.ts +1 -0
  34. package/dist/storage.mjs +1 -0
  35. package/dist/storage.mjs.map +1 -1
  36. package/package.json +2 -2
  37. package/src/__tests__/noStorageLiterals.test.ts +1 -1
  38. package/src/_api/generated/_cfg_accounts/hooks/index.ts +2 -0
  39. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGoogleAuthorizeCreate.ts +68 -0
  40. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGoogleCallbackCreate.ts +68 -0
  41. package/src/_api/generated/_cfg_accounts/openapi.json +263 -19
  42. package/src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts +2 -2
  43. package/src/_api/generated/_cfg_accounts/schemas/OAuthError.ts +2 -1
  44. package/src/_api/generated/_cfg_accounts/schemas/OAuthErrorCodeEnum.ts +9 -0
  45. package/src/_api/generated/_cfg_accounts/schemas/OAuthProviderEnum.ts +1 -1
  46. package/src/_api/generated/_cfg_accounts/schemas/OAuthProviderInfo.ts +14 -0
  47. package/src/_api/generated/_cfg_accounts/schemas/OAuthProvidersResponse.ts +2 -1
  48. package/src/_api/generated/_cfg_accounts/schemas/index.ts +2 -0
  49. package/src/_api/generated/helpers/keys.ts +1 -0
  50. package/src/_api/generated/openapi.json +263 -19
  51. package/src/_api/generated/sdk.gen.ts +36 -4
  52. package/src/_api/generated/types.gen.ts +136 -11
  53. package/src/auth/__tests__/oauthErrors.test.ts +23 -0
  54. package/src/auth/__tests__/passwordLogin.test.tsx +1 -0
  55. package/src/auth/__tests__/useOAuthLogin.test.tsx +387 -0
  56. package/src/auth/hooks/index.ts +12 -1
  57. package/src/auth/hooks/useGithubAuth.ts +15 -225
  58. package/src/auth/hooks/useOAuthLogin.ts +237 -0
  59. package/src/auth/hooks/useOAuthProviders.ts +76 -0
  60. package/src/auth/utils/index.ts +8 -0
  61. package/src/auth/utils/oauthErrors.ts +45 -0
@@ -328,7 +328,7 @@
328
328
  "/cfg/accounts/oauth/github/authorize/": {
329
329
  "post": {
330
330
  "operationId": "cfg_accounts_oauth_github_authorize_create",
331
- "description": "Generate GitHub OAuth authorization URL. Redirect user to this URL to start authentication.",
331
+ "description": "Generate the GitHub authorization URL. Redirect the user to it to start authentication. The redirect URI is derived from the request Origin.",
332
332
  "summary": "Start GitHub OAuth",
333
333
  "tags": [
334
334
  "cfg_accounts_oauth"
@@ -356,6 +356,16 @@
356
356
  },
357
357
  "description": ""
358
358
  },
359
+ "400": {
360
+ "content": {
361
+ "application/json": {
362
+ "schema": {
363
+ "$ref": "#/components/schemas/OAuthError"
364
+ }
365
+ }
366
+ },
367
+ "description": ""
368
+ },
359
369
  "503": {
360
370
  "content": {
361
371
  "application/json": {
@@ -373,7 +383,7 @@
373
383
  "/cfg/accounts/oauth/github/callback/": {
374
384
  "post": {
375
385
  "operationId": "cfg_accounts_oauth_github_callback_create",
376
- "description": "Exchange authorization code for JWT tokens. Call this after GitHub redirects back with code.",
386
+ "description": "Exchange the authorization code for JWT tokens. Call this after GitHub redirects back with a code. The state is single use.",
377
387
  "summary": "Complete GitHub OAuth",
378
388
  "tags": [
379
389
  "cfg_accounts_oauth"
@@ -411,6 +421,187 @@
411
421
  }
412
422
  },
413
423
  "description": ""
424
+ },
425
+ "403": {
426
+ "content": {
427
+ "application/json": {
428
+ "schema": {
429
+ "$ref": "#/components/schemas/OAuthError"
430
+ }
431
+ }
432
+ },
433
+ "description": ""
434
+ },
435
+ "429": {
436
+ "content": {
437
+ "application/json": {
438
+ "schema": {
439
+ "$ref": "#/components/schemas/OAuthError"
440
+ }
441
+ }
442
+ },
443
+ "description": ""
444
+ },
445
+ "502": {
446
+ "content": {
447
+ "application/json": {
448
+ "schema": {
449
+ "$ref": "#/components/schemas/OAuthError"
450
+ }
451
+ }
452
+ },
453
+ "description": ""
454
+ },
455
+ "503": {
456
+ "content": {
457
+ "application/json": {
458
+ "schema": {
459
+ "$ref": "#/components/schemas/OAuthError"
460
+ }
461
+ }
462
+ },
463
+ "description": ""
464
+ }
465
+ },
466
+ "x-async-capable": false
467
+ }
468
+ },
469
+ "/cfg/accounts/oauth/google/authorize/": {
470
+ "post": {
471
+ "operationId": "cfg_accounts_oauth_google_authorize_create",
472
+ "description": "Generate the Google authorization URL. Redirect the user to it to start authentication. The redirect URI is derived from the request Origin.",
473
+ "summary": "Start Google OAuth",
474
+ "tags": [
475
+ "cfg_accounts_oauth"
476
+ ],
477
+ "requestBody": {
478
+ "content": {
479
+ "application/json": {
480
+ "schema": {
481
+ "$ref": "#/components/schemas/OAuthAuthorizeRequestRequest"
482
+ }
483
+ }
484
+ }
485
+ },
486
+ "security": [
487
+ {}
488
+ ],
489
+ "responses": {
490
+ "200": {
491
+ "content": {
492
+ "application/json": {
493
+ "schema": {
494
+ "$ref": "#/components/schemas/OAuthAuthorizeResponse"
495
+ }
496
+ }
497
+ },
498
+ "description": ""
499
+ },
500
+ "400": {
501
+ "content": {
502
+ "application/json": {
503
+ "schema": {
504
+ "$ref": "#/components/schemas/OAuthError"
505
+ }
506
+ }
507
+ },
508
+ "description": ""
509
+ },
510
+ "503": {
511
+ "content": {
512
+ "application/json": {
513
+ "schema": {
514
+ "$ref": "#/components/schemas/OAuthError"
515
+ }
516
+ }
517
+ },
518
+ "description": ""
519
+ }
520
+ },
521
+ "x-async-capable": false
522
+ }
523
+ },
524
+ "/cfg/accounts/oauth/google/callback/": {
525
+ "post": {
526
+ "operationId": "cfg_accounts_oauth_google_callback_create",
527
+ "description": "Exchange the authorization code for JWT tokens. Call this after Google redirects back with a code. The state is single use.",
528
+ "summary": "Complete Google OAuth",
529
+ "tags": [
530
+ "cfg_accounts_oauth"
531
+ ],
532
+ "requestBody": {
533
+ "content": {
534
+ "application/json": {
535
+ "schema": {
536
+ "$ref": "#/components/schemas/OAuthCallbackRequestRequest"
537
+ }
538
+ }
539
+ },
540
+ "required": true
541
+ },
542
+ "security": [
543
+ {}
544
+ ],
545
+ "responses": {
546
+ "200": {
547
+ "content": {
548
+ "application/json": {
549
+ "schema": {
550
+ "$ref": "#/components/schemas/OAuthTokenResponse"
551
+ }
552
+ }
553
+ },
554
+ "description": ""
555
+ },
556
+ "400": {
557
+ "content": {
558
+ "application/json": {
559
+ "schema": {
560
+ "$ref": "#/components/schemas/OAuthError"
561
+ }
562
+ }
563
+ },
564
+ "description": ""
565
+ },
566
+ "403": {
567
+ "content": {
568
+ "application/json": {
569
+ "schema": {
570
+ "$ref": "#/components/schemas/OAuthError"
571
+ }
572
+ }
573
+ },
574
+ "description": ""
575
+ },
576
+ "429": {
577
+ "content": {
578
+ "application/json": {
579
+ "schema": {
580
+ "$ref": "#/components/schemas/OAuthError"
581
+ }
582
+ }
583
+ },
584
+ "description": ""
585
+ },
586
+ "502": {
587
+ "content": {
588
+ "application/json": {
589
+ "schema": {
590
+ "$ref": "#/components/schemas/OAuthError"
591
+ }
592
+ }
593
+ },
594
+ "description": ""
595
+ },
596
+ "503": {
597
+ "content": {
598
+ "application/json": {
599
+ "schema": {
600
+ "$ref": "#/components/schemas/OAuthError"
601
+ }
602
+ }
603
+ },
604
+ "description": ""
414
605
  }
415
606
  },
416
607
  "x-async-capable": false
@@ -419,7 +610,7 @@
419
610
  "/cfg/accounts/oauth/providers/": {
420
611
  "get": {
421
612
  "operationId": "cfg_accounts_oauth_providers_retrieve",
422
- "description": "Get list of available OAuth providers for authentication.",
613
+ "description": "Providers that are configured, in display order. The login screen shows exactly these buttons.",
423
614
  "summary": "List OAuth providers",
424
615
  "tags": [
425
616
  "cfg_accounts_oauth"
@@ -2050,7 +2241,7 @@
2050
2241
  "redirect_uri": {
2051
2242
  "type": "string",
2052
2243
  "format": "uri",
2053
- "description": "URL to redirect after OAuth authorization. If not provided, uses config's site_url + callback_path"
2244
+ "description": "Optional. Must be `<origin>/auth?provider=<id>` for an origin of the resolved site; anything else is rejected with `origin_not_allowed`. Omit it: the server derives it from the request Origin."
2054
2245
  },
2055
2246
  "source_url": {
2056
2247
  "type": "string",
@@ -2084,20 +2275,20 @@
2084
2275
  "properties": {
2085
2276
  "code": {
2086
2277
  "type": "string",
2087
- "minLength": 10,
2278
+ "minLength": 1,
2088
2279
  "description": "Authorization code from OAuth provider callback",
2089
- "maxLength": 500
2280
+ "maxLength": 2048
2090
2281
  },
2091
2282
  "state": {
2092
2283
  "type": "string",
2093
- "minLength": 20,
2094
- "description": "State token for CSRF verification (from authorize response)",
2095
- "maxLength": 100
2284
+ "minLength": 1,
2285
+ "description": "State token from the authorize response; single use",
2286
+ "maxLength": 64
2096
2287
  },
2097
2288
  "redirect_uri": {
2098
2289
  "type": "string",
2099
2290
  "format": "uri",
2100
- "description": "Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path"
2291
+ "description": "Ignored. The server reuses the redirect URI stored with the state."
2101
2292
  }
2102
2293
  },
2103
2294
  "required": [
@@ -2120,7 +2311,7 @@
2120
2311
  }
2121
2312
  ],
2122
2313
  "readOnly": true,
2123
- "description": "OAuth provider name (github, google, etc.)\n\n* `github` - GitHub"
2314
+ "description": "OAuth provider name (github, google, etc.)\n\n* `github` - GitHub\n* `google` - Google"
2124
2315
  },
2125
2316
  "provider_display": {
2126
2317
  "type": "string",
@@ -2177,7 +2368,7 @@
2177
2368
  "$ref": "#/components/schemas/OAuthProviderEnum"
2178
2369
  }
2179
2370
  ],
2180
- "description": "OAuth provider to disconnect\n\n* `github` - GitHub"
2371
+ "description": "OAuth provider to disconnect\n\n* `github` - GitHub\n* `google` - Google"
2181
2372
  }
2182
2373
  },
2183
2374
  "required": [
@@ -2189,8 +2380,12 @@
2189
2380
  "description": "Error response for OAuth endpoints.",
2190
2381
  "properties": {
2191
2382
  "error": {
2192
- "type": "string",
2193
- "description": "Error code"
2383
+ "allOf": [
2384
+ {
2385
+ "$ref": "#/components/schemas/OAuthErrorCodeEnum"
2386
+ }
2387
+ ],
2388
+ "description": "Error code (closed set)\n\n* `oauth_disabled` - oauth_disabled\n* `github_oauth_disabled` - github_oauth_disabled\n* `origin_not_allowed` - origin_not_allowed\n* `missing_redirect_uri` - missing_redirect_uri\n* `invalid_state` - invalid_state\n* `oauth_exchange_failed` - oauth_exchange_failed\n* `invalid_id_token` - invalid_id_token\n* `email_missing` - email_missing\n* `email_not_verified` - email_not_verified\n* `hosted_domain_not_allowed` - hosted_domain_not_allowed\n* `account_inactive` - account_inactive\n* `link_not_allowed` - link_not_allowed\n* `rate_limited` - rate_limited\n* `provider_unavailable` - provider_unavailable\n* `server_error` - server_error\n* `not_found` - not_found"
2194
2389
  },
2195
2390
  "error_description": {
2196
2391
  "type": "string",
@@ -2201,12 +2396,62 @@
2201
2396
  "error"
2202
2397
  ]
2203
2398
  },
2399
+ "OAuthErrorCodeEnum": {
2400
+ "enum": [
2401
+ "oauth_disabled",
2402
+ "github_oauth_disabled",
2403
+ "origin_not_allowed",
2404
+ "missing_redirect_uri",
2405
+ "invalid_state",
2406
+ "oauth_exchange_failed",
2407
+ "invalid_id_token",
2408
+ "email_missing",
2409
+ "email_not_verified",
2410
+ "hosted_domain_not_allowed",
2411
+ "account_inactive",
2412
+ "link_not_allowed",
2413
+ "rate_limited",
2414
+ "provider_unavailable",
2415
+ "server_error",
2416
+ "not_found"
2417
+ ],
2418
+ "type": "string",
2419
+ "description": "* `oauth_disabled` - oauth_disabled\n* `github_oauth_disabled` - github_oauth_disabled\n* `origin_not_allowed` - origin_not_allowed\n* `missing_redirect_uri` - missing_redirect_uri\n* `invalid_state` - invalid_state\n* `oauth_exchange_failed` - oauth_exchange_failed\n* `invalid_id_token` - invalid_id_token\n* `email_missing` - email_missing\n* `email_not_verified` - email_not_verified\n* `hosted_domain_not_allowed` - hosted_domain_not_allowed\n* `account_inactive` - account_inactive\n* `link_not_allowed` - link_not_allowed\n* `rate_limited` - rate_limited\n* `provider_unavailable` - provider_unavailable\n* `server_error` - server_error\n* `not_found` - not_found"
2420
+ },
2204
2421
  "OAuthProviderEnum": {
2205
2422
  "enum": [
2206
- "github"
2423
+ "github",
2424
+ "google"
2207
2425
  ],
2208
2426
  "type": "string",
2209
- "description": "* `github` - GitHub"
2427
+ "description": "* `github` - GitHub\n* `google` - Google"
2428
+ },
2429
+ "OAuthProviderInfo": {
2430
+ "type": "object",
2431
+ "description": "One enabled sign-in provider.",
2432
+ "properties": {
2433
+ "id": {
2434
+ "allOf": [
2435
+ {
2436
+ "$ref": "#/components/schemas/OAuthProviderEnum"
2437
+ }
2438
+ ],
2439
+ "description": "Provider id\n\n* `github` - GitHub\n* `google` - Google"
2440
+ },
2441
+ "name": {
2442
+ "type": "string",
2443
+ "description": "Display name"
2444
+ },
2445
+ "icon": {
2446
+ "type": "string",
2447
+ "description": "Icon key"
2448
+ }
2449
+ },
2450
+ "required": [
2451
+ "icon",
2452
+ "id",
2453
+ "name"
2454
+ ]
2210
2455
  },
2211
2456
  "OAuthProvidersResponse": {
2212
2457
  "type": "object",
@@ -2215,10 +2460,9 @@
2215
2460
  "providers": {
2216
2461
  "type": "array",
2217
2462
  "items": {
2218
- "type": "object",
2219
- "additionalProperties": {}
2463
+ "$ref": "#/components/schemas/OAuthProviderInfo"
2220
2464
  },
2221
- "description": "List of available OAuth providers"
2465
+ "description": "Providers that are configured, in display order. The login screen shows exactly these."
2222
2466
  }
2223
2467
  },
2224
2468
  "required": [
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { type Client, type ClientMeta, formDataBodySerializer, type Options as Options2, type RequestResult, type TDataShape } from './client';
4
4
  import { client } from './client.gen';
5
- import type { CfgAccountsApiKeyRegenerateCreateData, CfgAccountsApiKeyRegenerateCreateErrors, CfgAccountsApiKeyRegenerateCreateResponses, CfgAccountsApiKeyRetrieveData, CfgAccountsApiKeyRetrieveErrors, CfgAccountsApiKeyRetrieveResponses, CfgAccountsApiKeyRevealCreateData, CfgAccountsApiKeyRevealCreateErrors, CfgAccountsApiKeyRevealCreateResponses, CfgAccountsApiKeyTestCreateData, CfgAccountsApiKeyTestCreateResponses, CfgAccountsOauthConnectionsListData, CfgAccountsOauthConnectionsListResponses, CfgAccountsOauthDisconnectCreateData, CfgAccountsOauthDisconnectCreateErrors, CfgAccountsOauthDisconnectCreateResponses, CfgAccountsOauthGithubAuthorizeCreateData, CfgAccountsOauthGithubAuthorizeCreateErrors, CfgAccountsOauthGithubAuthorizeCreateResponses, CfgAccountsOauthGithubCallbackCreateData, CfgAccountsOauthGithubCallbackCreateErrors, CfgAccountsOauthGithubCallbackCreateResponses, CfgAccountsOauthProvidersRetrieveData, CfgAccountsOauthProvidersRetrieveResponses, CfgAccountsOtpConsentPolicyRetrieveData, CfgAccountsOtpConsentPolicyRetrieveResponses, CfgAccountsOtpRequestCreateData, CfgAccountsOtpRequestCreateErrors, CfgAccountsOtpRequestCreateResponses, CfgAccountsOtpVerifyCreateData, CfgAccountsOtpVerifyCreateErrors, CfgAccountsOtpVerifyCreateResponses, CfgAccountsProfileAvatarCreateData, CfgAccountsProfileAvatarCreateErrors, CfgAccountsProfileAvatarCreateResponses, CfgAccountsProfileDeleteCreateData, CfgAccountsProfileDeleteCreateErrors, CfgAccountsProfileDeleteCreateResponses, CfgAccountsProfilePartialPartialUpdateData, CfgAccountsProfilePartialPartialUpdateErrors, CfgAccountsProfilePartialPartialUpdateResponses, CfgAccountsProfilePartialUpdateData, CfgAccountsProfilePartialUpdateErrors, CfgAccountsProfilePartialUpdateResponses, CfgAccountsProfileRetrieveData, CfgAccountsProfileRetrieveErrors, CfgAccountsProfileRetrieveResponses, CfgAccountsProfileUpdatePartialUpdateData, CfgAccountsProfileUpdatePartialUpdateErrors, CfgAccountsProfileUpdatePartialUpdateResponses, CfgAccountsProfileUpdateUpdateData, CfgAccountsProfileUpdateUpdateErrors, CfgAccountsProfileUpdateUpdateResponses, CfgAccountsTokenBlacklistCreateData, CfgAccountsTokenBlacklistCreateResponses, CfgAccountsTokenCreateData, CfgAccountsTokenCreateErrors, CfgAccountsTokenCreateResponses, CfgAccountsTokenRefreshCreateData, CfgAccountsTokenRefreshCreateResponses, CfgTotpBackupCodesRegenerateCreateData, CfgTotpBackupCodesRegenerateCreateErrors, CfgTotpBackupCodesRegenerateCreateResponses, CfgTotpBackupCodesRetrieveData, CfgTotpBackupCodesRetrieveResponses, CfgTotpDevicesDestroyData, CfgTotpDevicesDestroyResponses, CfgTotpDevicesRetrieveData, CfgTotpDevicesRetrieveResponses, CfgTotpDisableCreateData, CfgTotpDisableCreateErrors, CfgTotpDisableCreateResponses, CfgTotpSetupConfirmCreateData, CfgTotpSetupConfirmCreateErrors, CfgTotpSetupConfirmCreateResponses, CfgTotpSetupCreateData, CfgTotpSetupCreateErrors, CfgTotpSetupCreateResponses, CfgTotpVerifyBackupCreateData, CfgTotpVerifyBackupCreateErrors, CfgTotpVerifyBackupCreateResponses, CfgTotpVerifyCreateData, CfgTotpVerifyCreateErrors, CfgTotpVerifyCreateResponses } from './types.gen';
5
+ import type { CfgAccountsApiKeyRegenerateCreateData, CfgAccountsApiKeyRegenerateCreateErrors, CfgAccountsApiKeyRegenerateCreateResponses, CfgAccountsApiKeyRetrieveData, CfgAccountsApiKeyRetrieveErrors, CfgAccountsApiKeyRetrieveResponses, CfgAccountsApiKeyRevealCreateData, CfgAccountsApiKeyRevealCreateErrors, CfgAccountsApiKeyRevealCreateResponses, CfgAccountsApiKeyTestCreateData, CfgAccountsApiKeyTestCreateResponses, CfgAccountsOauthConnectionsListData, CfgAccountsOauthConnectionsListResponses, CfgAccountsOauthDisconnectCreateData, CfgAccountsOauthDisconnectCreateErrors, CfgAccountsOauthDisconnectCreateResponses, CfgAccountsOauthGithubAuthorizeCreateData, CfgAccountsOauthGithubAuthorizeCreateErrors, CfgAccountsOauthGithubAuthorizeCreateResponses, CfgAccountsOauthGithubCallbackCreateData, CfgAccountsOauthGithubCallbackCreateErrors, CfgAccountsOauthGithubCallbackCreateResponses, CfgAccountsOauthGoogleAuthorizeCreateData, CfgAccountsOauthGoogleAuthorizeCreateErrors, CfgAccountsOauthGoogleAuthorizeCreateResponses, CfgAccountsOauthGoogleCallbackCreateData, CfgAccountsOauthGoogleCallbackCreateErrors, CfgAccountsOauthGoogleCallbackCreateResponses, CfgAccountsOauthProvidersRetrieveData, CfgAccountsOauthProvidersRetrieveResponses, CfgAccountsOtpConsentPolicyRetrieveData, CfgAccountsOtpConsentPolicyRetrieveResponses, CfgAccountsOtpRequestCreateData, CfgAccountsOtpRequestCreateErrors, CfgAccountsOtpRequestCreateResponses, CfgAccountsOtpVerifyCreateData, CfgAccountsOtpVerifyCreateErrors, CfgAccountsOtpVerifyCreateResponses, CfgAccountsProfileAvatarCreateData, CfgAccountsProfileAvatarCreateErrors, CfgAccountsProfileAvatarCreateResponses, CfgAccountsProfileDeleteCreateData, CfgAccountsProfileDeleteCreateErrors, CfgAccountsProfileDeleteCreateResponses, CfgAccountsProfilePartialPartialUpdateData, CfgAccountsProfilePartialPartialUpdateErrors, CfgAccountsProfilePartialPartialUpdateResponses, CfgAccountsProfilePartialUpdateData, CfgAccountsProfilePartialUpdateErrors, CfgAccountsProfilePartialUpdateResponses, CfgAccountsProfileRetrieveData, CfgAccountsProfileRetrieveErrors, CfgAccountsProfileRetrieveResponses, CfgAccountsProfileUpdatePartialUpdateData, CfgAccountsProfileUpdatePartialUpdateErrors, CfgAccountsProfileUpdatePartialUpdateResponses, CfgAccountsProfileUpdateUpdateData, CfgAccountsProfileUpdateUpdateErrors, CfgAccountsProfileUpdateUpdateResponses, CfgAccountsTokenBlacklistCreateData, CfgAccountsTokenBlacklistCreateResponses, CfgAccountsTokenCreateData, CfgAccountsTokenCreateErrors, CfgAccountsTokenCreateResponses, CfgAccountsTokenRefreshCreateData, CfgAccountsTokenRefreshCreateResponses, CfgTotpBackupCodesRegenerateCreateData, CfgTotpBackupCodesRegenerateCreateErrors, CfgTotpBackupCodesRegenerateCreateResponses, CfgTotpBackupCodesRetrieveData, CfgTotpBackupCodesRetrieveResponses, CfgTotpDevicesDestroyData, CfgTotpDevicesDestroyResponses, CfgTotpDevicesRetrieveData, CfgTotpDevicesRetrieveResponses, CfgTotpDisableCreateData, CfgTotpDisableCreateErrors, CfgTotpDisableCreateResponses, CfgTotpSetupConfirmCreateData, CfgTotpSetupConfirmCreateErrors, CfgTotpSetupConfirmCreateResponses, CfgTotpSetupCreateData, CfgTotpSetupCreateErrors, CfgTotpSetupCreateResponses, CfgTotpVerifyBackupCreateData, CfgTotpVerifyBackupCreateErrors, CfgTotpVerifyBackupCreateResponses, CfgTotpVerifyCreateData, CfgTotpVerifyCreateErrors, CfgTotpVerifyCreateResponses } from './types.gen';
6
6
 
7
7
  export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
8
8
  /**
@@ -158,7 +158,7 @@ export class CfgAccountsOauth {
158
158
  /**
159
159
  * Start GitHub OAuth
160
160
  *
161
- * Generate GitHub OAuth authorization URL. Redirect user to this URL to start authentication.
161
+ * Generate the GitHub authorization URL. Redirect the user to it to start authentication. The redirect URI is derived from the request Origin.
162
162
  */
163
163
  public static cfgAccountsOauthGithubAuthorizeCreate<ThrowOnError extends boolean = false>(options?: Options<CfgAccountsOauthGithubAuthorizeCreateData, ThrowOnError>): RequestResult<CfgAccountsOauthGithubAuthorizeCreateResponses, CfgAccountsOauthGithubAuthorizeCreateErrors, ThrowOnError> {
164
164
  return (options?.client ?? client).post<CfgAccountsOauthGithubAuthorizeCreateResponses, CfgAccountsOauthGithubAuthorizeCreateErrors, ThrowOnError>({
@@ -174,7 +174,7 @@ export class CfgAccountsOauth {
174
174
  /**
175
175
  * Complete GitHub OAuth
176
176
  *
177
- * Exchange authorization code for JWT tokens. Call this after GitHub redirects back with code.
177
+ * Exchange the authorization code for JWT tokens. Call this after GitHub redirects back with a code. The state is single use.
178
178
  */
179
179
  public static cfgAccountsOauthGithubCallbackCreate<ThrowOnError extends boolean = false>(options: Options<CfgAccountsOauthGithubCallbackCreateData, ThrowOnError>): RequestResult<CfgAccountsOauthGithubCallbackCreateResponses, CfgAccountsOauthGithubCallbackCreateErrors, ThrowOnError> {
180
180
  return (options.client ?? client).post<CfgAccountsOauthGithubCallbackCreateResponses, CfgAccountsOauthGithubCallbackCreateErrors, ThrowOnError>({
@@ -187,10 +187,42 @@ export class CfgAccountsOauth {
187
187
  });
188
188
  }
189
189
 
190
+ /**
191
+ * Start Google OAuth
192
+ *
193
+ * Generate the Google authorization URL. Redirect the user to it to start authentication. The redirect URI is derived from the request Origin.
194
+ */
195
+ public static cfgAccountsOauthGoogleAuthorizeCreate<ThrowOnError extends boolean = false>(options?: Options<CfgAccountsOauthGoogleAuthorizeCreateData, ThrowOnError>): RequestResult<CfgAccountsOauthGoogleAuthorizeCreateResponses, CfgAccountsOauthGoogleAuthorizeCreateErrors, ThrowOnError> {
196
+ return (options?.client ?? client).post<CfgAccountsOauthGoogleAuthorizeCreateResponses, CfgAccountsOauthGoogleAuthorizeCreateErrors, ThrowOnError>({
197
+ url: '/cfg/accounts/oauth/google/authorize/',
198
+ ...options,
199
+ headers: {
200
+ 'Content-Type': 'application/json',
201
+ ...options?.headers
202
+ }
203
+ });
204
+ }
205
+
206
+ /**
207
+ * Complete Google OAuth
208
+ *
209
+ * Exchange the authorization code for JWT tokens. Call this after Google redirects back with a code. The state is single use.
210
+ */
211
+ public static cfgAccountsOauthGoogleCallbackCreate<ThrowOnError extends boolean = false>(options: Options<CfgAccountsOauthGoogleCallbackCreateData, ThrowOnError>): RequestResult<CfgAccountsOauthGoogleCallbackCreateResponses, CfgAccountsOauthGoogleCallbackCreateErrors, ThrowOnError> {
212
+ return (options.client ?? client).post<CfgAccountsOauthGoogleCallbackCreateResponses, CfgAccountsOauthGoogleCallbackCreateErrors, ThrowOnError>({
213
+ url: '/cfg/accounts/oauth/google/callback/',
214
+ ...options,
215
+ headers: {
216
+ 'Content-Type': 'application/json',
217
+ ...options.headers
218
+ }
219
+ });
220
+ }
221
+
190
222
  /**
191
223
  * List OAuth providers
192
224
  *
193
- * Get list of available OAuth providers for authentication.
225
+ * Providers that are configured, in display order. The login screen shows exactly these buttons.
194
226
  */
195
227
  public static cfgAccountsOauthProvidersRetrieve<ThrowOnError extends boolean = false>(options?: Options<CfgAccountsOauthProvidersRetrieveData, ThrowOnError>): RequestResult<CfgAccountsOauthProvidersRetrieveResponses, unknown, ThrowOnError> {
196
228
  return (options?.client ?? client).get<CfgAccountsOauthProvidersRetrieveResponses, unknown, ThrowOnError>({ url: '/cfg/accounts/oauth/providers/', ...options });
@@ -282,7 +282,7 @@ export enum MarketingConsentDefaultEnum {
282
282
  */
283
283
  export type OAuthAuthorizeRequestRequest = {
284
284
  /**
285
- * URL to redirect after OAuth authorization. If not provided, uses config's site_url + callback_path
285
+ * Optional. Must be `<origin>/auth?provider=<id>` for an origin of the resolved site; anything else is rejected with `origin_not_allowed`. Omit it: the server derives it from the request Origin.
286
286
  */
287
287
  redirect_uri?: string;
288
288
  /**
@@ -314,11 +314,11 @@ export type OAuthCallbackRequestRequest = {
314
314
  */
315
315
  code: string;
316
316
  /**
317
- * State token for CSRF verification (from authorize response)
317
+ * State token from the authorize response; single use
318
318
  */
319
319
  state: string;
320
320
  /**
321
- * Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path
321
+ * Ignored. The server reuses the redirect URI stored with the state.
322
322
  */
323
323
  redirect_uri?: string;
324
324
  };
@@ -332,6 +332,7 @@ export type OAuthConnection = {
332
332
  * OAuth provider name (github, google, etc.)
333
333
  *
334
334
  * * `github` - GitHub
335
+ * * `google` - Google
335
336
  */
336
337
  readonly provider: OAuthProviderEnum;
337
338
  readonly provider_display: string;
@@ -365,6 +366,7 @@ export type OAuthDisconnectRequestRequest = {
365
366
  * OAuth provider to disconnect
366
367
  *
367
368
  * * `github` - GitHub
369
+ * * `google` - Google
368
370
  */
369
371
  provider: OAuthProviderEnum;
370
372
  };
@@ -374,32 +376,107 @@ export type OAuthDisconnectRequestRequest = {
374
376
  */
375
377
  export type OAuthError = {
376
378
  /**
377
- * Error code
378
- */
379
- error: string;
379
+ * Error code (closed set)
380
+ *
381
+ * * `oauth_disabled` - oauth_disabled
382
+ * * `github_oauth_disabled` - github_oauth_disabled
383
+ * * `origin_not_allowed` - origin_not_allowed
384
+ * * `missing_redirect_uri` - missing_redirect_uri
385
+ * * `invalid_state` - invalid_state
386
+ * * `oauth_exchange_failed` - oauth_exchange_failed
387
+ * * `invalid_id_token` - invalid_id_token
388
+ * * `email_missing` - email_missing
389
+ * * `email_not_verified` - email_not_verified
390
+ * * `hosted_domain_not_allowed` - hosted_domain_not_allowed
391
+ * * `account_inactive` - account_inactive
392
+ * * `link_not_allowed` - link_not_allowed
393
+ * * `rate_limited` - rate_limited
394
+ * * `provider_unavailable` - provider_unavailable
395
+ * * `server_error` - server_error
396
+ * * `not_found` - not_found
397
+ */
398
+ error: OAuthErrorCodeEnum;
380
399
  /**
381
400
  * Human-readable error description
382
401
  */
383
402
  error_description?: string;
384
403
  };
385
404
 
405
+ /**
406
+ * * `oauth_disabled` - oauth_disabled
407
+ * * `github_oauth_disabled` - github_oauth_disabled
408
+ * * `origin_not_allowed` - origin_not_allowed
409
+ * * `missing_redirect_uri` - missing_redirect_uri
410
+ * * `invalid_state` - invalid_state
411
+ * * `oauth_exchange_failed` - oauth_exchange_failed
412
+ * * `invalid_id_token` - invalid_id_token
413
+ * * `email_missing` - email_missing
414
+ * * `email_not_verified` - email_not_verified
415
+ * * `hosted_domain_not_allowed` - hosted_domain_not_allowed
416
+ * * `account_inactive` - account_inactive
417
+ * * `link_not_allowed` - link_not_allowed
418
+ * * `rate_limited` - rate_limited
419
+ * * `provider_unavailable` - provider_unavailable
420
+ * * `server_error` - server_error
421
+ * * `not_found` - not_found
422
+ */
423
+ export enum OAuthErrorCodeEnum {
424
+ OAUTH_DISABLED = 'oauth_disabled',
425
+ GITHUB_OAUTH_DISABLED = 'github_oauth_disabled',
426
+ ORIGIN_NOT_ALLOWED = 'origin_not_allowed',
427
+ MISSING_REDIRECT_URI = 'missing_redirect_uri',
428
+ INVALID_STATE = 'invalid_state',
429
+ OAUTH_EXCHANGE_FAILED = 'oauth_exchange_failed',
430
+ INVALID_ID_TOKEN = 'invalid_id_token',
431
+ EMAIL_MISSING = 'email_missing',
432
+ EMAIL_NOT_VERIFIED = 'email_not_verified',
433
+ HOSTED_DOMAIN_NOT_ALLOWED = 'hosted_domain_not_allowed',
434
+ ACCOUNT_INACTIVE = 'account_inactive',
435
+ LINK_NOT_ALLOWED = 'link_not_allowed',
436
+ RATE_LIMITED = 'rate_limited',
437
+ PROVIDER_UNAVAILABLE = 'provider_unavailable',
438
+ SERVER_ERROR = 'server_error',
439
+ NOT_FOUND = 'not_found'
440
+ }
441
+
386
442
  /**
387
443
  * * `github` - GitHub
444
+ * * `google` - Google
388
445
  */
389
446
  export enum OAuthProviderEnum {
390
- GITHUB = 'github'
447
+ GITHUB = 'github',
448
+ GOOGLE = 'google'
391
449
  }
392
450
 
451
+ /**
452
+ * One enabled sign-in provider.
453
+ */
454
+ export type OAuthProviderInfo = {
455
+ /**
456
+ * Provider id
457
+ *
458
+ * * `github` - GitHub
459
+ * * `google` - Google
460
+ */
461
+ id: OAuthProviderEnum;
462
+ /**
463
+ * Display name
464
+ */
465
+ name: string;
466
+ /**
467
+ * Icon key
468
+ */
469
+ icon: string;
470
+ };
471
+
393
472
  /**
394
473
  * Response with available OAuth providers.
395
474
  */
396
475
  export type OAuthProvidersResponse = {
397
476
  /**
398
- * List of available OAuth providers
477
+ * Providers that are configured, in display order. The login screen shows exactly these.
399
478
  */
400
- providers: Array<{
401
- [key: string]: unknown;
402
- }>;
479
+ providers: Array<OAuthProviderInfo>;
403
480
  };
404
481
 
405
482
  /**
@@ -1244,6 +1321,7 @@ export type CfgAccountsOauthGithubAuthorizeCreateData = {
1244
1321
  };
1245
1322
 
1246
1323
  export type CfgAccountsOauthGithubAuthorizeCreateErrors = {
1324
+ 400: OAuthError;
1247
1325
  503: OAuthError;
1248
1326
  };
1249
1327
 
@@ -1264,6 +1342,10 @@ export type CfgAccountsOauthGithubCallbackCreateData = {
1264
1342
 
1265
1343
  export type CfgAccountsOauthGithubCallbackCreateErrors = {
1266
1344
  400: OAuthError;
1345
+ 403: OAuthError;
1346
+ 429: OAuthError;
1347
+ 502: OAuthError;
1348
+ 503: OAuthError;
1267
1349
  };
1268
1350
 
1269
1351
  export type CfgAccountsOauthGithubCallbackCreateError = CfgAccountsOauthGithubCallbackCreateErrors[keyof CfgAccountsOauthGithubCallbackCreateErrors];
@@ -1274,6 +1356,49 @@ export type CfgAccountsOauthGithubCallbackCreateResponses = {
1274
1356
 
1275
1357
  export type CfgAccountsOauthGithubCallbackCreateResponse = CfgAccountsOauthGithubCallbackCreateResponses[keyof CfgAccountsOauthGithubCallbackCreateResponses];
1276
1358
 
1359
+ export type CfgAccountsOauthGoogleAuthorizeCreateData = {
1360
+ body?: OAuthAuthorizeRequestRequest;
1361
+ path?: never;
1362
+ query?: never;
1363
+ url: '/cfg/accounts/oauth/google/authorize/';
1364
+ };
1365
+
1366
+ export type CfgAccountsOauthGoogleAuthorizeCreateErrors = {
1367
+ 400: OAuthError;
1368
+ 503: OAuthError;
1369
+ };
1370
+
1371
+ export type CfgAccountsOauthGoogleAuthorizeCreateError = CfgAccountsOauthGoogleAuthorizeCreateErrors[keyof CfgAccountsOauthGoogleAuthorizeCreateErrors];
1372
+
1373
+ export type CfgAccountsOauthGoogleAuthorizeCreateResponses = {
1374
+ 200: OAuthAuthorizeResponse;
1375
+ };
1376
+
1377
+ export type CfgAccountsOauthGoogleAuthorizeCreateResponse = CfgAccountsOauthGoogleAuthorizeCreateResponses[keyof CfgAccountsOauthGoogleAuthorizeCreateResponses];
1378
+
1379
+ export type CfgAccountsOauthGoogleCallbackCreateData = {
1380
+ body: OAuthCallbackRequestRequest;
1381
+ path?: never;
1382
+ query?: never;
1383
+ url: '/cfg/accounts/oauth/google/callback/';
1384
+ };
1385
+
1386
+ export type CfgAccountsOauthGoogleCallbackCreateErrors = {
1387
+ 400: OAuthError;
1388
+ 403: OAuthError;
1389
+ 429: OAuthError;
1390
+ 502: OAuthError;
1391
+ 503: OAuthError;
1392
+ };
1393
+
1394
+ export type CfgAccountsOauthGoogleCallbackCreateError = CfgAccountsOauthGoogleCallbackCreateErrors[keyof CfgAccountsOauthGoogleCallbackCreateErrors];
1395
+
1396
+ export type CfgAccountsOauthGoogleCallbackCreateResponses = {
1397
+ 200: OAuthTokenResponse;
1398
+ };
1399
+
1400
+ export type CfgAccountsOauthGoogleCallbackCreateResponse = CfgAccountsOauthGoogleCallbackCreateResponses[keyof CfgAccountsOauthGoogleCallbackCreateResponses];
1401
+
1277
1402
  export type CfgAccountsOauthProvidersRetrieveData = {
1278
1403
  body?: never;
1279
1404
  path?: never;