@proofoftech/flowsafe 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/LICENSE +202 -0
- package/README.md +273 -0
- package/dist/approval-api/contract.d.ts +45 -0
- package/dist/approval-api/contract.d.ts.map +1 -0
- package/dist/approval-api/contract.js +37 -0
- package/dist/approval-api/contract.js.map +1 -0
- package/dist/approval-api/d1-store.d.ts +52 -0
- package/dist/approval-api/d1-store.d.ts.map +1 -0
- package/dist/approval-api/d1-store.js +468 -0
- package/dist/approval-api/d1-store.js.map +1 -0
- package/dist/approval-api/grants.d.ts +52 -0
- package/dist/approval-api/grants.d.ts.map +1 -0
- package/dist/approval-api/grants.js +200 -0
- package/dist/approval-api/grants.js.map +1 -0
- package/dist/approval-api/index.d.ts +21 -0
- package/dist/approval-api/index.d.ts.map +1 -0
- package/dist/approval-api/index.js +18 -0
- package/dist/approval-api/index.js.map +1 -0
- package/dist/approval-api/retention.d.ts +32 -0
- package/dist/approval-api/retention.d.ts.map +1 -0
- package/dist/approval-api/retention.js +81 -0
- package/dist/approval-api/retention.js.map +1 -0
- package/dist/approval-api/router.d.ts +51 -0
- package/dist/approval-api/router.d.ts.map +1 -0
- package/dist/approval-api/router.js +245 -0
- package/dist/approval-api/router.js.map +1 -0
- package/dist/approval-api/service.d.ts +134 -0
- package/dist/approval-api/service.d.ts.map +1 -0
- package/dist/approval-api/service.js +537 -0
- package/dist/approval-api/service.js.map +1 -0
- package/dist/approval-api/store.d.ts +126 -0
- package/dist/approval-api/store.d.ts.map +1 -0
- package/dist/approval-api/store.js +189 -0
- package/dist/approval-api/store.js.map +1 -0
- package/dist/approval-api/tenant-brand.d.ts +35 -0
- package/dist/approval-api/tenant-brand.d.ts.map +1 -0
- package/dist/approval-api/tenant-brand.js +18 -0
- package/dist/approval-api/tenant-brand.js.map +1 -0
- package/dist/approval-api/tenant-context.d.ts +44 -0
- package/dist/approval-api/tenant-context.d.ts.map +1 -0
- package/dist/approval-api/tenant-context.js +49 -0
- package/dist/approval-api/tenant-context.js.map +1 -0
- package/dist/approval-api/tenant-store.d.ts +36 -0
- package/dist/approval-api/tenant-store.d.ts.map +1 -0
- package/dist/approval-api/tenant-store.js +122 -0
- package/dist/approval-api/tenant-store.js.map +1 -0
- package/dist/approval-api/types.d.ts +247 -0
- package/dist/approval-api/types.d.ts.map +1 -0
- package/dist/approval-api/types.js +157 -0
- package/dist/approval-api/types.js.map +1 -0
- package/dist/approval-ui/App.d.ts +11 -0
- package/dist/approval-ui/App.d.ts.map +1 -0
- package/dist/approval-ui/App.js +15 -0
- package/dist/approval-ui/App.js.map +1 -0
- package/dist/approval-ui/DetailView.d.ts +13 -0
- package/dist/approval-ui/DetailView.d.ts.map +1 -0
- package/dist/approval-ui/DetailView.js +20 -0
- package/dist/approval-ui/DetailView.js.map +1 -0
- package/dist/approval-ui/MetricsView.d.ts +7 -0
- package/dist/approval-ui/MetricsView.d.ts.map +1 -0
- package/dist/approval-ui/MetricsView.js +22 -0
- package/dist/approval-ui/MetricsView.js.map +1 -0
- package/dist/approval-ui/QueueView.d.ts +11 -0
- package/dist/approval-ui/QueueView.d.ts.map +1 -0
- package/dist/approval-ui/QueueView.js +59 -0
- package/dist/approval-ui/QueueView.js.map +1 -0
- package/dist/approval-ui/client.d.ts +34 -0
- package/dist/approval-ui/client.d.ts.map +1 -0
- package/dist/approval-ui/client.js +103 -0
- package/dist/approval-ui/client.js.map +1 -0
- package/dist/approval-ui/components.d.ts +125 -0
- package/dist/approval-ui/components.d.ts.map +1 -0
- package/dist/approval-ui/components.js +54 -0
- package/dist/approval-ui/components.js.map +1 -0
- package/dist/approval-ui/index.d.ts +21 -0
- package/dist/approval-ui/index.d.ts.map +1 -0
- package/dist/approval-ui/index.js +21 -0
- package/dist/approval-ui/index.js.map +1 -0
- package/dist/approval-ui/mount.d.ts +23 -0
- package/dist/approval-ui/mount.d.ts.map +1 -0
- package/dist/approval-ui/mount.js +17 -0
- package/dist/approval-ui/mount.js.map +1 -0
- package/dist/approval-ui/tips.d.ts +32 -0
- package/dist/approval-ui/tips.d.ts.map +1 -0
- package/dist/approval-ui/tips.js +32 -0
- package/dist/approval-ui/tips.js.map +1 -0
- package/dist/approval-ui/use-approval-dashboard.d.ts +70 -0
- package/dist/approval-ui/use-approval-dashboard.d.ts.map +1 -0
- package/dist/approval-ui/use-approval-dashboard.js +148 -0
- package/dist/approval-ui/use-approval-dashboard.js.map +1 -0
- package/dist/approval-ui/view-model.d.ts +24 -0
- package/dist/approval-ui/view-model.d.ts.map +1 -0
- package/dist/approval-ui/view-model.js +62 -0
- package/dist/approval-ui/view-model.js.map +1 -0
- package/dist/artifacts/index.d.ts +123 -0
- package/dist/artifacts/index.d.ts.map +1 -0
- package/dist/artifacts/index.js +223 -0
- package/dist/artifacts/index.js.map +1 -0
- package/dist/audit-export/index.d.ts +71 -0
- package/dist/audit-export/index.d.ts.map +1 -0
- package/dist/audit-export/index.js +124 -0
- package/dist/audit-export/index.js.map +1 -0
- package/dist/do-runner/breakwater-keys.d.ts +23 -0
- package/dist/do-runner/breakwater-keys.d.ts.map +1 -0
- package/dist/do-runner/breakwater-keys.js +38 -0
- package/dist/do-runner/breakwater-keys.js.map +1 -0
- package/dist/do-runner/cf-types.d.ts +26 -0
- package/dist/do-runner/cf-types.d.ts.map +1 -0
- package/dist/do-runner/cf-types.js +13 -0
- package/dist/do-runner/cf-types.js.map +1 -0
- package/dist/do-runner/d1-storage.d.ts +128 -0
- package/dist/do-runner/d1-storage.d.ts.map +1 -0
- package/dist/do-runner/d1-storage.js +287 -0
- package/dist/do-runner/d1-storage.js.map +1 -0
- package/dist/do-runner/durable-object.d.ts +28 -0
- package/dist/do-runner/durable-object.d.ts.map +1 -0
- package/dist/do-runner/durable-object.js +164 -0
- package/dist/do-runner/durable-object.js.map +1 -0
- package/dist/do-runner/index.d.ts +12 -0
- package/dist/do-runner/index.d.ts.map +1 -0
- package/dist/do-runner/index.js +11 -0
- package/dist/do-runner/index.js.map +1 -0
- package/dist/do-runner/init.d.ts +38 -0
- package/dist/do-runner/init.d.ts.map +1 -0
- package/dist/do-runner/init.js +45 -0
- package/dist/do-runner/init.js.map +1 -0
- package/dist/do-runner/path-safe-id.d.ts +19 -0
- package/dist/do-runner/path-safe-id.d.ts.map +1 -0
- package/dist/do-runner/path-safe-id.js +70 -0
- package/dist/do-runner/path-safe-id.js.map +1 -0
- package/dist/do-runner/resume-ledger.d.ts +48 -0
- package/dist/do-runner/resume-ledger.d.ts.map +1 -0
- package/dist/do-runner/resume-ledger.js +59 -0
- package/dist/do-runner/resume-ledger.js.map +1 -0
- package/dist/do-runner/runtime.d.ts +161 -0
- package/dist/do-runner/runtime.d.ts.map +1 -0
- package/dist/do-runner/runtime.js +509 -0
- package/dist/do-runner/runtime.js.map +1 -0
- package/dist/host-kit/approval-bridge.d.ts +109 -0
- package/dist/host-kit/approval-bridge.d.ts.map +1 -0
- package/dist/host-kit/approval-bridge.js +262 -0
- package/dist/host-kit/approval-bridge.js.map +1 -0
- package/dist/host-kit/bearer-auth.d.ts +19 -0
- package/dist/host-kit/bearer-auth.d.ts.map +1 -0
- package/dist/host-kit/bearer-auth.js +67 -0
- package/dist/host-kit/bearer-auth.js.map +1 -0
- package/dist/host-kit/do-response.d.ts +13 -0
- package/dist/host-kit/do-response.d.ts.map +1 -0
- package/dist/host-kit/do-response.js +24 -0
- package/dist/host-kit/do-response.js.map +1 -0
- package/dist/host-kit/do-run-topology.d.ts +32 -0
- package/dist/host-kit/do-run-topology.d.ts.map +1 -0
- package/dist/host-kit/do-run-topology.js +39 -0
- package/dist/host-kit/do-run-topology.js.map +1 -0
- package/dist/host-kit/env-vars.d.ts +26 -0
- package/dist/host-kit/env-vars.d.ts.map +1 -0
- package/dist/host-kit/env-vars.js +48 -0
- package/dist/host-kit/env-vars.js.map +1 -0
- package/dist/host-kit/host-approval-service.d.ts +125 -0
- package/dist/host-kit/host-approval-service.d.ts.map +1 -0
- package/dist/host-kit/host-approval-service.js +187 -0
- package/dist/host-kit/host-approval-service.js.map +1 -0
- package/dist/host-kit/index.d.ts +18 -0
- package/dist/host-kit/index.d.ts.map +1 -0
- package/dist/host-kit/index.js +34 -0
- package/dist/host-kit/index.js.map +1 -0
- package/dist/host-kit/module.d.ts +34 -0
- package/dist/host-kit/module.d.ts.map +1 -0
- package/dist/host-kit/module.js +17 -0
- package/dist/host-kit/module.js.map +1 -0
- package/dist/host-kit/registration.d.ts +11 -0
- package/dist/host-kit/registration.d.ts.map +1 -0
- package/dist/host-kit/registration.js +21 -0
- package/dist/host-kit/registration.js.map +1 -0
- package/dist/host-kit/run-route-error.d.ts +11 -0
- package/dist/host-kit/run-route-error.d.ts.map +1 -0
- package/dist/host-kit/run-route-error.js +22 -0
- package/dist/host-kit/run-route-error.js.map +1 -0
- package/dist/host-kit/run-router.d.ts +60 -0
- package/dist/host-kit/run-router.d.ts.map +1 -0
- package/dist/host-kit/run-router.js +212 -0
- package/dist/host-kit/run-router.js.map +1 -0
- package/dist/host-kit/subdomain-check.d.ts +23 -0
- package/dist/host-kit/subdomain-check.d.ts.map +1 -0
- package/dist/host-kit/subdomain-check.js +60 -0
- package/dist/host-kit/subdomain-check.js.map +1 -0
- package/dist/host-kit/tenant-registry.d.ts +51 -0
- package/dist/host-kit/tenant-registry.d.ts.map +1 -0
- package/dist/host-kit/tenant-registry.js +87 -0
- package/dist/host-kit/tenant-registry.js.map +1 -0
- package/dist/host-kit/verifier.d.ts +63 -0
- package/dist/host-kit/verifier.d.ts.map +1 -0
- package/dist/host-kit/verifier.js +191 -0
- package/dist/host-kit/verifier.js.map +1 -0
- package/dist/host-kit/workflow-meta.d.ts +25 -0
- package/dist/host-kit/workflow-meta.d.ts.map +1 -0
- package/dist/host-kit/workflow-meta.js +12 -0
- package/dist/host-kit/workflow-meta.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/package.json +95 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// The token-verification seam identity flows through. Both routers accept an
|
|
2
|
+
// `authenticate(request)`; bearerActorAuthenticator (bearer-auth.ts) extracts
|
|
3
|
+
// the bearer token and delegates to a TokenVerifier:
|
|
4
|
+
//
|
|
5
|
+
// staticTokenVerifier — the parsed APPROVAL_ACTOR_TOKENS map (dev/test and
|
|
6
|
+
// small deployments).
|
|
7
|
+
// hmacVerifier — HS256 JWTs signed with a Worker secret (the demo
|
|
8
|
+
// worker mints these; a commercial IdP later drops in as another
|
|
9
|
+
// TokenVerifier implementation without touching the routers).
|
|
10
|
+
//
|
|
11
|
+
// TRUSTED-COMPUTING-BASE code: a verifier ASSERTS identity, including
|
|
12
|
+
// `tenantId` — the axis every isolation predicate keys on. Every path out of
|
|
13
|
+
// this module therefore validates the tenant against TENANT_ID_PATTERN
|
|
14
|
+
// (INV-3) and the role against APPROVAL_ROLES before an ApprovalActor exists.
|
|
15
|
+
// Fail closed: anything malformed verifies to `undefined` (a 401), never to a
|
|
16
|
+
// default actor.
|
|
17
|
+
import { APPROVAL_ROLES } from '../approval-api/index.js';
|
|
18
|
+
import { RESERVED_TENANT_IDS, TENANT_ID_PATTERN, } from '../do-runner/path-safe-id.js';
|
|
19
|
+
/**
|
|
20
|
+
* Validate an untyped candidate into an ApprovalActor — the ONE place a
|
|
21
|
+
* decoded token/map entry becomes an identity. No `as`-casting at the JSON
|
|
22
|
+
* boundary: id non-empty, role recognized, tenantId INV-3-valid and not a
|
|
23
|
+
* reserved identity.
|
|
24
|
+
*/
|
|
25
|
+
export function toApprovalActor(candidate) {
|
|
26
|
+
if (candidate === null || typeof candidate !== 'object')
|
|
27
|
+
return undefined;
|
|
28
|
+
const { id, role, tenantId } = candidate;
|
|
29
|
+
if (typeof id !== 'string' || id.length === 0)
|
|
30
|
+
return undefined;
|
|
31
|
+
if (typeof role !== 'string' ||
|
|
32
|
+
!APPROVAL_ROLES.includes(role)) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
if (typeof tenantId !== 'string' || !TENANT_ID_PATTERN.test(tenantId)) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
// 'system' is the TCB's own audit identity (cron maintenance attribution);
|
|
39
|
+
// a client token claiming it would launder into the operator's maintenance
|
|
40
|
+
// log stream. Only RESERVED_TENANT_IDS bites here: rejecting the routing
|
|
41
|
+
// slugs (api/docs/...) too would 401 a single-tenant host named 'api' over
|
|
42
|
+
// a subdomain collision that cannot occur on a host with no subdomains —
|
|
43
|
+
// those stay allocation/routing concerns (RESERVED_FOR_ALLOCATION).
|
|
44
|
+
if (RESERVED_TENANT_IDS.includes(tenantId))
|
|
45
|
+
return undefined;
|
|
46
|
+
return { id, role: role, tenantId };
|
|
47
|
+
}
|
|
48
|
+
/** The parsed bearer map as a TokenVerifier (entries are pre-validated). */
|
|
49
|
+
export function staticTokenVerifier(actors) {
|
|
50
|
+
return {
|
|
51
|
+
async verify(token) {
|
|
52
|
+
return actors.get(token);
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const encoder = new TextEncoder();
|
|
57
|
+
function base64UrlDecodeBytes(segment) {
|
|
58
|
+
const normalized = segment.replace(/-/g, '+').replace(/_/g, '/');
|
|
59
|
+
const padded = normalized + '='.repeat((4 - (normalized.length % 4)) % 4);
|
|
60
|
+
try {
|
|
61
|
+
const binary = atob(padded);
|
|
62
|
+
const bytes = new Uint8Array(binary.length);
|
|
63
|
+
for (let index = 0; index < binary.length; index += 1) {
|
|
64
|
+
bytes[index] = binary.charCodeAt(index);
|
|
65
|
+
}
|
|
66
|
+
return bytes;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function base64UrlDecodeJson(segment) {
|
|
73
|
+
const bytes = base64UrlDecodeBytes(segment);
|
|
74
|
+
if (!bytes)
|
|
75
|
+
return undefined;
|
|
76
|
+
try {
|
|
77
|
+
return JSON.parse(new TextDecoder().decode(bytes));
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export function base64UrlEncode(bytes) {
|
|
84
|
+
let binary = '';
|
|
85
|
+
for (const byte of bytes)
|
|
86
|
+
binary += String.fromCharCode(byte);
|
|
87
|
+
return btoa(binary)
|
|
88
|
+
.replace(/\+/g, '-')
|
|
89
|
+
.replace(/\//g, '_')
|
|
90
|
+
.replace(/=+$/, '');
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* HMAC-SHA256 a payload with `secret`, base64url-encoded. The canonical
|
|
94
|
+
* signer — the demo's OAuth state signing reuses it rather than re-rolling
|
|
95
|
+
* importKey + subtle.sign (two HMAC paths drift; the base64url pair already
|
|
96
|
+
* did).
|
|
97
|
+
*/
|
|
98
|
+
export async function hmacSign(secret, payload) {
|
|
99
|
+
const key = await importHmacKey(secret, 'sign');
|
|
100
|
+
const signature = await crypto.subtle.sign('HMAC', key, encoder.encode(payload));
|
|
101
|
+
return base64UrlEncode(new Uint8Array(signature));
|
|
102
|
+
}
|
|
103
|
+
async function importHmacKey(secret, usage) {
|
|
104
|
+
return crypto.subtle.importKey('raw', encoder.encode(secret), { name: 'HMAC', hash: 'SHA-256' }, false, [usage]);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* HS256 JWT verifier over Worker-secret keys.
|
|
108
|
+
*
|
|
109
|
+
* The algorithm is PINNED: only `alg: "HS256"` verifies — `none` and every
|
|
110
|
+
* negotiated value are rejected before any cryptography runs, so a token
|
|
111
|
+
* cannot choose its own verification scheme. Signature comparison goes
|
|
112
|
+
* through crypto.subtle.verify (constant-time), never a hand-rolled string
|
|
113
|
+
* compare. Claims checked: exp (required), nbf (when present), iss, aud
|
|
114
|
+
* (string or array), then sub/role/tenantId through toApprovalActor.
|
|
115
|
+
*/
|
|
116
|
+
export function hmacVerifier(options) {
|
|
117
|
+
const now = options.now ?? Date.now;
|
|
118
|
+
return {
|
|
119
|
+
async verify(token) {
|
|
120
|
+
const parts = token.split('.');
|
|
121
|
+
if (parts.length !== 3)
|
|
122
|
+
return undefined;
|
|
123
|
+
const [headerPart, claimsPart, signaturePart] = parts;
|
|
124
|
+
const header = base64UrlDecodeJson(headerPart);
|
|
125
|
+
if (header?.alg !== 'HS256')
|
|
126
|
+
return undefined;
|
|
127
|
+
let secret;
|
|
128
|
+
if (typeof header.kid === 'string') {
|
|
129
|
+
secret = options.keys.get(header.kid);
|
|
130
|
+
}
|
|
131
|
+
else if (header.kid === undefined && options.keys.size === 1) {
|
|
132
|
+
secret = [...options.keys.values()][0];
|
|
133
|
+
}
|
|
134
|
+
if (secret === undefined)
|
|
135
|
+
return undefined;
|
|
136
|
+
const signature = base64UrlDecodeBytes(signaturePart);
|
|
137
|
+
if (!signature)
|
|
138
|
+
return undefined;
|
|
139
|
+
const key = await importHmacKey(secret, 'verify');
|
|
140
|
+
const valid = await crypto.subtle.verify('HMAC', key, signature, encoder.encode(`${headerPart}.${claimsPart}`));
|
|
141
|
+
if (!valid)
|
|
142
|
+
return undefined;
|
|
143
|
+
const claims = base64UrlDecodeJson(claimsPart);
|
|
144
|
+
if (!claims)
|
|
145
|
+
return undefined;
|
|
146
|
+
const nowSeconds = now() / 1000;
|
|
147
|
+
if (typeof claims.exp !== 'number' || nowSeconds >= claims.exp) {
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
if (claims.nbf !== undefined) {
|
|
151
|
+
if (typeof claims.nbf !== 'number' || nowSeconds < claims.nbf) {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (claims.iss !== options.issuer)
|
|
156
|
+
return undefined;
|
|
157
|
+
const audiences = Array.isArray(claims.aud) ? claims.aud : [claims.aud];
|
|
158
|
+
if (!audiences.includes(options.audience))
|
|
159
|
+
return undefined;
|
|
160
|
+
return toApprovalActor({
|
|
161
|
+
id: claims.sub,
|
|
162
|
+
role: claims.role,
|
|
163
|
+
tenantId: claims.tenantId,
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Mint an HS256 JWT hmacVerifier accepts — the demo worker's token factory
|
|
170
|
+
* and the test suite's fixture builder. Server-side only: the secret must
|
|
171
|
+
* never reach a client.
|
|
172
|
+
*/
|
|
173
|
+
export async function mintHmacToken(options) {
|
|
174
|
+
const nowSeconds = Math.floor((options.now ?? Date.now)() / 1000);
|
|
175
|
+
const header = { alg: 'HS256', typ: 'JWT', kid: options.kid };
|
|
176
|
+
const claims = {
|
|
177
|
+
iss: options.issuer,
|
|
178
|
+
aud: options.audience,
|
|
179
|
+
sub: options.actor.id,
|
|
180
|
+
role: options.actor.role,
|
|
181
|
+
tenantId: options.actor.tenantId,
|
|
182
|
+
iat: nowSeconds,
|
|
183
|
+
exp: nowSeconds + options.ttlSeconds,
|
|
184
|
+
};
|
|
185
|
+
const headerPart = base64UrlEncode(encoder.encode(JSON.stringify(header)));
|
|
186
|
+
const claimsPart = base64UrlEncode(encoder.encode(JSON.stringify(claims)));
|
|
187
|
+
const key = await importHmacKey(options.secret, 'sign');
|
|
188
|
+
const signature = await crypto.subtle.sign('HMAC', key, encoder.encode(`${headerPart}.${claimsPart}`));
|
|
189
|
+
return `${headerPart}.${claimsPart}.${base64UrlEncode(new Uint8Array(signature))}`;
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=verifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifier.js","sourceRoot":"","sources":["../../src/host-kit/verifier.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,8EAA8E;AAC9E,qDAAqD;AACrD,EAAE;AACF,6EAA6E;AAC7E,0BAA0B;AAC1B,2EAA2E;AAC3E,qEAAqE;AACrE,kEAAkE;AAClE,EAAE;AACF,sE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AO,CAAC,KAAK,CAAC,EAAE;QACrB,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI;QACxB,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ;QAChC,GAAG,EAAE,UAAU;QACf,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU;KACrC,CAAC;IACF,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC3E,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC3E,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxD,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CACxC,MAAM,EACN,GAAG,EACH,OAAO,CAAC,MAAM,CAAC,GAAG,UAAU,IAAI,UAAU,EAAE,CAAC,CAC9C,CAAC;IACF,OAAO,GAAG,UAAU,IAAI,UAAU,IAAI,eAAe,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;AACrF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ApprovalRole } from '../approval-api/index.js';
|
|
2
|
+
/** Static metadata every workflow advertises to a launcher/host. */
|
|
3
|
+
export interface WorkflowMeta {
|
|
4
|
+
/** Workflow id — MUST equal the registered createWorkflow id (PATH_SAFE_ID_PATTERN). */
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
/** A ready-to-run inputData example a launcher can prefill. */
|
|
9
|
+
sampleInput: unknown;
|
|
10
|
+
/**
|
|
11
|
+
* Roles permitted to ADVANCE this workflow at the HTTP routes — start AND
|
|
12
|
+
* resume (any mutating method; a role that may not start a workflow may
|
|
13
|
+
* not drive its suspended runs to completion either). Reads stay coarse:
|
|
14
|
+
* reviewer/viewer inspect runs they cannot drive. Omitted => only the
|
|
15
|
+
* host's coarse start-role check applies. This is a route-level gate; the
|
|
16
|
+
* approval queue's own role policy governs decisions, and in-step RBAC (if
|
|
17
|
+
* any) is enforced separately inside the workflow.
|
|
18
|
+
*
|
|
19
|
+
* Must be a SUBSET of the host's coarse start-role set (RUN_START_ROLES in
|
|
20
|
+
* approval-api/contract.ts): the coarse gate runs first, so any role listed
|
|
21
|
+
* here that cannot start a run at all is silently dead.
|
|
22
|
+
*/
|
|
23
|
+
allowedRoles?: readonly ApprovalRole[];
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=workflow-meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-meta.d.ts","sourceRoot":"","sources":["../../src/host-kit/workflow-meta.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,oEAAoE;AACpE,MAAM,WAAW,YAAY;IAC3B,wFAAwF;IACxF,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,WAAW,EAAE,OAAO,CAAC;IACrB;;;;;;;;;;;;OAYG;IACH,YAAY,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;CACxC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// WorkflowMeta — the metadata a host advertises for a workflow, and the only
|
|
2
|
+
// part of the module contract the run router needs.
|
|
3
|
+
//
|
|
4
|
+
// Deliberately its own leaf module, separate from module.ts: `WorkflowModule`
|
|
5
|
+
// carries a breakwater `AuditLogger` in its registration context, and
|
|
6
|
+
// breakwater is a devDependency (flowsafe has no runtime dependency on it). A
|
|
7
|
+
// barrel that re-exported the module contract would pull that type into the
|
|
8
|
+
// public `./host-kit` .d.ts graph, so a consumer importing merely
|
|
9
|
+
// `createRunRouter` would need breakwater installed to typecheck. Keeping meta
|
|
10
|
+
// here lets index.ts export a breakwater-free surface.
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=workflow-meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-meta.js","sourceRoot":"","sources":["../../src/host-kit/workflow-meta.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,oDAAoD;AACpD,EAAE;AACF,8EAA8E;AAC9E,sEAAsE;AACtE,8EAA8E;AAC9E,4EAA4E;AAC5E,kEAAkE;AAClE,+EAA+E;AAC/E,uDAAuD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { ApprovalActor, ApprovalAuditEvent, ApprovalAuditSink, ApprovalCursor, ApprovalDatabase, ApprovalDecision, ApprovalListFilter, ApprovalListOrder, ApprovalMetrics, ApprovalPatch, ApprovalPreparedStatement, ApprovalPriority, ApprovalRecord, ApprovalRole, ApprovalRouter, ApprovalRouterOptions, ApprovalServiceOptions, ApprovalStatus, ApprovalStore, ApprovalStoreFactory, CreateApprovalInput, CreateResult, CreateTenantResolverOptions, DecideResult, PurgeExpiredApprovalsOptions, ResumeOutcome, SweepSLAOptions, SystemApprovalStore, TenantBoundApprovalStore, TenantContext, TenantResolver, } from './approval-api/index.js';
|
|
2
|
+
export { APPROVAL_LIST_ORDERS, APPROVAL_PRIORITIES, APPROVAL_ROLES, APPROVAL_STATUSES, ApprovalAuthzError, ApprovalConflictError, ApprovalService, approvalCursor, approvalGrantProvider, approvalGrantProviderFromFactory, approvalListOrder, approvedConnectorsForLeg, BREAKWATER_ACTOR_KEY, BREAKWATER_APPROVED_CONNECTORS_KEY, BREAKWATER_WORKFLOW_SCOPE_KEY, byReviewerOrder, CLIENT_CREATE_FIELDS, createApprovalRouter, createTenantResolver, D1ApprovalStoreFactory, defaultResumeData, InMemoryApprovalStore, InMemoryApprovalStoreFactory, InvalidApprovalInputError, MAX_APPROVAL_LIST_LIMIT, OPEN_STATUSES, parseApprovalCursor, purgeExpiredApprovals, RUN_START_ROLES, resumeViaRuntime, stepKeyOf, sweepSLA, TCB_ONLY_CREATE_FIELDS, TENANT_BOUND, TERMINAL_APPROVAL_STATUSES, TenantResolutionError, UnknownApprovalError, } from './approval-api/index.js';
|
|
3
|
+
export type { ArtifactBody, ArtifactBucket, ArtifactBucketListResult, ArtifactBucketObject, ArtifactBucketObjectBody, ArtifactContent, ArtifactRecord, ArtifactRef, ListArtifactsScope, PutArtifactOptions, R2ArtifactStoreOptions, } from './artifacts/index.js';
|
|
4
|
+
export { InMemoryArtifactBucket, InvalidArtifactRefError, R2ArtifactStore, } from './artifacts/index.js';
|
|
5
|
+
export type { AuditExportFetch, AuditExportOptions, AuditMessageBatch, AuditQueue, AuditQueueMessage, } from './audit-export/index.js';
|
|
6
|
+
export { createAuditQueueConsumer, createAuditQueueHandler, queueAuditSink, } from './audit-export/index.js';
|
|
7
|
+
export type { D1DatabaseBinding, D1StorageOptions, DORunnerEnv, DurableObjectRunnerState, InitOptions, InitResult, InitSource, PurgeExpiredRunsOptions, PurgeTenantOptions, PurgeTenantResult, RequestContextProvider, ResumeLedger, ResumeLedgerStorage, ResumeRunOptions, RunLeg, RunnerRuntimeOptions, RunSummary, SnapshotDatabase, SnapshotStatement, StartRunOptions, TenantArtifactPurger, } from './do-runner/index.js';
|
|
8
|
+
export { createD1Storage, DurableObjectRunner, DurableStorageResumeLedger, d1Changes, ensureSnapshotRunIdIndex, InMemoryResumeLedger, InvalidRunRequestError, init, PATH_SAFE_ID_PATTERN, purgeExpiredWorkflowRuns, purgeTenant, RunAlreadyExistsError, RunNotSuspendedError, RunnerRuntime, TENANT_ID_PATTERN, tenantOfRunId, UnknownRunError, UnknownWorkflowError, } from './do-runner/index.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,yBAAyB,EACzB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,2BAA2B,EAC3B,YAAY,EACZ,4BAA4B,EAC5B,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACxB,aAAa,EACb,cAAc,GACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,gCAAgC,EAChC,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,kCAAkC,EAClC,6BAA6B,EAC7B,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,4BAA4B,EAC5B,yBAAyB,EACzB,uBAAuB,EACvB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,sBAAsB,EACtB,YAAY,EACZ,0BAA0B,EAC1B,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,YAAY,EACZ,cAAc,EACd,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACxB,eAAe,EACf,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,cAAc,GACf,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,wBAAwB,EACxB,WAAW,EACX,UAAU,EACV,UAAU,EACV,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,MAAM,EACN,oBAAoB,EACpB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,0BAA0B,EAC1B,SAAS,EACT,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,IAAI,EACJ,oBAAoB,EACpB,wBAAwB,EACxB,WAAW,EACX,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,oBAAoB,GACrB,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// @proofoftech/flowsafe — Approval UX + Cloudflare-native durable execution
|
|
2
|
+
//
|
|
3
|
+
// flowsafe plugs into Mastra's suspend/resume workflow events and adds:
|
|
4
|
+
// 1. Approval API — queue, claim, decide, delegate, SLA tracking, escalation,
|
|
5
|
+
// and store-derived breakwater grant minting
|
|
6
|
+
// 2. Approval dashboard — minimal React UI for the approval queue
|
|
7
|
+
// (subpath export '@proofoftech/flowsafe/approval-ui' only — a standalone
|
|
8
|
+
// app over the REST API)
|
|
9
|
+
// 3. DO runner — init()-based import-swap for Mastra on Cloudflare Durable Objects
|
|
10
|
+
// 4. Audit export — Queues producer sink + batch consumer shipping audit
|
|
11
|
+
// events to a SIEM over HTTP
|
|
12
|
+
// 5. Artifacts — R2-backed workflow artifact storage keyed by run identity
|
|
13
|
+
// 6. Host kit — the shared run routes, bearer auth seam, and suspension→approval
|
|
14
|
+
// bridge every host mounts (subpath export '@proofoftech/flowsafe/host-kit'
|
|
15
|
+
// only — it is host glue, not part of the library's core surface)
|
|
16
|
+
//
|
|
17
|
+
// Export rule: this root barrel mirrors the approval-api, do-runner,
|
|
18
|
+
// artifacts, and audit-export subpath barrels COMPLETELY — anything those
|
|
19
|
+
// subpaths export is also importable from the package root. approval-ui and
|
|
20
|
+
// host-kit are subpath-only by design (React peer / host glue).
|
|
21
|
+
export { APPROVAL_LIST_ORDERS, APPROVAL_PRIORITIES, APPROVAL_ROLES, APPROVAL_STATUSES, ApprovalAuthzError, ApprovalConflictError, ApprovalService, approvalCursor, approvalGrantProvider, approvalGrantProviderFromFactory, approvalListOrder, approvedConnectorsForLeg, BREAKWATER_ACTOR_KEY, BREAKWATER_APPROVED_CONNECTORS_KEY, BREAKWATER_WORKFLOW_SCOPE_KEY, byReviewerOrder, CLIENT_CREATE_FIELDS, createApprovalRouter, createTenantResolver, D1ApprovalStoreFactory, defaultResumeData, InMemoryApprovalStore, InMemoryApprovalStoreFactory, InvalidApprovalInputError, MAX_APPROVAL_LIST_LIMIT, OPEN_STATUSES, parseApprovalCursor, purgeExpiredApprovals, RUN_START_ROLES, resumeViaRuntime, stepKeyOf, sweepSLA, TCB_ONLY_CREATE_FIELDS, TENANT_BOUND, TERMINAL_APPROVAL_STATUSES, TenantResolutionError, UnknownApprovalError, } from './approval-api/index.js';
|
|
22
|
+
export { InMemoryArtifactBucket, InvalidArtifactRefError, R2ArtifactStore, } from './artifacts/index.js';
|
|
23
|
+
export { createAuditQueueConsumer, createAuditQueueHandler, queueAuditSink, } from './audit-export/index.js';
|
|
24
|
+
export { createD1Storage, DurableObjectRunner, DurableStorageResumeLedger, d1Changes, ensureSnapshotRunIdIndex, InMemoryResumeLedger, InvalidRunRequestError, init, PATH_SAFE_ID_PATTERN, purgeExpiredWorkflowRuns, purgeTenant, RunAlreadyExistsError, RunNotSuspendedError, RunnerRuntime, TENANT_ID_PATTERN, tenantOfRunId, UnknownRunError, UnknownWorkflowError, } from './do-runner/index.js';
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,EAAE;AACF,wEAAwE;AACxE,8EAA8E;AAC9E,gDAAgD;AAChD,kEAAkE;AAClE,6EAA6E;AAC7E,4BAA4B;AAC5B,mFAAmF;AACnF,yEAAyE;AACzE,gCAAgC;AAChC,2EAA2E;AAC3E,iFAAiF;AACjF,+EAA+E;AAC/E,qEAAqE;AACrE,EAAE;AACF,qEAAqE;AACrE,0EAA0E;AAC1E,4EAA4E;AAC5E,gEAAgE;AAmChE,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,gCAAgC,EAChC,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,kCAAkC,EAClC,6BAA6B,EAC7B,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,4BAA4B,EAC5B,yBAAyB,EACzB,uBAAuB,EACvB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,sBAAsB,EACtB,YAAY,EACZ,0BAA0B,EAC1B,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AAcjC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,cAAc,GACf,MAAM,yBAAyB,CAAC;AAwBjC,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,0BAA0B,EAC1B,SAAS,EACT,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,IAAI,EACJ,oBAAoB,EACpB,wBAAwB,EACxB,WAAW,EACX,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,oBAAoB,GACrB,MAAM,sBAAsB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proofoftech/flowsafe",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md",
|
|
10
|
+
"CHANGELOG.md",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=22"
|
|
16
|
+
},
|
|
17
|
+
"description": "Approval UX + Cloudflare-native durable execution for AI agent workflows",
|
|
18
|
+
"type": "module",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/ProofOfTechOrg/anchorage.git",
|
|
22
|
+
"directory": "packages/flowsafe"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/ProofOfTechOrg/anchorage/tree/main/packages/flowsafe#readme",
|
|
25
|
+
"bugs": "https://github.com/ProofOfTechOrg/anchorage/issues",
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": "./dist/index.js",
|
|
30
|
+
"./approval-api": "./dist/approval-api/index.js",
|
|
31
|
+
"./approval-ui": "./dist/approval-ui/index.js",
|
|
32
|
+
"./artifacts": "./dist/artifacts/index.js",
|
|
33
|
+
"./audit-export": "./dist/audit-export/index.js",
|
|
34
|
+
"./do-runner": "./dist/do-runner/index.js",
|
|
35
|
+
"./host-kit": "./dist/host-kit/index.js",
|
|
36
|
+
"./host-kit/module": "./dist/host-kit/module.js",
|
|
37
|
+
"./package.json": "./package.json"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@mastra/core": "^1.50.0",
|
|
41
|
+
"@proofoftech/breakwater": "^0.1.0",
|
|
42
|
+
"react": ">=18 <20",
|
|
43
|
+
"react-dom": ">=18 <20"
|
|
44
|
+
},
|
|
45
|
+
"peerDependenciesMeta": {
|
|
46
|
+
"@proofoftech/breakwater": {
|
|
47
|
+
"optional": true
|
|
48
|
+
},
|
|
49
|
+
"react": {
|
|
50
|
+
"optional": true
|
|
51
|
+
},
|
|
52
|
+
"react-dom": {
|
|
53
|
+
"optional": true
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@cloudflare/workers-types": "^4.2025",
|
|
58
|
+
"@mastra/core": "^1.50.0",
|
|
59
|
+
"@types/react": "^19.0.0",
|
|
60
|
+
"@types/react-dom": "^19.0.0",
|
|
61
|
+
"happy-dom": "^20.10.6",
|
|
62
|
+
"react": "^19.0.0",
|
|
63
|
+
"react-dom": "^19.0.0",
|
|
64
|
+
"typescript": "^5.6",
|
|
65
|
+
"vitest": "^4.1.8",
|
|
66
|
+
"wrangler": "^4.107.0",
|
|
67
|
+
"zod": "^4.4.3",
|
|
68
|
+
"@proofoftech/breakwater": "0.1.0"
|
|
69
|
+
},
|
|
70
|
+
"keywords": [
|
|
71
|
+
"mastra",
|
|
72
|
+
"ai-agents",
|
|
73
|
+
"approval-workflow",
|
|
74
|
+
"human-in-the-loop",
|
|
75
|
+
"cloudflare-workers",
|
|
76
|
+
"durable-objects"
|
|
77
|
+
],
|
|
78
|
+
"license": "Apache-2.0",
|
|
79
|
+
"dependencies": {
|
|
80
|
+
"@mastra/cloudflare-d1": "^1.1.1"
|
|
81
|
+
},
|
|
82
|
+
"scripts": {
|
|
83
|
+
"build": "tsc && tsc -p src/approval-ui/tsconfig.json",
|
|
84
|
+
"dev": "tsc --watch",
|
|
85
|
+
"test": "vitest run",
|
|
86
|
+
"test:watch": "vitest",
|
|
87
|
+
"example:gtm": "vitest run examples/gtm-outbound.e2e.test.ts",
|
|
88
|
+
"lint": "pnpm -w exec biome check packages/flowsafe",
|
|
89
|
+
"typecheck": "tsc -p tsconfig.test.json && tsc -p src/approval-ui/tsconfig.json --noEmit && tsc -p src/approval-ui/tsconfig.test.json && tsc -p spike/tsconfig.json && tsc -p deploy/tsconfig.json",
|
|
90
|
+
"spike": "wrangler dev --config spike/wrangler.jsonc",
|
|
91
|
+
"spike:verify": "node scripts/spike-verify.mjs",
|
|
92
|
+
"deploy:cf": "wrangler deploy --config deploy/wrangler.jsonc",
|
|
93
|
+
"deploy:dev": "wrangler dev --config deploy/wrangler.jsonc"
|
|
94
|
+
}
|
|
95
|
+
}
|