@kortix/sdk 0.13.53 → 0.13.55
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/README.md +141 -8
- package/dist/browser/cache/idb-sync-cache.d.ts +44 -22
- package/dist/browser/cache/idb-sync-cache.d.ts.map +1 -1
- package/dist/browser/cache/idb-sync-cache.js +113 -257
- package/dist/browser/cache/idb-sync-cache.js.map +1 -1
- package/dist/browser/session-sync/server-transcript-mirror.d.ts +0 -1
- package/dist/browser/session-sync/server-transcript-mirror.d.ts.map +1 -1
- package/dist/browser/session-sync/server-transcript-mirror.js +3 -2
- package/dist/browser/session-sync/server-transcript-mirror.js.map +1 -1
- package/dist/browser/stores/sandbox-connection-store.d.ts +8 -0
- package/dist/browser/stores/sandbox-connection-store.d.ts.map +1 -1
- package/dist/browser/stores/sandbox-connection-store.js +7 -0
- package/dist/browser/stores/sandbox-connection-store.js.map +1 -1
- package/dist/browser/stores/sync-store.d.ts +20 -0
- package/dist/browser/stores/sync-store.d.ts.map +1 -1
- package/dist/browser/stores/sync-store.js +71 -46
- package/dist/browser/stores/sync-store.js.map +1 -1
- package/dist/core/auth/app-viewer.d.ts +74 -2
- package/dist/core/auth/app-viewer.d.ts.map +1 -1
- package/dist/core/auth/app-viewer.js +95 -2
- package/dist/core/auth/app-viewer.js.map +1 -1
- package/dist/core/auth/kortix-member.d.ts +111 -0
- package/dist/core/auth/kortix-member.d.ts.map +1 -0
- package/dist/core/auth/kortix-member.js +232 -0
- package/dist/core/auth/kortix-member.js.map +1 -0
- package/dist/core/client/facade-commerce.d.ts +5 -1
- package/dist/core/client/facade-commerce.d.ts.map +1 -1
- package/dist/core/client/facade-commerce.js +5 -1
- package/dist/core/client/facade-commerce.js.map +1 -1
- package/dist/core/client/kortix.d.ts +117 -8
- package/dist/core/client/kortix.d.ts.map +1 -1
- package/dist/core/client/kortix.js +24 -1
- package/dist/core/client/kortix.js.map +1 -1
- package/dist/core/client/project-access-resources.d.ts +37 -2
- package/dist/core/client/project-access-resources.d.ts.map +1 -1
- package/dist/core/client/project-access-resources.js +26 -0
- package/dist/core/client/project-access-resources.js.map +1 -1
- package/dist/core/client/project-connectors.d.ts +9 -1
- package/dist/core/client/project-connectors.d.ts.map +1 -1
- package/dist/core/client/project-connectors.js +29 -0
- package/dist/core/client/project-connectors.js.map +1 -1
- package/dist/core/client/project-core.d.ts.map +1 -1
- package/dist/core/client/project-operations-admin.d.ts +17 -0
- package/dist/core/client/project-operations-admin.d.ts.map +1 -1
- package/dist/core/client/project-operations-admin.js +6 -0
- package/dist/core/client/project-operations-admin.js.map +1 -1
- package/dist/core/client/project-operations-workspace.d.ts +9 -0
- package/dist/core/client/project-operations-workspace.d.ts.map +1 -1
- package/dist/core/client/project-operations-workspace.js +6 -0
- package/dist/core/client/project-operations-workspace.js.map +1 -1
- package/dist/core/client/project-operations.d.ts +21 -1
- package/dist/core/client/project-operations.d.ts.map +1 -1
- package/dist/core/client/project-operations.js +2 -0
- package/dist/core/client/project-operations.js.map +1 -1
- package/dist/core/client/session-handle.d.ts +20 -2
- package/dist/core/client/session-handle.d.ts.map +1 -1
- package/dist/core/client/session-lifecycle-resources.d.ts +29 -2
- package/dist/core/client/session-lifecycle-resources.d.ts.map +1 -1
- package/dist/core/client/session-lifecycle-resources.js +13 -1
- package/dist/core/client/session-lifecycle-resources.js.map +1 -1
- package/dist/core/files/client.d.ts +8 -0
- package/dist/core/files/client.d.ts.map +1 -1
- package/dist/core/files/client.js +52 -10
- package/dist/core/files/client.js.map +1 -1
- package/dist/core/http/api/errors.d.ts +1 -1
- package/dist/core/http/api/errors.js +1 -1
- package/dist/core/http/authenticated-request.d.ts +14 -0
- package/dist/core/http/authenticated-request.d.ts.map +1 -0
- package/dist/core/http/authenticated-request.js +21 -0
- package/dist/core/http/authenticated-request.js.map +1 -0
- package/dist/core/http/response-error.d.ts.map +1 -1
- package/dist/core/http/response-error.js +12 -5
- package/dist/core/http/response-error.js.map +1 -1
- package/dist/core/http/transport.d.ts.map +1 -1
- package/dist/core/http/transport.js +10 -1
- package/dist/core/http/transport.js.map +1 -1
- package/dist/core/models/composer-model.d.ts +3 -1
- package/dist/core/models/composer-model.d.ts.map +1 -1
- package/dist/core/models/composer-model.js +4 -2
- package/dist/core/models/composer-model.js.map +1 -1
- package/dist/core/models/model-visibility.d.ts +4 -2
- package/dist/core/models/model-visibility.d.ts.map +1 -1
- package/dist/core/models/model-visibility.js +12 -8
- package/dist/core/models/model-visibility.js.map +1 -1
- package/dist/core/rest/platform-client/client-policy.d.ts +21 -0
- package/dist/core/rest/platform-client/client-policy.d.ts.map +1 -0
- package/dist/core/rest/platform-client/client-policy.js +49 -0
- package/dist/core/rest/platform-client/client-policy.js.map +1 -0
- package/dist/core/rest/platform-client/index.d.ts +1 -0
- package/dist/core/rest/platform-client/index.d.ts.map +1 -1
- package/dist/core/rest/platform-client/index.js +1 -0
- package/dist/core/rest/platform-client/index.js.map +1 -1
- package/dist/core/rest/platform-client/lifecycle.d.ts.map +1 -1
- package/dist/core/rest/platform-client/lifecycle.js.map +1 -1
- package/dist/core/rest/platform-client/shared.d.ts.map +1 -1
- package/dist/core/rest/platform-client/shared.js +0 -4
- package/dist/core/rest/platform-client/shared.js.map +1 -1
- package/dist/core/rest/projects-client/accounts.d.ts +13 -0
- package/dist/core/rest/projects-client/accounts.d.ts.map +1 -1
- package/dist/core/rest/projects-client/accounts.js.map +1 -1
- package/dist/core/rest/projects-client/admin-providers.d.ts +61 -0
- package/dist/core/rest/projects-client/admin-providers.d.ts.map +1 -1
- package/dist/core/rest/projects-client/admin-providers.js +6 -0
- package/dist/core/rest/projects-client/admin-providers.js.map +1 -1
- package/dist/core/rest/projects-client/apps-fleet.d.ts +99 -0
- package/dist/core/rest/projects-client/apps-fleet.d.ts.map +1 -0
- package/dist/core/rest/projects-client/apps-fleet.js +58 -0
- package/dist/core/rest/projects-client/apps-fleet.js.map +1 -0
- package/dist/core/rest/projects-client/apps.d.ts +246 -16
- package/dist/core/rest/projects-client/apps.d.ts.map +1 -1
- package/dist/core/rest/projects-client/apps.js +30 -1
- package/dist/core/rest/projects-client/apps.js.map +1 -1
- package/dist/core/rest/projects-client/billing.d.ts +45 -6
- package/dist/core/rest/projects-client/billing.d.ts.map +1 -1
- package/dist/core/rest/projects-client/billing.js +32 -25
- package/dist/core/rest/projects-client/billing.js.map +1 -1
- package/dist/core/rest/projects-client/change-requests.d.ts +10 -0
- package/dist/core/rest/projects-client/change-requests.d.ts.map +1 -1
- package/dist/core/rest/projects-client/change-requests.js +4 -0
- package/dist/core/rest/projects-client/change-requests.js.map +1 -1
- package/dist/core/rest/projects-client/connector-run.d.ts +135 -0
- package/dist/core/rest/projects-client/connector-run.d.ts.map +1 -0
- package/dist/core/rest/projects-client/connector-run.js +211 -0
- package/dist/core/rest/projects-client/connector-run.js.map +1 -0
- package/dist/core/rest/projects-client/connectors.d.ts +80 -1
- package/dist/core/rest/projects-client/connectors.d.ts.map +1 -1
- package/dist/core/rest/projects-client/connectors.js +25 -4
- package/dist/core/rest/projects-client/connectors.js.map +1 -1
- package/dist/core/rest/projects-client/drives.d.ts +201 -0
- package/dist/core/rest/projects-client/drives.d.ts.map +1 -0
- package/dist/core/rest/projects-client/drives.js +124 -0
- package/dist/core/rest/projects-client/drives.js.map +1 -0
- package/dist/core/rest/projects-client/files.d.ts +41 -0
- package/dist/core/rest/projects-client/files.d.ts.map +1 -1
- package/dist/core/rest/projects-client/files.js +49 -0
- package/dist/core/rest/projects-client/files.js.map +1 -1
- package/dist/core/rest/projects-client/index.d.ts +5 -0
- package/dist/core/rest/projects-client/index.d.ts.map +1 -1
- package/dist/core/rest/projects-client/index.js +5 -0
- package/dist/core/rest/projects-client/index.js.map +1 -1
- package/dist/core/rest/projects-client/notifications.d.ts +160 -0
- package/dist/core/rest/projects-client/notifications.d.ts.map +1 -0
- package/dist/core/rest/projects-client/notifications.js +105 -0
- package/dist/core/rest/projects-client/notifications.js.map +1 -0
- package/dist/core/rest/projects-client/projects.d.ts +24 -9
- package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
- package/dist/core/rest/projects-client/projects.js +7 -1
- package/dist/core/rest/projects-client/projects.js.map +1 -1
- package/dist/core/rest/projects-client/session-attachments.d.ts.map +1 -1
- package/dist/core/rest/projects-client/session-attachments.js +0 -3
- package/dist/core/rest/projects-client/session-attachments.js.map +1 -1
- package/dist/core/rest/projects-client/session-prompt-actions.d.ts +29 -0
- package/dist/core/rest/projects-client/session-prompt-actions.d.ts.map +1 -0
- package/dist/core/rest/projects-client/session-prompt-actions.js +13 -0
- package/dist/core/rest/projects-client/session-prompt-actions.js.map +1 -0
- package/dist/core/rest/projects-client/session-reminders.d.ts +17 -0
- package/dist/core/rest/projects-client/session-reminders.d.ts.map +1 -1
- package/dist/core/rest/projects-client/session-reminders.js +40 -0
- package/dist/core/rest/projects-client/session-reminders.js.map +1 -1
- package/dist/core/rest/projects-client/session-sandbox.d.ts +23 -8
- package/dist/core/rest/projects-client/session-sandbox.d.ts.map +1 -1
- package/dist/core/rest/projects-client/session-sandbox.js +28 -10
- package/dist/core/rest/projects-client/session-sandbox.js.map +1 -1
- package/dist/core/rest/projects-client/sessions.d.ts +41 -1
- package/dist/core/rest/projects-client/sessions.d.ts.map +1 -1
- package/dist/core/rest/projects-client/sessions.js +35 -3
- package/dist/core/rest/projects-client/sessions.js.map +1 -1
- package/dist/core/rest/projects-client/tokens.d.ts +5 -0
- package/dist/core/rest/projects-client/tokens.d.ts.map +1 -1
- package/dist/core/rest/projects-client/tokens.js.map +1 -1
- package/dist/core/rest/projects-client/triggers.d.ts +123 -1
- package/dist/core/rest/projects-client/triggers.d.ts.map +1 -1
- package/dist/core/rest/projects-client/triggers.js +16 -0
- package/dist/core/rest/projects-client/triggers.js.map +1 -1
- package/dist/core/session/control-stream.d.ts +112 -16
- package/dist/core/session/control-stream.d.ts.map +1 -1
- package/dist/core/session/control-stream.js +292 -41
- package/dist/core/session/control-stream.js.map +1 -1
- package/dist/core/session/message-queue.d.ts +35 -9
- package/dist/core/session/message-queue.d.ts.map +1 -1
- package/dist/core/session/message-queue.js +23 -6
- package/dist/core/session/message-queue.js.map +1 -1
- package/dist/core/session/runtime-gone.d.ts +19 -0
- package/dist/core/session/runtime-gone.d.ts.map +1 -0
- package/dist/core/session/runtime-gone.js +28 -0
- package/dist/core/session/runtime-gone.js.map +1 -0
- package/dist/core/session/working-server.d.ts +41 -0
- package/dist/core/session/working-server.d.ts.map +1 -0
- package/dist/core/session/working-server.js +76 -0
- package/dist/core/session/working-server.js.map +1 -0
- package/dist/core/session-log/guard.d.ts +18 -0
- package/dist/core/session-log/guard.d.ts.map +1 -0
- package/dist/core/session-log/guard.js +114 -0
- package/dist/core/session-log/guard.js.map +1 -0
- package/dist/core/session-log/index.d.ts +16 -0
- package/dist/core/session-log/index.d.ts.map +1 -0
- package/dist/core/session-log/index.js +15 -0
- package/dist/core/session-log/index.js.map +1 -0
- package/dist/core/session-log/saved-log.d.ts +23 -0
- package/dist/core/session-log/saved-log.d.ts.map +1 -0
- package/dist/core/session-log/saved-log.js +34 -0
- package/dist/core/session-log/saved-log.js.map +1 -0
- package/dist/core/session-log/source.d.ts +36 -0
- package/dist/core/session-log/source.d.ts.map +1 -0
- package/dist/core/session-log/source.js +52 -0
- package/dist/core/session-log/source.js.map +1 -0
- package/dist/core/session-log/store.d.ts +25 -0
- package/dist/core/session-log/store.d.ts.map +1 -0
- package/dist/core/session-log/store.js +170 -0
- package/dist/core/session-log/store.js.map +1 -0
- package/dist/core/session-log/types.d.ts +371 -0
- package/dist/core/session-log/types.d.ts.map +1 -0
- package/dist/core/session-log/types.js +24 -0
- package/dist/core/session-log/types.js.map +1 -0
- package/dist/core/session-log/v1-view.d.ts +30 -0
- package/dist/core/session-log/v1-view.d.ts.map +1 -0
- package/dist/core/session-log/v1-view.js +106 -0
- package/dist/core/session-log/v1-view.js.map +1 -0
- package/dist/core/session-log/v1.d.ts +107 -0
- package/dist/core/session-log/v1.d.ts.map +1 -0
- package/dist/core/session-log/v1.js +495 -0
- package/dist/core/session-log/v1.js.map +1 -0
- package/dist/core/session-sync/copy-store-types.d.ts +29 -0
- package/dist/core/session-sync/copy-store-types.d.ts.map +1 -0
- package/dist/core/session-sync/copy-store-types.js +2 -0
- package/dist/core/session-sync/copy-store-types.js.map +1 -0
- package/dist/core/session-sync/saved-copy-store.d.ts +11 -4
- package/dist/core/session-sync/saved-copy-store.d.ts.map +1 -1
- package/dist/core/session-sync/saved-copy-store.js +36 -8
- package/dist/core/session-sync/saved-copy-store.js.map +1 -1
- package/dist/core/session-sync/session-sync-controller.d.ts +9 -0
- package/dist/core/session-sync/session-sync-controller.d.ts.map +1 -1
- package/dist/core/session-sync/session-sync-controller.js +12 -1
- package/dist/core/session-sync/session-sync-controller.js.map +1 -1
- package/dist/core/stream/event-stream.d.ts +2 -3
- package/dist/core/stream/event-stream.d.ts.map +1 -1
- package/dist/core/stream/event-stream.js +8 -10
- package/dist/core/stream/event-stream.js.map +1 -1
- package/dist/core/turns/parts.d.ts.map +1 -1
- package/dist/core/turns/parts.js +3 -0
- package/dist/core/turns/parts.js.map +1 -1
- package/dist/core/turns/segments/index.d.ts +1 -0
- package/dist/core/turns/segments/index.d.ts.map +1 -1
- package/dist/core/turns/segments/index.js +1 -0
- package/dist/core/turns/segments/index.js.map +1 -1
- package/dist/core/turns/segments/work-split.d.ts +16 -0
- package/dist/core/turns/segments/work-split.d.ts.map +1 -0
- package/dist/core/turns/segments/work-split.js +59 -0
- package/dist/core/turns/segments/work-split.js.map +1 -0
- package/dist/core/turns/segments/working-turn.d.ts +23 -0
- package/dist/core/turns/segments/working-turn.d.ts.map +1 -1
- package/dist/core/turns/segments/working-turn.js +22 -0
- package/dist/core/turns/segments/working-turn.js.map +1 -1
- package/dist/core/warm-session-pool.d.ts +85 -0
- package/dist/core/warm-session-pool.d.ts.map +1 -0
- package/dist/core/warm-session-pool.js +180 -0
- package/dist/core/warm-session-pool.js.map +1 -0
- package/dist/deprecated/api-client.d.ts +1 -1
- package/dist/deprecated/api-client.js +1 -1
- package/dist/deprecated/auth.d.ts +1 -1
- package/dist/deprecated/auth.js +1 -1
- package/dist/deprecated/config.d.ts +1 -1
- package/dist/deprecated/config.js +1 -1
- package/dist/deprecated/event-stream.d.ts +1 -1
- package/dist/deprecated/event-stream.js +1 -1
- package/dist/deprecated/feature-flags.d.ts +1 -1
- package/dist/deprecated/feature-flags.js +1 -1
- package/dist/deprecated/files.d.ts +1 -1
- package/dist/deprecated/files.js +1 -1
- package/dist/deprecated/fresh-sessions.d.ts +1 -1
- package/dist/deprecated/fresh-sessions.js +1 -1
- package/dist/deprecated/idb-sync-cache.d.ts +3 -3
- package/dist/deprecated/idb-sync-cache.js +3 -3
- package/dist/deprecated/instance-routes.d.ts +1 -1
- package/dist/deprecated/instance-routes.js +1 -1
- package/dist/deprecated/opencode-client.d.ts +1 -1
- package/dist/deprecated/opencode-client.js +1 -1
- package/dist/deprecated/opencode-errors.d.ts +1 -1
- package/dist/deprecated/opencode-errors.js +1 -1
- package/dist/deprecated/opencode-pending-store.d.ts +3 -3
- package/dist/deprecated/opencode-pending-store.js +3 -3
- package/dist/deprecated/platform-client.d.ts +1 -1
- package/dist/deprecated/platform-client.js +1 -1
- package/dist/deprecated/projects-client.d.ts +1 -1
- package/dist/deprecated/projects-client.js +1 -1
- package/dist/deprecated/sandbox-connection-store.d.ts +3 -3
- package/dist/deprecated/sandbox-connection-store.js +3 -3
- package/dist/deprecated/server-store.d.ts +3 -3
- package/dist/deprecated/server-store.js +3 -3
- package/dist/deprecated/session-url.d.ts +1 -1
- package/dist/deprecated/session-url.js +1 -1
- package/dist/deprecated/session.d.ts +1 -1
- package/dist/deprecated/session.js +1 -1
- package/dist/deprecated/sync-store.d.ts +3 -3
- package/dist/deprecated/sync-store.js +3 -3
- package/dist/deprecated/turns.d.ts +1 -1
- package/dist/deprecated/turns.js +1 -1
- package/dist/index.d.ts +13 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/opencode-pending-store.d.ts +3 -2
- package/dist/internal/opencode-pending-store.d.ts.map +1 -1
- package/dist/internal/opencode-pending-store.js +3 -2
- package/dist/internal/opencode-pending-store.js.map +1 -1
- package/dist/internal/sandbox-connection-store.d.ts +3 -2
- package/dist/internal/sandbox-connection-store.d.ts.map +1 -1
- package/dist/internal/sandbox-connection-store.js +3 -2
- package/dist/internal/sandbox-connection-store.js.map +1 -1
- package/dist/internal/server-store.d.ts +3 -2
- package/dist/internal/server-store.d.ts.map +1 -1
- package/dist/internal/server-store.js +3 -2
- package/dist/internal/server-store.js.map +1 -1
- package/dist/internal/sync-store.d.ts +3 -2
- package/dist/internal/sync-store.d.ts.map +1 -1
- package/dist/internal/sync-store.js +3 -2
- package/dist/internal/sync-store.js.map +1 -1
- package/dist/kortix.esm.min.js +33 -33
- package/dist/kortix.global.js +34 -34
- package/dist/node/app-guard.d.ts +16 -0
- package/dist/node/app-guard.d.ts.map +1 -1
- package/dist/node/app-guard.js +36 -15
- package/dist/node/app-guard.js.map +1 -1
- package/dist/node/app-viewer.d.ts +10 -0
- package/dist/node/app-viewer.d.ts.map +1 -1
- package/dist/node/app-viewer.js +15 -0
- package/dist/node/app-viewer.js.map +1 -1
- package/dist/node/scoped-client.d.ts.map +1 -1
- package/dist/node/scoped-client.js +19 -1
- package/dist/node/scoped-client.js.map +1 -1
- package/dist/platform/auth-core.d.ts +0 -2
- package/dist/platform/auth-core.d.ts.map +1 -1
- package/dist/platform/auth-core.js +0 -10
- package/dist/platform/auth-core.js.map +1 -1
- package/dist/react/hold-live-start.d.ts +1 -1
- package/dist/react/hold-live-start.d.ts.map +1 -1
- package/dist/react/hold-live-start.js +5 -1
- package/dist/react/hold-live-start.js.map +1 -1
- package/dist/react/human-presence.d.ts +44 -0
- package/dist/react/human-presence.d.ts.map +1 -0
- package/dist/react/human-presence.js +96 -0
- package/dist/react/human-presence.js.map +1 -0
- package/dist/react/index.d.ts +6 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +10 -2
- package/dist/react/index.js.map +1 -1
- package/dist/react/opencode.d.ts +1 -0
- package/dist/react/opencode.d.ts.map +1 -1
- package/dist/react/opencode.js +2 -0
- package/dist/react/opencode.js.map +1 -1
- package/dist/react/provider-refresh.d.ts +6 -0
- package/dist/react/provider-refresh.d.ts.map +1 -1
- package/dist/react/provider-refresh.js +9 -2
- package/dist/react/provider-refresh.js.map +1 -1
- package/dist/react/query-contracts.d.ts +9 -1
- package/dist/react/query-contracts.d.ts.map +1 -1
- package/dist/react/query-contracts.js +37 -0
- package/dist/react/query-contracts.js.map +1 -1
- package/dist/react/query-keys.d.ts +64 -0
- package/dist/react/query-keys.d.ts.map +1 -1
- package/dist/react/query-keys.js +66 -0
- package/dist/react/query-keys.js.map +1 -1
- package/dist/react/session-transcript-subscription.d.ts +5 -1
- package/dist/react/session-transcript-subscription.d.ts.map +1 -1
- package/dist/react/session-transcript-subscription.js +8 -2
- package/dist/react/session-transcript-subscription.js.map +1 -1
- package/dist/react/sign-in-with-kortix.d.ts +3 -3
- package/dist/react/use-accounts.d.ts +14 -2
- package/dist/react/use-accounts.d.ts.map +1 -1
- package/dist/react/use-admin-accounts.d.ts +2 -1
- package/dist/react/use-admin-accounts.d.ts.map +1 -1
- package/dist/react/use-admin-accounts.js +1 -1
- package/dist/react/use-admin-accounts.js.map +1 -1
- package/dist/react/use-admin-analytics.d.ts +62 -28
- package/dist/react/use-admin-analytics.d.ts.map +1 -1
- package/dist/react/use-admin-analytics.js +28 -28
- package/dist/react/use-admin-analytics.js.map +1 -1
- package/dist/react/use-admin-billing.d.ts +4 -4
- package/dist/react/use-admin-billing.d.ts.map +1 -1
- package/dist/react/use-admin-billing.js +4 -4
- package/dist/react/use-admin-billing.js.map +1 -1
- package/dist/react/use-admin-feedback.d.ts +18 -8
- package/dist/react/use-admin-feedback.d.ts.map +1 -1
- package/dist/react/use-admin-feedback.js +8 -8
- package/dist/react/use-admin-feedback.js.map +1 -1
- package/dist/react/use-admin-providers.d.ts +3 -0
- package/dist/react/use-admin-providers.d.ts.map +1 -1
- package/dist/react/use-admin-providers.js +11 -1
- package/dist/react/use-admin-providers.js.map +1 -1
- package/dist/react/use-admin-sandboxes.d.ts +17 -8
- package/dist/react/use-admin-sandboxes.d.ts.map +1 -1
- package/dist/react/use-admin-sandboxes.js +8 -8
- package/dist/react/use-admin-sandboxes.js.map +1 -1
- package/dist/react/use-connector-query.d.ts +24 -0
- package/dist/react/use-connector-query.d.ts.map +1 -0
- package/dist/react/use-connector-query.js +37 -0
- package/dist/react/use-connector-query.js.map +1 -0
- package/dist/react/use-feature-flag.d.ts +3 -2
- package/dist/react/use-feature-flag.d.ts.map +1 -1
- package/dist/react/use-feature-flag.js +4 -2
- package/dist/react/use-feature-flag.js.map +1 -1
- package/dist/react/use-notifications.d.ts +644 -0
- package/dist/react/use-notifications.d.ts.map +1 -0
- package/dist/react/use-notifications.js +134 -0
- package/dist/react/use-notifications.js.map +1 -0
- package/dist/react/use-opencode-events/handle-event.d.ts +6 -0
- package/dist/react/use-opencode-events/handle-event.d.ts.map +1 -1
- package/dist/react/use-opencode-events/handle-event.js +5 -0
- package/dist/react/use-opencode-events/handle-event.js.map +1 -1
- package/dist/react/use-opencode-events/handle-session-event.d.ts.map +1 -1
- package/dist/react/use-opencode-events/handle-session-event.js +3 -5
- package/dist/react/use-opencode-events/handle-session-event.js.map +1 -1
- package/dist/react/use-opencode-events/index.d.ts +6 -0
- package/dist/react/use-opencode-events/index.d.ts.map +1 -1
- package/dist/react/use-opencode-events/index.js +28 -2
- package/dist/react/use-opencode-events/index.js.map +1 -1
- package/dist/react/use-opencode-local.d.ts.map +1 -1
- package/dist/react/use-opencode-local.js +0 -12
- package/dist/react/use-opencode-local.js.map +1 -1
- package/dist/react/use-opencode-sessions/agents.d.ts +1 -0
- package/dist/react/use-opencode-sessions/agents.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/agents.js +4 -21
- package/dist/react/use-opencode-sessions/agents.js.map +1 -1
- package/dist/react/use-opencode-sessions/commands.d.ts +1 -2
- package/dist/react/use-opencode-sessions/commands.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/commands.js +3 -7
- package/dist/react/use-opencode-sessions/commands.js.map +1 -1
- package/dist/react/use-opencode-sessions/messages.d.ts +1 -0
- package/dist/react/use-opencode-sessions/messages.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/messages.js +1 -0
- package/dist/react/use-opencode-sessions/messages.js.map +1 -1
- package/dist/react/use-opencode-sessions/providers.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/providers.js +7 -37
- package/dist/react/use-opencode-sessions/providers.js.map +1 -1
- package/dist/react/use-opencode-sessions/sessions.d.ts +3 -0
- package/dist/react/use-opencode-sessions/sessions.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/sessions.js +5 -6
- package/dist/react/use-opencode-sessions/sessions.js.map +1 -1
- package/dist/react/use-opencode-sessions/shared.d.ts +3 -23
- package/dist/react/use-opencode-sessions/shared.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/shared.js +3 -60
- package/dist/react/use-opencode-sessions/shared.js.map +1 -1
- package/dist/react/use-opencode-sessions/tools.d.ts +1 -0
- package/dist/react/use-opencode-sessions/tools.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/tools.js +1 -0
- package/dist/react/use-opencode-sessions/tools.js.map +1 -1
- package/dist/react/use-project-apps.d.ts +496 -13
- package/dist/react/use-project-apps.d.ts.map +1 -1
- package/dist/react/use-project-apps.js +99 -2
- package/dist/react/use-project-apps.js.map +1 -1
- package/dist/react/use-project-files.d.ts +106 -0
- package/dist/react/use-project-files.d.ts.map +1 -0
- package/dist/react/use-project-files.js +131 -0
- package/dist/react/use-project-files.js.map +1 -0
- package/dist/react/use-project-sessions.d.ts +46 -0
- package/dist/react/use-project-sessions.d.ts.map +1 -1
- package/dist/react/use-project-sessions.js +32 -1
- package/dist/react/use-project-sessions.js.map +1 -1
- package/dist/react/use-project-triggers.d.ts +12 -1
- package/dist/react/use-project-triggers.d.ts.map +1 -1
- package/dist/react/use-project-triggers.js +23 -1
- package/dist/react/use-project-triggers.js.map +1 -1
- package/dist/react/use-reminders.d.ts +47 -0
- package/dist/react/use-reminders.d.ts.map +1 -1
- package/dist/react/use-reminders.js +14 -2
- package/dist/react/use-reminders.js.map +1 -1
- package/dist/react/use-runtime-reconnect.d.ts.map +1 -1
- package/dist/react/use-runtime-reconnect.js +18 -0
- package/dist/react/use-runtime-reconnect.js.map +1 -1
- package/dist/react/use-session-log.d.ts +52 -0
- package/dist/react/use-session-log.d.ts.map +1 -0
- package/dist/react/use-session-log.js +166 -0
- package/dist/react/use-session-log.js.map +1 -0
- package/dist/react/use-session-stream.d.ts +47 -0
- package/dist/react/use-session-stream.d.ts.map +1 -0
- package/dist/react/use-session-stream.js +224 -0
- package/dist/react/use-session-stream.js.map +1 -0
- package/dist/react/use-session-sync.d.ts +6 -0
- package/dist/react/use-session-sync.d.ts.map +1 -1
- package/dist/react/use-session-sync.js +25 -14
- package/dist/react/use-session-sync.js.map +1 -1
- package/dist/react/use-session-working.d.ts +3 -0
- package/dist/react/use-session-working.d.ts.map +1 -1
- package/dist/react/use-session-working.js +28 -9
- package/dist/react/use-session-working.js.map +1 -1
- package/dist/react/use-session.d.ts +21 -1
- package/dist/react/use-session.d.ts.map +1 -1
- package/dist/react/use-session.js +132 -32
- package/dist/react/use-session.js.map +1 -1
- package/dist/react/use-system-status.d.ts +9 -4
- package/dist/react/use-system-status.d.ts.map +1 -1
- package/dist/react/use-system-status.js +4 -4
- package/dist/react/use-system-status.js.map +1 -1
- package/dist/react/use-tunnel.d.ts +55 -0
- package/dist/react/use-tunnel.d.ts.map +1 -1
- package/dist/react/use-tunnel.js +29 -0
- package/dist/react/use-tunnel.js.map +1 -1
- package/dist/react/use-wake-escalation.d.ts +18 -0
- package/dist/react/use-wake-escalation.d.ts.map +1 -1
- package/dist/react/use-wake-escalation.js +41 -4
- package/dist/react/use-wake-escalation.js.map +1 -1
- package/package.json +2 -2
- package/dist/browser/cache/idb-sync-cache-key.d.ts +0 -2
- package/dist/browser/cache/idb-sync-cache-key.d.ts.map +0 -1
- package/dist/browser/cache/idb-sync-cache-key.js +0 -7
- package/dist/browser/cache/idb-sync-cache-key.js.map +0 -1
- package/dist/browser/stores/sync-store/stream-cache.d.ts +0 -31
- package/dist/browser/stores/sync-store/stream-cache.d.ts.map +0 -1
- package/dist/browser/stores/sync-store/stream-cache.js +0 -138
- package/dist/browser/stores/sync-store/stream-cache.js.map +0 -1
- package/dist/react/model-lookup.d.ts +0 -2
- package/dist/react/model-lookup.d.ts.map +0 -1
- package/dist/react/model-lookup.js +0 -3
- package/dist/react/model-lookup.js.map +0 -1
|
@@ -10,11 +10,16 @@
|
|
|
10
10
|
*
|
|
11
11
|
* ```ts
|
|
12
12
|
* const kortix = createKortix({
|
|
13
|
-
* backendUrl: '
|
|
13
|
+
* backendUrl: '/_kortix/api/v1',
|
|
14
14
|
* getToken: kortixAppViewerToken(),
|
|
15
15
|
* });
|
|
16
16
|
* ```
|
|
17
17
|
*
|
|
18
|
+
* `/_kortix/api/v1/*` is the gate on the App's own origin. It forwards each
|
|
19
|
+
* call to the Kortix API as the signed-in viewer, so the browser makes no
|
|
20
|
+
* cross-origin request (the API answers no CORS preflight from an App origin).
|
|
21
|
+
* It needs the App's `viewer_token_scope: 'api'`.
|
|
22
|
+
*
|
|
18
23
|
* The token is NOT the user's Kortix session: it expires in an hour, carries
|
|
19
24
|
* only the scopes the App was granted (`profile email`, plus `kortix` when the
|
|
20
25
|
* App is API-scoped), and dies with the App. This module caches it and refetches
|
|
@@ -30,7 +35,17 @@ export interface KortixAppViewerSession {
|
|
|
30
35
|
account_id: string;
|
|
31
36
|
user_id: string;
|
|
32
37
|
email: string | null;
|
|
38
|
+
/** Display name from the viewer's profile. Absent from older gates. */
|
|
39
|
+
name?: string | null;
|
|
40
|
+
/** Profile picture URL. Absent from older gates. */
|
|
41
|
+
picture?: string | null;
|
|
33
42
|
group_ids: string[];
|
|
43
|
+
/** Names of the same groups, unique within the account. Absent from older gates. */
|
|
44
|
+
groups?: string[];
|
|
45
|
+
/** The viewer's account role: `owner`, `admin` or `member`. Absent from older gates. */
|
|
46
|
+
role?: string | null;
|
|
47
|
+
/** The project that owns the App. Absent from older gates. */
|
|
48
|
+
project_id?: string;
|
|
34
49
|
scopes: string[];
|
|
35
50
|
/** Bearer for the Kortix API, scoped to this viewer + App. Null when the App is identity-only. */
|
|
36
51
|
access_token: string | null;
|
|
@@ -41,7 +56,7 @@ export interface KortixAppViewerOptions {
|
|
|
41
56
|
path?: string;
|
|
42
57
|
fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
43
58
|
}
|
|
44
|
-
/** Drop the cached viewer (sign-out, or an App that just changed who it acts as). */
|
|
59
|
+
/** Drop the cached viewer and sign-in tokens (sign-out, or an App that just changed who it acts as). */
|
|
45
60
|
export declare function clearKortixAppViewerCache(): void;
|
|
46
61
|
/**
|
|
47
62
|
* The signed-in Kortix viewer of this App, or `null`. Cached until its token is
|
|
@@ -56,4 +71,61 @@ export declare function fetchKortixAppViewer(options?: KortixAppViewerOptions):
|
|
|
56
71
|
export declare function kortixAppViewerToken(options?: KortixAppViewerOptions): (() => Promise<string | null>) & {
|
|
57
72
|
invalidate: (rejectedToken: string) => void;
|
|
58
73
|
};
|
|
74
|
+
export interface KortixTokenOptions {
|
|
75
|
+
/**
|
|
76
|
+
* The App the token is for, by slug or id: this App itself (the default) or
|
|
77
|
+
* an App it uses (`uses`). Any other App answers `403 app_not_linked`.
|
|
78
|
+
*/
|
|
79
|
+
audience?: string;
|
|
80
|
+
/** Where the gate answers. Default `/_kortix/token` (same origin). */
|
|
81
|
+
path?: string;
|
|
82
|
+
fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
83
|
+
}
|
|
84
|
+
/** A token fetcher: the shape realtime clients take as their auth callback. */
|
|
85
|
+
export type KortixTokenFetcher = (args?: {
|
|
86
|
+
forceRefreshToken?: boolean;
|
|
87
|
+
}) => Promise<string | null>;
|
|
88
|
+
/**
|
|
89
|
+
* A 15-minute Kortix sign-in token naming this App's viewer, from the App's
|
|
90
|
+
* own origin. `aud` is the App the token is for; its server reads the viewer
|
|
91
|
+
* with `verifyKortixToken`, or `readKortixMember` / `requireKortixMember` on
|
|
92
|
+
* claims its runtime already verified.
|
|
93
|
+
*
|
|
94
|
+
* ```ts
|
|
95
|
+
* const token = kortixToken(); // for this App itself
|
|
96
|
+
* client.setAuth(kortixToken({ audience: 'backend' })); // for an App this App uses
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* Cached until shortly before expiry; concurrent callers share one request;
|
|
100
|
+
* `{ forceRefreshToken: true }` always asks the gate again. Yields `null`
|
|
101
|
+
* when there is no signed-in viewer, never throws. An App this App does not
|
|
102
|
+
* use yields `null` and one console warning that names the fix.
|
|
103
|
+
*/
|
|
104
|
+
export declare function kortixToken(options?: KortixTokenOptions): KortixTokenFetcher;
|
|
105
|
+
export interface KortixBindingOptions {
|
|
106
|
+
/** This App's origin. Default: the page's `location.origin`. */
|
|
107
|
+
origin?: string;
|
|
108
|
+
fetch?: KortixTokenOptions['fetch'];
|
|
109
|
+
}
|
|
110
|
+
/** An App this App uses, reached through this App's own origin. */
|
|
111
|
+
export interface KortixBinding {
|
|
112
|
+
/** `<origin>/_kortix/apps/<slug>`: the used App's endpoint, HTTP and WebSocket. */
|
|
113
|
+
url: string;
|
|
114
|
+
/** Sign-in tokens for the used App, naming this App's viewer. */
|
|
115
|
+
token: KortixTokenFetcher;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* An App this App uses (`uses`), on this App's own origin: no cross-origin
|
|
119
|
+
* request, no CORS. A used static App answers
|
|
120
|
+
* `409 app_binding_unsupported`; an App this App does not use answers
|
|
121
|
+
* `403 app_not_linked`.
|
|
122
|
+
*
|
|
123
|
+
* ```ts
|
|
124
|
+
* const api = kortixBinding('api');
|
|
125
|
+
* const res = await fetch(`${api.url}/orders`, {
|
|
126
|
+
* headers: { authorization: `Bearer ${await api.token()}` },
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export declare function kortixBinding(slug: string, options?: KortixBindingOptions): KortixBinding;
|
|
59
131
|
//# sourceMappingURL=app-viewer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-viewer.d.ts","sourceRoot":"","sources":["../../../src/core/auth/app-viewer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"app-viewer.d.ts","sourceRoot":"","sources":["../../../src/core/auth/app-viewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,kDAAkD;AAClD,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,wFAAwF;IACxF,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,kGAAkG;IAClG,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,sBAAsB;IACrC,uEAAuE;IACvE,IAAI,CAA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,mFAAmF;IACnF,GAAG,EAAE,MAAM,CAAC;IACZ,iEAAiE;IACjE,KAAK,EAAE,kBAAkB,CAAC;CAC3B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,aAAa,CAO7F"}
|
|
@@ -10,11 +10,16 @@
|
|
|
10
10
|
*
|
|
11
11
|
* ```ts
|
|
12
12
|
* const kortix = createKortix({
|
|
13
|
-
* backendUrl: '
|
|
13
|
+
* backendUrl: '/_kortix/api/v1',
|
|
14
14
|
* getToken: kortixAppViewerToken(),
|
|
15
15
|
* });
|
|
16
16
|
* ```
|
|
17
17
|
*
|
|
18
|
+
* `/_kortix/api/v1/*` is the gate on the App's own origin. It forwards each
|
|
19
|
+
* call to the Kortix API as the signed-in viewer, so the browser makes no
|
|
20
|
+
* cross-origin request (the API answers no CORS preflight from an App origin).
|
|
21
|
+
* It needs the App's `viewer_token_scope: 'api'`.
|
|
22
|
+
*
|
|
18
23
|
* The token is NOT the user's Kortix session: it expires in an hour, carries
|
|
19
24
|
* only the scopes the App was granted (`profile email`, plus `kortix` when the
|
|
20
25
|
* App is API-scoped), and dies with the App. This module caches it and refetches
|
|
@@ -23,13 +28,15 @@
|
|
|
23
28
|
* For an App served on its own domain (not `*.apps.kortix.com`) there is no gate
|
|
24
29
|
* — use `createKortixAuth` from `@kortix/sdk/server` instead.
|
|
25
30
|
*/
|
|
31
|
+
import { stripTrailingSlashes } from '../../platform/strings.js';
|
|
26
32
|
const DEFAULT_PATH = '/_kortix/viewer';
|
|
27
33
|
/** Refetch this long before expiry so a token handed to a caller is always live. */
|
|
28
34
|
const REFRESH_SKEW_MS = 60_000;
|
|
29
35
|
const cache = new Map();
|
|
30
|
-
/** Drop the cached viewer (sign-out, or an App that just changed who it acts as). */
|
|
36
|
+
/** Drop the cached viewer and sign-in tokens (sign-out, or an App that just changed who it acts as). */
|
|
31
37
|
export function clearKortixAppViewerCache() {
|
|
32
38
|
cache.clear();
|
|
39
|
+
appTokens.clear();
|
|
33
40
|
}
|
|
34
41
|
async function load(path, fetchImpl) {
|
|
35
42
|
let res;
|
|
@@ -89,4 +96,90 @@ export function kortixAppViewerToken(options = {}) {
|
|
|
89
96
|
},
|
|
90
97
|
});
|
|
91
98
|
}
|
|
99
|
+
const appTokens = new Map();
|
|
100
|
+
async function loadAppToken(url, fetchImpl) {
|
|
101
|
+
try {
|
|
102
|
+
const res = await fetchImpl(url, { credentials: 'same-origin', headers: { accept: 'application/json' } });
|
|
103
|
+
// 401 nobody signed in, 403 an agent viewer or an App this App does not
|
|
104
|
+
// use, 404 viewer identity off: all "no token", none of them a crash. The
|
|
105
|
+
// unlinked App is a setup mistake the developer must see, so it warns.
|
|
106
|
+
if (!res.ok) {
|
|
107
|
+
if (res.status === 403) {
|
|
108
|
+
const refusal = (await res.json().catch(() => null));
|
|
109
|
+
if (refusal?.error === 'app_not_linked')
|
|
110
|
+
console.warn(`[kortix] ${String(refusal.error_description)}`);
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const body = (await res.json().catch(() => null));
|
|
115
|
+
if (!body || typeof body.token !== 'string')
|
|
116
|
+
return null;
|
|
117
|
+
const expiry = typeof body.expires_at === 'string' ? Date.parse(body.expires_at) : Number.NaN;
|
|
118
|
+
appTokens.set(url, {
|
|
119
|
+
token: body.token,
|
|
120
|
+
refreshAt: Number.isFinite(expiry) ? expiry - REFRESH_SKEW_MS : Date.now() + REFRESH_SKEW_MS,
|
|
121
|
+
});
|
|
122
|
+
return body.token;
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* A 15-minute Kortix sign-in token naming this App's viewer, from the App's
|
|
130
|
+
* own origin. `aud` is the App the token is for; its server reads the viewer
|
|
131
|
+
* with `verifyKortixToken`, or `readKortixMember` / `requireKortixMember` on
|
|
132
|
+
* claims its runtime already verified.
|
|
133
|
+
*
|
|
134
|
+
* ```ts
|
|
135
|
+
* const token = kortixToken(); // for this App itself
|
|
136
|
+
* client.setAuth(kortixToken({ audience: 'backend' })); // for an App this App uses
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* Cached until shortly before expiry; concurrent callers share one request;
|
|
140
|
+
* `{ forceRefreshToken: true }` always asks the gate again. Yields `null`
|
|
141
|
+
* when there is no signed-in viewer, never throws. An App this App does not
|
|
142
|
+
* use yields `null` and one console warning that names the fix.
|
|
143
|
+
*/
|
|
144
|
+
export function kortixToken(options = {}) {
|
|
145
|
+
const base = options.path ?? '/_kortix/token';
|
|
146
|
+
const url = options.audience === undefined ? base : `${base}?audience=${encodeURIComponent(options.audience)}`;
|
|
147
|
+
const fetchImpl = options.fetch ?? ((input, init) => fetch(input, init));
|
|
148
|
+
return async (args = {}) => {
|
|
149
|
+
const entry = appTokens.get(url);
|
|
150
|
+
if (entry instanceof Promise)
|
|
151
|
+
return entry;
|
|
152
|
+
if (entry && !args.forceRefreshToken && entry.refreshAt > Date.now())
|
|
153
|
+
return entry.token;
|
|
154
|
+
const inflight = loadAppToken(url, fetchImpl).then((token) => {
|
|
155
|
+
if (token === null)
|
|
156
|
+
appTokens.delete(url);
|
|
157
|
+
return token;
|
|
158
|
+
});
|
|
159
|
+
appTokens.set(url, inflight);
|
|
160
|
+
return inflight;
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* An App this App uses (`uses`), on this App's own origin: no cross-origin
|
|
165
|
+
* request, no CORS. A used static App answers
|
|
166
|
+
* `409 app_binding_unsupported`; an App this App does not use answers
|
|
167
|
+
* `403 app_not_linked`.
|
|
168
|
+
*
|
|
169
|
+
* ```ts
|
|
170
|
+
* const api = kortixBinding('api');
|
|
171
|
+
* const res = await fetch(`${api.url}/orders`, {
|
|
172
|
+
* headers: { authorization: `Bearer ${await api.token()}` },
|
|
173
|
+
* });
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export function kortixBinding(slug, options = {}) {
|
|
177
|
+
const origin = options.origin ?? globalThis.location?.origin;
|
|
178
|
+
if (!origin)
|
|
179
|
+
throw new Error('kortixBinding needs the App origin: pass { origin } outside a browser.');
|
|
180
|
+
return {
|
|
181
|
+
url: `${stripTrailingSlashes(origin)}/_kortix/apps/${encodeURIComponent(slug)}`,
|
|
182
|
+
token: kortixToken({ audience: slug, fetch: options.fetch }),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
92
185
|
//# sourceMappingURL=app-viewer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-viewer.js","sourceRoot":"","sources":["../../../src/core/auth/app-viewer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"app-viewer.js","sourceRoot":"","sources":["../../../src/core/auth/app-viewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAgC9D,MAAM,YAAY,GAAG,iBAAiB,CAAC;AACvC,oFAAoF;AACpF,MAAM,eAAe,GAAG,MAAM,CAAC;AAQ/B,MAAM,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;AAE5C,wGAAwG;AACxG,MAAM,UAAU,yBAAyB;IACvC,KAAK,CAAC,KAAK,EAAE,CAAC;IACd,SAAS,CAAC,KAAK,EAAE,CAAC;AACpB,CAAC;AAED,KAAK,UAAU,IAAI,CACjB,IAAY,EACZ,SAAuD;IAEvD,IAAI,GAAa,CAAC;IAClB,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAC;IACvG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,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;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,UAAgC,EAAE;IAC5E,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAK,UAAiD,CAAC,QAAQ,EAAE,MAAM,CAAC;IACrG,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;IACvG,OAAO;QACL,GAAG,EAAE,GAAG,oBAAoB,CAAC,MAAM,CAAC,iBAAiB,kBAAkB,CAAC,IAAI,CAAC,EAAE;QAC/E,KAAK,EAAE,WAAW,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;KAC7D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The signed-in Kortix member, on any runtime.
|
|
3
|
+
*
|
|
4
|
+
* Kortix vouches for a person in three places, and each one hands the same
|
|
5
|
+
* facts over in its own shape:
|
|
6
|
+
*
|
|
7
|
+
* - An App's browser asks its gate: `GET /_kortix/viewer` (see
|
|
8
|
+
* `fetchKortixAppViewer`).
|
|
9
|
+
* - An App's server reads the gate's signed header (`createKortixAppGuard`
|
|
10
|
+
* in `@kortix/sdk/server`).
|
|
11
|
+
* - An App's own server, an App it uses, or any server holding the project's
|
|
12
|
+
* key set receives a short-lived ES256 token that Kortix signed for one
|
|
13
|
+
* App (`aud` = the App id).
|
|
14
|
+
*
|
|
15
|
+
* `readKortixMember` turns any of those shapes into one `KortixMember`, and
|
|
16
|
+
* `requireKortixMember` enforces who may proceed. Group-based access uses the
|
|
17
|
+
* same Kortix groups that decide who may open the App, so a person added to a
|
|
18
|
+
* group in Kortix gains the matching rights in every App, with no user table
|
|
19
|
+
* of the App's own.
|
|
20
|
+
*
|
|
21
|
+
* Where the claims come from is the caller's choice:
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* // A runtime that verified the token already (an App's server functions,
|
|
25
|
+
* // JWT middleware): pass what it verified.
|
|
26
|
+
* const me = requireKortixMember(await ctx.auth.getUserIdentity(), { groups: ['Finance'] });
|
|
27
|
+
*
|
|
28
|
+
* // A plain server: verify the bearer here. With no options, the key set,
|
|
29
|
+
* // issuer and audience come from KORTIX_AUTH_JWKS / _ISSUER / _AUDIENCE.
|
|
30
|
+
* // Kortix sets them on an App kind that runs its own machine; elsewhere copy
|
|
31
|
+
* // them from the App's `auth` (`jwks_uri` is a valid KORTIX_AUTH_JWKS).
|
|
32
|
+
* const me = await verifyKortixToken(bearer);
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* No dependency and no framework: WebCrypto only, so it runs in a browser,
|
|
36
|
+
* Node 18+, Bun, Deno and a Worker alike.
|
|
37
|
+
*/
|
|
38
|
+
/** The person Kortix vouched for. Every field is present; unknown ones are null or empty. */
|
|
39
|
+
export interface KortixMember {
|
|
40
|
+
/** The Kortix user id. Stable for life; key your rows on it. */
|
|
41
|
+
userId: string;
|
|
42
|
+
email: string | null;
|
|
43
|
+
/** Display name from the member's profile. */
|
|
44
|
+
name: string | null;
|
|
45
|
+
/** Profile picture URL. */
|
|
46
|
+
picture: string | null;
|
|
47
|
+
/** Names of the member's Kortix groups in this account. Unique within the account. */
|
|
48
|
+
groups: string[];
|
|
49
|
+
/** Ids of the same groups. Stable across a rename. */
|
|
50
|
+
groupIds: string[];
|
|
51
|
+
/** The member's account role: `owner`, `admin` or `member`. */
|
|
52
|
+
role: string | null;
|
|
53
|
+
accountId: string | null;
|
|
54
|
+
projectId: string | null;
|
|
55
|
+
}
|
|
56
|
+
/** Who may proceed. Each list means "any one of these"; both lists must hold. */
|
|
57
|
+
export interface KortixMemberRequirement {
|
|
58
|
+
/** Group names or group ids. */
|
|
59
|
+
groups?: string[];
|
|
60
|
+
/** Account roles, e.g. `['owner', 'admin']`. */
|
|
61
|
+
roles?: string[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Why a member was refused. `unauthenticated`: nobody, or a token that failed a
|
|
65
|
+
* check. `forbidden`: a real member outside the required groups or roles.
|
|
66
|
+
* Map it to HTTP 401 and 403.
|
|
67
|
+
*/
|
|
68
|
+
export declare class KortixMemberError extends Error {
|
|
69
|
+
readonly code: 'unauthenticated' | 'forbidden';
|
|
70
|
+
constructor(code: 'unauthenticated' | 'forbidden', message: string);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The member these claims name, or `null` for nobody. Accepts raw token claims
|
|
74
|
+
* (`sub`, `picture`), an identity a runtime already verified (`subject`,
|
|
75
|
+
* `pictureUrl`), the App gate's answer (`user_id`), and a server-side viewer
|
|
76
|
+
* from `readAppViewer` or `createKortixAppGuard` (`userId`). Never verifies a
|
|
77
|
+
* signature: pass only claims something already verified, or use
|
|
78
|
+
* `verifyKortixToken`.
|
|
79
|
+
*/
|
|
80
|
+
export declare function readKortixMember(claims: unknown): KortixMember | null;
|
|
81
|
+
/**
|
|
82
|
+
* The member, or a `KortixMemberError`. An empty requirement list refuses: a
|
|
83
|
+
* rule that names no group admits nobody, rather than everybody.
|
|
84
|
+
*/
|
|
85
|
+
export declare function requireKortixMember(claims: unknown, requirement?: KortixMemberRequirement): KortixMember;
|
|
86
|
+
/** A JSON Web Key Set, as an object, JSON text, a `data:` URI or an https URL. */
|
|
87
|
+
export type KortixMemberKeySet = {
|
|
88
|
+
keys: JsonWebKey[];
|
|
89
|
+
} | string;
|
|
90
|
+
export interface VerifyKortixTokenOptions {
|
|
91
|
+
/** Default: `KORTIX_AUTH_JWKS`. */
|
|
92
|
+
jwks?: KortixMemberKeySet;
|
|
93
|
+
/** Default: `KORTIX_AUTH_ISSUER`. */
|
|
94
|
+
issuer?: string;
|
|
95
|
+
/**
|
|
96
|
+
* The App id the token must name (`aud`). Default: `KORTIX_AUTH_AUDIENCE`.
|
|
97
|
+
* Required: one project key signs the tokens of every App in the project,
|
|
98
|
+
* so `aud` is what keeps a token for another App out. With neither set the
|
|
99
|
+
* token is refused. `false` accepts any App of the key set's project.
|
|
100
|
+
*/
|
|
101
|
+
audience?: string | false;
|
|
102
|
+
fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Verifies a Kortix-signed member token (ES256) and returns the member. Checks
|
|
106
|
+
* the signature, `exp` (60 s skew), the issuer and the audience. Every failure,
|
|
107
|
+
* including a missing key set or a missing audience, is a `KortixMemberError`
|
|
108
|
+
* with code `unauthenticated`: nothing is ever accepted unchecked.
|
|
109
|
+
*/
|
|
110
|
+
export declare function verifyKortixToken(token: string, options?: VerifyKortixTokenOptions): Promise<KortixMember>;
|
|
111
|
+
//# sourceMappingURL=kortix-member.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kortix-member.d.ts","sourceRoot":"","sources":["../../../src/core/auth/kortix-member.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAIH,6FAA6F;AAC7F,MAAM,WAAW,YAAY;IAC3B,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,8CAA8C;IAC9C,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,2BAA2B;IAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,sFAAsF;IACtF,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,sDAAsD;IACtD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,+DAA+D;IAC/D,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,iFAAiF;AACjF,MAAM,WAAW,uBAAuB;IACtC,gCAAgC;IAChC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,IAAI,EAAE,iBAAiB,GAAG,WAAW,CAAC;gBACnC,IAAI,EAAE,iBAAiB,GAAG,WAAW,EAAE,OAAO,EAAE,MAAM;CAKnE;AAmBD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI,CAgBrE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,GAAE,uBAA4B,GAAG,YAAY,CAW5G;AAID,kFAAkF;AAClF,MAAM,MAAM,kBAAkB,GAAG;IAAE,IAAI,EAAE,UAAU,EAAE,CAAA;CAAE,GAAG,MAAM,CAAC;AAEjE,MAAM,WAAW,wBAAwB;IACvC,mCAAmC;IACnC,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC1B,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC7E;AA6CD;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,YAAY,CAAC,CAsEvB"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The signed-in Kortix member, on any runtime.
|
|
3
|
+
*
|
|
4
|
+
* Kortix vouches for a person in three places, and each one hands the same
|
|
5
|
+
* facts over in its own shape:
|
|
6
|
+
*
|
|
7
|
+
* - An App's browser asks its gate: `GET /_kortix/viewer` (see
|
|
8
|
+
* `fetchKortixAppViewer`).
|
|
9
|
+
* - An App's server reads the gate's signed header (`createKortixAppGuard`
|
|
10
|
+
* in `@kortix/sdk/server`).
|
|
11
|
+
* - An App's own server, an App it uses, or any server holding the project's
|
|
12
|
+
* key set receives a short-lived ES256 token that Kortix signed for one
|
|
13
|
+
* App (`aud` = the App id).
|
|
14
|
+
*
|
|
15
|
+
* `readKortixMember` turns any of those shapes into one `KortixMember`, and
|
|
16
|
+
* `requireKortixMember` enforces who may proceed. Group-based access uses the
|
|
17
|
+
* same Kortix groups that decide who may open the App, so a person added to a
|
|
18
|
+
* group in Kortix gains the matching rights in every App, with no user table
|
|
19
|
+
* of the App's own.
|
|
20
|
+
*
|
|
21
|
+
* Where the claims come from is the caller's choice:
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* // A runtime that verified the token already (an App's server functions,
|
|
25
|
+
* // JWT middleware): pass what it verified.
|
|
26
|
+
* const me = requireKortixMember(await ctx.auth.getUserIdentity(), { groups: ['Finance'] });
|
|
27
|
+
*
|
|
28
|
+
* // A plain server: verify the bearer here. With no options, the key set,
|
|
29
|
+
* // issuer and audience come from KORTIX_AUTH_JWKS / _ISSUER / _AUDIENCE.
|
|
30
|
+
* // Kortix sets them on an App kind that runs its own machine; elsewhere copy
|
|
31
|
+
* // them from the App's `auth` (`jwks_uri` is a valid KORTIX_AUTH_JWKS).
|
|
32
|
+
* const me = await verifyKortixToken(bearer);
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* No dependency and no framework: WebCrypto only, so it runs in a browser,
|
|
36
|
+
* Node 18+, Bun, Deno and a Worker alike.
|
|
37
|
+
*/
|
|
38
|
+
import { safeEnv } from '../http/env.js';
|
|
39
|
+
/**
|
|
40
|
+
* Why a member was refused. `unauthenticated`: nobody, or a token that failed a
|
|
41
|
+
* check. `forbidden`: a real member outside the required groups or roles.
|
|
42
|
+
* Map it to HTTP 401 and 403.
|
|
43
|
+
*/
|
|
44
|
+
export class KortixMemberError extends Error {
|
|
45
|
+
code;
|
|
46
|
+
constructor(code, message) {
|
|
47
|
+
super(message);
|
|
48
|
+
this.name = 'KortixMemberError';
|
|
49
|
+
this.code = code;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const text = (value) => (typeof value === 'string' && value.length > 0 ? value : null);
|
|
53
|
+
/** A list claim. Some runtimes hand custom claims over as JSON text. */
|
|
54
|
+
function list(value) {
|
|
55
|
+
let parsed = value;
|
|
56
|
+
if (typeof value === 'string') {
|
|
57
|
+
try {
|
|
58
|
+
parsed = JSON.parse(value);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return Array.isArray(parsed) ? parsed.filter((item) => typeof item === 'string') : [];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The member these claims name, or `null` for nobody. Accepts raw token claims
|
|
68
|
+
* (`sub`, `picture`), an identity a runtime already verified (`subject`,
|
|
69
|
+
* `pictureUrl`), the App gate's answer (`user_id`), and a server-side viewer
|
|
70
|
+
* from `readAppViewer` or `createKortixAppGuard` (`userId`). Never verifies a
|
|
71
|
+
* signature: pass only claims something already verified, or use
|
|
72
|
+
* `verifyKortixToken`.
|
|
73
|
+
*/
|
|
74
|
+
export function readKortixMember(claims) {
|
|
75
|
+
if (!claims || typeof claims !== 'object')
|
|
76
|
+
return null;
|
|
77
|
+
const c = claims;
|
|
78
|
+
const userId = text(c.sub) ?? text(c.subject) ?? text(c.user_id) ?? text(c.userId);
|
|
79
|
+
if (!userId)
|
|
80
|
+
return null;
|
|
81
|
+
return {
|
|
82
|
+
userId,
|
|
83
|
+
email: text(c.email),
|
|
84
|
+
name: text(c.name),
|
|
85
|
+
picture: text(c.picture) ?? text(c.pictureUrl),
|
|
86
|
+
groups: list(c.groups),
|
|
87
|
+
groupIds: list(c.group_ids ?? c.groupIds),
|
|
88
|
+
role: text(c.role),
|
|
89
|
+
accountId: text(c.account_id) ?? text(c.accountId),
|
|
90
|
+
projectId: text(c.project_id) ?? text(c.projectId),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The member, or a `KortixMemberError`. An empty requirement list refuses: a
|
|
95
|
+
* rule that names no group admits nobody, rather than everybody.
|
|
96
|
+
*/
|
|
97
|
+
export function requireKortixMember(claims, requirement = {}) {
|
|
98
|
+
const member = readKortixMember(claims);
|
|
99
|
+
if (!member)
|
|
100
|
+
throw new KortixMemberError('unauthenticated', 'Sign in with Kortix to continue.');
|
|
101
|
+
const { groups, roles } = requirement;
|
|
102
|
+
if (groups && !groups.some((group) => member.groups.includes(group) || member.groupIds.includes(group))) {
|
|
103
|
+
throw new KortixMemberError('forbidden', `Only members of ${groups.join(' or ') || 'no group'} may do this.`);
|
|
104
|
+
}
|
|
105
|
+
if (roles && !roles.some((role) => member.role === role)) {
|
|
106
|
+
throw new KortixMemberError('forbidden', `Only ${roles.join(' or ') || 'no role'} members may do this.`);
|
|
107
|
+
}
|
|
108
|
+
return member;
|
|
109
|
+
}
|
|
110
|
+
const CLOCK_SKEW_SECONDS = 60;
|
|
111
|
+
const remoteKeySets = new Map();
|
|
112
|
+
function base64UrlBytes(value) {
|
|
113
|
+
const base64 = value.replace(/-/g, '+').replace(/_/g, '/');
|
|
114
|
+
const binary = atob(base64 + '='.repeat((4 - (base64.length % 4)) % 4));
|
|
115
|
+
return Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
116
|
+
}
|
|
117
|
+
function base64UrlJson(value) {
|
|
118
|
+
return JSON.parse(new TextDecoder().decode(base64UrlBytes(value)));
|
|
119
|
+
}
|
|
120
|
+
async function loadKeySet(source, fetchImpl) {
|
|
121
|
+
if (typeof source !== 'string')
|
|
122
|
+
return source;
|
|
123
|
+
if (source.startsWith('data:')) {
|
|
124
|
+
const comma = source.indexOf(',');
|
|
125
|
+
const meta = source.slice(5, comma);
|
|
126
|
+
const payload = source.slice(comma + 1);
|
|
127
|
+
const body = meta.endsWith(';base64')
|
|
128
|
+
? new TextDecoder().decode(Uint8Array.from(atob(payload), (char) => char.charCodeAt(0)))
|
|
129
|
+
: decodeURIComponent(payload);
|
|
130
|
+
return JSON.parse(body);
|
|
131
|
+
}
|
|
132
|
+
if (/^https?:\/\//.test(source)) {
|
|
133
|
+
let cached = remoteKeySets.get(source);
|
|
134
|
+
if (!cached) {
|
|
135
|
+
cached = fetchImpl(source, { headers: { accept: 'application/json' } }).then(async (res) => {
|
|
136
|
+
if (!res.ok)
|
|
137
|
+
throw new Error(`key set ${res.status}`);
|
|
138
|
+
return (await res.json());
|
|
139
|
+
});
|
|
140
|
+
// A failed fetch is not cached: the next request tries again.
|
|
141
|
+
cached.catch(() => remoteKeySets.delete(source));
|
|
142
|
+
remoteKeySets.set(source, cached);
|
|
143
|
+
}
|
|
144
|
+
return cached;
|
|
145
|
+
}
|
|
146
|
+
return JSON.parse(source);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Verifies a Kortix-signed member token (ES256) and returns the member. Checks
|
|
150
|
+
* the signature, `exp` (60 s skew), the issuer and the audience. Every failure,
|
|
151
|
+
* including a missing key set or a missing audience, is a `KortixMemberError`
|
|
152
|
+
* with code `unauthenticated`: nothing is ever accepted unchecked.
|
|
153
|
+
*/
|
|
154
|
+
export async function verifyKortixToken(token, options = {}) {
|
|
155
|
+
const refuse = (why) => {
|
|
156
|
+
throw new KortixMemberError('unauthenticated', `Kortix sign-in token refused: ${why}.`);
|
|
157
|
+
};
|
|
158
|
+
const jwks = options.jwks ?? safeEnv('KORTIX_AUTH_JWKS');
|
|
159
|
+
const issuer = options.issuer ?? safeEnv('KORTIX_AUTH_ISSUER');
|
|
160
|
+
const audience = options.audience ?? safeEnv('KORTIX_AUTH_AUDIENCE');
|
|
161
|
+
if (!jwks)
|
|
162
|
+
return refuse('no key set configured (KORTIX_AUTH_JWKS)');
|
|
163
|
+
if (audience !== false && !audience) {
|
|
164
|
+
return refuse('no audience configured (KORTIX_AUTH_AUDIENCE, or `audience: false` to accept any App)');
|
|
165
|
+
}
|
|
166
|
+
const parts = typeof token === 'string' ? token.split('.') : [];
|
|
167
|
+
if (parts.length !== 3)
|
|
168
|
+
return refuse('malformed');
|
|
169
|
+
const [head, body, signature] = parts;
|
|
170
|
+
let header;
|
|
171
|
+
let claims;
|
|
172
|
+
try {
|
|
173
|
+
header = base64UrlJson(head);
|
|
174
|
+
claims = base64UrlJson(body);
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
return refuse('malformed');
|
|
178
|
+
}
|
|
179
|
+
if (header.alg !== 'ES256')
|
|
180
|
+
return refuse('unsupported algorithm');
|
|
181
|
+
let keySet;
|
|
182
|
+
try {
|
|
183
|
+
keySet = await loadKeySet(jwks, options.fetch ?? ((input, init) => fetch(input, init)));
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
return refuse('key set unavailable');
|
|
187
|
+
}
|
|
188
|
+
const candidates = (keySet.keys ?? []).filter((key) => key.kty === 'EC' && (header.kid === undefined || key.kid === header.kid));
|
|
189
|
+
if (candidates.length === 0)
|
|
190
|
+
return refuse('unknown key');
|
|
191
|
+
const signed = new TextEncoder().encode(`${head}.${body}`);
|
|
192
|
+
let signatureBytes;
|
|
193
|
+
try {
|
|
194
|
+
signatureBytes = base64UrlBytes(signature);
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
return refuse('malformed');
|
|
198
|
+
}
|
|
199
|
+
let valid = false;
|
|
200
|
+
for (const jwk of candidates) {
|
|
201
|
+
try {
|
|
202
|
+
const { kid: _kid, alg: _alg, use: _use, key_ops: _ops, ...material } = jwk;
|
|
203
|
+
const key = await crypto.subtle.importKey('jwk', material, { name: 'ECDSA', namedCurve: 'P-256' }, false, [
|
|
204
|
+
'verify',
|
|
205
|
+
]);
|
|
206
|
+
if (await crypto.subtle.verify({ name: 'ECDSA', hash: 'SHA-256' }, key, signatureBytes, signed)) {
|
|
207
|
+
valid = true;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
// A key this runtime cannot import is not the one that signed.
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (!valid)
|
|
216
|
+
return refuse('bad signature');
|
|
217
|
+
const nowSeconds = Math.floor(Date.now() / 1000);
|
|
218
|
+
if (typeof claims.exp !== 'number' || claims.exp + CLOCK_SKEW_SECONDS < nowSeconds)
|
|
219
|
+
return refuse('expired');
|
|
220
|
+
if (issuer && claims.iss !== issuer)
|
|
221
|
+
return refuse('wrong issuer');
|
|
222
|
+
if (audience) {
|
|
223
|
+
const aud = claims.aud;
|
|
224
|
+
if (!(aud === audience || (Array.isArray(aud) && aud.includes(audience))))
|
|
225
|
+
return refuse('wrong audience');
|
|
226
|
+
}
|
|
227
|
+
const member = readKortixMember(claims);
|
|
228
|
+
if (!member)
|
|
229
|
+
return refuse('no subject');
|
|
230
|
+
return member;
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=kortix-member.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kortix-member.js","sourceRoot":"","sources":["../../../src/core/auth/kortix-member.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA6BtC;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACjC,IAAI,CAAkC;IAC/C,YAAY,IAAqC,EAAE,OAAe;QAChE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAID,MAAM,IAAI,GAAG,CAAC,KAAc,EAAiB,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK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
};
|
|
17
17
|
tierConfigurations: typeof P.getBillingTierConfigurations;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated The API retired these routes. Both reject with
|
|
20
|
+
* `ENDPOINT_RETIRED`. Use `createPerSeatCheckout`. Removed in the next major.
|
|
21
|
+
*/
|
|
19
22
|
checkout: {
|
|
20
23
|
createSession: (input: Parameters<typeof P.createCheckoutSession>[0]) => Promise<P.CheckoutSessionResult>;
|
|
21
24
|
confirmSession: (sessionId: string, accountId?: string) => Promise<P.ConfirmCheckoutSessionResult>;
|
|
@@ -25,6 +28,7 @@ export declare function bindCommerce(): {
|
|
|
25
28
|
createPortalSession: (returnUrl: string, accountId?: string) => Promise<P.PortalSessionResult>;
|
|
26
29
|
cancel: (feedback?: string, accountId?: string) => Promise<P.SubscriptionMutationResult>;
|
|
27
30
|
reactivate: (accountId?: string) => Promise<P.SubscriptionMutationResult>;
|
|
31
|
+
/** @deprecated Rejects with `ENDPOINT_RETIRED`. Use `createPortalSession`. Removed in the next major. */
|
|
28
32
|
scheduleDowngrade: (targetTierKey: string, commitmentType?: string, accountId?: string) => Promise<P.SubscriptionMutationResult>;
|
|
29
33
|
cancelScheduledChange: (accountId?: string) => Promise<P.SubscriptionMutationResult>;
|
|
30
34
|
prorationPreview: (newPriceId: string, accountId?: string) => Promise<P.ProrationPreviewResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facade-commerce.d.ts","sourceRoot":"","sources":["../../../src/core/client/facade-commerce.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,yBAAyB,CAAC;AAE7C,wBAAgB,YAAY;;;;;;;;QAQxB,+EAA+E;;QAE/E,yDAAyD;;;;;;QAOzD
|
|
1
|
+
{"version":3,"file":"facade-commerce.d.ts","sourceRoot":"","sources":["../../../src/core/client/facade-commerce.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,yBAAyB,CAAC;AAE7C,wBAAgB,YAAY;;;;;;;;QAQxB,+EAA+E;;QAE/E,yDAAyD;;;;;;QAOzD;;;WAGG;;mCAEsB,UAAU,CAAC,OAAO,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;wCAExC,MAAM,cAAc,MAAM;;QAIxD,8EAA8E;;6CAE3C,MAAM,cAAc,MAAM;gCAEvC,MAAM,cAAc,MAAM;qCACrB,MAAM;YAC/B,yGAAyG;+CACtE,MAAM,mBAAmB,MAAM,cAAc,MAAM;gDAElD,MAAM;2CACX,MAAM,cAAc,MAAM;;QAI3D,qEAAqE;;8BAEjD,UAAU,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;4CACzB,MAAM;wCACV,UAAU,CAAC,OAAO,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;;;;;;;;EAmB3E"}
|