@effect-agent/platform-cloudflare 0.1.0-beta.122 → 0.1.0-beta.124
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/BrowserCredentials.d.mts +91 -0
- package/dist/BrowserCredentials.mjs +120 -0
- package/dist/BrowserCredentials.mjs.map +1 -0
- package/dist/BrowserSession-DuOUcC6G.mjs +442 -0
- package/dist/BrowserSession-DuOUcC6G.mjs.map +1 -0
- package/dist/BrowserSession-DxCN-5F9.d.mts +109 -0
- package/dist/BrowserSession.d.mts +3 -0
- package/dist/BrowserSession.mjs +4 -0
- package/dist/CloudflareThreadClient.d.mts +48 -48
- package/dist/{InteractiveBrowser-Cm4xgiGy.d.mts → InteractiveBrowser-BnqY_Y-F.d.mts} +2 -2
- package/dist/{InteractiveBrowser-DXwmvWdA.mjs → InteractiveBrowser-DeOlcu-2.mjs} +4 -5
- package/dist/InteractiveBrowser-DeOlcu-2.mjs.map +1 -0
- package/dist/InteractiveBrowser.d.mts +1 -1
- package/dist/InteractiveBrowser.mjs +1 -1
- package/dist/{ThreadObject-mt0uxvZZ.d.mts → ThreadObject-QBlTByAB.d.mts} +32 -32
- package/dist/ThreadObject.d.mts +1 -1
- package/dist/index.d.mts +4 -2
- package/dist/index.mjs +3 -1
- package/package.json +1 -1
- package/src/BrowserCredentials.ts +146 -0
- package/src/BrowserSession.ts +589 -0
- package/src/index.ts +2 -0
- package/src/internal/browser-binding.ts +3 -3
- package/src/internal/browser-credentials.ts +362 -0
- package/dist/InteractiveBrowser-DXwmvWdA.mjs.map +0 -1
- package/dist/ProtectedBrowser.d.mts +0 -142
- package/dist/ProtectedBrowser.mjs +0 -1242
- package/dist/ProtectedBrowser.mjs.map +0 -1
- package/src/ProtectedBrowser.ts +0 -9
- package/src/protected-browser/binding.ts +0 -445
- package/src/protected-browser/host.ts +0 -398
- package/src/protected-browser/inspect-frame.ts +0 -140
- package/src/protected-browser/native.ts +0 -483
- package/src/protected-browser/policy.ts +0 -872
|
@@ -705,17 +705,28 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
|
|
|
705
705
|
} | {
|
|
706
706
|
readonly _tag: "AdminFailed";
|
|
707
707
|
readonly failure: {
|
|
708
|
-
readonly _tag: "
|
|
708
|
+
readonly _tag: "ThreadNotMaterialized";
|
|
709
|
+
readonly threadId: string;
|
|
710
|
+
} | {
|
|
711
|
+
readonly _tag: "ThreadStoreError";
|
|
709
712
|
readonly operation: string;
|
|
710
713
|
readonly message: string;
|
|
711
714
|
readonly cause?: Schema.Json | undefined;
|
|
715
|
+
readonly diagnostic?: {
|
|
716
|
+
readonly causeTag: string;
|
|
717
|
+
readonly operation: string;
|
|
718
|
+
readonly decoder?: string | undefined;
|
|
719
|
+
readonly issueTag?: string | undefined;
|
|
720
|
+
readonly sequence?: number | undefined;
|
|
721
|
+
} | undefined;
|
|
712
722
|
} | {
|
|
713
723
|
readonly _tag: "HostProtocolError";
|
|
714
724
|
readonly message: string;
|
|
715
725
|
} | {
|
|
716
|
-
readonly _tag: "
|
|
726
|
+
readonly _tag: "LedgerError";
|
|
727
|
+
readonly operation: string;
|
|
717
728
|
readonly message: string;
|
|
718
|
-
readonly cause?:
|
|
729
|
+
readonly cause?: import("effect-agent/failure-diagnostic").Diagnostic | undefined;
|
|
719
730
|
} | {
|
|
720
731
|
readonly _tag: "AdmissionPolicyError";
|
|
721
732
|
readonly reason: "occupied" | "refused" | "unavailable";
|
|
@@ -723,53 +734,38 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
|
|
|
723
734
|
readonly cause?: import("effect-agent/failure-diagnostic").Diagnostic | undefined;
|
|
724
735
|
readonly stack?: string | undefined;
|
|
725
736
|
} | {
|
|
726
|
-
readonly _tag: "
|
|
727
|
-
readonly
|
|
728
|
-
readonly
|
|
737
|
+
readonly _tag: "AppendConflict";
|
|
738
|
+
readonly threadId: string;
|
|
739
|
+
readonly batchId: string;
|
|
740
|
+
readonly reason: "batch-digest" | "record-identity" | "tail";
|
|
741
|
+
readonly actualTailSequence?: number | undefined;
|
|
742
|
+
readonly actualTailDigest?: string | undefined;
|
|
729
743
|
} | {
|
|
730
|
-
readonly _tag: "
|
|
731
|
-
readonly operation: string;
|
|
744
|
+
readonly _tag: "DigestError";
|
|
732
745
|
readonly message: string;
|
|
733
|
-
readonly cause?:
|
|
746
|
+
readonly cause?: Schema.Json | undefined;
|
|
734
747
|
} | {
|
|
735
|
-
readonly _tag: "
|
|
748
|
+
readonly _tag: "DurableAlarmError";
|
|
736
749
|
readonly operation: string;
|
|
737
750
|
readonly message: string;
|
|
738
751
|
readonly cause?: Schema.Json | undefined;
|
|
739
|
-
readonly diagnostic?: {
|
|
740
|
-
readonly causeTag: string;
|
|
741
|
-
readonly operation: string;
|
|
742
|
-
readonly decoder?: string | undefined;
|
|
743
|
-
readonly issueTag?: string | undefined;
|
|
744
|
-
readonly sequence?: number | undefined;
|
|
745
|
-
} | undefined;
|
|
746
|
-
} | {
|
|
747
|
-
readonly _tag: "ThreadNotMaterialized";
|
|
748
|
-
readonly threadId: string;
|
|
749
752
|
} | {
|
|
750
|
-
readonly _tag: "
|
|
751
|
-
readonly
|
|
752
|
-
readonly batchId: string;
|
|
753
|
-
readonly reason: "batch-digest" | "record-identity" | "tail";
|
|
754
|
-
readonly actualTailSequence?: number | undefined;
|
|
755
|
-
readonly actualTailDigest?: string | undefined;
|
|
753
|
+
readonly _tag: "DurableRuntimeFailpointError";
|
|
754
|
+
readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "checkpoint:after-save" | "checkpoint:before-save" | "claim:after-claim" | "compaction:after-canonical-append" | "compaction:before-canonical-append" | "input:after-canonical-append" | "join:after-canonical-append" | "join:after-claim" | "policy:after-reservation-append" | "policy:before-reservation-append" | "resolve:after-intent" | "run:after-duration-append" | "run:after-start-append" | "run:before-duration-append" | "run:before-start-append" | "step:after-step-append" | "subagent:after-admit" | "subagent:after-child-abort-intent" | "subagent:after-child-ready" | "subagent:after-join-append" | "subagent:after-release" | "subagent:after-release-pending" | "subagent:after-request-append" | "subagent:after-reserve" | "subagent:after-sibling-settle" | "subagent:after-start-append" | "subagent:after-suspend" | "subagent:before-join-append" | "submit:after-admit" | "submit:after-materialize" | "terminalize:after-canonical-append" | "terminalize:after-reserve" | "tools:after-prepared-append" | "tools:after-unavailable-append" | "tools:before-prepared-append" | "tools:before-unavailable-append" | "turn:after-canonical-append" | "turn:after-response-append" | "turn:after-results-append" | "update:after-canonical-append" | "update:after-delivery-insert" | "update:before-canonical-append" | "update:before-delivery-insert" | "worker:after-completion-append" | "worker:after-origin-append" | "worker:after-report-append" | "worker:after-report-delivery" | "worker:after-source-append" | "worker:after-stop-append" | "worker:after-stop-seal" | "worker:after-subtree-append" | "worker:before-completion-append" | "worker:before-origin-append" | "worker:before-report-append" | "worker:before-report-delivery" | "worker:before-source-append" | "worker:before-stop-append" | "worker:before-stop-seal" | "worker:before-subtree-append";
|
|
756
755
|
} | {
|
|
757
756
|
readonly _tag: "FenceRejected";
|
|
758
757
|
readonly threadId: string;
|
|
759
758
|
readonly actualEpoch: number;
|
|
760
759
|
readonly attemptedEpoch: number;
|
|
761
760
|
} | {
|
|
762
|
-
readonly _tag: "
|
|
763
|
-
readonly
|
|
761
|
+
readonly _tag: "ApprovalSuspensionError";
|
|
762
|
+
readonly cause: Schema.Json;
|
|
764
763
|
} | {
|
|
765
764
|
readonly _tag: "OperationDenied";
|
|
766
765
|
readonly operation: "abort" | "awaitSettlement" | "explain" | "observe" | "resolveApproval" | "resolveUnknown" | "retry" | "scanObligations" | "verify" | "wake";
|
|
767
766
|
readonly reason: string;
|
|
768
767
|
readonly threadId?: string | undefined;
|
|
769
768
|
readonly submissionId?: string | undefined;
|
|
770
|
-
} | {
|
|
771
|
-
readonly _tag: "ApprovalSuspensionError";
|
|
772
|
-
readonly cause: Schema.Json;
|
|
773
769
|
} | {
|
|
774
770
|
readonly _tag: "RetryRefused";
|
|
775
771
|
readonly submissionId: string;
|
|
@@ -784,6 +780,10 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
|
|
|
784
780
|
readonly _tag: "OwnershipLost";
|
|
785
781
|
readonly submissionId: string;
|
|
786
782
|
readonly actualEpoch: number;
|
|
783
|
+
} | {
|
|
784
|
+
readonly _tag: "SettlementConflict";
|
|
785
|
+
readonly submissionId: string;
|
|
786
|
+
readonly existingOutcome: "aborted" | "completed" | "failed";
|
|
787
787
|
};
|
|
788
788
|
}, Schema.SchemaError, never>;
|
|
789
789
|
declare const decodeAdminResponse: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AdminFailed | ExplainedRecovery | ObligationsScanned | RetryExecuted | VerifiedIntegrity, Schema.SchemaError, never>;
|
|
@@ -836,4 +836,4 @@ interface Class<EventServices = never> {
|
|
|
836
836
|
declare const make: <ApplicationServices, ApplicationError, EventServices = never, EventLayerError = never>(applicationLayer: Layer.Layer<CloudflareDurableRuntimeServices | ApplicationServices, ApplicationError, CloudflareBootstrapServices | DurableObjectState$1.DurableObjectState | WorkerEnvironment | DurableObjectContext | ThreadObjectNamespace>, options: Options<ApplicationServices, EventServices, EventLayerError>) => Class<ApplicationServices | EventServices>;
|
|
837
837
|
//#endregion
|
|
838
838
|
export { ThreadPublicationOptions as A, portCall as C, CloudflareDurableRuntimeOptions as D, CloudflareDurableRuntimeInitializationError as E, layerConfig as M, layerHostConfig as N, CloudflareDurableRuntimeServices as O, layerInHost as P, make as S, CloudflareBootstrapServices as T, decodeAdminVerifyRequest as _, AdminVerifyRequest as a, encodeAdminResponse as b, Instance as c, RetryExecuted as d, ThreadObject_d_exports as f, decodeAdminResponse as g, decodeAdminExplainRequest as h, AdminResponse as i, layer as j, ThreadObjectPorts as k, ObligationsScanned as l, VerifiedIntegrity as m, AdminFailed as n, Class as o, ThreadRpcOperation as p, AdminFailure as r, ExplainedRecovery as s, AdminExplainRequest as t, Options as u, decodeObligationThresholds as v, submit as w, handleRpc as x, decodeRetryCommand as y };
|
|
839
|
-
//# sourceMappingURL=ThreadObject-
|
|
839
|
+
//# sourceMappingURL=ThreadObject-QBlTByAB.d.mts.map
|
package/dist/ThreadObject.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as ThreadPublicationOptions, C as portCall, D as CloudflareDurableRuntimeOptions, E as CloudflareDurableRuntimeInitializationError, M as layerConfig, N as layerHostConfig, O as CloudflareDurableRuntimeServices, P as layerInHost, S as make, T as CloudflareBootstrapServices, _ as decodeAdminVerifyRequest, a as AdminVerifyRequest, b as encodeAdminResponse, c as Instance, d as RetryExecuted, g as decodeAdminResponse, h as decodeAdminExplainRequest, i as AdminResponse, j as layer, k as ThreadObjectPorts, l as ObligationsScanned, m as VerifiedIntegrity, n as AdminFailed, o as Class, p as ThreadRpcOperation, r as AdminFailure, s as ExplainedRecovery, t as AdminExplainRequest, u as Options, v as decodeObligationThresholds, w as submit, x as handleRpc, y as decodeRetryCommand } from "./ThreadObject-
|
|
1
|
+
import { A as ThreadPublicationOptions, C as portCall, D as CloudflareDurableRuntimeOptions, E as CloudflareDurableRuntimeInitializationError, M as layerConfig, N as layerHostConfig, O as CloudflareDurableRuntimeServices, P as layerInHost, S as make, T as CloudflareBootstrapServices, _ as decodeAdminVerifyRequest, a as AdminVerifyRequest, b as encodeAdminResponse, c as Instance, d as RetryExecuted, g as decodeAdminResponse, h as decodeAdminExplainRequest, i as AdminResponse, j as layer, k as ThreadObjectPorts, l as ObligationsScanned, m as VerifiedIntegrity, n as AdminFailed, o as Class, p as ThreadRpcOperation, r as AdminFailure, s as ExplainedRecovery, t as AdminExplainRequest, u as Options, v as decodeObligationThresholds, w as submit, x as handleRpc, y as decodeRetryCommand } from "./ThreadObject-QBlTByAB.mjs";
|
|
2
2
|
export { AdminExplainRequest, AdminFailed, AdminFailure, AdminResponse, AdminVerifyRequest, type CloudflareBootstrapServices as BootstrapServices, Class, ExplainedRecovery, type CloudflareDurableRuntimeInitializationError as InitializationError, Instance, ObligationsScanned, Options, type ThreadPublicationOptions as PublicationOptions, RetryExecuted, type CloudflareDurableRuntimeOptions as RuntimeOptions, type CloudflareDurableRuntimeServices as Services, ThreadObjectPorts, ThreadRpcOperation, VerifiedIntegrity, decodeAdminExplainRequest, decodeAdminResponse, decodeAdminVerifyRequest, decodeObligationThresholds, decodeRetryCommand, encodeAdminResponse, handleRpc, layer, layerConfig, layerHostConfig, layerInHost, make, portCall, submit };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { t as CloudflareBindings_d_exports } from "./CloudflareBindings.mjs";
|
|
2
2
|
import { o as CloudflareConfig_d_exports } from "./CloudflareConfig-DKXGo8L3.mjs";
|
|
3
3
|
import { t as Alarm_d_exports } from "./Alarm.mjs";
|
|
4
|
+
import { t as BrowserCredentials_d_exports } from "./BrowserCredentials.mjs";
|
|
4
5
|
import { t as CloudflareBrowser_d_exports } from "./CloudflareBrowser-Doe1M7R5.mjs";
|
|
6
|
+
import { a as BrowserSession_d_exports } from "./BrowserSession-DxCN-5F9.mjs";
|
|
5
7
|
import { t as CloudflareAiGateway_d_exports } from "./CloudflareAiGateway.mjs";
|
|
6
8
|
import { t as CloudflareCodeMode_d_exports } from "./CloudflareCodeMode.mjs";
|
|
7
9
|
import { t as CloudflareMemory_d_exports } from "./CloudflareMemory.mjs";
|
|
8
10
|
import { t as CloudflareScheduling_d_exports } from "./CloudflareScheduling.mjs";
|
|
9
11
|
import { t as CloudflareSubscriptions_d_exports } from "./CloudflareSubscriptions.mjs";
|
|
10
12
|
import { t as CloudflareThreadClient_d_exports } from "./CloudflareThreadClient.mjs";
|
|
11
|
-
import { f as ThreadObject_d_exports } from "./ThreadObject-
|
|
13
|
+
import { f as ThreadObject_d_exports } from "./ThreadObject-QBlTByAB.mjs";
|
|
12
14
|
import { t as WakeScheduler_d_exports } from "./WakeScheduler.mjs";
|
|
13
|
-
export { Alarm_d_exports as Alarm, CloudflareAiGateway_d_exports as CloudflareAiGateway, CloudflareBindings_d_exports as CloudflareBindings, CloudflareBrowser_d_exports as CloudflareBrowser, CloudflareCodeMode_d_exports as CloudflareCodeMode, CloudflareConfig_d_exports as CloudflareConfig, CloudflareMemory_d_exports as CloudflareMemory, CloudflareScheduling_d_exports as CloudflareScheduling, CloudflareSubscriptions_d_exports as CloudflareSubscriptions, CloudflareThreadClient_d_exports as CloudflareThreadClient, ThreadObject_d_exports as ThreadObject, WakeScheduler_d_exports as WakeScheduler };
|
|
15
|
+
export { Alarm_d_exports as Alarm, BrowserCredentials_d_exports as BrowserCredentials, BrowserSession_d_exports as BrowserSession, CloudflareAiGateway_d_exports as CloudflareAiGateway, CloudflareBindings_d_exports as CloudflareBindings, CloudflareBrowser_d_exports as CloudflareBrowser, CloudflareCodeMode_d_exports as CloudflareCodeMode, CloudflareConfig_d_exports as CloudflareConfig, CloudflareMemory_d_exports as CloudflareMemory, CloudflareScheduling_d_exports as CloudflareScheduling, CloudflareSubscriptions_d_exports as CloudflareSubscriptions, CloudflareThreadClient_d_exports as CloudflareThreadClient, ThreadObject_d_exports as ThreadObject, WakeScheduler_d_exports as WakeScheduler };
|
package/dist/index.mjs
CHANGED
|
@@ -10,4 +10,6 @@ import { t as CloudflareSubscriptions_exports } from "./CloudflareSubscriptions.
|
|
|
10
10
|
import { t as WakeScheduler_exports } from "./WakeScheduler.mjs";
|
|
11
11
|
import { l as ThreadObject_exports } from "./ThreadObject-DaC-IhCm.mjs";
|
|
12
12
|
import { t as CloudflareAiGateway_exports } from "./CloudflareAiGateway.mjs";
|
|
13
|
-
|
|
13
|
+
import { t as BrowserCredentials_exports } from "./BrowserCredentials.mjs";
|
|
14
|
+
import { i as BrowserSession_exports } from "./BrowserSession-DuOUcC6G.mjs";
|
|
15
|
+
export { Alarm_exports as Alarm, BrowserCredentials_exports as BrowserCredentials, BrowserSession_exports as BrowserSession, CloudflareAiGateway_exports as CloudflareAiGateway, CloudflareBindings_exports as CloudflareBindings, CloudflareBrowser_exports as CloudflareBrowser, CloudflareCodeMode_exports as CloudflareCodeMode, CloudflareConfig_exports as CloudflareConfig, CloudflareMemory_exports as CloudflareMemory, CloudflareScheduling_exports as CloudflareScheduling, CloudflareSubscriptions_exports as CloudflareSubscriptions, CloudflareThreadClient_exports as CloudflareThreadClient, ThreadObject_exports as ThreadObject, WakeScheduler_exports as WakeScheduler };
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@effect-agent/platform-cloudflare","version":"0.1.0-beta.
|
|
1
|
+
{"name":"@effect-agent/platform-cloudflare","version":"0.1.0-beta.124","dependencies":{"@effect-agent/storage-cloudflare":"0.1.0-beta.124","@effect/platform-browser":"4.0.0-rc.116","@effect/sql-sqlite-do":"4.0.0-rc.116","effect-agent":"0.1.0-beta.124","puppeteer-core":"24.29.0"},"devDependencies":{"@cloudflare/vitest-pool-workers":"0.21.3","@cloudflare/workers-types":"5.20260825.1","@effect-agent/testing":"0.1.0-beta.124","@effect/platform-node":"4.0.0-rc.116","@effect/sql-d1":"4.0.0-rc.116","@effect/vitest":"4.0.0-rc.116","effect":"4.0.0-rc.116","effect-cf":"0.44.1","esbuild":"0.28.1","miniflare":"5.20260811.1-alpha","typescript":"7.0.2","vite-plus":"0.3.2","vitest":"4.1.11"},"peerDependencies":{"effect":"^4.0.0-rc.116","effect-cf":"^0.44.1 || ^0.45.0"},"exports":{".":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"./alarm":{"types":"./dist/Alarm.d.mts","default":"./dist/Alarm.mjs"},"./browser-rest-capture":{"types":"./dist/BrowserRestCapture.d.mts","default":"./dist/BrowserRestCapture.mjs"},"./browser-rest-crawl":{"types":"./dist/BrowserRestCrawl.d.mts","default":"./dist/BrowserRestCrawl.mjs"},"./cloudflare-bindings":{"types":"./dist/CloudflareBindings.d.mts","default":"./dist/CloudflareBindings.mjs"},"./cloudflare-browser":{"types":"./dist/CloudflareBrowser.d.mts","default":"./dist/CloudflareBrowser.mjs"},"./cloudflare-code-mode":{"types":"./dist/CloudflareCodeMode.d.mts","default":"./dist/CloudflareCodeMode.mjs"},"./cloudflare-config":{"types":"./dist/CloudflareConfig.d.mts","default":"./dist/CloudflareConfig.mjs"},"./cloudflare-memory":{"types":"./dist/CloudflareMemory.d.mts","default":"./dist/CloudflareMemory.mjs"},"./cloudflare-scheduling":{"types":"./dist/CloudflareScheduling.d.mts","default":"./dist/CloudflareScheduling.mjs"},"./cloudflare-subscriptions":{"types":"./dist/CloudflareSubscriptions.d.mts","default":"./dist/CloudflareSubscriptions.mjs"},"./cloudflare-thread-client":{"types":"./dist/CloudflareThreadClient.d.mts","default":"./dist/CloudflareThreadClient.mjs"},"./interactive-browser":{"types":"./dist/InteractiveBrowser.d.mts","default":"./dist/InteractiveBrowser.mjs"},"./browser-session":{"types":"./dist/BrowserSession.d.mts","default":"./dist/BrowserSession.mjs"},"./browser-credentials":{"types":"./dist/BrowserCredentials.d.mts","default":"./dist/BrowserCredentials.mjs"},"./thread-object":{"types":"./dist/ThreadObject.d.mts","default":"./dist/ThreadObject.mjs"},"./wake-scheduler":{"types":"./dist/WakeScheduler.d.mts","default":"./dist/WakeScheduler.mjs"},"./cloudflare-ai-gateway":{"types":"./dist/CloudflareAiGateway.d.mts","default":"./dist/CloudflareAiGateway.mjs"}},"description":"Cloudflare Layer assembly for Effect Agent: Durable Objects and Browser Run adapters.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/danieljvdm/effect-agent.git","directory":"packages/platform-cloudflare"},"files":["dist","src"],"type":"module","sideEffects":[],"publishConfig":{"access":"public"},"scripts":{"build":"vp pack","check":"tsc --noEmit -p tsconfig.json"}}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Context, type Effect, Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
const Selector = Schema.NonEmptyString.check(Schema.isMaxLength(2048));
|
|
4
|
+
|
|
5
|
+
export const CredentialKind = Schema.Literals(["login", "card"]);
|
|
6
|
+
|
|
7
|
+
export const CredentialFieldRole = Schema.Literals([
|
|
8
|
+
"username",
|
|
9
|
+
"password",
|
|
10
|
+
"card-name",
|
|
11
|
+
"card-number",
|
|
12
|
+
"card-expiry",
|
|
13
|
+
"card-expiry-month",
|
|
14
|
+
"card-expiry-year",
|
|
15
|
+
"card-security-code",
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
/** Canonical HTTPS origins, including non-default ports. Grants must match exactly. */
|
|
19
|
+
export const CredentialOrigin = Schema.String.check(
|
|
20
|
+
Schema.isMaxLength(2048),
|
|
21
|
+
Schema.makeFilter((value) => {
|
|
22
|
+
try {
|
|
23
|
+
const url = new URL(value);
|
|
24
|
+
|
|
25
|
+
return url.protocol === "https:" && url.origin === value && !url.username && !url.password;
|
|
26
|
+
} catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export class CredentialTarget extends Schema.Class<CredentialTarget>("CredentialTarget")({
|
|
33
|
+
topOrigin: CredentialOrigin,
|
|
34
|
+
frameOrigin: CredentialOrigin,
|
|
35
|
+
recipientOrigin: CredentialOrigin,
|
|
36
|
+
}) {}
|
|
37
|
+
|
|
38
|
+
/** Selectors identify one native form. Roles explicitly select material; no field inference occurs. */
|
|
39
|
+
export class FillCredentialRequest extends Schema.Class<FillCredentialRequest>(
|
|
40
|
+
"FillCredentialRequest",
|
|
41
|
+
)({
|
|
42
|
+
credential: Schema.NonEmptyString.check(Schema.isMaxLength(256)),
|
|
43
|
+
kind: CredentialKind,
|
|
44
|
+
frame: Schema.optionalKey(Schema.Array(Selector).check(Schema.isMaxLength(8))),
|
|
45
|
+
fields: Schema.Array(Schema.Struct({ selector: Selector, role: CredentialFieldRole })).check(
|
|
46
|
+
Schema.isMinLength(1),
|
|
47
|
+
Schema.isMaxLength(8),
|
|
48
|
+
),
|
|
49
|
+
}) {}
|
|
50
|
+
|
|
51
|
+
const SecretText = Schema.Redacted(Schema.NonEmptyString.check(Schema.isMaxLength(1024)));
|
|
52
|
+
|
|
53
|
+
/** Host-only material. Never return or encode it through a Tool, log, trace, or checkpoint. */
|
|
54
|
+
export const LoginCredential = Schema.TaggedStruct("LoginCredential", {
|
|
55
|
+
username: SecretText,
|
|
56
|
+
password: SecretText,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/** Security codes are transient; the host must not persist them. */
|
|
60
|
+
export const CardCredential = Schema.TaggedStruct("CardCredential", {
|
|
61
|
+
name: SecretText,
|
|
62
|
+
number: Schema.Redacted(Schema.String.check(Schema.isPattern(/^\d{12,19}$/))),
|
|
63
|
+
expiry: SecretText,
|
|
64
|
+
expiryMonth: Schema.Redacted(Schema.String.check(Schema.isPattern(/^(0[1-9]|1[0-2])$/))),
|
|
65
|
+
expiryYear: Schema.Redacted(Schema.String.check(Schema.isPattern(/^\d{4}$/))),
|
|
66
|
+
securityCode: Schema.optionalKey(
|
|
67
|
+
Schema.Redacted(Schema.String.check(Schema.isPattern(/^\d{3,4}$/))),
|
|
68
|
+
),
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
export const BrowserCredentialMaterial = Schema.Union([LoginCredential, CardCredential]);
|
|
72
|
+
export type BrowserCredentialMaterial = typeof BrowserCredentialMaterial.Type;
|
|
73
|
+
|
|
74
|
+
export class CredentialAccessError extends Schema.TaggedError<CredentialAccessError>()(
|
|
75
|
+
"CredentialAccessError",
|
|
76
|
+
{
|
|
77
|
+
reason: Schema.Literals([
|
|
78
|
+
"denied",
|
|
79
|
+
"missing-credential",
|
|
80
|
+
"needs-attention",
|
|
81
|
+
"busy",
|
|
82
|
+
"resolver",
|
|
83
|
+
]),
|
|
84
|
+
},
|
|
85
|
+
) {}
|
|
86
|
+
|
|
87
|
+
export interface CredentialAccessRequest {
|
|
88
|
+
readonly credential: string;
|
|
89
|
+
readonly kind: typeof CredentialKind.Type;
|
|
90
|
+
readonly target: CredentialTarget;
|
|
91
|
+
readonly roles: ReadonlyArray<typeof CredentialFieldRole.Type>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Invocation-owned authority. Derive caller/ownership from the host, not the public credential
|
|
96
|
+
* identifier. Authorize the actual merchant, frame, recipient, roles, and side effects of filling.
|
|
97
|
+
* Repeated checks must consult current grants. Never log or trace resolved material.
|
|
98
|
+
* Bind caller identity and identifier-to-vault-item selection for the whole invocation; an alias
|
|
99
|
+
* changing between resolve and authorize must never authorize different material.
|
|
100
|
+
*/
|
|
101
|
+
export class BrowserCredentialAccess extends Context.Service<
|
|
102
|
+
BrowserCredentialAccess,
|
|
103
|
+
{
|
|
104
|
+
readonly authorize: (
|
|
105
|
+
request: CredentialAccessRequest,
|
|
106
|
+
) => Effect.Effect<void, CredentialAccessError>;
|
|
107
|
+
readonly resolve: (
|
|
108
|
+
request: CredentialAccessRequest,
|
|
109
|
+
) => Effect.Effect<BrowserCredentialMaterial, CredentialAccessError>;
|
|
110
|
+
}
|
|
111
|
+
>()("@effect-agent/platform-cloudflare/BrowserCredentialAccess") {}
|
|
112
|
+
|
|
113
|
+
export const CredentialDispatch = Schema.Literals([
|
|
114
|
+
"not-dispatched",
|
|
115
|
+
"possibly-dispatched",
|
|
116
|
+
"dispatched",
|
|
117
|
+
]);
|
|
118
|
+
|
|
119
|
+
/** Filled counts acknowledged assignments, not authentication, submission, or website acceptance. */
|
|
120
|
+
export class CredentialFillResult extends Schema.Class<CredentialFillResult>(
|
|
121
|
+
"CredentialFillResult",
|
|
122
|
+
)({
|
|
123
|
+
dispatch: Schema.Literal("dispatched"),
|
|
124
|
+
filled: Schema.Natural.check(Schema.isLessThanOrEqualTo(8)),
|
|
125
|
+
}) {}
|
|
126
|
+
|
|
127
|
+
/** Content-free evidence. A lost reply never authorizes a retry or proves that no write occurred. */
|
|
128
|
+
export class CredentialFillError extends Schema.TaggedError<CredentialFillError>()(
|
|
129
|
+
"CredentialFillError",
|
|
130
|
+
{
|
|
131
|
+
reason: Schema.Literals([
|
|
132
|
+
"denied",
|
|
133
|
+
"missing-credential",
|
|
134
|
+
"stale-target",
|
|
135
|
+
"unsupported",
|
|
136
|
+
"needs-attention",
|
|
137
|
+
"busy",
|
|
138
|
+
"provider",
|
|
139
|
+
"resolver",
|
|
140
|
+
"timeout",
|
|
141
|
+
]),
|
|
142
|
+
dispatch: CredentialDispatch,
|
|
143
|
+
filled: Schema.Natural.check(Schema.isLessThanOrEqualTo(8)),
|
|
144
|
+
cleanup: Schema.Literals(["not-requested", "confirmed", "unconfirmed"]),
|
|
145
|
+
},
|
|
146
|
+
) {}
|