@kya-os/consent 0.4.1 → 0.5.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/README.md +8 -4
- package/dist/bundle/index.d.ts +5 -0
- package/dist/bundle/index.d.ts.map +1 -1
- package/dist/bundle/index.js +7 -0
- package/dist/bundle/index.js.map +1 -1
- package/dist/bundle/inline.d.ts.map +1 -1
- package/dist/bundle/inline.js +4 -4
- package/dist/bundle/inline.js.map +1 -1
- package/dist/cjs/bundle/index.js +21 -0
- package/dist/cjs/bundle/index.js.map +1 -1
- package/dist/cjs/bundle/inline.js +4 -4
- package/dist/cjs/bundle/inline.js.map +1 -1
- package/dist/cjs/components/consent-capabilities-screen.js +168 -215
- package/dist/cjs/components/consent-capabilities-screen.js.map +1 -1
- package/dist/cjs/components/consent-capability-card.js +30 -7
- package/dist/cjs/components/consent-capability-card.js.map +1 -1
- package/dist/cjs/components/consent-connector-header.js +69 -15
- package/dist/cjs/components/consent-connector-header.js.map +1 -1
- package/dist/cjs/components/consent-flow-timeline.js +177 -0
- package/dist/cjs/components/consent-flow-timeline.js.map +1 -0
- package/dist/cjs/components/consent-flow.js +540 -0
- package/dist/cjs/components/consent-flow.js.map +1 -0
- package/dist/cjs/components/consent-footer.js +9 -2
- package/dist/cjs/components/consent-footer.js.map +1 -1
- package/dist/cjs/components/consent-headline.js +30 -76
- package/dist/cjs/components/consent-headline.js.map +1 -1
- package/dist/cjs/components/consent-oauth-button.js +10 -89
- package/dist/cjs/components/consent-oauth-button.js.map +1 -1
- package/dist/cjs/components/consent-revocation-notice.js +25 -16
- package/dist/cjs/components/consent-revocation-notice.js.map +1 -1
- package/dist/cjs/components/consent-wallet-check.js +25 -1
- package/dist/cjs/components/consent-wallet-check.js.map +1 -1
- package/dist/cjs/components/decision-icons.js +6 -2
- package/dist/cjs/components/decision-icons.js.map +1 -1
- package/dist/cjs/components/flow-blocks.js +762 -0
- package/dist/cjs/components/flow-blocks.js.map +1 -0
- package/dist/cjs/components/flow-motion.js +177 -0
- package/dist/cjs/components/flow-motion.js.map +1 -0
- package/dist/cjs/components/grant-details.js +143 -0
- package/dist/cjs/components/grant-details.js.map +1 -0
- package/dist/cjs/components/index.js +10 -1
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/components/mcp-consent.js +12 -0
- package/dist/cjs/components/mcp-consent.js.map +1 -1
- package/dist/cjs/components/provider-icons.js +92 -0
- package/dist/cjs/components/provider-icons.js.map +1 -0
- package/dist/cjs/constants/capabilities.js +6 -1
- package/dist/cjs/constants/capabilities.js.map +1 -1
- package/dist/cjs/copy/tokens.js +9 -5
- package/dist/cjs/copy/tokens.js.map +1 -1
- package/dist/cjs/flow/copy.js +146 -0
- package/dist/cjs/flow/copy.js.map +1 -0
- package/dist/cjs/flow/index.js +31 -0
- package/dist/cjs/flow/index.js.map +1 -0
- package/dist/cjs/flow/model.js +107 -0
- package/dist/cjs/flow/model.js.map +1 -0
- package/dist/cjs/flow/presets.js +157 -0
- package/dist/cjs/flow/presets.js.map +1 -0
- package/dist/cjs/flow/schema.js +76 -0
- package/dist/cjs/flow/schema.js.map +1 -0
- package/dist/cjs/mcp-app/inline.js +2 -2
- package/dist/cjs/mcp-app/inline.js.map +1 -1
- package/dist/cjs/react/index.js +30 -1
- package/dist/cjs/react/index.js.map +1 -1
- package/dist/cjs/styles/theme.js +8 -6
- package/dist/cjs/styles/theme.js.map +1 -1
- package/dist/components/consent-capabilities-screen.d.ts +22 -6
- package/dist/components/consent-capabilities-screen.d.ts.map +1 -1
- package/dist/components/consent-capabilities-screen.js +169 -216
- package/dist/components/consent-capabilities-screen.js.map +1 -1
- package/dist/components/consent-capability-card.d.ts +10 -1
- package/dist/components/consent-capability-card.d.ts.map +1 -1
- package/dist/components/consent-capability-card.js +30 -7
- package/dist/components/consent-capability-card.js.map +1 -1
- package/dist/components/consent-connector-header.d.ts +14 -1
- package/dist/components/consent-connector-header.d.ts.map +1 -1
- package/dist/components/consent-connector-header.js +69 -15
- package/dist/components/consent-connector-header.js.map +1 -1
- package/dist/components/consent-flow-timeline.d.ts +49 -0
- package/dist/components/consent-flow-timeline.d.ts.map +1 -0
- package/dist/components/consent-flow-timeline.js +174 -0
- package/dist/components/consent-flow-timeline.js.map +1 -0
- package/dist/components/consent-flow.d.ts +101 -0
- package/dist/components/consent-flow.d.ts.map +1 -0
- package/dist/components/consent-flow.js +504 -0
- package/dist/components/consent-flow.js.map +1 -0
- package/dist/components/consent-footer.d.ts.map +1 -1
- package/dist/components/consent-footer.js +9 -2
- package/dist/components/consent-footer.js.map +1 -1
- package/dist/components/consent-headline.d.ts +12 -5
- package/dist/components/consent-headline.d.ts.map +1 -1
- package/dist/components/consent-headline.js +30 -76
- package/dist/components/consent-headline.js.map +1 -1
- package/dist/components/consent-oauth-button.d.ts +3 -4
- package/dist/components/consent-oauth-button.d.ts.map +1 -1
- package/dist/components/consent-oauth-button.js +10 -89
- package/dist/components/consent-oauth-button.js.map +1 -1
- package/dist/components/consent-revocation-notice.d.ts.map +1 -1
- package/dist/components/consent-revocation-notice.js +25 -16
- package/dist/components/consent-revocation-notice.js.map +1 -1
- package/dist/components/consent-wallet-check.d.ts +8 -0
- package/dist/components/consent-wallet-check.d.ts.map +1 -1
- package/dist/components/consent-wallet-check.js +26 -2
- package/dist/components/consent-wallet-check.js.map +1 -1
- package/dist/components/decision-icons.d.ts +6 -2
- package/dist/components/decision-icons.d.ts.map +1 -1
- package/dist/components/decision-icons.js +6 -2
- package/dist/components/decision-icons.js.map +1 -1
- package/dist/components/flow-blocks.d.ts +45 -0
- package/dist/components/flow-blocks.d.ts.map +1 -0
- package/dist/components/flow-blocks.js +755 -0
- package/dist/components/flow-blocks.js.map +1 -0
- package/dist/components/flow-motion.d.ts +41 -0
- package/dist/components/flow-motion.d.ts.map +1 -0
- package/dist/components/flow-motion.js +164 -0
- package/dist/components/flow-motion.js.map +1 -0
- package/dist/components/grant-details.d.ts +28 -0
- package/dist/components/grant-details.d.ts.map +1 -0
- package/dist/components/grant-details.js +138 -0
- package/dist/components/grant-details.js.map +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +3 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/mcp-consent.d.ts +4 -0
- package/dist/components/mcp-consent.d.ts.map +1 -1
- package/dist/components/mcp-consent.js +12 -0
- package/dist/components/mcp-consent.js.map +1 -1
- package/dist/components/provider-icons.d.ts +16 -0
- package/dist/components/provider-icons.d.ts.map +1 -0
- package/dist/components/provider-icons.js +88 -0
- package/dist/components/provider-icons.js.map +1 -0
- package/dist/consent.js +3066 -1084
- package/dist/consent.min.js +1419 -658
- package/dist/constants/capabilities.d.ts +6 -2
- package/dist/constants/capabilities.d.ts.map +1 -1
- package/dist/constants/capabilities.js +6 -1
- package/dist/constants/capabilities.js.map +1 -1
- package/dist/copy/tokens.d.ts +9 -5
- package/dist/copy/tokens.d.ts.map +1 -1
- package/dist/copy/tokens.js +9 -5
- package/dist/copy/tokens.js.map +1 -1
- package/dist/flow/copy.d.ts +31 -0
- package/dist/flow/copy.d.ts.map +1 -0
- package/dist/flow/copy.js +137 -0
- package/dist/flow/copy.js.map +1 -0
- package/dist/flow/index.d.ts +15 -0
- package/dist/flow/index.d.ts.map +1 -0
- package/dist/flow/index.js +15 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/flow/model.d.ts +209 -0
- package/dist/flow/model.d.ts.map +1 -0
- package/dist/flow/model.js +103 -0
- package/dist/flow/model.js.map +1 -0
- package/dist/flow/presets.d.ts +29 -0
- package/dist/flow/presets.d.ts.map +1 -0
- package/dist/flow/presets.js +153 -0
- package/dist/flow/presets.js.map +1 -0
- package/dist/flow/schema.d.ts +127 -0
- package/dist/flow/schema.d.ts.map +1 -0
- package/dist/flow/schema.js +72 -0
- package/dist/flow/schema.js.map +1 -0
- package/dist/mcp-app/inline.d.ts.map +1 -1
- package/dist/mcp-app/inline.js +2 -2
- package/dist/mcp-app/inline.js.map +1 -1
- package/dist/react/index.d.ts +21 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +29 -0
- package/dist/react/index.js.map +1 -1
- package/dist/styles/theme.d.ts +11 -8
- package/dist/styles/theme.d.ts.map +1 -1
- package/dist/styles/theme.js +8 -6
- package/dist/styles/theme.js.map +1 -1
- package/package.json +9 -4
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consent flow model
|
|
3
|
+
*
|
|
4
|
+
* A consent flow is data: which blocks each step draws, in order, the
|
|
5
|
+
* connector's state in that step, and where focus lands, plus copy overrides.
|
|
6
|
+
* It is plain JSON (no functions), so Checkpoint can store a project's flow in
|
|
7
|
+
* its consent config, validate it (`flowSchema`), diff it against a preset,
|
|
8
|
+
* and have every server render exactly what was saved.
|
|
9
|
+
*
|
|
10
|
+
* This file holds the names and types only. It imports nothing but the
|
|
11
|
+
* package's own types, so the presets and the browser bundle carry no
|
|
12
|
+
* validator.
|
|
13
|
+
*
|
|
14
|
+
* @module flow/model
|
|
15
|
+
*/
|
|
16
|
+
export const FLOW_SCHEMA_VERSION = 1;
|
|
17
|
+
/** The blocks a step can draw. A block name may carry a variant: "capability:locked". */
|
|
18
|
+
export const FLOW_BLOCKS = [
|
|
19
|
+
"eyebrow",
|
|
20
|
+
"headline",
|
|
21
|
+
"sub",
|
|
22
|
+
"signIn",
|
|
23
|
+
"finePrint",
|
|
24
|
+
"approver",
|
|
25
|
+
"capability",
|
|
26
|
+
"details",
|
|
27
|
+
"countdown",
|
|
28
|
+
"actions",
|
|
29
|
+
"status",
|
|
30
|
+
"notice",
|
|
31
|
+
"expiredNote",
|
|
32
|
+
"receipt",
|
|
33
|
+
"goBack",
|
|
34
|
+
"retry",
|
|
35
|
+
];
|
|
36
|
+
/** The steps a flow can have. */
|
|
37
|
+
export const FLOW_STEPS = [
|
|
38
|
+
"sign-in",
|
|
39
|
+
"consent",
|
|
40
|
+
"passkey",
|
|
41
|
+
"granted",
|
|
42
|
+
"denied",
|
|
43
|
+
"cancelled",
|
|
44
|
+
"expired",
|
|
45
|
+
"error",
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* The connector's states; a step names the one it shows. With the wallet
|
|
49
|
+
* check in the connector: resting until the person acts (sign-in, consent),
|
|
50
|
+
* turning while the passkey is open, closed on its check once granted, open
|
|
51
|
+
* at the top when the passkey was dismissed (cancelled), and its error once
|
|
52
|
+
* nothing was granted (denied, expired, error).
|
|
53
|
+
*/
|
|
54
|
+
export const FLOW_CONNECTOR_STATES = [
|
|
55
|
+
"sign-in",
|
|
56
|
+
"consent",
|
|
57
|
+
"passkey",
|
|
58
|
+
"cancelled",
|
|
59
|
+
"granted",
|
|
60
|
+
"denied",
|
|
61
|
+
"expired",
|
|
62
|
+
"error",
|
|
63
|
+
];
|
|
64
|
+
/**
|
|
65
|
+
* How the person approves: `consent` submits on Allow, with no passkey step;
|
|
66
|
+
* `passkey` confirms with a passkey (created first by a first-time shopper).
|
|
67
|
+
*/
|
|
68
|
+
export const APPROVAL_METHODS = ["consent", "passkey"];
|
|
69
|
+
/**
|
|
70
|
+
* How much the flow moves between steps: `default`, `subtle` (shorter and
|
|
71
|
+
* smaller), or `none` (cross-fades only: the reduced-motion path).
|
|
72
|
+
*/
|
|
73
|
+
export const MOTION_PRESETS = ["default", "subtle", "none"];
|
|
74
|
+
/** What sits in the connector's middle: the wallet check, or nothing (its shield). */
|
|
75
|
+
export const CONNECTOR_MARKS = ["wallet-check", "none"];
|
|
76
|
+
/** The motion primitives a flow plays, as its `consent-flow-motion` events name them. */
|
|
77
|
+
export const MOTION_PRIMITIVES = [
|
|
78
|
+
"leave",
|
|
79
|
+
"arrive",
|
|
80
|
+
"move",
|
|
81
|
+
"cross-fade",
|
|
82
|
+
"resize",
|
|
83
|
+
];
|
|
84
|
+
/** The events a flow sends, each as `consent-flow-<name>`, bubbling and composed. */
|
|
85
|
+
export const FLOW_EVENTS = [
|
|
86
|
+
"sign-in",
|
|
87
|
+
"approve",
|
|
88
|
+
"deny",
|
|
89
|
+
"retry",
|
|
90
|
+
"expire",
|
|
91
|
+
"motion",
|
|
92
|
+
"step",
|
|
93
|
+
];
|
|
94
|
+
/** The attributes `<consent-flow>` stamps on itself, for a host or preview to read. */
|
|
95
|
+
export const FLOW_HOST_ATTRIBUTES = {
|
|
96
|
+
version: "data-consent-version",
|
|
97
|
+
approvalMethod: "data-approval-method",
|
|
98
|
+
};
|
|
99
|
+
/** `{ flow, approvalMethod }`, to spread into a declaration's `renders`. */
|
|
100
|
+
export function consentFlowRenders() {
|
|
101
|
+
return { flow: FLOW_SCHEMA_VERSION, approvalMethod: true };
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/flow/model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAErC,yFAAyF;AACzF,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,SAAS;IACT,UAAU;IACV,KAAK;IACL,QAAQ;IACR,WAAW;IACX,UAAU;IACV,YAAY;IACZ,SAAS;IACT,WAAW;IACX,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,aAAa;IACb,SAAS;IACT,QAAQ;IACR,OAAO;CACC,CAAC;AAGX,iCAAiC;AACjC,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,QAAQ;IACR,WAAW;IACX,SAAS;IACT,OAAO;CACC,CAAC;AAGX;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,SAAS;IACT,SAAS;IACT,SAAS;IACT,WAAW;IACX,SAAS;IACT,QAAQ;IACR,SAAS;IACT,OAAO;CACC,CAAC;AAGX;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,SAAS,EAAE,SAAS,CAAU,CAAC;AAGhE;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;AAGrE,sFAAsF;AACtF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,cAAc,EAAE,MAAM,CAAU,CAAC;AAGjE,yFAAyF;AACzF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,OAAO;IACP,QAAQ;IACR,MAAM;IACN,YAAY;IACZ,QAAQ;CACA,CAAC;AA6BX,qFAAqF;AACrF,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,SAAS;IACT,SAAS;IACT,MAAM;IACN,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,MAAM;CACE,CAAC;AAuHX,uFAAuF;AACvF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,OAAO,EAAE,sBAAsB;IAC/B,cAAc,EAAE,sBAAsB;CAC9B,CAAC;AAgBX,4EAA4E;AAC5E,MAAM,UAAU,kBAAkB;IAChC,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consent flow presets
|
|
3
|
+
*
|
|
4
|
+
* The flows Checkpoint offers as templates, as plain JSON. A project's saved
|
|
5
|
+
* flow is one of these, or one of these with its edits; Checkpoint diffs the
|
|
6
|
+
* two. The editor's Approval method switch picks between the `passkey` and
|
|
7
|
+
* `consent` presets (`flowPreset`).
|
|
8
|
+
*
|
|
9
|
+
* @module flow/presets
|
|
10
|
+
*/
|
|
11
|
+
import { type ApprovalMethod, type ConsentFlowDefinition } from "./model.js";
|
|
12
|
+
/** Sign in with the merchant's provider, then approve with a passkey (kya-os-mcp, Liminal). */
|
|
13
|
+
export declare const SIGN_IN_FLOW: ConsentFlowDefinition;
|
|
14
|
+
/** Already signed in; approve with a passkey (Hobbsidian's /c). */
|
|
15
|
+
export declare const DECISION_FLOW: ConsentFlowDefinition;
|
|
16
|
+
/** Sign in, then Allow submits. */
|
|
17
|
+
export declare const SIGN_IN_CONSENT_FLOW: ConsentFlowDefinition;
|
|
18
|
+
/** Already signed in; Allow submits. */
|
|
19
|
+
export declare const DECISION_CONSENT_FLOW: ConsentFlowDefinition;
|
|
20
|
+
/** Every preset, by approval method and whether the flow signs the person in. */
|
|
21
|
+
export declare const FLOW_PRESETS: Record<ApprovalMethod, {
|
|
22
|
+
signIn: ConsentFlowDefinition;
|
|
23
|
+
decision: ConsentFlowDefinition;
|
|
24
|
+
}>;
|
|
25
|
+
/** The preset for an approval method: what the editor's Approval method switch picks. */
|
|
26
|
+
export declare function flowPreset(approvalMethod: ApprovalMethod, { signIn }?: {
|
|
27
|
+
signIn?: boolean;
|
|
28
|
+
}): ConsentFlowDefinition;
|
|
29
|
+
//# sourceMappingURL=presets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/flow/presets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAG3B,MAAM,YAAY,CAAC;AA2IpB,+FAA+F;AAC/F,eAAO,MAAM,YAAY,uBAAqD,CAAC;AAC/E,mEAAmE;AACnE,eAAO,MAAM,aAAa,uBAA6C,CAAC;AACxE,mCAAmC;AACnC,eAAO,MAAM,oBAAoB,uBAA4C,CAAC;AAC9E,wCAAwC;AACxC,eAAO,MAAM,qBAAqB,uBAAoC,CAAC;AAEvE,iFAAiF;AACjF,eAAO,MAAM,YAAY,EAAE,MAAM,CAC/B,cAAc,EACd;IAAE,MAAM,EAAE,qBAAqB,CAAC;IAAC,QAAQ,EAAE,qBAAqB,CAAA;CAAE,CAInE,CAAC;AAEF,yFAAyF;AACzF,wBAAgB,UAAU,CACxB,cAAc,EAAE,cAAc,EAC9B,EAAE,MAAc,EAAE,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5C,qBAAqB,CAEvB"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consent flow presets
|
|
3
|
+
*
|
|
4
|
+
* The flows Checkpoint offers as templates, as plain JSON. A project's saved
|
|
5
|
+
* flow is one of these, or one of these with its edits; Checkpoint diffs the
|
|
6
|
+
* two. The editor's Approval method switch picks between the `passkey` and
|
|
7
|
+
* `consent` presets (`flowPreset`).
|
|
8
|
+
*
|
|
9
|
+
* @module flow/presets
|
|
10
|
+
*/
|
|
11
|
+
import { FLOW_SCHEMA_VERSION, } from "./model.js";
|
|
12
|
+
const CONSENT_BLOCKS = [
|
|
13
|
+
"eyebrow",
|
|
14
|
+
"headline",
|
|
15
|
+
"approver",
|
|
16
|
+
"capability",
|
|
17
|
+
"details",
|
|
18
|
+
"countdown",
|
|
19
|
+
"actions",
|
|
20
|
+
];
|
|
21
|
+
const SIGN_IN_STEP = {
|
|
22
|
+
connector: "sign-in",
|
|
23
|
+
blocks: ["eyebrow", "headline", "signIn", "finePrint"],
|
|
24
|
+
focus: "headline",
|
|
25
|
+
};
|
|
26
|
+
/** The steps both approval methods share. */
|
|
27
|
+
const OUTCOMES = {
|
|
28
|
+
granted: {
|
|
29
|
+
connector: "granted",
|
|
30
|
+
blocks: [
|
|
31
|
+
"eyebrow",
|
|
32
|
+
"headline",
|
|
33
|
+
"approver:granted",
|
|
34
|
+
"sub",
|
|
35
|
+
"receipt",
|
|
36
|
+
"goBack",
|
|
37
|
+
],
|
|
38
|
+
focus: "headline",
|
|
39
|
+
},
|
|
40
|
+
denied: {
|
|
41
|
+
connector: "denied",
|
|
42
|
+
blocks: ["eyebrow", "headline", "sub", "approver:denied"],
|
|
43
|
+
focus: "headline",
|
|
44
|
+
},
|
|
45
|
+
expired: {
|
|
46
|
+
connector: "expired",
|
|
47
|
+
blocks: [
|
|
48
|
+
"eyebrow",
|
|
49
|
+
"headline",
|
|
50
|
+
"approver",
|
|
51
|
+
"capability:dim",
|
|
52
|
+
"expiredNote",
|
|
53
|
+
],
|
|
54
|
+
focus: "headline",
|
|
55
|
+
},
|
|
56
|
+
error: {
|
|
57
|
+
connector: "error",
|
|
58
|
+
blocks: ["eyebrow", "headline", "sub", "approver", "retry"],
|
|
59
|
+
focus: "headline",
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
/** Approve opens the passkey; dismissing it comes back to consent with a notice. */
|
|
63
|
+
const PASSKEY_STEPS = {
|
|
64
|
+
consent: { connector: "consent", blocks: CONSENT_BLOCKS, focus: "headline" },
|
|
65
|
+
passkey: {
|
|
66
|
+
connector: "passkey",
|
|
67
|
+
blocks: [
|
|
68
|
+
"eyebrow",
|
|
69
|
+
"headline",
|
|
70
|
+
"approver",
|
|
71
|
+
"capability:locked",
|
|
72
|
+
"details",
|
|
73
|
+
"countdown",
|
|
74
|
+
"actions:loading",
|
|
75
|
+
"status",
|
|
76
|
+
],
|
|
77
|
+
focus: "status",
|
|
78
|
+
},
|
|
79
|
+
cancelled: {
|
|
80
|
+
connector: "cancelled",
|
|
81
|
+
blocks: [...CONSENT_BLOCKS, "notice"],
|
|
82
|
+
focus: "notice",
|
|
83
|
+
},
|
|
84
|
+
...OUTCOMES,
|
|
85
|
+
};
|
|
86
|
+
/** Allow submits: no passkey step, so nothing to cancel. */
|
|
87
|
+
const CONSENT_STEPS = {
|
|
88
|
+
consent: { connector: "consent", blocks: CONSENT_BLOCKS, focus: "headline" },
|
|
89
|
+
...OUTCOMES,
|
|
90
|
+
};
|
|
91
|
+
/** A first-time shopper creates a passkey rather than using one. */
|
|
92
|
+
const CREATE_PASSKEY_COPY = {
|
|
93
|
+
actions: { approve: "Create a passkey and approve" },
|
|
94
|
+
status: "Create your passkey…",
|
|
95
|
+
seal: {
|
|
96
|
+
consent: "Ready to create a passkey",
|
|
97
|
+
passkey: "Creating your passkey",
|
|
98
|
+
},
|
|
99
|
+
approver: { confirmed: "Confirmed with your new passkey" },
|
|
100
|
+
announce: { passkey: "Create your passkey." },
|
|
101
|
+
};
|
|
102
|
+
const CONSENT_COPY = {
|
|
103
|
+
actions: { approve: "Allow" },
|
|
104
|
+
approver: { confirmed: "Approved" },
|
|
105
|
+
seal: { consent: "Waiting for your approval", granted: "Approved" },
|
|
106
|
+
};
|
|
107
|
+
/** A frozen copy, so no preset shares or changes another's tables. */
|
|
108
|
+
function frozen(value) {
|
|
109
|
+
const copy = JSON.parse(JSON.stringify(value));
|
|
110
|
+
const freeze = (node) => {
|
|
111
|
+
if (node && typeof node === "object") {
|
|
112
|
+
Object.freeze(node);
|
|
113
|
+
Object.values(node).forEach(freeze);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
freeze(copy);
|
|
117
|
+
return copy;
|
|
118
|
+
}
|
|
119
|
+
function flow(name, approvalMethod, signIn) {
|
|
120
|
+
const passkey = approvalMethod === "passkey";
|
|
121
|
+
return frozen({
|
|
122
|
+
version: FLOW_SCHEMA_VERSION,
|
|
123
|
+
name,
|
|
124
|
+
approvalMethod,
|
|
125
|
+
initial: signIn ? "sign-in" : "consent",
|
|
126
|
+
motion: "default",
|
|
127
|
+
connectorMark: "wallet-check",
|
|
128
|
+
steps: {
|
|
129
|
+
...(signIn ? { "sign-in": SIGN_IN_STEP } : {}),
|
|
130
|
+
...(passkey ? PASSKEY_STEPS : CONSENT_STEPS),
|
|
131
|
+
},
|
|
132
|
+
copy: passkey ? {} : CONSENT_COPY,
|
|
133
|
+
copyWhenCreatingPasskey: passkey ? CREATE_PASSKEY_COPY : {},
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/** Sign in with the merchant's provider, then approve with a passkey (kya-os-mcp, Liminal). */
|
|
137
|
+
export const SIGN_IN_FLOW = flow("Sign in, consent, passkey", "passkey", true);
|
|
138
|
+
/** Already signed in; approve with a passkey (Hobbsidian's /c). */
|
|
139
|
+
export const DECISION_FLOW = flow("Consent, passkey", "passkey", false);
|
|
140
|
+
/** Sign in, then Allow submits. */
|
|
141
|
+
export const SIGN_IN_CONSENT_FLOW = flow("Sign in, consent", "consent", true);
|
|
142
|
+
/** Already signed in; Allow submits. */
|
|
143
|
+
export const DECISION_CONSENT_FLOW = flow("Consent", "consent", false);
|
|
144
|
+
/** Every preset, by approval method and whether the flow signs the person in. */
|
|
145
|
+
export const FLOW_PRESETS = {
|
|
146
|
+
passkey: { signIn: SIGN_IN_FLOW, decision: DECISION_FLOW },
|
|
147
|
+
consent: { signIn: SIGN_IN_CONSENT_FLOW, decision: DECISION_CONSENT_FLOW },
|
|
148
|
+
};
|
|
149
|
+
/** The preset for an approval method: what the editor's Approval method switch picks. */
|
|
150
|
+
export function flowPreset(approvalMethod, { signIn = false } = {}) {
|
|
151
|
+
return FLOW_PRESETS[approvalMethod][signIn ? "signIn" : "decision"];
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=presets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../../src/flow/presets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,mBAAmB,GAKpB,MAAM,YAAY,CAAC;AAEpB,MAAM,cAAc,GAAG;IACrB,SAAS;IACT,UAAU;IACV,UAAU;IACV,YAAY;IACZ,SAAS;IACT,WAAW;IACX,SAAS;CACV,CAAC;AAEF,MAAM,YAAY,GAAuB;IACvC,SAAS,EAAE,SAAS;IACpB,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,CAAC;IACtD,KAAK,EAAE,UAAU;CAClB,CAAC;AAEF,6CAA6C;AAC7C,MAAM,QAAQ,GAAkD;IAC9D,OAAO,EAAE;QACP,SAAS,EAAE,SAAS;QACpB,MAAM,EAAE;YACN,SAAS;YACT,UAAU;YACV,kBAAkB;YAClB,KAAK;YACL,SAAS;YACT,QAAQ;SACT;QACD,KAAK,EAAE,UAAU;KAClB;IAC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
1
|
+
/**
|
|
2
|
+
* Consent flow schema
|
|
3
|
+
*
|
|
4
|
+
* What Checkpoint validates a project's saved flow with before it stores it,
|
|
5
|
+
* and what a server checks before it renders one. Strict: an unknown key, an
|
|
6
|
+
* unknown block or step, a focus on a block the step doesn't draw, or a step
|
|
7
|
+
* the approval method has no use for is an error, so what was saved is what
|
|
8
|
+
* every server renders.
|
|
9
|
+
*
|
|
10
|
+
* @module flow/schema
|
|
11
|
+
*/
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { type ConsentFlowDefinition, type FlowCopy } from "./model.js";
|
|
14
|
+
/** "name" or "name:variant", with a known block name. */
|
|
15
|
+
export declare const flowBlockRefSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
16
|
+
export declare const flowCopySchema: z.ZodType<FlowCopy>;
|
|
17
|
+
export declare const flowStepSchema: z.ZodEffects<z.ZodObject<{
|
|
18
|
+
connector: z.ZodEnum<["sign-in", "consent", "passkey", "cancelled", "granted", "denied", "expired", "error"]>;
|
|
19
|
+
blocks: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
20
|
+
focus: z.ZodOptional<z.ZodEnum<["eyebrow", "headline", "sub", "signIn", "finePrint", "approver", "capability", "details", "countdown", "actions", "status", "notice", "expiredNote", "receipt", "goBack", "retry"]>>;
|
|
21
|
+
}, "strict", z.ZodTypeAny, {
|
|
22
|
+
connector: "passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired";
|
|
23
|
+
blocks: string[];
|
|
24
|
+
focus?: "headline" | "status" | "details" | "notice" | "sub" | "eyebrow" | "approver" | "signIn" | "finePrint" | "capability" | "countdown" | "actions" | "expiredNote" | "receipt" | "goBack" | "retry" | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
connector: "passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired";
|
|
27
|
+
blocks: string[];
|
|
28
|
+
focus?: "headline" | "status" | "details" | "notice" | "sub" | "eyebrow" | "approver" | "signIn" | "finePrint" | "capability" | "countdown" | "actions" | "expiredNote" | "receipt" | "goBack" | "retry" | undefined;
|
|
29
|
+
}>, {
|
|
30
|
+
connector: "passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired";
|
|
31
|
+
blocks: string[];
|
|
32
|
+
focus?: "headline" | "status" | "details" | "notice" | "sub" | "eyebrow" | "approver" | "signIn" | "finePrint" | "capability" | "countdown" | "actions" | "expiredNote" | "receipt" | "goBack" | "retry" | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
connector: "passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired";
|
|
35
|
+
blocks: string[];
|
|
36
|
+
focus?: "headline" | "status" | "details" | "notice" | "sub" | "eyebrow" | "approver" | "signIn" | "finePrint" | "capability" | "countdown" | "actions" | "expiredNote" | "receipt" | "goBack" | "retry" | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
export declare const flowSchema: z.ZodEffects<z.ZodObject<{
|
|
39
|
+
version: z.ZodLiteral<1>;
|
|
40
|
+
name: z.ZodString;
|
|
41
|
+
approvalMethod: z.ZodEnum<["consent", "passkey"]>;
|
|
42
|
+
initial: z.ZodEnum<["sign-in", "consent", "passkey", "granted", "denied", "cancelled", "expired", "error"]>;
|
|
43
|
+
motion: z.ZodDefault<z.ZodEnum<["default", "subtle", "none"]>>;
|
|
44
|
+
connectorMark: z.ZodDefault<z.ZodEnum<["wallet-check", "none"]>>;
|
|
45
|
+
steps: z.ZodRecord<z.ZodEnum<["sign-in", "consent", "passkey", "granted", "denied", "cancelled", "expired", "error"]>, z.ZodEffects<z.ZodObject<{
|
|
46
|
+
connector: z.ZodEnum<["sign-in", "consent", "passkey", "cancelled", "granted", "denied", "expired", "error"]>;
|
|
47
|
+
blocks: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
48
|
+
focus: z.ZodOptional<z.ZodEnum<["eyebrow", "headline", "sub", "signIn", "finePrint", "approver", "capability", "details", "countdown", "actions", "status", "notice", "expiredNote", "receipt", "goBack", "retry"]>>;
|
|
49
|
+
}, "strict", z.ZodTypeAny, {
|
|
50
|
+
connector: "passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired";
|
|
51
|
+
blocks: string[];
|
|
52
|
+
focus?: "headline" | "status" | "details" | "notice" | "sub" | "eyebrow" | "approver" | "signIn" | "finePrint" | "capability" | "countdown" | "actions" | "expiredNote" | "receipt" | "goBack" | "retry" | undefined;
|
|
53
|
+
}, {
|
|
54
|
+
connector: "passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired";
|
|
55
|
+
blocks: string[];
|
|
56
|
+
focus?: "headline" | "status" | "details" | "notice" | "sub" | "eyebrow" | "approver" | "signIn" | "finePrint" | "capability" | "countdown" | "actions" | "expiredNote" | "receipt" | "goBack" | "retry" | undefined;
|
|
57
|
+
}>, {
|
|
58
|
+
connector: "passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired";
|
|
59
|
+
blocks: string[];
|
|
60
|
+
focus?: "headline" | "status" | "details" | "notice" | "sub" | "eyebrow" | "approver" | "signIn" | "finePrint" | "capability" | "countdown" | "actions" | "expiredNote" | "receipt" | "goBack" | "retry" | undefined;
|
|
61
|
+
}, {
|
|
62
|
+
connector: "passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired";
|
|
63
|
+
blocks: string[];
|
|
64
|
+
focus?: "headline" | "status" | "details" | "notice" | "sub" | "eyebrow" | "approver" | "signIn" | "finePrint" | "capability" | "countdown" | "actions" | "expiredNote" | "receipt" | "goBack" | "retry" | undefined;
|
|
65
|
+
}>>;
|
|
66
|
+
copy: z.ZodDefault<z.ZodType<FlowCopy, z.ZodTypeDef, FlowCopy>>;
|
|
67
|
+
copyWhenCreatingPasskey: z.ZodDefault<z.ZodType<FlowCopy, z.ZodTypeDef, FlowCopy>>;
|
|
68
|
+
}, "strict", z.ZodTypeAny, {
|
|
69
|
+
name: string;
|
|
70
|
+
version: 1;
|
|
71
|
+
copy: FlowCopy;
|
|
72
|
+
motion: "none" | "default" | "subtle";
|
|
73
|
+
steps: Partial<Record<"passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired", {
|
|
74
|
+
connector: "passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired";
|
|
75
|
+
blocks: string[];
|
|
76
|
+
focus?: "headline" | "status" | "details" | "notice" | "sub" | "eyebrow" | "approver" | "signIn" | "finePrint" | "capability" | "countdown" | "actions" | "expiredNote" | "receipt" | "goBack" | "retry" | undefined;
|
|
77
|
+
}>>;
|
|
78
|
+
approvalMethod: "passkey" | "consent";
|
|
79
|
+
initial: "passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired";
|
|
80
|
+
connectorMark: "none" | "wallet-check";
|
|
81
|
+
copyWhenCreatingPasskey: FlowCopy;
|
|
82
|
+
}, {
|
|
83
|
+
name: string;
|
|
84
|
+
version: 1;
|
|
85
|
+
steps: Partial<Record<"passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired", {
|
|
86
|
+
connector: "passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired";
|
|
87
|
+
blocks: string[];
|
|
88
|
+
focus?: "headline" | "status" | "details" | "notice" | "sub" | "eyebrow" | "approver" | "signIn" | "finePrint" | "capability" | "countdown" | "actions" | "expiredNote" | "receipt" | "goBack" | "retry" | undefined;
|
|
89
|
+
}>>;
|
|
90
|
+
approvalMethod: "passkey" | "consent";
|
|
91
|
+
initial: "passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired";
|
|
92
|
+
copy?: FlowCopy | undefined;
|
|
93
|
+
motion?: "none" | "default" | "subtle" | undefined;
|
|
94
|
+
connectorMark?: "none" | "wallet-check" | undefined;
|
|
95
|
+
copyWhenCreatingPasskey?: FlowCopy | undefined;
|
|
96
|
+
}>, {
|
|
97
|
+
name: string;
|
|
98
|
+
version: 1;
|
|
99
|
+
copy: FlowCopy;
|
|
100
|
+
motion: "none" | "default" | "subtle";
|
|
101
|
+
steps: Partial<Record<"passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired", {
|
|
102
|
+
connector: "passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired";
|
|
103
|
+
blocks: string[];
|
|
104
|
+
focus?: "headline" | "status" | "details" | "notice" | "sub" | "eyebrow" | "approver" | "signIn" | "finePrint" | "capability" | "countdown" | "actions" | "expiredNote" | "receipt" | "goBack" | "retry" | undefined;
|
|
105
|
+
}>>;
|
|
106
|
+
approvalMethod: "passkey" | "consent";
|
|
107
|
+
initial: "passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired";
|
|
108
|
+
connectorMark: "none" | "wallet-check";
|
|
109
|
+
copyWhenCreatingPasskey: FlowCopy;
|
|
110
|
+
}, {
|
|
111
|
+
name: string;
|
|
112
|
+
version: 1;
|
|
113
|
+
steps: Partial<Record<"passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired", {
|
|
114
|
+
connector: "passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired";
|
|
115
|
+
blocks: string[];
|
|
116
|
+
focus?: "headline" | "status" | "details" | "notice" | "sub" | "eyebrow" | "approver" | "signIn" | "finePrint" | "capability" | "countdown" | "actions" | "expiredNote" | "receipt" | "goBack" | "retry" | undefined;
|
|
117
|
+
}>>;
|
|
118
|
+
approvalMethod: "passkey" | "consent";
|
|
119
|
+
initial: "passkey" | "error" | "sign-in" | "consent" | "granted" | "denied" | "cancelled" | "expired";
|
|
120
|
+
copy?: FlowCopy | undefined;
|
|
121
|
+
motion?: "none" | "default" | "subtle" | undefined;
|
|
122
|
+
connectorMark?: "none" | "wallet-check" | undefined;
|
|
123
|
+
copyWhenCreatingPasskey?: FlowCopy | undefined;
|
|
124
|
+
}>;
|
|
125
|
+
/** A saved flow, checked; throws with every problem found. Defaults filled in. */
|
|
126
|
+
export declare function parseConsentFlow(input: unknown): ConsentFlowDefinition;
|
|
127
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/flow/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAQL,KAAK,qBAAqB,EAC1B,KAAK,QAAQ,EACd,MAAM,YAAY,CAAC;AAIpB,yDAAyD;AACzD,eAAO,MAAM,kBAAkB,2CAQ5B,CAAC;AAEJ,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAE9C,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;EAWxB,CAAC;AAEJ,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCnB,CAAC;AAEL,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,qBAAqB,CAEtE"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consent flow schema
|
|
3
|
+
*
|
|
4
|
+
* What Checkpoint validates a project's saved flow with before it stores it,
|
|
5
|
+
* and what a server checks before it renders one. Strict: an unknown key, an
|
|
6
|
+
* unknown block or step, a focus on a block the step doesn't draw, or a step
|
|
7
|
+
* the approval method has no use for is an error, so what was saved is what
|
|
8
|
+
* every server renders.
|
|
9
|
+
*
|
|
10
|
+
* @module flow/schema
|
|
11
|
+
*/
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { APPROVAL_METHODS, CONNECTOR_MARKS, FLOW_BLOCKS, FLOW_CONNECTOR_STATES, FLOW_SCHEMA_VERSION, FLOW_STEPS, MOTION_PRESETS, } from "./model.js";
|
|
14
|
+
const blockName = (ref) => ref.split(":")[0] ?? "";
|
|
15
|
+
/** "name" or "name:variant", with a known block name. */
|
|
16
|
+
export const flowBlockRefSchema = z
|
|
17
|
+
.string()
|
|
18
|
+
.regex(/^[a-zA-Z]+(:[a-z]+)?$/, "a block, or block:variant")
|
|
19
|
+
.refine((ref) => FLOW_BLOCKS.includes(blockName(ref)), {
|
|
20
|
+
message: `a block the package draws: ${FLOW_BLOCKS.join(", ")}`,
|
|
21
|
+
});
|
|
22
|
+
export const flowCopySchema = z.lazy(() => z.record(z.union([z.string(), flowCopySchema])));
|
|
23
|
+
export const flowStepSchema = z
|
|
24
|
+
.object({
|
|
25
|
+
connector: z.enum(FLOW_CONNECTOR_STATES),
|
|
26
|
+
blocks: z.array(flowBlockRefSchema).min(1),
|
|
27
|
+
focus: z.enum(FLOW_BLOCKS).optional(),
|
|
28
|
+
})
|
|
29
|
+
.strict()
|
|
30
|
+
.refine((step) => !step.focus || step.blocks.some((ref) => blockName(ref) === step.focus), { message: "focus names one of the step's blocks", path: ["focus"] });
|
|
31
|
+
export const flowSchema = z
|
|
32
|
+
.object({
|
|
33
|
+
version: z.literal(FLOW_SCHEMA_VERSION),
|
|
34
|
+
name: z.string().min(1),
|
|
35
|
+
approvalMethod: z.enum(APPROVAL_METHODS),
|
|
36
|
+
initial: z.enum(FLOW_STEPS),
|
|
37
|
+
motion: z.enum(MOTION_PRESETS).default("default"),
|
|
38
|
+
connectorMark: z.enum(CONNECTOR_MARKS).default("wallet-check"),
|
|
39
|
+
steps: z.record(z.enum(FLOW_STEPS), flowStepSchema),
|
|
40
|
+
copy: flowCopySchema.default({}),
|
|
41
|
+
copyWhenCreatingPasskey: flowCopySchema.default({}),
|
|
42
|
+
})
|
|
43
|
+
.strict()
|
|
44
|
+
.superRefine((flow, ctx) => {
|
|
45
|
+
if (!flow.steps[flow.initial]) {
|
|
46
|
+
ctx.addIssue({
|
|
47
|
+
code: z.ZodIssueCode.custom,
|
|
48
|
+
path: ["initial"],
|
|
49
|
+
message: "the first step is one of the flow's steps",
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const passkeySteps = ["passkey", "cancelled"].filter((step) => flow.steps[step]);
|
|
53
|
+
if (flow.approvalMethod === "consent" && passkeySteps.length > 0) {
|
|
54
|
+
ctx.addIssue({
|
|
55
|
+
code: z.ZodIssueCode.custom,
|
|
56
|
+
path: ["steps"],
|
|
57
|
+
message: `consent approval has no passkey, so no ${passkeySteps.join(" or ")} step`,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (flow.approvalMethod === "passkey" && !flow.steps.passkey) {
|
|
61
|
+
ctx.addIssue({
|
|
62
|
+
code: z.ZodIssueCode.custom,
|
|
63
|
+
path: ["steps"],
|
|
64
|
+
message: "passkey approval needs a passkey step",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
/** A saved flow, checked; throws with every problem found. Defaults filled in. */
|
|
69
|
+
export function parseConsentFlow(input) {
|
|
70
|
+
return flowSchema.parse(input);
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/flow/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,qBAAqB,EACrB,mBAAmB,EACnB,UAAU,EACV,cAAc,GAGf,MAAM,YAAY,CAAC;AAEpB,MAAM,SAAS,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAEnE,yDAAyD;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC;KAChC,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CAAC,OAAO;SACpF,CAAC,CAAC;IACL,CAAC;IACD,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QAC7D,GAAG,CAAC,QAAQ,CAAC;YACX,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM;YAC3B,IAAI,EAAE,CAAC,OAAO,CAAC;YACf,OAAO,EAAE,uCAAuC;SACjD,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,kFAAkF;AAClF,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,UAAU,CAAC,KAAK,CAAC,KAAK,CAA0B,CAAC;AAC1D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline.d.ts","sourceRoot":"","sources":["../../src/mcp-app/inline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,sEAAsE;AACtE,eAAO,MAAM,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"inline.d.ts","sourceRoot":"","sources":["../../src/mcp-app/inline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,sEAAsE;AACtE,eAAO,MAAM,oBAAoB,EAAE,MAAsok6B,CAAC;AAE1qk6B,4CAA4C;AAC5C,eAAO,MAAM,yBAAyB,EAAE,MAAe,CAAC"}
|