@stackframe/stack 2.4.16 → 2.4.18

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 (82) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/components/credential-sign-in.js +1 -1
  3. package/dist/components/credential-sign-in.js.map +1 -1
  4. package/dist/components/credential-sign-up.js +1 -1
  5. package/dist/components/credential-sign-up.js.map +1 -1
  6. package/dist/components/forgot-password.js +1 -1
  7. package/dist/components/forgot-password.js.map +1 -1
  8. package/dist/components/magic-link-sign-in.js +1 -1
  9. package/dist/components/magic-link-sign-in.js.map +1 -1
  10. package/dist/components/maybe-full-page.js +5 -1
  11. package/dist/components/maybe-full-page.js.map +1 -1
  12. package/dist/components/password-reset-inner.js +1 -1
  13. package/dist/components/password-reset-inner.js.map +1 -1
  14. package/dist/components/user-avatar.d.mts +1 -0
  15. package/dist/components/user-avatar.d.ts +1 -0
  16. package/dist/components/user-avatar.js +1 -1
  17. package/dist/components/user-avatar.js.map +1 -1
  18. package/dist/components/user-button.js +4 -4
  19. package/dist/components/user-button.js.map +1 -1
  20. package/dist/components-core/button.js.map +1 -1
  21. package/dist/components-core-joy/button.js +1 -1
  22. package/dist/components-core-joy/button.js.map +1 -1
  23. package/dist/components-page/account-settings.js +1 -1
  24. package/dist/components-page/account-settings.js.map +1 -1
  25. package/dist/components-page/stack-handler.d.mts +1 -0
  26. package/dist/components-page/stack-handler.d.ts +1 -0
  27. package/dist/esm/components/credential-sign-in.js +2 -2
  28. package/dist/esm/components/credential-sign-in.js.map +1 -1
  29. package/dist/esm/components/credential-sign-up.js +2 -2
  30. package/dist/esm/components/credential-sign-up.js.map +1 -1
  31. package/dist/esm/components/forgot-password.js +2 -2
  32. package/dist/esm/components/forgot-password.js.map +1 -1
  33. package/dist/esm/components/magic-link-sign-in.js +2 -2
  34. package/dist/esm/components/magic-link-sign-in.js.map +1 -1
  35. package/dist/esm/components/maybe-full-page.js +5 -1
  36. package/dist/esm/components/maybe-full-page.js.map +1 -1
  37. package/dist/esm/components/password-reset-inner.js +2 -2
  38. package/dist/esm/components/password-reset-inner.js.map +1 -1
  39. package/dist/esm/components/user-avatar.js +1 -1
  40. package/dist/esm/components/user-avatar.js.map +1 -1
  41. package/dist/esm/components/user-button.js +5 -5
  42. package/dist/esm/components/user-button.js.map +1 -1
  43. package/dist/esm/components-core/button.js.map +1 -1
  44. package/dist/esm/components-core-joy/button.js +1 -1
  45. package/dist/esm/components-core-joy/button.js.map +1 -1
  46. package/dist/esm/components-page/account-settings.js +1 -1
  47. package/dist/esm/components-page/account-settings.js.map +1 -1
  48. package/dist/esm/lib/auth.js +2 -3
  49. package/dist/esm/lib/auth.js.map +1 -1
  50. package/dist/esm/lib/stack-app.js +218 -168
  51. package/dist/esm/lib/stack-app.js.map +1 -1
  52. package/dist/esm/providers/stack-provider-client.js +2 -1
  53. package/dist/esm/providers/stack-provider-client.js.map +1 -1
  54. package/dist/esm/providers/styled-components-registry.js +2 -1
  55. package/dist/esm/providers/styled-components-registry.js.map +1 -1
  56. package/dist/index.d.mts +1 -0
  57. package/dist/index.d.ts +1 -0
  58. package/dist/lib/auth.d.mts +5 -3
  59. package/dist/lib/auth.d.ts +5 -3
  60. package/dist/lib/auth.js +2 -3
  61. package/dist/lib/auth.js.map +1 -1
  62. package/dist/lib/hooks.d.mts +1 -0
  63. package/dist/lib/hooks.d.ts +1 -0
  64. package/dist/lib/stack-app.d.mts +23 -16
  65. package/dist/lib/stack-app.d.ts +23 -16
  66. package/dist/lib/stack-app.js +217 -167
  67. package/dist/lib/stack-app.js.map +1 -1
  68. package/dist/providers/stack-provider-client.d.mts +1 -0
  69. package/dist/providers/stack-provider-client.d.ts +1 -0
  70. package/dist/providers/stack-provider-client.js +2 -1
  71. package/dist/providers/stack-provider-client.js.map +1 -1
  72. package/dist/providers/stack-provider.d.mts +1 -0
  73. package/dist/providers/stack-provider.d.ts +1 -0
  74. package/dist/providers/styled-components-registry.js +2 -1
  75. package/dist/providers/styled-components-registry.js.map +1 -1
  76. package/package.json +2 -2
  77. package/dist/esm/utils/next.js +0 -8
  78. package/dist/esm/utils/next.js.map +0 -1
  79. package/dist/utils/next.d.mts +0 -3
  80. package/dist/utils/next.d.ts +0 -3
  81. package/dist/utils/next.js +0 -33
  82. package/dist/utils/next.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -28,6 +28,7 @@ import '@stackframe/stack-shared/dist/utils/json';
28
28
  import '@stackframe/stack-shared/dist/interface/adminInterface';
29
29
  import '@stackframe/stack-shared/dist/interface/serverInterface';
30
30
  import '@stackframe/stack-shared/dist/interface/crud/email-templates';
31
+ import '@stackframe/stack-shared/dist/sessions';
31
32
  import '@radix-ui/react-tabs';
32
33
  import '@radix-ui/react-collapsible';
33
34
  import '@radix-ui/react-avatar';
@@ -1,11 +1,13 @@
1
- import * as oauth4webapi from 'oauth4webapi';
2
1
  import { StackClientInterface } from '@stackframe/stack-shared';
3
- import { TokenStore } from '@stackframe/stack-shared/dist/interface/clientInterface';
4
2
 
5
3
  declare function signInWithOAuth(iface: StackClientInterface, { provider, redirectUrl, }: {
6
4
  provider: string;
7
5
  redirectUrl?: string;
8
6
  }): Promise<void>;
9
- declare function callOAuthCallback(iface: StackClientInterface, tokenStore: TokenStore, redirectUrl: string): Promise<oauth4webapi.OAuth2TokenEndpointResponse | null>;
7
+ declare function callOAuthCallback(iface: StackClientInterface, redirectUrl: string): Promise<{
8
+ newUser: boolean;
9
+ accessToken: string;
10
+ refreshToken: string;
11
+ } | null>;
10
12
 
11
13
  export { callOAuthCallback, signInWithOAuth };
@@ -1,11 +1,13 @@
1
- import * as oauth4webapi from 'oauth4webapi';
2
1
  import { StackClientInterface } from '@stackframe/stack-shared';
3
- import { TokenStore } from '@stackframe/stack-shared/dist/interface/clientInterface';
4
2
 
5
3
  declare function signInWithOAuth(iface: StackClientInterface, { provider, redirectUrl, }: {
6
4
  provider: string;
7
5
  redirectUrl?: string;
8
6
  }): Promise<void>;
9
- declare function callOAuthCallback(iface: StackClientInterface, tokenStore: TokenStore, redirectUrl: string): Promise<oauth4webapi.OAuth2TokenEndpointResponse | null>;
7
+ declare function callOAuthCallback(iface: StackClientInterface, redirectUrl: string): Promise<{
8
+ newUser: boolean;
9
+ accessToken: string;
10
+ refreshToken: string;
11
+ } | null>;
10
12
 
11
13
  export { callOAuthCallback, signInWithOAuth };
package/dist/lib/auth.js CHANGED
@@ -61,7 +61,7 @@ function consumeOAuthCallbackQueryParams(expectedState) {
61
61
  window.history.replaceState({}, "", newUrl.toString());
62
62
  return originalUrl;
63
63
  }
64
- async function callOAuthCallback(iface, tokenStore, redirectUrl) {
64
+ async function callOAuthCallback(iface, redirectUrl) {
65
65
  const { codeVerifier, state } = (0, import_cookie.getVerifierAndState)();
66
66
  if (!codeVerifier || !state) {
67
67
  throw new Error("Invalid OAuth callback URL parameters. It seems like the OAuth flow was interrupted, so please try again.");
@@ -74,8 +74,7 @@ async function callOAuthCallback(iface, tokenStore, redirectUrl) {
74
74
  originalUrl.searchParams,
75
75
  (0, import_url.constructRedirectUrl)(redirectUrl),
76
76
  codeVerifier,
77
- state,
78
- tokenStore
77
+ state
79
78
  );
80
79
  } catch (e) {
81
80
  throw new import_errors.StackAssertionError("Error signing in during OAuth callback. Please try again.", { cause: e });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/auth.ts"],"sourcesContent":["import { StackClientInterface } from \"@stackframe/stack-shared\";\nimport { saveVerifierAndState, getVerifierAndState } from \"./cookie\";\nimport { constructRedirectUrl } from \"../utils/url\";\nimport { TokenStore } from \"@stackframe/stack-shared/dist/interface/clientInterface\";\nimport { neverResolve, wait } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { StackAssertionError } from \"@stackframe/stack-shared/dist/utils/errors\";\n\nexport async function signInWithOAuth(\n iface: StackClientInterface,\n {\n provider,\n redirectUrl,\n } : { \n provider: string,\n redirectUrl?: string,\n }\n) {\n redirectUrl = constructRedirectUrl(redirectUrl);\n const { codeChallenge, state } = await saveVerifierAndState();\n const location = await iface.getOAuthUrl(\n provider,\n redirectUrl,\n codeChallenge,\n state,\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(expectedState: string): null | URL {\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 return null;\n }\n }\n\n if (expectedState !== originalUrl.searchParams.get(\"state\")) {\n // If the state doesn't match, then the callback wasn't meant for us.\n // Maybe the website uses another OAuth library?\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 originalUrl; \n}\n\nexport async function callOAuthCallback(\n iface: StackClientInterface,\n tokenStore: TokenStore,\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 { codeVerifier, state } = getVerifierAndState();\n if (!codeVerifier || !state) {\n throw new Error(\"Invalid OAuth callback URL parameters. It seems like the OAuth flow was interrupted, so please try again.\");\n }\n const originalUrl = consumeOAuthCallbackQueryParams(state);\n if (!originalUrl) return null;\n\n // the rest can be asynchronous (we now know that we are the\n // intended recipient of the callback)\n try {\n return await iface.callOAuthCallback(\n originalUrl.searchParams,\n constructRedirectUrl(redirectUrl),\n codeVerifier,\n state,\n tokenStore,\n );\n } catch (e) {\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;AACA,oBAA0D;AAC1D,iBAAqC;AAErC,sBAAmC;AACnC,oBAAoC;AAEpC,eAAsB,gBACpB,OACA;AAAA,EACE;AAAA,EACA;AACF,GAIA;AACA,oBAAc,iCAAqB,WAAW;AAC9C,QAAM,EAAE,eAAe,MAAM,IAAI,UAAM,oCAAqB;AAC5D,QAAM,WAAW,MAAM,MAAM;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,SAAO,SAAS,OAAO,QAAQ;AAC/B,YAAM,8BAAa;AACrB;AAOA,SAAS,gCAAgC,eAAmC;AAC1E,QAAM,iBAAiB,CAAC,QAAQ,OAAO;AACvC,QAAM,cAAc,IAAI,IAAI,OAAO,SAAS,IAAI;AAChD,aAAW,SAAS,gBAAgB;AAClC,QAAI,CAAC,YAAY,aAAa,IAAI,KAAK,GAAG;AACxC,aAAO;AAAA,IACT;AAAA,EACF;AAEA,MAAI,kBAAkB,YAAY,aAAa,IAAI,OAAO,GAAG;AAG3D,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;AACT;AAEA,eAAsB,kBACpB,OACA,YACA,aACA;AAIA,QAAM,EAAE,cAAc,MAAM,QAAI,mCAAoB;AACpD,MAAI,CAAC,gBAAgB,CAAC,OAAO;AAC3B,UAAM,IAAI,MAAM,2GAA2G;AAAA,EAC7H;AACA,QAAM,cAAc,gCAAgC,KAAK;AACzD,MAAI,CAAC;AAAa,WAAO;AAIzB,MAAI;AACF,WAAO,MAAM,MAAM;AAAA,MACjB,YAAY;AAAA,UACZ,iCAAqB,WAAW;AAAA,MAChC;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,SAAS,GAAG;AACV,UAAM,IAAI,kCAAoB,6DAA6D,EAAE,OAAO,EAAE,CAAC;AAAA,EACzG;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/lib/auth.ts"],"sourcesContent":["import { StackClientInterface } from \"@stackframe/stack-shared\";\nimport { saveVerifierAndState, getVerifierAndState } from \"./cookie\";\nimport { constructRedirectUrl } from \"../utils/url\";\nimport { neverResolve, wait } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { StackAssertionError } from \"@stackframe/stack-shared/dist/utils/errors\";\n\nexport async function signInWithOAuth(\n iface: StackClientInterface,\n {\n provider,\n redirectUrl,\n } : { \n provider: string,\n redirectUrl?: string,\n }\n) {\n redirectUrl = constructRedirectUrl(redirectUrl);\n const { codeChallenge, state } = await saveVerifierAndState();\n const location = await iface.getOAuthUrl(\n provider,\n redirectUrl,\n codeChallenge,\n state,\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(expectedState: string): null | URL {\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 return null;\n }\n }\n\n if (expectedState !== originalUrl.searchParams.get(\"state\")) {\n // If the state doesn't match, then the callback wasn't meant for us.\n // Maybe the website uses another OAuth library?\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 originalUrl; \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 { codeVerifier, state } = getVerifierAndState();\n if (!codeVerifier || !state) {\n throw new Error(\"Invalid OAuth callback URL parameters. It seems like the OAuth flow was interrupted, so please try again.\");\n }\n const originalUrl = consumeOAuthCallbackQueryParams(state);\n if (!originalUrl) return null;\n\n // the rest can be asynchronous (we now know that we are the\n // intended recipient of the callback)\n try {\n return await iface.callOAuthCallback(\n originalUrl.searchParams,\n constructRedirectUrl(redirectUrl),\n codeVerifier,\n state,\n );\n } catch (e) {\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;AACA,oBAA0D;AAC1D,iBAAqC;AACrC,sBAAmC;AACnC,oBAAoC;AAEpC,eAAsB,gBACpB,OACA;AAAA,EACE;AAAA,EACA;AACF,GAIA;AACA,oBAAc,iCAAqB,WAAW;AAC9C,QAAM,EAAE,eAAe,MAAM,IAAI,UAAM,oCAAqB;AAC5D,QAAM,WAAW,MAAM,MAAM;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,SAAO,SAAS,OAAO,QAAQ;AAC/B,YAAM,8BAAa;AACrB;AAOA,SAAS,gCAAgC,eAAmC;AAC1E,QAAM,iBAAiB,CAAC,QAAQ,OAAO;AACvC,QAAM,cAAc,IAAI,IAAI,OAAO,SAAS,IAAI;AAChD,aAAW,SAAS,gBAAgB;AAClC,QAAI,CAAC,YAAY,aAAa,IAAI,KAAK,GAAG;AACxC,aAAO;AAAA,IACT;AAAA,EACF;AAEA,MAAI,kBAAkB,YAAY,aAAa,IAAI,OAAO,GAAG;AAG3D,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;AACT;AAEA,eAAsB,kBACpB,OACA,aACA;AAIA,QAAM,EAAE,cAAc,MAAM,QAAI,mCAAoB;AACpD,MAAI,CAAC,gBAAgB,CAAC,OAAO;AAC3B,UAAM,IAAI,MAAM,2GAA2G;AAAA,EAC7H;AACA,QAAM,cAAc,gCAAgC,KAAK;AACzD,MAAI,CAAC;AAAa,WAAO;AAIzB,MAAI;AACF,WAAO,MAAM,MAAM;AAAA,MACjB,YAAY;AAAA,UACZ,iCAAqB,WAAW;AAAA,MAChC;AAAA,MACA;AAAA,IACF;AAAA,EACF,SAAS,GAAG;AACV,UAAM,IAAI,kCAAoB,6DAA6D,EAAE,OAAO,EAAE,CAAC;AAAA,EACzG;AACF;","names":[]}
@@ -5,6 +5,7 @@ import '@stackframe/stack-shared/dist/utils/json';
5
5
  import '@stackframe/stack-shared/dist/interface/adminInterface';
6
6
  import '@stackframe/stack-shared/dist/interface/serverInterface';
7
7
  import '@stackframe/stack-shared/dist/interface/crud/email-templates';
8
+ import '@stackframe/stack-shared/dist/sessions';
8
9
 
9
10
  /**
10
11
  * Returns the current user object. Equivalent to `useStackApp().useUser()`.
@@ -5,6 +5,7 @@ import '@stackframe/stack-shared/dist/utils/json';
5
5
  import '@stackframe/stack-shared/dist/interface/adminInterface';
6
6
  import '@stackframe/stack-shared/dist/interface/serverInterface';
7
7
  import '@stackframe/stack-shared/dist/interface/crud/email-templates';
8
+ import '@stackframe/stack-shared/dist/sessions';
8
9
 
9
10
  /**
10
11
  * Returns the current user object. Equivalent to `useStackApp().useUser()`.
@@ -1,11 +1,20 @@
1
1
  import { ServerUserJson, OAuthProviderConfigJson, KnownErrors } from '@stackframe/stack-shared';
2
- import { TokenStore, UserJson, UserUpdateJson, ProjectJson, ProductionModeError, TeamJson, EmailConfigJson, DomainConfigJson, ClientProjectJson } from '@stackframe/stack-shared/dist/interface/clientInterface';
2
+ import { UserJson, UserUpdateJson, ProjectJson, ProductionModeError, TeamJson, EmailConfigJson, DomainConfigJson, ClientProjectJson } from '@stackframe/stack-shared/dist/interface/clientInterface';
3
3
  import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
4
4
  import { ProjectUpdateOptions, ApiKeySetCreateOptions } from '@stackframe/stack-shared/dist/interface/adminInterface';
5
5
  import { ServerUserUpdateJson, ServerTeamCustomizableJson, ServerPermissionDefinitionCustomizableJson, ServerPermissionDefinitionJson, EmailTemplateType } from '@stackframe/stack-shared/dist/interface/serverInterface';
6
6
  import { ListEmailTemplatesCrud, EmailTemplateCrud } from '@stackframe/stack-shared/dist/interface/crud/email-templates';
7
+ import { Session } from '@stackframe/stack-shared/dist/sessions';
7
8
 
8
- type TokenStoreInit<HasTokenStore extends boolean = boolean> = HasTokenStore extends true ? ("cookie" | "nextjs-cookie" | "memory" | Request) : HasTokenStore extends false ? null : TokenStoreInit<true> | TokenStoreInit<false>;
9
+ type RequestLike = {
10
+ headers: {
11
+ get: (name: string) => string | null;
12
+ };
13
+ };
14
+ type TokenStoreInit<HasTokenStore extends boolean = boolean> = HasTokenStore extends true ? ("cookie" | "nextjs-cookie" | "memory" | RequestLike | {
15
+ accessToken: string;
16
+ refreshToken: string;
17
+ }) : HasTokenStore extends false ? null : TokenStoreInit<true> | TokenStoreInit<false>;
9
18
  type HandlerUrls = {
10
19
  handler: string;
11
20
  signIn: string;
@@ -36,8 +45,7 @@ type StackServerAppConstructorOptions<HasTokenStore extends boolean, ProjectId e
36
45
  type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = ((StackServerAppConstructorOptions<HasTokenStore, ProjectId> & {
37
46
  superSecretAdminKey?: string;
38
47
  }) | (Omit<StackServerAppConstructorOptions<HasTokenStore, ProjectId>, "publishableClientKey" | "secretServerKey"> & {
39
- projectOwnerTokens: TokenStore;
40
- refreshProjectOwnerTokens: () => Promise<void>;
48
+ projectOwnerSession: Session;
41
49
  }));
42
50
  type StackClientAppJson<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
43
51
  uniqueIdentifier: string;
@@ -47,16 +55,15 @@ type RedirectToOptions = {
47
55
  replace?: boolean;
48
56
  };
49
57
  type Auth<T, C> = {
50
- readonly tokenStore: TokenStore;
51
- refreshAccessToken(this: T): Promise<void>;
58
+ readonly session: Session;
52
59
  updateSelectedTeam(this: T, team: Team | null): Promise<void>;
53
60
  update(this: T, user: C): Promise<void>;
54
61
  signOut(this: T): Promise<void>;
55
- sendVerificationEmail(this: T): Promise<KnownErrors["EmailAlreadyVerified"] | undefined>;
62
+ sendVerificationEmail(this: T): Promise<KnownErrors["EmailAlreadyVerified"] | void>;
56
63
  updatePassword(this: T, options: {
57
64
  oldPassword: string;
58
65
  newPassword: string;
59
- }): Promise<KnownErrors["PasswordMismatch"] | KnownErrors["PasswordRequirementsNotMet"] | undefined>;
66
+ }): Promise<KnownErrors["PasswordMismatch"] | KnownErrors["PasswordRequirementsNotMet"] | void>;
60
67
  };
61
68
  type InternalAuth<T> = {
62
69
  createProject(this: T, newProject: ProjectUpdateOptions & {
@@ -230,21 +237,21 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
230
237
  signInWithCredential(options: {
231
238
  email: string;
232
239
  password: string;
233
- }): Promise<KnownErrors["EmailPasswordMismatch"] | undefined>;
240
+ }): Promise<KnownErrors["EmailPasswordMismatch"] | void>;
234
241
  signUpWithCredential(options: {
235
242
  email: string;
236
243
  password: string;
237
- }): Promise<KnownErrors["UserEmailAlreadyExists"] | KnownErrors["PasswordRequirementsNotMet"] | undefined>;
244
+ }): Promise<KnownErrors["UserEmailAlreadyExists"] | KnownErrors["PasswordRequirementsNotMet"] | void>;
238
245
  callOAuthCallback(): Promise<boolean>;
239
- sendForgotPasswordEmail(email: string): Promise<KnownErrors["UserNotFound"] | undefined>;
240
- sendMagicLinkEmail(email: string): Promise<KnownErrors["RedirectUrlNotWhitelisted"] | undefined>;
246
+ sendForgotPasswordEmail(email: string): Promise<KnownErrors["UserNotFound"] | void>;
247
+ sendMagicLinkEmail(email: string): Promise<KnownErrors["RedirectUrlNotWhitelisted"] | void>;
241
248
  resetPassword(options: {
242
249
  code: string;
243
250
  password: string;
244
- }): Promise<KnownErrors["PasswordResetError"] | undefined>;
245
- verifyPasswordResetCode(code: string): Promise<KnownErrors["PasswordResetCodeError"] | undefined>;
246
- verifyEmail(code: string): Promise<KnownErrors["EmailVerificationError"] | undefined>;
247
- signInWithMagicLink(code: string): Promise<KnownErrors["MagicLinkError"] | undefined>;
251
+ }): Promise<KnownErrors["PasswordResetError"] | void>;
252
+ verifyPasswordResetCode(code: string): Promise<KnownErrors["PasswordResetCodeError"] | void>;
253
+ verifyEmail(code: string): Promise<KnownErrors["EmailVerificationError"] | void>;
254
+ signInWithMagicLink(code: string): Promise<KnownErrors["MagicLinkError"] | void>;
248
255
  [stackAppInternalsSymbol]: {
249
256
  toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>;
250
257
  setCurrentUser(userJsonPromise: Promise<UserJson | null>): void;
@@ -1,11 +1,20 @@
1
1
  import { ServerUserJson, OAuthProviderConfigJson, KnownErrors } from '@stackframe/stack-shared';
2
- import { TokenStore, UserJson, UserUpdateJson, ProjectJson, ProductionModeError, TeamJson, EmailConfigJson, DomainConfigJson, ClientProjectJson } from '@stackframe/stack-shared/dist/interface/clientInterface';
2
+ import { UserJson, UserUpdateJson, ProjectJson, ProductionModeError, TeamJson, EmailConfigJson, DomainConfigJson, ClientProjectJson } from '@stackframe/stack-shared/dist/interface/clientInterface';
3
3
  import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
4
4
  import { ProjectUpdateOptions, ApiKeySetCreateOptions } from '@stackframe/stack-shared/dist/interface/adminInterface';
5
5
  import { ServerUserUpdateJson, ServerTeamCustomizableJson, ServerPermissionDefinitionCustomizableJson, ServerPermissionDefinitionJson, EmailTemplateType } from '@stackframe/stack-shared/dist/interface/serverInterface';
6
6
  import { ListEmailTemplatesCrud, EmailTemplateCrud } from '@stackframe/stack-shared/dist/interface/crud/email-templates';
7
+ import { Session } from '@stackframe/stack-shared/dist/sessions';
7
8
 
8
- type TokenStoreInit<HasTokenStore extends boolean = boolean> = HasTokenStore extends true ? ("cookie" | "nextjs-cookie" | "memory" | Request) : HasTokenStore extends false ? null : TokenStoreInit<true> | TokenStoreInit<false>;
9
+ type RequestLike = {
10
+ headers: {
11
+ get: (name: string) => string | null;
12
+ };
13
+ };
14
+ type TokenStoreInit<HasTokenStore extends boolean = boolean> = HasTokenStore extends true ? ("cookie" | "nextjs-cookie" | "memory" | RequestLike | {
15
+ accessToken: string;
16
+ refreshToken: string;
17
+ }) : HasTokenStore extends false ? null : TokenStoreInit<true> | TokenStoreInit<false>;
9
18
  type HandlerUrls = {
10
19
  handler: string;
11
20
  signIn: string;
@@ -36,8 +45,7 @@ type StackServerAppConstructorOptions<HasTokenStore extends boolean, ProjectId e
36
45
  type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = ((StackServerAppConstructorOptions<HasTokenStore, ProjectId> & {
37
46
  superSecretAdminKey?: string;
38
47
  }) | (Omit<StackServerAppConstructorOptions<HasTokenStore, ProjectId>, "publishableClientKey" | "secretServerKey"> & {
39
- projectOwnerTokens: TokenStore;
40
- refreshProjectOwnerTokens: () => Promise<void>;
48
+ projectOwnerSession: Session;
41
49
  }));
42
50
  type StackClientAppJson<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
43
51
  uniqueIdentifier: string;
@@ -47,16 +55,15 @@ type RedirectToOptions = {
47
55
  replace?: boolean;
48
56
  };
49
57
  type Auth<T, C> = {
50
- readonly tokenStore: TokenStore;
51
- refreshAccessToken(this: T): Promise<void>;
58
+ readonly session: Session;
52
59
  updateSelectedTeam(this: T, team: Team | null): Promise<void>;
53
60
  update(this: T, user: C): Promise<void>;
54
61
  signOut(this: T): Promise<void>;
55
- sendVerificationEmail(this: T): Promise<KnownErrors["EmailAlreadyVerified"] | undefined>;
62
+ sendVerificationEmail(this: T): Promise<KnownErrors["EmailAlreadyVerified"] | void>;
56
63
  updatePassword(this: T, options: {
57
64
  oldPassword: string;
58
65
  newPassword: string;
59
- }): Promise<KnownErrors["PasswordMismatch"] | KnownErrors["PasswordRequirementsNotMet"] | undefined>;
66
+ }): Promise<KnownErrors["PasswordMismatch"] | KnownErrors["PasswordRequirementsNotMet"] | void>;
60
67
  };
61
68
  type InternalAuth<T> = {
62
69
  createProject(this: T, newProject: ProjectUpdateOptions & {
@@ -230,21 +237,21 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
230
237
  signInWithCredential(options: {
231
238
  email: string;
232
239
  password: string;
233
- }): Promise<KnownErrors["EmailPasswordMismatch"] | undefined>;
240
+ }): Promise<KnownErrors["EmailPasswordMismatch"] | void>;
234
241
  signUpWithCredential(options: {
235
242
  email: string;
236
243
  password: string;
237
- }): Promise<KnownErrors["UserEmailAlreadyExists"] | KnownErrors["PasswordRequirementsNotMet"] | undefined>;
244
+ }): Promise<KnownErrors["UserEmailAlreadyExists"] | KnownErrors["PasswordRequirementsNotMet"] | void>;
238
245
  callOAuthCallback(): Promise<boolean>;
239
- sendForgotPasswordEmail(email: string): Promise<KnownErrors["UserNotFound"] | undefined>;
240
- sendMagicLinkEmail(email: string): Promise<KnownErrors["RedirectUrlNotWhitelisted"] | undefined>;
246
+ sendForgotPasswordEmail(email: string): Promise<KnownErrors["UserNotFound"] | void>;
247
+ sendMagicLinkEmail(email: string): Promise<KnownErrors["RedirectUrlNotWhitelisted"] | void>;
241
248
  resetPassword(options: {
242
249
  code: string;
243
250
  password: string;
244
- }): Promise<KnownErrors["PasswordResetError"] | undefined>;
245
- verifyPasswordResetCode(code: string): Promise<KnownErrors["PasswordResetCodeError"] | undefined>;
246
- verifyEmail(code: string): Promise<KnownErrors["EmailVerificationError"] | undefined>;
247
- signInWithMagicLink(code: string): Promise<KnownErrors["MagicLinkError"] | undefined>;
251
+ }): Promise<KnownErrors["PasswordResetError"] | void>;
252
+ verifyPasswordResetCode(code: string): Promise<KnownErrors["PasswordResetCodeError"] | void>;
253
+ verifyEmail(code: string): Promise<KnownErrors["EmailVerificationError"] | void>;
254
+ signInWithMagicLink(code: string): Promise<KnownErrors["MagicLinkError"] | void>;
248
255
  [stackAppInternalsSymbol]: {
249
256
  toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>;
250
257
  setCurrentUser(userJsonPromise: Promise<UserJson | null>): void;