@stackframe/stack 2.6.27 → 2.6.29

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 (58) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/components/message-cards/known-error-message-card.js +2 -2
  3. package/dist/components/message-cards/known-error-message-card.js.map +1 -1
  4. package/dist/components/message-cards/predefined-message-card.js +5 -5
  5. package/dist/components/message-cards/predefined-message-card.js.map +1 -1
  6. package/dist/components-page/account-settings.js +56 -36
  7. package/dist/components-page/account-settings.js.map +1 -1
  8. package/dist/components-page/email-verification.js +3 -3
  9. package/dist/components-page/email-verification.js.map +1 -1
  10. package/dist/components-page/error-page.js +6 -6
  11. package/dist/components-page/error-page.js.map +1 -1
  12. package/dist/components-page/magic-link-callback.js +4 -4
  13. package/dist/components-page/magic-link-callback.js.map +1 -1
  14. package/dist/components-page/team-invitation.js +2 -2
  15. package/dist/components-page/team-invitation.js.map +1 -1
  16. package/dist/esm/components/message-cards/known-error-message-card.js +2 -2
  17. package/dist/esm/components/message-cards/known-error-message-card.js.map +1 -1
  18. package/dist/esm/components/message-cards/predefined-message-card.js +5 -5
  19. package/dist/esm/components/message-cards/predefined-message-card.js.map +1 -1
  20. package/dist/esm/components-page/account-settings.js +58 -38
  21. package/dist/esm/components-page/account-settings.js.map +1 -1
  22. package/dist/esm/components-page/email-verification.js +3 -3
  23. package/dist/esm/components-page/email-verification.js.map +1 -1
  24. package/dist/esm/components-page/error-page.js +6 -6
  25. package/dist/esm/components-page/error-page.js.map +1 -1
  26. package/dist/esm/components-page/magic-link-callback.js +4 -4
  27. package/dist/esm/components-page/magic-link-callback.js.map +1 -1
  28. package/dist/esm/components-page/team-invitation.js +2 -2
  29. package/dist/esm/components-page/team-invitation.js.map +1 -1
  30. package/dist/esm/generated/global-css.js +1 -1
  31. package/dist/esm/generated/global-css.js.map +1 -1
  32. package/dist/esm/generated/quetzal-translations.js +1233 -1221
  33. package/dist/esm/generated/quetzal-translations.js.map +1 -1
  34. package/dist/esm/lib/auth.js +2 -2
  35. package/dist/esm/lib/auth.js.map +1 -1
  36. package/dist/esm/lib/stack-app.js +50 -1
  37. package/dist/esm/lib/stack-app.js.map +1 -1
  38. package/dist/esm/providers/theme-provider.js +1 -0
  39. package/dist/esm/providers/theme-provider.js.map +1 -1
  40. package/dist/generated/global-css.d.mts +1 -1
  41. package/dist/generated/global-css.d.ts +1 -1
  42. package/dist/generated/global-css.js +1 -1
  43. package/dist/generated/global-css.js.map +1 -1
  44. package/dist/generated/quetzal-translations.d.mts +2 -2
  45. package/dist/generated/quetzal-translations.d.ts +2 -2
  46. package/dist/generated/quetzal-translations.js +1233 -1221
  47. package/dist/generated/quetzal-translations.js.map +1 -1
  48. package/dist/index.d.mts +1 -1
  49. package/dist/index.d.ts +1 -1
  50. package/dist/lib/auth.js +1 -1
  51. package/dist/lib/auth.js.map +1 -1
  52. package/dist/lib/stack-app.d.mts +9 -1
  53. package/dist/lib/stack-app.d.ts +9 -1
  54. package/dist/lib/stack-app.js +50 -1
  55. package/dist/lib/stack-app.js.map +1 -1
  56. package/dist/providers/theme-provider.js +1 -0
  57. package/dist/providers/theme-provider.js.map +1 -1
  58. package/package.json +4 -4
package/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@ export { default as StackProvider } from './providers/stack-provider.mjs';
2
2
  export { useStackApp, useUser } from './lib/hooks.mjs';
3
3
  export { default as StackHandler } from './components-page/stack-handler.mjs';
4
4
  export { StackTheme } from './providers/theme-provider.mjs';
5
- export { AdminDomainConfig, AdminEmailConfig, AdminOAuthProviderConfig, AdminOwnedProject, AdminProject, AdminProjectConfig, AdminProjectConfigUpdateOptions, AdminProjectCreateOptions, AdminProjectUpdateOptions, AdminTeamPermission, AdminTeamPermissionDefinition, AdminTeamPermissionDefinitionCreateOptions, AdminTeamPermissionDefinitionUpdateOptions, ApiKey, ApiKeyBase, ApiKeyBaseCrudRead, ApiKeyCreateOptions, ApiKeyFirstView, Connection, CurrentInternalServerUser, CurrentInternalUser, CurrentServerUser, CurrentUser, EditableTeamMemberProfile, GetUserOptions, HandlerUrls, OAuthConnection, OAuthProviderConfig, OAuthScopesOnSignIn, Project, ProjectConfig, ServerListUsersOptions, ServerTeam, ServerTeamCreateOptions, ServerTeamMemberProfile, ServerTeamUpdateOptions, ServerTeamUser, ServerUser, StackAdminApp, StackAdminAppConstructorOptions, StackClientApp, StackClientAppConstructorOptions, StackClientAppJson, StackServerApp, StackServerAppConstructorOptions, Team, TeamCreateOptions, TeamMemberProfile, TeamPermission, TeamUpdateOptions, TeamUser, TokenStoreInit, User, serverTeamPermissionDefinitionCreateOptionsToCrud, serverTeamPermissionDefinitionUpdateOptionsToCrud, stackAppInternalsSymbol } from './lib/stack-app.mjs';
5
+ export { AdminDomainConfig, AdminEmailConfig, AdminOAuthProviderConfig, AdminOwnedProject, AdminProject, AdminProjectConfig, AdminProjectConfigUpdateOptions, AdminProjectCreateOptions, AdminProjectUpdateOptions, AdminTeamPermission, AdminTeamPermissionDefinition, AdminTeamPermissionDefinitionCreateOptions, AdminTeamPermissionDefinitionUpdateOptions, ApiKey, ApiKeyBase, ApiKeyBaseCrudRead, ApiKeyCreateOptions, ApiKeyFirstView, Connection, CurrentInternalServerUser, CurrentInternalUser, CurrentServerUser, CurrentUser, EditableTeamMemberProfile, GetUserOptions, HandlerUrls, OAuthConnection, OAuthProviderConfig, OAuthScopesOnSignIn, Project, ProjectConfig, ServerListUsersOptions, ServerTeam, ServerTeamCreateOptions, ServerTeamMemberProfile, ServerTeamUpdateOptions, ServerTeamUser, ServerUser, StackAdminApp, StackAdminAppConstructorOptions, StackClientApp, StackClientAppConstructorOptions, StackClientAppJson, StackServerApp, StackServerAppConstructorOptions, Team, TeamCreateOptions, TeamInvitation, TeamMemberProfile, TeamPermission, TeamUpdateOptions, TeamUser, TokenStoreInit, User, serverTeamPermissionDefinitionCreateOptionsToCrud, serverTeamPermissionDefinitionUpdateOptionsToCrud, stackAppInternalsSymbol } from './lib/stack-app.mjs';
6
6
  export { SignIn } from './components-page/sign-in.mjs';
7
7
  export { SignUp } from './components-page/sign-up.mjs';
8
8
  export { EmailVerification } from './components-page/email-verification.mjs';
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export { default as StackProvider } from './providers/stack-provider.js';
2
2
  export { useStackApp, useUser } from './lib/hooks.js';
3
3
  export { default as StackHandler } from './components-page/stack-handler.js';
4
4
  export { StackTheme } from './providers/theme-provider.js';
5
- export { AdminDomainConfig, AdminEmailConfig, AdminOAuthProviderConfig, AdminOwnedProject, AdminProject, AdminProjectConfig, AdminProjectConfigUpdateOptions, AdminProjectCreateOptions, AdminProjectUpdateOptions, AdminTeamPermission, AdminTeamPermissionDefinition, AdminTeamPermissionDefinitionCreateOptions, AdminTeamPermissionDefinitionUpdateOptions, ApiKey, ApiKeyBase, ApiKeyBaseCrudRead, ApiKeyCreateOptions, ApiKeyFirstView, Connection, CurrentInternalServerUser, CurrentInternalUser, CurrentServerUser, CurrentUser, EditableTeamMemberProfile, GetUserOptions, HandlerUrls, OAuthConnection, OAuthProviderConfig, OAuthScopesOnSignIn, Project, ProjectConfig, ServerListUsersOptions, ServerTeam, ServerTeamCreateOptions, ServerTeamMemberProfile, ServerTeamUpdateOptions, ServerTeamUser, ServerUser, StackAdminApp, StackAdminAppConstructorOptions, StackClientApp, StackClientAppConstructorOptions, StackClientAppJson, StackServerApp, StackServerAppConstructorOptions, Team, TeamCreateOptions, TeamMemberProfile, TeamPermission, TeamUpdateOptions, TeamUser, TokenStoreInit, User, serverTeamPermissionDefinitionCreateOptionsToCrud, serverTeamPermissionDefinitionUpdateOptionsToCrud, stackAppInternalsSymbol } from './lib/stack-app.js';
5
+ export { AdminDomainConfig, AdminEmailConfig, AdminOAuthProviderConfig, AdminOwnedProject, AdminProject, AdminProjectConfig, AdminProjectConfigUpdateOptions, AdminProjectCreateOptions, AdminProjectUpdateOptions, AdminTeamPermission, AdminTeamPermissionDefinition, AdminTeamPermissionDefinitionCreateOptions, AdminTeamPermissionDefinitionUpdateOptions, ApiKey, ApiKeyBase, ApiKeyBaseCrudRead, ApiKeyCreateOptions, ApiKeyFirstView, Connection, CurrentInternalServerUser, CurrentInternalUser, CurrentServerUser, CurrentUser, EditableTeamMemberProfile, GetUserOptions, HandlerUrls, OAuthConnection, OAuthProviderConfig, OAuthScopesOnSignIn, Project, ProjectConfig, ServerListUsersOptions, ServerTeam, ServerTeamCreateOptions, ServerTeamMemberProfile, ServerTeamUpdateOptions, ServerTeamUser, ServerUser, StackAdminApp, StackAdminAppConstructorOptions, StackClientApp, StackClientAppConstructorOptions, StackClientAppJson, StackServerApp, StackServerAppConstructorOptions, Team, TeamCreateOptions, TeamInvitation, TeamMemberProfile, TeamPermission, TeamUpdateOptions, TeamUser, TokenStoreInit, User, serverTeamPermissionDefinitionCreateOptionsToCrud, serverTeamPermissionDefinitionUpdateOptionsToCrud, stackAppInternalsSymbol } from './lib/stack-app.js';
6
6
  export { SignIn } from './components-page/sign-in.js';
7
7
  export { SignUp } from './components-page/sign-up.js';
8
8
  export { EmailVerification } from './components-page/email-verification.js';
package/dist/lib/auth.js CHANGED
@@ -67,7 +67,7 @@ function consumeOAuthCallbackQueryParams() {
67
67
  const originalUrl = new URL(window.location.href);
68
68
  for (const param of requiredParams) {
69
69
  if (!originalUrl.searchParams.has(param)) {
70
- (0, import_errors.captureError)("consumeOAuthCallbackQueryParams", new Error(`Missing required query parameter on OAuth callback: ${param}`));
70
+ console.warn(new Error(`Missing required query parameter on OAuth callback: ${param}. Maybe you opened or reloaded the oauth-callback page from your history?`));
71
71
  return null;
72
72
  }
73
73
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/auth.ts"],"sourcesContent":["import { KnownError, StackClientInterface } from \"@stackframe/stack-shared\";\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport { StackAssertionError, captureError, throwErr } from \"@stackframe/stack-shared/dist/utils/errors\";\nimport { neverResolve } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { deindent } from \"@stackframe/stack-shared/dist/utils/strings\";\nimport { constructRedirectUrl } from \"../utils/url\";\nimport { consumeVerifierAndStateCookie, saveVerifierAndState } from \"./cookie\";\n\nexport async function signInWithOAuth(\n iface: StackClientInterface,\n options: {\n provider: string,\n redirectUrl: string,\n errorRedirectUrl: string,\n providerScope?: string,\n }\n) {\n const { codeChallenge, state } = await saveVerifierAndState();\n const location = await iface.getOAuthUrl({\n provider: options.provider,\n redirectUrl: constructRedirectUrl(options.redirectUrl),\n errorRedirectUrl: constructRedirectUrl(options.errorRedirectUrl),\n codeChallenge,\n state,\n type: \"authenticate\",\n providerScope: options.providerScope,\n });\n window.location.assign(location);\n await neverResolve();\n}\n\nexport async function addNewOAuthProviderOrScope(\n iface: StackClientInterface,\n options: {\n provider: string,\n redirectUrl: string,\n errorRedirectUrl: string,\n providerScope?: string,\n },\n session: InternalSession,\n) {\n const { codeChallenge, state } = await saveVerifierAndState();\n const location = await iface.getOAuthUrl({\n provider: options.provider,\n redirectUrl: constructRedirectUrl(options.redirectUrl),\n errorRedirectUrl: constructRedirectUrl(options.errorRedirectUrl),\n afterCallbackRedirectUrl: constructRedirectUrl(window.location.href),\n codeChallenge,\n state,\n type: \"link\",\n session,\n providerScope: options.providerScope,\n });\n window.location.assign(location);\n await neverResolve();\n}\n\n/**\n * Checks if the current URL has the query parameters for an OAuth callback, and if so, removes them.\n *\n * Must be synchronous for the logic in callOAuthCallback to work without race conditions.\n */\nfunction consumeOAuthCallbackQueryParams() {\n const requiredParams = [\"code\", \"state\"];\n const originalUrl = new URL(window.location.href);\n for (const param of requiredParams) {\n if (!originalUrl.searchParams.has(param)) {\n captureError(\"consumeOAuthCallbackQueryParams\", new Error(`Missing required query parameter on OAuth callback: ${param}`));\n return null;\n }\n }\n\n const expectedState = originalUrl.searchParams.get(\"state\") ?? throwErr(\"This should never happen; isn't state required above?\");\n const cookieResult = consumeVerifierAndStateCookie(expectedState);\n\n if (!cookieResult) {\n // If the state can't be found in the cookies, then the callback wasn't meant for us.\n // Maybe the website uses another OAuth library?\n console.warn(deindent`\n Stack found an outer OAuth callback state in the query parameters, but not in cookies.\n \n This could have multiple reasons:\n - The cookie expired, because the OAuth flow took too long.\n - The user's browser deleted the cookie, either manually or because of a very strict cookie policy.\n - The cookie was already consumed by this page, and the user already logged in.\n - You are using another OAuth client library with the same callback URL as Stack.\n - The user opened the OAuth callback page from their history.\n\n Either way, it is probably safe to ignore this warning unless you are debugging an OAuth issue.\n `);\n return null;\n }\n\n\n const newUrl = new URL(originalUrl);\n for (const param of requiredParams) {\n newUrl.searchParams.delete(param);\n }\n\n // let's get rid of the authorization code in the history as we\n // don't redirect to `redirectUrl` if there's a validation error\n // (as the redirectUrl might be malicious!).\n //\n // We use history.replaceState instead of location.assign(...) to\n // prevent an unnecessary reload\n window.history.replaceState({}, \"\", newUrl.toString());\n\n return {\n originalUrl,\n codeVerifier: cookieResult.codeVerifier,\n state: expectedState,\n };\n}\n\nexport async function callOAuthCallback(\n iface: StackClientInterface,\n redirectUrl: string,\n) {\n // note: this part of the function (until the return) needs\n // to be synchronous, to prevent race conditions when\n // callOAuthCallback is called multiple times in parallel\n const consumed = consumeOAuthCallbackQueryParams();\n if (!consumed) return Result.ok(undefined);\n\n // the rest can be asynchronous (we now know that we are the\n // intended recipient of the callback, and the only instance\n // of callOAuthCallback that's running)\n try {\n return Result.ok(await iface.callOAuthCallback({\n oauthParams: consumed.originalUrl.searchParams,\n redirectUri: constructRedirectUrl(redirectUrl),\n codeVerifier: consumed.codeVerifier,\n state: consumed.state,\n }));\n } catch (e) {\n if (e instanceof KnownError) {\n throw e;\n }\n throw new StackAssertionError(\"Error signing in during OAuth callback. Please try again.\", { cause: e });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAiD;AAEjD,oBAA4D;AAC5D,s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AA8B,aAAa;AAEhE,MAAI,CAAC,cAAc;AAGjB,YAAQ,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAWZ;AACD,WAAO;AAAA,EACT;AAGA,QAAM,SAAS,IAAI,IAAI,WAAW;AAClC,aAAW,SAAS,gBAAgB;AAClC,WAAO,aAAa,OAAO,KAAK;AAAA,EAClC;AAQA,SAAO,QAAQ,aAAa,CAAC,GAAG,IAAI,OAAO,SAAS,CAAC;AAErD,SAAO;AAAA,IACL;AAAA,IACA,cAAc,aAAa;AAAA,IAC3B,OAAO;AAAA,EACT;AACF;AAEA,eAAsB,kBACpB,OACA,aACA;AAIA,QAAM,WAAW,gCAAgC;AACjD,MAAI,CAAC,SAAU,QAAO,sBAAO,GAAG,MAAS;AAKzC,MAAI;AACF,WAAO,sBAAO,GAAG,MAAM,MAAM,kBAAkB;AAAA,MAC7C,aAAa,SAAS,YAAY;AAAA,MAClC,iBAAa,iCAAqB,WAAW;AAAA,MAC7C,cAAc,SAAS;AAAA,MACvB,OAAO,SAAS;AAAA,IAClB,CAAC,CAAC;AAAA,EACJ,SAAS,GAAG;AACV,QAAI,aAAa,gCAAY;AAC3B,YAAM;AAAA,IACR;AACA,UAAM,IAAI,kCAAoB,6DAA6D,EAAE,OAAO,EAAE,CAAC;AAAA,EACzG;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/lib/auth.ts"],"sourcesContent":["import { KnownError, StackClientInterface } from \"@stackframe/stack-shared\";\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport { StackAssertionError, throwErr } from \"@stackframe/stack-shared/dist/utils/errors\";\nimport { neverResolve } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { deindent } from \"@stackframe/stack-shared/dist/utils/strings\";\nimport { constructRedirectUrl } from \"../utils/url\";\nimport { consumeVerifierAndStateCookie, saveVerifierAndState } from \"./cookie\";\n\nexport async function signInWithOAuth(\n iface: StackClientInterface,\n options: {\n provider: string,\n redirectUrl: string,\n errorRedirectUrl: string,\n providerScope?: string,\n }\n) {\n const { codeChallenge, state } = await saveVerifierAndState();\n const location = await iface.getOAuthUrl({\n provider: options.provider,\n redirectUrl: constructRedirectUrl(options.redirectUrl),\n errorRedirectUrl: constructRedirectUrl(options.errorRedirectUrl),\n codeChallenge,\n state,\n type: \"authenticate\",\n providerScope: options.providerScope,\n });\n window.location.assign(location);\n await neverResolve();\n}\n\nexport async function addNewOAuthProviderOrScope(\n iface: StackClientInterface,\n options: {\n provider: string,\n redirectUrl: string,\n errorRedirectUrl: string,\n providerScope?: string,\n },\n session: InternalSession,\n) {\n const { codeChallenge, state } = await saveVerifierAndState();\n const location = await iface.getOAuthUrl({\n provider: options.provider,\n redirectUrl: constructRedirectUrl(options.redirectUrl),\n errorRedirectUrl: constructRedirectUrl(options.errorRedirectUrl),\n afterCallbackRedirectUrl: constructRedirectUrl(window.location.href),\n codeChallenge,\n state,\n type: \"link\",\n session,\n providerScope: options.providerScope,\n });\n window.location.assign(location);\n await neverResolve();\n}\n\n/**\n * Checks if the current URL has the query parameters for an OAuth callback, and if so, removes them.\n *\n * Must be synchronous for the logic in callOAuthCallback to work without race conditions.\n */\nfunction consumeOAuthCallbackQueryParams() {\n const requiredParams = [\"code\", \"state\"];\n const originalUrl = new URL(window.location.href);\n for (const param of requiredParams) {\n if (!originalUrl.searchParams.has(param)) {\n console.warn(new Error(`Missing required query parameter on OAuth callback: ${param}. Maybe you opened or reloaded the oauth-callback page from your history?`));\n return null;\n }\n }\n\n const expectedState = originalUrl.searchParams.get(\"state\") ?? throwErr(\"This should never happen; isn't state required above?\");\n const cookieResult = consumeVerifierAndStateCookie(expectedState);\n\n if (!cookieResult) {\n // If the state can't be found in the cookies, then the callback wasn't meant for us.\n // Maybe the website uses another OAuth library?\n console.warn(deindent`\n Stack found an outer OAuth callback state in the query parameters, but not in cookies.\n \n This could have multiple reasons:\n - The cookie expired, because the OAuth flow took too long.\n - The user's browser deleted the cookie, either manually or because of a very strict cookie policy.\n - The cookie was already consumed by this page, and the user already logged in.\n - You are using another OAuth client library with the same callback URL as Stack.\n - The user opened the OAuth callback page from their history.\n\n Either way, it is probably safe to ignore this warning unless you are debugging an OAuth issue.\n `);\n return null;\n }\n\n\n const newUrl = new URL(originalUrl);\n for (const param of requiredParams) {\n newUrl.searchParams.delete(param);\n }\n\n // let's get rid of the authorization code in the history as we\n // don't redirect to `redirectUrl` if there's a validation error\n // (as the redirectUrl might be malicious!).\n //\n // We use history.replaceState instead of location.assign(...) to\n // prevent an unnecessary reload\n window.history.replaceState({}, \"\", newUrl.toString());\n\n return {\n originalUrl,\n codeVerifier: cookieResult.codeVerifier,\n state: expectedState,\n };\n}\n\nexport async function callOAuthCallback(\n iface: StackClientInterface,\n redirectUrl: string,\n) {\n // note: this part of the function (until the return) needs\n // to be synchronous, to prevent race conditions when\n // callOAuthCallback is called multiple times in parallel\n const consumed = consumeOAuthCallbackQueryParams();\n if (!consumed) return Result.ok(undefined);\n\n // the rest can be asynchronous (we now know that we are the\n // intended recipient of the callback, and the only instance\n // of callOAuthCallback that's running)\n try {\n return Result.ok(await iface.callOAuthCallback({\n oauthParams: consumed.originalUrl.searchParams,\n redirectUri: constructRedirectUrl(redirectUrl),\n codeVerifier: consumed.codeVerifier,\n state: consumed.state,\n }));\n } catch (e) {\n if (e instanceof KnownError) {\n throw e;\n }\n throw new StackAssertionError(\"Error signing in during OAuth callback. Please try again.\", { cause: e });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAiD;AAEjD,oBAA8C;AAC9C,sBAA6B;AAC7B,qBAAuB;AACvB,qBAAyB;AACzB,iBAAqC;AACrC,oBAAoE;AAEpE,eAAsB,gBACpB,OACA,SAMA;AACA,QAAM,EAAE,eAAe,MAAM,IAAI,UAAM,oCAAqB;AAC5D,QAAM,W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AM,SAAS,IAAI,IAAI,WAAW;AAClC,aAAW,SAAS,gBAAgB;AAClC,WAAO,aAAa,OAAO,KAAK;AAAA,EAClC;AAQA,SAAO,QAAQ,aAAa,CAAC,GAAG,IAAI,OAAO,SAAS,CAAC;AAErD,SAAO;AAAA,IACL;AAAA,IACA,cAAc,aAAa;AAAA,IAC3B,OAAO;AAAA,EACT;AACF;AAEA,eAAsB,kBACpB,OACA,aACA;AAIA,QAAM,WAAW,gCAAgC;AACjD,MAAI,CAAC,SAAU,QAAO,sBAAO,GAAG,MAAS;AAKzC,MAAI;AACF,WAAO,sBAAO,GAAG,MAAM,MAAM,kBAAkB;AAAA,MAC7C,aAAa,SAAS,YAAY;AAAA,MAClC,iBAAa,iCAAqB,WAAW;AAAA,MAC7C,cAAc,SAAS;AAAA,MACvB,OAAO,SAAS;AAAA,IAClB,CAAC,CAAC;AAAA,EACJ,SAAS,GAAG;AACV,QAAI,aAAa,gCAAY;AAC3B,YAAM;AAAA,IACR;AACA,UAAM,IAAI,kCAAoB,6DAA6D,EAAE,OAAO,EAAE,CAAC;AAAA,EACzG;AACF;","names":[]}
@@ -509,6 +509,12 @@ type TeamUser = {
509
509
  id: string;
510
510
  teamProfile: TeamMemberProfile;
511
511
  };
512
+ type TeamInvitation = {
513
+ id: string;
514
+ recipientEmail: string | null;
515
+ expiresAt: Date;
516
+ revoke(): Promise<void>;
517
+ };
512
518
  type Team = {
513
519
  id: string;
514
520
  displayName: string;
@@ -521,6 +527,8 @@ type Team = {
521
527
  }): Promise<void>;
522
528
  listUsers(): Promise<TeamUser[]>;
523
529
  useUsers(): TeamUser[];
530
+ listInvitations(): Promise<TeamInvitation[]>;
531
+ useInvitations(): TeamInvitation[];
524
532
  update(update: TeamUpdateOptions): Promise<void>;
525
533
  };
526
534
  type TeamUpdateOptions = {
@@ -727,4 +735,4 @@ type AsyncStoreProperty<Name extends string, Args extends any[], Value, IsMultip
727
735
  [key in `use${Capitalize<Name>}`]: (...args: Args) => Value;
728
736
  };
729
737
 
730
- export { type AdminDomainConfig, type AdminEmailConfig, type AdminOAuthProviderConfig, type AdminOwnedProject, type AdminProject, type AdminProjectConfig, type AdminProjectConfigUpdateOptions, type AdminProjectCreateOptions, type AdminProjectUpdateOptions, type AdminTeamPermission, type AdminTeamPermissionDefinition, type AdminTeamPermissionDefinitionCreateOptions, type AdminTeamPermissionDefinitionUpdateOptions, type ApiKey, type ApiKeyBase, type ApiKeyBaseCrudRead, type ApiKeyCreateOptions, type ApiKeyFirstView, type Connection, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, type GetUserOptions, type HandlerUrls, type OAuthConnection, type OAuthProviderConfig, type OAuthScopesOnSignIn, type Project, type ProjectConfig, type ServerListUsersOptions, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, StackAdminApp, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructorOptions, type StackClientAppJson, StackServerApp, type StackServerAppConstructorOptions, type Team, type TeamCreateOptions, type TeamMemberProfile, type TeamPermission, type TeamUpdateOptions, type TeamUser, type TokenStoreInit, type User, serverTeamPermissionDefinitionCreateOptionsToCrud, serverTeamPermissionDefinitionUpdateOptionsToCrud, stackAppInternalsSymbol };
738
+ export { type AdminDomainConfig, type AdminEmailConfig, type AdminOAuthProviderConfig, type AdminOwnedProject, type AdminProject, type AdminProjectConfig, type AdminProjectConfigUpdateOptions, type AdminProjectCreateOptions, type AdminProjectUpdateOptions, type AdminTeamPermission, type AdminTeamPermissionDefinition, type AdminTeamPermissionDefinitionCreateOptions, type AdminTeamPermissionDefinitionUpdateOptions, type ApiKey, type ApiKeyBase, type ApiKeyBaseCrudRead, type ApiKeyCreateOptions, type ApiKeyFirstView, type Connection, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, type GetUserOptions, type HandlerUrls, type OAuthConnection, type OAuthProviderConfig, type OAuthScopesOnSignIn, type Project, type ProjectConfig, type ServerListUsersOptions, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, StackAdminApp, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructorOptions, type StackClientAppJson, StackServerApp, type StackServerAppConstructorOptions, type Team, type TeamCreateOptions, type TeamInvitation, type TeamMemberProfile, type TeamPermission, type TeamUpdateOptions, type TeamUser, type TokenStoreInit, type User, serverTeamPermissionDefinitionCreateOptionsToCrud, serverTeamPermissionDefinitionUpdateOptionsToCrud, stackAppInternalsSymbol };
@@ -509,6 +509,12 @@ type TeamUser = {
509
509
  id: string;
510
510
  teamProfile: TeamMemberProfile;
511
511
  };
512
+ type TeamInvitation = {
513
+ id: string;
514
+ recipientEmail: string | null;
515
+ expiresAt: Date;
516
+ revoke(): Promise<void>;
517
+ };
512
518
  type Team = {
513
519
  id: string;
514
520
  displayName: string;
@@ -521,6 +527,8 @@ type Team = {
521
527
  }): Promise<void>;
522
528
  listUsers(): Promise<TeamUser[]>;
523
529
  useUsers(): TeamUser[];
530
+ listInvitations(): Promise<TeamInvitation[]>;
531
+ useInvitations(): TeamInvitation[];
524
532
  update(update: TeamUpdateOptions): Promise<void>;
525
533
  };
526
534
  type TeamUpdateOptions = {
@@ -727,4 +735,4 @@ type AsyncStoreProperty<Name extends string, Args extends any[], Value, IsMultip
727
735
  [key in `use${Capitalize<Name>}`]: (...args: Args) => Value;
728
736
  };
729
737
 
730
- export { type AdminDomainConfig, type AdminEmailConfig, type AdminOAuthProviderConfig, type AdminOwnedProject, type AdminProject, type AdminProjectConfig, type AdminProjectConfigUpdateOptions, type AdminProjectCreateOptions, type AdminProjectUpdateOptions, type AdminTeamPermission, type AdminTeamPermissionDefinition, type AdminTeamPermissionDefinitionCreateOptions, type AdminTeamPermissionDefinitionUpdateOptions, type ApiKey, type ApiKeyBase, type ApiKeyBaseCrudRead, type ApiKeyCreateOptions, type ApiKeyFirstView, type Connection, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, type GetUserOptions, type HandlerUrls, type OAuthConnection, type OAuthProviderConfig, type OAuthScopesOnSignIn, type Project, type ProjectConfig, type ServerListUsersOptions, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, StackAdminApp, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructorOptions, type StackClientAppJson, StackServerApp, type StackServerAppConstructorOptions, type Team, type TeamCreateOptions, type TeamMemberProfile, type TeamPermission, type TeamUpdateOptions, type TeamUser, type TokenStoreInit, type User, serverTeamPermissionDefinitionCreateOptionsToCrud, serverTeamPermissionDefinitionUpdateOptionsToCrud, stackAppInternalsSymbol };
738
+ export { type AdminDomainConfig, type AdminEmailConfig, type AdminOAuthProviderConfig, type AdminOwnedProject, type AdminProject, type AdminProjectConfig, type AdminProjectConfigUpdateOptions, type AdminProjectCreateOptions, type AdminProjectUpdateOptions, type AdminTeamPermission, type AdminTeamPermissionDefinition, type AdminTeamPermissionDefinitionCreateOptions, type AdminTeamPermissionDefinitionUpdateOptions, type ApiKey, type ApiKeyBase, type ApiKeyBaseCrudRead, type ApiKeyCreateOptions, type ApiKeyFirstView, type Connection, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, type GetUserOptions, type HandlerUrls, type OAuthConnection, type OAuthProviderConfig, type OAuthScopesOnSignIn, type Project, type ProjectConfig, type ServerListUsersOptions, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, StackAdminApp, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructorOptions, type StackClientAppJson, StackServerApp, type StackServerAppConstructorOptions, type Team, type TeamCreateOptions, type TeamInvitation, type TeamMemberProfile, type TeamPermission, type TeamUpdateOptions, type TeamUser, type TokenStoreInit, type User, serverTeamPermissionDefinitionCreateOptionsToCrud, serverTeamPermissionDefinitionUpdateOptionsToCrud, stackAppInternalsSymbol };
@@ -64,7 +64,7 @@ var import_url = require("../utils/url");
64
64
  var import_auth = require("./auth");
65
65
  var import_cookie = require("./cookie");
66
66
  var NextNavigation = (0, import_compile_time.scrambleDuringCompileTime)(NextNavigationUnscrambled);
67
- var clientVersion = "js @stackframe/stack@2.6.27";
67
+ var clientVersion = "js @stackframe/stack@2.6.29";
68
68
  function getUrls(partial) {
69
69
  const handler = partial.handler ?? "/handler";
70
70
  const home = partial.home ?? "/";
@@ -230,6 +230,11 @@ var _StackClientAppImpl = class __StackClientAppImpl {
230
230
  return await this._interface.listTeamMemberProfiles({ teamId }, session);
231
231
  }
232
232
  );
233
+ this._teamInvitationsCache = createCacheBySession(
234
+ async (session, [teamId]) => {
235
+ return await this._interface.listTeamInvitations({ teamId }, session);
236
+ }
237
+ );
233
238
  this._currentUserTeamProfileCache = createCacheBySession(
234
239
  async (session, [teamId]) => {
235
240
  return await this._interface.getTeamMemberProfile({ teamId, userId: "me" }, session);
@@ -581,6 +586,17 @@ var _StackClientAppImpl = class __StackClientAppImpl {
581
586
  }
582
587
  };
583
588
  }
589
+ _clientTeamInvitationFromCrud(session, crud) {
590
+ return {
591
+ id: crud.id,
592
+ recipientEmail: crud.recipient_email,
593
+ expiresAt: new Date(crud.expires_at_millis),
594
+ revoke: async () => {
595
+ await this._interface.revokeTeamInvitation(crud.id, crud.team_id, session);
596
+ await this._teamInvitationsCache.refresh([session, crud.team_id]);
597
+ }
598
+ };
599
+ }
584
600
  _clientTeamFromCrud(crud, session) {
585
601
  const app = this;
586
602
  return {
@@ -599,6 +615,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
599
615
  session,
600
616
  callbackUrl: options.callbackUrl ?? (0, import_url.constructRedirectUrl)(app.urls.teamInvitation)
601
617
  });
618
+ await app._teamInvitationsCache.refresh([session, crud.id]);
602
619
  },
603
620
  async listUsers() {
604
621
  const result = import_results.Result.orThrow(await app._teamMemberProfilesCache.getOrWait([session, crud.id], "write-only"));
@@ -608,6 +625,14 @@ var _StackClientAppImpl = class __StackClientAppImpl {
608
625
  const result = useAsyncCache(app._teamMemberProfilesCache, [session, crud.id], "team.useUsers()");
609
626
  return result.map((crud2) => app._clientTeamUserFromCrud(crud2));
610
627
  },
628
+ async listInvitations() {
629
+ const result = import_results.Result.orThrow(await app._teamInvitationsCache.getOrWait([session, crud.id], "write-only"));
630
+ return result.map((crud2) => app._clientTeamInvitationFromCrud(session, crud2));
631
+ },
632
+ useInvitations() {
633
+ const result = useAsyncCache(app._teamInvitationsCache, [session, crud.id], "team.useInvitations()");
634
+ return result.map((crud2) => app._clientTeamInvitationFromCrud(session, crud2));
635
+ },
611
636
  async update(data) {
612
637
  await app._interface.updateTeam({ data: teamUpdateOptionsToCrud(data), teamId: crud.id }, session);
613
638
  await app._currentUserTeamsCache.refresh([session]);
@@ -1424,6 +1449,11 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1424
1449
  return await this._interface.listServerTeamMemberProfiles({ teamId });
1425
1450
  }
1426
1451
  );
1452
+ this._serverTeamInvitationsCache = createCache(
1453
+ async ([teamId]) => {
1454
+ return await this._interface.listServerTeamInvitations({ teamId });
1455
+ }
1456
+ );
1427
1457
  this._serverUserTeamProfileCache = createCache(
1428
1458
  async ([teamId, userId]) => {
1429
1459
  return await this._interface.getServerTeamMemberProfile({ teamId, userId });
@@ -1636,6 +1666,16 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1636
1666
  }
1637
1667
  };
1638
1668
  }
1669
+ _serverTeamInvitationFromCrud(crud) {
1670
+ return {
1671
+ id: crud.id,
1672
+ recipientEmail: crud.recipient_email,
1673
+ expiresAt: new Date(crud.expires_at_millis),
1674
+ revoke: async () => {
1675
+ await this._interface.revokeServerTeamInvitation(crud.id, crud.team_id);
1676
+ }
1677
+ };
1678
+ }
1639
1679
  _currentUserFromCrud(crud, session) {
1640
1680
  const app = this;
1641
1681
  const currentUser = {
@@ -1695,6 +1735,15 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1695
1735
  email: options.email,
1696
1736
  callbackUrl: options.callbackUrl ?? (0, import_url.constructRedirectUrl)(app.urls.teamInvitation)
1697
1737
  });
1738
+ await app._serverTeamInvitationsCache.refresh([crud.id]);
1739
+ },
1740
+ async listInvitations() {
1741
+ const result = import_results.Result.orThrow(await app._serverTeamInvitationsCache.getOrWait([crud.id], "write-only"));
1742
+ return result.map((crud2) => app._serverTeamInvitationFromCrud(crud2));
1743
+ },
1744
+ useInvitations() {
1745
+ const result = useAsyncCache(app._serverTeamInvitationsCache, [crud.id], "team.useInvitations()");
1746
+ return (0, import_react2.useMemo)(() => result.map((crud2) => app._serverTeamInvitationFromCrud(crud2)), [result]);
1698
1747
  }
1699
1748
  };
1700
1749
  }