@stackframe/stack 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-CTQhv9tV.d.ts +395 -0
- package/dist/admin-app-impl-DpyRKp1e.d.mts +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 +4 -7
- 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} +39 -1111
- 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 +142 -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-C7D6Vt7X.d.mts} +139 -354
- package/dist/{lib/stack-app.d.ts → index-DQk7XJpU.d.ts} +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 +5 -8
- 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} +77 -1154
- 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 +187 -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 +4 -4
- 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_compile_time = require("@stackframe/stack-shared/dist/utils/compile-time");
|
|
48
40
|
var import_env = require("@stackframe/stack-shared/dist/utils/env");
|
|
49
41
|
var import_errors = require("@stackframe/stack-shared/dist/utils/errors");
|
|
@@ -59,143 +51,30 @@ var import_uuids = require("@stackframe/stack-shared/dist/utils/uuids");
|
|
|
59
51
|
var cookie = __toESM(require("cookie"));
|
|
60
52
|
var NextNavigationUnscrambled = __toESM(require("next/navigation"));
|
|
61
53
|
var import_react2 = __toESM(require("react"));
|
|
62
|
-
var import_url = require("
|
|
63
|
-
var import_auth = require("
|
|
64
|
-
var import_cookie = require("
|
|
54
|
+
var import_url = require("../../../../utils/url");
|
|
55
|
+
var import_auth = require("../../../auth");
|
|
56
|
+
var import_cookie = require("../../../cookie");
|
|
57
|
+
var import_common = require("../../common");
|
|
58
|
+
var import_contact_channels = require("../../contact-channels");
|
|
59
|
+
var import_projects = require("../../projects");
|
|
60
|
+
var import_teams = require("../../teams");
|
|
61
|
+
var import_users = require("../../users");
|
|
62
|
+
var import_common2 = require("./common");
|
|
63
|
+
var import_common3 = require("./common");
|
|
65
64
|
var sc = __toESM(require("@stackframe/stack-sc"));
|
|
66
65
|
var import_stack_sc = require("@stackframe/stack-sc");
|
|
67
66
|
var isReactServer2 = false;
|
|
68
67
|
isReactServer2 = sc.isReactServer;
|
|
69
68
|
var NextNavigation = (0, import_compile_time.scrambleDuringCompileTime)(NextNavigationUnscrambled);
|
|
70
|
-
var clientVersion = "js @stackframe/stack@2.7.20";
|
|
71
|
-
if (clientVersion.startsWith("STACK_COMPILE_TIME")) {
|
|
72
|
-
throw new import_errors.StackAssertionError("Client version was not replaced. Something went wrong during build!");
|
|
73
|
-
}
|
|
74
|
-
function getUrls(partial) {
|
|
75
|
-
const handler = partial.handler ?? "/handler";
|
|
76
|
-
const home = partial.home ?? "/";
|
|
77
|
-
const afterSignIn = partial.afterSignIn ?? home;
|
|
78
|
-
return {
|
|
79
|
-
handler,
|
|
80
|
-
signIn: `${handler}/sign-in`,
|
|
81
|
-
afterSignIn: home,
|
|
82
|
-
signUp: `${handler}/sign-up`,
|
|
83
|
-
afterSignUp: afterSignIn,
|
|
84
|
-
signOut: `${handler}/sign-out`,
|
|
85
|
-
afterSignOut: home,
|
|
86
|
-
emailVerification: `${handler}/email-verification`,
|
|
87
|
-
passwordReset: `${handler}/password-reset`,
|
|
88
|
-
forgotPassword: `${handler}/forgot-password`,
|
|
89
|
-
oauthCallback: `${handler}/oauth-callback`,
|
|
90
|
-
magicLinkCallback: `${handler}/magic-link-callback`,
|
|
91
|
-
home,
|
|
92
|
-
accountSettings: `${handler}/account-settings`,
|
|
93
|
-
error: `${handler}/error`,
|
|
94
|
-
teamInvitation: `${handler}/team-invitation`,
|
|
95
|
-
...(0, import_objects.filterUndefined)(partial)
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function getDefaultProjectId() {
|
|
99
|
-
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."));
|
|
100
|
-
}
|
|
101
|
-
function getDefaultPublishableClientKey() {
|
|
102
|
-
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."));
|
|
103
|
-
}
|
|
104
|
-
function getDefaultSecretServerKey() {
|
|
105
|
-
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."));
|
|
106
|
-
}
|
|
107
|
-
function getDefaultSuperSecretAdminKey() {
|
|
108
|
-
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."));
|
|
109
|
-
}
|
|
110
|
-
function getBaseUrl(userSpecifiedBaseUrl) {
|
|
111
|
-
let url;
|
|
112
|
-
if (userSpecifiedBaseUrl) {
|
|
113
|
-
if (typeof userSpecifiedBaseUrl === "string") {
|
|
114
|
-
url = userSpecifiedBaseUrl;
|
|
115
|
-
} else {
|
|
116
|
-
if ((0, import_env.isBrowserLike)()) {
|
|
117
|
-
url = userSpecifiedBaseUrl.browser;
|
|
118
|
-
} else {
|
|
119
|
-
url = userSpecifiedBaseUrl.server;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
} else {
|
|
123
|
-
if ((0, import_env.isBrowserLike)()) {
|
|
124
|
-
url = process.env.NEXT_PUBLIC_BROWSER_STACK_API_URL;
|
|
125
|
-
} else {
|
|
126
|
-
url = process.env.NEXT_PUBLIC_SERVER_STACK_API_URL;
|
|
127
|
-
}
|
|
128
|
-
url = url || process.env.NEXT_PUBLIC_STACK_API_URL || process.env.NEXT_PUBLIC_STACK_URL || defaultBaseUrl;
|
|
129
|
-
}
|
|
130
|
-
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
131
|
-
}
|
|
132
|
-
var defaultBaseUrl = "https://api.stack-auth.com";
|
|
133
|
-
function createEmptyTokenStore() {
|
|
134
|
-
return new import_stores.Store({
|
|
135
|
-
refreshToken: null,
|
|
136
|
-
accessToken: null
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
var cachePromiseByComponentId = /* @__PURE__ */ new Map();
|
|
140
|
-
function useAsyncCache(cache, dependencies, caller) {
|
|
141
|
-
(0, import_react.suspendIfSsr)(caller);
|
|
142
|
-
const id = import_react2.default.useId();
|
|
143
|
-
const subscribe = (0, import_react2.useCallback)((cb) => {
|
|
144
|
-
const { unsubscribe } = cache.onStateChange(dependencies, () => {
|
|
145
|
-
cachePromiseByComponentId.delete(id);
|
|
146
|
-
cb();
|
|
147
|
-
});
|
|
148
|
-
return unsubscribe;
|
|
149
|
-
}, [cache, ...dependencies]);
|
|
150
|
-
const getSnapshot = (0, import_react2.useCallback)(() => {
|
|
151
|
-
if (!cachePromiseByComponentId.has(id)) {
|
|
152
|
-
cachePromiseByComponentId.set(id, cache.getOrWait(dependencies, "read-write"));
|
|
153
|
-
}
|
|
154
|
-
return cachePromiseByComponentId.get(id);
|
|
155
|
-
}, [cache, ...dependencies]);
|
|
156
|
-
const promise = import_react2.default.useSyncExternalStore(
|
|
157
|
-
subscribe,
|
|
158
|
-
getSnapshot,
|
|
159
|
-
() => (0, import_errors.throwErr)(new Error("getServerSnapshot should never be called in useAsyncCache because we restrict to CSR earlier"))
|
|
160
|
-
);
|
|
161
|
-
const result = import_react2.default.use(promise);
|
|
162
|
-
if (result.status === "error") {
|
|
163
|
-
const error = result.error;
|
|
164
|
-
if (error instanceof Error && !error.__stackHasConcatenatedStacktraces) {
|
|
165
|
-
(0, import_errors.concatStacktraces)(error, new Error());
|
|
166
|
-
error.__stackHasConcatenatedStacktraces = true;
|
|
167
|
-
}
|
|
168
|
-
throw error;
|
|
169
|
-
}
|
|
170
|
-
return result.data;
|
|
171
|
-
}
|
|
172
|
-
var stackAppInternalsSymbol = Symbol.for("StackAuth--DO-NOT-USE-OR-YOU-WILL-BE-FIRED--StackAppInternals");
|
|
173
|
-
var allClientApps = /* @__PURE__ */ new Map();
|
|
174
|
-
var createCache = (fetcher) => {
|
|
175
|
-
return new import_caches.AsyncCache(
|
|
176
|
-
async (dependencies) => await import_results.Result.fromThrowingAsync(async () => await fetcher(dependencies)),
|
|
177
|
-
{}
|
|
178
|
-
);
|
|
179
|
-
};
|
|
180
|
-
var createCacheBySession = (fetcher) => {
|
|
181
|
-
return new import_caches.AsyncCache(
|
|
182
|
-
async ([session, ...extraDependencies]) => await import_results.Result.fromThrowingAsync(async () => await fetcher(session, extraDependencies)),
|
|
183
|
-
{
|
|
184
|
-
onSubscribe: ([session], refresh) => {
|
|
185
|
-
const handler = session.onInvalidate(() => refresh());
|
|
186
|
-
return () => handler.unsubscribe();
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
);
|
|
190
|
-
};
|
|
191
69
|
var numberOfAppsCreated = 0;
|
|
192
|
-
var
|
|
70
|
+
var allClientApps = /* @__PURE__ */ new Map();
|
|
71
|
+
var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
193
72
|
constructor(_options) {
|
|
194
73
|
this._options = _options;
|
|
195
74
|
this._uniqueIdentifier = void 0;
|
|
196
75
|
this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY = false;
|
|
197
76
|
this._ownedAdminApps = new import_maps.DependenciesMap();
|
|
198
|
-
this._currentUserCache = createCacheBySession(async (session) => {
|
|
77
|
+
this._currentUserCache = (0, import_common2.createCacheBySession)(async (session) => {
|
|
199
78
|
if (this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY) {
|
|
200
79
|
await (0, import_promises.wait)(2e3);
|
|
201
80
|
}
|
|
@@ -204,19 +83,19 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
204
83
|
}
|
|
205
84
|
return await this._interface.getClientUserByToken(session);
|
|
206
85
|
});
|
|
207
|
-
this._currentProjectCache = createCache(async () => {
|
|
86
|
+
this._currentProjectCache = (0, import_common2.createCache)(async () => {
|
|
208
87
|
return import_results.Result.orThrow(await this._interface.getClientProject());
|
|
209
88
|
});
|
|
210
|
-
this._ownedProjectsCache = createCacheBySession(async (session) => {
|
|
89
|
+
this._ownedProjectsCache = (0, import_common2.createCacheBySession)(async (session) => {
|
|
211
90
|
return await this._interface.listProjects(session);
|
|
212
91
|
});
|
|
213
|
-
this._currentUserPermissionsCache = createCacheBySession(async (session, [teamId, recursive]) => {
|
|
92
|
+
this._currentUserPermissionsCache = (0, import_common2.createCacheBySession)(async (session, [teamId, recursive]) => {
|
|
214
93
|
return await this._interface.listCurrentUserTeamPermissions({ teamId, recursive }, session);
|
|
215
94
|
});
|
|
216
|
-
this._currentUserTeamsCache = createCacheBySession(async (session) => {
|
|
95
|
+
this._currentUserTeamsCache = (0, import_common2.createCacheBySession)(async (session) => {
|
|
217
96
|
return await this._interface.listCurrentUserTeams(session);
|
|
218
97
|
});
|
|
219
|
-
this._currentUserOAuthConnectionAccessTokensCache = createCacheBySession(
|
|
98
|
+
this._currentUserOAuthConnectionAccessTokensCache = (0, import_common2.createCacheBySession)(
|
|
220
99
|
async (session, [providerId, scope]) => {
|
|
221
100
|
try {
|
|
222
101
|
const result = await this._interface.createProviderAccessToken(providerId, scope || "", session);
|
|
@@ -229,12 +108,12 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
229
108
|
return null;
|
|
230
109
|
}
|
|
231
110
|
);
|
|
232
|
-
this._currentUserOAuthConnectionCache = createCacheBySession(
|
|
111
|
+
this._currentUserOAuthConnectionCache = (0, import_common2.createCacheBySession)(
|
|
233
112
|
async (session, [providerId, scope, redirect]) => {
|
|
234
113
|
return await this._getUserOAuthConnectionCacheFn({
|
|
235
114
|
getUser: async () => import_results.Result.orThrow(await this._currentUserCache.getOrWait([session], "write-only")),
|
|
236
115
|
getOrWaitOAuthToken: async () => import_results.Result.orThrow(await this._currentUserOAuthConnectionAccessTokensCache.getOrWait([session, providerId, scope || ""], "write-only")),
|
|
237
|
-
useOAuthToken: () => useAsyncCache(this._currentUserOAuthConnectionAccessTokensCache, [session, providerId, scope || ""], "useOAuthToken"),
|
|
116
|
+
useOAuthToken: () => (0, import_common3.useAsyncCache)(this._currentUserOAuthConnectionAccessTokensCache, [session, providerId, scope || ""], "useOAuthToken"),
|
|
238
117
|
providerId,
|
|
239
118
|
scope,
|
|
240
119
|
redirect,
|
|
@@ -242,27 +121,28 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
242
121
|
});
|
|
243
122
|
}
|
|
244
123
|
);
|
|
245
|
-
this._teamMemberProfilesCache = createCacheBySession(
|
|
124
|
+
this._teamMemberProfilesCache = (0, import_common2.createCacheBySession)(
|
|
246
125
|
async (session, [teamId]) => {
|
|
247
126
|
return await this._interface.listTeamMemberProfiles({ teamId }, session);
|
|
248
127
|
}
|
|
249
128
|
);
|
|
250
|
-
this._teamInvitationsCache = createCacheBySession(
|
|
129
|
+
this._teamInvitationsCache = (0, import_common2.createCacheBySession)(
|
|
251
130
|
async (session, [teamId]) => {
|
|
252
131
|
return await this._interface.listTeamInvitations({ teamId }, session);
|
|
253
132
|
}
|
|
254
133
|
);
|
|
255
|
-
this._currentUserTeamProfileCache = createCacheBySession(
|
|
134
|
+
this._currentUserTeamProfileCache = (0, import_common2.createCacheBySession)(
|
|
256
135
|
async (session, [teamId]) => {
|
|
257
136
|
return await this._interface.getTeamMemberProfile({ teamId, userId: "me" }, session);
|
|
258
137
|
}
|
|
259
138
|
);
|
|
260
|
-
this._clientContactChannelsCache = createCacheBySession(
|
|
139
|
+
this._clientContactChannelsCache = (0, import_common2.createCacheBySession)(
|
|
261
140
|
async (session) => {
|
|
262
141
|
return await this._interface.listClientContactChannels(session);
|
|
263
142
|
}
|
|
264
143
|
);
|
|
265
|
-
this._memoryTokenStore = createEmptyTokenStore();
|
|
144
|
+
this._memoryTokenStore = (0, import_common2.createEmptyTokenStore)();
|
|
145
|
+
this._nextServerCookiesTokenStores = /* @__PURE__ */ new WeakMap();
|
|
266
146
|
this._requestTokenStores = /* @__PURE__ */ new WeakMap();
|
|
267
147
|
this._storedBrowserCookieTokenStore = null;
|
|
268
148
|
/**
|
|
@@ -274,14 +154,17 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
274
154
|
* - 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
|
|
275
155
|
*/
|
|
276
156
|
this._sessionsByTokenStoreAndSessionKey = /* @__PURE__ */ new WeakMap();
|
|
157
|
+
if (!__StackClientAppImplIncomplete.LazyStackAdminAppImpl.value) {
|
|
158
|
+
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).");
|
|
159
|
+
}
|
|
277
160
|
if ("interface" in _options) {
|
|
278
161
|
this._interface = _options.interface;
|
|
279
162
|
} else {
|
|
280
163
|
this._interface = new import_stack_shared.StackClientInterface({
|
|
281
|
-
getBaseUrl: () => getBaseUrl(_options.baseUrl),
|
|
282
|
-
projectId: _options.projectId ?? getDefaultProjectId(),
|
|
283
|
-
clientVersion,
|
|
284
|
-
publishableClientKey: _options.publishableClientKey ?? getDefaultPublishableClientKey(),
|
|
164
|
+
getBaseUrl: () => (0, import_common2.getBaseUrl)(_options.baseUrl),
|
|
165
|
+
projectId: _options.projectId ?? (0, import_common2.getDefaultProjectId)(),
|
|
166
|
+
clientVersion: import_common2.clientVersion,
|
|
167
|
+
publishableClientKey: _options.publishableClientKey ?? (0, import_common2.getDefaultPublishableClientKey)(),
|
|
285
168
|
prepareRequest: async () => {
|
|
286
169
|
await (0, import_stack_sc.cookies)?.();
|
|
287
170
|
}
|
|
@@ -307,7 +190,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
307
190
|
if (this._tokenStoreInit === "nextjs-cookie" || this._tokenStoreInit === "cookie") {
|
|
308
191
|
return await (0, import_cookie.createCookieHelper)();
|
|
309
192
|
} else {
|
|
310
|
-
return await (0, import_cookie.
|
|
193
|
+
return await (0, import_cookie.createPlaceholderCookieHelper)();
|
|
311
194
|
}
|
|
312
195
|
}
|
|
313
196
|
async _getUserOAuthConnectionCacheFn(options) {
|
|
@@ -476,7 +359,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
476
359
|
}
|
|
477
360
|
default: {
|
|
478
361
|
if (tokenStoreInit === null) {
|
|
479
|
-
return createEmptyTokenStore();
|
|
362
|
+
return (0, import_common2.createEmptyTokenStore)();
|
|
480
363
|
} else if (typeof tokenStoreInit === "object" && "headers" in tokenStoreInit) {
|
|
481
364
|
if (this._requestTokenStores.has(tokenStoreInit)) return this._requestTokenStores.get(tokenStoreInit);
|
|
482
365
|
const stackAuthHeader = tokenStoreInit.headers.get("x-stack-auth");
|
|
@@ -651,7 +534,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
651
534
|
return result.map((crud2) => app._clientTeamUserFromCrud(crud2));
|
|
652
535
|
},
|
|
653
536
|
useUsers() {
|
|
654
|
-
const result = useAsyncCache(app._teamMemberProfilesCache, [session, crud.id], "team.useUsers()");
|
|
537
|
+
const result = (0, import_common3.useAsyncCache)(app._teamMemberProfilesCache, [session, crud.id], "team.useUsers()");
|
|
655
538
|
return result.map((crud2) => app._clientTeamUserFromCrud(crud2));
|
|
656
539
|
},
|
|
657
540
|
async listInvitations() {
|
|
@@ -659,11 +542,11 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
659
542
|
return result.map((crud2) => app._clientTeamInvitationFromCrud(session, crud2));
|
|
660
543
|
},
|
|
661
544
|
useInvitations() {
|
|
662
|
-
const result = useAsyncCache(app._teamInvitationsCache, [session, crud.id], "team.useInvitations()");
|
|
545
|
+
const result = (0, import_common3.useAsyncCache)(app._teamInvitationsCache, [session, crud.id], "team.useInvitations()");
|
|
663
546
|
return result.map((crud2) => app._clientTeamInvitationFromCrud(session, crud2));
|
|
664
547
|
},
|
|
665
548
|
async update(data) {
|
|
666
|
-
await app._interface.updateTeam({ data: teamUpdateOptionsToCrud(data), teamId: crud.id }, session);
|
|
549
|
+
await app._interface.updateTeam({ data: (0, import_teams.teamUpdateOptionsToCrud)(data), teamId: crud.id }, session);
|
|
667
550
|
await app._currentUserTeamsCache.refresh([session]);
|
|
668
551
|
},
|
|
669
552
|
async delete() {
|
|
@@ -685,7 +568,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
685
568
|
await app._interface.sendCurrentUserContactChannelVerificationEmail(crud.id, (0, import_url.constructRedirectUrl)(app.urls.emailVerification), session);
|
|
686
569
|
},
|
|
687
570
|
async update(data) {
|
|
688
|
-
await app._interface.updateClientContactChannel(crud.id, contactChannelUpdateOptionsToCrud(data), session);
|
|
571
|
+
await app._interface.updateClientContactChannel(crud.id, (0, import_contact_channels.contactChannelUpdateOptionsToCrud)(data), session);
|
|
689
572
|
await app._clientContactChannelsCache.refresh([session]);
|
|
690
573
|
},
|
|
691
574
|
async delete() {
|
|
@@ -733,12 +616,12 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
733
616
|
let attResp;
|
|
734
617
|
try {
|
|
735
618
|
attResp = await (0, import_browser.startRegistration)({ optionsJSON: options_json });
|
|
736
|
-
debugger;
|
|
737
619
|
} catch (error) {
|
|
738
620
|
if (error instanceof import_browser.WebAuthnError) {
|
|
739
621
|
return import_results.Result.error(new import_stack_shared.KnownErrors.PasskeyWebAuthnError(error.message, error.name));
|
|
740
622
|
} else {
|
|
741
|
-
|
|
623
|
+
(0, import_errors.captureError)("passkey-registration-failed", error);
|
|
624
|
+
return import_results.Result.error(new import_stack_shared.KnownErrors.PasskeyRegistrationFailed("Failed to start passkey registration due to unknown error"));
|
|
742
625
|
}
|
|
743
626
|
}
|
|
744
627
|
const registrationResult = await app._interface.registerPasskey({ credential: attResp, code }, session);
|
|
@@ -797,7 +680,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
797
680
|
}
|
|
798
681
|
function useConnectedAccount(id, options) {
|
|
799
682
|
const scopeString = options?.scopes?.join(" ");
|
|
800
|
-
return useAsyncCache(app._currentUserOAuthConnectionCache, [session, id, scopeString || "", options?.or === "redirect"], "user.useConnectedAccount()");
|
|
683
|
+
return (0, import_common3.useAsyncCache)(app._currentUserOAuthConnectionCache, [session, id, scopeString || "", options?.or === "redirect"], "user.useConnectedAccount()");
|
|
801
684
|
}
|
|
802
685
|
return {
|
|
803
686
|
setDisplayName(displayName) {
|
|
@@ -826,11 +709,11 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
826
709
|
return teams.map((crud2) => app._clientTeamFromCrud(crud2, session));
|
|
827
710
|
},
|
|
828
711
|
useTeams() {
|
|
829
|
-
const teams = useAsyncCache(app._currentUserTeamsCache, [session], "user.useTeams()");
|
|
712
|
+
const teams = (0, import_common3.useAsyncCache)(app._currentUserTeamsCache, [session], "user.useTeams()");
|
|
830
713
|
return (0, import_react2.useMemo)(() => teams.map((crud2) => app._clientTeamFromCrud(crud2, session)), [teams]);
|
|
831
714
|
},
|
|
832
715
|
async createTeam(data) {
|
|
833
|
-
const crud2 = await app._interface.createClientTeam(teamCreateOptionsToCrud(data, "me"), session);
|
|
716
|
+
const crud2 = await app._interface.createClientTeam((0, import_teams.teamCreateOptionsToCrud)(data, "me"), session);
|
|
834
717
|
await app._currentUserTeamsCache.refresh([session]);
|
|
835
718
|
return app._clientTeamFromCrud(crud2, session);
|
|
836
719
|
},
|
|
@@ -844,7 +727,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
844
727
|
},
|
|
845
728
|
usePermissions(scope, options) {
|
|
846
729
|
const recursive = options?.recursive ?? true;
|
|
847
|
-
const permissions = useAsyncCache(app._currentUserPermissionsCache, [session, scope.id, recursive], "user.usePermissions()");
|
|
730
|
+
const permissions = (0, import_common3.useAsyncCache)(app._currentUserPermissionsCache, [session, scope.id, recursive], "user.usePermissions()");
|
|
848
731
|
return (0, import_react2.useMemo)(() => permissions.map((crud2) => app._clientTeamPermissionFromCrud(crud2)), [permissions]);
|
|
849
732
|
},
|
|
850
733
|
usePermission(scope, permissionId) {
|
|
@@ -886,7 +769,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
886
769
|
return app._editableTeamProfileFromCrud(result, session);
|
|
887
770
|
},
|
|
888
771
|
useTeamProfile(team) {
|
|
889
|
-
const result = useAsyncCache(app._currentUserTeamProfileCache, [session, team.id], "user.useTeamProfile()");
|
|
772
|
+
const result = (0, import_common3.useAsyncCache)(app._currentUserTeamProfileCache, [session, team.id], "user.useTeamProfile()");
|
|
890
773
|
return app._editableTeamProfileFromCrud(result, session);
|
|
891
774
|
},
|
|
892
775
|
async delete() {
|
|
@@ -898,11 +781,11 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
898
781
|
return result.map((crud2) => app._clientContactChannelFromCrud(crud2, session));
|
|
899
782
|
},
|
|
900
783
|
useContactChannels() {
|
|
901
|
-
const result = useAsyncCache(app._clientContactChannelsCache, [session], "user.useContactChannels()");
|
|
784
|
+
const result = (0, import_common3.useAsyncCache)(app._clientContactChannelsCache, [session], "user.useContactChannels()");
|
|
902
785
|
return result.map((crud2) => app._clientContactChannelFromCrud(crud2, session));
|
|
903
786
|
},
|
|
904
787
|
async createContactChannel(data) {
|
|
905
|
-
const crud2 = await app._interface.createClientContactChannel(contactChannelCreateOptionsToCrud("me", data), session);
|
|
788
|
+
const crud2 = await app._interface.createClientContactChannel((0, import_contact_channels.contactChannelCreateOptionsToCrud)("me", data), session);
|
|
906
789
|
await app._clientContactChannelsCache.refresh([session]);
|
|
907
790
|
return app._clientContactChannelFromCrud(crud2, session);
|
|
908
791
|
}
|
|
@@ -935,7 +818,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
935
818
|
}
|
|
936
819
|
_getOwnedAdminApp(forProjectId, session) {
|
|
937
820
|
if (!this._ownedAdminApps.has([session, forProjectId])) {
|
|
938
|
-
this._ownedAdminApps.set([session, forProjectId], new
|
|
821
|
+
this._ownedAdminApps.set([session, forProjectId], new __StackClientAppImplIncomplete.LazyStackAdminAppImpl.value({
|
|
939
822
|
baseUrl: this._interface.options.getBaseUrl(),
|
|
940
823
|
projectId: forProjectId,
|
|
941
824
|
tokenStore: null,
|
|
@@ -952,7 +835,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
952
835
|
return (0, import_urls.isRelative)(url);
|
|
953
836
|
}
|
|
954
837
|
get urls() {
|
|
955
|
-
return getUrls(this._urlOptions);
|
|
838
|
+
return (0, import_common2.getUrls)(this._urlOptions);
|
|
956
839
|
}
|
|
957
840
|
async _getCurrentUrl() {
|
|
958
841
|
if (this._redirectMethod === "none") {
|
|
@@ -980,9 +863,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
980
863
|
if (typeof this._redirectMethod === "object") {
|
|
981
864
|
return this._redirectMethod.useNavigate();
|
|
982
865
|
} else if (this._redirectMethod === "window") {
|
|
983
|
-
return () => window.location.assign;
|
|
866
|
+
return (to) => window.location.assign(to);
|
|
984
867
|
} else if (this._redirectMethod === "nextjs") {
|
|
985
|
-
return NextNavigation.useRouter().push;
|
|
868
|
+
return (to) => NextNavigation.useRouter().push(to);
|
|
986
869
|
} else {
|
|
987
870
|
return (to) => {
|
|
988
871
|
};
|
|
@@ -1153,7 +1036,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1153
1036
|
useUser(options) {
|
|
1154
1037
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1155
1038
|
const session = this._useSession(options?.tokenStore);
|
|
1156
|
-
const crud = useAsyncCache(this._currentUserCache, [session], "useUser()");
|
|
1039
|
+
const crud = (0, import_common3.useAsyncCache)(this._currentUserCache, [session], "useUser()");
|
|
1157
1040
|
if (crud === null) {
|
|
1158
1041
|
switch (options?.or) {
|
|
1159
1042
|
case "redirect": {
|
|
@@ -1174,7 +1057,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1174
1057
|
}, [crud, session, options?.or]);
|
|
1175
1058
|
}
|
|
1176
1059
|
async _updateClientUser(update, session) {
|
|
1177
|
-
const res = await this._interface.updateClientUser(userUpdateOptionsToCrud(update), session);
|
|
1060
|
+
const res = await this._interface.updateClientUser((0, import_users.userUpdateOptionsToCrud)(update), session);
|
|
1178
1061
|
await this._refreshUser(session);
|
|
1179
1062
|
return res;
|
|
1180
1063
|
}
|
|
@@ -1249,7 +1132,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1249
1132
|
async signUpWithCredential(options) {
|
|
1250
1133
|
this._ensurePersistentTokenStore();
|
|
1251
1134
|
const session = await this._getSession();
|
|
1252
|
-
const emailVerificationRedirectUrl = (0, import_url.constructRedirectUrl)(this.urls.emailVerification);
|
|
1135
|
+
const emailVerificationRedirectUrl = options.verificationCallbackUrl ?? (0, import_url.constructRedirectUrl)(this.urls.emailVerification);
|
|
1253
1136
|
const result = await this._interface.signUpWithCredential(
|
|
1254
1137
|
options.email,
|
|
1255
1138
|
options.password,
|
|
@@ -1378,7 +1261,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1378
1261
|
return this._clientProjectFromCrud(crud);
|
|
1379
1262
|
}
|
|
1380
1263
|
useProject() {
|
|
1381
|
-
const crud = useAsyncCache(this._currentProjectCache, [], "useProject()");
|
|
1264
|
+
const crud = (0, import_common3.useAsyncCache)(this._currentProjectCache, [], "useProject()");
|
|
1382
1265
|
return (0, import_react2.useMemo)(() => this._clientProjectFromCrud(crud), [crud]);
|
|
1383
1266
|
}
|
|
1384
1267
|
async _listOwnedProjects(session) {
|
|
@@ -1391,7 +1274,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1391
1274
|
}
|
|
1392
1275
|
_useOwnedProjects(session) {
|
|
1393
1276
|
this._ensureInternalProject();
|
|
1394
|
-
const projects = useAsyncCache(this._ownedProjectsCache, [session], "useOwnedProjects()");
|
|
1277
|
+
const projects = (0, import_common3.useAsyncCache)(this._ownedProjectsCache, [session], "useOwnedProjects()");
|
|
1395
1278
|
return (0, import_react2.useMemo)(() => projects.map((j) => this._getOwnedAdminApp(j.id, session)._adminOwnedProjectFromCrud(
|
|
1396
1279
|
j,
|
|
1397
1280
|
() => this._refreshOwnedProjects(session)
|
|
@@ -1399,7 +1282,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1399
1282
|
}
|
|
1400
1283
|
async _createProject(session, newProject) {
|
|
1401
1284
|
this._ensureInternalProject();
|
|
1402
|
-
const crud = await this._interface.createProject(adminProjectCreateOptionsToCrud(newProject), session);
|
|
1285
|
+
const crud = await this._interface.createProject((0, import_projects.adminProjectCreateOptionsToCrud)(newProject), session);
|
|
1403
1286
|
const res = this._getOwnedAdminApp(crud.id, session)._adminOwnedProjectFromCrud(
|
|
1404
1287
|
crud,
|
|
1405
1288
|
() => this._refreshOwnedProjects(session)
|
|
@@ -1421,7 +1304,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1421
1304
|
async _refreshOwnedProjects(session) {
|
|
1422
1305
|
await this._ownedProjectsCache.refresh([session]);
|
|
1423
1306
|
}
|
|
1424
|
-
static get [stackAppInternalsSymbol]() {
|
|
1307
|
+
static get [import_common.stackAppInternalsSymbol]() {
|
|
1425
1308
|
return {
|
|
1426
1309
|
fromClientJson: (json) => {
|
|
1427
1310
|
const providedCheckString = JSON.stringify((0, import_objects.omit)(json, [
|
|
@@ -1435,14 +1318,14 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1435
1318
|
}
|
|
1436
1319
|
return clientApp;
|
|
1437
1320
|
}
|
|
1438
|
-
return new
|
|
1321
|
+
return new __StackClientAppImplIncomplete({
|
|
1439
1322
|
...json,
|
|
1440
1323
|
checkString: providedCheckString
|
|
1441
1324
|
});
|
|
1442
1325
|
}
|
|
1443
1326
|
};
|
|
1444
1327
|
}
|
|
1445
|
-
get [stackAppInternalsSymbol]() {
|
|
1328
|
+
get [import_common.stackAppInternalsSymbol]() {
|
|
1446
1329
|
return {
|
|
1447
1330
|
toClientJson: () => {
|
|
1448
1331
|
if (!("publishableClientKey" in this._interface.options)) {
|
|
@@ -1473,977 +1356,17 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1473
1356
|
};
|
|
1474
1357
|
}
|
|
1475
1358
|
};
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
getBaseUrl: () => getBaseUrl(options.baseUrl),
|
|
1486
|
-
projectId: options.projectId ?? getDefaultProjectId(),
|
|
1487
|
-
clientVersion,
|
|
1488
|
-
publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),
|
|
1489
|
-
secretServerKey: options.secretServerKey ?? getDefaultSecretServerKey()
|
|
1490
|
-
}),
|
|
1491
|
-
baseUrl: options.baseUrl,
|
|
1492
|
-
projectId: options.projectId,
|
|
1493
|
-
publishableClientKey: options.publishableClientKey,
|
|
1494
|
-
tokenStore: options.tokenStore,
|
|
1495
|
-
urls: options.urls ?? {},
|
|
1496
|
-
oauthScopesOnSignIn: options.oauthScopesOnSignIn ?? {},
|
|
1497
|
-
redirectMethod: options.redirectMethod
|
|
1498
|
-
});
|
|
1499
|
-
// TODO override the client user cache to use the server user cache, so we save some requests
|
|
1500
|
-
this._currentServerUserCache = createCacheBySession(async (session) => {
|
|
1501
|
-
if (session.isKnownToBeInvalid()) {
|
|
1502
|
-
return null;
|
|
1503
|
-
}
|
|
1504
|
-
return await this._interface.getServerUserByToken(session);
|
|
1505
|
-
});
|
|
1506
|
-
this._serverUsersCache = createCache(async ([cursor, limit, orderBy, desc, query]) => {
|
|
1507
|
-
return await this._interface.listServerUsers({ cursor, limit, orderBy, desc, query });
|
|
1508
|
-
});
|
|
1509
|
-
this._serverUserCache = createCache(async ([userId]) => {
|
|
1510
|
-
const user = await this._interface.getServerUserById(userId);
|
|
1511
|
-
return import_results.Result.or(user, null);
|
|
1512
|
-
});
|
|
1513
|
-
this._serverTeamsCache = createCache(async ([userId]) => {
|
|
1514
|
-
return await this._interface.listServerTeams({ userId });
|
|
1515
|
-
});
|
|
1516
|
-
this._serverTeamUserPermissionsCache = createCache(async ([teamId, userId, recursive]) => {
|
|
1517
|
-
return await this._interface.listServerTeamPermissions({ teamId, userId, recursive }, null);
|
|
1518
|
-
});
|
|
1519
|
-
this._serverUserOAuthConnectionAccessTokensCache = createCache(
|
|
1520
|
-
async ([userId, providerId, scope]) => {
|
|
1521
|
-
try {
|
|
1522
|
-
const result = await this._interface.createServerProviderAccessToken(userId, providerId, scope || "");
|
|
1523
|
-
return { accessToken: result.access_token };
|
|
1524
|
-
} catch (err) {
|
|
1525
|
-
if (!(err instanceof import_stack_shared.KnownErrors.OAuthConnectionDoesNotHaveRequiredScope || err instanceof import_stack_shared.KnownErrors.OAuthConnectionNotConnectedToUser)) {
|
|
1526
|
-
throw err;
|
|
1527
|
-
}
|
|
1528
|
-
}
|
|
1529
|
-
return null;
|
|
1530
|
-
}
|
|
1531
|
-
);
|
|
1532
|
-
this._serverUserOAuthConnectionCache = createCache(
|
|
1533
|
-
async ([userId, providerId, scope, redirect]) => {
|
|
1534
|
-
return await this._getUserOAuthConnectionCacheFn({
|
|
1535
|
-
getUser: async () => import_results.Result.orThrow(await this._serverUserCache.getOrWait([userId], "write-only")),
|
|
1536
|
-
getOrWaitOAuthToken: async () => import_results.Result.orThrow(await this._serverUserOAuthConnectionAccessTokensCache.getOrWait([userId, providerId, scope || ""], "write-only")),
|
|
1537
|
-
useOAuthToken: () => useAsyncCache(this._serverUserOAuthConnectionAccessTokensCache, [userId, providerId, scope || ""], "user.useConnectedAccount()"),
|
|
1538
|
-
providerId,
|
|
1539
|
-
scope,
|
|
1540
|
-
redirect,
|
|
1541
|
-
session: null
|
|
1542
|
-
});
|
|
1543
|
-
}
|
|
1544
|
-
);
|
|
1545
|
-
this._serverTeamMemberProfilesCache = createCache(
|
|
1546
|
-
async ([teamId]) => {
|
|
1547
|
-
return await this._interface.listServerTeamMemberProfiles({ teamId });
|
|
1548
|
-
}
|
|
1549
|
-
);
|
|
1550
|
-
this._serverTeamInvitationsCache = createCache(
|
|
1551
|
-
async ([teamId]) => {
|
|
1552
|
-
return await this._interface.listServerTeamInvitations({ teamId });
|
|
1553
|
-
}
|
|
1554
|
-
);
|
|
1555
|
-
this._serverUserTeamProfileCache = createCache(
|
|
1556
|
-
async ([teamId, userId]) => {
|
|
1557
|
-
return await this._interface.getServerTeamMemberProfile({ teamId, userId });
|
|
1558
|
-
}
|
|
1559
|
-
);
|
|
1560
|
-
this._serverContactChannelsCache = createCache(
|
|
1561
|
-
async ([userId]) => {
|
|
1562
|
-
return await this._interface.listServerContactChannels(userId);
|
|
1563
|
-
}
|
|
1564
|
-
);
|
|
1565
|
-
}
|
|
1566
|
-
async _updateServerUser(userId, update) {
|
|
1567
|
-
const result = await this._interface.updateServerUser(userId, serverUserUpdateOptionsToCrud(update));
|
|
1568
|
-
await this._refreshUsers();
|
|
1569
|
-
return result;
|
|
1570
|
-
}
|
|
1571
|
-
_serverEditableTeamProfileFromCrud(crud) {
|
|
1572
|
-
const app = this;
|
|
1573
|
-
return {
|
|
1574
|
-
displayName: crud.display_name,
|
|
1575
|
-
profileImageUrl: crud.profile_image_url,
|
|
1576
|
-
async update(update) {
|
|
1577
|
-
await app._interface.updateServerTeamMemberProfile({
|
|
1578
|
-
teamId: crud.team_id,
|
|
1579
|
-
userId: crud.user_id,
|
|
1580
|
-
profile: {
|
|
1581
|
-
display_name: update.displayName,
|
|
1582
|
-
profile_image_url: update.profileImageUrl
|
|
1583
|
-
}
|
|
1584
|
-
});
|
|
1585
|
-
await app._serverUserTeamProfileCache.refresh([crud.team_id, crud.user_id]);
|
|
1586
|
-
}
|
|
1587
|
-
};
|
|
1588
|
-
}
|
|
1589
|
-
_serverContactChannelFromCrud(userId, crud) {
|
|
1590
|
-
const app = this;
|
|
1591
|
-
return {
|
|
1592
|
-
id: crud.id,
|
|
1593
|
-
value: crud.value,
|
|
1594
|
-
type: crud.type,
|
|
1595
|
-
isVerified: crud.is_verified,
|
|
1596
|
-
isPrimary: crud.is_primary,
|
|
1597
|
-
usedForAuth: crud.used_for_auth,
|
|
1598
|
-
async sendVerificationEmail(options) {
|
|
1599
|
-
if (!options?.callbackUrl && !await app._getCurrentUrl()) {
|
|
1600
|
-
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: ... })`");
|
|
1601
|
-
}
|
|
1602
|
-
await app._interface.sendServerContactChannelVerificationEmail(userId, crud.id, options?.callbackUrl ?? (0, import_url.constructRedirectUrl)(app.urls.emailVerification));
|
|
1603
|
-
},
|
|
1604
|
-
async update(data) {
|
|
1605
|
-
await app._interface.updateServerContactChannel(userId, crud.id, serverContactChannelUpdateOptionsToCrud(data));
|
|
1606
|
-
},
|
|
1607
|
-
async delete() {
|
|
1608
|
-
await app._interface.deleteServerContactChannel(userId, crud.id);
|
|
1609
|
-
}
|
|
1610
|
-
};
|
|
1611
|
-
}
|
|
1612
|
-
_serverUserFromCrud(crud) {
|
|
1613
|
-
const app = this;
|
|
1614
|
-
async function getConnectedAccount(id, options) {
|
|
1615
|
-
const scopeString = options?.scopes?.join(" ");
|
|
1616
|
-
return import_results.Result.orThrow(await app._serverUserOAuthConnectionCache.getOrWait([crud.id, id, scopeString || "", options?.or === "redirect"], "write-only"));
|
|
1617
|
-
}
|
|
1618
|
-
function useConnectedAccount(id, options) {
|
|
1619
|
-
const scopeString = options?.scopes?.join(" ");
|
|
1620
|
-
return useAsyncCache(app._serverUserOAuthConnectionCache, [crud.id, id, scopeString || "", options?.or === "redirect"], "user.useConnectedAccount()");
|
|
1621
|
-
}
|
|
1622
|
-
return {
|
|
1623
|
-
...super._createBaseUser(crud),
|
|
1624
|
-
lastActiveAt: new Date(crud.last_active_at_millis),
|
|
1625
|
-
serverMetadata: crud.server_metadata,
|
|
1626
|
-
async setPrimaryEmail(email, options) {
|
|
1627
|
-
await app._updateServerUser(crud.id, { primaryEmail: email, primaryEmailVerified: options?.verified });
|
|
1628
|
-
},
|
|
1629
|
-
async grantPermission(scope, permissionId) {
|
|
1630
|
-
await app._interface.grantServerTeamUserPermission(scope.id, crud.id, permissionId);
|
|
1631
|
-
for (const recursive of [true, false]) {
|
|
1632
|
-
await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);
|
|
1633
|
-
}
|
|
1634
|
-
},
|
|
1635
|
-
async revokePermission(scope, permissionId) {
|
|
1636
|
-
await app._interface.revokeServerTeamUserPermission(scope.id, crud.id, permissionId);
|
|
1637
|
-
for (const recursive of [true, false]) {
|
|
1638
|
-
await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);
|
|
1639
|
-
}
|
|
1640
|
-
},
|
|
1641
|
-
async delete() {
|
|
1642
|
-
const res = await app._interface.deleteServerServerUser(crud.id);
|
|
1643
|
-
await app._refreshUsers();
|
|
1644
|
-
return res;
|
|
1645
|
-
},
|
|
1646
|
-
async createSession(options) {
|
|
1647
|
-
const tokens = await app._interface.createServerUserSession(crud.id, options.expiresInMillis ?? 1e3 * 60 * 60 * 24 * 365);
|
|
1648
|
-
return {
|
|
1649
|
-
async getTokens() {
|
|
1650
|
-
return tokens;
|
|
1651
|
-
}
|
|
1652
|
-
};
|
|
1653
|
-
},
|
|
1654
|
-
async setDisplayName(displayName) {
|
|
1655
|
-
return await this.update({ displayName });
|
|
1656
|
-
},
|
|
1657
|
-
async setClientMetadata(metadata) {
|
|
1658
|
-
return await this.update({ clientMetadata: metadata });
|
|
1659
|
-
},
|
|
1660
|
-
async setClientReadOnlyMetadata(metadata) {
|
|
1661
|
-
return await this.update({ clientReadOnlyMetadata: metadata });
|
|
1662
|
-
},
|
|
1663
|
-
async setServerMetadata(metadata) {
|
|
1664
|
-
return await this.update({ serverMetadata: metadata });
|
|
1665
|
-
},
|
|
1666
|
-
async setSelectedTeam(team) {
|
|
1667
|
-
return await this.update({ selectedTeamId: team?.id ?? null });
|
|
1668
|
-
},
|
|
1669
|
-
getConnectedAccount,
|
|
1670
|
-
useConnectedAccount,
|
|
1671
|
-
selectedTeam: crud.selected_team ? app._serverTeamFromCrud(crud.selected_team) : null,
|
|
1672
|
-
async getTeam(teamId) {
|
|
1673
|
-
const teams = await this.listTeams();
|
|
1674
|
-
return teams.find((t) => t.id === teamId) ?? null;
|
|
1675
|
-
},
|
|
1676
|
-
useTeam(teamId) {
|
|
1677
|
-
const teams = this.useTeams();
|
|
1678
|
-
return (0, import_react2.useMemo)(() => {
|
|
1679
|
-
return teams.find((t) => t.id === teamId) ?? null;
|
|
1680
|
-
}, [teams, teamId]);
|
|
1681
|
-
},
|
|
1682
|
-
async listTeams() {
|
|
1683
|
-
const teams = import_results.Result.orThrow(await app._serverTeamsCache.getOrWait([crud.id], "write-only"));
|
|
1684
|
-
return teams.map((t) => app._serverTeamFromCrud(t));
|
|
1685
|
-
},
|
|
1686
|
-
useTeams() {
|
|
1687
|
-
const teams = useAsyncCache(app._serverTeamsCache, [crud.id], "user.useTeams()");
|
|
1688
|
-
return (0, import_react2.useMemo)(() => teams.map((t) => app._serverTeamFromCrud(t)), [teams]);
|
|
1689
|
-
},
|
|
1690
|
-
createTeam: async (data) => {
|
|
1691
|
-
const team = await app._interface.createServerTeam(serverTeamCreateOptionsToCrud({
|
|
1692
|
-
creatorUserId: crud.id,
|
|
1693
|
-
...data
|
|
1694
|
-
}));
|
|
1695
|
-
await app._serverTeamsCache.refresh([void 0]);
|
|
1696
|
-
return app._serverTeamFromCrud(team);
|
|
1697
|
-
},
|
|
1698
|
-
leaveTeam: async (team) => {
|
|
1699
|
-
await app._interface.leaveServerTeam({ teamId: team.id, userId: crud.id });
|
|
1700
|
-
},
|
|
1701
|
-
async listPermissions(scope, options) {
|
|
1702
|
-
const recursive = options?.recursive ?? true;
|
|
1703
|
-
const permissions = import_results.Result.orThrow(await app._serverTeamUserPermissionsCache.getOrWait([scope.id, crud.id, recursive], "write-only"));
|
|
1704
|
-
return permissions.map((crud2) => app._serverPermissionFromCrud(crud2));
|
|
1705
|
-
},
|
|
1706
|
-
usePermissions(scope, options) {
|
|
1707
|
-
const recursive = options?.recursive ?? true;
|
|
1708
|
-
const permissions = useAsyncCache(app._serverTeamUserPermissionsCache, [scope.id, crud.id, recursive], "user.usePermissions()");
|
|
1709
|
-
return (0, import_react2.useMemo)(() => permissions.map((crud2) => app._serverPermissionFromCrud(crud2)), [permissions]);
|
|
1710
|
-
},
|
|
1711
|
-
async getPermission(scope, permissionId) {
|
|
1712
|
-
const permissions = await this.listPermissions(scope);
|
|
1713
|
-
return permissions.find((p) => p.id === permissionId) ?? null;
|
|
1714
|
-
},
|
|
1715
|
-
usePermission(scope, permissionId) {
|
|
1716
|
-
const permissions = this.usePermissions(scope);
|
|
1717
|
-
return (0, import_react2.useMemo)(() => permissions.find((p) => p.id === permissionId) ?? null, [permissions, permissionId]);
|
|
1718
|
-
},
|
|
1719
|
-
async hasPermission(scope, permissionId) {
|
|
1720
|
-
return await this.getPermission(scope, permissionId) !== null;
|
|
1721
|
-
},
|
|
1722
|
-
async update(update) {
|
|
1723
|
-
await app._updateServerUser(crud.id, update);
|
|
1724
|
-
},
|
|
1725
|
-
async sendVerificationEmail() {
|
|
1726
|
-
return await app._checkFeatureSupport("sendVerificationEmail() on ServerUser", {});
|
|
1727
|
-
},
|
|
1728
|
-
async updatePassword(options) {
|
|
1729
|
-
const result = await this.update({ password: options.newPassword });
|
|
1730
|
-
await app._serverUserCache.refresh([crud.id]);
|
|
1731
|
-
return result;
|
|
1732
|
-
},
|
|
1733
|
-
async setPassword(options) {
|
|
1734
|
-
const result = await this.update(options);
|
|
1735
|
-
await app._serverUserCache.refresh([crud.id]);
|
|
1736
|
-
return result;
|
|
1737
|
-
},
|
|
1738
|
-
async getTeamProfile(team) {
|
|
1739
|
-
const result = import_results.Result.orThrow(await app._serverUserTeamProfileCache.getOrWait([team.id, crud.id], "write-only"));
|
|
1740
|
-
return app._serverEditableTeamProfileFromCrud(result);
|
|
1741
|
-
},
|
|
1742
|
-
useTeamProfile(team) {
|
|
1743
|
-
const result = useAsyncCache(app._serverUserTeamProfileCache, [team.id, crud.id], "user.useTeamProfile()");
|
|
1744
|
-
return (0, import_react2.useMemo)(() => app._serverEditableTeamProfileFromCrud(result), [result]);
|
|
1745
|
-
},
|
|
1746
|
-
async listContactChannels() {
|
|
1747
|
-
const result = import_results.Result.orThrow(await app._serverContactChannelsCache.getOrWait([crud.id], "write-only"));
|
|
1748
|
-
return result.map((data) => app._serverContactChannelFromCrud(crud.id, data));
|
|
1749
|
-
},
|
|
1750
|
-
useContactChannels() {
|
|
1751
|
-
const result = useAsyncCache(app._serverContactChannelsCache, [crud.id], "user.useContactChannels()");
|
|
1752
|
-
return (0, import_react2.useMemo)(() => result.map((data) => app._serverContactChannelFromCrud(crud.id, data)), [result]);
|
|
1753
|
-
},
|
|
1754
|
-
createContactChannel: async (data) => {
|
|
1755
|
-
const contactChannel = await app._interface.createServerContactChannel(serverContactChannelCreateOptionsToCrud(crud.id, data));
|
|
1756
|
-
await app._serverContactChannelsCache.refresh([crud.id]);
|
|
1757
|
-
return app._serverContactChannelFromCrud(crud.id, contactChannel);
|
|
1758
|
-
}
|
|
1759
|
-
};
|
|
1760
|
-
}
|
|
1761
|
-
_serverTeamUserFromCrud(crud) {
|
|
1762
|
-
return {
|
|
1763
|
-
...this._serverUserFromCrud(crud.user),
|
|
1764
|
-
teamProfile: {
|
|
1765
|
-
displayName: crud.display_name,
|
|
1766
|
-
profileImageUrl: crud.profile_image_url
|
|
1767
|
-
}
|
|
1768
|
-
};
|
|
1769
|
-
}
|
|
1770
|
-
_serverTeamInvitationFromCrud(crud) {
|
|
1771
|
-
return {
|
|
1772
|
-
id: crud.id,
|
|
1773
|
-
recipientEmail: crud.recipient_email,
|
|
1774
|
-
expiresAt: new Date(crud.expires_at_millis),
|
|
1775
|
-
revoke: async () => {
|
|
1776
|
-
await this._interface.revokeServerTeamInvitation(crud.id, crud.team_id);
|
|
1777
|
-
}
|
|
1778
|
-
};
|
|
1779
|
-
}
|
|
1780
|
-
_currentUserFromCrud(crud, session) {
|
|
1781
|
-
const app = this;
|
|
1782
|
-
const currentUser = {
|
|
1783
|
-
...this._serverUserFromCrud(crud),
|
|
1784
|
-
...this._createAuth(session),
|
|
1785
|
-
...this._isInternalProject() ? this._createInternalUserExtra(session) : {}
|
|
1786
|
-
};
|
|
1787
|
-
Object.freeze(currentUser);
|
|
1788
|
-
return currentUser;
|
|
1789
|
-
}
|
|
1790
|
-
_serverTeamFromCrud(crud) {
|
|
1791
|
-
const app = this;
|
|
1792
|
-
return {
|
|
1793
|
-
id: crud.id,
|
|
1794
|
-
displayName: crud.display_name,
|
|
1795
|
-
profileImageUrl: crud.profile_image_url,
|
|
1796
|
-
createdAt: new Date(crud.created_at_millis),
|
|
1797
|
-
clientMetadata: crud.client_metadata,
|
|
1798
|
-
clientReadOnlyMetadata: crud.client_read_only_metadata,
|
|
1799
|
-
serverMetadata: crud.server_metadata,
|
|
1800
|
-
async update(update) {
|
|
1801
|
-
await app._interface.updateServerTeam(crud.id, serverTeamUpdateOptionsToCrud(update));
|
|
1802
|
-
await app._serverTeamsCache.refresh([void 0]);
|
|
1803
|
-
},
|
|
1804
|
-
async delete() {
|
|
1805
|
-
await app._interface.deleteServerTeam(crud.id);
|
|
1806
|
-
await app._serverTeamsCache.refresh([void 0]);
|
|
1807
|
-
},
|
|
1808
|
-
async listUsers() {
|
|
1809
|
-
const result = import_results.Result.orThrow(await app._serverTeamMemberProfilesCache.getOrWait([crud.id], "write-only"));
|
|
1810
|
-
return result.map((u) => app._serverTeamUserFromCrud(u));
|
|
1811
|
-
},
|
|
1812
|
-
useUsers() {
|
|
1813
|
-
const result = useAsyncCache(app._serverTeamMemberProfilesCache, [crud.id], "team.useUsers()");
|
|
1814
|
-
return (0, import_react2.useMemo)(() => result.map((u) => app._serverTeamUserFromCrud(u)), [result]);
|
|
1815
|
-
},
|
|
1816
|
-
async addUser(userId) {
|
|
1817
|
-
await app._interface.addServerUserToTeam({
|
|
1818
|
-
teamId: crud.id,
|
|
1819
|
-
userId
|
|
1820
|
-
});
|
|
1821
|
-
await app._serverTeamMemberProfilesCache.refresh([crud.id]);
|
|
1822
|
-
},
|
|
1823
|
-
async removeUser(userId) {
|
|
1824
|
-
await app._interface.removeServerUserFromTeam({
|
|
1825
|
-
teamId: crud.id,
|
|
1826
|
-
userId
|
|
1827
|
-
});
|
|
1828
|
-
await app._serverTeamMemberProfilesCache.refresh([crud.id]);
|
|
1829
|
-
},
|
|
1830
|
-
async inviteUser(options) {
|
|
1831
|
-
if (!options.callbackUrl && !await app._getCurrentUrl()) {
|
|
1832
|
-
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: ... })`");
|
|
1833
|
-
}
|
|
1834
|
-
await app._interface.sendServerTeamInvitation({
|
|
1835
|
-
teamId: crud.id,
|
|
1836
|
-
email: options.email,
|
|
1837
|
-
callbackUrl: options.callbackUrl ?? (0, import_url.constructRedirectUrl)(app.urls.teamInvitation)
|
|
1838
|
-
});
|
|
1839
|
-
await app._serverTeamInvitationsCache.refresh([crud.id]);
|
|
1840
|
-
},
|
|
1841
|
-
async listInvitations() {
|
|
1842
|
-
const result = import_results.Result.orThrow(await app._serverTeamInvitationsCache.getOrWait([crud.id], "write-only"));
|
|
1843
|
-
return result.map((crud2) => app._serverTeamInvitationFromCrud(crud2));
|
|
1844
|
-
},
|
|
1845
|
-
useInvitations() {
|
|
1846
|
-
const result = useAsyncCache(app._serverTeamInvitationsCache, [crud.id], "team.useInvitations()");
|
|
1847
|
-
return (0, import_react2.useMemo)(() => result.map((crud2) => app._serverTeamInvitationFromCrud(crud2)), [result]);
|
|
1848
|
-
}
|
|
1849
|
-
};
|
|
1850
|
-
}
|
|
1851
|
-
async createUser(options) {
|
|
1852
|
-
const crud = await this._interface.createServerUser(serverUserCreateOptionsToCrud(options));
|
|
1853
|
-
await this._refreshUsers();
|
|
1854
|
-
return this._serverUserFromCrud(crud);
|
|
1855
|
-
}
|
|
1856
|
-
async getUser(options) {
|
|
1857
|
-
if (typeof options === "string") {
|
|
1858
|
-
return await this.getServerUserById(options);
|
|
1859
|
-
} else {
|
|
1860
|
-
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1861
|
-
const session = await this._getSession(options?.tokenStore);
|
|
1862
|
-
const crud = import_results.Result.orThrow(await this._currentServerUserCache.getOrWait([session], "write-only"));
|
|
1863
|
-
if (crud === null) {
|
|
1864
|
-
switch (options?.or) {
|
|
1865
|
-
case "redirect": {
|
|
1866
|
-
await this.redirectToSignIn({ replace: true });
|
|
1867
|
-
break;
|
|
1868
|
-
}
|
|
1869
|
-
case "throw": {
|
|
1870
|
-
throw new Error("User is not signed in but getUser was called with { or: 'throw' }");
|
|
1871
|
-
}
|
|
1872
|
-
default: {
|
|
1873
|
-
return null;
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
}
|
|
1877
|
-
return crud && this._currentUserFromCrud(crud, session);
|
|
1878
|
-
}
|
|
1879
|
-
}
|
|
1880
|
-
async getServerUser() {
|
|
1881
|
-
console.warn("stackServerApp.getServerUser is deprecated; use stackServerApp.getUser instead");
|
|
1882
|
-
return await this.getUser();
|
|
1883
|
-
}
|
|
1884
|
-
async getServerUserById(userId) {
|
|
1885
|
-
const crud = import_results.Result.orThrow(await this._serverUserCache.getOrWait([userId], "write-only"));
|
|
1886
|
-
return crud && this._serverUserFromCrud(crud);
|
|
1887
|
-
}
|
|
1888
|
-
useUser(options) {
|
|
1889
|
-
if (typeof options === "string") {
|
|
1890
|
-
return this.useUserById(options);
|
|
1891
|
-
} else {
|
|
1892
|
-
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1893
|
-
const session = this._useSession(options?.tokenStore);
|
|
1894
|
-
const crud = useAsyncCache(this._currentServerUserCache, [session], "useUser()");
|
|
1895
|
-
if (crud === null) {
|
|
1896
|
-
switch (options?.or) {
|
|
1897
|
-
case "redirect": {
|
|
1898
|
-
(0, import_promises.runAsynchronously)(this.redirectToSignIn({ replace: true }));
|
|
1899
|
-
(0, import_react.suspend)();
|
|
1900
|
-
throw new import_errors.StackAssertionError("suspend should never return");
|
|
1901
|
-
}
|
|
1902
|
-
case "throw": {
|
|
1903
|
-
throw new Error("User is not signed in but useUser was called with { or: 'throw' }");
|
|
1904
|
-
}
|
|
1905
|
-
case void 0:
|
|
1906
|
-
case "return-null": {
|
|
1907
|
-
}
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1910
|
-
return (0, import_react2.useMemo)(() => {
|
|
1911
|
-
return crud && this._currentUserFromCrud(crud, session);
|
|
1912
|
-
}, [crud, session, options?.or]);
|
|
1913
|
-
}
|
|
1914
|
-
}
|
|
1915
|
-
useUserById(userId) {
|
|
1916
|
-
const crud = useAsyncCache(this._serverUserCache, [userId], "useUserById()");
|
|
1917
|
-
return (0, import_react2.useMemo)(() => {
|
|
1918
|
-
return crud && this._serverUserFromCrud(crud);
|
|
1919
|
-
}, [crud]);
|
|
1920
|
-
}
|
|
1921
|
-
async listUsers(options) {
|
|
1922
|
-
const crud = import_results.Result.orThrow(await this._serverUsersCache.getOrWait([options?.cursor, options?.limit, options?.orderBy, options?.desc, options?.query], "write-only"));
|
|
1923
|
-
const result = crud.items.map((j) => this._serverUserFromCrud(j));
|
|
1924
|
-
result.nextCursor = crud.pagination?.next_cursor ?? null;
|
|
1925
|
-
return result;
|
|
1926
|
-
}
|
|
1927
|
-
useUsers(options) {
|
|
1928
|
-
const crud = useAsyncCache(this._serverUsersCache, [options?.cursor, options?.limit, options?.orderBy, options?.desc, options?.query], "useServerUsers()");
|
|
1929
|
-
const result = crud.items.map((j) => this._serverUserFromCrud(j));
|
|
1930
|
-
result.nextCursor = crud.pagination?.next_cursor ?? null;
|
|
1931
|
-
return result;
|
|
1932
|
-
}
|
|
1933
|
-
_serverPermissionFromCrud(crud) {
|
|
1934
|
-
return {
|
|
1935
|
-
id: crud.id
|
|
1936
|
-
};
|
|
1937
|
-
}
|
|
1938
|
-
_serverTeamPermissionDefinitionFromCrud(crud) {
|
|
1939
|
-
return {
|
|
1940
|
-
id: crud.id,
|
|
1941
|
-
description: crud.description,
|
|
1942
|
-
containedPermissionIds: crud.contained_permission_ids
|
|
1943
|
-
};
|
|
1944
|
-
}
|
|
1945
|
-
async listTeams() {
|
|
1946
|
-
const teams = import_results.Result.orThrow(await this._serverTeamsCache.getOrWait([void 0], "write-only"));
|
|
1947
|
-
return teams.map((t) => this._serverTeamFromCrud(t));
|
|
1948
|
-
}
|
|
1949
|
-
async createTeam(data) {
|
|
1950
|
-
const team = await this._interface.createServerTeam(serverTeamCreateOptionsToCrud(data));
|
|
1951
|
-
await this._serverTeamsCache.refresh([void 0]);
|
|
1952
|
-
return this._serverTeamFromCrud(team);
|
|
1953
|
-
}
|
|
1954
|
-
useTeams() {
|
|
1955
|
-
const teams = useAsyncCache(this._serverTeamsCache, [void 0], "useServerTeams()");
|
|
1956
|
-
return (0, import_react2.useMemo)(() => {
|
|
1957
|
-
return teams.map((t) => this._serverTeamFromCrud(t));
|
|
1958
|
-
}, [teams]);
|
|
1959
|
-
}
|
|
1960
|
-
async getTeam(teamId) {
|
|
1961
|
-
const teams = await this.listTeams();
|
|
1962
|
-
return teams.find((t) => t.id === teamId) ?? null;
|
|
1963
|
-
}
|
|
1964
|
-
useTeam(teamId) {
|
|
1965
|
-
const teams = this.useTeams();
|
|
1966
|
-
return (0, import_react2.useMemo)(() => {
|
|
1967
|
-
return teams.find((t) => t.id === teamId) ?? null;
|
|
1968
|
-
}, [teams, teamId]);
|
|
1969
|
-
}
|
|
1970
|
-
async _refreshSession(session) {
|
|
1971
|
-
await Promise.all([
|
|
1972
|
-
super._refreshUser(session),
|
|
1973
|
-
this._currentServerUserCache.refresh([session])
|
|
1974
|
-
]);
|
|
1975
|
-
}
|
|
1976
|
-
async _refreshUsers() {
|
|
1977
|
-
await Promise.all([
|
|
1978
|
-
super._refreshUsers(),
|
|
1979
|
-
this._serverUserCache.refreshWhere(() => true),
|
|
1980
|
-
this._serverUsersCache.refreshWhere(() => true),
|
|
1981
|
-
this._serverContactChannelsCache.refreshWhere(() => true)
|
|
1982
|
-
]);
|
|
1983
|
-
}
|
|
1984
|
-
};
|
|
1985
|
-
var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
1986
|
-
constructor(options) {
|
|
1987
|
-
super({
|
|
1988
|
-
interface: new import_stack_shared.StackAdminInterface({
|
|
1989
|
-
getBaseUrl: () => getBaseUrl(options.baseUrl),
|
|
1990
|
-
projectId: options.projectId ?? getDefaultProjectId(),
|
|
1991
|
-
clientVersion,
|
|
1992
|
-
..."projectOwnerSession" in options ? {
|
|
1993
|
-
projectOwnerSession: options.projectOwnerSession
|
|
1994
|
-
} : {
|
|
1995
|
-
publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),
|
|
1996
|
-
secretServerKey: options.secretServerKey ?? getDefaultSecretServerKey(),
|
|
1997
|
-
superSecretAdminKey: options.superSecretAdminKey ?? getDefaultSuperSecretAdminKey()
|
|
1998
|
-
}
|
|
1999
|
-
}),
|
|
2000
|
-
baseUrl: options.baseUrl,
|
|
2001
|
-
projectId: options.projectId,
|
|
2002
|
-
tokenStore: options.tokenStore,
|
|
2003
|
-
urls: options.urls,
|
|
2004
|
-
oauthScopesOnSignIn: options.oauthScopesOnSignIn,
|
|
2005
|
-
redirectMethod: options.redirectMethod
|
|
2006
|
-
});
|
|
2007
|
-
this._adminProjectCache = createCache(async () => {
|
|
2008
|
-
return await this._interface.getProject();
|
|
2009
|
-
});
|
|
2010
|
-
this._apiKeysCache = createCache(async () => {
|
|
2011
|
-
return await this._interface.listApiKeys();
|
|
2012
|
-
});
|
|
2013
|
-
this._adminEmailTemplatesCache = createCache(async () => {
|
|
2014
|
-
return await this._interface.listEmailTemplates();
|
|
2015
|
-
});
|
|
2016
|
-
this._adminTeamPermissionDefinitionsCache = createCache(async () => {
|
|
2017
|
-
return await this._interface.listPermissionDefinitions();
|
|
2018
|
-
});
|
|
2019
|
-
this._svixTokenCache = createCache(async () => {
|
|
2020
|
-
return await this._interface.getSvixToken();
|
|
2021
|
-
});
|
|
2022
|
-
this._metricsCache = createCache(async () => {
|
|
2023
|
-
return await this._interface.getMetrics();
|
|
2024
|
-
});
|
|
2025
|
-
}
|
|
2026
|
-
_adminOwnedProjectFromCrud(data, onRefresh) {
|
|
2027
|
-
if (this._tokenStoreInit !== null) {
|
|
2028
|
-
throw new import_errors.StackAssertionError("Owned apps must always have tokenStore === null \u2014 did you not create this project with app._createOwnedApp()?");
|
|
2029
|
-
;
|
|
2030
|
-
}
|
|
2031
|
-
return {
|
|
2032
|
-
...this._adminProjectFromCrud(data, onRefresh),
|
|
2033
|
-
app: this
|
|
2034
|
-
};
|
|
2035
|
-
}
|
|
2036
|
-
_adminProjectFromCrud(data, onRefresh) {
|
|
2037
|
-
if (data.id !== this.projectId) {
|
|
2038
|
-
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})!`);
|
|
2039
|
-
}
|
|
2040
|
-
const app = this;
|
|
2041
|
-
return {
|
|
2042
|
-
id: data.id,
|
|
2043
|
-
displayName: data.display_name,
|
|
2044
|
-
description: data.description,
|
|
2045
|
-
createdAt: new Date(data.created_at_millis),
|
|
2046
|
-
userCount: data.user_count,
|
|
2047
|
-
isProductionMode: data.is_production_mode,
|
|
2048
|
-
config: {
|
|
2049
|
-
id: data.config.id,
|
|
2050
|
-
signUpEnabled: data.config.sign_up_enabled,
|
|
2051
|
-
credentialEnabled: data.config.credential_enabled,
|
|
2052
|
-
magicLinkEnabled: data.config.magic_link_enabled,
|
|
2053
|
-
passkeyEnabled: data.config.passkey_enabled,
|
|
2054
|
-
clientTeamCreationEnabled: data.config.client_team_creation_enabled,
|
|
2055
|
-
clientUserDeletionEnabled: data.config.client_user_deletion_enabled,
|
|
2056
|
-
allowLocalhost: data.config.allow_localhost,
|
|
2057
|
-
oauthProviders: data.config.oauth_providers.map((p) => p.type === "shared" ? {
|
|
2058
|
-
id: p.id,
|
|
2059
|
-
enabled: p.enabled,
|
|
2060
|
-
type: "shared"
|
|
2061
|
-
} : {
|
|
2062
|
-
id: p.id,
|
|
2063
|
-
enabled: p.enabled,
|
|
2064
|
-
type: "standard",
|
|
2065
|
-
clientId: p.client_id ?? (0, import_errors.throwErr)("Client ID is missing"),
|
|
2066
|
-
clientSecret: p.client_secret ?? (0, import_errors.throwErr)("Client secret is missing"),
|
|
2067
|
-
facebookConfigId: p.facebook_config_id,
|
|
2068
|
-
microsoftTenantId: p.microsoft_tenant_id
|
|
2069
|
-
}),
|
|
2070
|
-
emailConfig: data.config.email_config.type === "shared" ? {
|
|
2071
|
-
type: "shared"
|
|
2072
|
-
} : {
|
|
2073
|
-
type: "standard",
|
|
2074
|
-
host: data.config.email_config.host ?? (0, import_errors.throwErr)("Email host is missing"),
|
|
2075
|
-
port: data.config.email_config.port ?? (0, import_errors.throwErr)("Email port is missing"),
|
|
2076
|
-
username: data.config.email_config.username ?? (0, import_errors.throwErr)("Email username is missing"),
|
|
2077
|
-
password: data.config.email_config.password ?? (0, import_errors.throwErr)("Email password is missing"),
|
|
2078
|
-
senderName: data.config.email_config.sender_name ?? (0, import_errors.throwErr)("Email sender name is missing"),
|
|
2079
|
-
senderEmail: data.config.email_config.sender_email ?? (0, import_errors.throwErr)("Email sender email is missing")
|
|
2080
|
-
},
|
|
2081
|
-
domains: data.config.domains.map((d) => ({
|
|
2082
|
-
domain: d.domain,
|
|
2083
|
-
handlerPath: d.handler_path
|
|
2084
|
-
})),
|
|
2085
|
-
createTeamOnSignUp: data.config.create_team_on_sign_up,
|
|
2086
|
-
teamCreatorDefaultPermissions: data.config.team_creator_default_permissions,
|
|
2087
|
-
teamMemberDefaultPermissions: data.config.team_member_default_permissions
|
|
2088
|
-
},
|
|
2089
|
-
async update(update) {
|
|
2090
|
-
await app._interface.updateProject(adminProjectUpdateOptionsToCrud(update));
|
|
2091
|
-
await onRefresh();
|
|
2092
|
-
},
|
|
2093
|
-
async delete() {
|
|
2094
|
-
await app._interface.deleteProject();
|
|
2095
|
-
},
|
|
2096
|
-
async getProductionModeErrors() {
|
|
2097
|
-
return (0, import_production_mode.getProductionModeErrors)(data);
|
|
2098
|
-
},
|
|
2099
|
-
useProductionModeErrors() {
|
|
2100
|
-
return (0, import_production_mode.getProductionModeErrors)(data);
|
|
2101
|
-
}
|
|
2102
|
-
};
|
|
2103
|
-
}
|
|
2104
|
-
_adminEmailTemplateFromCrud(data) {
|
|
2105
|
-
return {
|
|
2106
|
-
type: data.type,
|
|
2107
|
-
subject: data.subject,
|
|
2108
|
-
content: data.content,
|
|
2109
|
-
isDefault: data.is_default
|
|
2110
|
-
};
|
|
2111
|
-
}
|
|
2112
|
-
async getProject() {
|
|
2113
|
-
return this._adminProjectFromCrud(
|
|
2114
|
-
import_results.Result.orThrow(await this._adminProjectCache.getOrWait([], "write-only")),
|
|
2115
|
-
() => this._refreshProject()
|
|
2116
|
-
);
|
|
2117
|
-
}
|
|
2118
|
-
useProject() {
|
|
2119
|
-
const crud = useAsyncCache(this._adminProjectCache, [], "useProjectAdmin()");
|
|
2120
|
-
return (0, import_react2.useMemo)(() => this._adminProjectFromCrud(
|
|
2121
|
-
crud,
|
|
2122
|
-
() => this._refreshProject()
|
|
2123
|
-
), [crud]);
|
|
2124
|
-
}
|
|
2125
|
-
_createApiKeyBaseFromCrud(data) {
|
|
2126
|
-
const app = this;
|
|
2127
|
-
return {
|
|
2128
|
-
id: data.id,
|
|
2129
|
-
description: data.description,
|
|
2130
|
-
expiresAt: new Date(data.expires_at_millis),
|
|
2131
|
-
manuallyRevokedAt: data.manually_revoked_at_millis ? new Date(data.manually_revoked_at_millis) : null,
|
|
2132
|
-
createdAt: new Date(data.created_at_millis),
|
|
2133
|
-
isValid() {
|
|
2134
|
-
return this.whyInvalid() === null;
|
|
2135
|
-
},
|
|
2136
|
-
whyInvalid() {
|
|
2137
|
-
if (this.expiresAt.getTime() < Date.now()) return "expired";
|
|
2138
|
-
if (this.manuallyRevokedAt) return "manually-revoked";
|
|
2139
|
-
return null;
|
|
2140
|
-
},
|
|
2141
|
-
async revoke() {
|
|
2142
|
-
const res = await app._interface.revokeApiKeyById(data.id);
|
|
2143
|
-
await app._refreshApiKeys();
|
|
2144
|
-
return res;
|
|
2145
|
-
}
|
|
2146
|
-
};
|
|
2147
|
-
}
|
|
2148
|
-
_createApiKeyFromCrud(data) {
|
|
2149
|
-
return {
|
|
2150
|
-
...this._createApiKeyBaseFromCrud(data),
|
|
2151
|
-
publishableClientKey: data.publishable_client_key ? { lastFour: data.publishable_client_key.last_four } : null,
|
|
2152
|
-
secretServerKey: data.secret_server_key ? { lastFour: data.secret_server_key.last_four } : null,
|
|
2153
|
-
superSecretAdminKey: data.super_secret_admin_key ? { lastFour: data.super_secret_admin_key.last_four } : null
|
|
2154
|
-
};
|
|
2155
|
-
}
|
|
2156
|
-
_createApiKeyFirstViewFromCrud(data) {
|
|
2157
|
-
return {
|
|
2158
|
-
...this._createApiKeyBaseFromCrud(data),
|
|
2159
|
-
publishableClientKey: data.publishable_client_key,
|
|
2160
|
-
secretServerKey: data.secret_server_key,
|
|
2161
|
-
superSecretAdminKey: data.super_secret_admin_key
|
|
2162
|
-
};
|
|
2163
|
-
}
|
|
2164
|
-
async listApiKeys() {
|
|
2165
|
-
const crud = import_results.Result.orThrow(await this._apiKeysCache.getOrWait([], "write-only"));
|
|
2166
|
-
return crud.map((j) => this._createApiKeyFromCrud(j));
|
|
2167
|
-
}
|
|
2168
|
-
useApiKeys() {
|
|
2169
|
-
const crud = useAsyncCache(this._apiKeysCache, [], "useApiKeys()");
|
|
2170
|
-
return (0, import_react2.useMemo)(() => {
|
|
2171
|
-
return crud.map((j) => this._createApiKeyFromCrud(j));
|
|
2172
|
-
}, [crud]);
|
|
2173
|
-
}
|
|
2174
|
-
async createApiKey(options) {
|
|
2175
|
-
const crud = await this._interface.createApiKey(apiKeyCreateOptionsToCrud(options));
|
|
2176
|
-
await this._refreshApiKeys();
|
|
2177
|
-
return this._createApiKeyFirstViewFromCrud(crud);
|
|
2178
|
-
}
|
|
2179
|
-
useEmailTemplates() {
|
|
2180
|
-
const crud = useAsyncCache(this._adminEmailTemplatesCache, [], "useEmailTemplates()");
|
|
2181
|
-
return (0, import_react2.useMemo)(() => {
|
|
2182
|
-
return crud.map((j) => this._adminEmailTemplateFromCrud(j));
|
|
2183
|
-
}, [crud]);
|
|
2184
|
-
}
|
|
2185
|
-
async listEmailTemplates() {
|
|
2186
|
-
const crud = import_results.Result.orThrow(await this._adminEmailTemplatesCache.getOrWait([], "write-only"));
|
|
2187
|
-
return crud.map((j) => this._adminEmailTemplateFromCrud(j));
|
|
2188
|
-
}
|
|
2189
|
-
async updateEmailTemplate(type, data) {
|
|
2190
|
-
await this._interface.updateEmailTemplate(type, adminEmailTemplateUpdateOptionsToCrud(data));
|
|
2191
|
-
await this._adminEmailTemplatesCache.refresh([]);
|
|
2192
|
-
}
|
|
2193
|
-
async resetEmailTemplate(type) {
|
|
2194
|
-
await this._interface.resetEmailTemplate(type);
|
|
2195
|
-
await this._adminEmailTemplatesCache.refresh([]);
|
|
2196
|
-
}
|
|
2197
|
-
async createTeamPermissionDefinition(data) {
|
|
2198
|
-
const crud = await this._interface.createPermissionDefinition(serverTeamPermissionDefinitionCreateOptionsToCrud(data));
|
|
2199
|
-
await this._adminTeamPermissionDefinitionsCache.refresh([]);
|
|
2200
|
-
return this._serverTeamPermissionDefinitionFromCrud(crud);
|
|
2201
|
-
}
|
|
2202
|
-
async updateTeamPermissionDefinition(permissionId, data) {
|
|
2203
|
-
await this._interface.updatePermissionDefinition(permissionId, serverTeamPermissionDefinitionUpdateOptionsToCrud(data));
|
|
2204
|
-
await this._adminTeamPermissionDefinitionsCache.refresh([]);
|
|
2205
|
-
}
|
|
2206
|
-
async deleteTeamPermissionDefinition(permissionId) {
|
|
2207
|
-
await this._interface.deletePermissionDefinition(permissionId);
|
|
2208
|
-
await this._adminTeamPermissionDefinitionsCache.refresh([]);
|
|
2209
|
-
}
|
|
2210
|
-
async listTeamPermissionDefinitions() {
|
|
2211
|
-
const crud = import_results.Result.orThrow(await this._adminTeamPermissionDefinitionsCache.getOrWait([], "write-only"));
|
|
2212
|
-
return crud.map((p) => this._serverTeamPermissionDefinitionFromCrud(p));
|
|
2213
|
-
}
|
|
2214
|
-
useTeamPermissionDefinitions() {
|
|
2215
|
-
const crud = useAsyncCache(this._adminTeamPermissionDefinitionsCache, [], "usePermissions()");
|
|
2216
|
-
return (0, import_react2.useMemo)(() => {
|
|
2217
|
-
return crud.map((p) => this._serverTeamPermissionDefinitionFromCrud(p));
|
|
2218
|
-
}, [crud]);
|
|
2219
|
-
}
|
|
2220
|
-
useSvixToken() {
|
|
2221
|
-
const crud = useAsyncCache(this._svixTokenCache, [], "useSvixToken()");
|
|
2222
|
-
return crud.token;
|
|
2223
|
-
}
|
|
2224
|
-
async _refreshProject() {
|
|
2225
|
-
await Promise.all([
|
|
2226
|
-
super._refreshProject(),
|
|
2227
|
-
this._adminProjectCache.refresh([])
|
|
2228
|
-
]);
|
|
2229
|
-
}
|
|
2230
|
-
async _refreshApiKeys() {
|
|
2231
|
-
await this._apiKeysCache.refresh([]);
|
|
2232
|
-
}
|
|
2233
|
-
get [stackAppInternalsSymbol]() {
|
|
2234
|
-
return {
|
|
2235
|
-
...super[stackAppInternalsSymbol],
|
|
2236
|
-
useMetrics: () => {
|
|
2237
|
-
return useAsyncCache(this._metricsCache, [], "useMetrics()");
|
|
2238
|
-
}
|
|
2239
|
-
};
|
|
2240
|
-
}
|
|
2241
|
-
async sendTestEmail(options) {
|
|
2242
|
-
const response = await this._interface.sendTestEmail({
|
|
2243
|
-
recipient_email: options.recipientEmail,
|
|
2244
|
-
email_config: {
|
|
2245
|
-
...(0, import_objects.pick)(options.emailConfig, ["host", "port", "username", "password"]),
|
|
2246
|
-
sender_email: options.emailConfig.senderEmail,
|
|
2247
|
-
sender_name: options.emailConfig.senderName
|
|
2248
|
-
}
|
|
2249
|
-
});
|
|
2250
|
-
if (response.success) {
|
|
2251
|
-
return import_results.Result.ok(void 0);
|
|
2252
|
-
} else {
|
|
2253
|
-
return import_results.Result.error({ errorMessage: response.error_message ?? (0, import_errors.throwErr)("Email test error not specified") });
|
|
2254
|
-
}
|
|
2255
|
-
}
|
|
2256
|
-
};
|
|
2257
|
-
function contactChannelCreateOptionsToCrud(userId, options) {
|
|
2258
|
-
return {
|
|
2259
|
-
value: options.value,
|
|
2260
|
-
type: options.type,
|
|
2261
|
-
used_for_auth: options.usedForAuth,
|
|
2262
|
-
user_id: userId
|
|
2263
|
-
};
|
|
2264
|
-
}
|
|
2265
|
-
function contactChannelUpdateOptionsToCrud(options) {
|
|
2266
|
-
return {
|
|
2267
|
-
value: options.value,
|
|
2268
|
-
used_for_auth: options.usedForAuth,
|
|
2269
|
-
is_primary: options.isPrimary
|
|
2270
|
-
};
|
|
2271
|
-
}
|
|
2272
|
-
function serverContactChannelUpdateOptionsToCrud(options) {
|
|
2273
|
-
return {
|
|
2274
|
-
value: options.value,
|
|
2275
|
-
is_verified: options.isVerified,
|
|
2276
|
-
used_for_auth: options.usedForAuth
|
|
2277
|
-
};
|
|
2278
|
-
}
|
|
2279
|
-
function serverContactChannelCreateOptionsToCrud(userId, options) {
|
|
2280
|
-
return {
|
|
2281
|
-
type: options.type,
|
|
2282
|
-
value: options.value,
|
|
2283
|
-
is_verified: options.isVerified,
|
|
2284
|
-
user_id: userId,
|
|
2285
|
-
used_for_auth: options.usedForAuth
|
|
2286
|
-
};
|
|
2287
|
-
}
|
|
2288
|
-
function userUpdateOptionsToCrud(options) {
|
|
2289
|
-
return {
|
|
2290
|
-
display_name: options.displayName,
|
|
2291
|
-
client_metadata: options.clientMetadata,
|
|
2292
|
-
selected_team_id: options.selectedTeamId,
|
|
2293
|
-
totp_secret_base64: options.totpMultiFactorSecret != null ? (0, import_bytes.encodeBase64)(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,
|
|
2294
|
-
profile_image_url: options.profileImageUrl,
|
|
2295
|
-
otp_auth_enabled: options.otpAuthEnabled,
|
|
2296
|
-
passkey_auth_enabled: options.passkeyAuthEnabled
|
|
2297
|
-
};
|
|
2298
|
-
}
|
|
2299
|
-
function serverUserUpdateOptionsToCrud(options) {
|
|
2300
|
-
return {
|
|
2301
|
-
display_name: options.displayName,
|
|
2302
|
-
primary_email: options.primaryEmail,
|
|
2303
|
-
client_metadata: options.clientMetadata,
|
|
2304
|
-
client_read_only_metadata: options.clientReadOnlyMetadata,
|
|
2305
|
-
server_metadata: options.serverMetadata,
|
|
2306
|
-
selected_team_id: options.selectedTeamId,
|
|
2307
|
-
primary_email_auth_enabled: options.primaryEmailAuthEnabled,
|
|
2308
|
-
primary_email_verified: options.primaryEmailVerified,
|
|
2309
|
-
password: options.password,
|
|
2310
|
-
profile_image_url: options.profileImageUrl,
|
|
2311
|
-
totp_secret_base64: options.totpMultiFactorSecret != null ? (0, import_bytes.encodeBase64)(options.totpMultiFactorSecret) : options.totpMultiFactorSecret
|
|
2312
|
-
};
|
|
2313
|
-
}
|
|
2314
|
-
function serverUserCreateOptionsToCrud(options) {
|
|
2315
|
-
return {
|
|
2316
|
-
primary_email: options.primaryEmail,
|
|
2317
|
-
password: options.password,
|
|
2318
|
-
otp_auth_enabled: options.otpAuthEnabled,
|
|
2319
|
-
primary_email_auth_enabled: options.primaryEmailAuthEnabled,
|
|
2320
|
-
display_name: options.displayName,
|
|
2321
|
-
primary_email_verified: options.primaryEmailVerified,
|
|
2322
|
-
client_metadata: options.clientMetadata,
|
|
2323
|
-
client_read_only_metadata: options.clientReadOnlyMetadata,
|
|
2324
|
-
server_metadata: options.serverMetadata
|
|
2325
|
-
};
|
|
2326
|
-
}
|
|
2327
|
-
function adminProjectUpdateOptionsToCrud(options) {
|
|
2328
|
-
return {
|
|
2329
|
-
display_name: options.displayName,
|
|
2330
|
-
description: options.description,
|
|
2331
|
-
is_production_mode: options.isProductionMode,
|
|
2332
|
-
config: {
|
|
2333
|
-
domains: options.config?.domains?.map((d) => ({
|
|
2334
|
-
domain: d.domain,
|
|
2335
|
-
handler_path: d.handlerPath
|
|
2336
|
-
})),
|
|
2337
|
-
oauth_providers: options.config?.oauthProviders?.map((p) => ({
|
|
2338
|
-
id: p.id,
|
|
2339
|
-
enabled: p.enabled,
|
|
2340
|
-
type: p.type,
|
|
2341
|
-
...p.type === "standard" && {
|
|
2342
|
-
client_id: p.clientId,
|
|
2343
|
-
client_secret: p.clientSecret,
|
|
2344
|
-
facebook_config_id: p.facebookConfigId,
|
|
2345
|
-
microsoft_tenant_id: p.microsoftTenantId
|
|
2346
|
-
}
|
|
2347
|
-
})),
|
|
2348
|
-
email_config: options.config?.emailConfig && (options.config.emailConfig.type === "shared" ? {
|
|
2349
|
-
type: "shared"
|
|
2350
|
-
} : {
|
|
2351
|
-
type: "standard",
|
|
2352
|
-
host: options.config.emailConfig.host,
|
|
2353
|
-
port: options.config.emailConfig.port,
|
|
2354
|
-
username: options.config.emailConfig.username,
|
|
2355
|
-
password: options.config.emailConfig.password,
|
|
2356
|
-
sender_name: options.config.emailConfig.senderName,
|
|
2357
|
-
sender_email: options.config.emailConfig.senderEmail
|
|
2358
|
-
}),
|
|
2359
|
-
sign_up_enabled: options.config?.signUpEnabled,
|
|
2360
|
-
credential_enabled: options.config?.credentialEnabled,
|
|
2361
|
-
magic_link_enabled: options.config?.magicLinkEnabled,
|
|
2362
|
-
passkey_enabled: options.config?.passkeyEnabled,
|
|
2363
|
-
allow_localhost: options.config?.allowLocalhost,
|
|
2364
|
-
create_team_on_sign_up: options.config?.createTeamOnSignUp,
|
|
2365
|
-
client_team_creation_enabled: options.config?.clientTeamCreationEnabled,
|
|
2366
|
-
client_user_deletion_enabled: options.config?.clientUserDeletionEnabled,
|
|
2367
|
-
team_creator_default_permissions: options.config?.teamCreatorDefaultPermissions,
|
|
2368
|
-
team_member_default_permissions: options.config?.teamMemberDefaultPermissions
|
|
2369
|
-
}
|
|
2370
|
-
};
|
|
2371
|
-
}
|
|
2372
|
-
function adminProjectCreateOptionsToCrud(options) {
|
|
2373
|
-
return {
|
|
2374
|
-
...adminProjectUpdateOptionsToCrud(options),
|
|
2375
|
-
display_name: options.displayName
|
|
2376
|
-
};
|
|
2377
|
-
}
|
|
2378
|
-
function apiKeyCreateOptionsToCrud(options) {
|
|
2379
|
-
return {
|
|
2380
|
-
description: options.description,
|
|
2381
|
-
expires_at_millis: options.expiresAt.getTime(),
|
|
2382
|
-
has_publishable_client_key: options.hasPublishableClientKey,
|
|
2383
|
-
has_secret_server_key: options.hasSecretServerKey,
|
|
2384
|
-
has_super_secret_admin_key: options.hasSuperSecretAdminKey
|
|
2385
|
-
};
|
|
2386
|
-
}
|
|
2387
|
-
function teamUpdateOptionsToCrud(options) {
|
|
2388
|
-
return {
|
|
2389
|
-
display_name: options.displayName,
|
|
2390
|
-
profile_image_url: options.profileImageUrl,
|
|
2391
|
-
client_metadata: options.clientMetadata
|
|
2392
|
-
};
|
|
2393
|
-
}
|
|
2394
|
-
function teamCreateOptionsToCrud(options, creatorUserId) {
|
|
2395
|
-
return {
|
|
2396
|
-
display_name: options.displayName,
|
|
2397
|
-
profile_image_url: options.profileImageUrl,
|
|
2398
|
-
creator_user_id: creatorUserId
|
|
2399
|
-
};
|
|
2400
|
-
}
|
|
2401
|
-
function serverTeamCreateOptionsToCrud(options) {
|
|
2402
|
-
return {
|
|
2403
|
-
display_name: options.displayName,
|
|
2404
|
-
profile_image_url: options.profileImageUrl,
|
|
2405
|
-
creator_user_id: options.creatorUserId
|
|
2406
|
-
};
|
|
2407
|
-
}
|
|
2408
|
-
function serverTeamUpdateOptionsToCrud(options) {
|
|
2409
|
-
return {
|
|
2410
|
-
display_name: options.displayName,
|
|
2411
|
-
profile_image_url: options.profileImageUrl,
|
|
2412
|
-
client_metadata: options.clientMetadata,
|
|
2413
|
-
client_read_only_metadata: options.clientReadOnlyMetadata,
|
|
2414
|
-
server_metadata: options.serverMetadata
|
|
2415
|
-
};
|
|
2416
|
-
}
|
|
2417
|
-
function serverTeamPermissionDefinitionCreateOptionsToCrud(options) {
|
|
2418
|
-
return {
|
|
2419
|
-
id: options.id,
|
|
2420
|
-
description: options.description,
|
|
2421
|
-
contained_permission_ids: options.containedPermissionIds
|
|
2422
|
-
};
|
|
2423
|
-
}
|
|
2424
|
-
function serverTeamPermissionDefinitionUpdateOptionsToCrud(options) {
|
|
2425
|
-
return {
|
|
2426
|
-
id: options.id,
|
|
2427
|
-
description: options.description,
|
|
2428
|
-
contained_permission_ids: options.containedPermissionIds
|
|
2429
|
-
};
|
|
2430
|
-
}
|
|
2431
|
-
var StackClientApp = _StackClientAppImpl;
|
|
2432
|
-
var StackServerApp = _StackServerAppImpl;
|
|
2433
|
-
var StackAdminApp = _StackAdminAppImpl;
|
|
2434
|
-
function adminEmailTemplateUpdateOptionsToCrud(options) {
|
|
2435
|
-
return {
|
|
2436
|
-
subject: options.subject,
|
|
2437
|
-
content: options.content
|
|
2438
|
-
};
|
|
2439
|
-
}
|
|
1359
|
+
/**
|
|
1360
|
+
* There is a circular dependency between the admin app and the client app, as the former inherits from the latter and
|
|
1361
|
+
* the latter needs to use the former when creating a new instance of an internal project.
|
|
1362
|
+
*
|
|
1363
|
+
* To break it, we set the admin app here lazily instead of importing it directly. This variable is set by ./index.ts,
|
|
1364
|
+
* which imports both this file and ./admin-app-impl.ts.
|
|
1365
|
+
*/
|
|
1366
|
+
__StackClientAppImplIncomplete.LazyStackAdminAppImpl = { value: void 0 };
|
|
1367
|
+
var _StackClientAppImplIncomplete = __StackClientAppImplIncomplete;
|
|
2440
1368
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2441
1369
|
0 && (module.exports = {
|
|
2442
|
-
|
|
2443
|
-
StackClientApp,
|
|
2444
|
-
StackServerApp,
|
|
2445
|
-
serverTeamPermissionDefinitionCreateOptionsToCrud,
|
|
2446
|
-
serverTeamPermissionDefinitionUpdateOptionsToCrud,
|
|
2447
|
-
stackAppInternalsSymbol
|
|
1370
|
+
_StackClientAppImplIncomplete
|
|
2448
1371
|
});
|
|
2449
|
-
//# sourceMappingURL=
|
|
1372
|
+
//# sourceMappingURL=client-app-impl.js.map
|