@salsita-ai/sdk 0.50.0-develop.b5dfdd9774 → 0.50.0-develop.b65a5a9c66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/common/admin-interface.d.ts +11 -1
- package/dist/admin/common/admin-interface.js +1 -1
- package/dist/admin/ui/layout/UserProfile.d.ts +1 -1
- package/dist/admin/ui/layout/UserProfile.js +1 -1
- package/dist/admin/ui/maintenance/ImportPresets.js +1 -1
- package/dist/application/mount-application.js +1 -1
- package/dist/application/mount-configurator.js +1 -1
- package/dist/application/studio-embedding.d.ts +6 -0
- package/dist/application/studio-embedding.js +1 -0
- package/dist/application-spec/core/enhanced-json-schema.d.ts +5 -6
- package/dist/application-spec/core/enhanced-json-schema.js +1 -1
- package/dist/application-spec/core/markers/index.d.ts +1 -0
- package/dist/application-spec/core/markers/index.js +1 -1
- package/dist/application-spec/core/markers/set-in-studio-marker.d.ts +15 -0
- package/dist/application-spec/core/markers/set-in-studio-marker.js +1 -0
- package/dist/application-spec/errors/diagnostic-codes.d.ts +14 -0
- package/dist/application-spec/errors/diagnostic-codes.js +1 -1
- package/dist/application-spec/errors/diagnostic-messages.d.ts +14 -0
- package/dist/application-spec/errors/diagnostic-messages.js +1 -1
- package/dist/application-spec/generate-application/code/domain-runtime-files.d.ts +3 -3
- package/dist/application-spec/generate-application/code/domain-runtime-files.js +1 -1
- package/dist/application-spec/generate-application/code/standalone-app-files.d.ts +0 -12
- package/dist/application-spec/generate-application/code/standalone-app-files.js +1 -1
- package/dist/application-spec/generate-application/code/templates/admin-config.d.ts +5 -1
- package/dist/application-spec/generate-application/code/templates/admin-config.js +4 -4
- package/dist/application-spec/generate-application/code/templates/configurator-config.js +6 -6
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-phx-globals.d.ts +1 -1
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-phx-globals.js +19 -0
- package/dist/application-spec/generate-application/code/templates/domain-spec.js +12 -12
- package/dist/application-spec/generate-application/code/templates/global-definition/generate-phx-types.js +12 -12
- package/dist/application-spec/generate-application/code/templates/globals.js +21 -12
- package/dist/application-spec/generate-application/code/templates/sign-in-page-options.d.ts +5 -0
- package/dist/application-spec/generate-application/code/templates/sign-in-page-options.js +1 -0
- package/dist/application-spec/generate-application/code/templates/skills/core/cli.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/features/custom-layout/custom-layout.js +2 -2
- package/dist/application-spec/generate-application/code/templates/skills/features/custom-layout/sign-in.d.ts +3 -0
- package/dist/application-spec/generate-application/code/templates/skills/features/custom-layout/sign-in.js +19 -0
- package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/authentication.d.ts +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/authentication.js +32 -26
- package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/entry-and-environment.js +1 -3
- package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/publishing.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/session-fields.d.ts +3 -0
- package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/session-fields.js +1 -0
- package/dist/application-spec/generate-application/code/templates/skills/features/webhooks/webhooks.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/guide.d.ts +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/sdk-subpath-imports.js +1 -1
- package/dist/application-spec/generate-application/code/templates/webhook-builders.js +3 -2
- package/dist/application-spec/generate-application/code/templates/webhook-index.d.ts +1 -2
- package/dist/application-spec/generate-application/code/templates/webhook-index.js +3 -7
- package/dist/application-spec/generate-application/code/webhook-safe-files.d.ts +3 -1
- package/dist/application-spec/generate-application/code/webhook-safe-files.js +1 -1
- package/dist/application-spec/parse-application-files/access/access-handler-kinds.d.ts +18 -0
- package/dist/application-spec/parse-application-files/access/access-handler-kinds.js +1 -0
- package/dist/application-spec/parse-application-files/access/analyzed-file.d.ts +7 -0
- package/dist/application-spec/parse-application-files/access/analyzed-file.js +1 -0
- package/dist/application-spec/parse-application-files/access/check-access-handler-files.d.ts +20 -0
- package/dist/application-spec/parse-application-files/access/check-access-handler-files.js +1 -0
- package/dist/application-spec/parse-application-files/access/check-auth-hook-files.d.ts +17 -0
- package/dist/application-spec/parse-application-files/access/check-auth-hook-files.js +1 -0
- package/dist/application-spec/parse-application-files/access/index.d.ts +5 -0
- package/dist/application-spec/parse-application-files/access/index.js +1 -0
- package/dist/application-spec/parse-application-files/access/sign-in-control.d.ts +7 -0
- package/dist/application-spec/parse-application-files/access/sign-in-control.js +1 -0
- package/dist/application-spec/parse-application-files/categorize/categorize-files.d.ts +2 -1
- package/dist/application-spec/parse-application-files/categorize/categorize-files.js +1 -1
- package/dist/application-spec/parse-application-files/categorize/module-analysis.d.ts +30 -4
- package/dist/application-spec/parse-application-files/categorize/module-analysis.js +1 -1
- package/dist/application-spec/parse-application-files/categorize/webhook-safety.js +1 -1
- package/dist/application-spec/parse-application-files/merge/merged-app-metadata.d.ts +14 -1
- package/dist/application-spec/parse-application-files/merge/merged-app-metadata.js +1 -1
- package/dist/application-spec/parse-application-files/merge/merged-spec.d.ts +7 -1
- package/dist/application-spec/parse-application-files/merge/merged-spec.js +1 -1
- package/dist/application-spec/parse-application-files/parse-application-files.js +1 -1
- package/dist/application-spec/parse-application-files/parse-common-admin-spec.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.d.ts +6 -0
- package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.js +1 -1
- package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.d.ts +6 -0
- package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.js +1 -1
- package/dist/application-spec/parse-application-files/spec/model/index.d.ts +2 -1
- package/dist/application-spec/parse-application-files/spec/model/index.js +1 -1
- package/dist/application-spec/parse-application-files/spec/model/session-data-schema.d.ts +5 -2
- package/dist/application-spec/parse-application-files/spec/model/session-data-schema.js +1 -1
- package/dist/application-spec/parse-application-files/spec/model/session-fields/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/spec/model/session-fields/index.js +1 -0
- package/dist/application-spec/parse-application-files/spec/model/session-fields/session-fields.d.ts +15 -0
- package/dist/application-spec/parse-application-files/spec/model/session-fields/session-fields.js +1 -0
- package/dist/application-spec/parse-application-files/spec/sections/app-metadata.js +1 -1
- package/dist/client/authenticated-client.d.ts +5 -1
- package/dist/client/authenticated-client.js +1 -1
- package/dist/client/authorized-client.d.ts +3 -1
- package/dist/client/authorized-client.js +1 -1
- package/dist/client/base-client.d.ts +15 -1
- package/dist/client/base-client.js +1 -1
- package/dist/client/contract.d.ts +25 -0
- package/dist/client/contract.js +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/phoenix-api.d.ts +941 -8
- package/dist/client/unauthenticated-client.d.ts +1 -0
- package/dist/client/unauthenticated-client.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +9 -3
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
- package/dist/configurator/common/configurator-interface.d.ts +11 -1
- package/dist/configurator/common/configurator-interface.js +1 -1
- package/dist/docs/index.json +1 -1
- package/dist/docs/phoenix/admin.mdx +5 -40
- package/dist/docs/phoenix/clerk-sign-in.mdx +9 -5
- package/dist/docs/phoenix/data-sources.mdx +25 -29
- package/dist/docs/phoenix/deployments.mdx +3 -3
- package/dist/docs/phoenix/finalization.mdx +0 -1
- package/dist/docs/phoenix/integration/authentication-external.mdx +5 -5
- package/dist/docs/phoenix/integration/authentication-internal.mdx +1 -1
- package/dist/docs/phoenix/integration/finalization-internal.mdx +1 -4
- package/dist/docs/phoenix/integration/integration-modes-internal.mdx +9 -0
- package/dist/docs/phoenix/phoenix-cli.mdx +4 -4
- package/dist/docs/phoenix/project-structure.mdx +13 -8
- package/dist/docs/phoenix/publishing.mdx +21 -28
- package/dist/docs/phoenix/sdk-builder-workflow.mdx +2 -2
- package/dist/docs/phoenix/sessions-and-access.mdx +169 -163
- package/dist/docs/phoenix/webhook-membership.mdx +3 -0
- package/dist/docs/phoenix/webhooks.mdx +90 -113
- package/dist/domain/application/access/access-handlers.d.ts +19 -0
- package/dist/domain/application/access/access-handlers.js +1 -0
- package/dist/domain/application/access/anonymous-handler.d.ts +16 -0
- package/dist/domain/application/access/anonymous-handler.js +1 -0
- package/dist/domain/application/access/chunk-scopes-handler.d.ts +27 -0
- package/dist/domain/application/access/chunk-scopes-handler.js +1 -0
- package/dist/domain/application/access/code-handler.d.ts +16 -0
- package/dist/domain/application/access/code-handler.js +1 -0
- package/dist/domain/application/access/index.d.ts +7 -0
- package/dist/domain/application/access/index.js +1 -0
- package/dist/domain/application/access/refresh-handler.d.ts +16 -0
- package/dist/domain/application/access/refresh-handler.js +1 -0
- package/dist/domain/application/access/signed-in-handler.d.ts +44 -0
- package/dist/domain/application/access/signed-in-handler.js +1 -0
- package/dist/domain/application/access/visitor-handler.d.ts +23 -0
- package/dist/domain/application/access/visitor-handler.js +1 -0
- package/dist/domain/application/application-config.d.ts +29 -0
- package/dist/domain/application/configurator-builder.d.ts +2 -0
- package/dist/domain/application/configurator-builder.js +1 -1
- package/dist/domain/application/index.d.ts +2 -1
- package/dist/domain/application/index.js +1 -1
- package/dist/domain/application/standard-properties.d.ts +1 -1
- package/dist/domain/application/standard-properties.js +1 -1
- package/dist/domain/core/domain-factory.d.ts +6 -0
- package/dist/domain/core/domain-factory.js +1 -1
- package/dist/domain/core/fit-session-data.d.ts +16 -0
- package/dist/domain/core/fit-session-data.js +1 -0
- package/dist/domain/domain-runtime/domain-context/actions.d.ts +4 -0
- package/dist/domain/domain-runtime/domain-context/actions.js +1 -1
- package/dist/domain/domain-runtime/domain-context/domain-context.d.ts +8 -0
- package/dist/domain/domain-runtime/domain-context/domain-context.js +1 -1
- package/dist/domain/domain-runtime/domain-context/selectors.d.ts +1 -0
- package/dist/domain/domain-runtime/domain-context/selectors.js +1 -1
- package/dist/domain/domain-runtime/domain-context/types.d.ts +8 -4
- package/dist/domain/domain-runtime/domain-runtime.d.ts +8 -0
- package/dist/domain/mocks/create-mock-domain-runtime.d.ts +4 -0
- package/dist/domain/spec/sections/app-metadata.d.ts +10 -0
- package/dist/editor/domain-editors/use-implementation-files.js +1 -1
- package/dist/extras/clerk/index.d.ts +6 -0
- package/dist/extras/cognito/AccountAvatar.d.ts +7 -0
- package/dist/extras/cognito/AccountAvatar.js +1 -0
- package/dist/extras/cognito/AccountControl.d.ts +13 -0
- package/dist/extras/cognito/AccountControl.js +1 -0
- package/dist/extras/cognito/AdminSignInPage.d.ts +26 -0
- package/dist/extras/cognito/AdminSignInPage.js +1 -0
- package/dist/extras/cognito/CognitoSignInPage.d.ts +8 -2
- package/dist/extras/cognito/CognitoSignInPage.js +1 -1
- package/dist/extras/cognito/ConfiguratorSignInPage.d.ts +19 -0
- package/dist/extras/cognito/ConfiguratorSignInPage.js +1 -0
- package/dist/extras/cognito/SignInFailurePage.d.ts +11 -0
- package/dist/extras/cognito/SignInFailurePage.js +1 -0
- package/dist/extras/cognito/SignInGateLayout.d.ts +25 -0
- package/dist/extras/cognito/SignInGateLayout.js +1 -0
- package/dist/extras/cognito/SignInNotice.d.ts +8 -0
- package/dist/extras/cognito/SignInNotice.js +1 -0
- package/dist/extras/cognito/index.d.ts +4 -0
- package/dist/extras/cognito/index.js +1 -1
- package/dist/i18n/locales/cs/messages.js +1 -1
- package/dist/i18n/locales/da/messages.js +1 -1
- package/dist/i18n/locales/de/messages.js +1 -1
- package/dist/i18n/locales/de-AT/messages.js +1 -1
- package/dist/i18n/locales/en/messages.js +1 -1
- package/dist/i18n/locales/en-AU/messages.js +1 -1
- package/dist/i18n/locales/en-GB/messages.js +1 -1
- package/dist/i18n/locales/es/messages.js +1 -1
- package/dist/i18n/locales/fr/messages.js +1 -1
- package/dist/i18n/locales/hu/messages.js +1 -1
- package/dist/i18n/locales/it/messages.js +1 -1
- package/dist/i18n/locales/nl/messages.js +1 -1
- package/dist/i18n/locales/pl/messages.js +1 -1
- package/dist/i18n/locales/pt/messages.js +1 -1
- package/dist/i18n/locales/ro/messages.js +1 -1
- package/dist/i18n/locales/sk/messages.js +1 -1
- package/dist/i18n/locales/tr/messages.js +1 -1
- package/dist/phoenix/application-spec/resolve-deployment-data.d.ts +10 -3
- package/dist/phoenix/application-spec/resolve-deployment-data.js +2 -2
- package/dist/phoenix/commands/deps/deps.js +2 -2
- package/dist/phoenix/commands/prepare-deployment-command.js +2 -2
- package/dist/phoenix/commands/prepare-local-environment-command.js +1 -1
- package/dist/phoenix/services/prepare-development-environment.js +2 -2
- package/dist/phoenix/services/variant-file-session.js +1 -1
- package/dist/react-sdk/application-runtime/common-services/selectors.js +1 -1
- package/dist/react-sdk/application-runtime/domain-application-context/configuration-persist-system.d.ts +6 -0
- package/dist/react-sdk/application-runtime/domain-application-context/configuration-persist-system.js +1 -1
- package/dist/react-sdk/application-runtime/host-properties/selectors.d.ts +2 -2
- package/dist/react-sdk/application-runtime/integration/integration-mode.d.ts +30 -0
- package/dist/react-sdk/application-runtime/integration/integration-mode.js +1 -1
- package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +20 -6
- package/dist/react-sdk/application-runtime/session/actions.d.ts +2 -1
- package/dist/react-sdk/application-runtime/session/actions.js +1 -1
- package/dist/react-sdk/application-runtime/session/initialize.js +1 -1
- package/dist/react-sdk/application-runtime/session/selectors.d.ts +2 -0
- package/dist/react-sdk/application-runtime/session/selectors.js +1 -1
- package/dist/react-sdk/application-runtime/session/session-service.d.ts +34 -1
- package/dist/react-sdk/application-runtime/session/session-service.js +1 -1
- package/dist/react-sdk/application-runtime/session/session-token.d.ts +8 -0
- package/dist/react-sdk/application-runtime/session/session-token.js +1 -1
- package/dist/react-sdk/application-runtime/session/types.d.ts +6 -1
- package/dist/react-sdk/domain-context/common-hooks/use-domain-context.d.ts +1 -0
- package/dist/react-sdk/preset-selection/PresetSelectionProvider.js +1 -1
- package/dist/react-sdk/session/AccessDeniedAdminPage.d.ts +13 -0
- package/dist/react-sdk/session/AccessDeniedAdminPage.js +1 -0
- package/dist/react-sdk/session/AccessDeniedPage.d.ts +20 -0
- package/dist/react-sdk/session/AccessDeniedPage.js +1 -0
- package/dist/react-sdk/session/SessionServiceProvider.js +1 -1
- package/dist/react-sdk/session/index.d.ts +3 -0
- package/dist/react-sdk/session/index.js +1 -1
- package/dist/react-sdk/session/sign-in-address.d.ts +13 -0
- package/dist/react-sdk/session/sign-in-address.js +1 -0
- package/dist/react-sdk/session/studio-frame.d.ts +7 -0
- package/dist/react-sdk/session/studio-frame.js +1 -0
- package/dist/react-sdk/session/use-sign-in.d.ts +50 -0
- package/dist/react-sdk/session/use-sign-in.js +1 -0
- package/dist/webhook/builders/auth-handler-builder.d.ts +21 -1
- package/dist/webhook/builders/auth-handler-builder.js +1 -1
- package/dist/webhook/builders/common.d.ts +9 -0
- package/dist/webhook/builders/webhook-builder.d.ts +13 -0
- package/dist/webhook/builders/webhook-builder.js +1 -1
- package/package.json +4 -4
|
@@ -440,6 +440,7 @@ export declare function createApplicationRuntimeSlices<State extends Application
|
|
|
440
440
|
selectActiveSessionData: import("@salsita-ai/common/utils").Selector<import("#package/domain").DomainContextSelectorState, Record<string, unknown>>;
|
|
441
441
|
selectExpressionContext: import("@salsita-ai/common/utils").Selector<import("#package/domain").DomainContextSelectorState, import("#package/domain").AnyExpressionContext>;
|
|
442
442
|
getInitializationContext: () => import("#package/domain").DomainContextInitializationContext | null;
|
|
443
|
+
getLatestSessionContext: () => import("#package/domain").DomainSessionContext | null;
|
|
443
444
|
getInitializationState: () => import("#package/domain").DomainContextInitializationState;
|
|
444
445
|
getNextInitializationContext: () => import("#package/domain").DomainContextInitializationContext;
|
|
445
446
|
getLatestLoadedData: () => import("#package/domain").ConfiguratorLoadedData | null;
|
|
@@ -550,6 +551,7 @@ export declare function createApplicationRuntimeSlices<State extends Application
|
|
|
550
551
|
selectActiveSessionData: import("@salsita-ai/common/utils").Selector<import("#package/domain").DomainContextSelectorState, Record<string, unknown>>;
|
|
551
552
|
selectExpressionContext: import("@salsita-ai/common/utils").Selector<import("#package/domain").DomainContextSelectorState, import("#package/domain").AnyExpressionContext>;
|
|
552
553
|
getInitializationContext: () => import("#package/domain").DomainContextInitializationContext | null;
|
|
554
|
+
getLatestSessionContext: () => import("#package/domain").DomainSessionContext | null;
|
|
553
555
|
getInitializationState: () => import("#package/domain").DomainContextInitializationState;
|
|
554
556
|
getNextInitializationContext: () => import("#package/domain").DomainContextInitializationContext;
|
|
555
557
|
getLatestLoadedData: () => import("#package/domain").ConfiguratorLoadedData | null;
|
|
@@ -636,7 +638,7 @@ export declare function createApplicationRuntimeSlices<State extends Application
|
|
|
636
638
|
readonly adminSessionToken: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, string | undefined>;
|
|
637
639
|
readonly authorizationCode: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, string | undefined>;
|
|
638
640
|
readonly expanded: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, boolean>;
|
|
639
|
-
readonly integrationMode: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, "handoff" | "headless" | "page" | "widget">;
|
|
641
|
+
readonly integrationMode: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, "embedded" | "handoff" | "headless" | "page" | "widget">;
|
|
640
642
|
readonly mode: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, "admin" | "configurator" | "standalone-admin">;
|
|
641
643
|
readonly power: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, "off" | "on" | "standby">;
|
|
642
644
|
readonly presetTags: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, string[] | null>;
|
|
@@ -665,7 +667,7 @@ export declare function createApplicationRuntimeSlices<State extends Application
|
|
|
665
667
|
selectMode: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, "admin" | "configurator" | "standalone-admin">;
|
|
666
668
|
selectPower: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, "off" | "on" | "standby">;
|
|
667
669
|
selectPresetTags: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, string[] | null>;
|
|
668
|
-
selectIntegrationMode: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, "handoff" | "headless" | "page" | "widget">;
|
|
670
|
+
selectIntegrationMode: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, "embedded" | "handoff" | "headless" | "page" | "widget">;
|
|
669
671
|
selectSessionToken: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, string | undefined>;
|
|
670
672
|
selectAdminSessionToken: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, string | undefined>;
|
|
671
673
|
selectRefreshToken: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, string | undefined>;
|
|
@@ -684,7 +686,7 @@ export declare function createApplicationRuntimeSlices<State extends Application
|
|
|
684
686
|
getMode: () => "admin" | "configurator" | "standalone-admin";
|
|
685
687
|
getPower: () => "off" | "on" | "standby";
|
|
686
688
|
getPresetTags: () => string[] | null;
|
|
687
|
-
getIntegrationMode: () => "handoff" | "headless" | "page" | "widget";
|
|
689
|
+
getIntegrationMode: () => "embedded" | "handoff" | "headless" | "page" | "widget";
|
|
688
690
|
getSessionToken: () => string | undefined;
|
|
689
691
|
getAdminSessionToken: () => string | undefined;
|
|
690
692
|
getRefreshToken: () => string | undefined;
|
|
@@ -749,10 +751,12 @@ export declare function createApplicationRuntimeSlices<State extends Application
|
|
|
749
751
|
selectRawConfiguratorSessionPayload: import("@salsita-ai/common/utils").Selector<import("../index.js").SessionSelectorState, import("../index.js").RuntimeSessionPayload | null>;
|
|
750
752
|
selectConfiguratorSessionPayload: import("@salsita-ai/common/utils").Selector<import("../index.js").SessionSelectorState, import("../index.js").RuntimeSessionPayload | null>;
|
|
751
753
|
selectSession: import("@salsita-ai/common/utils").Selector<import("../index.js").SessionSelectorState, import("#package/domain").Session<Record<string, unknown>>>;
|
|
754
|
+
selectSignIn: import("@salsita-ai/common/utils").Selector<import("../index.js").SessionSelectorState, import("#package/domain").SignInOutcome>;
|
|
752
755
|
getRawSessionState: () => import("#package/domain").SessionState;
|
|
753
756
|
getDecodedSessionToken: () => import("../index.js").RuntimeSessionPayload | null;
|
|
754
757
|
getExp: () => number | null;
|
|
755
758
|
getSession: () => import("#package/domain").Session<Record<string, unknown>>;
|
|
759
|
+
getSignIn: () => import("#package/domain").SignInOutcome;
|
|
756
760
|
getRawConfiguratorSessionPayload: () => import("../index.js").RuntimeSessionPayload | null;
|
|
757
761
|
};
|
|
758
762
|
domainApplicationContext: {
|
|
@@ -815,12 +819,14 @@ export declare function createApplicationRuntimeSlices<State extends Application
|
|
|
815
819
|
failInitialization: () => void;
|
|
816
820
|
setExecutionMode: (executionMode: import("#package/domain").DomainExecutionMode) => void;
|
|
817
821
|
setInitializationContext: (initializationContext: import("#package/domain").DomainContextInitializationContext) => void;
|
|
822
|
+
updateSessionInputs: (role: import("@salsita-ai/contracts/api").SessionRole, sessionData: Record<string, unknown>) => void;
|
|
818
823
|
};
|
|
819
824
|
admin: {
|
|
820
825
|
completeInitialization: () => void;
|
|
821
826
|
failInitialization: () => void;
|
|
822
827
|
setExecutionMode: (executionMode: import("#package/domain").DomainExecutionMode) => void;
|
|
823
828
|
setInitializationContext: (initializationContext: import("#package/domain").DomainContextInitializationContext) => void;
|
|
829
|
+
updateSessionInputs: (role: import("@salsita-ai/contracts/api").SessionRole, sessionData: Record<string, unknown>) => void;
|
|
824
830
|
};
|
|
825
831
|
};
|
|
826
832
|
integration: {
|
|
@@ -881,6 +887,7 @@ export declare function createApplicationRuntimeSlices<State extends Application
|
|
|
881
887
|
session: {
|
|
882
888
|
setSessionState: (sessionState: import("#package/domain").SessionState) => void;
|
|
883
889
|
setAuthenticated: (authenticated: import("#package/domain").SessionState['authenticated'], authenticationErrorCode: import("#package/domain").SessionState['authenticationErrorCode']) => void;
|
|
890
|
+
setSignIn: (signIn: import("#package/domain").SignInOutcome) => void;
|
|
884
891
|
};
|
|
885
892
|
};
|
|
886
893
|
};
|
|
@@ -1254,6 +1261,7 @@ declare const createApplicationRuntimeImpl: <EXTENSIONS extends readonly AnyAppl
|
|
|
1254
1261
|
selectActiveSessionData: import("@salsita-ai/common/utils").Selector<import("#package/domain").DomainContextSelectorState, Record<string, unknown>>;
|
|
1255
1262
|
selectExpressionContext: import("@salsita-ai/common/utils").Selector<import("#package/domain").DomainContextSelectorState, import("#package/domain").AnyExpressionContext>;
|
|
1256
1263
|
getInitializationContext: () => import("#package/domain").DomainContextInitializationContext | null;
|
|
1264
|
+
getLatestSessionContext: () => import("#package/domain").DomainSessionContext | null;
|
|
1257
1265
|
getInitializationState: () => import("#package/domain").DomainContextInitializationState;
|
|
1258
1266
|
getNextInitializationContext: () => import("#package/domain").DomainContextInitializationContext;
|
|
1259
1267
|
getLatestLoadedData: () => import("#package/domain").ConfiguratorLoadedData | null;
|
|
@@ -1364,6 +1372,7 @@ declare const createApplicationRuntimeImpl: <EXTENSIONS extends readonly AnyAppl
|
|
|
1364
1372
|
selectActiveSessionData: import("@salsita-ai/common/utils").Selector<import("#package/domain").DomainContextSelectorState, Record<string, unknown>>;
|
|
1365
1373
|
selectExpressionContext: import("@salsita-ai/common/utils").Selector<import("#package/domain").DomainContextSelectorState, import("#package/domain").AnyExpressionContext>;
|
|
1366
1374
|
getInitializationContext: () => import("#package/domain").DomainContextInitializationContext | null;
|
|
1375
|
+
getLatestSessionContext: () => import("#package/domain").DomainSessionContext | null;
|
|
1367
1376
|
getInitializationState: () => import("#package/domain").DomainContextInitializationState;
|
|
1368
1377
|
getNextInitializationContext: () => import("#package/domain").DomainContextInitializationContext;
|
|
1369
1378
|
getLatestLoadedData: () => import("#package/domain").ConfiguratorLoadedData | null;
|
|
@@ -1450,7 +1459,7 @@ declare const createApplicationRuntimeImpl: <EXTENSIONS extends readonly AnyAppl
|
|
|
1450
1459
|
readonly adminSessionToken: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, string | undefined>;
|
|
1451
1460
|
readonly authorizationCode: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, string | undefined>;
|
|
1452
1461
|
readonly expanded: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, boolean>;
|
|
1453
|
-
readonly integrationMode: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, "handoff" | "headless" | "page" | "widget">;
|
|
1462
|
+
readonly integrationMode: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, "embedded" | "handoff" | "headless" | "page" | "widget">;
|
|
1454
1463
|
readonly mode: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, "admin" | "configurator" | "standalone-admin">;
|
|
1455
1464
|
readonly power: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, "off" | "on" | "standby">;
|
|
1456
1465
|
readonly presetTags: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, string[] | null>;
|
|
@@ -1479,7 +1488,7 @@ declare const createApplicationRuntimeImpl: <EXTENSIONS extends readonly AnyAppl
|
|
|
1479
1488
|
selectMode: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, "admin" | "configurator" | "standalone-admin">;
|
|
1480
1489
|
selectPower: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, "off" | "on" | "standby">;
|
|
1481
1490
|
selectPresetTags: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, string[] | null>;
|
|
1482
|
-
selectIntegrationMode: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, "handoff" | "headless" | "page" | "widget">;
|
|
1491
|
+
selectIntegrationMode: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, "embedded" | "handoff" | "headless" | "page" | "widget">;
|
|
1483
1492
|
selectSessionToken: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, string | undefined>;
|
|
1484
1493
|
selectAdminSessionToken: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, string | undefined>;
|
|
1485
1494
|
selectRefreshToken: import("@salsita-ai/common/utils").Selector<import("../host-properties/selectors.js").HostPropertiesSelectorState, string | undefined>;
|
|
@@ -1498,7 +1507,7 @@ declare const createApplicationRuntimeImpl: <EXTENSIONS extends readonly AnyAppl
|
|
|
1498
1507
|
getMode: () => "admin" | "configurator" | "standalone-admin";
|
|
1499
1508
|
getPower: () => "off" | "on" | "standby";
|
|
1500
1509
|
getPresetTags: () => string[] | null;
|
|
1501
|
-
getIntegrationMode: () => "handoff" | "headless" | "page" | "widget";
|
|
1510
|
+
getIntegrationMode: () => "embedded" | "handoff" | "headless" | "page" | "widget";
|
|
1502
1511
|
getSessionToken: () => string | undefined;
|
|
1503
1512
|
getAdminSessionToken: () => string | undefined;
|
|
1504
1513
|
getRefreshToken: () => string | undefined;
|
|
@@ -1563,10 +1572,12 @@ declare const createApplicationRuntimeImpl: <EXTENSIONS extends readonly AnyAppl
|
|
|
1563
1572
|
selectRawConfiguratorSessionPayload: import("@salsita-ai/common/utils").Selector<import("../index.js").SessionSelectorState, import("../index.js").RuntimeSessionPayload | null>;
|
|
1564
1573
|
selectConfiguratorSessionPayload: import("@salsita-ai/common/utils").Selector<import("../index.js").SessionSelectorState, import("../index.js").RuntimeSessionPayload | null>;
|
|
1565
1574
|
selectSession: import("@salsita-ai/common/utils").Selector<import("../index.js").SessionSelectorState, import("#package/domain").Session<Record<string, unknown>>>;
|
|
1575
|
+
selectSignIn: import("@salsita-ai/common/utils").Selector<import("../index.js").SessionSelectorState, import("#package/domain").SignInOutcome>;
|
|
1566
1576
|
getRawSessionState: () => import("#package/domain").SessionState;
|
|
1567
1577
|
getDecodedSessionToken: () => import("../index.js").RuntimeSessionPayload | null;
|
|
1568
1578
|
getExp: () => number | null;
|
|
1569
1579
|
getSession: () => import("#package/domain").Session<Record<string, unknown>>;
|
|
1580
|
+
getSignIn: () => import("#package/domain").SignInOutcome;
|
|
1570
1581
|
getRawConfiguratorSessionPayload: () => import("../index.js").RuntimeSessionPayload | null;
|
|
1571
1582
|
};
|
|
1572
1583
|
domainApplicationContext: {
|
|
@@ -1629,12 +1640,14 @@ declare const createApplicationRuntimeImpl: <EXTENSIONS extends readonly AnyAppl
|
|
|
1629
1640
|
failInitialization: () => void;
|
|
1630
1641
|
setExecutionMode: (executionMode: import("#package/domain").DomainExecutionMode) => void;
|
|
1631
1642
|
setInitializationContext: (initializationContext: import("#package/domain").DomainContextInitializationContext) => void;
|
|
1643
|
+
updateSessionInputs: (role: import("@salsita-ai/contracts/api").SessionRole, sessionData: Record<string, unknown>) => void;
|
|
1632
1644
|
};
|
|
1633
1645
|
admin: {
|
|
1634
1646
|
completeInitialization: () => void;
|
|
1635
1647
|
failInitialization: () => void;
|
|
1636
1648
|
setExecutionMode: (executionMode: import("#package/domain").DomainExecutionMode) => void;
|
|
1637
1649
|
setInitializationContext: (initializationContext: import("#package/domain").DomainContextInitializationContext) => void;
|
|
1650
|
+
updateSessionInputs: (role: import("@salsita-ai/contracts/api").SessionRole, sessionData: Record<string, unknown>) => void;
|
|
1638
1651
|
};
|
|
1639
1652
|
};
|
|
1640
1653
|
integration: {
|
|
@@ -1695,6 +1708,7 @@ declare const createApplicationRuntimeImpl: <EXTENSIONS extends readonly AnyAppl
|
|
|
1695
1708
|
session: {
|
|
1696
1709
|
setSessionState: (sessionState: import("#package/domain").SessionState) => void;
|
|
1697
1710
|
setAuthenticated: (authenticated: import("#package/domain").SessionState['authenticated'], authenticationErrorCode: import("#package/domain").SessionState['authenticationErrorCode']) => void;
|
|
1711
|
+
setSignIn: (signIn: import("#package/domain").SignInOutcome) => void;
|
|
1698
1712
|
};
|
|
1699
1713
|
};
|
|
1700
1714
|
getState: () => ApplicationRuntimeState;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SessionState } from '#package/domain';
|
|
1
|
+
import type { SessionState, SignInOutcome } from '#package/domain';
|
|
2
2
|
import type { ApplicationSessionRuntime } from './types.js';
|
|
3
3
|
interface Context {
|
|
4
4
|
readonly setSessionRuntime: (fn: (state: ApplicationSessionRuntime) => ApplicationSessionRuntime) => void;
|
|
@@ -6,6 +6,7 @@ interface Context {
|
|
|
6
6
|
export declare const createSessionRuntimeActions: (context: Context) => {
|
|
7
7
|
setSessionState: (sessionState: SessionState) => void;
|
|
8
8
|
setAuthenticated: (authenticated: SessionState['authenticated'], authenticationErrorCode: SessionState['authenticationErrorCode']) => void;
|
|
9
|
+
setSignIn: (signIn: SignInOutcome) => void;
|
|
9
10
|
};
|
|
10
11
|
export type SessionRuntimeActions = ReturnType<typeof createSessionRuntimeActions>;
|
|
11
12
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const createSessionRuntimeActions=t=>{let{setSessionRuntime:e}=t;return{setSessionState:t=>{e(e=>({...e,sessionState:t}))},setAuthenticated:(t,s)=>{e(e=>({...e,sessionState:{...e.sessionState,authenticated:t,authenticationErrorCode:s}}))}}};
|
|
1
|
+
export const createSessionRuntimeActions=t=>{let{setSessionRuntime:e}=t;return{setSessionState:t=>{e(e=>({...e,sessionState:t}))},setAuthenticated:(t,s)=>{e(e=>({...e,sessionState:{...e.sessionState,authenticated:t,authenticationErrorCode:s}}))},setSignIn:t=>{e(e=>({...e,signIn:t}))}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const initializeSessionRuntime=()=>({sessionState:{sessionToken:null,adminSessionToken:null,refreshToken:null,authenticated:"loading",authenticationErrorCode:null}});
|
|
1
|
+
export const initializeSessionRuntime=()=>({sessionState:{sessionToken:null,adminSessionToken:null,refreshToken:null,authenticated:"loading",authenticationErrorCode:null},signIn:{state:"idle"}});
|
|
@@ -16,10 +16,12 @@ export declare const createSessionRuntimeSelectors: (context: Context) => {
|
|
|
16
16
|
selectRawConfiguratorSessionPayload: import("@salsita-ai/common/utils").Selector<SessionSelectorState, RuntimeSessionPayload | null>;
|
|
17
17
|
selectConfiguratorSessionPayload: import("@salsita-ai/common/utils").Selector<SessionSelectorState, RuntimeSessionPayload | null>;
|
|
18
18
|
selectSession: import("@salsita-ai/common/utils").Selector<SessionSelectorState, Session<Record<string, unknown>>>;
|
|
19
|
+
selectSignIn: import("@salsita-ai/common/utils").Selector<SessionSelectorState, import("#package/domain").SignInOutcome>;
|
|
19
20
|
getRawSessionState: () => import("#package/domain").SessionState;
|
|
20
21
|
getDecodedSessionToken: () => RuntimeSessionPayload | null;
|
|
21
22
|
getExp: () => number | null;
|
|
22
23
|
getSession: () => Session<Record<string, unknown>>;
|
|
24
|
+
getSignIn: () => import("#package/domain").SignInOutcome;
|
|
23
25
|
getRawConfiguratorSessionPayload: () => RuntimeSessionPayload | null;
|
|
24
26
|
};
|
|
25
27
|
export type SessionRuntimeSelectors = ReturnType<typeof createSessionRuntimeSelectors>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSelector as e}from"@salsita-ai/common/utils";import{decodeSessionToken as n}from"./session-token.js";let s=e=>{if(null===e)return null;let{deploymentId:n,applicationType:s,publishedAdminRevisionPath:o,environmentId:t,configurationSchemaId:i,chunkScopes:a,origins:l}=e;return{deploymentId:n,applicationType:s,...void 0===o?{}:{publishedAdminRevisionPath:o},environmentId:t,configurationSchemaId:i,...void 0===a?{}:{chunkScopes:a},origins:l}},o=(e,n,s,o)=>null===e||null===n||null===s||null===o?null:{...e,role:n.role,data:n.data,iat:s,exp:o},t=(e,n)=>({rawSessionToken:e.sessionToken,rawAdminSessionToken:e.adminSessionToken,rawRefreshToken:e.refreshToken,sessionPayload:n,authenticated:e.authenticated,authenticationErrorCode:e.authenticationErrorCode});export const createSessionRuntimeSelectors=i=>{let{getState:a,sessionContextSelectors:l}=i,r=e.withTypes(),u=r([r.leaf(e=>e.session.sessionState)],e=>e),S=r([r.leaf(e=>e.session.sessionState.sessionToken)],n),d=r([S],s),c=r([S],e=>e?.iat??null),
|
|
1
|
+
import{createSelector as e}from"@salsita-ai/common/utils";import{decodeSessionToken as n}from"./session-token.js";let s=e=>{if(null===e)return null;let{deploymentId:n,applicationType:s,publishedAdminRevisionPath:o,environmentId:t,configurationSchemaId:i,chunkScopes:a,origins:l}=e;return{deploymentId:n,applicationType:s,...void 0===o?{}:{publishedAdminRevisionPath:o},environmentId:t,configurationSchemaId:i,...void 0===a?{}:{chunkScopes:a},origins:l}},o=(e,n,s,o)=>null===e||null===n||null===s||null===o?null:{...e,role:n.role,data:n.data,iat:s,exp:o},t=(e,n)=>({rawSessionToken:e.sessionToken,rawAdminSessionToken:e.adminSessionToken,rawRefreshToken:e.refreshToken,sessionPayload:n,authenticated:e.authenticated,authenticationErrorCode:e.authenticationErrorCode});export const createSessionRuntimeSelectors=i=>{let{getState:a,sessionContextSelectors:l}=i,r=e.withTypes(),u=r([r.leaf(e=>e.session.sessionState)],e=>e),S=r([r.leaf(e=>e.session.sessionState.sessionToken)],n),d=r([S],s),c=r([S],e=>e?.iat??null),f=r([S],e=>e?.exp??null),g=r([d,l.selectRawSessionContext,c,f],o),k=r([d,l.selectSessionContext,c,f],o),m=r([u,k],t),T=r([r.leaf(e=>e.session.signIn)],e=>e);return{selectRawSessionState:u,selectDecodedSessionToken:S,selectSessionClaims:d,selectIat:c,selectExp:f,selectRawConfiguratorSessionPayload:g,selectConfiguratorSessionPayload:k,selectSession:m,selectSignIn:T,getRawSessionState:()=>u(a()),getDecodedSessionToken:()=>S(a()),getExp:()=>f(a()),getSession:()=>m(a()),getSignIn:()=>T(a()),getRawConfiguratorSessionPayload:()=>g(a())}};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Logger } from '@salsita-ai/common/utils';
|
|
2
2
|
import type { UnauthenticatedPhoenixApiClient } from '#package/client';
|
|
3
3
|
import { type AnalyticsSystem, type DomainSessionContext, type EnvironmentSelectors, type ISessionService, type SpecSelectors } from '#package/domain';
|
|
4
4
|
import type { SessionRuntimeActions } from './actions.js';
|
|
@@ -22,6 +22,12 @@ interface SessionServiceConfiguration {
|
|
|
22
22
|
readonly retrieveAuthorizationCode: () => string | undefined;
|
|
23
23
|
readonly dispatchAuthenticationFailed: () => Promise<unknown>;
|
|
24
24
|
readonly storage: Storage;
|
|
25
|
+
/**
|
|
26
|
+
* Whether a Studio-account sign-in that is refused or does not finish continues as a visitor, which the server lets
|
|
27
|
+
* in where visitors may use the configurator. Off in Studio's frame, which shows its own state for a refusal.
|
|
28
|
+
* Defaults to on.
|
|
29
|
+
*/
|
|
30
|
+
readonly visitorAfterSignInError?: boolean;
|
|
25
31
|
}
|
|
26
32
|
export declare class SessionService<SESSION_DATA extends Record<string, unknown>> implements ISessionService {
|
|
27
33
|
private readonly _context;
|
|
@@ -46,6 +52,14 @@ export declare class SessionService<SESSION_DATA extends Record<string, unknown>
|
|
|
46
52
|
private readonly _getStoredRefreshToken;
|
|
47
53
|
private readonly _clearStoredRefreshToken;
|
|
48
54
|
private readonly _handleAuthentication;
|
|
55
|
+
/** Records a session that could not be authenticated, with its failure class ({@link getFailureCode}). */
|
|
56
|
+
private readonly _reportFailure;
|
|
57
|
+
/**
|
|
58
|
+
* One authentication request. A failure is recorded only with `reportFailure`, so a sign-in that continues as a
|
|
59
|
+
* visitor never shows its error. `failureCode` overrides the failure class it records: a visitor's session that
|
|
60
|
+
* follows a rejected sign-in code still reports the code as rejected.
|
|
61
|
+
*/
|
|
62
|
+
private readonly _authenticate;
|
|
49
63
|
private readonly _awaitAuthentication;
|
|
50
64
|
readonly requestSessionToken: (minValiditySeconds?: number) => Promise<string>;
|
|
51
65
|
readonly requestAdminSessionToken: (minValiditySeconds?: number) => Promise<string>;
|
|
@@ -53,5 +67,24 @@ export declare class SessionService<SESSION_DATA extends Record<string, unknown>
|
|
|
53
67
|
readonly hasLoggedOutFlag: () => boolean;
|
|
54
68
|
readonly clearLoggedOutFlag: () => void;
|
|
55
69
|
readonly refreshSession: () => Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Marks the start of a Studio-account sign-in, just before the page leaves for the sign-in form: the outcome becomes
|
|
72
|
+
* `signing-in`, the logged-out flag is cleared, and the page remembers that it started the sign-in, so a page that
|
|
73
|
+
* otherwise ignores a code in its address, such as a widget on the customer's own page, redeems the one it comes
|
|
74
|
+
* back with.
|
|
75
|
+
*/
|
|
76
|
+
readonly startSignIn: () => void;
|
|
77
|
+
/**
|
|
78
|
+
* The tab's own storage, whatever the mode keeps its tokens in: the sign-in returns to the tab that started it, and
|
|
79
|
+
* another tab of the same configurator must neither take nor report it. Null where the browser offers none.
|
|
80
|
+
*/
|
|
81
|
+
private readonly _getSignInStartedStorage;
|
|
82
|
+
/** Whether this tab started a Studio-account sign-in that has not come back yet. */
|
|
83
|
+
readonly hasStartedSignIn: () => boolean;
|
|
84
|
+
readonly clearStartedSignIn: () => void;
|
|
85
|
+
/** Forgets a sign-in that never left the page, such as one whose page came back from the browser's history. */
|
|
86
|
+
readonly cancelSignIn: () => void;
|
|
87
|
+
/** Records a sign-in this page started that came back without a sign-in code. */
|
|
88
|
+
readonly reportUnfinishedSignIn: () => void;
|
|
56
89
|
}
|
|
57
90
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SessionRole as e}from"@salsita-ai/contracts/api";import{ConfiguratorUnavailableError as t,InvalidDeploymentError as n}from"#package/client";import{AnalyticsEventFactory as o}from"#package/domain";import{getBrowserUserId as i}from"./browser-user-id.js";import{decodeOpaqueTokenExp as s,decodeSessionToken as a,parseSessionToken as r}from"./session-token.js";let l=(e,t=0)=>!e||e<Date.now()/1e3+t,c=e=>l(a(e)?.exp),u=(e,t)=>`configurator-session-token-${t}-${e}`,h=e=>`configurator-refresh-token-${e}`,d=e=>`configurator-logged-out-${e}`,g=(t,n,o)=>void 0===n&&null===t.refreshToken&&null!==t.sessionToken&&null!==o&&o.role!==e.Anonymous;export class SessionService{_context;_authenticationRequest=null;_configuration=null;_configurationIdentity=null;constructor(e){this._context=e}configure=e=>{this._configuration=e;let t={initialSessionToken:e.initialSessionToken,initialAdminSessionToken:e.initialAdminSessionToken,initialRefreshToken:e.initialRefreshToken,storage:e.storage};if(this._isSameConfigurationIdentity(t))return;this._configurationIdentity=t;let n=e.initialSessionToken??this._getStoredSessionToken("configurator"),o=e.initialAdminSessionToken??this._getStoredSessionToken("admin"),i=e.initialRefreshToken??this._getStoredRefreshToken();this._setSession({sessionToken:n,adminSessionToken:o,refreshToken:i,authenticated:this._getInitialAuthState(e.initialSessionToken),authenticationErrorCode:null})};_isSameConfigurationIdentity=e=>{let t=this._configurationIdentity;return null!==t&&t.initialSessionToken===e.initialSessionToken&&t.initialAdminSessionToken===e.initialAdminSessionToken&&t.initialRefreshToken===e.initialRefreshToken&&t.storage===e.storage};_getInitialAuthState=e=>e?c(e)?"stale":"authenticated":"loading";_getConfiguration=()=>{if(null===this._configuration)throw Error("Cannot use session service because it is not configured. Mount SessionServiceProvider before session-dependent providers.");return this._configuration};_setSession=e=>{this._context.sessionActions.setSessionState(e);let t=this._context.sessionSelectors.getDecodedSessionToken();this._context.setSessionContext(null===t?null:{role:t.role,data:t.data})};_storeSessionToken=(e,t)=>{this._getConfiguration().storage.setItem(u(this._context.environmentSelectors.getDeploymentId(),e),t)};_storeRefreshToken=e=>{this._getConfiguration().storage.setItem(h(this._context.environmentSelectors.getDeploymentId()),e)};_getStoredSessionToken=e=>{let t=this._getConfiguration().storage.getItem(u(this._context.environmentSelectors.getDeploymentId(),e));return!t||c(t)?null:t};_clearStoredSessionToken=e=>{this._getConfiguration().storage.removeItem(u(this._context.environmentSelectors.getDeploymentId(),e))};_getStoredRefreshToken=()=>{let e=this._getConfiguration().storage.getItem(h(this._context.environmentSelectors.getDeploymentId()));return e?l(s(e))?null:e:null};_clearStoredRefreshToken=()=>{this._getConfiguration().storage.removeItem(h(this._context.environmentSelectors.getDeploymentId()))};_handleAuthentication=async e=>{let s=this._context.getLogger();try{let t=this._context.environmentSelectors.getDeploymentId(),n=this._context.sessionSelectors.getRawSessionState(),a=n.refreshToken??void 0;if(g(n,e,this._context.sessionSelectors.getDecodedSessionToken()))return s.debug("Keeping the current session because no authorization code or refresh token is available."),{sessionToken:n.sessionToken,adminSessionToken:n.adminSessionToken??void 0,refreshToken:n.refreshToken??void 0};let l=await this._context.getUnauthenticatedClient().authenticateSession(t,e,a,i()),c=r(l.sessionToken);if(!c.success)throw Error(`Could not authenticate session because the session token payload is not valid: ${c.reason}. Check that the SessionData are correctly set.`);let u=c.payload;return this._context.specSelectors.getConfiguratorFactory().parseSessionData(u.data),s.appendToGlobalContext({environmentId:u.environmentId,role:u.role}),s.debug("New session authenticated."),this._setSession({...n,sessionToken:l.sessionToken,adminSessionToken:l.adminSessionToken??null,refreshToken:l.refreshToken??n.refreshToken,authenticated:"authenticated",authenticationErrorCode:null}),this._storeSessionToken("configurator",l.sessionToken),l.adminSessionToken?(s.debug("Admin session token found."),this._storeSessionToken("admin",l.adminSessionToken)):this._clearStoredSessionToken("admin"),l.refreshToken&&this._storeRefreshToken(l.refreshToken),this._context.getAnalyticsService().push(o.SessionAuthenticatedEvent({userRole:u.role})),l}catch(o){if(o instanceof n)throw this._context.sessionActions.setAuthenticated("stale",null),o;throw this._context.sessionActions.setAuthenticated("error",o instanceof t?"configurator-unavailable":void 0===e?"authentication-failed":"authorization-code-rejected"),this._getConfiguration().dispatchAuthenticationFailed(),o}};_awaitAuthentication=async e=>{if(null==this._authenticationRequest){let t=this._context.sessionSelectors.getRawSessionState();g(t,e,this._context.sessionSelectors.getDecodedSessionToken())||"error"!==t.authenticated&&"stale"!==t.authenticated||this._context.sessionActions.setAuthenticated("loading",null),this._authenticationRequest=this._handleAuthentication(e)}try{return await this._authenticationRequest}finally{this._authenticationRequest=null}};requestSessionToken=async(e=5)=>{let t=this._context.getLogger();t.debug("Requesting session token.");let n=this._getConfiguration().retrieveAuthorizationCode(),o=this._context.sessionSelectors.getRawSessionState().sessionToken;return null==o||void 0!==n||null!==this._authenticationRequest?(t.debug("Session token not found, code exists or authentication is in progress."),(await this._awaitAuthentication(n)).sessionToken):l(this._context.sessionSelectors.getExp(),e)?(t.debug("Session token expired, re-authenticating deployment."),(await this._awaitAuthentication(n)).sessionToken):("loading"===this._context.sessionSelectors.getRawSessionState().authenticated&&this._context.sessionActions.setAuthenticated("authenticated",null),o)};requestAdminSessionToken=async(e=5)=>{let t=this._context.getLogger();t.debug("Requesting admin session token.");let n=this._getConfiguration().retrieveAuthorizationCode(),o=this._context.sessionSelectors.getRawSessionState().adminSessionToken;if(null==o||void 0!==n||null!==this._authenticationRequest){t.debug("Admin session token not found, code exists or authentication is in progress.");let e=await this._awaitAuthentication(n);if(null==e.adminSessionToken)throw Error("Admin session token not found.");return e.adminSessionToken}if(l(a(o)?.exp,e)){t.debug("Admin session token expired, re-authenticating deployment.");let e=await this._awaitAuthentication(n);if(null==e.adminSessionToken)throw Error("Admin session token not found.");return e.adminSessionToken}return"loading"===this._context.sessionSelectors.getRawSessionState().authenticated&&this._context.sessionActions.setAuthenticated("authenticated",null),o};clearSession=()=>{this._setSession({sessionToken:null,adminSessionToken:null,refreshToken:null,authenticated:"loading",authenticationErrorCode:null}),this._clearStoredRefreshToken(),this._clearStoredSessionToken("configurator"),this._clearStoredSessionToken("admin"),this._getConfiguration().storage.setItem(d(this._context.environmentSelectors.getDeploymentId()),"true")};hasLoggedOutFlag=()=>"true"===this._getConfiguration().storage.getItem(d(this._context.environmentSelectors.getDeploymentId()));clearLoggedOutFlag=()=>{this._getConfiguration().storage.removeItem(d(this._context.environmentSelectors.getDeploymentId()))};refreshSession=async()=>{await this._awaitAuthentication(void 0)}}
|
|
1
|
+
import{InfoError as e}from"@salsita-ai/common/utils";import{SessionRole as t}from"@salsita-ai/contracts/api";import{ConfiguratorUnavailableError as n,InvalidDeploymentError as i,SignInRefusedError as o,SignInUnavailableError as s}from"#package/client";import{AnalyticsEventFactory as a}from"#package/domain";import{getBrowserUserId as r}from"./browser-user-id.js";import{decodeOpaqueTokenExp as l,decodeSessionToken as c,isStudioSignInCredential as h,parseSessionToken as u}from"./session-token.js";let g=(e,t=0)=>!e||e<Date.now()/1e3+t,d=e=>g(c(e)?.exp),S=(e,t)=>`configurator-session-token-${t}-${e}`,_=e=>`configurator-refresh-token-${e}`,f=e=>`configurator-logged-out-${e}`,m=e=>`configurator-sign-in-started-${e}`,k=(e,t,i)=>e instanceof n?"configurator-unavailable":i??(void 0===t?"authentication-failed":"authorization-code-rejected"),T=(e,n,i)=>void 0===n&&null===e.refreshToken&&null!==e.sessionToken&&null!==i&&i.role!==t.Anonymous;export class SessionService{_context;_authenticationRequest=null;_configuration=null;_configurationIdentity=null;constructor(e){this._context=e}configure=e=>{this._configuration=e;let t={initialSessionToken:e.initialSessionToken,initialAdminSessionToken:e.initialAdminSessionToken,initialRefreshToken:e.initialRefreshToken,storage:e.storage};if(this._isSameConfigurationIdentity(t))return;this._configurationIdentity=t;let n=e.initialSessionToken??this._getStoredSessionToken("configurator"),i=e.initialAdminSessionToken??this._getStoredSessionToken("admin"),o=e.initialRefreshToken??this._getStoredRefreshToken();this._setSession({sessionToken:n,adminSessionToken:i,refreshToken:o,authenticated:this._getInitialAuthState(e.initialSessionToken),authenticationErrorCode:null})};_isSameConfigurationIdentity=e=>{let t=this._configurationIdentity;return null!==t&&t.initialSessionToken===e.initialSessionToken&&t.initialAdminSessionToken===e.initialAdminSessionToken&&t.initialRefreshToken===e.initialRefreshToken&&t.storage===e.storage};_getInitialAuthState=e=>e?d(e)?"stale":"authenticated":"loading";_getConfiguration=()=>{if(null===this._configuration)throw Error("Cannot use session service because it is not configured. Mount SessionServiceProvider before session-dependent providers.");return this._configuration};_setSession=e=>{this._context.sessionActions.setSessionState(e);let t=this._context.sessionSelectors.getDecodedSessionToken();this._context.setSessionContext(null===t?null:{role:t.role,data:t.data})};_storeSessionToken=(e,t)=>{this._getConfiguration().storage.setItem(S(this._context.environmentSelectors.getDeploymentId(),e),t)};_storeRefreshToken=e=>{this._getConfiguration().storage.setItem(_(this._context.environmentSelectors.getDeploymentId()),e)};_getStoredSessionToken=e=>{let t=this._getConfiguration().storage.getItem(S(this._context.environmentSelectors.getDeploymentId(),e));return!t||d(t)?null:t};_clearStoredSessionToken=e=>{this._getConfiguration().storage.removeItem(S(this._context.environmentSelectors.getDeploymentId(),e))};_getStoredRefreshToken=()=>{let e=this._getConfiguration().storage.getItem(_(this._context.environmentSelectors.getDeploymentId()));return e?g(l(e))?null:e:null};_clearStoredRefreshToken=()=>{this._getConfiguration().storage.removeItem(_(this._context.environmentSelectors.getDeploymentId()))};_handleAuthentication=async t=>{let n=this._context.sessionSelectors.getRawSessionState(),a=h(void 0===t?{refreshToken:n.refreshToken??void 0}:{code:t}),r=a&&!1!==this._getConfiguration().visitorAfterSignInError;a&&void 0!==t&&this._context.sessionActions.setSignIn({state:"signing-in"});try{return await this._authenticate(t,{reportFailure:!r})}catch(u){var l;let n=a?(l=void 0!==t,u instanceof o?{state:"refused",account:null===u.email?null:{email:u.email,name:u.fullName}}:u instanceof s?{state:"failed",reason:"unavailable",message:u.detail}:u instanceof e?l?{state:"failed",reason:"not-completed",message:"The sign-in code was already used or has expired."}:{state:"idle"}:null):null;if(null!==n?this._context.sessionActions.setSignIn(n):a&&void 0!==t&&this._context.sessionActions.setSignIn(u instanceof i?{state:"idle"}:{state:"failed",reason:"unavailable",message:u instanceof Error?u.message:String(u)}),!r||u instanceof i)throw u;if(null===n)throw this._reportFailure(k(u,t)),u;this._context.getLogger().debug("The Studio-account sign-in ended without a session; continuing as a visitor.");let c=void 0===t&&"failed"===n.state&&"unavailable"===n.reason;c||this._clearStoredRefreshToken(),this._clearStoredSessionToken("configurator"),this._clearStoredSessionToken("admin"),this._setSession({sessionToken:null,adminSessionToken:null,refreshToken:null,authenticated:"loading",authenticationErrorCode:null});let h=await this._authenticate(void 0,{reportFailure:!0,failureCode:k(void 0,t)});return c&&this._clearStoredSessionToken("configurator"),h}};_reportFailure=e=>{this._context.sessionActions.setAuthenticated("error",e),this._getConfiguration().dispatchAuthenticationFailed()};_authenticate=async(e,t)=>{let n=this._context.getLogger();try{let t=this._context.environmentSelectors.getDeploymentId(),i=this._context.sessionSelectors.getRawSessionState(),o=i.refreshToken??void 0,s=h(void 0===e?{refreshToken:o}:{code:e});if(T(i,e,this._context.sessionSelectors.getDecodedSessionToken()))return n.debug("Keeping the current session because no authorization code or refresh token is available."),{sessionToken:i.sessionToken,adminSessionToken:i.adminSessionToken??void 0,refreshToken:i.refreshToken??void 0};let l=await this._context.getUnauthenticatedClient().authenticateSession(t,e,o,r()),c=u(l.sessionToken);if(!c.success)throw Error(`Could not authenticate session because the session token payload is not valid: ${c.reason}. Check that the SessionData are correctly set.`);let g=c.payload;return this._context.specSelectors.getConfiguratorFactory().parseSessionData(g.data),n.appendToGlobalContext({environmentId:g.environmentId,role:g.role}),n.debug("New session authenticated."),this._setSession({...i,sessionToken:l.sessionToken,adminSessionToken:l.adminSessionToken??null,refreshToken:l.refreshToken??i.refreshToken,authenticated:"authenticated",authenticationErrorCode:null}),this._storeSessionToken("configurator",l.sessionToken),l.adminSessionToken?(n.debug("Admin session token found."),this._storeSessionToken("admin",l.adminSessionToken)):this._clearStoredSessionToken("admin"),l.refreshToken&&this._storeRefreshToken(l.refreshToken),s&&this._context.sessionActions.setSignIn({state:"idle"}),this._context.getAnalyticsService().push(a.SessionAuthenticatedEvent({userRole:g.role})),l}catch(n){if(n instanceof i)throw this._context.sessionActions.setAuthenticated("stale",null),n;throw t.reportFailure&&this._reportFailure(k(n,e,t.failureCode)),n}};_awaitAuthentication=async e=>{if(null==this._authenticationRequest){let t=this._context.sessionSelectors.getRawSessionState();T(t,e,this._context.sessionSelectors.getDecodedSessionToken())||"error"!==t.authenticated&&"stale"!==t.authenticated||this._context.sessionActions.setAuthenticated("loading",null),this._authenticationRequest=this._handleAuthentication(e)}try{return await this._authenticationRequest}finally{this._authenticationRequest=null}};requestSessionToken=async(e=5)=>{let t=this._context.getLogger();t.debug("Requesting session token.");let n=this._getConfiguration().retrieveAuthorizationCode(),i=this._context.sessionSelectors.getRawSessionState().sessionToken;return null==i||void 0!==n||null!==this._authenticationRequest?(t.debug("Session token not found, code exists or authentication is in progress."),(await this._awaitAuthentication(n)).sessionToken):g(this._context.sessionSelectors.getExp(),e)?(t.debug("Session token expired, re-authenticating deployment."),(await this._awaitAuthentication(n)).sessionToken):("loading"===this._context.sessionSelectors.getRawSessionState().authenticated&&this._context.sessionActions.setAuthenticated("authenticated",null),i)};requestAdminSessionToken=async(e=5)=>{let t=this._context.getLogger();t.debug("Requesting admin session token.");let n=this._getConfiguration().retrieveAuthorizationCode(),i=this._context.sessionSelectors.getRawSessionState().adminSessionToken;if(null==i||void 0!==n||null!==this._authenticationRequest){t.debug("Admin session token not found, code exists or authentication is in progress.");let e=await this._awaitAuthentication(n);if(null==e.adminSessionToken)throw Error("Admin session token not found.");return e.adminSessionToken}if(g(c(i)?.exp,e)){t.debug("Admin session token expired, re-authenticating deployment.");let e=await this._awaitAuthentication(n);if(null==e.adminSessionToken)throw Error("Admin session token not found.");return e.adminSessionToken}return"loading"===this._context.sessionSelectors.getRawSessionState().authenticated&&this._context.sessionActions.setAuthenticated("authenticated",null),i};clearSession=()=>{let e=this._context.sessionSelectors.getRawSessionState().refreshToken??this._getStoredRefreshToken(),t=this._context.getUnauthenticatedClient();if(e&&t.signOutSession){let n=this._context.environmentSelectors.getDeploymentId();Promise.resolve().then(()=>t.signOutSession?.(n,e)).catch(e=>{this._context.getLogger().warn("Could not end the sign-in on the server.",{},e instanceof Error?e:void 0)})}this._context.sessionActions.setSignIn({state:"idle"}),this._setSession({sessionToken:null,adminSessionToken:null,refreshToken:null,authenticated:"loading",authenticationErrorCode:null}),this._clearStoredRefreshToken(),this._clearStoredSessionToken("configurator"),this._clearStoredSessionToken("admin"),this._getConfiguration().storage.setItem(f(this._context.environmentSelectors.getDeploymentId()),"true")};hasLoggedOutFlag=()=>"true"===this._getConfiguration().storage.getItem(f(this._context.environmentSelectors.getDeploymentId()));clearLoggedOutFlag=()=>{this._getConfiguration().storage.removeItem(f(this._context.environmentSelectors.getDeploymentId()))};refreshSession=async()=>{await this._awaitAuthentication(void 0)};startSignIn=()=>{this._context.sessionActions.setSignIn({state:"signing-in"}),this.clearLoggedOutFlag(),this._getSignInStartedStorage()?.setItem(m(this._context.environmentSelectors.getDeploymentId()),"true")};_getSignInStartedStorage=()=>{try{return globalThis.sessionStorage??null}catch{return null}};hasStartedSignIn=()=>this._getSignInStartedStorage()?.getItem(m(this._context.environmentSelectors.getDeploymentId()))==="true";clearStartedSignIn=()=>{this._getSignInStartedStorage()?.removeItem(m(this._context.environmentSelectors.getDeploymentId()))};cancelSignIn=()=>{this.clearStartedSignIn(),"signing-in"===this._context.sessionSelectors.getSignIn().state&&this._context.sessionActions.setSignIn({state:"idle"})};reportUnfinishedSignIn=()=>{this._context.sessionActions.setSignIn({state:"failed",reason:"not-completed",message:"No sign-in code came back to this page."})}}
|
|
@@ -36,4 +36,12 @@ export declare const decodeSessionToken: (token: string | null) => RuntimeSessio
|
|
|
36
36
|
* applied to one: every refresh token would fail the session schema and be discarded as expired.
|
|
37
37
|
*/
|
|
38
38
|
export declare const decodeOpaqueTokenExp: (token: string) => number | null;
|
|
39
|
+
/**
|
|
40
|
+
* Whether a credential belongs to a Studio-account sign-in, which the server issues, rather than to the project's own
|
|
41
|
+
* auth handler: a code the server issued, or its refresh credential, current or legacy.
|
|
42
|
+
*/
|
|
43
|
+
export declare const isStudioSignInCredential: (credential: {
|
|
44
|
+
readonly code?: string;
|
|
45
|
+
readonly refreshToken?: string;
|
|
46
|
+
}) => boolean;
|
|
39
47
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jwtDecode as e}from"jwt-decode";import{z as
|
|
1
|
+
import{jwtDecode as e}from"jwt-decode";import{z as r}from"zod";import{Branded as n,usingType as t}from"@salsita-ai/common/utils";import{SessionRole as o}from"@salsita-ai/contracts/api";import{AllowedOrigin as s,ApplicationType as i,ChunkScope as a}from"@salsita-ai/contracts/domain";let c=r.string().refine(e=>e.trim().length>0,{message:"Session token id claims cannot be empty or whitespace."}).transform(e=>n(e)),u=r.object({deploymentId:c,applicationType:r.nativeEnum(i),publishedAdminRevisionPath:r.string().optional(),environmentId:c,configurationSchemaId:c,chunkScopes:r.array(r.string().transform(t(a))).optional(),role:r.nativeEnum(o),origins:r.array(r.string().transform(t(s))),data:r.record(r.string(),r.unknown()),iat:r.number(),exp:r.number()});export const parseSessionToken=r=>{if(null===r)return{success:!1,reason:"no session token is present"};try{let n=u.safeParse(e(r));if(!n.success)return{success:!1,reason:JSON.stringify(n.error)};return{success:!0,payload:n.data}}catch(e){return{success:!1,reason:e instanceof Error?e.message:"the token could not be decoded"}}};export const decodeSessionToken=e=>{let r=parseSessionToken(e);return r.success?r.payload:null};export const decodeOpaqueTokenExp=r=>{try{return e(r).exp??null}catch{return null}};export const isStudioSignInCredential=r=>{if(void 0!==r.code)return r.code.startsWith("phoenix-");let n=r.refreshToken;if(void 0===n)return!1;if(n.startsWith("phoenix-refresh-"))return!0;try{return"phoenix:configurator-sign-in"===e(n).iss}catch{return!1}};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SessionTokenPayload } from '@salsita-ai/contracts/api';
|
|
2
2
|
import type { AllowedOrigin, ApplicationType, ChunkScope, ConfigurationSchemaId, DeploymentId, EnvironmentId } from '@salsita-ai/contracts/domain';
|
|
3
|
-
import type { SessionState } from '#package/domain';
|
|
3
|
+
import type { SessionState, SignInOutcome } from '#package/domain';
|
|
4
4
|
/**
|
|
5
5
|
* The decoded configurator session token, as issued by the server. This is the one type that is
|
|
6
6
|
* meant to track the wire contract — it models the payload rather than what the runtime keeps.
|
|
@@ -32,4 +32,9 @@ export interface RuntimeSessionClaims {
|
|
|
32
32
|
*/
|
|
33
33
|
export interface ApplicationSessionRuntime {
|
|
34
34
|
readonly sessionState: SessionState;
|
|
35
|
+
/**
|
|
36
|
+
* Outcome of the latest Studio-account sign-in. It is not derivable from the tokens: a refused or failed sign-in
|
|
37
|
+
* leaves a visitor's session, or none, behind.
|
|
38
|
+
*/
|
|
39
|
+
readonly signIn: SignInOutcome;
|
|
35
40
|
}
|
|
@@ -54,6 +54,7 @@ export declare const useDomainContextSelectors: () => {
|
|
|
54
54
|
selectActiveSessionData: import("@salsita-ai/common/utils").Selector<import("#package/domain").DomainContextSelectorState, Record<string, unknown>>;
|
|
55
55
|
selectExpressionContext: import("@salsita-ai/common/utils").Selector<import("#package/domain").DomainContextSelectorState, import("#package/domain").AnyExpressionContext>;
|
|
56
56
|
getInitializationContext: () => import("#package/domain").DomainContextInitializationContext | null;
|
|
57
|
+
getLatestSessionContext: () => import("#package/domain").DomainSessionContext | null;
|
|
57
58
|
getInitializationState: () => import("#package/domain").DomainContextInitializationState;
|
|
58
59
|
getNextInitializationContext: () => import("#package/domain").DomainContextInitializationContext;
|
|
59
60
|
getLatestLoadedData: () => import("#package/domain").ConfiguratorLoadedData | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{useMutation as t}from"@tanstack/react-query";import{useSnackbar as r}from"notistack";import{useSubscription as i}from"observable-hooks";import{createContext as o,useCallback as n,useContext as s,useEffect as a,useMemo as l,useState as m}from"react";import{skip as d}from"rxjs";import{match as p}from"ts-pattern";import{AuthorizedClient as c,LocalStorageAuthorizedPhoenixApiClient as g,MemoryAuthorizedPhoenixApiClient as u}from"#package/client";import{SYSTEM_CHUNK_KEY as f,standardWebComponentProperties as h}from"#package/domain";import{ApplicationRoutes as y,FrontendAnalyticsFactory as x,useAnalyticsService as P,useAuthenticatedClient as w,useConfiguratorDomainFactory as v,useIsDev as C,useLogger as T,usePersistenceConfig as S,usePublishedData as D,useRoutingSelectors as k,useSessionService as b,useSpecPresetSeed as E,useWebComponentProperty$ as j}from"../application-runtime/index.js";import{useConfiguratorRouting as A}from"../configurator-routing/index.js";import{useOnPresetLoadedHandler as I}from"../domain-application-context/index.js";import{useEagerObservableValue as V}from"../domain-context/index.js";import{useResolveLocalizable as $}from"../localizable/index.js";let R={id:"sdk.presets.create.error.message",message:"Could not start configuring from this preset. Please try again."},F={id:"sdk.presets.create.error.dismiss.label",message:"Dismiss"},M="phx-preset-creation-error";export const PresetSelectionContext=o(null);export const usePresetSelection=()=>{let e=s(PresetSelectionContext);if(null===e)throw Error("usePresetSelection must be used within a PresetSelectionProvider!");return e};let q=e=>t=>null===e||void 0!==t.tags&&t.tags.some(t=>e.includes(t));export const PresetSelectionProvider=o=>{let{children:s}=o,[z,B]=m(null),[U,G]=m(null),H=E(),J=w(),K=P(),L=S(),N=v(),O=C(),Q=$(),{requestSessionToken:W}=b(),
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{useMutation as t}from"@tanstack/react-query";import{useSnackbar as r}from"notistack";import{useSubscription as i}from"observable-hooks";import{createContext as o,useCallback as n,useContext as s,useEffect as a,useMemo as l,useState as m}from"react";import{skip as d}from"rxjs";import{match as p}from"ts-pattern";import{AuthorizedClient as c,LocalStorageAuthorizedPhoenixApiClient as g,MemoryAuthorizedPhoenixApiClient as u}from"#package/client";import{SYSTEM_CHUNK_KEY as f,standardWebComponentProperties as h}from"#package/domain";import{ApplicationRoutes as y,FrontendAnalyticsFactory as x,useAnalyticsService as P,useAuthenticatedClient as w,useConfiguratorDomainFactory as v,useIsDev as C,useLogger as T,usePersistenceConfig as S,usePublishedData as D,useRoutingSelectors as k,useSessionService as b,useSpecPresetSeed as E,useWebComponentProperty$ as j}from"../application-runtime/index.js";import{useConfiguratorRouting as A}from"../configurator-routing/index.js";import{useOnPresetLoadedHandler as I}from"../domain-application-context/index.js";import{useEagerObservableValue as V}from"../domain-context/index.js";import{useResolveLocalizable as $}from"../localizable/index.js";let R={id:"sdk.presets.create.error.message",message:"Could not start configuring from this preset. Please try again."},F={id:"sdk.presets.create.error.dismiss.label",message:"Dismiss"},M="phx-preset-creation-error";export const PresetSelectionContext=o(null);export const usePresetSelection=()=>{let e=s(PresetSelectionContext);if(null===e)throw Error("usePresetSelection must be used within a PresetSelectionProvider!");return e};let q=e=>t=>null===e||void 0!==t.tags&&t.tags.some(t=>e.includes(t));export const PresetSelectionProvider=o=>{let{children:s}=o,[z,B]=m(null),[U,G]=m(null),H=E(),J=w(),K=P(),L=S(),N=v(),O=C(),Q=$(),{requestSessionToken:W,refreshSession:X}=b(),Y=T(),Z=A(),_=k(),ee=D(),{enqueueSnackbar:et,closeSnackbar:er}=r(),ei=j(h.presetTags),eo=V(ei),en=I();i(l(()=>ei.pipe(d(1)),[ei]),()=>{_.getRoutingState().route!==y.Index&&Z.goToIndex()}),a(()=>{G(null),er(M)},[O,er]);let{mutateAsync:es}=t({mutationFn:n(async e=>{let{getData:t,name:r}=e,{rootEntityType:i,entities:o,modelVersion:n}=await t(),s=N.validateAndMigrateState(o,n);K.push(x.ProductSelected(i,Q(r)));let a=en?await en(s):s;return J.createConfiguration({rootEntityType:i,data:a})},[N,K,Q,J,en]),onSuccess:e=>{Z.goToConfigurationDetail(e.configurationId,e.accessToken)},onError:(e,t)=>{Y.error("Failed to create a new configuration from a preset!",{name:t.name},e),G(e)},onSettled:()=>{B(null)}}),ea=l(()=>{let e,t=(e=f in ee?ee[f].presetCategories:ee.presetCategories,{publishedPresetCategories:(e??[]).map(e=>({...e,presets:e.presets.filter(q(eo))})).filter(e=>e.presets.length>0),seedPresets:H.filter(q(eo))});return t.publishedPresetCategories.length>0?t.publishedPresetCategories.map(e=>({id:e.id,name:e.name,description:e.description,img:e.img,imgAlt:e.imgAlt,presets:e.presets.map(e=>({id:e.configurationId,name:e.name,description:e.description,img:e?.img,imgAlt:e?.imgAlt,detailTitle:e?.detailTitle,detailDescription:e?.detailDescription,getData:async()=>{let t=p(L).with({type:"server"},t=>new c(t.serverUrl,()=>e.readToken,W,X)).with({type:"local-storage"},()=>new g(N.modelVersion)).with({type:"memory"},()=>new u(N.modelVersion)).exhaustive(),r=await t.getConfigurationRevision(e.configurationId,e.revisionId);return{entities:r.data,rootEntityType:r.rootEntityType,modelVersion:r.modelVersion}}}))})):t.seedPresets.length>0?[{id:"Default",name:"Default Category",presets:t.seedPresets.map((e,t)=>({id:`${t}`,name:e.name??`${e.rootEntityType} preset - ${t}`,description:e.description??"",img:e.img,imgAlt:e.imgAlt,detailTitle:e.detailTitle,detailDescription:e.detailDescription,getData:async()=>({entities:e.initialDomainEntities,rootEntityType:e.rootEntityType,modelVersion:N.modelVersion})}))}]:[]},[ee,W,X,L,N,eo,H]),el=l(()=>ea.flatMap(e=>e.presets),[ea]),em=n(e=>{let t=el.find(t=>t.id===e);if(void 0===t)throw Error(`Preset with id ${e} not found!`);return t},[el]),ed=n(async e=>{let{id:t,getData:r,name:i}=e,o=_.getRoutingState().route===y.Index,n=!o||!O&&el.length>1;G(null),B(t);try{let{configurationId:e}=await es({getData:r,name:i});return{configurationId:e}}catch(e){throw n&&(er(M),et(Q(R),{variant:"error",key:M,persist:!0,preventDuplicate:!0,actionButton:{label:Q(F),onClick:e=>{G(null),er(e)}}})),o||G(null),e}},[el,O,_,es,et,er,Q]),ep=n(async e=>ed(em(e)),[ed,em]),ec=n(e=>{ed(em(e)).catch(()=>{})},[ed,em]),eg=el.length>1,eu=l(()=>({hasMultiplePresets:eg,presetCategories:ea,selectPreset:ec,createFromPreset:ep,selectionError:U,creatingPresetId:z}),[ec,ep,eg,ea,U,z]);return e(PresetSelectionContext.Provider,{value:eu,children:s})};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type PhoenixLayoutElementRegistration } from '#package/domain';
|
|
2
|
+
import type { AccessDeniedPageProps } from './AccessDeniedPage.js';
|
|
3
|
+
/**
|
|
4
|
+
* Registers a project's own access-denied page of the admin, shown to a person signed in to the admin who may not
|
|
5
|
+
* administer the project, or whom the project's signed-in handler refused. `phx.frontend.useSignIn()` tells them
|
|
6
|
+
* apart: `refusedAccount` names a refused account, `person` the one signed in without the Admin role.
|
|
7
|
+
*/
|
|
8
|
+
export declare const createAccessDeniedAdminPage: (Element: (props: AccessDeniedPageProps) => JSX.Element) => PhoenixLayoutElementRegistration;
|
|
9
|
+
export type CreateAccessDeniedAdminPage = (Element: (props: AccessDeniedPageProps) => JSX.Element) => PhoenixLayoutElementRegistration;
|
|
10
|
+
/** Renders the `AccessDeniedAdminPage` element: a project element registered under the name, else `defaultPage`. */
|
|
11
|
+
export declare const AccessDeniedAdminPage: (props: AccessDeniedPageProps & {
|
|
12
|
+
readonly defaultPage: (props: AccessDeniedPageProps) => JSX.Element;
|
|
13
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{createCustomPhoenixLayoutElement as t}from"#package/domain";import{PhoenixLayoutElement as n}from"../elements/index.js";let m="AccessDeniedAdminPage";export const createAccessDeniedAdminPage=e=>t(m,e);export const AccessDeniedAdminPage=t=>{let{defaultPage:r,projectName:s}=t;return e(n,{name:m,elementProps:{projectName:s},defaultSlot:r})};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type PhoenixLayoutElementRegistration } from '#package/domain';
|
|
3
|
+
export interface AccessDeniedPageProps {
|
|
4
|
+
/** The project's name, when its spec sets a page title. */
|
|
5
|
+
readonly projectName?: string | undefined;
|
|
6
|
+
readonly children?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Registers a project's own access-denied page, shown when a Studio-account sign-in is refused: the account is not
|
|
10
|
+
* invited, or the project's signed-in handler refused it. `phx.frontend.useSignIn().refusedAccount` names the account.
|
|
11
|
+
*/
|
|
12
|
+
export declare const createAccessDeniedPage: (Element: (props: AccessDeniedPageProps) => JSX.Element) => PhoenixLayoutElementRegistration;
|
|
13
|
+
export type CreateAccessDeniedPage = (Element: (props: AccessDeniedPageProps) => JSX.Element) => PhoenixLayoutElementRegistration;
|
|
14
|
+
/**
|
|
15
|
+
* Renders the `AccessDeniedPage` element: a project element registered under the name, else `defaultPage`, the page of
|
|
16
|
+
* the sign-in page that shows it.
|
|
17
|
+
*/
|
|
18
|
+
export declare const AccessDeniedPage: (props: AccessDeniedPageProps & {
|
|
19
|
+
readonly defaultPage: (props: AccessDeniedPageProps) => JSX.Element;
|
|
20
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{createCustomPhoenixLayoutElement as t}from"#package/domain";import{PhoenixLayoutElement as r}from"../elements/index.js";let s="AccessDeniedPage";export const createAccessDeniedPage=e=>t(s,e);export const AccessDeniedPage=t=>{let{defaultPage:o,projectName:n}=t;return e(r,{name:s,elementProps:{projectName:n},defaultSlot:o})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{useCallback as t,useEffect as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{useCallback as t,useEffect as n,useMemo as o,useRef as i}from"react";import{distinctUntilChanged as a,filter as r,skip as s}from"rxjs";import{match as l}from"ts-pattern";import{standardWebComponentEvents as d,standardWebComponentProperties as c}from"#package/domain";import{ApplicationType as u,DomainSessionProvider as h,INTEGRATION_MODE_SETTINGS as m,SessionProvider as g,isStudioSignInCredential as f,useApplicationRuntime as S,useApplicationRuntimeSelector as p,useDispatchWebComponentEvent as v,useIsLoaderHosted as k,useLogger as w,useOptionalApplicationType as x,useRawSession as b,useSessionService as j,useWebComponentProperty$ as T,useWebComponentPropertyValue as C}from"../application-runtime/index.js";import{usePatientObservableValue as U}from"../domain-context/index.js";import{BuiltInLoadingPhase as A,useLoadingPhase as E}from"../loading-state/index.js";import{ConfiguratorUnavailablePage as F}from"./ConfiguratorUnavailablePage.js";import{NotAuthenticatedPage as P}from"./NotAuthenticatedPage.js";import{useStudioFrameReport as I}from"./studio-frame.js";let y="code",z=()=>null;export const SessionServiceProvider=$=>{let{children:q,notAuthenticatedFallback:M=P,configuratorUnavailableFallback:N=F,loadingFallback:R=z}=$,L=S(),W=w(),B=j(),D=b(),G=p(L.selectors.session.getSession),H=p(L.selectors.sessionContext.getSessionContext),J=C(c.sessionToken),K=C(c.adminSessionToken),O=C(c.refreshToken),Q=T(c.integrationMode),V=T(c.authorizationCode),X=i(!1),Y=t(()=>{if(V.value){let e=Q.value;"local-storage"===m[e].authenticationStorage&&W.warn(`authorizationCode WC prop used in '${e}' mode. This is discouraged — tokens stored in localStorage leak across tabs. Use 'handoff' or 'headless' mode instead.`);let t=V.value;return V.next(void 0),t}let e=new URL(window.location.href),t=e.searchParams.get(y),n=!X.current&&B.hasStartedSignIn();X.current=!0;let o=null!==t&&f({code:t});if(n&&(B.clearStartedSignIn(),o||B.reportUnfinishedSignIn()),m[Q.value].consumeCodeFromUrl||n&&o)return e.searchParams.delete(y),history.replaceState(null,"",e),t??void 0},[V,Q,W,B]),Z=U(o(()=>V.pipe(s(1),r(e=>void 0!==e),a()),[V]),void 0),_=C(c.integrationMode),ee=m[_].authenticationStorage,et=v(d.authenticationFailed),en=o(()=>l(ee).with("local-storage",()=>localStorage).with("session-storage",()=>sessionStorage).exhaustive(),[ee]),eo=!m[_].hideSignInElements;n(()=>{B.configure({initialSessionToken:J,initialAdminSessionToken:K,initialRefreshToken:O,retrieveAuthorizationCode:Y,dispatchAuthenticationFailed:et,storage:en,visitorAfterSignInError:eo})},[B,J,K,O,Y,et,en,eo]),n(()=>{"loading"===D.authenticated&&B.requestSessionToken().catch(e=>{let t=e instanceof Error?e:Error(`Unknown error ${e}`);W.warn("Session could not be authenticated",{},t)})},[B,D.authenticated,W]),n(()=>{Z&&(W.debug("New authorization code received, re-authenticating session"),B.requestSessionToken().catch(e=>{let t=e instanceof Error?e:Error(`Unknown error ${e}`);W.warn("Session could not be authenticated",{},t)}))},[Z,B,W]);let ei=I(),ea=x()===u.Admin,er=i(null);n(()=>{let e=l(D).with({authenticated:"authenticated"},({rawAdminSessionToken:e})=>ea&&null===e?"denied":"ready").with({authenticated:"error"},()=>"ready"===er.current?"denied":"failed").otherwise(()=>null);null!==e&&e!==er.current&&ei(e)&&(er.current=e)},[D,ei,ea]);let es=k();return(E({id:A.SessionAuth,label:"Authenticating session…"},"loading"===D.authenticated),"loading"===D.authenticated)?es?null:e(R,{}):"error"===D.authenticated&&"configurator-unavailable"===D.authenticationErrorCode?e(g,{value:D,children:e(N,{})}):"error"===D.authenticated?e(g,{value:D,children:e(M,{})}):null===H?null:e(g,{value:G,children:e(h,{value:H,children:q})})};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { SessionServiceProvider } from './SessionServiceProvider.js';
|
|
2
2
|
export { ConfigurationNotFoundPage, type ConfigurationNotFoundPageProps } from './ConfigurationNotFoundPage.js';
|
|
3
3
|
export { NotAuthenticatedPage, createNotAuthenticatedPage, type CreateNotAuthenticatedPage, } from './NotAuthenticatedPage.js';
|
|
4
|
+
export { useSignIn, type SignIn, type SignInOptions, type UseSignIn } from './use-sign-in.js';
|
|
5
|
+
export { AccessDeniedPage, createAccessDeniedPage, type AccessDeniedPageProps, type CreateAccessDeniedPage, } from './AccessDeniedPage.js';
|
|
6
|
+
export { AccessDeniedAdminPage, createAccessDeniedAdminPage, type CreateAccessDeniedAdminPage, } from './AccessDeniedAdminPage.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{SessionServiceProvider}from"./SessionServiceProvider.js";export{ConfigurationNotFoundPage}from"./ConfigurationNotFoundPage.js";export{NotAuthenticatedPage,createNotAuthenticatedPage}from"./NotAuthenticatedPage.js";
|
|
1
|
+
export{SessionServiceProvider}from"./SessionServiceProvider.js";export{ConfigurationNotFoundPage}from"./ConfigurationNotFoundPage.js";export{NotAuthenticatedPage,createNotAuthenticatedPage}from"./NotAuthenticatedPage.js";export{useSignIn}from"./use-sign-in.js";export{AccessDeniedPage,createAccessDeniedPage}from"./AccessDeniedPage.js";export{AccessDeniedAdminPage,createAccessDeniedAdminPage}from"./AccessDeniedAdminPage.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** What the Studio sign-in form is opened with. */
|
|
2
|
+
export interface SignInAddressInput {
|
|
3
|
+
readonly serverUrl: string;
|
|
4
|
+
readonly deploymentId: string;
|
|
5
|
+
/** The page's own address, which the form sends the person back to without its used `code`. */
|
|
6
|
+
readonly pageHref: string;
|
|
7
|
+
/** Whether the form asks which account continues: after a sign-out or a refusal, or when the page asks for another account. */
|
|
8
|
+
readonly selectAccount: boolean;
|
|
9
|
+
/** Whether the admin, not the configurator, asks: the workspace's audit log names which one was signed in to. */
|
|
10
|
+
readonly admin: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** The address of the Studio sign-in form on the server for a configurator or its admin. */
|
|
13
|
+
export declare const signInAddress: ({ serverUrl, deploymentId, pageHref, selectAccount, admin }: SignInAddressInput) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const signInAddress=({serverUrl:e,deploymentId:r,pageHref:a,selectAccount:s,admin:t})=>{let n=new URL(a);n.searchParams.delete("code");let c=new URL(`/deployments/${r}/auth`,e);return c.searchParams.set("returnUrl",n.href),c.searchParams.set("application",t?"admin":"configurator"),s&&c.searchParams.set("prompt","select_account"),c.href};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type EmbeddedFrameMessage } from '@salsita-ai/contracts/api';
|
|
2
|
+
/**
|
|
3
|
+
* Reports the frame's state to Builder Studio, which shows this page embedded in its frame. The message goes only to
|
|
4
|
+
* the Studio origin the server names, so a page that frames this one elsewhere learns nothing; outside a frame, or in
|
|
5
|
+
* any integration mode but `embedded`, nothing is sent.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useStudioFrameReport: () => (type: EmbeddedFrameMessage['type']) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useCallback as t}from"react";import{EMBEDDED_FRAME_SOURCE as e}from"@salsita-ai/contracts/api";import{createApiBaseClient as r}from"#package/client";import{standardWebComponentProperties as o}from"#package/domain";import{INTEGRATION_MODE_SETTINGS as n,usePersistenceConfig as i,useWebComponentPropertyValue as a}from"../application-runtime/index.js";let l=new Map;export const useStudioFrameReport=()=>{let p=a(o.integrationMode),s=i(),u="server"===s.type?s.serverUrl:null,m=n[p].reportsToStudio;return t(t=>!!m&&null!==u&&window.parent!==window&&((t=>{let e=l.get(t);if(e)return e;let o=r(t).GET("/auth/config").then(({data:t})=>t?.studioOrigin??null).catch(()=>null);return l.set(t,o),o})(u).then(r=>{null!==r&&window.parent.postMessage({source:e,type:t},r)}),!0),[m,u])};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type SignInAccount, type SignInOutcome } from '#package/domain';
|
|
2
|
+
/** How `SignIn.signIn` opens the Studio sign-in form. */
|
|
3
|
+
export interface SignInOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Whether the form asks which account continues even though the person is signed in to Studio, as "Sign in with
|
|
6
|
+
* another account" needs. Without it Studio signs its own account back in without a form.
|
|
7
|
+
*/
|
|
8
|
+
readonly anotherAccount?: boolean | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface SignIn {
|
|
11
|
+
/**
|
|
12
|
+
* Where the latest Studio-account sign-in on this page stands: `idle` (none, or it completed), `signing-in`,
|
|
13
|
+
* `refused` (the account is not invited, or the project's signed-in handler refused it) or `failed` (it did not
|
|
14
|
+
* finish, see `failure`).
|
|
15
|
+
*/
|
|
16
|
+
readonly state: SignInOutcome['state'];
|
|
17
|
+
/** The person signed in now, null for a visitor. `name` is their Studio display name, null when they have none. */
|
|
18
|
+
readonly person: SignInAccount | null;
|
|
19
|
+
/** With `state: 'refused'`, the account that was refused, when the server named it. */
|
|
20
|
+
readonly refusedAccount: SignInAccount | null;
|
|
21
|
+
/**
|
|
22
|
+
* With `state: 'failed'`: `not-completed` when the person came back without being signed in, such as with a code
|
|
23
|
+
* that was already used or expired; `unavailable` when the server could not complete the sign-in right now and
|
|
24
|
+
* trying again may help. `message` is the technical detail.
|
|
25
|
+
*/
|
|
26
|
+
readonly failure: {
|
|
27
|
+
readonly reason: 'not-completed' | 'unavailable';
|
|
28
|
+
readonly message: string;
|
|
29
|
+
} | null;
|
|
30
|
+
/** Whether the person signed out on this page and has not signed in since; a sign-in page then waits for a click. */
|
|
31
|
+
readonly signedOut: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether sign-in elements stay hidden: in Studio's frame, where Studio shows the account, and where the
|
|
34
|
+
* configurator has no server to sign in with.
|
|
35
|
+
*/
|
|
36
|
+
readonly hidden: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Sends the person to the Studio sign-in form, after saving the configuration's latest change, and back to this
|
|
39
|
+
* address. After a sign-out or a refusal, or with `anotherAccount`, the form asks which account continues.
|
|
40
|
+
*/
|
|
41
|
+
readonly signIn: (options?: SignInOptions) => Promise<void>;
|
|
42
|
+
/** Ends this configurator's sign-in; where visitors may use the configurator, the person continues as one. */
|
|
43
|
+
readonly signOut: () => void;
|
|
44
|
+
}
|
|
45
|
+
export type UseSignIn = () => SignIn;
|
|
46
|
+
/**
|
|
47
|
+
* The Studio-account sign-in of the configurator or its admin: its outcome, the person signed in, and the actions a
|
|
48
|
+
* sign-in page or an account control needs.
|
|
49
|
+
*/
|
|
50
|
+
export declare const useSignIn: UseSignIn;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useCallback as e,useEffect as s,useMemo as t,useState as n}from"react";import{SessionRole as a}from"@salsita-ai/contracts/api";import{standardWebComponentProperties as o}from"#package/domain";import{ApplicationType as i,INTEGRATION_MODE_SETTINGS as r,useApplicationRuntime as l,useApplicationRuntimeSelector as d,useDomainApplicationProps as u,useOptionalApplicationType as m,useRawSession as c,useSessionService as g,useWebComponentPropertyValue as f}from"../application-runtime/index.js";import{signInAddress as p}from"./sign-in-address.js";export const useSignIn=()=>{let w=l(),y=g(),h=c(),P=d(w.selectors.session.getSignIn),{deploymentId:S,persistenceConfig:v}=u(),A=f(o.integrationMode),I=m(),L="server"===v.type?v.serverUrl:null,x=r[A].hideSignInElements||null===L,[E]=n(()=>y.hasLoggedOutFlag());s(()=>{let e=e=>{e.persisted&&y.cancelSignIn()};return window.addEventListener("pageshow",e),()=>window.removeEventListener("pageshow",e)},[y]);let j=e(async()=>{I!==i.Admin&&await Promise.race([Promise.resolve().then(()=>w.selectors.domainApplicationContext.configurator.getSystems().configurationPersistSystem.flush()).catch(()=>void 0),new Promise(e=>setTimeout(e,5e3))])},[I,w]),F=e(async e=>{if(x||null===L)return;let s=e?.anotherAccount===!0||y.hasLoggedOutFlag()||"refused"===P.state;y.startSignIn(),await j();let t=p({serverUrl:L,deploymentId:S,pageHref:window.location.href,selectAccount:s,admin:I===i.Admin});window.location.assign(t)},[x,L,y,P.state,j,S,I]),O=e(()=>{y.clearSession()},[y]),k=null===h.sessionPayload||h.sessionPayload.role===a.Anonymous;return t(()=>({state:P.state,person:k?null:(e=>{let s=e?.emailAddress;if("string"!=typeof s||""===s)return null;let t=e?.fullName;return{email:s,name:"string"==typeof t&&""!==t?t:null}})(h.sessionPayload?.data),refusedAccount:"refused"===P.state?P.account:null,failure:"failed"===P.state?{reason:P.reason,message:P.message}:null,signedOut:E,hidden:x,signIn:F,signOut:O}),[P,k,h.sessionPayload,E,x,F,O])};
|