@stackframe/stack 2.3.5 → 2.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/card-frame.d.mts +9 -0
- package/dist/components/card-frame.d.ts +8 -5
- package/dist/components/card-frame.js +58 -23
- package/dist/components/credential-sign-in.d.mts +5 -0
- package/dist/components/credential-sign-in.d.ts +5 -1
- package/dist/components/credential-sign-in.js +109 -41
- package/dist/components/credential-sign-up.d.mts +5 -0
- package/dist/components/credential-sign-up.d.ts +5 -1
- package/dist/components/credential-sign-up.js +140 -62
- package/dist/components/forgot-password.d.mts +7 -0
- package/dist/components/forgot-password.d.ts +6 -2
- package/dist/components/forgot-password.js +83 -26
- package/dist/components/form-warning.d.mts +7 -0
- package/dist/components/form-warning.d.ts +6 -2
- package/dist/components/form-warning.js +34 -8
- package/dist/components/magic-link-sign-in.d.mts +5 -0
- package/dist/components/magic-link-sign-in.d.ts +5 -1
- package/dist/components/magic-link-sign-in.js +89 -31
- package/dist/components/message-card.d.mts +10 -0
- package/dist/components/message-card.d.ts +8 -4
- package/dist/components/message-card.js +45 -6
- package/dist/components/oauth-button.d.mts +8 -0
- package/dist/components/oauth-button.d.ts +6 -2
- package/dist/components/oauth-button.js +142 -63
- package/dist/components/oauth-group.d.mts +7 -0
- package/dist/components/oauth-group.d.ts +6 -2
- package/dist/components/oauth-group.js +46 -8
- package/dist/components/password-field.d.mts +5 -0
- package/dist/components/password-field.d.ts +5 -3
- package/dist/components/password-field.js +111 -41
- package/dist/components/password-reset-inner.d.mts +8 -0
- package/dist/components/password-reset-inner.d.ts +6 -2
- package/dist/components/password-reset-inner.js +120 -58
- package/dist/components/redirect-message-card.d.mts +8 -0
- package/dist/components/redirect-message-card.d.ts +6 -2
- package/dist/components/redirect-message-card.js +110 -58
- package/dist/components/separator-with-text.d.mts +7 -0
- package/dist/components/separator-with-text.d.ts +6 -2
- package/dist/components/separator-with-text.js +35 -5
- package/dist/components/user-avatar.d.mts +13 -0
- package/dist/components/user-avatar.d.ts +11 -3
- package/dist/components/user-avatar.js +34 -6
- package/dist/components/user-button.d.mts +15 -0
- package/dist/components/user-button.d.ts +12 -3
- package/dist/components/user-button.js +156 -26
- package/dist/components-core/avatar.d.mts +8 -0
- package/dist/components-core/avatar.d.ts +7 -5
- package/dist/components-core/avatar.js +73 -18
- package/dist/components-core/button.d.mts +12 -0
- package/dist/components-core/button.d.ts +8 -6
- package/dist/components-core/button.js +177 -113
- package/dist/components-core/card.d.mts +8 -0
- package/dist/components-core/card.d.ts +4 -2
- package/dist/components-core/card.js +73 -22
- package/dist/components-core/collapsible.d.mts +8 -0
- package/dist/components-core/collapsible.d.ts +8 -6
- package/dist/components-core/collapsible.js +48 -5
- package/dist/components-core/container.d.mts +8 -0
- package/dist/components-core/container.d.ts +5 -3
- package/dist/components-core/container.js +61 -11
- package/dist/components-core/dropdown.d.mts +15 -0
- package/dist/components-core/dropdown.d.ts +10 -8
- package/dist/components-core/dropdown.js +108 -36
- package/dist/components-core/index.d.mts +59 -0
- package/dist/components-core/index.d.ts +51 -40
- package/dist/components-core/index.js +144 -46
- package/dist/components-core/input.d.mts +6 -0
- package/dist/components-core/input.d.ts +5 -3
- package/dist/components-core/input.js +97 -28
- package/dist/components-core/label.d.mts +6 -0
- package/dist/components-core/label.d.ts +5 -3
- package/dist/components-core/label.js +65 -15
- package/dist/components-core/link.d.mts +10 -0
- package/dist/components-core/link.d.ts +7 -6
- package/dist/components-core/link.js +72 -18
- package/dist/components-core/loading-indicator.d.mts +13 -0
- package/dist/components-core/loading-indicator.d.ts +11 -4
- package/dist/components-core/loading-indicator.js +46 -6
- package/dist/components-core/popover.d.mts +8 -0
- package/dist/components-core/popover.d.ts +8 -6
- package/dist/components-core/popover.js +72 -16
- package/dist/components-core/separator.d.mts +6 -0
- package/dist/components-core/separator.d.ts +5 -3
- package/dist/components-core/separator.js +66 -16
- package/dist/components-core/skeleton.d.mts +7 -0
- package/dist/components-core/skeleton.d.ts +5 -3
- package/dist/components-core/skeleton.js +75 -21
- package/dist/components-core/tabs.d.mts +9 -0
- package/dist/components-core/tabs.d.ts +8 -6
- package/dist/components-core/tabs.js +87 -20
- package/dist/components-core/text.d.mts +10 -0
- package/dist/components-core/text.d.ts +5 -3
- package/dist/components-core/text.js +95 -40
- package/dist/components-core-joy/button.d.mts +6 -0
- package/dist/components-core-joy/button.d.ts +6 -2
- package/dist/components-core-joy/button.js +86 -28
- package/dist/components-core-joy/input.d.mts +5 -0
- package/dist/components-core-joy/input.d.ts +5 -2
- package/dist/components-core-joy/input.js +51 -6
- package/dist/components-core-joy/separator.d.mts +6 -0
- package/dist/components-core-joy/separator.d.ts +6 -2
- package/dist/components-core-joy/separator.js +50 -6
- package/dist/components-core-joy/tabs.d.mts +9 -0
- package/dist/components-core-joy/tabs.d.ts +9 -5
- package/dist/components-core-joy/tabs.js +62 -16
- package/dist/components-core-joy/text.d.mts +9 -0
- package/dist/components-core-joy/text.d.ts +6 -3
- package/dist/components-core-joy/text.js +68 -28
- package/dist/components-page/account-settings.d.mts +7 -0
- package/dist/components-page/account-settings.d.ts +6 -2
- package/dist/components-page/account-settings.js +213 -81
- package/dist/components-page/auth-page.d.mts +8 -0
- package/dist/components-page/auth-page.d.ts +6 -2
- package/dist/components-page/auth-page.js +79 -19
- package/dist/components-page/email-verification.d.mts +8 -0
- package/dist/components-page/email-verification.d.ts +6 -2
- package/dist/components-page/email-verification.js +65 -28
- package/dist/components-page/forgot-password.d.mts +7 -0
- package/dist/components-page/forgot-password.d.ts +6 -2
- package/dist/components-page/forgot-password.js +64 -20
- package/dist/components-page/magic-link-callback.d.mts +8 -0
- package/dist/components-page/magic-link-callback.d.ts +6 -2
- package/dist/components-page/magic-link-callback.js +72 -34
- package/dist/components-page/oauth-callback.d.mts +5 -0
- package/dist/components-page/oauth-callback.d.ts +5 -1
- package/dist/components-page/oauth-callback.js +52 -16
- package/dist/components-page/password-reset.d.mts +8 -0
- package/dist/components-page/password-reset.d.ts +6 -2
- package/dist/components-page/password-reset.js +70 -34
- package/dist/components-page/sign-in.d.mts +7 -0
- package/dist/components-page/sign-in.d.ts +6 -2
- package/dist/components-page/sign-in.js +41 -5
- package/dist/components-page/sign-out.d.mts +5 -0
- package/dist/components-page/sign-out.d.ts +5 -1
- package/dist/components-page/sign-out.js +47 -11
- package/dist/components-page/sign-up.d.mts +7 -0
- package/dist/components-page/sign-up.d.ts +6 -2
- package/dist/components-page/sign-up.js +41 -5
- package/dist/components-page/stack-handler.d.mts +16 -0
- package/dist/components-page/stack-handler.d.ts +11 -3
- package/dist/components-page/stack-handler.js +102 -64
- package/dist/esm/components/card-frame.js +39 -0
- package/dist/esm/components/credential-sign-in.js +82 -0
- package/dist/esm/components/credential-sign-up.js +114 -0
- package/dist/esm/components/forgot-password.js +55 -0
- package/dist/esm/components/form-warning.js +15 -0
- package/dist/esm/components/magic-link-sign-in.js +61 -0
- package/dist/esm/components/message-card.js +16 -0
- package/dist/esm/components/oauth-button.js +124 -0
- package/dist/esm/components/oauth-group.js +17 -0
- package/dist/esm/components/password-field.js +82 -0
- package/dist/esm/components/password-reset-inner.js +93 -0
- package/dist/esm/components/redirect-message-card.js +83 -0
- package/dist/esm/components/separator-with-text.js +16 -0
- package/dist/esm/components/user-avatar.js +14 -0
- package/dist/esm/components/user-button.js +133 -0
- package/dist/esm/components-core/avatar.js +56 -0
- package/dist/esm/components-core/button.js +165 -0
- package/dist/esm/components-core/card.js +51 -0
- package/dist/esm/components-core/collapsible.js +13 -0
- package/dist/esm/components-core/container.js +35 -0
- package/dist/esm/components-core/dropdown.js +106 -0
- package/dist/esm/components-core/index.js +93 -0
- package/dist/esm/components-core/input.js +80 -0
- package/dist/esm/components-core/label.js +38 -0
- package/dist/esm/components-core/link.js +38 -0
- package/dist/esm/components-core/loading-indicator.js +27 -0
- package/dist/esm/components-core/popover.js +43 -0
- package/dist/esm/components-core/separator.js +36 -0
- package/dist/esm/components-core/skeleton.js +52 -0
- package/dist/esm/components-core/tabs.js +79 -0
- package/dist/esm/components-core/text.js +63 -0
- package/dist/esm/components-core-joy/button.js +53 -0
- package/dist/esm/components-core-joy/input.js +18 -0
- package/dist/esm/components-core-joy/separator.js +17 -0
- package/dist/esm/components-core-joy/tabs.js +29 -0
- package/dist/esm/components-core-joy/text.js +35 -0
- package/dist/esm/components-page/account-settings.js +197 -0
- package/dist/esm/components-page/auth-page.js +50 -0
- package/dist/esm/components-page/email-verification.js +36 -0
- package/dist/esm/components-page/forgot-password.js +35 -0
- package/dist/esm/components-page/magic-link-callback.js +43 -0
- package/dist/esm/components-page/oauth-callback.js +23 -0
- package/dist/esm/components-page/password-reset.js +42 -0
- package/dist/esm/components-page/sign-in.js +12 -0
- package/dist/esm/components-page/sign-out.js +18 -0
- package/dist/esm/components-page/sign-up.js +12 -0
- package/dist/esm/components-page/stack-handler.js +75 -0
- package/dist/esm/index.js +47 -0
- package/dist/esm/joy.js +5 -0
- package/dist/esm/lib/auth.js +62 -0
- package/dist/esm/lib/cookie.js +185 -0
- package/dist/esm/lib/hooks.js +29 -0
- package/dist/esm/lib/stack-app.js +940 -0
- package/dist/esm/providers/component-provider.js +76 -0
- package/dist/esm/providers/design-provider.js +36 -0
- package/dist/esm/providers/joy-provider.js +35 -0
- package/dist/esm/providers/stack-provider-client.js +31 -0
- package/dist/esm/providers/stack-provider.js +21 -0
- package/dist/esm/providers/styled-components-registry.js +24 -0
- package/dist/esm/providers/theme-provider.js +22 -0
- package/dist/esm/utils/browser-script.js +25 -0
- package/dist/esm/utils/constants.js +34 -0
- package/dist/esm/utils/email.js +10 -0
- package/dist/esm/utils/next.js +7 -0
- package/dist/esm/utils/url.js +21 -0
- package/dist/index.d.mts +37 -0
- package/dist/index.d.ts +37 -22
- package/dist/index.js +106 -21
- package/dist/joy.d.mts +16 -0
- package/dist/joy.d.ts +16 -1
- package/dist/joy.js +30 -1
- package/dist/lib/auth.d.mts +11 -0
- package/dist/lib/auth.d.ts +8 -4
- package/dist/lib/auth.js +83 -57
- package/dist/lib/cookie.d.mts +14 -0
- package/dist/lib/cookie.d.ts +8 -6
- package/dist/lib/cookie.js +217 -45
- package/dist/lib/hooks.d.mts +35 -0
- package/dist/lib/hooks.d.ts +14 -8
- package/dist/lib/hooks.js +53 -28
- package/dist/lib/stack-app.d.mts +227 -0
- package/dist/lib/stack-app.d.ts +43 -41
- package/dist/lib/stack-app.js +937 -849
- package/dist/providers/component-provider.d.mts +113 -0
- package/dist/providers/component-provider.d.ts +95 -77
- package/dist/providers/component-provider.js +92 -58
- package/dist/providers/design-provider.d.mts +34 -0
- package/dist/providers/design-provider.d.ts +16 -21
- package/dist/providers/design-provider.js +57 -58
- package/dist/providers/joy-provider.d.mts +36 -0
- package/dist/providers/joy-provider.d.ts +30 -14
- package/dist/providers/joy-provider.js +58 -30
- package/dist/providers/stack-provider-client.d.mts +20 -0
- package/dist/providers/stack-provider-client.d.ts +15 -8
- package/dist/providers/stack-provider-client.js +64 -20
- package/dist/providers/stack-provider.d.mts +14 -0
- package/dist/providers/stack-provider.d.ts +13 -5
- package/dist/providers/stack-provider.js +39 -8
- package/dist/providers/styled-components-registry.d.mts +8 -0
- package/dist/providers/styled-components-registry.d.ts +8 -4
- package/dist/providers/styled-components-registry.js +43 -17
- package/dist/providers/theme-provider.d.mts +22 -0
- package/dist/providers/theme-provider.d.ts +21 -9
- package/dist/providers/theme-provider.js +55 -19
- package/dist/utils/browser-script.d.mts +5 -0
- package/dist/utils/browser-script.d.ts +5 -0
- package/dist/utils/browser-script.js +50 -0
- package/dist/utils/constants.d.mts +48 -0
- package/dist/utils/constants.d.ts +11 -9
- package/dist/utils/constants.js +66 -21
- package/dist/utils/email.d.mts +3 -0
- package/dist/utils/email.d.ts +3 -1
- package/dist/utils/email.js +44 -6
- package/dist/utils/next.d.mts +3 -0
- package/dist/utils/next.d.ts +3 -1
- package/dist/utils/next.js +31 -3
- package/dist/utils/url.d.mts +4 -0
- package/dist/utils/url.d.ts +4 -2
- package/dist/utils/url.js +44 -13
- package/package.json +20 -10
package/dist/joy.js
CHANGED
|
@@ -1 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/joy.tsx
|
|
21
|
+
var joy_exports = {};
|
|
22
|
+
__export(joy_exports, {
|
|
23
|
+
StackJoyTheme: () => import_joy_provider.StackJoyTheme
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(joy_exports);
|
|
26
|
+
var import_joy_provider = require("./providers/joy-provider");
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
StackJoyTheme
|
|
30
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as oauth4webapi from 'oauth4webapi';
|
|
2
|
+
import { StackClientInterface } from '@stackframe/stack-shared';
|
|
3
|
+
import { TokenStore } from '@stackframe/stack-shared/dist/interface/clientInterface';
|
|
4
|
+
|
|
5
|
+
declare function signInWithOAuth(iface: StackClientInterface, { provider, redirectUrl, }: {
|
|
6
|
+
provider: string;
|
|
7
|
+
redirectUrl?: string;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
declare function callOAuthCallback(iface: StackClientInterface, tokenStore: TokenStore, redirectUrl: string): Promise<oauth4webapi.OAuth2TokenEndpointResponse | null>;
|
|
10
|
+
|
|
11
|
+
export { callOAuthCallback, signInWithOAuth };
|
package/dist/lib/auth.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import * as oauth4webapi from 'oauth4webapi';
|
|
2
|
+
import { StackClientInterface } from '@stackframe/stack-shared';
|
|
3
|
+
import { TokenStore } from '@stackframe/stack-shared/dist/interface/clientInterface';
|
|
4
|
+
|
|
5
|
+
declare function signInWithOAuth(iface: StackClientInterface, { provider, redirectUrl, }: {
|
|
4
6
|
provider: string;
|
|
5
7
|
redirectUrl?: string;
|
|
6
8
|
}): Promise<void>;
|
|
7
|
-
|
|
9
|
+
declare function callOAuthCallback(iface: StackClientInterface, tokenStore: TokenStore, redirectUrl: string): Promise<oauth4webapi.OAuth2TokenEndpointResponse | null>;
|
|
10
|
+
|
|
11
|
+
export { callOAuthCallback, signInWithOAuth };
|
package/dist/lib/auth.js
CHANGED
|
@@ -1,62 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/lib/auth.ts
|
|
21
|
+
var auth_exports = {};
|
|
22
|
+
__export(auth_exports, {
|
|
23
|
+
callOAuthCallback: () => callOAuthCallback,
|
|
24
|
+
signInWithOAuth: () => signInWithOAuth
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(auth_exports);
|
|
27
|
+
var import_cookie = require("./cookie");
|
|
28
|
+
var import_url = require("../utils/url");
|
|
29
|
+
var import_promises = require("@stackframe/stack-shared/dist/utils/promises");
|
|
30
|
+
var import_errors = require("@stackframe/stack-shared/dist/utils/errors");
|
|
31
|
+
async function signInWithOAuth(iface, {
|
|
32
|
+
provider,
|
|
33
|
+
redirectUrl
|
|
34
|
+
}) {
|
|
35
|
+
redirectUrl = (0, import_url.constructRedirectUrl)(redirectUrl);
|
|
36
|
+
const { codeChallenge, state } = await (0, import_cookie.saveVerifierAndState)();
|
|
37
|
+
const location = await iface.getOAuthUrl(
|
|
38
|
+
provider,
|
|
39
|
+
redirectUrl,
|
|
40
|
+
codeChallenge,
|
|
41
|
+
state
|
|
42
|
+
);
|
|
43
|
+
window.location.assign(location);
|
|
44
|
+
await (0, import_promises.neverResolve)();
|
|
11
45
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Checks if the current URL has the query parameters for an OAuth callback, and if so, removes them.
|
|
14
|
-
*
|
|
15
|
-
* Must be synchronous for the logic in callOAuthCallback to work without race conditions.
|
|
16
|
-
*/
|
|
17
46
|
function consumeOAuthCallbackQueryParams(expectedState) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
47
|
+
const requiredParams = ["code", "state"];
|
|
48
|
+
const originalUrl = new URL(window.location.href);
|
|
49
|
+
for (const param of requiredParams) {
|
|
50
|
+
if (!originalUrl.searchParams.has(param)) {
|
|
51
|
+
return null;
|
|
24
52
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// don't redirect to `redirectUrl` if there's a validation error
|
|
36
|
-
// (as the redirectUrl might be malicious!).
|
|
37
|
-
//
|
|
38
|
-
// We use history.replaceState instead of location.assign(...) to
|
|
39
|
-
// prevent an unnecessary reload
|
|
40
|
-
window.history.replaceState({}, "", newUrl.toString());
|
|
41
|
-
return originalUrl;
|
|
53
|
+
}
|
|
54
|
+
if (expectedState !== originalUrl.searchParams.get("state")) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const newUrl = new URL(originalUrl);
|
|
58
|
+
for (const param of requiredParams) {
|
|
59
|
+
newUrl.searchParams.delete(param);
|
|
60
|
+
}
|
|
61
|
+
window.history.replaceState({}, "", newUrl.toString());
|
|
62
|
+
return originalUrl;
|
|
42
63
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
async function callOAuthCallback(iface, tokenStore, redirectUrl) {
|
|
65
|
+
const { codeVerifier, state } = (0, import_cookie.getVerifierAndState)();
|
|
66
|
+
if (!codeVerifier || !state) {
|
|
67
|
+
throw new Error("Invalid OAuth callback URL parameters. It seems like the OAuth flow was interrupted, so please try again.");
|
|
68
|
+
}
|
|
69
|
+
const originalUrl = consumeOAuthCallbackQueryParams(state);
|
|
70
|
+
if (!originalUrl)
|
|
71
|
+
return null;
|
|
72
|
+
try {
|
|
73
|
+
return await iface.callOAuthCallback(
|
|
74
|
+
originalUrl.searchParams,
|
|
75
|
+
(0, import_url.constructRedirectUrl)(redirectUrl),
|
|
76
|
+
codeVerifier,
|
|
77
|
+
state,
|
|
78
|
+
tokenStore
|
|
79
|
+
);
|
|
80
|
+
} catch (e) {
|
|
81
|
+
throw new import_errors.StackAssertionError("Error signing in during OAuth callback. Please try again.", { cause: e });
|
|
82
|
+
}
|
|
62
83
|
}
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
callOAuthCallback,
|
|
87
|
+
signInWithOAuth
|
|
88
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare function getCookie(name: string): string | null;
|
|
2
|
+
declare function setOrDeleteCookie(name: string, value: string | null): void;
|
|
3
|
+
declare function deleteCookie(name: string): void;
|
|
4
|
+
declare function setCookie(name: string, value: string): void;
|
|
5
|
+
declare function saveVerifierAndState(): Promise<{
|
|
6
|
+
codeChallenge: string;
|
|
7
|
+
state: string;
|
|
8
|
+
}>;
|
|
9
|
+
declare function getVerifierAndState(): {
|
|
10
|
+
codeVerifier: string | null;
|
|
11
|
+
state: string | null;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { deleteCookie, getCookie, getVerifierAndState, saveVerifierAndState, setCookie, setOrDeleteCookie };
|
package/dist/lib/cookie.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
declare function getCookie(name: string): string | null;
|
|
2
|
+
declare function setOrDeleteCookie(name: string, value: string | null): void;
|
|
3
|
+
declare function deleteCookie(name: string): void;
|
|
4
|
+
declare function setCookie(name: string, value: string): void;
|
|
5
|
+
declare function saveVerifierAndState(): Promise<{
|
|
6
6
|
codeChallenge: string;
|
|
7
7
|
state: string;
|
|
8
8
|
}>;
|
|
9
|
-
|
|
9
|
+
declare function getVerifierAndState(): {
|
|
10
10
|
codeVerifier: string | null;
|
|
11
11
|
state: string | null;
|
|
12
12
|
};
|
|
13
|
+
|
|
14
|
+
export { deleteCookie, getCookie, getVerifierAndState, saveVerifierAndState, setCookie, setOrDeleteCookie };
|
package/dist/lib/cookie.js
CHANGED
|
@@ -1,55 +1,227 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/lib/cookie.ts
|
|
31
|
+
var cookie_exports = {};
|
|
32
|
+
__export(cookie_exports, {
|
|
33
|
+
deleteCookie: () => deleteCookie,
|
|
34
|
+
getCookie: () => getCookie,
|
|
35
|
+
getVerifierAndState: () => getVerifierAndState,
|
|
36
|
+
saveVerifierAndState: () => saveVerifierAndState,
|
|
37
|
+
setCookie: () => setCookie,
|
|
38
|
+
setOrDeleteCookie: () => setOrDeleteCookie
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(cookie_exports);
|
|
41
|
+
|
|
42
|
+
// ../../node_modules/.pnpm/oauth4webapi@2.10.3/node_modules/oauth4webapi/build/index.js
|
|
43
|
+
var USER_AGENT;
|
|
44
|
+
if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) {
|
|
45
|
+
const NAME = "oauth4webapi";
|
|
46
|
+
const VERSION = "v2.10.3";
|
|
47
|
+
USER_AGENT = `${NAME}/${VERSION}`;
|
|
48
|
+
}
|
|
49
|
+
var clockSkew = Symbol();
|
|
50
|
+
var clockTolerance = Symbol();
|
|
51
|
+
var customFetch = Symbol();
|
|
52
|
+
var useMtlsAlias = Symbol();
|
|
53
|
+
var encoder = new TextEncoder();
|
|
54
|
+
var decoder = new TextDecoder();
|
|
55
|
+
function buf(input) {
|
|
56
|
+
if (typeof input === "string") {
|
|
57
|
+
return encoder.encode(input);
|
|
58
|
+
}
|
|
59
|
+
return decoder.decode(input);
|
|
60
|
+
}
|
|
61
|
+
var CHUNK_SIZE = 32768;
|
|
62
|
+
function encodeBase64Url(input) {
|
|
63
|
+
if (input instanceof ArrayBuffer) {
|
|
64
|
+
input = new Uint8Array(input);
|
|
65
|
+
}
|
|
66
|
+
const arr = [];
|
|
67
|
+
for (let i = 0; i < input.byteLength; i += CHUNK_SIZE) {
|
|
68
|
+
arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
|
|
69
|
+
}
|
|
70
|
+
return btoa(arr.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
71
|
+
}
|
|
72
|
+
function decodeBase64Url(input) {
|
|
73
|
+
try {
|
|
74
|
+
const binary = atob(input.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, ""));
|
|
75
|
+
const bytes = new Uint8Array(binary.length);
|
|
76
|
+
for (let i = 0; i < binary.length; i++) {
|
|
77
|
+
bytes[i] = binary.charCodeAt(i);
|
|
11
78
|
}
|
|
79
|
+
return bytes;
|
|
80
|
+
} catch (cause) {
|
|
81
|
+
throw new OPE("The input to be decoded is not correctly encoded.", { cause });
|
|
82
|
+
}
|
|
12
83
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
84
|
+
function b64u(input) {
|
|
85
|
+
if (typeof input === "string") {
|
|
86
|
+
return decodeBase64Url(input);
|
|
87
|
+
}
|
|
88
|
+
return encodeBase64Url(input);
|
|
89
|
+
}
|
|
90
|
+
var LRU = class {
|
|
91
|
+
constructor(maxSize) {
|
|
92
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
93
|
+
this._cache = /* @__PURE__ */ new Map();
|
|
94
|
+
this.maxSize = maxSize;
|
|
95
|
+
}
|
|
96
|
+
get(key) {
|
|
97
|
+
let v = this.cache.get(key);
|
|
98
|
+
if (v) {
|
|
99
|
+
return v;
|
|
16
100
|
}
|
|
17
|
-
|
|
18
|
-
|
|
101
|
+
if (v = this._cache.get(key)) {
|
|
102
|
+
this.update(key, v);
|
|
103
|
+
return v;
|
|
19
104
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
105
|
+
return void 0;
|
|
106
|
+
}
|
|
107
|
+
has(key) {
|
|
108
|
+
return this.cache.has(key) || this._cache.has(key);
|
|
109
|
+
}
|
|
110
|
+
set(key, value) {
|
|
111
|
+
if (this.cache.has(key)) {
|
|
112
|
+
this.cache.set(key, value);
|
|
113
|
+
} else {
|
|
114
|
+
this.update(key, value);
|
|
24
115
|
}
|
|
25
|
-
|
|
26
|
-
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
delete(key) {
|
|
119
|
+
if (this.cache.has(key)) {
|
|
120
|
+
return this.cache.delete(key);
|
|
27
121
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (rscCookies) {
|
|
31
|
-
rscCookies().set(name, value);
|
|
122
|
+
if (this._cache.has(key)) {
|
|
123
|
+
return this._cache.delete(key);
|
|
32
124
|
}
|
|
33
|
-
|
|
34
|
-
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
update(key, value) {
|
|
128
|
+
this.cache.set(key, value);
|
|
129
|
+
if (this.cache.size >= this.maxSize) {
|
|
130
|
+
this._cache = this.cache;
|
|
131
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
35
132
|
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
var OperationProcessingError = class extends Error {
|
|
136
|
+
constructor(message, options) {
|
|
137
|
+
super(message, options);
|
|
138
|
+
this.name = this.constructor.name;
|
|
139
|
+
Error.captureStackTrace?.(this, this.constructor);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
var OPE = OperationProcessingError;
|
|
143
|
+
var dpopNonces = new LRU(100);
|
|
144
|
+
function validateString(input) {
|
|
145
|
+
return typeof input === "string" && input.length !== 0;
|
|
146
|
+
}
|
|
147
|
+
function randomBytes() {
|
|
148
|
+
return b64u(crypto.getRandomValues(new Uint8Array(32)));
|
|
149
|
+
}
|
|
150
|
+
function generateRandomCodeVerifier() {
|
|
151
|
+
return randomBytes();
|
|
152
|
+
}
|
|
153
|
+
function generateRandomState() {
|
|
154
|
+
return randomBytes();
|
|
155
|
+
}
|
|
156
|
+
async function calculatePKCECodeChallenge(codeVerifier) {
|
|
157
|
+
if (!validateString(codeVerifier)) {
|
|
158
|
+
throw new TypeError('"codeVerifier" must be a non-empty string');
|
|
159
|
+
}
|
|
160
|
+
return b64u(await crypto.subtle.digest("SHA-256", buf(codeVerifier)));
|
|
161
|
+
}
|
|
162
|
+
var skipSubjectCheck = Symbol();
|
|
163
|
+
var expectNoNonce = Symbol();
|
|
164
|
+
var skipAuthTimeCheck = Symbol();
|
|
165
|
+
var noSignatureCheck = Symbol();
|
|
166
|
+
var skipStateCheck = Symbol();
|
|
167
|
+
var expectNoState = Symbol();
|
|
168
|
+
|
|
169
|
+
// src/lib/cookie.ts
|
|
170
|
+
var import_js_cookie = __toESM(require("js-cookie"));
|
|
171
|
+
var import_stack_sc = require("@stackframe/stack-sc");
|
|
172
|
+
function getCookie(name) {
|
|
173
|
+
if (import_stack_sc.cookies) {
|
|
174
|
+
return (0, import_stack_sc.cookies)().get(name)?.value ?? null;
|
|
175
|
+
} else {
|
|
176
|
+
return import_js_cookie.default.get(name) ?? null;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function setOrDeleteCookie(name, value) {
|
|
180
|
+
if (value === null) {
|
|
181
|
+
deleteCookie(name);
|
|
182
|
+
} else {
|
|
183
|
+
setCookie(name, value);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function deleteCookie(name) {
|
|
187
|
+
if (import_stack_sc.cookies) {
|
|
188
|
+
(0, import_stack_sc.cookies)().delete(name);
|
|
189
|
+
} else {
|
|
190
|
+
import_js_cookie.default.remove(name);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function setCookie(name, value) {
|
|
194
|
+
if (import_stack_sc.cookies) {
|
|
195
|
+
(0, import_stack_sc.cookies)().set(name, value);
|
|
196
|
+
} else {
|
|
197
|
+
import_js_cookie.default.set(name, value, { secure: window.location.protocol === "https:" });
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
async function saveVerifierAndState() {
|
|
201
|
+
const codeVerifier = generateRandomCodeVerifier();
|
|
202
|
+
const codeChallenge = await calculatePKCECodeChallenge(codeVerifier);
|
|
203
|
+
const state = generateRandomState();
|
|
204
|
+
setCookie("stack-code-verifier", codeVerifier);
|
|
205
|
+
setCookie("stack-state", state);
|
|
206
|
+
return {
|
|
207
|
+
codeChallenge,
|
|
208
|
+
state
|
|
209
|
+
};
|
|
36
210
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
codeChallenge,
|
|
45
|
-
state,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
export function getVerifierAndState() {
|
|
49
|
-
const codeVerifier = getCookie("stack-code-verifier");
|
|
50
|
-
const state = getCookie("stack-state");
|
|
51
|
-
return {
|
|
52
|
-
codeVerifier,
|
|
53
|
-
state,
|
|
54
|
-
};
|
|
211
|
+
function getVerifierAndState() {
|
|
212
|
+
const codeVerifier = getCookie("stack-code-verifier");
|
|
213
|
+
const state = getCookie("stack-state");
|
|
214
|
+
return {
|
|
215
|
+
codeVerifier,
|
|
216
|
+
state
|
|
217
|
+
};
|
|
55
218
|
}
|
|
219
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
220
|
+
0 && (module.exports = {
|
|
221
|
+
deleteCookie,
|
|
222
|
+
getCookie,
|
|
223
|
+
getVerifierAndState,
|
|
224
|
+
saveVerifierAndState,
|
|
225
|
+
setCookie,
|
|
226
|
+
setOrDeleteCookie
|
|
227
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CurrentInternalUser, CurrentUser, StackClientApp, GetUserOptions as GetUserOptions$1 } from './stack-app.mjs';
|
|
2
|
+
import '@stackframe/stack-shared';
|
|
3
|
+
import '@stackframe/stack-shared/dist/interface/clientInterface';
|
|
4
|
+
import '@stackframe/stack-shared/dist/utils/json';
|
|
5
|
+
import '@stackframe/stack-shared/dist/interface/adminInterface';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns the current user object. Equivalent to `useStackApp().useUser()`.
|
|
9
|
+
*
|
|
10
|
+
* @returns the current user
|
|
11
|
+
*/
|
|
12
|
+
type GetUserOptions = GetUserOptions$1 & {
|
|
13
|
+
projectIdMustMatch?: string;
|
|
14
|
+
};
|
|
15
|
+
declare function useUser(options: GetUserOptions & {
|
|
16
|
+
or: 'redirect' | 'throw';
|
|
17
|
+
projectIdMustMatch: "internal";
|
|
18
|
+
}): CurrentInternalUser;
|
|
19
|
+
declare function useUser(options: GetUserOptions & {
|
|
20
|
+
or: 'redirect' | 'throw';
|
|
21
|
+
}): CurrentUser;
|
|
22
|
+
declare function useUser(options: GetUserOptions & {
|
|
23
|
+
projectIdMustMatch: "internal";
|
|
24
|
+
}): CurrentInternalUser | null;
|
|
25
|
+
declare function useUser(options?: GetUserOptions): CurrentUser | CurrentInternalUser | null;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the current Stack app associated with the StackProvider.
|
|
28
|
+
*
|
|
29
|
+
* @returns the current Stack app
|
|
30
|
+
*/
|
|
31
|
+
declare function useStackApp<ProjectId extends string>(options?: {
|
|
32
|
+
projectIdMustMatch?: ProjectId;
|
|
33
|
+
}): StackClientApp<true, ProjectId>;
|
|
34
|
+
|
|
35
|
+
export { useStackApp, useUser };
|
package/dist/lib/hooks.d.ts
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
import { CurrentUser, GetUserOptions as
|
|
1
|
+
import { CurrentInternalUser, CurrentUser, StackClientApp, GetUserOptions as GetUserOptions$1 } from './stack-app.js';
|
|
2
|
+
import '@stackframe/stack-shared';
|
|
3
|
+
import '@stackframe/stack-shared/dist/interface/clientInterface';
|
|
4
|
+
import '@stackframe/stack-shared/dist/utils/json';
|
|
5
|
+
import '@stackframe/stack-shared/dist/interface/adminInterface';
|
|
6
|
+
|
|
2
7
|
/**
|
|
3
8
|
* Returns the current user object. Equivalent to `useStackApp().useUser()`.
|
|
4
9
|
*
|
|
5
10
|
* @returns the current user
|
|
6
11
|
*/
|
|
7
|
-
type GetUserOptions =
|
|
12
|
+
type GetUserOptions = GetUserOptions$1 & {
|
|
8
13
|
projectIdMustMatch?: string;
|
|
9
14
|
};
|
|
10
|
-
|
|
15
|
+
declare function useUser(options: GetUserOptions & {
|
|
11
16
|
or: 'redirect' | 'throw';
|
|
12
17
|
projectIdMustMatch: "internal";
|
|
13
18
|
}): CurrentInternalUser;
|
|
14
|
-
|
|
19
|
+
declare function useUser(options: GetUserOptions & {
|
|
15
20
|
or: 'redirect' | 'throw';
|
|
16
21
|
}): CurrentUser;
|
|
17
|
-
|
|
22
|
+
declare function useUser(options: GetUserOptions & {
|
|
18
23
|
projectIdMustMatch: "internal";
|
|
19
24
|
}): CurrentInternalUser | null;
|
|
20
|
-
|
|
25
|
+
declare function useUser(options?: GetUserOptions): CurrentUser | CurrentInternalUser | null;
|
|
21
26
|
/**
|
|
22
27
|
* Returns the current Stack app associated with the StackProvider.
|
|
23
28
|
*
|
|
24
29
|
* @returns the current Stack app
|
|
25
30
|
*/
|
|
26
|
-
|
|
31
|
+
declare function useStackApp<ProjectId extends string>(options?: {
|
|
27
32
|
projectIdMustMatch?: ProjectId;
|
|
28
33
|
}): StackClientApp<true, ProjectId>;
|
|
29
|
-
|
|
34
|
+
|
|
35
|
+
export { useStackApp, useUser };
|