@stackframe/react 2.7.20 → 2.7.22
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/CHANGELOG.md +20 -0
- package/dist/admin-app-impl-BN0oFR_r.d.mts +395 -0
- package/dist/admin-app-impl-DUgwqr7u.d.ts +395 -0
- package/dist/components/credential-sign-in.js.map +1 -1
- package/dist/components/credential-sign-up.js.map +1 -1
- package/dist/components/elements/form-warning.js.map +1 -1
- package/dist/components/elements/maybe-full-page.js.map +1 -1
- package/dist/components/elements/separator-with-text.js.map +1 -1
- package/dist/components/elements/sidebar-layout.js.map +1 -1
- package/dist/components/elements/ssr-layout-effect.js.map +1 -1
- package/dist/components/elements/user-avatar.js.map +1 -1
- package/dist/components/iframe-preventer.js.map +1 -1
- package/dist/components/link.js.map +1 -1
- package/dist/components/magic-link-sign-in.js.map +1 -1
- package/dist/components/message-cards/known-error-message-card.js.map +1 -1
- package/dist/components/message-cards/message-card.js.map +1 -1
- package/dist/components/message-cards/predefined-message-card.js.map +1 -1
- package/dist/components/oauth-button-group.js.map +1 -1
- package/dist/components/oauth-button.js.map +1 -1
- package/dist/components/passkey-button.js.map +1 -1
- package/dist/components/profile-image-editor.js.map +1 -1
- package/dist/components/selected-team-switcher.d.mts +18 -6
- package/dist/components/selected-team-switcher.d.ts +18 -6
- package/dist/components/selected-team-switcher.js.map +1 -1
- package/dist/components/team-icon.d.mts +18 -6
- package/dist/components/team-icon.d.ts +18 -6
- package/dist/components/team-icon.js.map +1 -1
- package/dist/components/user-button.js.map +1 -1
- package/dist/components-page/account-settings.js.map +1 -1
- package/dist/components-page/auth-page.js.map +1 -1
- package/dist/components-page/email-verification.js.map +1 -1
- package/dist/components-page/error-page.js.map +1 -1
- package/dist/components-page/forgot-password.js.map +1 -1
- package/dist/components-page/magic-link-callback.js.map +1 -1
- package/dist/components-page/oauth-callback.js.map +1 -1
- package/dist/components-page/password-reset.js.map +1 -1
- package/dist/components-page/sign-in.js.map +1 -1
- package/dist/components-page/sign-out.js.map +1 -1
- package/dist/components-page/sign-up.js.map +1 -1
- package/dist/components-page/stack-handler.d.mts +18 -6
- package/dist/components-page/stack-handler.d.ts +18 -6
- package/dist/components-page/stack-handler.js.map +1 -1
- package/dist/components-page/team-creation.js.map +1 -1
- package/dist/components-page/team-invitation.js.map +1 -1
- package/dist/esm/components/credential-sign-in.js.map +1 -1
- package/dist/esm/components/credential-sign-up.js.map +1 -1
- package/dist/esm/components/elements/form-warning.js.map +1 -1
- package/dist/esm/components/elements/maybe-full-page.js.map +1 -1
- package/dist/esm/components/elements/separator-with-text.js.map +1 -1
- package/dist/esm/components/elements/sidebar-layout.js.map +1 -1
- package/dist/esm/components/elements/ssr-layout-effect.js.map +1 -1
- package/dist/esm/components/elements/user-avatar.js.map +1 -1
- package/dist/esm/components/iframe-preventer.js.map +1 -1
- package/dist/esm/components/link.js.map +1 -1
- package/dist/esm/components/magic-link-sign-in.js.map +1 -1
- package/dist/esm/components/message-cards/known-error-message-card.js.map +1 -1
- package/dist/esm/components/message-cards/message-card.js.map +1 -1
- package/dist/esm/components/message-cards/predefined-message-card.js.map +1 -1
- package/dist/esm/components/oauth-button-group.js.map +1 -1
- package/dist/esm/components/oauth-button.js.map +1 -1
- package/dist/esm/components/passkey-button.js.map +1 -1
- package/dist/esm/components/profile-image-editor.js.map +1 -1
- package/dist/esm/components/selected-team-switcher.js.map +1 -1
- package/dist/esm/components/team-icon.js.map +1 -1
- package/dist/esm/components/user-button.js.map +1 -1
- package/dist/esm/components-page/account-settings.js.map +1 -1
- package/dist/esm/components-page/auth-page.js.map +1 -1
- package/dist/esm/components-page/email-verification.js.map +1 -1
- package/dist/esm/components-page/error-page.js.map +1 -1
- package/dist/esm/components-page/forgot-password.js.map +1 -1
- package/dist/esm/components-page/magic-link-callback.js.map +1 -1
- package/dist/esm/components-page/oauth-callback.js.map +1 -1
- package/dist/esm/components-page/password-reset.js.map +1 -1
- package/dist/esm/components-page/sign-in.js.map +1 -1
- package/dist/esm/components-page/sign-out.js.map +1 -1
- package/dist/esm/components-page/sign-up.js.map +1 -1
- package/dist/esm/components-page/stack-handler.js.map +1 -1
- package/dist/esm/components-page/team-creation.js.map +1 -1
- package/dist/esm/components-page/team-invitation.js.map +1 -1
- package/dist/esm/generated/quetzal-translations.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/auth.js.map +1 -1
- package/dist/esm/lib/cookie.js +5 -8
- package/dist/esm/lib/cookie.js.map +1 -1
- package/dist/esm/lib/hooks.js.map +1 -1
- package/dist/esm/lib/stack-app/api-keys/index.js +14 -0
- package/dist/esm/lib/stack-app/api-keys/index.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +291 -0
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -0
- package/dist/esm/lib/{stack-app.js → stack-app/apps/implementations/client-app-impl.js} +38 -1110
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/common.js +143 -0
- package/dist/esm/lib/stack-app/apps/implementations/common.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/index.js +24 -0
- package/dist/esm/lib/stack-app/apps/implementations/index.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js +527 -0
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/index.js +16 -0
- package/dist/esm/lib/stack-app/apps/index.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js +7 -0
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js +7 -0
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.js +7 -0
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.js.map +1 -0
- package/dist/esm/lib/stack-app/common.js +6 -0
- package/dist/esm/lib/stack-app/common.js.map +1 -0
- package/dist/esm/lib/stack-app/connected-accounts/index.js +1 -0
- package/dist/esm/lib/stack-app/connected-accounts/index.js.map +1 -0
- package/dist/esm/lib/stack-app/contact-channels/index.js +39 -0
- package/dist/esm/lib/stack-app/contact-channels/index.js.map +1 -0
- package/dist/esm/lib/stack-app/email-templates/index.js +11 -0
- package/dist/esm/lib/stack-app/email-templates/index.js.map +1 -0
- package/dist/esm/lib/stack-app/index.js +16 -0
- package/dist/esm/lib/stack-app/index.js.map +1 -0
- package/dist/esm/lib/stack-app/permissions/index.js +20 -0
- package/dist/esm/lib/stack-app/permissions/index.js.map +1 -0
- package/dist/esm/lib/stack-app/project-configs/index.js +1 -0
- package/dist/esm/lib/stack-app/project-configs/index.js.map +1 -0
- package/dist/esm/lib/stack-app/projects/index.js +57 -0
- package/dist/esm/lib/stack-app/projects/index.js.map +1 -0
- package/dist/esm/lib/stack-app/teams/index.js +38 -0
- package/dist/esm/lib/stack-app/teams/index.js.map +1 -0
- package/dist/esm/lib/stack-app/users/index.js +47 -0
- package/dist/esm/lib/stack-app/users/index.js.map +1 -0
- package/dist/esm/lib/translations.js.map +1 -1
- package/dist/esm/providers/stack-provider-client.js.map +1 -1
- package/dist/esm/providers/stack-provider.js.map +1 -1
- package/dist/esm/providers/theme-provider.js.map +1 -1
- package/dist/esm/providers/translation-provider-client.js.map +1 -1
- package/dist/esm/providers/translation-provider.js.map +1 -1
- package/dist/esm/utils/browser-script.js.map +1 -1
- package/dist/esm/utils/constants.js.map +1 -1
- package/dist/esm/utils/url.js +4 -13
- package/dist/esm/utils/url.js.map +1 -1
- package/dist/generated/quetzal-translations.d.mts +2 -2
- package/dist/generated/quetzal-translations.d.ts +2 -2
- package/dist/generated/quetzal-translations.js.map +1 -1
- package/dist/{lib/stack-app.d.mts → index-CLnvv7mq.d.ts} +139 -354
- package/dist/{lib/stack-app.d.ts → index-aU2I3xr5.d.mts} +139 -354
- package/dist/index.d.mts +17 -5
- package/dist/index.d.ts +17 -5
- package/dist/index.js.map +1 -1
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/cookie.d.mts +2 -2
- package/dist/lib/cookie.d.ts +2 -2
- package/dist/lib/cookie.js +6 -9
- package/dist/lib/cookie.js.map +1 -1
- package/dist/lib/hooks.d.mts +17 -5
- package/dist/lib/hooks.d.ts +17 -5
- package/dist/lib/hooks.js.map +1 -1
- package/dist/lib/stack-app/api-keys/index.d.mts +40 -0
- package/dist/lib/stack-app/api-keys/index.d.ts +40 -0
- package/dist/lib/stack-app/api-keys/index.js +39 -0
- package/dist/lib/stack-app/api-keys/index.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.d.mts +30 -0
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.d.ts +30 -0
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +316 -0
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.d.mts +30 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.d.ts +30 -0
- package/dist/lib/{stack-app.js → stack-app/apps/implementations/client-app-impl.js} +76 -1153
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/common.d.mts +45 -0
- package/dist/lib/stack-app/apps/implementations/common.d.ts +45 -0
- package/dist/lib/stack-app/apps/implementations/common.js +188 -0
- package/dist/lib/stack-app/apps/implementations/common.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/index.d.mts +36 -0
- package/dist/lib/stack-app/apps/implementations/index.d.ts +36 -0
- package/dist/lib/stack-app/apps/implementations/index.js +51 -0
- package/dist/lib/stack-app/apps/implementations/index.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/server-app-impl.d.mts +30 -0
- package/dist/lib/stack-app/apps/implementations/server-app-impl.d.ts +30 -0
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +552 -0
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -0
- package/dist/lib/stack-app/apps/index.d.mts +23 -0
- package/dist/lib/stack-app/apps/index.d.ts +23 -0
- package/dist/lib/stack-app/apps/index.js +37 -0
- package/dist/lib/stack-app/apps/index.js.map +1 -0
- package/dist/lib/stack-app/apps/interfaces/admin-app.d.mts +23 -0
- package/dist/lib/stack-app/apps/interfaces/admin-app.d.ts +23 -0
- package/dist/lib/stack-app/apps/interfaces/admin-app.js +32 -0
- package/dist/lib/stack-app/apps/interfaces/admin-app.js.map +1 -0
- package/dist/lib/stack-app/apps/interfaces/client-app.d.mts +23 -0
- package/dist/lib/stack-app/apps/interfaces/client-app.d.ts +23 -0
- package/dist/lib/stack-app/apps/interfaces/client-app.js +32 -0
- package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -0
- package/dist/lib/stack-app/apps/interfaces/server-app.d.mts +23 -0
- package/dist/lib/stack-app/apps/interfaces/server-app.d.ts +23 -0
- package/dist/lib/stack-app/apps/interfaces/server-app.js +32 -0
- package/dist/lib/stack-app/apps/interfaces/server-app.js.map +1 -0
- package/dist/lib/stack-app/common.d.mts +63 -0
- package/dist/lib/stack-app/common.d.ts +63 -0
- package/dist/lib/stack-app/common.js +31 -0
- package/dist/lib/stack-app/common.js.map +1 -0
- package/dist/lib/stack-app/connected-accounts/index.d.mts +13 -0
- package/dist/lib/stack-app/connected-accounts/index.d.ts +13 -0
- package/dist/lib/stack-app/connected-accounts/index.js +19 -0
- package/dist/lib/stack-app/connected-accounts/index.js.map +1 -0
- package/dist/lib/stack-app/contact-channels/index.d.mts +38 -0
- package/dist/lib/stack-app/contact-channels/index.d.ts +38 -0
- package/dist/lib/stack-app/contact-channels/index.js +67 -0
- package/dist/lib/stack-app/contact-channels/index.js.map +1 -0
- package/dist/lib/stack-app/email-templates/index.d.mts +15 -0
- package/dist/lib/stack-app/email-templates/index.d.ts +15 -0
- package/dist/lib/stack-app/email-templates/index.js +36 -0
- package/dist/lib/stack-app/email-templates/index.js.map +1 -0
- package/dist/lib/stack-app/index.d.mts +23 -0
- package/dist/lib/stack-app/index.d.ts +23 -0
- package/dist/lib/stack-app/index.js +38 -0
- package/dist/lib/stack-app/index.js.map +1 -0
- package/dist/lib/stack-app/permissions/index.d.mts +21 -0
- package/dist/lib/stack-app/permissions/index.d.ts +21 -0
- package/dist/lib/stack-app/permissions/index.js +46 -0
- package/dist/lib/stack-app/permissions/index.js.map +1 -0
- package/dist/lib/stack-app/project-configs/index.d.mts +82 -0
- package/dist/lib/stack-app/project-configs/index.d.ts +82 -0
- package/dist/lib/stack-app/project-configs/index.js +19 -0
- package/dist/lib/stack-app/project-configs/index.js.map +1 -0
- package/dist/lib/stack-app/projects/index.d.mts +23 -0
- package/dist/lib/stack-app/projects/index.d.ts +23 -0
- package/dist/lib/stack-app/projects/index.js +83 -0
- package/dist/lib/stack-app/projects/index.js.map +1 -0
- package/dist/lib/stack-app/teams/index.d.mts +23 -0
- package/dist/lib/stack-app/teams/index.d.ts +23 -0
- package/dist/lib/stack-app/teams/index.js +66 -0
- package/dist/lib/stack-app/teams/index.js.map +1 -0
- package/dist/lib/stack-app/users/index.d.mts +23 -0
- package/dist/lib/stack-app/users/index.d.ts +23 -0
- package/dist/lib/stack-app/users/index.js +74 -0
- package/dist/lib/stack-app/users/index.js.map +1 -0
- package/dist/lib/translations.js.map +1 -1
- package/dist/providers/stack-provider-client.d.mts +17 -5
- package/dist/providers/stack-provider-client.d.ts +17 -5
- package/dist/providers/stack-provider-client.js.map +1 -1
- package/dist/providers/stack-provider.d.mts +18 -6
- package/dist/providers/stack-provider.d.ts +18 -6
- package/dist/providers/stack-provider.js.map +1 -1
- package/dist/providers/theme-provider.js.map +1 -1
- package/dist/providers/translation-provider-client.js.map +1 -1
- package/dist/providers/translation-provider.js.map +1 -1
- package/dist/utils/browser-script.js.map +1 -1
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/url.d.mts +1 -2
- package/dist/utils/url.d.ts +1 -2
- package/dist/utils/url.js +4 -14
- package/dist/utils/url.js.map +1 -1
- package/package.json +3 -3
- package/dist/esm/lib/stack-app.js.map +0 -1
- package/dist/lib/stack-app.js.map +0 -1
|
@@ -27,23 +27,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// src/lib/stack-app.ts
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
33
|
-
|
|
34
|
-
StackClientApp: () => StackClientApp,
|
|
35
|
-
StackServerApp: () => StackServerApp,
|
|
36
|
-
serverTeamPermissionDefinitionCreateOptionsToCrud: () => serverTeamPermissionDefinitionCreateOptionsToCrud,
|
|
37
|
-
serverTeamPermissionDefinitionUpdateOptionsToCrud: () => serverTeamPermissionDefinitionUpdateOptionsToCrud,
|
|
38
|
-
stackAppInternalsSymbol: () => stackAppInternalsSymbol
|
|
30
|
+
// src/lib/stack-app/apps/implementations/client-app-impl.ts
|
|
31
|
+
var client_app_impl_exports = {};
|
|
32
|
+
__export(client_app_impl_exports, {
|
|
33
|
+
_StackClientAppImplIncomplete: () => _StackClientAppImplIncomplete
|
|
39
34
|
});
|
|
40
|
-
module.exports = __toCommonJS(
|
|
35
|
+
module.exports = __toCommonJS(client_app_impl_exports);
|
|
41
36
|
var import_browser = require("@simplewebauthn/browser");
|
|
42
37
|
var import_stack_shared = require("@stackframe/stack-shared");
|
|
43
|
-
var import_production_mode = require("@stackframe/stack-shared/dist/helpers/production-mode");
|
|
44
38
|
var import_sessions = require("@stackframe/stack-shared/dist/sessions");
|
|
45
|
-
var import_bytes = require("@stackframe/stack-shared/dist/utils/bytes");
|
|
46
|
-
var import_caches = require("@stackframe/stack-shared/dist/utils/caches");
|
|
47
39
|
var import_env = require("@stackframe/stack-shared/dist/utils/env");
|
|
48
40
|
var import_errors = require("@stackframe/stack-shared/dist/utils/errors");
|
|
49
41
|
var import_maps = require("@stackframe/stack-shared/dist/utils/maps");
|
|
@@ -57,140 +49,27 @@ var import_urls = require("@stackframe/stack-shared/dist/utils/urls");
|
|
|
57
49
|
var import_uuids = require("@stackframe/stack-shared/dist/utils/uuids");
|
|
58
50
|
var cookie = __toESM(require("cookie"));
|
|
59
51
|
var import_react2 = __toESM(require("react"));
|
|
60
|
-
var import_url = require("
|
|
61
|
-
var import_auth = require("
|
|
62
|
-
var import_cookie = require("
|
|
52
|
+
var import_url = require("../../../../utils/url");
|
|
53
|
+
var import_auth = require("../../../auth");
|
|
54
|
+
var import_cookie = require("../../../cookie");
|
|
55
|
+
var import_common = require("../../common");
|
|
56
|
+
var import_contact_channels = require("../../contact-channels");
|
|
57
|
+
var import_projects = require("../../projects");
|
|
58
|
+
var import_teams = require("../../teams");
|
|
59
|
+
var import_users = require("../../users");
|
|
60
|
+
var import_common2 = require("./common");
|
|
61
|
+
var import_common3 = require("./common");
|
|
63
62
|
var isReactServer = false;
|
|
64
|
-
var clientVersion = "js @stackframe/react@2.7.20";
|
|
65
|
-
if (clientVersion.startsWith("STACK_COMPILE_TIME")) {
|
|
66
|
-
throw new import_errors.StackAssertionError("Client version was not replaced. Something went wrong during build!");
|
|
67
|
-
}
|
|
68
63
|
var process = globalThis.process ?? { env: {} };
|
|
69
|
-
function getUrls(partial) {
|
|
70
|
-
const handler = partial.handler ?? "/handler";
|
|
71
|
-
const home = partial.home ?? "/";
|
|
72
|
-
const afterSignIn = partial.afterSignIn ?? home;
|
|
73
|
-
return {
|
|
74
|
-
handler,
|
|
75
|
-
signIn: `${handler}/sign-in`,
|
|
76
|
-
afterSignIn: home,
|
|
77
|
-
signUp: `${handler}/sign-up`,
|
|
78
|
-
afterSignUp: afterSignIn,
|
|
79
|
-
signOut: `${handler}/sign-out`,
|
|
80
|
-
afterSignOut: home,
|
|
81
|
-
emailVerification: `${handler}/email-verification`,
|
|
82
|
-
passwordReset: `${handler}/password-reset`,
|
|
83
|
-
forgotPassword: `${handler}/forgot-password`,
|
|
84
|
-
oauthCallback: `${handler}/oauth-callback`,
|
|
85
|
-
magicLinkCallback: `${handler}/magic-link-callback`,
|
|
86
|
-
home,
|
|
87
|
-
accountSettings: `${handler}/account-settings`,
|
|
88
|
-
error: `${handler}/error`,
|
|
89
|
-
teamInvitation: `${handler}/team-invitation`,
|
|
90
|
-
...(0, import_objects.filterUndefined)(partial)
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function getDefaultProjectId() {
|
|
94
|
-
return process.env.NEXT_PUBLIC_STACK_PROJECT_ID || (0, import_errors.throwErr)(new Error("Welcome to Stack Auth! It seems that you haven't provided a project ID. Please create a project on the Stack dashboard at https://app.stack-auth.com and put it in the NEXT_PUBLIC_STACK_PROJECT_ID environment variable."));
|
|
95
|
-
}
|
|
96
|
-
function getDefaultPublishableClientKey() {
|
|
97
|
-
return process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY || (0, import_errors.throwErr)(new Error("Welcome to Stack Auth! It seems that you haven't provided a publishable client key. Please create an API key for your project on the Stack dashboard at https://app.stack-auth.com and copy your publishable client key into the NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY environment variable."));
|
|
98
|
-
}
|
|
99
|
-
function getDefaultSecretServerKey() {
|
|
100
|
-
return process.env.STACK_SECRET_SERVER_KEY || (0, import_errors.throwErr)(new Error("No secret server key provided. Please copy your key from the Stack dashboard and put your it in the STACK_SECRET_SERVER_KEY environment variable."));
|
|
101
|
-
}
|
|
102
|
-
function getDefaultSuperSecretAdminKey() {
|
|
103
|
-
return process.env.STACK_SUPER_SECRET_ADMIN_KEY || (0, import_errors.throwErr)(new Error("No super secret admin key provided. Please copy your key from the Stack dashboard and put it in the STACK_SUPER_SECRET_ADMIN_KEY environment variable."));
|
|
104
|
-
}
|
|
105
|
-
function getBaseUrl(userSpecifiedBaseUrl) {
|
|
106
|
-
let url;
|
|
107
|
-
if (userSpecifiedBaseUrl) {
|
|
108
|
-
if (typeof userSpecifiedBaseUrl === "string") {
|
|
109
|
-
url = userSpecifiedBaseUrl;
|
|
110
|
-
} else {
|
|
111
|
-
if ((0, import_env.isBrowserLike)()) {
|
|
112
|
-
url = userSpecifiedBaseUrl.browser;
|
|
113
|
-
} else {
|
|
114
|
-
url = userSpecifiedBaseUrl.server;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
} else {
|
|
118
|
-
if ((0, import_env.isBrowserLike)()) {
|
|
119
|
-
url = process.env.NEXT_PUBLIC_BROWSER_STACK_API_URL;
|
|
120
|
-
} else {
|
|
121
|
-
url = process.env.NEXT_PUBLIC_SERVER_STACK_API_URL;
|
|
122
|
-
}
|
|
123
|
-
url = url || process.env.NEXT_PUBLIC_STACK_API_URL || process.env.NEXT_PUBLIC_STACK_URL || defaultBaseUrl;
|
|
124
|
-
}
|
|
125
|
-
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
126
|
-
}
|
|
127
|
-
var defaultBaseUrl = "https://api.stack-auth.com";
|
|
128
|
-
function createEmptyTokenStore() {
|
|
129
|
-
return new import_stores.Store({
|
|
130
|
-
refreshToken: null,
|
|
131
|
-
accessToken: null
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
var cachePromiseByComponentId = /* @__PURE__ */ new Map();
|
|
135
|
-
function useAsyncCache(cache, dependencies, caller) {
|
|
136
|
-
(0, import_react.suspendIfSsr)(caller);
|
|
137
|
-
const id = import_react2.default.useId();
|
|
138
|
-
const subscribe = (0, import_react2.useCallback)((cb) => {
|
|
139
|
-
const { unsubscribe } = cache.onStateChange(dependencies, () => {
|
|
140
|
-
cachePromiseByComponentId.delete(id);
|
|
141
|
-
cb();
|
|
142
|
-
});
|
|
143
|
-
return unsubscribe;
|
|
144
|
-
}, [cache, ...dependencies]);
|
|
145
|
-
const getSnapshot = (0, import_react2.useCallback)(() => {
|
|
146
|
-
if (!cachePromiseByComponentId.has(id)) {
|
|
147
|
-
cachePromiseByComponentId.set(id, cache.getOrWait(dependencies, "read-write"));
|
|
148
|
-
}
|
|
149
|
-
return cachePromiseByComponentId.get(id);
|
|
150
|
-
}, [cache, ...dependencies]);
|
|
151
|
-
const promise = import_react2.default.useSyncExternalStore(
|
|
152
|
-
subscribe,
|
|
153
|
-
getSnapshot,
|
|
154
|
-
() => (0, import_errors.throwErr)(new Error("getServerSnapshot should never be called in useAsyncCache because we restrict to CSR earlier"))
|
|
155
|
-
);
|
|
156
|
-
const result = import_react2.default.use(promise);
|
|
157
|
-
if (result.status === "error") {
|
|
158
|
-
const error = result.error;
|
|
159
|
-
if (error instanceof Error && !error.__stackHasConcatenatedStacktraces) {
|
|
160
|
-
(0, import_errors.concatStacktraces)(error, new Error());
|
|
161
|
-
error.__stackHasConcatenatedStacktraces = true;
|
|
162
|
-
}
|
|
163
|
-
throw error;
|
|
164
|
-
}
|
|
165
|
-
return result.data;
|
|
166
|
-
}
|
|
167
|
-
var stackAppInternalsSymbol = Symbol.for("StackAuth--DO-NOT-USE-OR-YOU-WILL-BE-FIRED--StackAppInternals");
|
|
168
|
-
var allClientApps = /* @__PURE__ */ new Map();
|
|
169
|
-
var createCache = (fetcher) => {
|
|
170
|
-
return new import_caches.AsyncCache(
|
|
171
|
-
async (dependencies) => await import_results.Result.fromThrowingAsync(async () => await fetcher(dependencies)),
|
|
172
|
-
{}
|
|
173
|
-
);
|
|
174
|
-
};
|
|
175
|
-
var createCacheBySession = (fetcher) => {
|
|
176
|
-
return new import_caches.AsyncCache(
|
|
177
|
-
async ([session, ...extraDependencies]) => await import_results.Result.fromThrowingAsync(async () => await fetcher(session, extraDependencies)),
|
|
178
|
-
{
|
|
179
|
-
onSubscribe: ([session], refresh) => {
|
|
180
|
-
const handler = session.onInvalidate(() => refresh());
|
|
181
|
-
return () => handler.unsubscribe();
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
);
|
|
185
|
-
};
|
|
186
64
|
var numberOfAppsCreated = 0;
|
|
187
|
-
var
|
|
65
|
+
var allClientApps = /* @__PURE__ */ new Map();
|
|
66
|
+
var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
188
67
|
constructor(_options) {
|
|
189
68
|
this._options = _options;
|
|
190
69
|
this._uniqueIdentifier = void 0;
|
|
191
70
|
this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY = false;
|
|
192
71
|
this._ownedAdminApps = new import_maps.DependenciesMap();
|
|
193
|
-
this._currentUserCache = createCacheBySession(async (session) => {
|
|
72
|
+
this._currentUserCache = (0, import_common2.createCacheBySession)(async (session) => {
|
|
194
73
|
if (this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY) {
|
|
195
74
|
await (0, import_promises.wait)(2e3);
|
|
196
75
|
}
|
|
@@ -199,19 +78,19 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
199
78
|
}
|
|
200
79
|
return await this._interface.getClientUserByToken(session);
|
|
201
80
|
});
|
|
202
|
-
this._currentProjectCache = createCache(async () => {
|
|
81
|
+
this._currentProjectCache = (0, import_common2.createCache)(async () => {
|
|
203
82
|
return import_results.Result.orThrow(await this._interface.getClientProject());
|
|
204
83
|
});
|
|
205
|
-
this._ownedProjectsCache = createCacheBySession(async (session) => {
|
|
84
|
+
this._ownedProjectsCache = (0, import_common2.createCacheBySession)(async (session) => {
|
|
206
85
|
return await this._interface.listProjects(session);
|
|
207
86
|
});
|
|
208
|
-
this._currentUserPermissionsCache = createCacheBySession(async (session, [teamId, recursive]) => {
|
|
87
|
+
this._currentUserPermissionsCache = (0, import_common2.createCacheBySession)(async (session, [teamId, recursive]) => {
|
|
209
88
|
return await this._interface.listCurrentUserTeamPermissions({ teamId, recursive }, session);
|
|
210
89
|
});
|
|
211
|
-
this._currentUserTeamsCache = createCacheBySession(async (session) => {
|
|
90
|
+
this._currentUserTeamsCache = (0, import_common2.createCacheBySession)(async (session) => {
|
|
212
91
|
return await this._interface.listCurrentUserTeams(session);
|
|
213
92
|
});
|
|
214
|
-
this._currentUserOAuthConnectionAccessTokensCache = createCacheBySession(
|
|
93
|
+
this._currentUserOAuthConnectionAccessTokensCache = (0, import_common2.createCacheBySession)(
|
|
215
94
|
async (session, [providerId, scope]) => {
|
|
216
95
|
try {
|
|
217
96
|
const result = await this._interface.createProviderAccessToken(providerId, scope || "", session);
|
|
@@ -224,12 +103,12 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
224
103
|
return null;
|
|
225
104
|
}
|
|
226
105
|
);
|
|
227
|
-
this._currentUserOAuthConnectionCache = createCacheBySession(
|
|
106
|
+
this._currentUserOAuthConnectionCache = (0, import_common2.createCacheBySession)(
|
|
228
107
|
async (session, [providerId, scope, redirect]) => {
|
|
229
108
|
return await this._getUserOAuthConnectionCacheFn({
|
|
230
109
|
getUser: async () => import_results.Result.orThrow(await this._currentUserCache.getOrWait([session], "write-only")),
|
|
231
110
|
getOrWaitOAuthToken: async () => import_results.Result.orThrow(await this._currentUserOAuthConnectionAccessTokensCache.getOrWait([session, providerId, scope || ""], "write-only")),
|
|
232
|
-
useOAuthToken: () => useAsyncCache(this._currentUserOAuthConnectionAccessTokensCache, [session, providerId, scope || ""], "useOAuthToken"),
|
|
111
|
+
useOAuthToken: () => (0, import_common3.useAsyncCache)(this._currentUserOAuthConnectionAccessTokensCache, [session, providerId, scope || ""], "useOAuthToken"),
|
|
233
112
|
providerId,
|
|
234
113
|
scope,
|
|
235
114
|
redirect,
|
|
@@ -237,27 +116,28 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
237
116
|
});
|
|
238
117
|
}
|
|
239
118
|
);
|
|
240
|
-
this._teamMemberProfilesCache = createCacheBySession(
|
|
119
|
+
this._teamMemberProfilesCache = (0, import_common2.createCacheBySession)(
|
|
241
120
|
async (session, [teamId]) => {
|
|
242
121
|
return await this._interface.listTeamMemberProfiles({ teamId }, session);
|
|
243
122
|
}
|
|
244
123
|
);
|
|
245
|
-
this._teamInvitationsCache = createCacheBySession(
|
|
124
|
+
this._teamInvitationsCache = (0, import_common2.createCacheBySession)(
|
|
246
125
|
async (session, [teamId]) => {
|
|
247
126
|
return await this._interface.listTeamInvitations({ teamId }, session);
|
|
248
127
|
}
|
|
249
128
|
);
|
|
250
|
-
this._currentUserTeamProfileCache = createCacheBySession(
|
|
129
|
+
this._currentUserTeamProfileCache = (0, import_common2.createCacheBySession)(
|
|
251
130
|
async (session, [teamId]) => {
|
|
252
131
|
return await this._interface.getTeamMemberProfile({ teamId, userId: "me" }, session);
|
|
253
132
|
}
|
|
254
133
|
);
|
|
255
|
-
this._clientContactChannelsCache = createCacheBySession(
|
|
134
|
+
this._clientContactChannelsCache = (0, import_common2.createCacheBySession)(
|
|
256
135
|
async (session) => {
|
|
257
136
|
return await this._interface.listClientContactChannels(session);
|
|
258
137
|
}
|
|
259
138
|
);
|
|
260
|
-
this._memoryTokenStore = createEmptyTokenStore();
|
|
139
|
+
this._memoryTokenStore = (0, import_common2.createEmptyTokenStore)();
|
|
140
|
+
this._nextServerCookiesTokenStores = /* @__PURE__ */ new WeakMap();
|
|
261
141
|
this._requestTokenStores = /* @__PURE__ */ new WeakMap();
|
|
262
142
|
this._storedBrowserCookieTokenStore = null;
|
|
263
143
|
/**
|
|
@@ -269,14 +149,17 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
269
149
|
* - So different token stores are separated and don't leak information between each other, eg. if the same user sends two requests to the same server they should get a different session object
|
|
270
150
|
*/
|
|
271
151
|
this._sessionsByTokenStoreAndSessionKey = /* @__PURE__ */ new WeakMap();
|
|
152
|
+
if (!__StackClientAppImplIncomplete.LazyStackAdminAppImpl.value) {
|
|
153
|
+
throw new import_errors.StackAssertionError("Admin app implementation not initialized. Did you import the _StackClientApp from stack-app/apps/implementations/index.ts? You can't import it directly from ./apps/implementations/client-app-impl.ts as that causes a circular dependency (see the comment at _LazyStackAdminAppImpl for more details).");
|
|
154
|
+
}
|
|
272
155
|
if ("interface" in _options) {
|
|
273
156
|
this._interface = _options.interface;
|
|
274
157
|
} else {
|
|
275
158
|
this._interface = new import_stack_shared.StackClientInterface({
|
|
276
|
-
getBaseUrl: () => getBaseUrl(_options.baseUrl),
|
|
277
|
-
projectId: _options.projectId ?? getDefaultProjectId(),
|
|
278
|
-
clientVersion,
|
|
279
|
-
publishableClientKey: _options.publishableClientKey ?? getDefaultPublishableClientKey(),
|
|
159
|
+
getBaseUrl: () => (0, import_common2.getBaseUrl)(_options.baseUrl),
|
|
160
|
+
projectId: _options.projectId ?? (0, import_common2.getDefaultProjectId)(),
|
|
161
|
+
clientVersion: import_common2.clientVersion,
|
|
162
|
+
publishableClientKey: _options.publishableClientKey ?? (0, import_common2.getDefaultPublishableClientKey)(),
|
|
280
163
|
prepareRequest: async () => {
|
|
281
164
|
}
|
|
282
165
|
});
|
|
@@ -300,7 +183,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
300
183
|
if (this._tokenStoreInit === "nextjs-cookie" || this._tokenStoreInit === "cookie") {
|
|
301
184
|
return await (0, import_cookie.createCookieHelper)();
|
|
302
185
|
} else {
|
|
303
|
-
return await (0, import_cookie.
|
|
186
|
+
return await (0, import_cookie.createPlaceholderCookieHelper)();
|
|
304
187
|
}
|
|
305
188
|
}
|
|
306
189
|
async _getUserOAuthConnectionCacheFn(options) {
|
|
@@ -469,7 +352,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
469
352
|
}
|
|
470
353
|
default: {
|
|
471
354
|
if (tokenStoreInit === null) {
|
|
472
|
-
return createEmptyTokenStore();
|
|
355
|
+
return (0, import_common2.createEmptyTokenStore)();
|
|
473
356
|
} else if (typeof tokenStoreInit === "object" && "headers" in tokenStoreInit) {
|
|
474
357
|
if (this._requestTokenStores.has(tokenStoreInit)) return this._requestTokenStores.get(tokenStoreInit);
|
|
475
358
|
const stackAuthHeader = tokenStoreInit.headers.get("x-stack-auth");
|
|
@@ -644,7 +527,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
644
527
|
return result.map((crud2) => app._clientTeamUserFromCrud(crud2));
|
|
645
528
|
},
|
|
646
529
|
useUsers() {
|
|
647
|
-
const result = useAsyncCache(app._teamMemberProfilesCache, [session, crud.id], "team.useUsers()");
|
|
530
|
+
const result = (0, import_common3.useAsyncCache)(app._teamMemberProfilesCache, [session, crud.id], "team.useUsers()");
|
|
648
531
|
return result.map((crud2) => app._clientTeamUserFromCrud(crud2));
|
|
649
532
|
},
|
|
650
533
|
async listInvitations() {
|
|
@@ -652,11 +535,11 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
652
535
|
return result.map((crud2) => app._clientTeamInvitationFromCrud(session, crud2));
|
|
653
536
|
},
|
|
654
537
|
useInvitations() {
|
|
655
|
-
const result = useAsyncCache(app._teamInvitationsCache, [session, crud.id], "team.useInvitations()");
|
|
538
|
+
const result = (0, import_common3.useAsyncCache)(app._teamInvitationsCache, [session, crud.id], "team.useInvitations()");
|
|
656
539
|
return result.map((crud2) => app._clientTeamInvitationFromCrud(session, crud2));
|
|
657
540
|
},
|
|
658
541
|
async update(data) {
|
|
659
|
-
await app._interface.updateTeam({ data: teamUpdateOptionsToCrud(data), teamId: crud.id }, session);
|
|
542
|
+
await app._interface.updateTeam({ data: (0, import_teams.teamUpdateOptionsToCrud)(data), teamId: crud.id }, session);
|
|
660
543
|
await app._currentUserTeamsCache.refresh([session]);
|
|
661
544
|
},
|
|
662
545
|
async delete() {
|
|
@@ -678,7 +561,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
678
561
|
await app._interface.sendCurrentUserContactChannelVerificationEmail(crud.id, (0, import_url.constructRedirectUrl)(app.urls.emailVerification), session);
|
|
679
562
|
},
|
|
680
563
|
async update(data) {
|
|
681
|
-
await app._interface.updateClientContactChannel(crud.id, contactChannelUpdateOptionsToCrud(data), session);
|
|
564
|
+
await app._interface.updateClientContactChannel(crud.id, (0, import_contact_channels.contactChannelUpdateOptionsToCrud)(data), session);
|
|
682
565
|
await app._clientContactChannelsCache.refresh([session]);
|
|
683
566
|
},
|
|
684
567
|
async delete() {
|
|
@@ -726,12 +609,12 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
726
609
|
let attResp;
|
|
727
610
|
try {
|
|
728
611
|
attResp = await (0, import_browser.startRegistration)({ optionsJSON: options_json });
|
|
729
|
-
debugger;
|
|
730
612
|
} catch (error) {
|
|
731
613
|
if (error instanceof import_browser.WebAuthnError) {
|
|
732
614
|
return import_results.Result.error(new import_stack_shared.KnownErrors.PasskeyWebAuthnError(error.message, error.name));
|
|
733
615
|
} else {
|
|
734
|
-
|
|
616
|
+
(0, import_errors.captureError)("passkey-registration-failed", error);
|
|
617
|
+
return import_results.Result.error(new import_stack_shared.KnownErrors.PasskeyRegistrationFailed("Failed to start passkey registration due to unknown error"));
|
|
735
618
|
}
|
|
736
619
|
}
|
|
737
620
|
const registrationResult = await app._interface.registerPasskey({ credential: attResp, code }, session);
|
|
@@ -790,7 +673,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
790
673
|
}
|
|
791
674
|
function useConnectedAccount(id, options) {
|
|
792
675
|
const scopeString = options?.scopes?.join(" ");
|
|
793
|
-
return useAsyncCache(app._currentUserOAuthConnectionCache, [session, id, scopeString || "", options?.or === "redirect"], "user.useConnectedAccount()");
|
|
676
|
+
return (0, import_common3.useAsyncCache)(app._currentUserOAuthConnectionCache, [session, id, scopeString || "", options?.or === "redirect"], "user.useConnectedAccount()");
|
|
794
677
|
}
|
|
795
678
|
return {
|
|
796
679
|
setDisplayName(displayName) {
|
|
@@ -819,11 +702,11 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
819
702
|
return teams.map((crud2) => app._clientTeamFromCrud(crud2, session));
|
|
820
703
|
},
|
|
821
704
|
useTeams() {
|
|
822
|
-
const teams = useAsyncCache(app._currentUserTeamsCache, [session], "user.useTeams()");
|
|
705
|
+
const teams = (0, import_common3.useAsyncCache)(app._currentUserTeamsCache, [session], "user.useTeams()");
|
|
823
706
|
return (0, import_react2.useMemo)(() => teams.map((crud2) => app._clientTeamFromCrud(crud2, session)), [teams]);
|
|
824
707
|
},
|
|
825
708
|
async createTeam(data) {
|
|
826
|
-
const crud2 = await app._interface.createClientTeam(teamCreateOptionsToCrud(data, "me"), session);
|
|
709
|
+
const crud2 = await app._interface.createClientTeam((0, import_teams.teamCreateOptionsToCrud)(data, "me"), session);
|
|
827
710
|
await app._currentUserTeamsCache.refresh([session]);
|
|
828
711
|
return app._clientTeamFromCrud(crud2, session);
|
|
829
712
|
},
|
|
@@ -837,7 +720,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
837
720
|
},
|
|
838
721
|
usePermissions(scope, options) {
|
|
839
722
|
const recursive = options?.recursive ?? true;
|
|
840
|
-
const permissions = useAsyncCache(app._currentUserPermissionsCache, [session, scope.id, recursive], "user.usePermissions()");
|
|
723
|
+
const permissions = (0, import_common3.useAsyncCache)(app._currentUserPermissionsCache, [session, scope.id, recursive], "user.usePermissions()");
|
|
841
724
|
return (0, import_react2.useMemo)(() => permissions.map((crud2) => app._clientTeamPermissionFromCrud(crud2)), [permissions]);
|
|
842
725
|
},
|
|
843
726
|
usePermission(scope, permissionId) {
|
|
@@ -879,7 +762,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
879
762
|
return app._editableTeamProfileFromCrud(result, session);
|
|
880
763
|
},
|
|
881
764
|
useTeamProfile(team) {
|
|
882
|
-
const result = useAsyncCache(app._currentUserTeamProfileCache, [session, team.id], "user.useTeamProfile()");
|
|
765
|
+
const result = (0, import_common3.useAsyncCache)(app._currentUserTeamProfileCache, [session, team.id], "user.useTeamProfile()");
|
|
883
766
|
return app._editableTeamProfileFromCrud(result, session);
|
|
884
767
|
},
|
|
885
768
|
async delete() {
|
|
@@ -891,11 +774,11 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
891
774
|
return result.map((crud2) => app._clientContactChannelFromCrud(crud2, session));
|
|
892
775
|
},
|
|
893
776
|
useContactChannels() {
|
|
894
|
-
const result = useAsyncCache(app._clientContactChannelsCache, [session], "user.useContactChannels()");
|
|
777
|
+
const result = (0, import_common3.useAsyncCache)(app._clientContactChannelsCache, [session], "user.useContactChannels()");
|
|
895
778
|
return result.map((crud2) => app._clientContactChannelFromCrud(crud2, session));
|
|
896
779
|
},
|
|
897
780
|
async createContactChannel(data) {
|
|
898
|
-
const crud2 = await app._interface.createClientContactChannel(contactChannelCreateOptionsToCrud("me", data), session);
|
|
781
|
+
const crud2 = await app._interface.createClientContactChannel((0, import_contact_channels.contactChannelCreateOptionsToCrud)("me", data), session);
|
|
899
782
|
await app._clientContactChannelsCache.refresh([session]);
|
|
900
783
|
return app._clientContactChannelFromCrud(crud2, session);
|
|
901
784
|
}
|
|
@@ -928,7 +811,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
928
811
|
}
|
|
929
812
|
_getOwnedAdminApp(forProjectId, session) {
|
|
930
813
|
if (!this._ownedAdminApps.has([session, forProjectId])) {
|
|
931
|
-
this._ownedAdminApps.set([session, forProjectId], new
|
|
814
|
+
this._ownedAdminApps.set([session, forProjectId], new __StackClientAppImplIncomplete.LazyStackAdminAppImpl.value({
|
|
932
815
|
baseUrl: this._interface.options.getBaseUrl(),
|
|
933
816
|
projectId: forProjectId,
|
|
934
817
|
tokenStore: null,
|
|
@@ -945,7 +828,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
945
828
|
return (0, import_urls.isRelative)(url);
|
|
946
829
|
}
|
|
947
830
|
get urls() {
|
|
948
|
-
return getUrls(this._urlOptions);
|
|
831
|
+
return (0, import_common2.getUrls)(this._urlOptions);
|
|
949
832
|
}
|
|
950
833
|
async _getCurrentUrl() {
|
|
951
834
|
if (this._redirectMethod === "none") {
|
|
@@ -971,7 +854,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
971
854
|
if (typeof this._redirectMethod === "object") {
|
|
972
855
|
return this._redirectMethod.useNavigate();
|
|
973
856
|
} else if (this._redirectMethod === "window") {
|
|
974
|
-
return () => window.location.assign;
|
|
857
|
+
return (to) => window.location.assign(to);
|
|
975
858
|
} else {
|
|
976
859
|
return (to) => {
|
|
977
860
|
};
|
|
@@ -1142,7 +1025,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1142
1025
|
useUser(options) {
|
|
1143
1026
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1144
1027
|
const session = this._useSession(options?.tokenStore);
|
|
1145
|
-
const crud = useAsyncCache(this._currentUserCache, [session], "useUser()");
|
|
1028
|
+
const crud = (0, import_common3.useAsyncCache)(this._currentUserCache, [session], "useUser()");
|
|
1146
1029
|
if (crud === null) {
|
|
1147
1030
|
switch (options?.or) {
|
|
1148
1031
|
case "redirect": {
|
|
@@ -1163,7 +1046,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1163
1046
|
}, [crud, session, options?.or]);
|
|
1164
1047
|
}
|
|
1165
1048
|
async _updateClientUser(update, session) {
|
|
1166
|
-
const res = await this._interface.updateClientUser(userUpdateOptionsToCrud(update), session);
|
|
1049
|
+
const res = await this._interface.updateClientUser((0, import_users.userUpdateOptionsToCrud)(update), session);
|
|
1167
1050
|
await this._refreshUser(session);
|
|
1168
1051
|
return res;
|
|
1169
1052
|
}
|
|
@@ -1238,7 +1121,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1238
1121
|
async signUpWithCredential(options) {
|
|
1239
1122
|
this._ensurePersistentTokenStore();
|
|
1240
1123
|
const session = await this._getSession();
|
|
1241
|
-
const emailVerificationRedirectUrl = (0, import_url.constructRedirectUrl)(this.urls.emailVerification);
|
|
1124
|
+
const emailVerificationRedirectUrl = options.verificationCallbackUrl ?? (0, import_url.constructRedirectUrl)(this.urls.emailVerification);
|
|
1242
1125
|
const result = await this._interface.signUpWithCredential(
|
|
1243
1126
|
options.email,
|
|
1244
1127
|
options.password,
|
|
@@ -1367,7 +1250,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1367
1250
|
return this._clientProjectFromCrud(crud);
|
|
1368
1251
|
}
|
|
1369
1252
|
useProject() {
|
|
1370
|
-
const crud = useAsyncCache(this._currentProjectCache, [], "useProject()");
|
|
1253
|
+
const crud = (0, import_common3.useAsyncCache)(this._currentProjectCache, [], "useProject()");
|
|
1371
1254
|
return (0, import_react2.useMemo)(() => this._clientProjectFromCrud(crud), [crud]);
|
|
1372
1255
|
}
|
|
1373
1256
|
async _listOwnedProjects(session) {
|
|
@@ -1380,7 +1263,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1380
1263
|
}
|
|
1381
1264
|
_useOwnedProjects(session) {
|
|
1382
1265
|
this._ensureInternalProject();
|
|
1383
|
-
const projects = useAsyncCache(this._ownedProjectsCache, [session], "useOwnedProjects()");
|
|
1266
|
+
const projects = (0, import_common3.useAsyncCache)(this._ownedProjectsCache, [session], "useOwnedProjects()");
|
|
1384
1267
|
return (0, import_react2.useMemo)(() => projects.map((j) => this._getOwnedAdminApp(j.id, session)._adminOwnedProjectFromCrud(
|
|
1385
1268
|
j,
|
|
1386
1269
|
() => this._refreshOwnedProjects(session)
|
|
@@ -1388,7 +1271,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1388
1271
|
}
|
|
1389
1272
|
async _createProject(session, newProject) {
|
|
1390
1273
|
this._ensureInternalProject();
|
|
1391
|
-
const crud = await this._interface.createProject(adminProjectCreateOptionsToCrud(newProject), session);
|
|
1274
|
+
const crud = await this._interface.createProject((0, import_projects.adminProjectCreateOptionsToCrud)(newProject), session);
|
|
1392
1275
|
const res = this._getOwnedAdminApp(crud.id, session)._adminOwnedProjectFromCrud(
|
|
1393
1276
|
crud,
|
|
1394
1277
|
() => this._refreshOwnedProjects(session)
|
|
@@ -1410,7 +1293,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1410
1293
|
async _refreshOwnedProjects(session) {
|
|
1411
1294
|
await this._ownedProjectsCache.refresh([session]);
|
|
1412
1295
|
}
|
|
1413
|
-
static get [stackAppInternalsSymbol]() {
|
|
1296
|
+
static get [import_common.stackAppInternalsSymbol]() {
|
|
1414
1297
|
return {
|
|
1415
1298
|
fromClientJson: (json) => {
|
|
1416
1299
|
const providedCheckString = JSON.stringify((0, import_objects.omit)(json, [
|
|
@@ -1424,14 +1307,14 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1424
1307
|
}
|
|
1425
1308
|
return clientApp;
|
|
1426
1309
|
}
|
|
1427
|
-
return new
|
|
1310
|
+
return new __StackClientAppImplIncomplete({
|
|
1428
1311
|
...json,
|
|
1429
1312
|
checkString: providedCheckString
|
|
1430
1313
|
});
|
|
1431
1314
|
}
|
|
1432
1315
|
};
|
|
1433
1316
|
}
|
|
1434
|
-
get [stackAppInternalsSymbol]() {
|
|
1317
|
+
get [import_common.stackAppInternalsSymbol]() {
|
|
1435
1318
|
return {
|
|
1436
1319
|
toClientJson: () => {
|
|
1437
1320
|
if (!("publishableClientKey" in this._interface.options)) {
|
|
@@ -1462,977 +1345,17 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1462
1345
|
};
|
|
1463
1346
|
}
|
|
1464
1347
|
};
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
getBaseUrl: () => getBaseUrl(options.baseUrl),
|
|
1475
|
-
projectId: options.projectId ?? getDefaultProjectId(),
|
|
1476
|
-
clientVersion,
|
|
1477
|
-
publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),
|
|
1478
|
-
secretServerKey: options.secretServerKey ?? getDefaultSecretServerKey()
|
|
1479
|
-
}),
|
|
1480
|
-
baseUrl: options.baseUrl,
|
|
1481
|
-
projectId: options.projectId,
|
|
1482
|
-
publishableClientKey: options.publishableClientKey,
|
|
1483
|
-
tokenStore: options.tokenStore,
|
|
1484
|
-
urls: options.urls ?? {},
|
|
1485
|
-
oauthScopesOnSignIn: options.oauthScopesOnSignIn ?? {},
|
|
1486
|
-
redirectMethod: options.redirectMethod
|
|
1487
|
-
});
|
|
1488
|
-
// TODO override the client user cache to use the server user cache, so we save some requests
|
|
1489
|
-
this._currentServerUserCache = createCacheBySession(async (session) => {
|
|
1490
|
-
if (session.isKnownToBeInvalid()) {
|
|
1491
|
-
return null;
|
|
1492
|
-
}
|
|
1493
|
-
return await this._interface.getServerUserByToken(session);
|
|
1494
|
-
});
|
|
1495
|
-
this._serverUsersCache = createCache(async ([cursor, limit, orderBy, desc, query]) => {
|
|
1496
|
-
return await this._interface.listServerUsers({ cursor, limit, orderBy, desc, query });
|
|
1497
|
-
});
|
|
1498
|
-
this._serverUserCache = createCache(async ([userId]) => {
|
|
1499
|
-
const user = await this._interface.getServerUserById(userId);
|
|
1500
|
-
return import_results.Result.or(user, null);
|
|
1501
|
-
});
|
|
1502
|
-
this._serverTeamsCache = createCache(async ([userId]) => {
|
|
1503
|
-
return await this._interface.listServerTeams({ userId });
|
|
1504
|
-
});
|
|
1505
|
-
this._serverTeamUserPermissionsCache = createCache(async ([teamId, userId, recursive]) => {
|
|
1506
|
-
return await this._interface.listServerTeamPermissions({ teamId, userId, recursive }, null);
|
|
1507
|
-
});
|
|
1508
|
-
this._serverUserOAuthConnectionAccessTokensCache = createCache(
|
|
1509
|
-
async ([userId, providerId, scope]) => {
|
|
1510
|
-
try {
|
|
1511
|
-
const result = await this._interface.createServerProviderAccessToken(userId, providerId, scope || "");
|
|
1512
|
-
return { accessToken: result.access_token };
|
|
1513
|
-
} catch (err) {
|
|
1514
|
-
if (!(err instanceof import_stack_shared.KnownErrors.OAuthConnectionDoesNotHaveRequiredScope || err instanceof import_stack_shared.KnownErrors.OAuthConnectionNotConnectedToUser)) {
|
|
1515
|
-
throw err;
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
return null;
|
|
1519
|
-
}
|
|
1520
|
-
);
|
|
1521
|
-
this._serverUserOAuthConnectionCache = createCache(
|
|
1522
|
-
async ([userId, providerId, scope, redirect]) => {
|
|
1523
|
-
return await this._getUserOAuthConnectionCacheFn({
|
|
1524
|
-
getUser: async () => import_results.Result.orThrow(await this._serverUserCache.getOrWait([userId], "write-only")),
|
|
1525
|
-
getOrWaitOAuthToken: async () => import_results.Result.orThrow(await this._serverUserOAuthConnectionAccessTokensCache.getOrWait([userId, providerId, scope || ""], "write-only")),
|
|
1526
|
-
useOAuthToken: () => useAsyncCache(this._serverUserOAuthConnectionAccessTokensCache, [userId, providerId, scope || ""], "user.useConnectedAccount()"),
|
|
1527
|
-
providerId,
|
|
1528
|
-
scope,
|
|
1529
|
-
redirect,
|
|
1530
|
-
session: null
|
|
1531
|
-
});
|
|
1532
|
-
}
|
|
1533
|
-
);
|
|
1534
|
-
this._serverTeamMemberProfilesCache = createCache(
|
|
1535
|
-
async ([teamId]) => {
|
|
1536
|
-
return await this._interface.listServerTeamMemberProfiles({ teamId });
|
|
1537
|
-
}
|
|
1538
|
-
);
|
|
1539
|
-
this._serverTeamInvitationsCache = createCache(
|
|
1540
|
-
async ([teamId]) => {
|
|
1541
|
-
return await this._interface.listServerTeamInvitations({ teamId });
|
|
1542
|
-
}
|
|
1543
|
-
);
|
|
1544
|
-
this._serverUserTeamProfileCache = createCache(
|
|
1545
|
-
async ([teamId, userId]) => {
|
|
1546
|
-
return await this._interface.getServerTeamMemberProfile({ teamId, userId });
|
|
1547
|
-
}
|
|
1548
|
-
);
|
|
1549
|
-
this._serverContactChannelsCache = createCache(
|
|
1550
|
-
async ([userId]) => {
|
|
1551
|
-
return await this._interface.listServerContactChannels(userId);
|
|
1552
|
-
}
|
|
1553
|
-
);
|
|
1554
|
-
}
|
|
1555
|
-
async _updateServerUser(userId, update) {
|
|
1556
|
-
const result = await this._interface.updateServerUser(userId, serverUserUpdateOptionsToCrud(update));
|
|
1557
|
-
await this._refreshUsers();
|
|
1558
|
-
return result;
|
|
1559
|
-
}
|
|
1560
|
-
_serverEditableTeamProfileFromCrud(crud) {
|
|
1561
|
-
const app = this;
|
|
1562
|
-
return {
|
|
1563
|
-
displayName: crud.display_name,
|
|
1564
|
-
profileImageUrl: crud.profile_image_url,
|
|
1565
|
-
async update(update) {
|
|
1566
|
-
await app._interface.updateServerTeamMemberProfile({
|
|
1567
|
-
teamId: crud.team_id,
|
|
1568
|
-
userId: crud.user_id,
|
|
1569
|
-
profile: {
|
|
1570
|
-
display_name: update.displayName,
|
|
1571
|
-
profile_image_url: update.profileImageUrl
|
|
1572
|
-
}
|
|
1573
|
-
});
|
|
1574
|
-
await app._serverUserTeamProfileCache.refresh([crud.team_id, crud.user_id]);
|
|
1575
|
-
}
|
|
1576
|
-
};
|
|
1577
|
-
}
|
|
1578
|
-
_serverContactChannelFromCrud(userId, crud) {
|
|
1579
|
-
const app = this;
|
|
1580
|
-
return {
|
|
1581
|
-
id: crud.id,
|
|
1582
|
-
value: crud.value,
|
|
1583
|
-
type: crud.type,
|
|
1584
|
-
isVerified: crud.is_verified,
|
|
1585
|
-
isPrimary: crud.is_primary,
|
|
1586
|
-
usedForAuth: crud.used_for_auth,
|
|
1587
|
-
async sendVerificationEmail(options) {
|
|
1588
|
-
if (!options?.callbackUrl && !await app._getCurrentUrl()) {
|
|
1589
|
-
throw new Error("Cannot send verification email without a callback URL from the server or without a redirect method. Make sure you pass the `callbackUrl` option: `sendVerificationEmail({ callbackUrl: ... })`");
|
|
1590
|
-
}
|
|
1591
|
-
await app._interface.sendServerContactChannelVerificationEmail(userId, crud.id, options?.callbackUrl ?? (0, import_url.constructRedirectUrl)(app.urls.emailVerification));
|
|
1592
|
-
},
|
|
1593
|
-
async update(data) {
|
|
1594
|
-
await app._interface.updateServerContactChannel(userId, crud.id, serverContactChannelUpdateOptionsToCrud(data));
|
|
1595
|
-
},
|
|
1596
|
-
async delete() {
|
|
1597
|
-
await app._interface.deleteServerContactChannel(userId, crud.id);
|
|
1598
|
-
}
|
|
1599
|
-
};
|
|
1600
|
-
}
|
|
1601
|
-
_serverUserFromCrud(crud) {
|
|
1602
|
-
const app = this;
|
|
1603
|
-
async function getConnectedAccount(id, options) {
|
|
1604
|
-
const scopeString = options?.scopes?.join(" ");
|
|
1605
|
-
return import_results.Result.orThrow(await app._serverUserOAuthConnectionCache.getOrWait([crud.id, id, scopeString || "", options?.or === "redirect"], "write-only"));
|
|
1606
|
-
}
|
|
1607
|
-
function useConnectedAccount(id, options) {
|
|
1608
|
-
const scopeString = options?.scopes?.join(" ");
|
|
1609
|
-
return useAsyncCache(app._serverUserOAuthConnectionCache, [crud.id, id, scopeString || "", options?.or === "redirect"], "user.useConnectedAccount()");
|
|
1610
|
-
}
|
|
1611
|
-
return {
|
|
1612
|
-
...super._createBaseUser(crud),
|
|
1613
|
-
lastActiveAt: new Date(crud.last_active_at_millis),
|
|
1614
|
-
serverMetadata: crud.server_metadata,
|
|
1615
|
-
async setPrimaryEmail(email, options) {
|
|
1616
|
-
await app._updateServerUser(crud.id, { primaryEmail: email, primaryEmailVerified: options?.verified });
|
|
1617
|
-
},
|
|
1618
|
-
async grantPermission(scope, permissionId) {
|
|
1619
|
-
await app._interface.grantServerTeamUserPermission(scope.id, crud.id, permissionId);
|
|
1620
|
-
for (const recursive of [true, false]) {
|
|
1621
|
-
await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);
|
|
1622
|
-
}
|
|
1623
|
-
},
|
|
1624
|
-
async revokePermission(scope, permissionId) {
|
|
1625
|
-
await app._interface.revokeServerTeamUserPermission(scope.id, crud.id, permissionId);
|
|
1626
|
-
for (const recursive of [true, false]) {
|
|
1627
|
-
await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);
|
|
1628
|
-
}
|
|
1629
|
-
},
|
|
1630
|
-
async delete() {
|
|
1631
|
-
const res = await app._interface.deleteServerServerUser(crud.id);
|
|
1632
|
-
await app._refreshUsers();
|
|
1633
|
-
return res;
|
|
1634
|
-
},
|
|
1635
|
-
async createSession(options) {
|
|
1636
|
-
const tokens = await app._interface.createServerUserSession(crud.id, options.expiresInMillis ?? 1e3 * 60 * 60 * 24 * 365);
|
|
1637
|
-
return {
|
|
1638
|
-
async getTokens() {
|
|
1639
|
-
return tokens;
|
|
1640
|
-
}
|
|
1641
|
-
};
|
|
1642
|
-
},
|
|
1643
|
-
async setDisplayName(displayName) {
|
|
1644
|
-
return await this.update({ displayName });
|
|
1645
|
-
},
|
|
1646
|
-
async setClientMetadata(metadata) {
|
|
1647
|
-
return await this.update({ clientMetadata: metadata });
|
|
1648
|
-
},
|
|
1649
|
-
async setClientReadOnlyMetadata(metadata) {
|
|
1650
|
-
return await this.update({ clientReadOnlyMetadata: metadata });
|
|
1651
|
-
},
|
|
1652
|
-
async setServerMetadata(metadata) {
|
|
1653
|
-
return await this.update({ serverMetadata: metadata });
|
|
1654
|
-
},
|
|
1655
|
-
async setSelectedTeam(team) {
|
|
1656
|
-
return await this.update({ selectedTeamId: team?.id ?? null });
|
|
1657
|
-
},
|
|
1658
|
-
getConnectedAccount,
|
|
1659
|
-
useConnectedAccount,
|
|
1660
|
-
selectedTeam: crud.selected_team ? app._serverTeamFromCrud(crud.selected_team) : null,
|
|
1661
|
-
async getTeam(teamId) {
|
|
1662
|
-
const teams = await this.listTeams();
|
|
1663
|
-
return teams.find((t) => t.id === teamId) ?? null;
|
|
1664
|
-
},
|
|
1665
|
-
useTeam(teamId) {
|
|
1666
|
-
const teams = this.useTeams();
|
|
1667
|
-
return (0, import_react2.useMemo)(() => {
|
|
1668
|
-
return teams.find((t) => t.id === teamId) ?? null;
|
|
1669
|
-
}, [teams, teamId]);
|
|
1670
|
-
},
|
|
1671
|
-
async listTeams() {
|
|
1672
|
-
const teams = import_results.Result.orThrow(await app._serverTeamsCache.getOrWait([crud.id], "write-only"));
|
|
1673
|
-
return teams.map((t) => app._serverTeamFromCrud(t));
|
|
1674
|
-
},
|
|
1675
|
-
useTeams() {
|
|
1676
|
-
const teams = useAsyncCache(app._serverTeamsCache, [crud.id], "user.useTeams()");
|
|
1677
|
-
return (0, import_react2.useMemo)(() => teams.map((t) => app._serverTeamFromCrud(t)), [teams]);
|
|
1678
|
-
},
|
|
1679
|
-
createTeam: async (data) => {
|
|
1680
|
-
const team = await app._interface.createServerTeam(serverTeamCreateOptionsToCrud({
|
|
1681
|
-
creatorUserId: crud.id,
|
|
1682
|
-
...data
|
|
1683
|
-
}));
|
|
1684
|
-
await app._serverTeamsCache.refresh([void 0]);
|
|
1685
|
-
return app._serverTeamFromCrud(team);
|
|
1686
|
-
},
|
|
1687
|
-
leaveTeam: async (team) => {
|
|
1688
|
-
await app._interface.leaveServerTeam({ teamId: team.id, userId: crud.id });
|
|
1689
|
-
},
|
|
1690
|
-
async listPermissions(scope, options) {
|
|
1691
|
-
const recursive = options?.recursive ?? true;
|
|
1692
|
-
const permissions = import_results.Result.orThrow(await app._serverTeamUserPermissionsCache.getOrWait([scope.id, crud.id, recursive], "write-only"));
|
|
1693
|
-
return permissions.map((crud2) => app._serverPermissionFromCrud(crud2));
|
|
1694
|
-
},
|
|
1695
|
-
usePermissions(scope, options) {
|
|
1696
|
-
const recursive = options?.recursive ?? true;
|
|
1697
|
-
const permissions = useAsyncCache(app._serverTeamUserPermissionsCache, [scope.id, crud.id, recursive], "user.usePermissions()");
|
|
1698
|
-
return (0, import_react2.useMemo)(() => permissions.map((crud2) => app._serverPermissionFromCrud(crud2)), [permissions]);
|
|
1699
|
-
},
|
|
1700
|
-
async getPermission(scope, permissionId) {
|
|
1701
|
-
const permissions = await this.listPermissions(scope);
|
|
1702
|
-
return permissions.find((p) => p.id === permissionId) ?? null;
|
|
1703
|
-
},
|
|
1704
|
-
usePermission(scope, permissionId) {
|
|
1705
|
-
const permissions = this.usePermissions(scope);
|
|
1706
|
-
return (0, import_react2.useMemo)(() => permissions.find((p) => p.id === permissionId) ?? null, [permissions, permissionId]);
|
|
1707
|
-
},
|
|
1708
|
-
async hasPermission(scope, permissionId) {
|
|
1709
|
-
return await this.getPermission(scope, permissionId) !== null;
|
|
1710
|
-
},
|
|
1711
|
-
async update(update) {
|
|
1712
|
-
await app._updateServerUser(crud.id, update);
|
|
1713
|
-
},
|
|
1714
|
-
async sendVerificationEmail() {
|
|
1715
|
-
return await app._checkFeatureSupport("sendVerificationEmail() on ServerUser", {});
|
|
1716
|
-
},
|
|
1717
|
-
async updatePassword(options) {
|
|
1718
|
-
const result = await this.update({ password: options.newPassword });
|
|
1719
|
-
await app._serverUserCache.refresh([crud.id]);
|
|
1720
|
-
return result;
|
|
1721
|
-
},
|
|
1722
|
-
async setPassword(options) {
|
|
1723
|
-
const result = await this.update(options);
|
|
1724
|
-
await app._serverUserCache.refresh([crud.id]);
|
|
1725
|
-
return result;
|
|
1726
|
-
},
|
|
1727
|
-
async getTeamProfile(team) {
|
|
1728
|
-
const result = import_results.Result.orThrow(await app._serverUserTeamProfileCache.getOrWait([team.id, crud.id], "write-only"));
|
|
1729
|
-
return app._serverEditableTeamProfileFromCrud(result);
|
|
1730
|
-
},
|
|
1731
|
-
useTeamProfile(team) {
|
|
1732
|
-
const result = useAsyncCache(app._serverUserTeamProfileCache, [team.id, crud.id], "user.useTeamProfile()");
|
|
1733
|
-
return (0, import_react2.useMemo)(() => app._serverEditableTeamProfileFromCrud(result), [result]);
|
|
1734
|
-
},
|
|
1735
|
-
async listContactChannels() {
|
|
1736
|
-
const result = import_results.Result.orThrow(await app._serverContactChannelsCache.getOrWait([crud.id], "write-only"));
|
|
1737
|
-
return result.map((data) => app._serverContactChannelFromCrud(crud.id, data));
|
|
1738
|
-
},
|
|
1739
|
-
useContactChannels() {
|
|
1740
|
-
const result = useAsyncCache(app._serverContactChannelsCache, [crud.id], "user.useContactChannels()");
|
|
1741
|
-
return (0, import_react2.useMemo)(() => result.map((data) => app._serverContactChannelFromCrud(crud.id, data)), [result]);
|
|
1742
|
-
},
|
|
1743
|
-
createContactChannel: async (data) => {
|
|
1744
|
-
const contactChannel = await app._interface.createServerContactChannel(serverContactChannelCreateOptionsToCrud(crud.id, data));
|
|
1745
|
-
await app._serverContactChannelsCache.refresh([crud.id]);
|
|
1746
|
-
return app._serverContactChannelFromCrud(crud.id, contactChannel);
|
|
1747
|
-
}
|
|
1748
|
-
};
|
|
1749
|
-
}
|
|
1750
|
-
_serverTeamUserFromCrud(crud) {
|
|
1751
|
-
return {
|
|
1752
|
-
...this._serverUserFromCrud(crud.user),
|
|
1753
|
-
teamProfile: {
|
|
1754
|
-
displayName: crud.display_name,
|
|
1755
|
-
profileImageUrl: crud.profile_image_url
|
|
1756
|
-
}
|
|
1757
|
-
};
|
|
1758
|
-
}
|
|
1759
|
-
_serverTeamInvitationFromCrud(crud) {
|
|
1760
|
-
return {
|
|
1761
|
-
id: crud.id,
|
|
1762
|
-
recipientEmail: crud.recipient_email,
|
|
1763
|
-
expiresAt: new Date(crud.expires_at_millis),
|
|
1764
|
-
revoke: async () => {
|
|
1765
|
-
await this._interface.revokeServerTeamInvitation(crud.id, crud.team_id);
|
|
1766
|
-
}
|
|
1767
|
-
};
|
|
1768
|
-
}
|
|
1769
|
-
_currentUserFromCrud(crud, session) {
|
|
1770
|
-
const app = this;
|
|
1771
|
-
const currentUser = {
|
|
1772
|
-
...this._serverUserFromCrud(crud),
|
|
1773
|
-
...this._createAuth(session),
|
|
1774
|
-
...this._isInternalProject() ? this._createInternalUserExtra(session) : {}
|
|
1775
|
-
};
|
|
1776
|
-
Object.freeze(currentUser);
|
|
1777
|
-
return currentUser;
|
|
1778
|
-
}
|
|
1779
|
-
_serverTeamFromCrud(crud) {
|
|
1780
|
-
const app = this;
|
|
1781
|
-
return {
|
|
1782
|
-
id: crud.id,
|
|
1783
|
-
displayName: crud.display_name,
|
|
1784
|
-
profileImageUrl: crud.profile_image_url,
|
|
1785
|
-
createdAt: new Date(crud.created_at_millis),
|
|
1786
|
-
clientMetadata: crud.client_metadata,
|
|
1787
|
-
clientReadOnlyMetadata: crud.client_read_only_metadata,
|
|
1788
|
-
serverMetadata: crud.server_metadata,
|
|
1789
|
-
async update(update) {
|
|
1790
|
-
await app._interface.updateServerTeam(crud.id, serverTeamUpdateOptionsToCrud(update));
|
|
1791
|
-
await app._serverTeamsCache.refresh([void 0]);
|
|
1792
|
-
},
|
|
1793
|
-
async delete() {
|
|
1794
|
-
await app._interface.deleteServerTeam(crud.id);
|
|
1795
|
-
await app._serverTeamsCache.refresh([void 0]);
|
|
1796
|
-
},
|
|
1797
|
-
async listUsers() {
|
|
1798
|
-
const result = import_results.Result.orThrow(await app._serverTeamMemberProfilesCache.getOrWait([crud.id], "write-only"));
|
|
1799
|
-
return result.map((u) => app._serverTeamUserFromCrud(u));
|
|
1800
|
-
},
|
|
1801
|
-
useUsers() {
|
|
1802
|
-
const result = useAsyncCache(app._serverTeamMemberProfilesCache, [crud.id], "team.useUsers()");
|
|
1803
|
-
return (0, import_react2.useMemo)(() => result.map((u) => app._serverTeamUserFromCrud(u)), [result]);
|
|
1804
|
-
},
|
|
1805
|
-
async addUser(userId) {
|
|
1806
|
-
await app._interface.addServerUserToTeam({
|
|
1807
|
-
teamId: crud.id,
|
|
1808
|
-
userId
|
|
1809
|
-
});
|
|
1810
|
-
await app._serverTeamMemberProfilesCache.refresh([crud.id]);
|
|
1811
|
-
},
|
|
1812
|
-
async removeUser(userId) {
|
|
1813
|
-
await app._interface.removeServerUserFromTeam({
|
|
1814
|
-
teamId: crud.id,
|
|
1815
|
-
userId
|
|
1816
|
-
});
|
|
1817
|
-
await app._serverTeamMemberProfilesCache.refresh([crud.id]);
|
|
1818
|
-
},
|
|
1819
|
-
async inviteUser(options) {
|
|
1820
|
-
if (!options.callbackUrl && !await app._getCurrentUrl()) {
|
|
1821
|
-
throw new Error("Cannot invite user without a callback URL from the server or without a redirect method. Make sure you pass the `callbackUrl` option: `inviteUser({ email, callbackUrl: ... })`");
|
|
1822
|
-
}
|
|
1823
|
-
await app._interface.sendServerTeamInvitation({
|
|
1824
|
-
teamId: crud.id,
|
|
1825
|
-
email: options.email,
|
|
1826
|
-
callbackUrl: options.callbackUrl ?? (0, import_url.constructRedirectUrl)(app.urls.teamInvitation)
|
|
1827
|
-
});
|
|
1828
|
-
await app._serverTeamInvitationsCache.refresh([crud.id]);
|
|
1829
|
-
},
|
|
1830
|
-
async listInvitations() {
|
|
1831
|
-
const result = import_results.Result.orThrow(await app._serverTeamInvitationsCache.getOrWait([crud.id], "write-only"));
|
|
1832
|
-
return result.map((crud2) => app._serverTeamInvitationFromCrud(crud2));
|
|
1833
|
-
},
|
|
1834
|
-
useInvitations() {
|
|
1835
|
-
const result = useAsyncCache(app._serverTeamInvitationsCache, [crud.id], "team.useInvitations()");
|
|
1836
|
-
return (0, import_react2.useMemo)(() => result.map((crud2) => app._serverTeamInvitationFromCrud(crud2)), [result]);
|
|
1837
|
-
}
|
|
1838
|
-
};
|
|
1839
|
-
}
|
|
1840
|
-
async createUser(options) {
|
|
1841
|
-
const crud = await this._interface.createServerUser(serverUserCreateOptionsToCrud(options));
|
|
1842
|
-
await this._refreshUsers();
|
|
1843
|
-
return this._serverUserFromCrud(crud);
|
|
1844
|
-
}
|
|
1845
|
-
async getUser(options) {
|
|
1846
|
-
if (typeof options === "string") {
|
|
1847
|
-
return await this.getServerUserById(options);
|
|
1848
|
-
} else {
|
|
1849
|
-
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1850
|
-
const session = await this._getSession(options?.tokenStore);
|
|
1851
|
-
const crud = import_results.Result.orThrow(await this._currentServerUserCache.getOrWait([session], "write-only"));
|
|
1852
|
-
if (crud === null) {
|
|
1853
|
-
switch (options?.or) {
|
|
1854
|
-
case "redirect": {
|
|
1855
|
-
await this.redirectToSignIn({ replace: true });
|
|
1856
|
-
break;
|
|
1857
|
-
}
|
|
1858
|
-
case "throw": {
|
|
1859
|
-
throw new Error("User is not signed in but getUser was called with { or: 'throw' }");
|
|
1860
|
-
}
|
|
1861
|
-
default: {
|
|
1862
|
-
return null;
|
|
1863
|
-
}
|
|
1864
|
-
}
|
|
1865
|
-
}
|
|
1866
|
-
return crud && this._currentUserFromCrud(crud, session);
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
async getServerUser() {
|
|
1870
|
-
console.warn("stackServerApp.getServerUser is deprecated; use stackServerApp.getUser instead");
|
|
1871
|
-
return await this.getUser();
|
|
1872
|
-
}
|
|
1873
|
-
async getServerUserById(userId) {
|
|
1874
|
-
const crud = import_results.Result.orThrow(await this._serverUserCache.getOrWait([userId], "write-only"));
|
|
1875
|
-
return crud && this._serverUserFromCrud(crud);
|
|
1876
|
-
}
|
|
1877
|
-
useUser(options) {
|
|
1878
|
-
if (typeof options === "string") {
|
|
1879
|
-
return this.useUserById(options);
|
|
1880
|
-
} else {
|
|
1881
|
-
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1882
|
-
const session = this._useSession(options?.tokenStore);
|
|
1883
|
-
const crud = useAsyncCache(this._currentServerUserCache, [session], "useUser()");
|
|
1884
|
-
if (crud === null) {
|
|
1885
|
-
switch (options?.or) {
|
|
1886
|
-
case "redirect": {
|
|
1887
|
-
(0, import_promises.runAsynchronously)(this.redirectToSignIn({ replace: true }));
|
|
1888
|
-
(0, import_react.suspend)();
|
|
1889
|
-
throw new import_errors.StackAssertionError("suspend should never return");
|
|
1890
|
-
}
|
|
1891
|
-
case "throw": {
|
|
1892
|
-
throw new Error("User is not signed in but useUser was called with { or: 'throw' }");
|
|
1893
|
-
}
|
|
1894
|
-
case void 0:
|
|
1895
|
-
case "return-null": {
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
return (0, import_react2.useMemo)(() => {
|
|
1900
|
-
return crud && this._currentUserFromCrud(crud, session);
|
|
1901
|
-
}, [crud, session, options?.or]);
|
|
1902
|
-
}
|
|
1903
|
-
}
|
|
1904
|
-
useUserById(userId) {
|
|
1905
|
-
const crud = useAsyncCache(this._serverUserCache, [userId], "useUserById()");
|
|
1906
|
-
return (0, import_react2.useMemo)(() => {
|
|
1907
|
-
return crud && this._serverUserFromCrud(crud);
|
|
1908
|
-
}, [crud]);
|
|
1909
|
-
}
|
|
1910
|
-
async listUsers(options) {
|
|
1911
|
-
const crud = import_results.Result.orThrow(await this._serverUsersCache.getOrWait([options?.cursor, options?.limit, options?.orderBy, options?.desc, options?.query], "write-only"));
|
|
1912
|
-
const result = crud.items.map((j) => this._serverUserFromCrud(j));
|
|
1913
|
-
result.nextCursor = crud.pagination?.next_cursor ?? null;
|
|
1914
|
-
return result;
|
|
1915
|
-
}
|
|
1916
|
-
useUsers(options) {
|
|
1917
|
-
const crud = useAsyncCache(this._serverUsersCache, [options?.cursor, options?.limit, options?.orderBy, options?.desc, options?.query], "useServerUsers()");
|
|
1918
|
-
const result = crud.items.map((j) => this._serverUserFromCrud(j));
|
|
1919
|
-
result.nextCursor = crud.pagination?.next_cursor ?? null;
|
|
1920
|
-
return result;
|
|
1921
|
-
}
|
|
1922
|
-
_serverPermissionFromCrud(crud) {
|
|
1923
|
-
return {
|
|
1924
|
-
id: crud.id
|
|
1925
|
-
};
|
|
1926
|
-
}
|
|
1927
|
-
_serverTeamPermissionDefinitionFromCrud(crud) {
|
|
1928
|
-
return {
|
|
1929
|
-
id: crud.id,
|
|
1930
|
-
description: crud.description,
|
|
1931
|
-
containedPermissionIds: crud.contained_permission_ids
|
|
1932
|
-
};
|
|
1933
|
-
}
|
|
1934
|
-
async listTeams() {
|
|
1935
|
-
const teams = import_results.Result.orThrow(await this._serverTeamsCache.getOrWait([void 0], "write-only"));
|
|
1936
|
-
return teams.map((t) => this._serverTeamFromCrud(t));
|
|
1937
|
-
}
|
|
1938
|
-
async createTeam(data) {
|
|
1939
|
-
const team = await this._interface.createServerTeam(serverTeamCreateOptionsToCrud(data));
|
|
1940
|
-
await this._serverTeamsCache.refresh([void 0]);
|
|
1941
|
-
return this._serverTeamFromCrud(team);
|
|
1942
|
-
}
|
|
1943
|
-
useTeams() {
|
|
1944
|
-
const teams = useAsyncCache(this._serverTeamsCache, [void 0], "useServerTeams()");
|
|
1945
|
-
return (0, import_react2.useMemo)(() => {
|
|
1946
|
-
return teams.map((t) => this._serverTeamFromCrud(t));
|
|
1947
|
-
}, [teams]);
|
|
1948
|
-
}
|
|
1949
|
-
async getTeam(teamId) {
|
|
1950
|
-
const teams = await this.listTeams();
|
|
1951
|
-
return teams.find((t) => t.id === teamId) ?? null;
|
|
1952
|
-
}
|
|
1953
|
-
useTeam(teamId) {
|
|
1954
|
-
const teams = this.useTeams();
|
|
1955
|
-
return (0, import_react2.useMemo)(() => {
|
|
1956
|
-
return teams.find((t) => t.id === teamId) ?? null;
|
|
1957
|
-
}, [teams, teamId]);
|
|
1958
|
-
}
|
|
1959
|
-
async _refreshSession(session) {
|
|
1960
|
-
await Promise.all([
|
|
1961
|
-
super._refreshUser(session),
|
|
1962
|
-
this._currentServerUserCache.refresh([session])
|
|
1963
|
-
]);
|
|
1964
|
-
}
|
|
1965
|
-
async _refreshUsers() {
|
|
1966
|
-
await Promise.all([
|
|
1967
|
-
super._refreshUsers(),
|
|
1968
|
-
this._serverUserCache.refreshWhere(() => true),
|
|
1969
|
-
this._serverUsersCache.refreshWhere(() => true),
|
|
1970
|
-
this._serverContactChannelsCache.refreshWhere(() => true)
|
|
1971
|
-
]);
|
|
1972
|
-
}
|
|
1973
|
-
};
|
|
1974
|
-
var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
1975
|
-
constructor(options) {
|
|
1976
|
-
super({
|
|
1977
|
-
interface: new import_stack_shared.StackAdminInterface({
|
|
1978
|
-
getBaseUrl: () => getBaseUrl(options.baseUrl),
|
|
1979
|
-
projectId: options.projectId ?? getDefaultProjectId(),
|
|
1980
|
-
clientVersion,
|
|
1981
|
-
..."projectOwnerSession" in options ? {
|
|
1982
|
-
projectOwnerSession: options.projectOwnerSession
|
|
1983
|
-
} : {
|
|
1984
|
-
publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),
|
|
1985
|
-
secretServerKey: options.secretServerKey ?? getDefaultSecretServerKey(),
|
|
1986
|
-
superSecretAdminKey: options.superSecretAdminKey ?? getDefaultSuperSecretAdminKey()
|
|
1987
|
-
}
|
|
1988
|
-
}),
|
|
1989
|
-
baseUrl: options.baseUrl,
|
|
1990
|
-
projectId: options.projectId,
|
|
1991
|
-
tokenStore: options.tokenStore,
|
|
1992
|
-
urls: options.urls,
|
|
1993
|
-
oauthScopesOnSignIn: options.oauthScopesOnSignIn,
|
|
1994
|
-
redirectMethod: options.redirectMethod
|
|
1995
|
-
});
|
|
1996
|
-
this._adminProjectCache = createCache(async () => {
|
|
1997
|
-
return await this._interface.getProject();
|
|
1998
|
-
});
|
|
1999
|
-
this._apiKeysCache = createCache(async () => {
|
|
2000
|
-
return await this._interface.listApiKeys();
|
|
2001
|
-
});
|
|
2002
|
-
this._adminEmailTemplatesCache = createCache(async () => {
|
|
2003
|
-
return await this._interface.listEmailTemplates();
|
|
2004
|
-
});
|
|
2005
|
-
this._adminTeamPermissionDefinitionsCache = createCache(async () => {
|
|
2006
|
-
return await this._interface.listPermissionDefinitions();
|
|
2007
|
-
});
|
|
2008
|
-
this._svixTokenCache = createCache(async () => {
|
|
2009
|
-
return await this._interface.getSvixToken();
|
|
2010
|
-
});
|
|
2011
|
-
this._metricsCache = createCache(async () => {
|
|
2012
|
-
return await this._interface.getMetrics();
|
|
2013
|
-
});
|
|
2014
|
-
}
|
|
2015
|
-
_adminOwnedProjectFromCrud(data, onRefresh) {
|
|
2016
|
-
if (this._tokenStoreInit !== null) {
|
|
2017
|
-
throw new import_errors.StackAssertionError("Owned apps must always have tokenStore === null \u2014 did you not create this project with app._createOwnedApp()?");
|
|
2018
|
-
;
|
|
2019
|
-
}
|
|
2020
|
-
return {
|
|
2021
|
-
...this._adminProjectFromCrud(data, onRefresh),
|
|
2022
|
-
app: this
|
|
2023
|
-
};
|
|
2024
|
-
}
|
|
2025
|
-
_adminProjectFromCrud(data, onRefresh) {
|
|
2026
|
-
if (data.id !== this.projectId) {
|
|
2027
|
-
throw new import_errors.StackAssertionError(`The project ID of the provided project JSON (${data.id}) does not match the project ID of the app (${this.projectId})!`);
|
|
2028
|
-
}
|
|
2029
|
-
const app = this;
|
|
2030
|
-
return {
|
|
2031
|
-
id: data.id,
|
|
2032
|
-
displayName: data.display_name,
|
|
2033
|
-
description: data.description,
|
|
2034
|
-
createdAt: new Date(data.created_at_millis),
|
|
2035
|
-
userCount: data.user_count,
|
|
2036
|
-
isProductionMode: data.is_production_mode,
|
|
2037
|
-
config: {
|
|
2038
|
-
id: data.config.id,
|
|
2039
|
-
signUpEnabled: data.config.sign_up_enabled,
|
|
2040
|
-
credentialEnabled: data.config.credential_enabled,
|
|
2041
|
-
magicLinkEnabled: data.config.magic_link_enabled,
|
|
2042
|
-
passkeyEnabled: data.config.passkey_enabled,
|
|
2043
|
-
clientTeamCreationEnabled: data.config.client_team_creation_enabled,
|
|
2044
|
-
clientUserDeletionEnabled: data.config.client_user_deletion_enabled,
|
|
2045
|
-
allowLocalhost: data.config.allow_localhost,
|
|
2046
|
-
oauthProviders: data.config.oauth_providers.map((p) => p.type === "shared" ? {
|
|
2047
|
-
id: p.id,
|
|
2048
|
-
enabled: p.enabled,
|
|
2049
|
-
type: "shared"
|
|
2050
|
-
} : {
|
|
2051
|
-
id: p.id,
|
|
2052
|
-
enabled: p.enabled,
|
|
2053
|
-
type: "standard",
|
|
2054
|
-
clientId: p.client_id ?? (0, import_errors.throwErr)("Client ID is missing"),
|
|
2055
|
-
clientSecret: p.client_secret ?? (0, import_errors.throwErr)("Client secret is missing"),
|
|
2056
|
-
facebookConfigId: p.facebook_config_id,
|
|
2057
|
-
microsoftTenantId: p.microsoft_tenant_id
|
|
2058
|
-
}),
|
|
2059
|
-
emailConfig: data.config.email_config.type === "shared" ? {
|
|
2060
|
-
type: "shared"
|
|
2061
|
-
} : {
|
|
2062
|
-
type: "standard",
|
|
2063
|
-
host: data.config.email_config.host ?? (0, import_errors.throwErr)("Email host is missing"),
|
|
2064
|
-
port: data.config.email_config.port ?? (0, import_errors.throwErr)("Email port is missing"),
|
|
2065
|
-
username: data.config.email_config.username ?? (0, import_errors.throwErr)("Email username is missing"),
|
|
2066
|
-
password: data.config.email_config.password ?? (0, import_errors.throwErr)("Email password is missing"),
|
|
2067
|
-
senderName: data.config.email_config.sender_name ?? (0, import_errors.throwErr)("Email sender name is missing"),
|
|
2068
|
-
senderEmail: data.config.email_config.sender_email ?? (0, import_errors.throwErr)("Email sender email is missing")
|
|
2069
|
-
},
|
|
2070
|
-
domains: data.config.domains.map((d) => ({
|
|
2071
|
-
domain: d.domain,
|
|
2072
|
-
handlerPath: d.handler_path
|
|
2073
|
-
})),
|
|
2074
|
-
createTeamOnSignUp: data.config.create_team_on_sign_up,
|
|
2075
|
-
teamCreatorDefaultPermissions: data.config.team_creator_default_permissions,
|
|
2076
|
-
teamMemberDefaultPermissions: data.config.team_member_default_permissions
|
|
2077
|
-
},
|
|
2078
|
-
async update(update) {
|
|
2079
|
-
await app._interface.updateProject(adminProjectUpdateOptionsToCrud(update));
|
|
2080
|
-
await onRefresh();
|
|
2081
|
-
},
|
|
2082
|
-
async delete() {
|
|
2083
|
-
await app._interface.deleteProject();
|
|
2084
|
-
},
|
|
2085
|
-
async getProductionModeErrors() {
|
|
2086
|
-
return (0, import_production_mode.getProductionModeErrors)(data);
|
|
2087
|
-
},
|
|
2088
|
-
useProductionModeErrors() {
|
|
2089
|
-
return (0, import_production_mode.getProductionModeErrors)(data);
|
|
2090
|
-
}
|
|
2091
|
-
};
|
|
2092
|
-
}
|
|
2093
|
-
_adminEmailTemplateFromCrud(data) {
|
|
2094
|
-
return {
|
|
2095
|
-
type: data.type,
|
|
2096
|
-
subject: data.subject,
|
|
2097
|
-
content: data.content,
|
|
2098
|
-
isDefault: data.is_default
|
|
2099
|
-
};
|
|
2100
|
-
}
|
|
2101
|
-
async getProject() {
|
|
2102
|
-
return this._adminProjectFromCrud(
|
|
2103
|
-
import_results.Result.orThrow(await this._adminProjectCache.getOrWait([], "write-only")),
|
|
2104
|
-
() => this._refreshProject()
|
|
2105
|
-
);
|
|
2106
|
-
}
|
|
2107
|
-
useProject() {
|
|
2108
|
-
const crud = useAsyncCache(this._adminProjectCache, [], "useProjectAdmin()");
|
|
2109
|
-
return (0, import_react2.useMemo)(() => this._adminProjectFromCrud(
|
|
2110
|
-
crud,
|
|
2111
|
-
() => this._refreshProject()
|
|
2112
|
-
), [crud]);
|
|
2113
|
-
}
|
|
2114
|
-
_createApiKeyBaseFromCrud(data) {
|
|
2115
|
-
const app = this;
|
|
2116
|
-
return {
|
|
2117
|
-
id: data.id,
|
|
2118
|
-
description: data.description,
|
|
2119
|
-
expiresAt: new Date(data.expires_at_millis),
|
|
2120
|
-
manuallyRevokedAt: data.manually_revoked_at_millis ? new Date(data.manually_revoked_at_millis) : null,
|
|
2121
|
-
createdAt: new Date(data.created_at_millis),
|
|
2122
|
-
isValid() {
|
|
2123
|
-
return this.whyInvalid() === null;
|
|
2124
|
-
},
|
|
2125
|
-
whyInvalid() {
|
|
2126
|
-
if (this.expiresAt.getTime() < Date.now()) return "expired";
|
|
2127
|
-
if (this.manuallyRevokedAt) return "manually-revoked";
|
|
2128
|
-
return null;
|
|
2129
|
-
},
|
|
2130
|
-
async revoke() {
|
|
2131
|
-
const res = await app._interface.revokeApiKeyById(data.id);
|
|
2132
|
-
await app._refreshApiKeys();
|
|
2133
|
-
return res;
|
|
2134
|
-
}
|
|
2135
|
-
};
|
|
2136
|
-
}
|
|
2137
|
-
_createApiKeyFromCrud(data) {
|
|
2138
|
-
return {
|
|
2139
|
-
...this._createApiKeyBaseFromCrud(data),
|
|
2140
|
-
publishableClientKey: data.publishable_client_key ? { lastFour: data.publishable_client_key.last_four } : null,
|
|
2141
|
-
secretServerKey: data.secret_server_key ? { lastFour: data.secret_server_key.last_four } : null,
|
|
2142
|
-
superSecretAdminKey: data.super_secret_admin_key ? { lastFour: data.super_secret_admin_key.last_four } : null
|
|
2143
|
-
};
|
|
2144
|
-
}
|
|
2145
|
-
_createApiKeyFirstViewFromCrud(data) {
|
|
2146
|
-
return {
|
|
2147
|
-
...this._createApiKeyBaseFromCrud(data),
|
|
2148
|
-
publishableClientKey: data.publishable_client_key,
|
|
2149
|
-
secretServerKey: data.secret_server_key,
|
|
2150
|
-
superSecretAdminKey: data.super_secret_admin_key
|
|
2151
|
-
};
|
|
2152
|
-
}
|
|
2153
|
-
async listApiKeys() {
|
|
2154
|
-
const crud = import_results.Result.orThrow(await this._apiKeysCache.getOrWait([], "write-only"));
|
|
2155
|
-
return crud.map((j) => this._createApiKeyFromCrud(j));
|
|
2156
|
-
}
|
|
2157
|
-
useApiKeys() {
|
|
2158
|
-
const crud = useAsyncCache(this._apiKeysCache, [], "useApiKeys()");
|
|
2159
|
-
return (0, import_react2.useMemo)(() => {
|
|
2160
|
-
return crud.map((j) => this._createApiKeyFromCrud(j));
|
|
2161
|
-
}, [crud]);
|
|
2162
|
-
}
|
|
2163
|
-
async createApiKey(options) {
|
|
2164
|
-
const crud = await this._interface.createApiKey(apiKeyCreateOptionsToCrud(options));
|
|
2165
|
-
await this._refreshApiKeys();
|
|
2166
|
-
return this._createApiKeyFirstViewFromCrud(crud);
|
|
2167
|
-
}
|
|
2168
|
-
useEmailTemplates() {
|
|
2169
|
-
const crud = useAsyncCache(this._adminEmailTemplatesCache, [], "useEmailTemplates()");
|
|
2170
|
-
return (0, import_react2.useMemo)(() => {
|
|
2171
|
-
return crud.map((j) => this._adminEmailTemplateFromCrud(j));
|
|
2172
|
-
}, [crud]);
|
|
2173
|
-
}
|
|
2174
|
-
async listEmailTemplates() {
|
|
2175
|
-
const crud = import_results.Result.orThrow(await this._adminEmailTemplatesCache.getOrWait([], "write-only"));
|
|
2176
|
-
return crud.map((j) => this._adminEmailTemplateFromCrud(j));
|
|
2177
|
-
}
|
|
2178
|
-
async updateEmailTemplate(type, data) {
|
|
2179
|
-
await this._interface.updateEmailTemplate(type, adminEmailTemplateUpdateOptionsToCrud(data));
|
|
2180
|
-
await this._adminEmailTemplatesCache.refresh([]);
|
|
2181
|
-
}
|
|
2182
|
-
async resetEmailTemplate(type) {
|
|
2183
|
-
await this._interface.resetEmailTemplate(type);
|
|
2184
|
-
await this._adminEmailTemplatesCache.refresh([]);
|
|
2185
|
-
}
|
|
2186
|
-
async createTeamPermissionDefinition(data) {
|
|
2187
|
-
const crud = await this._interface.createPermissionDefinition(serverTeamPermissionDefinitionCreateOptionsToCrud(data));
|
|
2188
|
-
await this._adminTeamPermissionDefinitionsCache.refresh([]);
|
|
2189
|
-
return this._serverTeamPermissionDefinitionFromCrud(crud);
|
|
2190
|
-
}
|
|
2191
|
-
async updateTeamPermissionDefinition(permissionId, data) {
|
|
2192
|
-
await this._interface.updatePermissionDefinition(permissionId, serverTeamPermissionDefinitionUpdateOptionsToCrud(data));
|
|
2193
|
-
await this._adminTeamPermissionDefinitionsCache.refresh([]);
|
|
2194
|
-
}
|
|
2195
|
-
async deleteTeamPermissionDefinition(permissionId) {
|
|
2196
|
-
await this._interface.deletePermissionDefinition(permissionId);
|
|
2197
|
-
await this._adminTeamPermissionDefinitionsCache.refresh([]);
|
|
2198
|
-
}
|
|
2199
|
-
async listTeamPermissionDefinitions() {
|
|
2200
|
-
const crud = import_results.Result.orThrow(await this._adminTeamPermissionDefinitionsCache.getOrWait([], "write-only"));
|
|
2201
|
-
return crud.map((p) => this._serverTeamPermissionDefinitionFromCrud(p));
|
|
2202
|
-
}
|
|
2203
|
-
useTeamPermissionDefinitions() {
|
|
2204
|
-
const crud = useAsyncCache(this._adminTeamPermissionDefinitionsCache, [], "usePermissions()");
|
|
2205
|
-
return (0, import_react2.useMemo)(() => {
|
|
2206
|
-
return crud.map((p) => this._serverTeamPermissionDefinitionFromCrud(p));
|
|
2207
|
-
}, [crud]);
|
|
2208
|
-
}
|
|
2209
|
-
useSvixToken() {
|
|
2210
|
-
const crud = useAsyncCache(this._svixTokenCache, [], "useSvixToken()");
|
|
2211
|
-
return crud.token;
|
|
2212
|
-
}
|
|
2213
|
-
async _refreshProject() {
|
|
2214
|
-
await Promise.all([
|
|
2215
|
-
super._refreshProject(),
|
|
2216
|
-
this._adminProjectCache.refresh([])
|
|
2217
|
-
]);
|
|
2218
|
-
}
|
|
2219
|
-
async _refreshApiKeys() {
|
|
2220
|
-
await this._apiKeysCache.refresh([]);
|
|
2221
|
-
}
|
|
2222
|
-
get [stackAppInternalsSymbol]() {
|
|
2223
|
-
return {
|
|
2224
|
-
...super[stackAppInternalsSymbol],
|
|
2225
|
-
useMetrics: () => {
|
|
2226
|
-
return useAsyncCache(this._metricsCache, [], "useMetrics()");
|
|
2227
|
-
}
|
|
2228
|
-
};
|
|
2229
|
-
}
|
|
2230
|
-
async sendTestEmail(options) {
|
|
2231
|
-
const response = await this._interface.sendTestEmail({
|
|
2232
|
-
recipient_email: options.recipientEmail,
|
|
2233
|
-
email_config: {
|
|
2234
|
-
...(0, import_objects.pick)(options.emailConfig, ["host", "port", "username", "password"]),
|
|
2235
|
-
sender_email: options.emailConfig.senderEmail,
|
|
2236
|
-
sender_name: options.emailConfig.senderName
|
|
2237
|
-
}
|
|
2238
|
-
});
|
|
2239
|
-
if (response.success) {
|
|
2240
|
-
return import_results.Result.ok(void 0);
|
|
2241
|
-
} else {
|
|
2242
|
-
return import_results.Result.error({ errorMessage: response.error_message ?? (0, import_errors.throwErr)("Email test error not specified") });
|
|
2243
|
-
}
|
|
2244
|
-
}
|
|
2245
|
-
};
|
|
2246
|
-
function contactChannelCreateOptionsToCrud(userId, options) {
|
|
2247
|
-
return {
|
|
2248
|
-
value: options.value,
|
|
2249
|
-
type: options.type,
|
|
2250
|
-
used_for_auth: options.usedForAuth,
|
|
2251
|
-
user_id: userId
|
|
2252
|
-
};
|
|
2253
|
-
}
|
|
2254
|
-
function contactChannelUpdateOptionsToCrud(options) {
|
|
2255
|
-
return {
|
|
2256
|
-
value: options.value,
|
|
2257
|
-
used_for_auth: options.usedForAuth,
|
|
2258
|
-
is_primary: options.isPrimary
|
|
2259
|
-
};
|
|
2260
|
-
}
|
|
2261
|
-
function serverContactChannelUpdateOptionsToCrud(options) {
|
|
2262
|
-
return {
|
|
2263
|
-
value: options.value,
|
|
2264
|
-
is_verified: options.isVerified,
|
|
2265
|
-
used_for_auth: options.usedForAuth
|
|
2266
|
-
};
|
|
2267
|
-
}
|
|
2268
|
-
function serverContactChannelCreateOptionsToCrud(userId, options) {
|
|
2269
|
-
return {
|
|
2270
|
-
type: options.type,
|
|
2271
|
-
value: options.value,
|
|
2272
|
-
is_verified: options.isVerified,
|
|
2273
|
-
user_id: userId,
|
|
2274
|
-
used_for_auth: options.usedForAuth
|
|
2275
|
-
};
|
|
2276
|
-
}
|
|
2277
|
-
function userUpdateOptionsToCrud(options) {
|
|
2278
|
-
return {
|
|
2279
|
-
display_name: options.displayName,
|
|
2280
|
-
client_metadata: options.clientMetadata,
|
|
2281
|
-
selected_team_id: options.selectedTeamId,
|
|
2282
|
-
totp_secret_base64: options.totpMultiFactorSecret != null ? (0, import_bytes.encodeBase64)(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,
|
|
2283
|
-
profile_image_url: options.profileImageUrl,
|
|
2284
|
-
otp_auth_enabled: options.otpAuthEnabled,
|
|
2285
|
-
passkey_auth_enabled: options.passkeyAuthEnabled
|
|
2286
|
-
};
|
|
2287
|
-
}
|
|
2288
|
-
function serverUserUpdateOptionsToCrud(options) {
|
|
2289
|
-
return {
|
|
2290
|
-
display_name: options.displayName,
|
|
2291
|
-
primary_email: options.primaryEmail,
|
|
2292
|
-
client_metadata: options.clientMetadata,
|
|
2293
|
-
client_read_only_metadata: options.clientReadOnlyMetadata,
|
|
2294
|
-
server_metadata: options.serverMetadata,
|
|
2295
|
-
selected_team_id: options.selectedTeamId,
|
|
2296
|
-
primary_email_auth_enabled: options.primaryEmailAuthEnabled,
|
|
2297
|
-
primary_email_verified: options.primaryEmailVerified,
|
|
2298
|
-
password: options.password,
|
|
2299
|
-
profile_image_url: options.profileImageUrl,
|
|
2300
|
-
totp_secret_base64: options.totpMultiFactorSecret != null ? (0, import_bytes.encodeBase64)(options.totpMultiFactorSecret) : options.totpMultiFactorSecret
|
|
2301
|
-
};
|
|
2302
|
-
}
|
|
2303
|
-
function serverUserCreateOptionsToCrud(options) {
|
|
2304
|
-
return {
|
|
2305
|
-
primary_email: options.primaryEmail,
|
|
2306
|
-
password: options.password,
|
|
2307
|
-
otp_auth_enabled: options.otpAuthEnabled,
|
|
2308
|
-
primary_email_auth_enabled: options.primaryEmailAuthEnabled,
|
|
2309
|
-
display_name: options.displayName,
|
|
2310
|
-
primary_email_verified: options.primaryEmailVerified,
|
|
2311
|
-
client_metadata: options.clientMetadata,
|
|
2312
|
-
client_read_only_metadata: options.clientReadOnlyMetadata,
|
|
2313
|
-
server_metadata: options.serverMetadata
|
|
2314
|
-
};
|
|
2315
|
-
}
|
|
2316
|
-
function adminProjectUpdateOptionsToCrud(options) {
|
|
2317
|
-
return {
|
|
2318
|
-
display_name: options.displayName,
|
|
2319
|
-
description: options.description,
|
|
2320
|
-
is_production_mode: options.isProductionMode,
|
|
2321
|
-
config: {
|
|
2322
|
-
domains: options.config?.domains?.map((d) => ({
|
|
2323
|
-
domain: d.domain,
|
|
2324
|
-
handler_path: d.handlerPath
|
|
2325
|
-
})),
|
|
2326
|
-
oauth_providers: options.config?.oauthProviders?.map((p) => ({
|
|
2327
|
-
id: p.id,
|
|
2328
|
-
enabled: p.enabled,
|
|
2329
|
-
type: p.type,
|
|
2330
|
-
...p.type === "standard" && {
|
|
2331
|
-
client_id: p.clientId,
|
|
2332
|
-
client_secret: p.clientSecret,
|
|
2333
|
-
facebook_config_id: p.facebookConfigId,
|
|
2334
|
-
microsoft_tenant_id: p.microsoftTenantId
|
|
2335
|
-
}
|
|
2336
|
-
})),
|
|
2337
|
-
email_config: options.config?.emailConfig && (options.config.emailConfig.type === "shared" ? {
|
|
2338
|
-
type: "shared"
|
|
2339
|
-
} : {
|
|
2340
|
-
type: "standard",
|
|
2341
|
-
host: options.config.emailConfig.host,
|
|
2342
|
-
port: options.config.emailConfig.port,
|
|
2343
|
-
username: options.config.emailConfig.username,
|
|
2344
|
-
password: options.config.emailConfig.password,
|
|
2345
|
-
sender_name: options.config.emailConfig.senderName,
|
|
2346
|
-
sender_email: options.config.emailConfig.senderEmail
|
|
2347
|
-
}),
|
|
2348
|
-
sign_up_enabled: options.config?.signUpEnabled,
|
|
2349
|
-
credential_enabled: options.config?.credentialEnabled,
|
|
2350
|
-
magic_link_enabled: options.config?.magicLinkEnabled,
|
|
2351
|
-
passkey_enabled: options.config?.passkeyEnabled,
|
|
2352
|
-
allow_localhost: options.config?.allowLocalhost,
|
|
2353
|
-
create_team_on_sign_up: options.config?.createTeamOnSignUp,
|
|
2354
|
-
client_team_creation_enabled: options.config?.clientTeamCreationEnabled,
|
|
2355
|
-
client_user_deletion_enabled: options.config?.clientUserDeletionEnabled,
|
|
2356
|
-
team_creator_default_permissions: options.config?.teamCreatorDefaultPermissions,
|
|
2357
|
-
team_member_default_permissions: options.config?.teamMemberDefaultPermissions
|
|
2358
|
-
}
|
|
2359
|
-
};
|
|
2360
|
-
}
|
|
2361
|
-
function adminProjectCreateOptionsToCrud(options) {
|
|
2362
|
-
return {
|
|
2363
|
-
...adminProjectUpdateOptionsToCrud(options),
|
|
2364
|
-
display_name: options.displayName
|
|
2365
|
-
};
|
|
2366
|
-
}
|
|
2367
|
-
function apiKeyCreateOptionsToCrud(options) {
|
|
2368
|
-
return {
|
|
2369
|
-
description: options.description,
|
|
2370
|
-
expires_at_millis: options.expiresAt.getTime(),
|
|
2371
|
-
has_publishable_client_key: options.hasPublishableClientKey,
|
|
2372
|
-
has_secret_server_key: options.hasSecretServerKey,
|
|
2373
|
-
has_super_secret_admin_key: options.hasSuperSecretAdminKey
|
|
2374
|
-
};
|
|
2375
|
-
}
|
|
2376
|
-
function teamUpdateOptionsToCrud(options) {
|
|
2377
|
-
return {
|
|
2378
|
-
display_name: options.displayName,
|
|
2379
|
-
profile_image_url: options.profileImageUrl,
|
|
2380
|
-
client_metadata: options.clientMetadata
|
|
2381
|
-
};
|
|
2382
|
-
}
|
|
2383
|
-
function teamCreateOptionsToCrud(options, creatorUserId) {
|
|
2384
|
-
return {
|
|
2385
|
-
display_name: options.displayName,
|
|
2386
|
-
profile_image_url: options.profileImageUrl,
|
|
2387
|
-
creator_user_id: creatorUserId
|
|
2388
|
-
};
|
|
2389
|
-
}
|
|
2390
|
-
function serverTeamCreateOptionsToCrud(options) {
|
|
2391
|
-
return {
|
|
2392
|
-
display_name: options.displayName,
|
|
2393
|
-
profile_image_url: options.profileImageUrl,
|
|
2394
|
-
creator_user_id: options.creatorUserId
|
|
2395
|
-
};
|
|
2396
|
-
}
|
|
2397
|
-
function serverTeamUpdateOptionsToCrud(options) {
|
|
2398
|
-
return {
|
|
2399
|
-
display_name: options.displayName,
|
|
2400
|
-
profile_image_url: options.profileImageUrl,
|
|
2401
|
-
client_metadata: options.clientMetadata,
|
|
2402
|
-
client_read_only_metadata: options.clientReadOnlyMetadata,
|
|
2403
|
-
server_metadata: options.serverMetadata
|
|
2404
|
-
};
|
|
2405
|
-
}
|
|
2406
|
-
function serverTeamPermissionDefinitionCreateOptionsToCrud(options) {
|
|
2407
|
-
return {
|
|
2408
|
-
id: options.id,
|
|
2409
|
-
description: options.description,
|
|
2410
|
-
contained_permission_ids: options.containedPermissionIds
|
|
2411
|
-
};
|
|
2412
|
-
}
|
|
2413
|
-
function serverTeamPermissionDefinitionUpdateOptionsToCrud(options) {
|
|
2414
|
-
return {
|
|
2415
|
-
id: options.id,
|
|
2416
|
-
description: options.description,
|
|
2417
|
-
contained_permission_ids: options.containedPermissionIds
|
|
2418
|
-
};
|
|
2419
|
-
}
|
|
2420
|
-
var StackClientApp = _StackClientAppImpl;
|
|
2421
|
-
var StackServerApp = _StackServerAppImpl;
|
|
2422
|
-
var StackAdminApp = _StackAdminAppImpl;
|
|
2423
|
-
function adminEmailTemplateUpdateOptionsToCrud(options) {
|
|
2424
|
-
return {
|
|
2425
|
-
subject: options.subject,
|
|
2426
|
-
content: options.content
|
|
2427
|
-
};
|
|
2428
|
-
}
|
|
1348
|
+
/**
|
|
1349
|
+
* There is a circular dependency between the admin app and the client app, as the former inherits from the latter and
|
|
1350
|
+
* the latter needs to use the former when creating a new instance of an internal project.
|
|
1351
|
+
*
|
|
1352
|
+
* To break it, we set the admin app here lazily instead of importing it directly. This variable is set by ./index.ts,
|
|
1353
|
+
* which imports both this file and ./admin-app-impl.ts.
|
|
1354
|
+
*/
|
|
1355
|
+
__StackClientAppImplIncomplete.LazyStackAdminAppImpl = { value: void 0 };
|
|
1356
|
+
var _StackClientAppImplIncomplete = __StackClientAppImplIncomplete;
|
|
2429
1357
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2430
1358
|
0 && (module.exports = {
|
|
2431
|
-
|
|
2432
|
-
StackClientApp,
|
|
2433
|
-
StackServerApp,
|
|
2434
|
-
serverTeamPermissionDefinitionCreateOptionsToCrud,
|
|
2435
|
-
serverTeamPermissionDefinitionUpdateOptionsToCrud,
|
|
2436
|
-
stackAppInternalsSymbol
|
|
1359
|
+
_StackClientAppImplIncomplete
|
|
2437
1360
|
});
|
|
2438
|
-
//# sourceMappingURL=
|
|
1361
|
+
//# sourceMappingURL=client-app-impl.js.map
|