zitejs 0.9.153 → 0.9.154
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/cjs/auth/actions.d.ts +28 -0
- package/dist/cjs/auth/actions.js +93 -0
- package/dist/cjs/auth/client.d.ts +357 -0
- package/dist/cjs/auth/client.js +66 -0
- package/dist/cjs/auth/config.js +9 -3
- package/dist/cjs/auth/index.d.ts +2 -249
- package/dist/cjs/auth/index.js +11 -108
- package/dist/cjs/auth/index.test.js +60 -0
- package/dist/cjs/auth/previewClaim.d.ts +7 -0
- package/dist/cjs/auth/previewClaim.js +16 -0
- package/dist/cjs/auth/profileUpdates.d.ts +9 -0
- package/dist/cjs/auth/profileUpdates.js +11 -0
- package/dist/cjs/backend/index.d.ts +6 -6
- package/dist/cjs/backend/index.js +13 -13
- package/dist/cjs/backend/index.test.js +102 -102
- package/dist/cjs/bundle/index.js +29 -16
- package/dist/cjs/caller/index.js +43 -43
- package/dist/cjs/check/index.d.ts +44 -1
- package/dist/cjs/check/index.js +198 -61
- package/dist/cjs/check/start/routeTree.d.ts +8 -0
- package/dist/cjs/check/start/routeTree.js +118 -0
- package/dist/cjs/check/start/tsgo.d.ts +2 -0
- package/dist/cjs/check/start/tsgo.js +35 -0
- package/dist/cjs/cli.js +19 -6
- package/dist/cjs/client/index.d.ts +2 -2
- package/dist/cjs/client/index.js +25 -25
- package/dist/cjs/dev/index.js +81 -53
- package/dist/cjs/dev/signin.d.ts +16 -0
- package/dist/cjs/dev/signin.js +84 -0
- package/dist/cjs/index.d.ts +5 -5
- package/dist/cjs/integrations/client.d.ts +3 -3
- package/dist/cjs/integrations/client.js +5 -4
- package/dist/cjs/integrations/client.test-d.js +15 -15
- package/dist/cjs/integrations/index.d.ts +2 -2
- package/dist/cjs/integrations/rules.js +42 -42
- package/dist/cjs/integrations/rules.test.js +60 -55
- package/dist/cjs/internal/appMode.d.ts +14 -0
- package/dist/cjs/internal/appMode.js +19 -0
- package/dist/cjs/internal/env.js +3 -2
- package/dist/cjs/internal/platformFetch.d.ts +2 -0
- package/dist/cjs/internal/platformFetch.js +14 -0
- package/dist/cjs/internal/reservedIds.d.ts +8 -0
- package/dist/cjs/internal/reservedIds.js +14 -0
- package/dist/cjs/internal/serviceUrls.d.ts +5 -0
- package/dist/cjs/internal/serviceUrls.js +14 -0
- package/dist/cjs/pdf/index.js +2 -1
- package/dist/cjs/runtime/filterConditionTypes.test-d.js +11 -11
- package/dist/cjs/runtime/index.d.ts +22 -22
- package/dist/cjs/runtime/index.js +28 -28
- package/dist/cjs/runtime/index.test.js +34 -34
- package/dist/cjs/runtime/sendEmailParamsTypes.test-d.js +29 -29
- package/dist/cjs/runtime/writeResultTypes.test-d.js +8 -8
- package/dist/cjs/sourceRoots.js +15 -15
- package/dist/cjs/sourceRoots.test.js +29 -27
- package/dist/cjs/start/build/entries.d.ts +25 -0
- package/dist/cjs/start/build/entries.js +121 -0
- package/dist/cjs/start/build/placeholders/devApp.d.ts +1 -0
- package/dist/cjs/start/build/placeholders/devApp.js +6 -0
- package/dist/cjs/start/describe/describeBuilt.d.ts +5 -0
- package/dist/cjs/start/describe/describeBuilt.js +144 -0
- package/dist/cjs/start/platform/aiUsage.d.ts +29 -0
- package/dist/cjs/start/platform/aiUsage.js +215 -0
- package/dist/cjs/start/platform/airtable/cache.d.ts +17 -0
- package/dist/cjs/start/platform/airtable/cache.js +93 -0
- package/dist/cjs/start/protocol.d.ts +19 -0
- package/dist/cjs/start/protocol.js +33 -0
- package/dist/cjs/start/serve/local/provider.d.ts +25 -0
- package/dist/cjs/start/serve/local/provider.js +196 -0
- package/dist/cjs/start/serve/provider.d.ts +19 -0
- package/dist/cjs/start/serve/provider.js +86 -0
- package/dist/cjs/start/types.d.ts +373 -0
- package/dist/cjs/start/types.js +2 -0
- package/dist/cjs/steps/index.d.ts +8 -8
- package/dist/cjs/steps/index.js +53 -53
- package/dist/cjs/steps/index.test.js +218 -218
- package/dist/cjs/sync/index.d.ts +1 -1
- package/dist/cjs/sync/index.js +28 -27
- package/dist/cjs/sync/lib.d.ts +15 -8
- package/dist/cjs/sync/lib.js +651 -665
- package/dist/cjs/sync/lib.test.js +81 -14
- package/dist/cjs/sync/sdkNames.d.ts +67 -9
- package/dist/cjs/sync/sdkNames.js +97 -31
- package/dist/cjs/sync/sdkNames.test.js +189 -113
- package/dist/cjs/types/fields.d.ts +1 -1
- package/dist/cjs/types/fields.js +105 -97
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/cjs/types/tables.d.ts +1 -1
- package/dist/cjs/upload/index.js +89 -24
- package/dist/cjs/upload/index.test.js +104 -1
- package/dist/cjs/vite/domTagNames.js +252 -252
- package/dist/cjs/vite/index.d.ts +1 -1
- package/dist/cjs/vite/index.js +51 -42
- package/dist/cjs/vite/index.test.js +10 -2
- package/dist/esm/auth/actions.d.ts +28 -0
- package/dist/esm/auth/actions.js +55 -0
- package/dist/esm/auth/client.d.ts +357 -0
- package/dist/esm/auth/client.js +62 -0
- package/dist/esm/auth/config.js +9 -3
- package/dist/esm/auth/index.d.ts +2 -249
- package/dist/esm/auth/index.js +2 -103
- package/dist/esm/auth/index.test.js +60 -0
- package/dist/esm/auth/previewClaim.d.ts +7 -0
- package/dist/esm/auth/previewClaim.js +12 -0
- package/dist/esm/auth/profileUpdates.d.ts +9 -0
- package/dist/esm/auth/profileUpdates.js +6 -0
- package/dist/esm/backend/index.d.ts +6 -6
- package/dist/esm/backend/index.js +13 -13
- package/dist/esm/backend/index.test.js +106 -106
- package/dist/esm/bundle/index.js +29 -16
- package/dist/esm/caller/index.js +44 -44
- package/dist/esm/check/index.d.ts +44 -1
- package/dist/esm/check/index.js +194 -61
- package/dist/esm/check/start/routeTree.d.ts +8 -0
- package/dist/esm/check/start/routeTree.js +77 -0
- package/dist/esm/check/start/tsgo.d.ts +2 -0
- package/dist/esm/check/start/tsgo.js +29 -0
- package/dist/esm/cli.js +19 -6
- package/dist/esm/client/index.d.ts +2 -2
- package/dist/esm/client/index.js +25 -25
- package/dist/esm/dev/index.js +88 -60
- package/dist/esm/dev/signin.d.ts +16 -0
- package/dist/esm/dev/signin.js +80 -0
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +3 -3
- package/dist/esm/integrations/client.d.ts +3 -3
- package/dist/esm/integrations/client.js +6 -5
- package/dist/esm/integrations/client.test-d.js +19 -19
- package/dist/esm/integrations/index.d.ts +2 -2
- package/dist/esm/integrations/index.js +1 -1
- package/dist/esm/integrations/rules.js +42 -42
- package/dist/esm/integrations/rules.test.js +62 -57
- package/dist/esm/internal/appMode.d.ts +14 -0
- package/dist/esm/internal/appMode.js +13 -0
- package/dist/esm/internal/env.js +3 -2
- package/dist/esm/internal/platformFetch.d.ts +2 -0
- package/dist/esm/internal/platformFetch.js +9 -0
- package/dist/esm/internal/reservedIds.d.ts +8 -0
- package/dist/esm/internal/reservedIds.js +10 -0
- package/dist/esm/internal/serviceUrls.d.ts +5 -0
- package/dist/esm/internal/serviceUrls.js +10 -0
- package/dist/esm/pdf/index.js +2 -1
- package/dist/esm/runtime/filterConditionTypes.test-d.js +12 -12
- package/dist/esm/runtime/index.d.ts +22 -22
- package/dist/esm/runtime/index.js +31 -31
- package/dist/esm/runtime/index.test.js +36 -36
- package/dist/esm/runtime/sendEmailParamsTypes.test-d.js +30 -30
- package/dist/esm/runtime/writeResultTypes.test-d.js +9 -9
- package/dist/esm/signin/conformance.d.ts +100 -0
- package/dist/esm/signin/conformance.js +616 -0
- package/dist/esm/signin/cookies.d.ts +28 -0
- package/dist/esm/signin/cookies.js +67 -0
- package/dist/esm/signin/encoding.d.ts +1 -0
- package/dist/esm/signin/encoding.js +12 -0
- package/dist/esm/signin/endpoints.d.ts +12 -0
- package/dist/esm/signin/endpoints.js +32 -0
- package/dist/esm/signin/http.d.ts +25 -0
- package/dist/esm/signin/http.js +106 -0
- package/dist/esm/signin/index.d.ts +8 -0
- package/dist/esm/signin/index.js +9 -0
- package/dist/esm/signin/keys.d.ts +35 -0
- package/dist/esm/signin/keys.js +230 -0
- package/dist/esm/signin/paths.d.ts +2 -0
- package/dist/esm/signin/paths.js +5 -0
- package/dist/esm/signin/seal.d.ts +19 -0
- package/dist/esm/signin/seal.js +47 -0
- package/dist/esm/signin/signin.d.ts +60 -0
- package/dist/esm/signin/signin.js +447 -0
- package/dist/esm/signin/transport.d.ts +112 -0
- package/dist/esm/signin/transport.js +1 -0
- package/dist/esm/signin/verifier.d.ts +2 -0
- package/dist/esm/signin/verifier.js +4 -0
- package/dist/esm/signin/verify.d.ts +83 -0
- package/dist/esm/signin/verify.js +142 -0
- package/dist/esm/sourceRoots.js +17 -17
- package/dist/esm/sourceRoots.test.js +34 -32
- package/dist/esm/start/access.d.ts +19 -0
- package/dist/esm/start/access.js +43 -0
- package/dist/esm/start/auth.d.ts +28 -0
- package/dist/esm/start/auth.js +33 -0
- package/dist/esm/start/automations/quiet.d.ts +2 -0
- package/dist/esm/start/automations/quiet.js +36 -0
- package/dist/esm/start/automations/registration.d.ts +13 -0
- package/dist/esm/start/automations/registration.js +25 -0
- package/dist/esm/start/automations/steps.d.ts +29 -0
- package/dist/esm/start/automations/steps.js +95 -0
- package/dist/esm/start/automations/workflow.d.ts +83 -0
- package/dist/esm/start/automations/workflow.js +36 -0
- package/dist/esm/start/automations/workflow.test-d.d.ts +1 -0
- package/dist/esm/start/automations/workflow.test-d.js +130 -0
- package/dist/esm/start/automations/workflowRun.d.ts +130 -0
- package/dist/esm/start/automations/workflowRun.js +185 -0
- package/dist/esm/start/barrel.test-d.d.ts +10 -0
- package/dist/esm/start/barrel.test-d.js +6 -0
- package/dist/esm/start/build/entries.d.ts +25 -0
- package/dist/esm/start/build/entries.js +109 -0
- package/dist/esm/start/build/placeholders/authHooksModule.d.ts +1 -0
- package/dist/esm/start/build/placeholders/authHooksModule.js +3 -0
- package/dist/esm/start/build/placeholders/devApp.d.ts +1 -0
- package/dist/esm/start/build/placeholders/devApp.js +3 -0
- package/dist/esm/start/build/placeholders/devSignIn.d.ts +1 -0
- package/dist/esm/start/build/placeholders/devSignIn.js +3 -0
- package/dist/esm/start/build/placeholders/siteHead.d.ts +2 -0
- package/dist/esm/start/build/placeholders/siteHead.js +3 -0
- package/dist/esm/start/build/placeholders/workflowModules.d.ts +1 -0
- package/dist/esm/start/build/placeholders/workflowModules.js +3 -0
- package/dist/esm/start/build/placeholders/workspaceSchema.d.ts +2 -0
- package/dist/esm/start/build/placeholders/workspaceSchema.js +3 -0
- package/dist/esm/start/build/registrationHash.d.ts +11 -0
- package/dist/esm/start/build/registrationHash.js +88 -0
- package/dist/esm/start/build/sdk/axios.d.ts +76 -0
- package/dist/esm/start/build/sdk/axios.js +253 -0
- package/dist/esm/start/build/sdk/nodeFetch.d.ts +41 -0
- package/dist/esm/start/build/sdk/nodeFetch.js +35 -0
- package/dist/esm/start/build/sdk/undici.d.ts +34 -0
- package/dist/esm/start/build/sdk/undici.js +18 -0
- package/dist/esm/start/build/sdkPatches.d.ts +22 -0
- package/dist/esm/start/build/sdkPatches.js +430 -0
- package/dist/esm/start/build/siteHead.d.ts +26 -0
- package/dist/esm/start/build/siteHead.js +88 -0
- package/dist/esm/start/build/vite.d.ts +50 -0
- package/dist/esm/start/build/vite.js +487 -0
- package/dist/esm/start/classicOnly.d.ts +1 -0
- package/dist/esm/start/classicOnly.js +4 -0
- package/dist/esm/start/clientErrorMessage.test.d.ts +1 -0
- package/dist/esm/start/clientErrorMessage.test.js +105 -0
- package/dist/esm/start/describe/describe.d.ts +120 -0
- package/dist/esm/start/describe/describe.js +372 -0
- package/dist/esm/start/describe/describeBuilt.d.ts +5 -0
- package/dist/esm/start/describe/describeBuilt.js +102 -0
- package/dist/esm/start/describe/descriptions.d.ts +4 -0
- package/dist/esm/start/describe/descriptions.js +54 -0
- package/dist/esm/start/errors.d.ts +62 -0
- package/dist/esm/start/errors.js +163 -0
- package/dist/esm/start/errors.test.d.ts +1 -0
- package/dist/esm/start/errors.test.js +54 -0
- package/dist/esm/start/factories.d.ts +14 -0
- package/dist/esm/start/factories.js +23 -0
- package/dist/esm/start/factories.test-d.d.ts +2 -0
- package/dist/esm/start/factories.test-d.js +60 -0
- package/dist/esm/start/failures.d.ts +7 -0
- package/dist/esm/start/failures.js +62 -0
- package/dist/esm/start/fnFactory.d.ts +16 -0
- package/dist/esm/start/fnFactory.js +1 -0
- package/dist/esm/start/host.d.ts +3 -0
- package/dist/esm/start/host.js +4 -0
- package/dist/esm/start/index.d.ts +10 -0
- package/dist/esm/start/index.js +7 -0
- package/dist/esm/start/login.d.ts +5 -0
- package/dist/esm/start/login.js +29 -0
- package/dist/esm/start/middlewareKind.d.ts +13 -0
- package/dist/esm/start/middlewareKind.js +9 -0
- package/dist/esm/start/platform/aiUsage.d.ts +29 -0
- package/dist/esm/start/platform/aiUsage.js +210 -0
- package/dist/esm/start/platform/airtable/arrayFields.d.ts +10 -0
- package/dist/esm/start/platform/airtable/arrayFields.js +30 -0
- package/dist/esm/start/platform/airtable/built.d.ts +2 -0
- package/dist/esm/start/platform/airtable/built.js +3 -0
- package/dist/esm/start/platform/airtable/cache.d.ts +17 -0
- package/dist/esm/start/platform/airtable/cache.js +89 -0
- package/dist/esm/start/platform/airtable/dispatch.d.ts +57 -0
- package/dist/esm/start/platform/airtable/dispatch.js +541 -0
- package/dist/esm/start/platform/airtable/formulas.d.ts +70 -0
- package/dist/esm/start/platform/airtable/formulas.js +261 -0
- package/dist/esm/start/platform/airtable/index.d.ts +6 -0
- package/dist/esm/start/platform/airtable/index.js +51 -0
- package/dist/esm/start/platform/airtable/settings.d.ts +37 -0
- package/dist/esm/start/platform/airtable/settings.js +138 -0
- package/dist/esm/start/platform/analytics.d.ts +3 -0
- package/dist/esm/start/platform/analytics.js +59 -0
- package/dist/esm/start/platform/calls.d.ts +5 -0
- package/dist/esm/start/platform/calls.js +104 -0
- package/dist/esm/start/platform/caps.d.ts +9 -0
- package/dist/esm/start/platform/caps.js +35 -0
- package/dist/esm/start/platform/connections.d.ts +25 -0
- package/dist/esm/start/platform/connections.js +198 -0
- package/dist/esm/start/platform/data/baseRunner.d.ts +97 -0
- package/dist/esm/start/platform/data/baseRunner.js +117 -0
- package/dist/esm/start/platform/data/dispatch.d.ts +17 -0
- package/dist/esm/start/platform/data/dispatch.js +216 -0
- package/dist/esm/start/platform/data/fetch.d.ts +7 -0
- package/dist/esm/start/platform/data/fetch.js +9 -0
- package/dist/esm/start/platform/data/index.d.ts +27 -0
- package/dist/esm/start/platform/data/index.js +75 -0
- package/dist/esm/start/platform/data/names.d.ts +7 -0
- package/dist/esm/start/platform/data/names.js +18 -0
- package/dist/esm/start/platform/data/sqlNameMappings.d.ts +58 -0
- package/dist/esm/start/platform/data/sqlNameMappings.js +92 -0
- package/dist/esm/start/platform/data/transformations.d.ts +97 -0
- package/dist/esm/start/platform/data/transformations.js +262 -0
- package/dist/esm/start/platform/data/types.d.ts +94 -0
- package/dist/esm/start/platform/data/types.js +14 -0
- package/dist/esm/start/platform/local.d.ts +6 -0
- package/dist/esm/start/platform/local.js +18 -0
- package/dist/esm/start/platform/meta.d.ts +3 -0
- package/dist/esm/start/platform/meta.js +33 -0
- package/dist/esm/start/platform/outbound.d.ts +17 -0
- package/dist/esm/start/platform/outbound.js +510 -0
- package/dist/esm/start/platform/redactSecrets.d.ts +13 -0
- package/dist/esm/start/platform/redactSecrets.js +156 -0
- package/dist/esm/start/platform/redactSecrets.test.d.ts +1 -0
- package/dist/esm/start/platform/redactSecrets.test.js +151 -0
- package/dist/esm/start/platform/requestSecrets.d.ts +15 -0
- package/dist/esm/start/platform/requestSecrets.js +41 -0
- package/dist/esm/start/platform/runLog.d.ts +40 -0
- package/dist/esm/start/platform/runLog.js +149 -0
- package/dist/esm/start/platform/services.d.ts +7 -0
- package/dist/esm/start/platform/services.js +46 -0
- package/dist/esm/start/platform/steps.d.ts +9 -0
- package/dist/esm/start/platform/steps.js +60 -0
- package/dist/esm/start/platform/telemetry.d.ts +13 -0
- package/dist/esm/start/platform/telemetry.js +71 -0
- package/dist/esm/start/platform/transport.d.ts +28 -0
- package/dist/esm/start/platform/transport.js +59 -0
- package/dist/esm/start/platformHead.d.ts +23 -0
- package/dist/esm/start/platformHead.js +133 -0
- package/dist/esm/start/previewClaim.d.ts +6 -0
- package/dist/esm/start/previewClaim.js +24 -0
- package/dist/esm/start/protocol.d.ts +19 -0
- package/dist/esm/start/protocol.js +27 -0
- package/dist/esm/start/roles.d.ts +12 -0
- package/dist/esm/start/roles.js +27 -0
- package/dist/esm/start/router.d.ts +44 -0
- package/dist/esm/start/router.js +280 -0
- package/dist/esm/start/serve/authHooks.d.ts +7 -0
- package/dist/esm/start/serve/authHooks.js +18 -0
- package/dist/esm/start/serve/demo.d.ts +9 -0
- package/dist/esm/start/serve/demo.js +24 -0
- package/dist/esm/start/serve/fetch.d.ts +1 -0
- package/dist/esm/start/serve/fetch.js +6 -0
- package/dist/esm/start/serve/instance.d.ts +12 -0
- package/dist/esm/start/serve/instance.js +134 -0
- package/dist/esm/start/serve/invoke.d.ts +13 -0
- package/dist/esm/start/serve/invoke.js +126 -0
- package/dist/esm/start/serve/local/load.d.ts +8 -0
- package/dist/esm/start/serve/local/load.js +44 -0
- package/dist/esm/start/serve/local/provider.d.ts +25 -0
- package/dist/esm/start/serve/local/provider.js +188 -0
- package/dist/esm/start/serve/local/signIn.d.ts +28 -0
- package/dist/esm/start/serve/local/signIn.js +123 -0
- package/dist/esm/start/serve/pageHead.d.ts +20 -0
- package/dist/esm/start/serve/pageHead.js +34 -0
- package/dist/esm/start/serve/provider.d.ts +19 -0
- package/dist/esm/start/serve/provider.js +78 -0
- package/dist/esm/start/serve/requestEnv.d.ts +2 -0
- package/dist/esm/start/serve/requestEnv.js +84 -0
- package/dist/esm/start/serve/scope.d.ts +18 -0
- package/dist/esm/start/serve/scope.js +67 -0
- package/dist/esm/start/serve/server.d.ts +56 -0
- package/dist/esm/start/serve/server.js +297 -0
- package/dist/esm/start/serve/uploads.d.ts +2 -0
- package/dist/esm/start/serve/uploads.js +49 -0
- package/dist/esm/start/serve/worker.d.ts +6 -0
- package/dist/esm/start/serve/worker.js +12 -0
- package/dist/esm/start/types.d.ts +373 -0
- package/dist/esm/start/types.js +1 -0
- package/dist/esm/start/version.d.ts +1 -0
- package/dist/esm/start/version.js +2 -0
- package/dist/esm/steps/index.d.ts +8 -8
- package/dist/esm/steps/index.js +54 -54
- package/dist/esm/steps/index.test.js +220 -220
- package/dist/esm/sync/index.d.ts +1 -1
- package/dist/esm/sync/index.js +32 -31
- package/dist/esm/sync/lib.d.ts +15 -8
- package/dist/esm/sync/lib.js +655 -669
- package/dist/esm/sync/lib.test.js +81 -14
- package/dist/esm/sync/sdkNames.d.ts +67 -9
- package/dist/esm/sync/sdkNames.js +94 -30
- package/dist/esm/sync/sdkNames.test.js +192 -116
- package/dist/esm/types/fields.d.ts +1 -1
- package/dist/esm/types/fields.js +106 -98
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/types/index.js +2 -2
- package/dist/esm/types/tables.d.ts +1 -1
- package/dist/esm/types/tables.js +2 -2
- package/dist/esm/upload/index.js +89 -24
- package/dist/esm/upload/index.test.js +104 -1
- package/dist/esm/vite/domTagNames.js +252 -252
- package/dist/esm/vite/index.d.ts +1 -1
- package/dist/esm/vite/index.js +56 -47
- package/dist/esm/vite/index.test.js +10 -2
- package/package.json +129 -16
- package/dist/cjs/auth-server/index.d.ts +0 -369
- package/dist/cjs/auth-server/index.js +0 -119
- package/dist/cjs/meta/index.d.ts +0 -14
- package/dist/cjs/meta/index.js +0 -12
- package/dist/cjs/notifications/index.d.ts +0 -25
- package/dist/cjs/notifications/index.js +0 -12
- package/dist/esm/auth-server/index.d.ts +0 -369
- package/dist/esm/auth-server/index.js +0 -116
- package/dist/esm/meta/index.d.ts +0 -14
- package/dist/esm/meta/index.js +0 -8
- package/dist/esm/notifications/index.d.ts +0 -25
- package/dist/esm/notifications/index.js +0 -8
|
@@ -0,0 +1,616 @@
|
|
|
1
|
+
// `zitejs/signin/conformance`: the sign-in scenarios (T5 design §9), for tests only. One list drives two runners:
|
|
2
|
+
// zitejs's, with the module mounted in the Node fixture against a fake issuer, and restly's, with the dispatcher and
|
|
3
|
+
// the real identity Worker. No dependencies, so either can import it.
|
|
4
|
+
/** A cookie jar per host and manual redirects: enough of a browser for sign-in's cross-origin hops. */
|
|
5
|
+
export class Browser {
|
|
6
|
+
target;
|
|
7
|
+
jars = new Map();
|
|
8
|
+
seenSetCookies = [];
|
|
9
|
+
constructor(target) {
|
|
10
|
+
this.target = target;
|
|
11
|
+
}
|
|
12
|
+
jar(host) {
|
|
13
|
+
let jar = this.jars.get(host);
|
|
14
|
+
if (!jar)
|
|
15
|
+
this.jars.set(host, (jar = new Map()));
|
|
16
|
+
return jar;
|
|
17
|
+
}
|
|
18
|
+
/** The cookies a request to `url` carries, as a Cookie header. */
|
|
19
|
+
cookieHeader(url) {
|
|
20
|
+
const jar = this.jar(new URL(url).host);
|
|
21
|
+
const now = Date.now();
|
|
22
|
+
for (const [name, { expiresAt }] of jar)
|
|
23
|
+
if (expiresAt !== undefined && expiresAt <= now)
|
|
24
|
+
jar.delete(name);
|
|
25
|
+
return jar.size
|
|
26
|
+
? [...jar].map(([name, { value }]) => `${name}=${value}`).join('; ')
|
|
27
|
+
: null;
|
|
28
|
+
}
|
|
29
|
+
get(url, name) {
|
|
30
|
+
this.cookieHeader(url);
|
|
31
|
+
return this.jar(new URL(url).host).get(name);
|
|
32
|
+
}
|
|
33
|
+
set(url, name, value) {
|
|
34
|
+
this.jar(new URL(url).host).set(name, { value, attributes: '' });
|
|
35
|
+
}
|
|
36
|
+
/** Every cookie this browser holds for `url`'s host, to copy into another browser. */
|
|
37
|
+
copyFrom(other, url) {
|
|
38
|
+
other.cookieHeader(url);
|
|
39
|
+
for (const [name, stored] of other.jar(new URL(url).host))
|
|
40
|
+
this.jar(new URL(url).host).set(name, { ...stored });
|
|
41
|
+
}
|
|
42
|
+
store(host, cookie) {
|
|
43
|
+
this.seenSetCookies.push({ host, cookie });
|
|
44
|
+
const [pair = '', ...rest] = cookie.split(';');
|
|
45
|
+
const eq = pair.indexOf('=');
|
|
46
|
+
const name = pair.slice(0, eq).trim();
|
|
47
|
+
const value = pair.slice(eq + 1).trim();
|
|
48
|
+
const attributes = rest.join(';');
|
|
49
|
+
const maxAge = /max-age=(-?\d+)/i.exec(attributes)?.[1];
|
|
50
|
+
if ((maxAge !== undefined && Number(maxAge) <= 0) ||
|
|
51
|
+
(!value && maxAge === undefined)) {
|
|
52
|
+
this.jar(host).delete(name);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.jar(host).set(name, {
|
|
56
|
+
value,
|
|
57
|
+
attributes,
|
|
58
|
+
...(maxAge !== undefined && {
|
|
59
|
+
expiresAt: Date.now() + Number(maxAge) * 1000,
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** One request with this browser's cookies; stores what it sets. */
|
|
64
|
+
async request(url, init = {}) {
|
|
65
|
+
const headers = new Headers(init.headers);
|
|
66
|
+
const cookie = this.cookieHeader(url);
|
|
67
|
+
if (cookie && !headers.has('cookie'))
|
|
68
|
+
headers.set('cookie', cookie);
|
|
69
|
+
const response = await this.target.fetch(new Request(url, { ...init, headers, redirect: 'manual' }));
|
|
70
|
+
for (const set of response.headers.getSetCookie())
|
|
71
|
+
this.store(new URL(url).host, set);
|
|
72
|
+
return response;
|
|
73
|
+
}
|
|
74
|
+
/** A top-level navigation, following redirects. */
|
|
75
|
+
async navigate(url, init = {}) {
|
|
76
|
+
let at = url;
|
|
77
|
+
let response = await this.request(at, {
|
|
78
|
+
...init,
|
|
79
|
+
headers: { accept: 'text/html', ...init.headers },
|
|
80
|
+
});
|
|
81
|
+
for (let hops = 0; response.status >= 300 && response.status < 400 && hops < 20; hops++) {
|
|
82
|
+
at = new URL(response.headers.get('location') ?? '', at).href;
|
|
83
|
+
response = await this.request(at, { headers: { accept: 'text/html' } });
|
|
84
|
+
}
|
|
85
|
+
return { url: at, response };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
89
|
+
const MODULE_COOKIE = /^(?:__host-)?zite_(?:id|signin|session)$/i;
|
|
90
|
+
const PLATFORM_COOKIE = /^(?:__(?:secure|host)-)?(?:better-auth\.|zite_)/i;
|
|
91
|
+
const cookieNames = (target) => {
|
|
92
|
+
const secure = new URL(target.appOrigin).protocol === 'https:';
|
|
93
|
+
const name = (base) => (secure ? `__Host-${base}` : base);
|
|
94
|
+
return {
|
|
95
|
+
secure,
|
|
96
|
+
identity: name('zite_id'),
|
|
97
|
+
flow: name('zite_signin'),
|
|
98
|
+
session: name('zite_session'),
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
const modeOf = (target) => target.clientId.split(':')[1] ?? '';
|
|
102
|
+
const echo = async (target, browser, headers = {}) => {
|
|
103
|
+
const response = await browser.request(`${target.appOrigin}${target.echoPath}`, { headers: { accept: 'application/json', ...headers } });
|
|
104
|
+
const text = await response.text();
|
|
105
|
+
try {
|
|
106
|
+
return { echo: JSON.parse(text), text, response };
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
throw new Error(`the echo path answered ${response.status}: ${text.slice(0, 300)}`);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
/** Signs `email` in through the whole flow; answers where the browser ended up. */
|
|
113
|
+
const signIn = async (target, browser, email, returnTo = '/') => {
|
|
114
|
+
const login = `${target.appOrigin}/auth/login?redirectUrl=${encodeURIComponent(new URL(returnTo, target.appOrigin).href)}`;
|
|
115
|
+
const page = await browser.navigate(login);
|
|
116
|
+
if (new URL(page.url).origin === target.appOrigin &&
|
|
117
|
+
!page.url.includes('/auth/sign-in'))
|
|
118
|
+
return page.url;
|
|
119
|
+
const next = await target.completeSignIn(browser, page.url, email);
|
|
120
|
+
return (await browser.navigate(next)).url;
|
|
121
|
+
};
|
|
122
|
+
const baseClaims = (target, overrides = {}) => {
|
|
123
|
+
const now = Math.floor(Date.now() / 1000);
|
|
124
|
+
return {
|
|
125
|
+
iss: target.issuer,
|
|
126
|
+
sub: 'u_forged',
|
|
127
|
+
aud: target.clientId,
|
|
128
|
+
iat: now,
|
|
129
|
+
exp: now + target.identityLifetimeS,
|
|
130
|
+
email: 'forged@x.co',
|
|
131
|
+
name: 'Forged',
|
|
132
|
+
roles: [],
|
|
133
|
+
isInternal: false,
|
|
134
|
+
mode: modeOf(target),
|
|
135
|
+
ver: target.ver ?? null,
|
|
136
|
+
...overrides,
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
const attributesOf = (cookie) => cookie
|
|
140
|
+
.split(';')
|
|
141
|
+
.slice(1)
|
|
142
|
+
.map(a => a.trim().toLowerCase());
|
|
143
|
+
const waitOutIdentity = (target) => sleep((target.identityLifetimeS + 1) * 1000);
|
|
144
|
+
const sameOrigin = (target) => ({
|
|
145
|
+
origin: target.appOrigin,
|
|
146
|
+
'sec-fetch-site': 'same-origin',
|
|
147
|
+
});
|
|
148
|
+
export const scenarios = [
|
|
149
|
+
{
|
|
150
|
+
id: 'S1',
|
|
151
|
+
title: 'an anonymous visitor reaches a page, signed out, with no sign-in cookies set',
|
|
152
|
+
runners: ['zite', 'local'],
|
|
153
|
+
async run({ target, browser, check }) {
|
|
154
|
+
const visitor = browser();
|
|
155
|
+
const page = await visitor.navigate(`${target.appOrigin}/`);
|
|
156
|
+
check(target.appAnswered(page.response) &&
|
|
157
|
+
page.url === `${target.appOrigin}/`, 'app code answers the page, in place', page.url);
|
|
158
|
+
const { echo: seen } = await echo(target, visitor);
|
|
159
|
+
check(seen.user === null, 'app code sees nobody', seen);
|
|
160
|
+
check(!visitor.seenSetCookies.some(({ cookie }) => MODULE_COOKIE.test(cookie.split('=')[0])), 'no module cookie is set', visitor.seenSetCookies);
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
id: 'S2',
|
|
165
|
+
title: '/auth/login sets the flow cookie and redirects to authorize with PKCE, state and nonce',
|
|
166
|
+
runners: ['zite', 'local'],
|
|
167
|
+
async run({ target, browser, check }) {
|
|
168
|
+
const visitor = browser();
|
|
169
|
+
const response = await visitor.request(`${target.appOrigin}/auth/login`);
|
|
170
|
+
const location = new URL(response.headers.get('location') ?? '', target.appOrigin);
|
|
171
|
+
const query = Object.fromEntries(location.searchParams);
|
|
172
|
+
check(response.status === 302 &&
|
|
173
|
+
location.pathname.endsWith('/api/auth/oauth2/authorize'), '302 to the authorize endpoint', location.href);
|
|
174
|
+
check(query.response_type === 'code' &&
|
|
175
|
+
query.client_id === target.clientId &&
|
|
176
|
+
query.redirect_uri === `${target.appOrigin}/auth/callback` &&
|
|
177
|
+
query.code_challenge_method === 'S256' &&
|
|
178
|
+
!!query.code_challenge &&
|
|
179
|
+
!!query.state &&
|
|
180
|
+
!!query.nonce, 'the authorization request names the client, the callback and PKCE', query);
|
|
181
|
+
const scopes = (query.scope ?? '').split(' ');
|
|
182
|
+
check(scopes.includes('openid') &&
|
|
183
|
+
scopes.includes('offline_access') === (target.runner === 'local'), 'offline_access only off Zite', query.scope);
|
|
184
|
+
const names = cookieNames(target);
|
|
185
|
+
const flow = visitor.seenSetCookies.find(({ cookie }) => cookie.startsWith(`${names.flow}=`))?.cookie ?? '';
|
|
186
|
+
const attributes = attributesOf(flow);
|
|
187
|
+
check(attributes.includes('httponly') &&
|
|
188
|
+
attributes.includes('path=/') &&
|
|
189
|
+
attributes.includes('max-age=600') &&
|
|
190
|
+
!attributes.some(a => a.startsWith('domain')) &&
|
|
191
|
+
attributes.includes('secure') === names.secure, 'the flow cookie is HttpOnly, host-only, 600 s', flow);
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
id: 'S3',
|
|
196
|
+
title: 'email sign-in end to end sets the identity cookie, clears the flow, and returns same-origin only',
|
|
197
|
+
runners: ['zite', 'local'],
|
|
198
|
+
async run({ target, browser, check }) {
|
|
199
|
+
const email = await target.createUser();
|
|
200
|
+
const visitor = browser();
|
|
201
|
+
const landed = await signIn(target, visitor, email, '/about?tab=2');
|
|
202
|
+
check(landed === `${target.appOrigin}/about?tab=2`, 'back where sign-in started', landed);
|
|
203
|
+
const names = cookieNames(target);
|
|
204
|
+
const identity = [...visitor.seenSetCookies]
|
|
205
|
+
.reverse()
|
|
206
|
+
.find(({ cookie }) => cookie.startsWith(`${names.identity}=`))
|
|
207
|
+
?.cookie ?? '';
|
|
208
|
+
const attributes = attributesOf(identity);
|
|
209
|
+
const maxAge = Number(attributes.find(a => a.startsWith('max-age='))?.slice(8));
|
|
210
|
+
check(attributes.includes('httponly') &&
|
|
211
|
+
attributes.includes('path=/') &&
|
|
212
|
+
attributes.includes('samesite=lax') &&
|
|
213
|
+
maxAge > 0 &&
|
|
214
|
+
maxAge <= 300 &&
|
|
215
|
+
!attributes.some(a => a.startsWith('domain')), 'the identity cookie is HttpOnly, Lax, host-only and short', identity);
|
|
216
|
+
check(!visitor.get(target.appOrigin, names.flow), 'the flow cookie is gone', visitor.cookieHeader(target.appOrigin));
|
|
217
|
+
const elsewhere = await signIn(target, browser(), email, 'https://evil.example/steal');
|
|
218
|
+
check(elsewhere === `${target.appOrigin}/`, "a foreign return address lands on the app's root", elsewhere);
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
id: 'S4',
|
|
223
|
+
title: 'the user reaches app code, and an x-zite-user header from the browser is ignored',
|
|
224
|
+
runners: ['zite', 'local'],
|
|
225
|
+
async run({ target, browser, check }) {
|
|
226
|
+
const email = await target.createUser();
|
|
227
|
+
const visitor = browser();
|
|
228
|
+
await signIn(target, visitor, email);
|
|
229
|
+
const forged = btoa(JSON.stringify({
|
|
230
|
+
id: 'u_mallory',
|
|
231
|
+
email: 'm@x.co',
|
|
232
|
+
name: 'M',
|
|
233
|
+
roles: [],
|
|
234
|
+
isInternal: true,
|
|
235
|
+
}))
|
|
236
|
+
.replace(/\+/g, '-')
|
|
237
|
+
.replace(/\//g, '_')
|
|
238
|
+
.replace(/=+$/, '');
|
|
239
|
+
const { echo: seen } = await echo(target, visitor, {
|
|
240
|
+
'x-zite-user': forged,
|
|
241
|
+
});
|
|
242
|
+
check(seen.user?.email === email, "app code sees the signed-in user, not the header's", seen);
|
|
243
|
+
const { echo: anonymous } = await echo(target, browser(), {
|
|
244
|
+
'x-zite-user': forged,
|
|
245
|
+
});
|
|
246
|
+
check(anonymous.user === null, 'nor does a header sign anyone in', anonymous);
|
|
247
|
+
const posted = await visitor.request(`${target.appOrigin}${target.echoPath}`, {
|
|
248
|
+
method: 'POST',
|
|
249
|
+
headers: {
|
|
250
|
+
...sameOrigin(target),
|
|
251
|
+
'content-type': 'application/json',
|
|
252
|
+
},
|
|
253
|
+
body: JSON.stringify({ hello: 'world' }),
|
|
254
|
+
});
|
|
255
|
+
const postedEcho = (await posted.json().catch(() => null));
|
|
256
|
+
check(posted.status === 200 && postedEcho?.user?.email === email, 'a same-origin POST with a body reaches app code as the user', postedEcho);
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
id: 'S5',
|
|
261
|
+
title: 'an expired identity is renewed from the long-lived credential',
|
|
262
|
+
runners: ['zite', 'local'],
|
|
263
|
+
async run({ target, browser, check }) {
|
|
264
|
+
const email = await target.createUser();
|
|
265
|
+
const visitor = browser();
|
|
266
|
+
await signIn(target, visitor, email);
|
|
267
|
+
const names = cookieNames(target);
|
|
268
|
+
const first = visitor.get(target.appOrigin, names.identity)?.value;
|
|
269
|
+
await waitOutIdentity(target);
|
|
270
|
+
const { echo: seen } = await echo(target, visitor);
|
|
271
|
+
const renewed = visitor.get(target.appOrigin, names.identity)?.value;
|
|
272
|
+
check(seen.user?.email === email, 'still signed in after the identity lapsed', seen);
|
|
273
|
+
check(!!renewed && renewed !== first, 'a new identity cookie', {
|
|
274
|
+
first,
|
|
275
|
+
renewed,
|
|
276
|
+
});
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
id: 'S6',
|
|
281
|
+
title: 'an internal app refuses a page, a server function and a call without a session, before app code',
|
|
282
|
+
runners: ['zite'],
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
id: 'S7',
|
|
286
|
+
title: 'forged identity cookies are refused and cleared',
|
|
287
|
+
runners: ['zite', 'local'],
|
|
288
|
+
async run({ target, browser, check }) {
|
|
289
|
+
const names = cookieNames(target);
|
|
290
|
+
const [app] = target.clientId.split(':');
|
|
291
|
+
const otherMode = modeOf(target) === 'live' ? 'preview' : 'live';
|
|
292
|
+
const appToken = await target.mint({
|
|
293
|
+
claims: {
|
|
294
|
+
iss: 'zite-host',
|
|
295
|
+
aud: ['backend'],
|
|
296
|
+
iat: baseClaims(target).iat,
|
|
297
|
+
exp: baseClaims(target).exp,
|
|
298
|
+
appId: app,
|
|
299
|
+
mode: 'live',
|
|
300
|
+
appUserId: 'u_forged',
|
|
301
|
+
},
|
|
302
|
+
header: { typ: 'JWT' },
|
|
303
|
+
key: 'app-token',
|
|
304
|
+
});
|
|
305
|
+
const cases = [
|
|
306
|
+
[
|
|
307
|
+
'signed with another key',
|
|
308
|
+
target.mint({ claims: baseClaims(target), key: 'stranger' }),
|
|
309
|
+
],
|
|
310
|
+
[
|
|
311
|
+
'alg none',
|
|
312
|
+
target.mint({ claims: baseClaims(target), header: { alg: 'none' } }),
|
|
313
|
+
],
|
|
314
|
+
[
|
|
315
|
+
'HS256',
|
|
316
|
+
target.mint({ claims: baseClaims(target), header: { alg: 'HS256' } }),
|
|
317
|
+
],
|
|
318
|
+
[
|
|
319
|
+
'typ JWT',
|
|
320
|
+
target.mint({ claims: baseClaims(target), header: { typ: 'JWT' } }),
|
|
321
|
+
],
|
|
322
|
+
[
|
|
323
|
+
"another app's audience",
|
|
324
|
+
target.mint({
|
|
325
|
+
claims: baseClaims(target, { aud: `other-app:${modeOf(target)}` }),
|
|
326
|
+
}),
|
|
327
|
+
],
|
|
328
|
+
[
|
|
329
|
+
`a ${otherMode} identity`,
|
|
330
|
+
target.mint({
|
|
331
|
+
claims: baseClaims(target, {
|
|
332
|
+
aud: `${app}:${otherMode}`,
|
|
333
|
+
mode: otherMode,
|
|
334
|
+
...(otherMode === 'preview' && {
|
|
335
|
+
preview: { build: 1, editor: 'e' },
|
|
336
|
+
}),
|
|
337
|
+
}),
|
|
338
|
+
}),
|
|
339
|
+
],
|
|
340
|
+
[
|
|
341
|
+
"another host's issuer",
|
|
342
|
+
target.mint({
|
|
343
|
+
claims: baseClaims(target, { iss: 'https://other.zite.so/auth' }),
|
|
344
|
+
}),
|
|
345
|
+
],
|
|
346
|
+
['an app token in the slot', `zite_app_v1.${appToken}`],
|
|
347
|
+
["an app token's JWS in the slot", appToken],
|
|
348
|
+
...(typeof target.ver === 'number'
|
|
349
|
+
? [
|
|
350
|
+
[
|
|
351
|
+
'a stale version',
|
|
352
|
+
target.mint({
|
|
353
|
+
claims: baseClaims(target, { ver: target.ver - 1 }),
|
|
354
|
+
}),
|
|
355
|
+
],
|
|
356
|
+
]
|
|
357
|
+
: []),
|
|
358
|
+
];
|
|
359
|
+
for (const [name, token] of cases) {
|
|
360
|
+
const visitor = browser();
|
|
361
|
+
visitor.set(target.appOrigin, names.identity, await token);
|
|
362
|
+
const { echo: seen } = await echo(target, visitor);
|
|
363
|
+
check(seen.user === null, `${name}: nobody signed in`, seen);
|
|
364
|
+
check(!visitor.get(target.appOrigin, names.identity), `${name}: the cookie is cleared`, visitor.seenSetCookies);
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
id: 'S8',
|
|
370
|
+
title: 'a role change shows at the next renewal, and a removed user is refused there',
|
|
371
|
+
runners: ['zite', 'local'],
|
|
372
|
+
async run({ target, browser, check }) {
|
|
373
|
+
const email = await target.createUser(['viewer']);
|
|
374
|
+
const visitor = browser();
|
|
375
|
+
await signIn(target, visitor, email);
|
|
376
|
+
await target.setRoles(email, ['manager']);
|
|
377
|
+
await waitOutIdentity(target);
|
|
378
|
+
const { echo: changed } = await echo(target, visitor);
|
|
379
|
+
check(changed.user?.roles?.map(role => role.id).join() === 'manager', 'the new role', changed);
|
|
380
|
+
await target.removeUser(email);
|
|
381
|
+
await waitOutIdentity(target);
|
|
382
|
+
const { echo: removed } = await echo(target, visitor);
|
|
383
|
+
check(removed.user === null, 'the removed user is signed out', removed);
|
|
384
|
+
const names = cookieNames(target);
|
|
385
|
+
check(!visitor.get(target.appOrigin, names.identity), 'and holds no identity', visitor.cookieHeader(target.appOrigin));
|
|
386
|
+
},
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
id: 'S9',
|
|
390
|
+
title: "sign-out ends this browser's session; a copied identity dies with its lifetime",
|
|
391
|
+
runners: ['zite', 'local'],
|
|
392
|
+
async run({ target, browser, check }) {
|
|
393
|
+
const email = await target.createUser();
|
|
394
|
+
const visitor = browser();
|
|
395
|
+
await signIn(target, visitor, email);
|
|
396
|
+
const copy = browser();
|
|
397
|
+
copy.copyFrom(visitor, target.appOrigin);
|
|
398
|
+
const response = await visitor.request(`${target.appOrigin}/auth/logout`, { method: 'POST', headers: sameOrigin(target) });
|
|
399
|
+
check(response.status === 200, 'sign-out: 200', response.status);
|
|
400
|
+
const held = visitor.cookieHeader(target.appOrigin) ?? '';
|
|
401
|
+
check(!held
|
|
402
|
+
.split('; ')
|
|
403
|
+
.some(pair => PLATFORM_COOKIE.test(pair.split('=')[0])), 'sign-out clears every sign-in cookie', held);
|
|
404
|
+
check((await echo(target, visitor)).echo.user === null, 'signed out');
|
|
405
|
+
check((await echo(target, copy)).echo.user?.email === email, 'a copied identity holds until it lapses');
|
|
406
|
+
await waitOutIdentity(target);
|
|
407
|
+
check((await echo(target, copy)).echo.user === null, "then the copy can't renew");
|
|
408
|
+
},
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
id: 'S10',
|
|
412
|
+
title: '/auth/profile changes the two name fields only, and re-issues the identity',
|
|
413
|
+
runners: ['zite'],
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
id: 'S11',
|
|
417
|
+
title: 'a cross-site POST with the cookies is refused; same-origin is accepted',
|
|
418
|
+
runners: ['zite', 'local'],
|
|
419
|
+
async run({ target, browser, check }) {
|
|
420
|
+
const email = await target.createUser();
|
|
421
|
+
const visitor = browser();
|
|
422
|
+
await signIn(target, visitor, email);
|
|
423
|
+
const crossSite = {
|
|
424
|
+
origin: 'https://evil.example',
|
|
425
|
+
'sec-fetch-site': 'cross-site',
|
|
426
|
+
};
|
|
427
|
+
const logout = await visitor.request(`${target.appOrigin}/auth/logout`, {
|
|
428
|
+
method: 'POST',
|
|
429
|
+
headers: crossSite,
|
|
430
|
+
});
|
|
431
|
+
check(logout.status === 403, 'sign-out cross-site: 403', logout.status);
|
|
432
|
+
const update = await visitor.request(`${target.appOrigin}/auth/profile`, {
|
|
433
|
+
method: 'POST',
|
|
434
|
+
headers: { ...crossSite, 'content-type': 'application/json' },
|
|
435
|
+
body: JSON.stringify({ firstName: 'Mallory' }),
|
|
436
|
+
});
|
|
437
|
+
check(update.status === 403, 'a profile change cross-site: 403', update.status);
|
|
438
|
+
check((await echo(target, visitor)).echo.user?.email === email, 'still signed in');
|
|
439
|
+
const response = await visitor.request(`${target.appOrigin}/auth/logout`, { method: 'POST', headers: sameOrigin(target) });
|
|
440
|
+
check(response.status === 200, 'same-origin sign-out: 200', response.status);
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
id: 'S12',
|
|
445
|
+
title: 'nothing under /auth or /api/auth reaches the app',
|
|
446
|
+
runners: ['zite', 'local'],
|
|
447
|
+
async run({ target, browser, check }) {
|
|
448
|
+
const visitor = browser();
|
|
449
|
+
for (const path of [
|
|
450
|
+
'/auth/anything',
|
|
451
|
+
'/api/auth/anything',
|
|
452
|
+
'/auth',
|
|
453
|
+
'/api/auth/oauth2/introspect',
|
|
454
|
+
'/api/auth/list-sessions',
|
|
455
|
+
'/api/auth/get-session',
|
|
456
|
+
]) {
|
|
457
|
+
const response = await visitor.request(`${target.appOrigin}${path}`);
|
|
458
|
+
check(!target.appAnswered(response) && response.status >= 400, `${path} isn't the app's`, response.status);
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
id: 'S12b',
|
|
464
|
+
title: 'the token endpoint refuses a browser redeeming a :live or :preview code: invalid_client',
|
|
465
|
+
runners: ['zite'],
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
id: 'S13',
|
|
469
|
+
title: 'preview entry: the preview claim, Partitioned cookies, URL and header forms, the re-enter signal',
|
|
470
|
+
runners: ['zite'],
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
id: 'S14',
|
|
474
|
+
title: 'demo: the picker, the demo token, a removed demo user refused',
|
|
475
|
+
runners: ['zite'],
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
id: 'S16',
|
|
479
|
+
title: 'cookie hygiene: no Domain, a duplicated identity dropped, an unprefixed one ignored over https, none in app code',
|
|
480
|
+
runners: ['zite', 'local'],
|
|
481
|
+
async run({ target, browser, check }) {
|
|
482
|
+
const names = cookieNames(target);
|
|
483
|
+
const email = await target.createUser();
|
|
484
|
+
const visitor = browser();
|
|
485
|
+
await signIn(target, visitor, email);
|
|
486
|
+
const appHost = new URL(target.appOrigin).host;
|
|
487
|
+
const ours = visitor.seenSetCookies
|
|
488
|
+
.filter(({ host }) => host === appHost)
|
|
489
|
+
.map(({ cookie }) => cookie);
|
|
490
|
+
check(ours.length > 0 &&
|
|
491
|
+
ours.every(cookie => !attributesOf(cookie).some(a => a.startsWith('domain'))), 'no Set-Cookie names a Domain', ours);
|
|
492
|
+
const identity = visitor.get(target.appOrigin, names.identity)?.value ?? '';
|
|
493
|
+
const duplicated = await echo(target, browser(), {
|
|
494
|
+
cookie: `${names.identity}=${identity}; ${names.identity}=${identity}`,
|
|
495
|
+
});
|
|
496
|
+
check(duplicated.echo.user === null, 'an identity sent twice counts for nothing', duplicated.echo);
|
|
497
|
+
if (names.secure) {
|
|
498
|
+
const unprefixed = await echo(target, browser(), {
|
|
499
|
+
cookie: `zite_id=${identity}`,
|
|
500
|
+
});
|
|
501
|
+
check(unprefixed.echo.user === null, 'an unprefixed zite_id counts for nothing over https', unprefixed.echo);
|
|
502
|
+
}
|
|
503
|
+
const { echo: seen } = await echo(target, visitor);
|
|
504
|
+
const appCookies = (seen.cookie ?? '')
|
|
505
|
+
.split('; ')
|
|
506
|
+
.filter(Boolean)
|
|
507
|
+
.map(pair => pair.split('=')[0]);
|
|
508
|
+
check(!appCookies.some(name => PLATFORM_COOKIE.test(name)), 'app code sees no sign-in cookie', seen.cookie);
|
|
509
|
+
},
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
id: 'S17',
|
|
513
|
+
title: 'nothing long-lived reaches app code, before or after a renewal',
|
|
514
|
+
runners: ['zite', 'local'],
|
|
515
|
+
async run({ target, browser, check }) {
|
|
516
|
+
const email = await target.createUser();
|
|
517
|
+
const visitor = browser();
|
|
518
|
+
visitor.set(target.appOrigin, 'theme', 'dark');
|
|
519
|
+
await signIn(target, visitor, email);
|
|
520
|
+
const secrets = () => (visitor.cookieHeader(target.appOrigin) ?? '')
|
|
521
|
+
.split('; ')
|
|
522
|
+
.filter(pair => PLATFORM_COOKIE.test(pair.split('=')[0]))
|
|
523
|
+
.map(pair => pair.slice(pair.indexOf('=') + 1))
|
|
524
|
+
.filter(value => value.length >= 16);
|
|
525
|
+
const before = secrets();
|
|
526
|
+
const first = await echo(target, visitor);
|
|
527
|
+
check(first.echo.cookie === 'theme=dark', 'app code gets its own cookies only', first.echo.cookie);
|
|
528
|
+
check(before.length > 0 && before.every(value => !first.text.includes(value)), "no sign-in cookie's value in what app code saw");
|
|
529
|
+
await waitOutIdentity(target);
|
|
530
|
+
const second = await echo(target, visitor);
|
|
531
|
+
const after = [...before, ...secrets()];
|
|
532
|
+
check(second.echo.user?.email === email &&
|
|
533
|
+
after.every(value => !second.text.includes(value)), 'nor after a renewal', second.echo);
|
|
534
|
+
},
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
id: 'S18',
|
|
538
|
+
title: 'two parallel renewals on one refresh token both succeed, and the session goes on',
|
|
539
|
+
runners: ['local'],
|
|
540
|
+
async run({ target, browser, check }) {
|
|
541
|
+
const email = await target.createUser();
|
|
542
|
+
const visitor = browser();
|
|
543
|
+
await signIn(target, visitor, email);
|
|
544
|
+
await waitOutIdentity(target);
|
|
545
|
+
const [a, b] = await Promise.all([
|
|
546
|
+
echo(target, visitor),
|
|
547
|
+
echo(target, visitor),
|
|
548
|
+
]);
|
|
549
|
+
check(a.echo.user?.email === email && b.echo.user?.email === email, 'both renew', [a.echo, b.echo]);
|
|
550
|
+
await waitOutIdentity(target);
|
|
551
|
+
check((await echo(target, visitor)).echo.user?.email === email, 'and the next renewal still works');
|
|
552
|
+
},
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
id: 'S19',
|
|
556
|
+
title: "ZITE_DEV_USER's stand-in bypasses the module, with no call to the identity server",
|
|
557
|
+
runners: ['local'],
|
|
558
|
+
async run({ target, browser, check }) {
|
|
559
|
+
if (!target.withDevUser)
|
|
560
|
+
throw new Error("the target can't set ZITE_DEV_USER");
|
|
561
|
+
const before = target.identityServerCalls();
|
|
562
|
+
await target.withDevUser({ id: 'u_stand_in', email: 'stand-in@x.co' }, async () => {
|
|
563
|
+
const visitor = browser();
|
|
564
|
+
const { echo: seen } = await echo(target, visitor);
|
|
565
|
+
check(seen.user?.email === 'stand-in@x.co', 'app code sees the stand-in', seen);
|
|
566
|
+
const login = await visitor.request(`${target.appOrigin}/auth/login`);
|
|
567
|
+
check(login.status !== 302, "the module doesn't answer /auth/login", login.status);
|
|
568
|
+
});
|
|
569
|
+
check(target.identityServerCalls() === before, 'the identity server heard nothing', target.identityServerCalls() - before);
|
|
570
|
+
},
|
|
571
|
+
},
|
|
572
|
+
];
|
|
573
|
+
/** Runs every scenario this runner can, in order. Scenarios for the other runner are reported skipped. */
|
|
574
|
+
export const runConformance = async (target, options = {}) => {
|
|
575
|
+
const results = [];
|
|
576
|
+
for (const scenario of scenarios) {
|
|
577
|
+
if (options.only && !options.only.includes(scenario.id))
|
|
578
|
+
continue;
|
|
579
|
+
const { id, title } = scenario;
|
|
580
|
+
let result;
|
|
581
|
+
if (!scenario.run || !scenario.runners.includes(target.runner)) {
|
|
582
|
+
result = {
|
|
583
|
+
id,
|
|
584
|
+
title,
|
|
585
|
+
status: 'skipped',
|
|
586
|
+
detail: scenario.runners.includes(target.runner)
|
|
587
|
+
? 'not implemented here'
|
|
588
|
+
: `the ${scenario.runners.join(' and ')} runner's`,
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
try {
|
|
593
|
+
await scenario.run({
|
|
594
|
+
target,
|
|
595
|
+
browser: () => new Browser(target),
|
|
596
|
+
check(ok, what, seen) {
|
|
597
|
+
if (!ok)
|
|
598
|
+
throw new Error(`${what}${seen === undefined ? '' : `: ${JSON.stringify(seen)?.slice(0, 400)}`}`);
|
|
599
|
+
},
|
|
600
|
+
});
|
|
601
|
+
result = { id, title, status: 'pass' };
|
|
602
|
+
}
|
|
603
|
+
catch (error) {
|
|
604
|
+
result = {
|
|
605
|
+
id,
|
|
606
|
+
title,
|
|
607
|
+
status: 'fail',
|
|
608
|
+
detail: error instanceof Error ? error.message : String(error),
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
results.push(result);
|
|
613
|
+
options.onResult?.(result);
|
|
614
|
+
}
|
|
615
|
+
return results;
|
|
616
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Where a cookie has to work: over https, and inside the editor's frame. */
|
|
2
|
+
export type CookieContext = {
|
|
3
|
+
secure: boolean;
|
|
4
|
+
framed: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const MODULE_COOKIES: {
|
|
7
|
+
/** The identity token. */
|
|
8
|
+
readonly identity: "zite_id";
|
|
9
|
+
/** One sign-in's state, PKCE verifier, nonce and return path. */
|
|
10
|
+
readonly flow: "zite_signin";
|
|
11
|
+
/** Off Zite only: the sealed refresh token. */
|
|
12
|
+
readonly session: "zite_session";
|
|
13
|
+
};
|
|
14
|
+
export type ModuleCookie = keyof typeof MODULE_COOKIES;
|
|
15
|
+
/** `__Host-` over https, so no sibling host can set or shadow it; plain on http://localhost, which can't hold one. */
|
|
16
|
+
export declare const cookieName: (cookie: ModuleCookie, secure: boolean) => string;
|
|
17
|
+
export declare const isModuleCookie: (name: string) => boolean;
|
|
18
|
+
export declare const setCookie: (cookie: ModuleCookie, value: string, context: CookieContext, maxAgeS: number) => string;
|
|
19
|
+
export declare const clearCookie: (cookie: ModuleCookie, context: CookieContext) => string;
|
|
20
|
+
/**
|
|
21
|
+
* The cookies sent once. A name sent twice is dropped: which copy wins differs between parsers, and that difference
|
|
22
|
+
* is how one cookie shadows another.
|
|
23
|
+
*/
|
|
24
|
+
export declare const readCookies: (header: string | null) => Map<string, string>;
|
|
25
|
+
/** The pairs of `header` whose names match, sent once each, as a Cookie header; null for none. */
|
|
26
|
+
export declare const cookiePairs: (header: string | null, names: RegExp) => string | null;
|
|
27
|
+
/** `header` without the pairs `drop` names; null when nothing is left. */
|
|
28
|
+
export declare const withoutCookies: (header: string | null, drop: (name: string) => boolean) => string | null;
|