@substrat-run/contracts 0.217.0 → 0.219.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.
Files changed (102) hide show
  1. package/dist/broker-dead-letters.d.ts +5 -1
  2. package/dist/broker-dead-letters.d.ts.map +1 -1
  3. package/dist/broker-dead-letters.js +20 -5
  4. package/dist/broker-dead-letters.js.map +1 -1
  5. package/dist/connections.d.ts +40 -0
  6. package/dist/connections.d.ts.map +1 -1
  7. package/dist/connections.js +33 -0
  8. package/dist/connections.js.map +1 -1
  9. package/dist/control-plane.d.ts +84 -1
  10. package/dist/control-plane.d.ts.map +1 -1
  11. package/dist/control-plane.js +75 -2
  12. package/dist/control-plane.js.map +1 -1
  13. package/dist/credential-binding.d.ts +63 -0
  14. package/dist/credential-binding.d.ts.map +1 -0
  15. package/dist/credential-binding.js +94 -0
  16. package/dist/credential-binding.js.map +1 -0
  17. package/dist/deploy.d.ts +205 -20
  18. package/dist/deploy.d.ts.map +1 -1
  19. package/dist/deploy.js +195 -27
  20. package/dist/deploy.js.map +1 -1
  21. package/dist/dev-node.d.ts +13 -0
  22. package/dist/dev-node.d.ts.map +1 -0
  23. package/dist/dev-node.js +13 -0
  24. package/dist/dev-node.js.map +1 -0
  25. package/dist/email-intent.d.ts +67 -2
  26. package/dist/email-intent.d.ts.map +1 -1
  27. package/dist/email-intent.js +12 -7
  28. package/dist/email-intent.js.map +1 -1
  29. package/dist/environments.d.ts +126 -3
  30. package/dist/environments.d.ts.map +1 -1
  31. package/dist/environments.js +85 -3
  32. package/dist/environments.js.map +1 -1
  33. package/dist/errors.d.ts +12 -0
  34. package/dist/errors.d.ts.map +1 -1
  35. package/dist/errors.js +15 -1
  36. package/dist/errors.js.map +1 -1
  37. package/dist/index.d.ts +6 -0
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +6 -0
  40. package/dist/index.js.map +1 -1
  41. package/dist/kernel-events.d.ts.map +1 -1
  42. package/dist/kernel-events.js +7 -0
  43. package/dist/kernel-events.js.map +1 -1
  44. package/dist/manifest.d.ts +17 -0
  45. package/dist/manifest.d.ts.map +1 -1
  46. package/dist/manifest.js +21 -0
  47. package/dist/manifest.js.map +1 -1
  48. package/dist/operations.d.ts +16 -0
  49. package/dist/operations.d.ts.map +1 -1
  50. package/dist/operations.js +53 -12
  51. package/dist/operations.js.map +1 -1
  52. package/dist/outbound-host.d.ts +21 -0
  53. package/dist/outbound-host.d.ts.map +1 -0
  54. package/dist/outbound-host.js +28 -0
  55. package/dist/outbound-host.js.map +1 -0
  56. package/dist/outbox-mail.d.ts +35 -0
  57. package/dist/outbox-mail.d.ts.map +1 -0
  58. package/dist/outbox-mail.js +89 -0
  59. package/dist/outbox-mail.js.map +1 -0
  60. package/dist/people.d.ts +79 -0
  61. package/dist/people.d.ts.map +1 -1
  62. package/dist/people.js +90 -0
  63. package/dist/people.js.map +1 -1
  64. package/dist/platform-request.d.ts +18 -0
  65. package/dist/platform-request.d.ts.map +1 -1
  66. package/dist/platform-request.js +27 -0
  67. package/dist/platform-request.js.map +1 -1
  68. package/dist/registry-diff.d.ts +8 -0
  69. package/dist/registry-diff.d.ts.map +1 -1
  70. package/dist/registry-diff.js +24 -4
  71. package/dist/registry-diff.js.map +1 -1
  72. package/dist/registry.d.ts +24 -0
  73. package/dist/registry.d.ts.map +1 -1
  74. package/dist/relay-intents.d.ts +193 -0
  75. package/dist/relay-intents.d.ts.map +1 -0
  76. package/dist/relay-intents.js +125 -0
  77. package/dist/relay-intents.js.map +1 -0
  78. package/dist/scope-store-proof.d.ts +84 -0
  79. package/dist/scope-store-proof.d.ts.map +1 -0
  80. package/dist/scope-store-proof.js +103 -0
  81. package/dist/scope-store-proof.js.map +1 -0
  82. package/dist/scope-store-transport.d.ts +1 -0
  83. package/dist/scope-store-transport.d.ts.map +1 -1
  84. package/dist/scope-store-transport.js +8 -0
  85. package/dist/scope-store-transport.js.map +1 -1
  86. package/dist/scope-types.d.ts +56 -5
  87. package/dist/scope-types.d.ts.map +1 -1
  88. package/dist/scope-types.js +90 -3
  89. package/dist/scope-types.js.map +1 -1
  90. package/dist/tenancy.d.ts +1 -0
  91. package/dist/tenancy.d.ts.map +1 -1
  92. package/dist/tenancy.js +6 -0
  93. package/dist/tenancy.js.map +1 -1
  94. package/dist/trace.d.ts +211 -0
  95. package/dist/trace.d.ts.map +1 -0
  96. package/dist/trace.js +128 -0
  97. package/dist/trace.js.map +1 -0
  98. package/dist/vertical-connector.d.ts +42 -1
  99. package/dist/vertical-connector.d.ts.map +1 -1
  100. package/dist/vertical-connector.js +8 -1
  101. package/dist/vertical-connector.js.map +1 -1
  102. package/package.json +1 -1
@@ -0,0 +1,193 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * The relay WRITES a vertical used to make by calling up, asked for by writing instead (K-58 step 6,
4
+ * #3374 decision (d)(1)).
5
+ *
6
+ * A vertical's worker used to POST each of these to the control plane with the shared platform
7
+ * credential, naming its own (tenant, scope) and the principal whose check authorized the act. Each
8
+ * is now an intent the vertical's operation writes in its own transaction, after its own permission
9
+ * check. The platform's drain reads it out of the scope that wrote it, runs the same relay core the
10
+ * route runs, and writes what became of it back into the scope as an outcome event.
11
+ *
12
+ * So none of these payloads names a tenant, a scope or a principal. Which scope asked is the scope the
13
+ * drain read the row from, and who asked is the kernel's stamp on the row (`requestedBy`). Neither is
14
+ * something a payload can say, and neither is taken on a caller's word, as the relays took them.
15
+ *
16
+ * **Nothing here carries a credential, and no answer does either.** The relay writes that cannot meet
17
+ * that are not here: storing a pasted credential (`/internal/connections/upsert`), and minting a mailed
18
+ * connect link, whose URL is a bearer capability for up to thirty days. The mail-in address is a
19
+ * capability too, so a request or a rotation reports that it happened and never the address.
20
+ */
21
+ /** Bind the scope's own connection to that scope, through the `on-request` landing its running version declares. */
22
+ export declare const CONNECTION_BIND_KIND = "connection-bind";
23
+ /** Drop that binding and take its landing key back on the scope. What the scope landed stays. */
24
+ export declare const CONNECTION_UNBIND_KIND = "connection-unbind";
25
+ /** Revoke a connect link this scope minted, by the id its mint answered. */
26
+ export declare const CONNECT_LINK_REVOKE_KIND = "connect-link-revoke";
27
+ /** Request, rotate or give up the scope's inbound mail address. */
28
+ export declare const MAIL_IN_ADDRESS_KIND = "mail-in-address";
29
+ export declare const RELAY_WRITE_KINDS: readonly ["connection-bind", "connection-unbind", "connect-link-revoke", "mail-in-address"];
30
+ /**
31
+ * `connection-bind`: the bind relay's body without the caller's identity. The operation and key come
32
+ * from the landing the scope's running version declares, never from here; the connector's bind
33
+ * validates and normalises `options`. A rebind keeps the options it does not name.
34
+ */
35
+ export declare const connectionBindIntent: z.ZodObject<{
36
+ connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
37
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
38
+ }, z.core.$strict>;
39
+ export type ConnectionBindIntent = z.infer<typeof connectionBindIntent>;
40
+ /** `connection-unbind`: idempotent; unbinding a connection the scope does not hold bound changes nothing. */
41
+ export declare const connectionUnbindIntent: z.ZodObject<{
42
+ connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
43
+ }, z.core.$strict>;
44
+ export type ConnectionUnbindIntent = z.infer<typeof connectionUnbindIntent>;
45
+ /**
46
+ * `connect-link-revoke`: idempotent. A revoked link answers revoked again; a used one answers used,
47
+ * since a spent link has nothing left to revoke. A link of another scope is refused exactly as an
48
+ * unknown one.
49
+ */
50
+ export declare const connectLinkRevokeIntent: z.ZodObject<{
51
+ linkId: z.core.$ZodBranded<z.ZodString, "ConnectLinkId", "out">;
52
+ }, z.core.$strict>;
53
+ export type ConnectLinkRevokeIntent = z.infer<typeof connectLinkRevokeIntent>;
54
+ /**
55
+ * `mail-in-address`: `request` mints the scope's address when it has none, `rotate` replaces it
56
+ * (carrying the allowlist and any mail in flight), `revoke` gives it up. `allowlist` on `request` or
57
+ * `rotate` replaces the list; absent keeps it. Which operation and key the address lands through is
58
+ * read from the manifest the scope runs, never from here.
59
+ *
60
+ * The address itself is never in the outcome: it is a capability that delivers into the scope. A
61
+ * screen reads it when it shows it, through the proven-caller read (`action: 'get'`).
62
+ */
63
+ export declare const mailInAddressIntent: z.ZodObject<{
64
+ action: z.ZodEnum<{
65
+ request: "request";
66
+ revoke: "revoke";
67
+ rotate: "rotate";
68
+ }>;
69
+ allowlist: z.ZodOptional<z.ZodArray<z.ZodString>>;
70
+ }, z.core.$strict>;
71
+ export type MailInAddressIntent = z.infer<typeof mailInAddressIntent>;
72
+ /** A binding was made or changed (`bind`), or dropped (`unbind`). */
73
+ export declare const CONNECTION_BINDING_APPLIED = "connection.binding-applied";
74
+ /** The platform refused the bind or unbind, or gave up on it. Not retried. */
75
+ export declare const CONNECTION_BINDING_REFUSED = "connection.binding-refused";
76
+ /** The link can no longer be opened: revoked now, or already revoked or used. */
77
+ export declare const CONNECT_LINK_REVOKED = "connect-link.revoked";
78
+ /** The platform refused the revoke (an unknown link, say), or gave up on it. */
79
+ export declare const CONNECT_LINK_REVOKE_REFUSED = "connect-link.revoke-refused";
80
+ /** The scope's address was requested, rotated or given up. Never the address. */
81
+ export declare const MAIL_IN_ADDRESS_APPLIED = "mail-in.address-applied";
82
+ /** The platform refused the act, or gave up on it. */
83
+ export declare const MAIL_IN_ADDRESS_REFUSED = "mail-in.address-refused";
84
+ export declare const connectionBindingOutcomePayload: z.ZodObject<{
85
+ request: z.core.$ZodBranded<z.ZodString, "PlatformRequestId", "out">;
86
+ attempts: z.ZodNumber;
87
+ code: z.ZodNullable<z.ZodString>;
88
+ status: z.ZodNullable<z.ZodNumber>;
89
+ gaveUp: z.ZodBoolean;
90
+ connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
91
+ action: z.ZodEnum<{
92
+ bind: "bind";
93
+ unbind: "unbind";
94
+ }>;
95
+ }, z.core.$strict>;
96
+ export type ConnectionBindingOutcomePayload = z.infer<typeof connectionBindingOutcomePayload>;
97
+ export declare const connectLinkRevokeOutcomePayload: z.ZodObject<{
98
+ request: z.core.$ZodBranded<z.ZodString, "PlatformRequestId", "out">;
99
+ attempts: z.ZodNumber;
100
+ code: z.ZodNullable<z.ZodString>;
101
+ status: z.ZodNullable<z.ZodNumber>;
102
+ gaveUp: z.ZodBoolean;
103
+ linkId: z.core.$ZodBranded<z.ZodString, "ConnectLinkId", "out">;
104
+ linkStatus: z.ZodNullable<z.ZodEnum<{
105
+ outstanding: "outstanding";
106
+ revoked: "revoked";
107
+ used: "used";
108
+ }>>;
109
+ }, z.core.$strict>;
110
+ export type ConnectLinkRevokeOutcomePayload = z.infer<typeof connectLinkRevokeOutcomePayload>;
111
+ export declare const mailInAddressOutcomePayload: z.ZodObject<{
112
+ request: z.core.$ZodBranded<z.ZodString, "PlatformRequestId", "out">;
113
+ attempts: z.ZodNumber;
114
+ code: z.ZodNullable<z.ZodString>;
115
+ status: z.ZodNullable<z.ZodNumber>;
116
+ gaveUp: z.ZodBoolean;
117
+ action: z.ZodEnum<{
118
+ request: "request";
119
+ revoke: "revoke";
120
+ rotate: "rotate";
121
+ }>;
122
+ active: z.ZodNullable<z.ZodBoolean>;
123
+ }, z.core.$strict>;
124
+ export type MailInAddressOutcomePayload = z.infer<typeof mailInAddressOutcomePayload>;
125
+ /** The relay-write outcome events a settle may write (one arm of `platformOutcomeEvent`). */
126
+ export declare const relayWriteOutcomeEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
127
+ type: z.ZodEnum<{
128
+ "connection.binding-applied": "connection.binding-applied";
129
+ "connection.binding-refused": "connection.binding-refused";
130
+ }>;
131
+ entity: z.ZodObject<{
132
+ entityType: z.ZodString;
133
+ entityId: z.ZodString;
134
+ }, z.core.$strip>;
135
+ payload: z.ZodObject<{
136
+ request: z.core.$ZodBranded<z.ZodString, "PlatformRequestId", "out">;
137
+ attempts: z.ZodNumber;
138
+ code: z.ZodNullable<z.ZodString>;
139
+ status: z.ZodNullable<z.ZodNumber>;
140
+ gaveUp: z.ZodBoolean;
141
+ connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
142
+ action: z.ZodEnum<{
143
+ bind: "bind";
144
+ unbind: "unbind";
145
+ }>;
146
+ }, z.core.$strict>;
147
+ }, z.core.$strict>, z.ZodObject<{
148
+ type: z.ZodEnum<{
149
+ "connect-link.revoke-refused": "connect-link.revoke-refused";
150
+ "connect-link.revoked": "connect-link.revoked";
151
+ }>;
152
+ entity: z.ZodObject<{
153
+ entityType: z.ZodString;
154
+ entityId: z.ZodString;
155
+ }, z.core.$strip>;
156
+ payload: z.ZodObject<{
157
+ request: z.core.$ZodBranded<z.ZodString, "PlatformRequestId", "out">;
158
+ attempts: z.ZodNumber;
159
+ code: z.ZodNullable<z.ZodString>;
160
+ status: z.ZodNullable<z.ZodNumber>;
161
+ gaveUp: z.ZodBoolean;
162
+ linkId: z.core.$ZodBranded<z.ZodString, "ConnectLinkId", "out">;
163
+ linkStatus: z.ZodNullable<z.ZodEnum<{
164
+ outstanding: "outstanding";
165
+ revoked: "revoked";
166
+ used: "used";
167
+ }>>;
168
+ }, z.core.$strict>;
169
+ }, z.core.$strict>, z.ZodObject<{
170
+ type: z.ZodEnum<{
171
+ "mail-in.address-applied": "mail-in.address-applied";
172
+ "mail-in.address-refused": "mail-in.address-refused";
173
+ }>;
174
+ entity: z.ZodObject<{
175
+ entityType: z.ZodString;
176
+ entityId: z.ZodString;
177
+ }, z.core.$strip>;
178
+ payload: z.ZodObject<{
179
+ request: z.core.$ZodBranded<z.ZodString, "PlatformRequestId", "out">;
180
+ attempts: z.ZodNumber;
181
+ code: z.ZodNullable<z.ZodString>;
182
+ status: z.ZodNullable<z.ZodNumber>;
183
+ gaveUp: z.ZodBoolean;
184
+ action: z.ZodEnum<{
185
+ request: "request";
186
+ revoke: "revoke";
187
+ rotate: "rotate";
188
+ }>;
189
+ active: z.ZodNullable<z.ZodBoolean>;
190
+ }, z.core.$strict>;
191
+ }, z.core.$strict>], "type">;
192
+ export type RelayWriteOutcomeEvent = z.infer<typeof relayWriteOutcomeEvent>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AgF;AAChF,eAAO,MAAM,2BAA2B,gCAAgC,CAAC;AACzE,iFAAiF;AACjF,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AACjE,sDAAsD;AACtD,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AAmBjE,eAAO,MAAM,+BAA+B;;;;;;;;;;;kBAEjC,CAAC;AACZ,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAE9F,eAAO,MAAM,+BAA+B;;;;;;;;;;;;kBAOjC,CAAC;AACZ,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAE9F,eAAO,MAAM,2BAA2B;;;;;;;;;;;;kBAO7B,CAAC;AACZ,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEtF,6FAA6F;AAC7F,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAIjC,CAAC;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
@@ -0,0 +1,125 @@
1
+ import { z } from 'zod';
2
+ import { connectLinkId, connectLinkStatus, connectionId } from './connections.js';
3
+ import { entityRef } from './events.js';
4
+ import { platformRequestId } from './ids.js';
5
+ import { MAIL_IN_MAX_ALLOWLIST, mailInAllowEntry } from './mail-in.js';
6
+ /**
7
+ * The relay WRITES a vertical used to make by calling up, asked for by writing instead (K-58 step 6,
8
+ * #3374 decision (d)(1)).
9
+ *
10
+ * A vertical's worker used to POST each of these to the control plane with the shared platform
11
+ * credential, naming its own (tenant, scope) and the principal whose check authorized the act. Each
12
+ * is now an intent the vertical's operation writes in its own transaction, after its own permission
13
+ * check. The platform's drain reads it out of the scope that wrote it, runs the same relay core the
14
+ * route runs, and writes what became of it back into the scope as an outcome event.
15
+ *
16
+ * So none of these payloads names a tenant, a scope or a principal. Which scope asked is the scope the
17
+ * drain read the row from, and who asked is the kernel's stamp on the row (`requestedBy`). Neither is
18
+ * something a payload can say, and neither is taken on a caller's word, as the relays took them.
19
+ *
20
+ * **Nothing here carries a credential, and no answer does either.** The relay writes that cannot meet
21
+ * that are not here: storing a pasted credential (`/internal/connections/upsert`), and minting a mailed
22
+ * connect link, whose URL is a bearer capability for up to thirty days. The mail-in address is a
23
+ * capability too, so a request or a rotation reports that it happened and never the address.
24
+ */
25
+ /** Bind the scope's own connection to that scope, through the `on-request` landing its running version declares. */
26
+ export const CONNECTION_BIND_KIND = 'connection-bind';
27
+ /** Drop that binding and take its landing key back on the scope. What the scope landed stays. */
28
+ export const CONNECTION_UNBIND_KIND = 'connection-unbind';
29
+ /** Revoke a connect link this scope minted, by the id its mint answered. */
30
+ export const CONNECT_LINK_REVOKE_KIND = 'connect-link-revoke';
31
+ /** Request, rotate or give up the scope's inbound mail address. */
32
+ export const MAIL_IN_ADDRESS_KIND = 'mail-in-address';
33
+ export const RELAY_WRITE_KINDS = [CONNECTION_BIND_KIND, CONNECTION_UNBIND_KIND, CONNECT_LINK_REVOKE_KIND, MAIL_IN_ADDRESS_KIND];
34
+ /**
35
+ * `connection-bind`: the bind relay's body without the caller's identity. The operation and key come
36
+ * from the landing the scope's running version declares, never from here; the connector's bind
37
+ * validates and normalises `options`. A rebind keeps the options it does not name.
38
+ */
39
+ export const connectionBindIntent = z
40
+ .object({
41
+ connectionId,
42
+ options: z.record(z.string().min(1), z.unknown()).optional(),
43
+ })
44
+ .strict();
45
+ /** `connection-unbind`: idempotent; unbinding a connection the scope does not hold bound changes nothing. */
46
+ export const connectionUnbindIntent = z.object({ connectionId }).strict();
47
+ /**
48
+ * `connect-link-revoke`: idempotent. A revoked link answers revoked again; a used one answers used,
49
+ * since a spent link has nothing left to revoke. A link of another scope is refused exactly as an
50
+ * unknown one.
51
+ */
52
+ export const connectLinkRevokeIntent = z.object({ linkId: connectLinkId }).strict();
53
+ /**
54
+ * `mail-in-address`: `request` mints the scope's address when it has none, `rotate` replaces it
55
+ * (carrying the allowlist and any mail in flight), `revoke` gives it up. `allowlist` on `request` or
56
+ * `rotate` replaces the list; absent keeps it. Which operation and key the address lands through is
57
+ * read from the manifest the scope runs, never from here.
58
+ *
59
+ * The address itself is never in the outcome: it is a capability that delivers into the scope. A
60
+ * screen reads it when it shows it, through the proven-caller read (`action: 'get'`).
61
+ */
62
+ export const mailInAddressIntent = z
63
+ .object({
64
+ action: z.enum(['request', 'rotate', 'revoke']),
65
+ allowlist: z.array(mailInAllowEntry).max(MAIL_IN_MAX_ALLOWLIST).optional(),
66
+ })
67
+ .strict()
68
+ .refine((m) => m.action !== 'revoke' || m.allowlist === undefined, {
69
+ message: 'a revoke gives the address up; it takes no allowlist',
70
+ path: ['allowlist'],
71
+ });
72
+ /** A binding was made or changed (`bind`), or dropped (`unbind`). */
73
+ export const CONNECTION_BINDING_APPLIED = 'connection.binding-applied';
74
+ /** The platform refused the bind or unbind, or gave up on it. Not retried. */
75
+ export const CONNECTION_BINDING_REFUSED = 'connection.binding-refused';
76
+ /** The link can no longer be opened: revoked now, or already revoked or used. */
77
+ export const CONNECT_LINK_REVOKED = 'connect-link.revoked';
78
+ /** The platform refused the revoke (an unknown link, say), or gave up on it. */
79
+ export const CONNECT_LINK_REVOKE_REFUSED = 'connect-link.revoke-refused';
80
+ /** The scope's address was requested, rotated or given up. Never the address. */
81
+ export const MAIL_IN_ADDRESS_APPLIED = 'mail-in.address-applied';
82
+ /** The platform refused the act, or gave up on it. */
83
+ export const MAIL_IN_ADDRESS_REFUSED = 'mail-in.address-refused';
84
+ /**
85
+ * What every relay-write outcome says beyond its own fields: which request (how a vertical joins the
86
+ * event to what it asked), the attempts made, and on a refusal the taxonomy code and the status the
87
+ * relay answered with. No platform prose: the full refusal stays on the intent row
88
+ * (`ctx.platformRequests`), and a connector's refusal can quote its provider.
89
+ */
90
+ const outcomeCommon = {
91
+ request: platformRequestId,
92
+ attempts: z.number().int().positive(),
93
+ /** The taxonomy code of the refusal, when the relay named one; always `null` on an applied outcome. */
94
+ code: z.string().min(1).nullable(),
95
+ /** The status the relay refused with, when it gave one; always `null` on an applied outcome. */
96
+ status: z.number().int().nullable(),
97
+ /** The platform stopped retrying a transient failure, rather than being refused. */
98
+ gaveUp: z.boolean(),
99
+ };
100
+ export const connectionBindingOutcomePayload = z
101
+ .object({ ...outcomeCommon, connectionId, action: z.enum(['bind', 'unbind']) })
102
+ .strict();
103
+ export const connectLinkRevokeOutcomePayload = z
104
+ .object({
105
+ ...outcomeCommon,
106
+ linkId: connectLinkId,
107
+ /** The link's status after the revoke (`revoked`, or `used` for a link already spent); `null` on a refusal. */
108
+ linkStatus: connectLinkStatus.nullable(),
109
+ })
110
+ .strict();
111
+ export const mailInAddressOutcomePayload = z
112
+ .object({
113
+ ...outcomeCommon,
114
+ action: z.enum(['request', 'rotate', 'revoke']),
115
+ /** Whether the scope holds an address after the act. Never which. */
116
+ active: z.boolean().nullable(),
117
+ })
118
+ .strict();
119
+ /** The relay-write outcome events a settle may write (one arm of `platformOutcomeEvent`). */
120
+ export const relayWriteOutcomeEvent = z.discriminatedUnion('type', [
121
+ z.object({ type: z.enum([CONNECTION_BINDING_APPLIED, CONNECTION_BINDING_REFUSED]), entity: entityRef, payload: connectionBindingOutcomePayload }).strict(),
122
+ z.object({ type: z.enum([CONNECT_LINK_REVOKED, CONNECT_LINK_REVOKE_REFUSED]), entity: entityRef, payload: connectLinkRevokeOutcomePayload }).strict(),
123
+ z.object({ type: z.enum([MAIL_IN_ADDRESS_APPLIED, MAIL_IN_ADDRESS_REFUSED]), entity: entityRef, payload: mailInAddressOutcomePayload }).strict(),
124
+ ]);
125
+ //# sourceMappingURL=relay-intents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-intents.js","sourceRoot":"","sources":["../src/relay-intents.ts"],"names":[],"mappings":"AAAA,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,EAAE,SAAS,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC,CAAC,MAAM,EAAE;IACrJ,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,uBAAuB,EAAE,uBAAuB,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAC,CAAC,MAAM,EAAE;CACjJ,CAAC,CAAC"}
@@ -0,0 +1,84 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Store calls under K-64 (#2996): a permission key per store operation, and a proof an operation
4
+ * minted after checking it.
5
+ *
6
+ * A module operation does not call its store inside its transaction. It calls
7
+ * `ctx.storeProof(binding, operation)`, which checks the key the vertical declared for that store
8
+ * operation and records a proof in the scope's own spine, in the operation's transaction. Host code
9
+ * then makes the store call with the proof, between two transactions, and a second operation records
10
+ * the result. The store's door redeems the proof before it calls the store, and refuses a call
11
+ * without one.
12
+ *
13
+ * This file is the declaration, its rules and the proof's shape. The mint and the redemption are the
14
+ * kernel's (`store-proof.ts`), written once for both adapters.
15
+ */
16
+ /** What a proof's secret starts with, so a secret scanner can flag a leaked one. */
17
+ export declare const STORE_PROOF_PREFIX = "sbsp_";
18
+ /** The prefix, then 32 random bytes as unpadded base64url. */
19
+ export declare const STORE_PROOF_SHAPE: RegExp;
20
+ /** Could `proof` be one the kernel minted? Says nothing about whether it names a live proof. */
21
+ export declare const isStoreProofShape: (proof: unknown) => proof is string;
22
+ /** A proof's secret on the wire: its shape, and nothing about whether it is live. */
23
+ export declare const storeProofSecret: z.ZodString;
24
+ /**
25
+ * How long a proof is good for. It covers one hop from host code to the store, made right after the
26
+ * operation that minted it commits, so it is short: a proof that leaks is worth a minute at most.
27
+ */
28
+ export declare const STORE_PROOF_TTL_SECONDS = 60;
29
+ /** The `reason` every refused redemption carries, whichever check refused it. */
30
+ export declare const STORE_PROOF_REFUSED = "store_proof_refused";
31
+ /**
32
+ * What `ctx.storeProof` returns. `proof` is the secret; the rest says what it is good for, so host
33
+ * code can see it without asking. The secret is stored nowhere: the scope keeps its SHA-256.
34
+ */
35
+ export interface StoreProof {
36
+ readonly proof: string;
37
+ readonly binding: string;
38
+ readonly operation: string;
39
+ /** ISO 8601. After it, the store's door refuses the proof. */
40
+ readonly expiresAt: string;
41
+ }
42
+ /**
43
+ * One scope store's permission keys, as a vertical declares them on its permission surface
44
+ * (`definePermissions({ stores })`), beside the scope types that name the same bindings.
45
+ * `operations` maps each store operation the vertical calls to the key an operation checks before it
46
+ * mints a proof for it. A store operation with no key here cannot be called: no proof can name it.
47
+ */
48
+ export interface StoreOperationKeys {
49
+ /** The binding, as `runtimeNeeds.scopeStores[].binding` declares it. */
50
+ readonly binding: string;
51
+ /** Store operation → the permission key that proves a caller may make it. */
52
+ readonly operations: Readonly<Record<string, string>>;
53
+ }
54
+ /** What {@link storeOperationKeyOffences} reads: the modules' keys and the declared store keys. */
55
+ export interface StoreOperationKeySurface {
56
+ readonly modules: readonly {
57
+ manifest: {
58
+ permissions?: readonly {
59
+ key: string;
60
+ }[];
61
+ };
62
+ }[];
63
+ readonly stores?: readonly StoreOperationKeys[];
64
+ }
65
+ /**
66
+ * Why a declaration of store keys does not hold together, one line each, or none. A binding named
67
+ * twice, a binding or an operation name the store grammar refuses, a binding with no operation, and a
68
+ * key no module declares are each refused: a key nothing declares is a permission nothing can grant,
69
+ * so the store operation would compile and never be callable.
70
+ */
71
+ export declare function storeOperationKeyOffences(surface: StoreOperationKeySurface): string[];
72
+ /** The one message every reader throws for the offences above. */
73
+ export declare function storeOperationKeyMessage(offences: readonly string[]): string;
74
+ /** The key a store operation is called under, or `undefined` when the vertical declares none for it. */
75
+ export declare function storeOperationKeyOf(stores: readonly StoreOperationKeys[] | undefined, binding: string, operation: string): string | undefined;
76
+ /**
77
+ * A declared scope store (`runtimeNeeds.scopeStores`) with no keys on the permission surface, or keys
78
+ * for a binding the vertical does not declare. What `substrat push` refuses before it uploads: a store
79
+ * with no keyed operation can never be called, and keys for an undeclared binding open nothing.
80
+ */
81
+ export declare function unkeyedScopeStoreOffences(scopeStores: readonly {
82
+ binding: string;
83
+ }[], stores: readonly StoreOperationKeys[] | undefined): string[];
84
+ //# sourceMappingURL=scope-store-proof.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-store-proof.d.ts","sourceRoot":"","sources":["../src/scope-store-proof.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;;GAaG;AAEH,oFAAoF;AACpF,eAAO,MAAM,kBAAkB,UAAU,CAAC;AAE1C,8DAA8D;AAC9D,eAAO,MAAM,iBAAiB,QAA6B,CAAC;AAE5D,gGAAgG;AAChG,eAAO,MAAM,iBAAiB,UAAW,OAAO,KAAG,KAAK,IAAI,MACA,CAAC;AAE7D,qFAAqF;AACrF,eAAO,MAAM,gBAAgB,aAAwE,CAAC;AAEtG;;;GAGG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,iFAAiF;AACjF,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,8DAA8D;IAC9D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAKD;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACvD;AAED,mGAAmG;AACnG,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,OAAO,EAAE,SAAS;QAAE,QAAQ,EAAE;YAAE,WAAW,CAAC,EAAE,SAAS;gBAAE,GAAG,EAAE,MAAM,CAAA;aAAE,EAAE,CAAA;SAAE,CAAA;KAAE,EAAE,CAAC;IACxF,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACjD;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,EAAE,CA0BrF;AAED,kEAAkE;AAClE,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAE5E;AAED,wGAAwG;AACxG,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,kBAAkB,EAAE,GAAG,SAAS,EACjD,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,SAAS,CAIpB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,SAAS;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,EAC3C,MAAM,EAAE,SAAS,kBAAkB,EAAE,GAAG,SAAS,GAChD,MAAM,EAAE,CAiBV"}
@@ -0,0 +1,103 @@
1
+ import { z } from 'zod';
2
+ import { storeCatalogOperation } from './deploy.js';
3
+ /**
4
+ * Store calls under K-64 (#2996): a permission key per store operation, and a proof an operation
5
+ * minted after checking it.
6
+ *
7
+ * A module operation does not call its store inside its transaction. It calls
8
+ * `ctx.storeProof(binding, operation)`, which checks the key the vertical declared for that store
9
+ * operation and records a proof in the scope's own spine, in the operation's transaction. Host code
10
+ * then makes the store call with the proof, between two transactions, and a second operation records
11
+ * the result. The store's door redeems the proof before it calls the store, and refuses a call
12
+ * without one.
13
+ *
14
+ * This file is the declaration, its rules and the proof's shape. The mint and the redemption are the
15
+ * kernel's (`store-proof.ts`), written once for both adapters.
16
+ */
17
+ /** What a proof's secret starts with, so a secret scanner can flag a leaked one. */
18
+ export const STORE_PROOF_PREFIX = 'sbsp_';
19
+ /** The prefix, then 32 random bytes as unpadded base64url. */
20
+ export const STORE_PROOF_SHAPE = /^sbsp_[A-Za-z0-9_-]{43}$/;
21
+ /** Could `proof` be one the kernel minted? Says nothing about whether it names a live proof. */
22
+ export const isStoreProofShape = (proof) => typeof proof === 'string' && STORE_PROOF_SHAPE.test(proof);
23
+ /** A proof's secret on the wire: its shape, and nothing about whether it is live. */
24
+ export const storeProofSecret = z.string().regex(STORE_PROOF_SHAPE, { message: 'not a store proof' });
25
+ /**
26
+ * How long a proof is good for. It covers one hop from host code to the store, made right after the
27
+ * operation that minted it commits, so it is short: a proof that leaks is worth a minute at most.
28
+ */
29
+ export const STORE_PROOF_TTL_SECONDS = 60;
30
+ /** The `reason` every refused redemption carries, whichever check refused it. */
31
+ export const STORE_PROOF_REFUSED = 'store_proof_refused';
32
+ /** A scope-store binding, as `runtimeNeeds.scopeStores[].binding` spells it. */
33
+ const STORE_BINDING = /^[A-Z][A-Z0-9_]*$/;
34
+ /**
35
+ * Why a declaration of store keys does not hold together, one line each, or none. A binding named
36
+ * twice, a binding or an operation name the store grammar refuses, a binding with no operation, and a
37
+ * key no module declares are each refused: a key nothing declares is a permission nothing can grant,
38
+ * so the store operation would compile and never be callable.
39
+ */
40
+ export function storeOperationKeyOffences(surface) {
41
+ const offences = [];
42
+ const declared = new Set();
43
+ for (const m of surface.modules)
44
+ for (const p of m.manifest.permissions ?? [])
45
+ declared.add(p.key);
46
+ const seen = new Set();
47
+ for (const store of surface.stores ?? []) {
48
+ if (!STORE_BINDING.test(store.binding)) {
49
+ offences.push(`store binding '${store.binding}' is not a binding name (SCREAMING_SNAKE)`);
50
+ continue;
51
+ }
52
+ if (seen.has(store.binding))
53
+ offences.push(`store binding '${store.binding}' is declared twice`);
54
+ seen.add(store.binding);
55
+ const operations = Object.entries(store.operations ?? {});
56
+ if (operations.length === 0) {
57
+ offences.push(`store binding '${store.binding}' declares no operation, so nothing can call it`);
58
+ }
59
+ for (const [operation, key] of operations) {
60
+ if (!storeCatalogOperation.safeParse(operation).success) {
61
+ offences.push(`store '${store.binding}': '${operation}' is not a store operation a vertical may call`);
62
+ }
63
+ if (typeof key !== 'string' || !declared.has(key)) {
64
+ offences.push(`store '${store.binding}' operation '${operation}': key '${String(key)}' is declared by no module`);
65
+ }
66
+ }
67
+ }
68
+ return offences;
69
+ }
70
+ /** The one message every reader throws for the offences above. */
71
+ export function storeOperationKeyMessage(offences) {
72
+ return `the store keys (definePermissions \`stores\`, K-64) do not hold together: ${offences.join('; ')}.`;
73
+ }
74
+ /** The key a store operation is called under, or `undefined` when the vertical declares none for it. */
75
+ export function storeOperationKeyOf(stores, binding, operation) {
76
+ const store = stores?.find((s) => s.binding === binding);
77
+ if (!store || !Object.prototype.hasOwnProperty.call(store.operations, operation))
78
+ return undefined;
79
+ return store.operations[operation];
80
+ }
81
+ /**
82
+ * A declared scope store (`runtimeNeeds.scopeStores`) with no keys on the permission surface, or keys
83
+ * for a binding the vertical does not declare. What `substrat push` refuses before it uploads: a store
84
+ * with no keyed operation can never be called, and keys for an undeclared binding open nothing.
85
+ */
86
+ export function unkeyedScopeStoreOffences(scopeStores, stores) {
87
+ const offences = [];
88
+ const keyed = new Set((stores ?? []).map((s) => s.binding));
89
+ const bound = new Set(scopeStores.map((s) => s.binding));
90
+ for (const binding of [...bound].sort()) {
91
+ if (!keyed.has(binding)) {
92
+ offences.push(`scope store '${binding}' has no permission key for any operation. Declare \`stores: [{ binding: '${binding}', ` +
93
+ `operations: { <operation>: '<key>' } }]\` on definePermissions: a store operation is called only with a ` +
94
+ `proof an operation minted after checking its key (K-64)`);
95
+ }
96
+ }
97
+ for (const binding of [...keyed].sort()) {
98
+ if (!bound.has(binding))
99
+ offences.push(`definePermissions \`stores\` names '${binding}', which runtimeNeeds.scopeStores does not declare`);
100
+ }
101
+ return offences;
102
+ }
103
+ //# sourceMappingURL=scope-store-proof.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-store-proof.js","sourceRoot":"","sources":["../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AE,EAAE,CAAC;QACxC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,uCAAuC,OAAO,oDAAoD,CAAC,CAAC;IAC7I,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -25,6 +25,7 @@ export declare const storeCallRequest: z.ZodObject<{
25
25
  binding: z.ZodString;
26
26
  operation: z.ZodString;
27
27
  input: z.ZodOptional<z.ZodUnknown>;
28
+ proof: z.ZodOptional<z.ZodString>;
28
29
  }, z.core.$strict>;
29
30
  export type StoreCallRequest = z.infer<typeof storeCallRequest>;
30
31
  /** Who the signature was made for. A reserved operation accepts only the platform's. */
@@ -1 +1 @@
1
- {"version":3,"file":"scope-store-transport.d.ts","sourceRoot":"","sources":["../src/scope-store-transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;;;GASG;AAEH,gEAAgE;AAChE,eAAO,MAAM,eAAe,4BAA4B,CAAC;AAEzD,8FAA8F;AAC9F,eAAO,MAAM,cAAc,2CAAsC,CAAC;AAElE,kFAAkF;AAClF,eAAO,MAAM,eAAe,aAAc,MAAM,KAAG,OACP,CAAC;AAE7C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;;;;kBAQlB,CAAC;AACZ,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,wFAAwF;AACxF,eAAO,MAAM,iBAAiB;;;EAAiC,CAAC;AAChE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAIlE,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAG3F;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIxG"}
1
+ {"version":3,"file":"scope-store-transport.d.ts","sourceRoot":"","sources":["../src/scope-store-transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB;;;;;;;;;GASG;AAEH,gEAAgE;AAChE,eAAO,MAAM,eAAe,4BAA4B,CAAC;AAEzD,8FAA8F;AAC9F,eAAO,MAAM,cAAc,2CAAsC,CAAC;AAElE,kFAAkF;AAClF,eAAO,MAAM,eAAe,aAAc,MAAM,KAAG,OACP,CAAC;AAE7C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;;;;;kBAelB,CAAC;AACZ,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,wFAAwF;AACxF,eAAO,MAAM,iBAAiB;;;EAAiC,CAAC;AAChE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAIlE,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAG3F;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIxG"}
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { scopeId } from './ids.js';
3
3
  import { RESERVED_STORE_OPERATIONS, STORE_FENCE_OPERATION, storeOperationName } from './deploy.js';
4
+ import { storeProofSecret } from './scope-store-proof.js';
4
5
  /**
5
6
  * The hosted transport for a scope-store call (#2207).
6
7
  *
@@ -29,6 +30,13 @@ export const storeCallRequest = z
29
30
  // The same fixed-label rule a log line and a driver's catalog hold (#2245).
30
31
  operation: storeOperationName,
31
32
  input: z.unknown().optional(),
33
+ /**
34
+ * #2996 (K-64): the proof an operation minted for this call. Optional in the schema so the
35
+ * router answers its absence with its own code (`substrat.proof_required`) rather than as a
36
+ * body that is not a store call; the router refuses a call without it. The host's door has
37
+ * already redeemed it against the scope's record when it gets here (see the router).
38
+ */
39
+ proof: storeProofSecret.optional(),
32
40
  })
33
41
  .strict();
34
42
  /** Who the signature was made for. A reserved operation accepts only the platform's. */
@@ -1 +1 @@
1
- {"version":3,"file":"scope-store-transport.js","sourceRoot":"","sources":["../src/scope-store-transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEnG;;;;;;;;;GASG;AAEH,gEAAgE;AAChE,MAAM,CAAC,MAAM,eAAe,GAAG,yBAAyB,CAAC;AAEzD,8FAA8F;AAC9F,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,eAAe,SAAS,CAAC;AAElE,kFAAkF;AAClF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAW,EAAE,CAC3D,QAAQ,CAAC,WAAW,EAAE,KAAK,eAAe,CAAC;AAE7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC;KAC9B,MAAM,CAAC;IACN,OAAO;IACP,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC;IAC9C,4EAA4E;IAC5E,SAAS,EAAE,kBAAkB;IAC7B,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC;KACD,MAAM,EAAE,CAAC;AAGZ,wFAAwF;AACxF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,UAAU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