@substrat-run/contracts 0.204.0 → 0.206.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.
@@ -24,8 +24,24 @@ import { scopeId, tenantId } from './ids.js';
24
24
  * just created, or its secret just rotated. The relay stores secrets hashed and cannot hand an
25
25
  * existing one back, so an ordinary re-delivery carries none and the issuer keeps the one it
26
26
  * holds. An issuer that holds none answers `SOCIAL_RELAY_SECRET_NEEDED` (409), and only then
27
- * does the platform rotate and deliver again. Rotating on every delivery instead would let two
28
- * overlapping reconciles deliver secrets out of order and leave the older one in place.
27
+ * does the platform rotate and deliver again.
28
+ *
29
+ * Every delivery also carries `generation`, the relay's count of the client's secrets (#3275): 1
30
+ * for the secret handed out at creation, one more for each rotation. The relay accepts only the
31
+ * newest, so the generation says which secret is live without anyone reading one back:
32
+ *
33
+ * - with a secret, it is that secret's generation, and an issuer holding a NEWER one refuses the
34
+ * delivery (`SOCIAL_RELAY_DELIVERY_STALE`) — a slow delivery from a run that rotated earlier
35
+ * can never overwrite the secret a later rotation delivered;
36
+ * - without one, it is the relay's current generation, and an issuer holding an OLDER one knows
37
+ * its secret is dead and says so (`SOCIAL_RELAY_SECRET_STALE`), which the platform answers
38
+ * with one rotation — the stuck install heals on its next reconcile.
39
+ *
40
+ * Rotation and its delivery are serialized per client at the relay itself: a rotation is a
41
+ * compare-and-set on the generation the caller saw, and it takes a short lease that refuses any
42
+ * other rotation of that client until the delivery is made (`packages/control-plane-api`,
43
+ * `reconcileSocialRelay`). So two reconciles can never both rotate, and the generation is the
44
+ * guard that holds even if that serialization is ever bypassed.
29
45
  */
30
46
  export const SOCIAL_RELAY_CONFIG_KEY = 'substrat:social-relay';
31
47
  /**
@@ -70,12 +86,34 @@ export const socialRelayProvider = z.object({
70
86
  endpoints: socialRelayEndpoints,
71
87
  });
72
88
  export const socialRelayProviders = z.object({ providers: z.array(socialRelayProvider).max(32) });
73
- /** What an issuer answers (409, as the `error`) when a delivery carries no secret and it holds none. */
89
+ /**
90
+ * What an issuer answers (409, as the `detail`) when a delivery carries no secret and it holds none
91
+ * it can vouch for: none for this client, or one held from before generations were delivered,
92
+ * which may or may not be the live one. A reconcile the install itself asked for never rotates on
93
+ * this answer when the install says it holds a client.
94
+ */
74
95
  export const SOCIAL_RELAY_SECRET_NEEDED = 'social_relay_secret_needed';
96
+ /**
97
+ * What an issuer answers (409) when a delivery carries no secret and the relay's generation is
98
+ * newer than the secret it holds: that secret was rotated out and cannot work. Rotating replaces
99
+ * nothing that signs anyone in, so every reconcile rotates on it, the install's own included.
100
+ */
101
+ export const SOCIAL_RELAY_SECRET_STALE = 'social_relay_secret_stale';
102
+ /**
103
+ * What an issuer answers (409) when a delivery carries a secret OLDER than the one it holds — a
104
+ * run that rotated, then delivered after a later rotation's secret had landed. Nothing is written.
105
+ */
106
+ export const SOCIAL_RELAY_DELIVERY_STALE = 'social_relay_delivery_stale';
75
107
  /** The delivered value of `substrat:social-relay`. */
76
108
  export const socialRelayDelivery = z.object({
77
109
  clientId: z.string().min(1).max(200),
78
110
  clientSecret: z.string().min(1).max(500).optional(),
111
+ /**
112
+ * The secret's generation when `clientSecret` is present, else the relay's current one (#3275).
113
+ * Optional only for a delivery from a control plane or relay older than generations, which the
114
+ * issuer handles as it always did.
115
+ */
116
+ generation: z.number().int().positive().optional(),
79
117
  providers: z.array(socialRelayProvider).max(32),
80
118
  });
81
119
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"social-relay.js","sourceRoot":"","sources":["../src/social-relay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,uBAAuB,CAAC;AAE/D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,sBAAsB,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,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE;IAChH,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE;CAC7E,CAAC,CAAC"}
@@ -0,0 +1,213 @@
1
+ /**
2
+ * Subject access (GDPR Art. 15, D-74, `docs/rfc/subject-access.md`): what one scope holds about one
3
+ * data subject, read through the same reach erasure writes through.
4
+ *
5
+ * This file is the read's page, the shape that crosses a Durable Object's RPC and a vertical's
6
+ * `/internal` hop. The package a controller downloads is assembled from pages by the control
7
+ * plane, which is also where masking and the audit happen.
8
+ */
9
+ import { z } from 'zod';
10
+ /**
11
+ * One event keyed to the subject, decoded as `readScopeHistory` decodes it, and whether an erasure
12
+ * already took its payload.
13
+ *
14
+ * Wider than erasure on purpose: every outbox row with the subject's id, `piiClass: 'none'`
15
+ * included, because access answers *whether* data about the person is processed at all. An
16
+ * erased event keeps its envelope, which is what the person is owed: the fact that something
17
+ * happened, without what was said.
18
+ */
19
+ export declare const subjectEvent: z.ZodObject<{
20
+ id: z.core.$ZodBranded<z.ZodString, "EventId", "out">;
21
+ type: z.ZodString;
22
+ occurredAt: z.core.$ZodBranded<z.ZodString, "Instant", "out">;
23
+ actor: z.ZodUnion<readonly [z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">, z.ZodObject<{
24
+ system: z.core.$ZodBranded<z.ZodString, "ModuleId", "out">;
25
+ }, z.core.$strip>, z.ZodObject<{
26
+ connection: z.ZodString;
27
+ }, z.core.$strip>, z.ZodObject<{
28
+ capability: z.core.$ZodBranded<z.ZodString, "CapabilityId", "out">;
29
+ }, z.core.$strip>, z.ZodObject<{
30
+ vertical: z.ZodString;
31
+ scope: z.core.$ZodBranded<z.ZodString, "ScopeId", "out">;
32
+ }, z.core.$strip>]>;
33
+ decodeError: z.ZodOptional<z.ZodString>;
34
+ payload: z.ZodUnknown;
35
+ authorization: z.ZodNullable<z.ZodArray<z.ZodObject<{
36
+ permission: z.core.$ZodBranded<z.ZodString, "PermissionKey", "out">;
37
+ grant: z.ZodOptional<z.ZodString>;
38
+ }, z.core.$strip>>>;
39
+ impersonation: z.ZodNullable<z.ZodObject<{
40
+ session: z.core.$ZodBranded<z.ZodString, "ImpersonationSessionId", "out">;
41
+ by: z.core.$ZodBranded<z.ZodString, "PlatformActorId", "out">;
42
+ }, z.core.$strip>>;
43
+ delegation: z.ZodOptional<z.ZodNullable<z.ZodObject<{
44
+ actor: z.ZodString;
45
+ }, z.core.$strip>>>;
46
+ piiClass: z.ZodEnum<{
47
+ direct: "direct";
48
+ none: "none";
49
+ pseudonymous: "pseudonymous";
50
+ }>;
51
+ subjectId: z.ZodNullable<z.core.$ZodBranded<z.ZodString, "DataSubjectId", "out">>;
52
+ operation: z.ZodNullable<z.ZodString>;
53
+ version: z.ZodNullable<z.ZodString>;
54
+ causedBy: z.ZodNullable<z.core.$ZodBranded<z.ZodString, "EventId", "out">>;
55
+ invocationId: z.ZodNullable<z.ZodString>;
56
+ entity: z.ZodObject<{
57
+ entityType: z.ZodString;
58
+ entityId: z.ZodString;
59
+ }, z.core.$strip>;
60
+ erased: z.ZodBoolean;
61
+ }, z.core.$strip>;
62
+ export type SubjectEvent = z.infer<typeof subjectEvent>;
63
+ /** One declared entity's rows that are the subject's: whole rows, matched by the predicate erasure uses. */
64
+ export declare const subjectRecords: z.ZodObject<{
65
+ module: z.ZodString;
66
+ entityType: z.ZodString;
67
+ mode: z.ZodEnum<{
68
+ blank: "blank";
69
+ delete: "delete";
70
+ }>;
71
+ subjects: z.ZodArray<z.ZodString>;
72
+ erasable: z.ZodArray<z.ZodString>;
73
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
74
+ }, z.core.$strip>;
75
+ export type SubjectRecords = z.infer<typeof subjectRecords>;
76
+ /**
77
+ * One page of `readSubject`. Each source is walked in turn, the events first and then each
78
+ * declared entity, until the page's budget is spent; `nextCursor` resumes where it stopped and is
79
+ * null once every source is exhausted. Opaque to the caller.
80
+ *
81
+ * `unreachedEntities` is the list a shred receipt names (an entity with erasable fields and no
82
+ * subject link). `hookEntities` are the entities erasure reaches only through a module's
83
+ * `onSubjectErased` hook, which access has no read-only twin for yet: unreached for access, and
84
+ * named so the package says so. Both are the same on every page.
85
+ */
86
+ export declare const subjectReadPage: z.ZodObject<{
87
+ events: z.ZodArray<z.ZodObject<{
88
+ id: z.core.$ZodBranded<z.ZodString, "EventId", "out">;
89
+ type: z.ZodString;
90
+ occurredAt: z.core.$ZodBranded<z.ZodString, "Instant", "out">;
91
+ actor: z.ZodUnion<readonly [z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">, z.ZodObject<{
92
+ system: z.core.$ZodBranded<z.ZodString, "ModuleId", "out">;
93
+ }, z.core.$strip>, z.ZodObject<{
94
+ connection: z.ZodString;
95
+ }, z.core.$strip>, z.ZodObject<{
96
+ capability: z.core.$ZodBranded<z.ZodString, "CapabilityId", "out">;
97
+ }, z.core.$strip>, z.ZodObject<{
98
+ vertical: z.ZodString;
99
+ scope: z.core.$ZodBranded<z.ZodString, "ScopeId", "out">;
100
+ }, z.core.$strip>]>;
101
+ decodeError: z.ZodOptional<z.ZodString>;
102
+ payload: z.ZodUnknown;
103
+ authorization: z.ZodNullable<z.ZodArray<z.ZodObject<{
104
+ permission: z.core.$ZodBranded<z.ZodString, "PermissionKey", "out">;
105
+ grant: z.ZodOptional<z.ZodString>;
106
+ }, z.core.$strip>>>;
107
+ impersonation: z.ZodNullable<z.ZodObject<{
108
+ session: z.core.$ZodBranded<z.ZodString, "ImpersonationSessionId", "out">;
109
+ by: z.core.$ZodBranded<z.ZodString, "PlatformActorId", "out">;
110
+ }, z.core.$strip>>;
111
+ delegation: z.ZodOptional<z.ZodNullable<z.ZodObject<{
112
+ actor: z.ZodString;
113
+ }, z.core.$strip>>>;
114
+ piiClass: z.ZodEnum<{
115
+ direct: "direct";
116
+ none: "none";
117
+ pseudonymous: "pseudonymous";
118
+ }>;
119
+ subjectId: z.ZodNullable<z.core.$ZodBranded<z.ZodString, "DataSubjectId", "out">>;
120
+ operation: z.ZodNullable<z.ZodString>;
121
+ version: z.ZodNullable<z.ZodString>;
122
+ causedBy: z.ZodNullable<z.core.$ZodBranded<z.ZodString, "EventId", "out">>;
123
+ invocationId: z.ZodNullable<z.ZodString>;
124
+ entity: z.ZodObject<{
125
+ entityType: z.ZodString;
126
+ entityId: z.ZodString;
127
+ }, z.core.$strip>;
128
+ erased: z.ZodBoolean;
129
+ }, z.core.$strip>>;
130
+ records: z.ZodArray<z.ZodObject<{
131
+ module: z.ZodString;
132
+ entityType: z.ZodString;
133
+ mode: z.ZodEnum<{
134
+ blank: "blank";
135
+ delete: "delete";
136
+ }>;
137
+ subjects: z.ZodArray<z.ZodString>;
138
+ erasable: z.ZodArray<z.ZodString>;
139
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
140
+ }, z.core.$strip>>;
141
+ unreachedEntities: z.ZodArray<z.ZodObject<{
142
+ module: z.ZodString;
143
+ entityType: z.ZodString;
144
+ }, z.core.$strip>>;
145
+ hookEntities: z.ZodArray<z.ZodObject<{
146
+ module: z.ZodString;
147
+ entityType: z.ZodString;
148
+ }, z.core.$strip>>;
149
+ nextCursor: z.ZodNullable<z.ZodString>;
150
+ }, z.core.$strip>;
151
+ export type SubjectReadPage = z.infer<typeof subjectReadPage>;
152
+ /** What a caller may ask of one page: where to resume, and how many items at most. */
153
+ export interface SubjectReadRequest {
154
+ readonly cursor?: string;
155
+ readonly limit?: number;
156
+ }
157
+ /** The default and the ceiling of a `readSubject` page, in events plus rows. */
158
+ export declare const SUBJECT_READ_PAGE_DEFAULT = 200;
159
+ export declare const SUBJECT_READ_PAGE_MAX = 1000;
160
+ /**
161
+ * What a controller sends to ask for one subject's package (D-74): a reference for the request
162
+ * and their word that they checked who asked (Art. 12(6) leaves that check to them).
163
+ *
164
+ * The reference lands in the admin log, which is never swept, so it is held to a short line: a
165
+ * ticket number or a date, never the person's name (the form says so).
166
+ */
167
+ export declare const subjectAccessBody: z.ZodObject<{
168
+ reference: z.ZodString;
169
+ requesterVerified: z.ZodLiteral<true>;
170
+ }, z.core.$strict>;
171
+ export type SubjectAccessBody = z.infer<typeof subjectAccessBody>;
172
+ /** One entity's line on an access receipt: how many of the subject's rows the package carries. */
173
+ export declare const accessedEntityCount: z.ZodObject<{
174
+ module: z.ZodString;
175
+ entityType: z.ZodString;
176
+ rows: z.ZodNumber;
177
+ }, z.core.$strip>;
178
+ /**
179
+ * What a subject access request did (D-74), kept as the admin log's `after`: counts, the request's
180
+ * reference and the identity confirmation, never content. An admin log that kept a copy of what a
181
+ * person was sent would be a second copy of that person. It is what lets a controller prove they
182
+ * answered, when, and (through the row's `onBehalfOf`) who on their team did it.
183
+ */
184
+ export declare const subjectAccessReceipt: z.ZodObject<{
185
+ subjectId: z.ZodString;
186
+ generatedAt: z.ZodString;
187
+ reference: z.ZodString;
188
+ requesterVerified: z.ZodLiteral<true>;
189
+ jurisdiction: z.ZodString;
190
+ residencyExempt: z.ZodBoolean;
191
+ events: z.ZodNumber;
192
+ erasedEvents: z.ZodNumber;
193
+ records: z.ZodArray<z.ZodObject<{
194
+ module: z.ZodString;
195
+ entityType: z.ZodString;
196
+ rows: z.ZodNumber;
197
+ }, z.core.$strip>>;
198
+ stores: z.ZodArray<z.ZodObject<{
199
+ binding: z.ZodString;
200
+ rows: z.ZodNumber;
201
+ }, z.core.$strip>>;
202
+ unreachedEntities: z.ZodArray<z.ZodObject<{
203
+ module: z.ZodString;
204
+ entityType: z.ZodString;
205
+ }, z.core.$strip>>;
206
+ hookEntities: z.ZodArray<z.ZodObject<{
207
+ module: z.ZodString;
208
+ entityType: z.ZodString;
209
+ }, z.core.$strip>>;
210
+ recipients: z.ZodLiteral<"not-available">;
211
+ }, z.core.$strip>;
212
+ export type SubjectAccessReceipt = z.infer<typeof subjectAccessReceipt>;
213
+ //# sourceMappingURL=subject-access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subject-access.d.ts","sourceRoot":"","sources":["../src/subject-access.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGvB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD,4GAA4G;AAC5G,eAAO,MAAM,cAAc;;;;;;;;;;iBASzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAM1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D,sFAAsF;AACtF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,gFAAgF;AAChF,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;;;kBAKnB,CAAC;AACZ,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE,kGAAkG;AAClG,eAAO,MAAM,mBAAmB;;;;iBAI9B,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgB/B,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Subject access (GDPR Art. 15, D-74, `docs/rfc/subject-access.md`): what one scope holds about one
3
+ * data subject, read through the same reach erasure writes through.
4
+ *
5
+ * This file is the read's page, the shape that crosses a Durable Object's RPC and a vertical's
6
+ * `/internal` hop. The package a controller downloads is assembled from pages by the control
7
+ * plane, which is also where masking and the audit happen.
8
+ */
9
+ import { z } from 'zod';
10
+ import { scopeHistoryEntry } from './events.js';
11
+ import { subjectErasureMode, unreachedEntity } from './subject-erasure.js';
12
+ /**
13
+ * One event keyed to the subject, decoded as `readScopeHistory` decodes it, and whether an erasure
14
+ * already took its payload.
15
+ *
16
+ * Wider than erasure on purpose: every outbox row with the subject's id, `piiClass: 'none'`
17
+ * included, because access answers *whether* data about the person is processed at all. An
18
+ * erased event keeps its envelope, which is what the person is owed: the fact that something
19
+ * happened, without what was said.
20
+ */
21
+ export const subjectEvent = scopeHistoryEntry.extend({
22
+ /** The stored payload is NULL: an erasure took it (K-37). A payload that only failed to decode is not erased. */
23
+ erased: z.boolean(),
24
+ });
25
+ /** One declared entity's rows that are the subject's: whole rows, matched by the predicate erasure uses. */
26
+ export const subjectRecords = z.object({
27
+ module: z.string().min(1),
28
+ entityType: z.string().min(1),
29
+ mode: subjectErasureMode.extract(['blank', 'delete']),
30
+ /** The entity's subject columns, so a reader can tell the subject's id from another person's. */
31
+ subjects: z.array(z.string().min(1)).min(1),
32
+ /** The entity's erasable fields: the data categories this entity holds about a person. */
33
+ erasable: z.array(z.string().min(1)),
34
+ rows: z.array(z.record(z.string(), z.unknown())),
35
+ });
36
+ /**
37
+ * One page of `readSubject`. Each source is walked in turn, the events first and then each
38
+ * declared entity, until the page's budget is spent; `nextCursor` resumes where it stopped and is
39
+ * null once every source is exhausted. Opaque to the caller.
40
+ *
41
+ * `unreachedEntities` is the list a shred receipt names (an entity with erasable fields and no
42
+ * subject link). `hookEntities` are the entities erasure reaches only through a module's
43
+ * `onSubjectErased` hook, which access has no read-only twin for yet: unreached for access, and
44
+ * named so the package says so. Both are the same on every page.
45
+ */
46
+ export const subjectReadPage = z.object({
47
+ events: z.array(subjectEvent),
48
+ records: z.array(subjectRecords),
49
+ unreachedEntities: z.array(unreachedEntity),
50
+ hookEntities: z.array(unreachedEntity),
51
+ nextCursor: z.string().min(1).nullable(),
52
+ });
53
+ /** The default and the ceiling of a `readSubject` page, in events plus rows. */
54
+ export const SUBJECT_READ_PAGE_DEFAULT = 200;
55
+ export const SUBJECT_READ_PAGE_MAX = 1000;
56
+ /**
57
+ * What a controller sends to ask for one subject's package (D-74): a reference for the request
58
+ * and their word that they checked who asked (Art. 12(6) leaves that check to them).
59
+ *
60
+ * The reference lands in the admin log, which is never swept, so it is held to a short line: a
61
+ * ticket number or a date, never the person's name (the form says so).
62
+ */
63
+ export const subjectAccessBody = z
64
+ .object({
65
+ reference: z.string().trim().min(1).max(80).regex(/^[^\r\n]*$/, 'one line'),
66
+ requesterVerified: z.literal(true),
67
+ })
68
+ .strict();
69
+ /** One entity's line on an access receipt: how many of the subject's rows the package carries. */
70
+ export const accessedEntityCount = z.object({
71
+ module: z.string().min(1),
72
+ entityType: z.string().min(1),
73
+ rows: z.number().int().nonnegative(),
74
+ });
75
+ /**
76
+ * What a subject access request did (D-74), kept as the admin log's `after`: counts, the request's
77
+ * reference and the identity confirmation, never content. An admin log that kept a copy of what a
78
+ * person was sent would be a second copy of that person. It is what lets a controller prove they
79
+ * answered, when, and (through the row's `onBehalfOf`) who on their team did it.
80
+ */
81
+ export const subjectAccessReceipt = z.object({
82
+ subjectId: z.string().min(1),
83
+ generatedAt: z.string().min(1),
84
+ reference: z.string().min(1),
85
+ requesterVerified: z.literal(true),
86
+ jurisdiction: z.string().min(1),
87
+ /** The scope is pinned tighter than `global`, and this route hands its data out anyway (D-74). */
88
+ residencyExempt: z.boolean(),
89
+ events: z.number().int().nonnegative(),
90
+ erasedEvents: z.number().int().nonnegative(),
91
+ records: z.array(accessedEntityCount),
92
+ /** The scope stores read. Empty: a scope with a store is refused until a driver can answer. */
93
+ stores: z.array(z.object({ binding: z.string().min(1), rows: z.number().int().nonnegative() })),
94
+ unreachedEntities: z.array(unreachedEntity),
95
+ hookEntities: z.array(unreachedEntity),
96
+ recipients: z.literal('not-available'),
97
+ });
98
+ //# sourceMappingURL=subject-access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subject-access.js","sourceRoot":"","sources":["../src/subject-access.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE3E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,iBAAiB,CAAC,MAAM,CAAC;IACnD,iHAAiH;IACjH,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE;CACpB,CAAC,CAAC;AAGH,4GAA4G;AAC5G,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,IAAI,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACrD,i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AE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAC/F,iBAAiB,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC;IAC3C,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC;IACtC,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC;CACvC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@substrat-run/contracts",
3
- "version": "0.204.0",
3
+ "version": "0.206.0",
4
4
  "description": "Substrat kernel contract schemas — Zod is the source of truth (master plan D-22); OAS/JSON Schema are emitted artifacts",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {