@substrat-run/contracts 0.195.0 → 0.197.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.
@@ -0,0 +1,108 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * An app's MACHINE client at the team auth-server it signs in with (#3134).
4
+ *
5
+ * A team auth-server serves machine-facing APIs of its own — SCIM at `/scim/v2` (#2941) and
6
+ * the Management API subset at `/api/v2` (#3107) — to a client that authenticates as itself
7
+ * with `client_credentials` (#2267). An app's sign-in client is registered for it when the
8
+ * app is installed; its machine client was four steps by hand. An app now DECLARES the
9
+ * issuer scopes it needs (package.json `substrat.issuerScopes`, {@link issuerScopes}) and
10
+ * the platform registers one machine client per app at the app's own issuer, holding the
11
+ * declared scopes the issuer's operator allows.
12
+ *
13
+ * This module is the vocabulary between the two ends: the control plane, which decides when,
14
+ * and the team auth-server (`demos/auth-server`), which registers, converges and removes.
15
+ * Two platform-gated routes on the issuer, each addressed by the issuer's OWN scope and
16
+ * refused unless that scope is the named tenant's instance:
17
+ *
18
+ * - `POST /internal/machine-client` — ensure the app's client: register it, or converge
19
+ * the one it has on the name and the scopes.
20
+ * - `DELETE /internal/machine-client` — remove the app's client, and only that one.
21
+ *
22
+ * ## One client per app, found by the app's scope
23
+ *
24
+ * SCIM lets only the client that created an account change it, so two apps sharing a
25
+ * client would share each other's accounts. The issuer records each client it registered
26
+ * here in its own `app_machine_client` table, keyed by the app's scope. Every verb finds
27
+ * its client there and nowhere else, so no verb can reach a client an operator registered
28
+ * in the console, nor one somebody registered dynamically.
29
+ *
30
+ * ## The ceiling stays the operator's
31
+ *
32
+ * The issuer's `MACHINE_SCOPES` setting bounds every machine client, this one included.
33
+ * An ensure grants the declared scopes that are inside it and answers the rest as
34
+ * `withheld`, by name, so the caller can say which scope is missing and where to add it.
35
+ * Nothing is dropped silently, and nothing is granted beyond the ceiling. When the ceiling
36
+ * widens, the next ensure grants what was withheld without issuing a new secret.
37
+ *
38
+ * ## The secret is answered once
39
+ *
40
+ * The issuer stores the secret hashed. An ensure answers it when it registered the client
41
+ * and when the call asked to `rotate`; never otherwise. A rotation keeps the client id,
42
+ * because the accounts a client provisioned through SCIM belong to that id.
43
+ */
44
+ /** The issuer-side path of both verbs. */
45
+ export declare const MACHINE_CLIENT_PATH = "/internal/machine-client";
46
+ /**
47
+ * The scopes a person grants by signing in. A machine client holds none of them: it has no
48
+ * person to speak for, and the issuer's ceiling refuses them too.
49
+ */
50
+ export declare const SIGN_IN_SCOPES: readonly string[];
51
+ /**
52
+ * One scope of the issuer's machine APIs, such as `read:users` or `users:provision`. A comma
53
+ * is refused because the issuer's `MACHINE_SCOPES` setting is a comma-separated list, so a
54
+ * scope holding one could never be put in the ceiling.
55
+ */
56
+ export declare const issuerScope: z.ZodString;
57
+ /**
58
+ * An app's declared issuer scopes — package.json `substrat.issuerScopes`. A request, bounded
59
+ * by the issuer's `MACHINE_SCOPES` ceiling: declaring a scope grants nothing by itself.
60
+ */
61
+ export declare const issuerScopes: z.ZodArray<z.ZodString>;
62
+ export type IssuerScopes = z.infer<typeof issuerScopes>;
63
+ /**
64
+ * `POST /internal/machine-client` — ensure the app's machine client. With no client recorded
65
+ * for `appScopeId` the issuer registers one and answers its secret. With one recorded it
66
+ * converges the name and the scopes and answers no secret, unless `rotate` asks for a new one.
67
+ */
68
+ export declare const machineClientEnsure: z.ZodObject<{
69
+ tenantId: z.core.$ZodBranded<z.ZodString, "TenantId", "out">;
70
+ scopeId: z.core.$ZodBranded<z.ZodString, "ScopeId", "out">;
71
+ appScopeId: z.core.$ZodBranded<z.ZodString, "ScopeId", "out">;
72
+ clientName: z.ZodString;
73
+ scopes: z.ZodArray<z.ZodString>;
74
+ rotate: z.ZodOptional<z.ZodBoolean>;
75
+ }, z.core.$strip>;
76
+ export type MachineClientEnsure = z.infer<typeof machineClientEnsure>;
77
+ /**
78
+ * What an ensure answers. `clientSecret` is present ONLY when this call registered the client
79
+ * or rotated its secret; the issuer stores it hashed and cannot answer it again. `scopes` are
80
+ * the ones the client holds now; `withheld` are the declared ones outside the issuer's ceiling.
81
+ */
82
+ export declare const ensuredMachineClient: z.ZodObject<{
83
+ clientId: z.ZodString;
84
+ clientSecret: z.ZodOptional<z.ZodString>;
85
+ scopes: z.ZodArray<z.ZodString>;
86
+ withheld: z.ZodArray<z.ZodString>;
87
+ }, z.core.$strip>;
88
+ export type EnsuredMachineClient = z.infer<typeof ensuredMachineClient>;
89
+ /** `DELETE /internal/machine-client` — remove the app's machine client and its tokens. */
90
+ export declare const machineClientRemove: z.ZodObject<{
91
+ tenantId: z.core.$ZodBranded<z.ZodString, "TenantId", "out">;
92
+ scopeId: z.core.$ZodBranded<z.ZodString, "ScopeId", "out">;
93
+ appScopeId: z.core.$ZodBranded<z.ZodString, "ScopeId", "out">;
94
+ }, z.core.$strip>;
95
+ export type MachineClientRemove = z.infer<typeof machineClientRemove>;
96
+ /** What a remove did: the client it deleted, or null when the app had none recorded. */
97
+ export declare const removedMachineClient: z.ZodObject<{
98
+ removed: z.ZodNullable<z.ZodString>;
99
+ }, z.core.$strip>;
100
+ export type RemovedMachineClient = z.infer<typeof removedMachineClient>;
101
+ /**
102
+ * The declared issuer scopes of a STORED manifest — `callsOfManifestJson`'s sibling. Empty
103
+ * when the manifest declares none, cannot be read, or was pushed before the declaration
104
+ * existed: all three mean the app asks for no machine client. A stored entry that is not a
105
+ * valid scope is left out rather than trusted.
106
+ */
107
+ export declare function issuerScopesOfManifestJson(manifestJson: string | null | undefined): string[];
108
+ //# sourceMappingURL=machine-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"machine-client.d.ts","sourceRoot":"","sources":["../src/machine-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,0CAA0C;AAC1C,eAAO,MAAM,mBAAmB,6BAA6B,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAAqD,CAAC;AAKlG;;;;GAIG;AACH,eAAO,MAAM,WAAW,aAMiG,CAAC;AAE1H;;;GAGG;AACH,eAAO,MAAM,YAAY,yBAG0D,CAAC;AACpF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAQxD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;;;;iBAM9B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;iBAK/B,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,0FAA0F;AAC1F,eAAO,MAAM,mBAAmB;;;;iBAG9B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE,wFAAwF;AACxF,eAAO,MAAM,oBAAoB;;iBAA+C,CAAC;AACjF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,EAAE,CAS5F"}
@@ -0,0 +1,128 @@
1
+ import { z } from 'zod';
2
+ import { scopeId, tenantId } from './ids.js';
3
+ /**
4
+ * An app's MACHINE client at the team auth-server it signs in with (#3134).
5
+ *
6
+ * A team auth-server serves machine-facing APIs of its own — SCIM at `/scim/v2` (#2941) and
7
+ * the Management API subset at `/api/v2` (#3107) — to a client that authenticates as itself
8
+ * with `client_credentials` (#2267). An app's sign-in client is registered for it when the
9
+ * app is installed; its machine client was four steps by hand. An app now DECLARES the
10
+ * issuer scopes it needs (package.json `substrat.issuerScopes`, {@link issuerScopes}) and
11
+ * the platform registers one machine client per app at the app's own issuer, holding the
12
+ * declared scopes the issuer's operator allows.
13
+ *
14
+ * This module is the vocabulary between the two ends: the control plane, which decides when,
15
+ * and the team auth-server (`demos/auth-server`), which registers, converges and removes.
16
+ * Two platform-gated routes on the issuer, each addressed by the issuer's OWN scope and
17
+ * refused unless that scope is the named tenant's instance:
18
+ *
19
+ * - `POST /internal/machine-client` — ensure the app's client: register it, or converge
20
+ * the one it has on the name and the scopes.
21
+ * - `DELETE /internal/machine-client` — remove the app's client, and only that one.
22
+ *
23
+ * ## One client per app, found by the app's scope
24
+ *
25
+ * SCIM lets only the client that created an account change it, so two apps sharing a
26
+ * client would share each other's accounts. The issuer records each client it registered
27
+ * here in its own `app_machine_client` table, keyed by the app's scope. Every verb finds
28
+ * its client there and nowhere else, so no verb can reach a client an operator registered
29
+ * in the console, nor one somebody registered dynamically.
30
+ *
31
+ * ## The ceiling stays the operator's
32
+ *
33
+ * The issuer's `MACHINE_SCOPES` setting bounds every machine client, this one included.
34
+ * An ensure grants the declared scopes that are inside it and answers the rest as
35
+ * `withheld`, by name, so the caller can say which scope is missing and where to add it.
36
+ * Nothing is dropped silently, and nothing is granted beyond the ceiling. When the ceiling
37
+ * widens, the next ensure grants what was withheld without issuing a new secret.
38
+ *
39
+ * ## The secret is answered once
40
+ *
41
+ * The issuer stores the secret hashed. An ensure answers it when it registered the client
42
+ * and when the call asked to `rotate`; never otherwise. A rotation keeps the client id,
43
+ * because the accounts a client provisioned through SCIM belong to that id.
44
+ */
45
+ /** The issuer-side path of both verbs. */
46
+ export const MACHINE_CLIENT_PATH = '/internal/machine-client';
47
+ /**
48
+ * The scopes a person grants by signing in. A machine client holds none of them: it has no
49
+ * person to speak for, and the issuer's ceiling refuses them too.
50
+ */
51
+ export const SIGN_IN_SCOPES = ['openid', 'profile', 'email', 'offline_access'];
52
+ /** RFC 6749 §3.3 `scope-token`: printable ASCII without space, `"` or `\`. */
53
+ const SCOPE_TOKEN = /^[\x21\x23-\x5B\x5D-\x7E]+$/;
54
+ /**
55
+ * One scope of the issuer's machine APIs, such as `read:users` or `users:provision`. A comma
56
+ * is refused because the issuer's `MACHINE_SCOPES` setting is a comma-separated list, so a
57
+ * scope holding one could never be put in the ceiling.
58
+ */
59
+ export const issuerScope = z
60
+ .string()
61
+ .min(1)
62
+ .max(128)
63
+ .regex(SCOPE_TOKEN, 'a scope token: printable ASCII without space, quote or backslash')
64
+ .refine((s) => !s.includes(','), 'a scope cannot contain a comma')
65
+ .refine((s) => !SIGN_IN_SCOPES.includes(s), 'a scope a person grants by signing in cannot be held by a machine client');
66
+ /**
67
+ * An app's declared issuer scopes — package.json `substrat.issuerScopes`. A request, bounded
68
+ * by the issuer's `MACHINE_SCOPES` ceiling: declaring a scope grants nothing by itself.
69
+ */
70
+ export const issuerScopes = z
71
+ .array(issuerScope)
72
+ .max(32)
73
+ .refine((list) => new Set(list).size === list.length, 'each scope is named once');
74
+ /** The issuer the call addresses: its own scope, and the tenant that scope must belong to. */
75
+ const issuerAddress = {
76
+ tenantId,
77
+ scopeId,
78
+ };
79
+ /**
80
+ * `POST /internal/machine-client` — ensure the app's machine client. With no client recorded
81
+ * for `appScopeId` the issuer registers one and answers its secret. With one recorded it
82
+ * converges the name and the scopes and answers no secret, unless `rotate` asks for a new one.
83
+ */
84
+ export const machineClientEnsure = z.object({
85
+ ...issuerAddress,
86
+ appScopeId: scopeId,
87
+ clientName: z.string().trim().min(1).max(200),
88
+ scopes: issuerScopes,
89
+ rotate: z.boolean().optional(),
90
+ });
91
+ /**
92
+ * What an ensure answers. `clientSecret` is present ONLY when this call registered the client
93
+ * or rotated its secret; the issuer stores it hashed and cannot answer it again. `scopes` are
94
+ * the ones the client holds now; `withheld` are the declared ones outside the issuer's ceiling.
95
+ */
96
+ export const ensuredMachineClient = z.object({
97
+ clientId: z.string().min(1),
98
+ clientSecret: z.string().min(1).optional(),
99
+ scopes: z.array(z.string()),
100
+ withheld: z.array(z.string()),
101
+ });
102
+ /** `DELETE /internal/machine-client` — remove the app's machine client and its tokens. */
103
+ export const machineClientRemove = z.object({
104
+ ...issuerAddress,
105
+ appScopeId: scopeId,
106
+ });
107
+ /** What a remove did: the client it deleted, or null when the app had none recorded. */
108
+ export const removedMachineClient = z.object({ removed: z.string().nullable() });
109
+ /**
110
+ * The declared issuer scopes of a STORED manifest — `callsOfManifestJson`'s sibling. Empty
111
+ * when the manifest declares none, cannot be read, or was pushed before the declaration
112
+ * existed: all three mean the app asks for no machine client. A stored entry that is not a
113
+ * valid scope is left out rather than trusted.
114
+ */
115
+ export function issuerScopesOfManifestJson(manifestJson) {
116
+ if (!manifestJson)
117
+ return [];
118
+ try {
119
+ const m = JSON.parse(manifestJson);
120
+ if (!Array.isArray(m.issuerScopes))
121
+ return [];
122
+ return [...new Set(m.issuerScopes.filter((v) => issuerScope.safeParse(v).success))];
123
+ }
124
+ catch {
125
+ return [];
126
+ }
127
+ }
128
+ //# sourceMappingURL=machine-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"machine-client.js","sourceRoot":"","sources":["../src/machine-client.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,60 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * PEOPLE shared between two apps of one tenant: the person contract.
4
+ *
5
+ * One app of a tenant owns the people (the MASTER): who exists, whether they are let in, and
6
+ * which base roles they hold. Another app (a DEPENDENT, a plugin of the first) signs people in
7
+ * at the same issuer and has no invitations of its own. When someone it has not seen signs in,
8
+ * it asks the master who they are, by a peer call, and keeps the answer for a bounded time.
9
+ *
10
+ * This module is that question and its answer. The master implements one operation taking
11
+ * {@link personResolveInput} and returning {@link personResolveOutput}, and allowlists the
12
+ * dependent as a peer for it; `@substrat-run/vertical-auth/people` is the dependent's half.
13
+ *
14
+ * The answer is the AUTHORISATION half of a person and nothing else: an id, a status and role
15
+ * keys. It carries no name and no address, so the copy a dependent keeps holds nothing an
16
+ * erasure has to reach.
17
+ */
18
+ export declare const IDENTITY_PERSON_CONTRACT = "identity.person@1";
19
+ /**
20
+ * Who is signing in at the dependent. `sub` and `issuer` are the login; `verifiedEmail` is the
21
+ * address the issuer verified for it, or null. A master matches on whichever it records: one
22
+ * that keeps each person's logins matches on (`issuer`, `sub`), and one that records the
23
+ * verified address a person joined with matches on that, the proof a member invite is admitted
24
+ * on (K-61). The address is the caller's own, sent to the app that already holds it.
25
+ */
26
+ export declare const personResolveInput: z.ZodObject<{
27
+ issuer: z.ZodNullable<z.ZodString>;
28
+ sub: z.ZodString;
29
+ verifiedEmail: z.ZodNullable<z.ZodString>;
30
+ }, z.core.$strip>;
31
+ export type PersonResolveInput = z.infer<typeof personResolveInput>;
32
+ /**
33
+ * Whether the master lets the person in. Only `active` is admitted by a dependent; `invited`
34
+ * has not arrived at the master yet, and `blocked` is refused everywhere.
35
+ */
36
+ export declare const personStatus: z.ZodEnum<{
37
+ active: "active";
38
+ blocked: "blocked";
39
+ invited: "invited";
40
+ }>;
41
+ export type PersonStatus = z.infer<typeof personStatus>;
42
+ /**
43
+ * The person as the master knows them, or null for a login it has nobody for. `id` is the
44
+ * master's id for the person and becomes their principal in the dependent's scope. `roles` are
45
+ * the MASTER's role keys, for the dependent to map onto its own; an empty list is a person
46
+ * who is known and holds nothing there.
47
+ */
48
+ export declare const personResolveOutput: z.ZodObject<{
49
+ person: z.ZodNullable<z.ZodObject<{
50
+ id: z.ZodString;
51
+ status: z.ZodEnum<{
52
+ active: "active";
53
+ blocked: "blocked";
54
+ invited: "invited";
55
+ }>;
56
+ roles: z.ZodArray<z.ZodString>;
57
+ }, z.core.$strip>>;
58
+ }, z.core.$strip>;
59
+ export type PersonResolveOutput = z.infer<typeof personResolveOutput>;
60
+ //# sourceMappingURL=people.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"people.d.ts","sourceRoot":"","sources":["../src/people.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAE5D;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;;;;iBAI7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;EAA2C,CAAC;AACrE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;iBAQ9B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
package/dist/people.js ADDED
@@ -0,0 +1,51 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * PEOPLE shared between two apps of one tenant: the person contract.
4
+ *
5
+ * One app of a tenant owns the people (the MASTER): who exists, whether they are let in, and
6
+ * which base roles they hold. Another app (a DEPENDENT, a plugin of the first) signs people in
7
+ * at the same issuer and has no invitations of its own. When someone it has not seen signs in,
8
+ * it asks the master who they are, by a peer call, and keeps the answer for a bounded time.
9
+ *
10
+ * This module is that question and its answer. The master implements one operation taking
11
+ * {@link personResolveInput} and returning {@link personResolveOutput}, and allowlists the
12
+ * dependent as a peer for it; `@substrat-run/vertical-auth/people` is the dependent's half.
13
+ *
14
+ * The answer is the AUTHORISATION half of a person and nothing else: an id, a status and role
15
+ * keys. It carries no name and no address, so the copy a dependent keeps holds nothing an
16
+ * erasure has to reach.
17
+ */
18
+ export const IDENTITY_PERSON_CONTRACT = 'identity.person@1';
19
+ /**
20
+ * Who is signing in at the dependent. `sub` and `issuer` are the login; `verifiedEmail` is the
21
+ * address the issuer verified for it, or null. A master matches on whichever it records: one
22
+ * that keeps each person's logins matches on (`issuer`, `sub`), and one that records the
23
+ * verified address a person joined with matches on that, the proof a member invite is admitted
24
+ * on (K-61). The address is the caller's own, sent to the app that already holds it.
25
+ */
26
+ export const personResolveInput = z.object({
27
+ issuer: z.string().min(1).nullable(),
28
+ sub: z.string().min(1),
29
+ verifiedEmail: z.string().min(1).nullable(),
30
+ });
31
+ /**
32
+ * Whether the master lets the person in. Only `active` is admitted by a dependent; `invited`
33
+ * has not arrived at the master yet, and `blocked` is refused everywhere.
34
+ */
35
+ export const personStatus = z.enum(['invited', 'active', 'blocked']);
36
+ /**
37
+ * The person as the master knows them, or null for a login it has nobody for. `id` is the
38
+ * master's id for the person and becomes their principal in the dependent's scope. `roles` are
39
+ * the MASTER's role keys, for the dependent to map onto its own; an empty list is a person
40
+ * who is known and holds nothing there.
41
+ */
42
+ export const personResolveOutput = z.object({
43
+ person: z
44
+ .object({
45
+ id: z.string().min(1),
46
+ status: personStatus,
47
+ roles: z.array(z.string().min(1)),
48
+ })
49
+ .nullable(),
50
+ });
51
+ //# sourceMappingURL=people.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"people.js","sourceRoot":"","sources":["../src/people.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACpC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC5C,CAAC,CAAC;AAGH;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAGrE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,MAAM,EAAE,CAAC;SACN,MAAM,CAAC;QACN,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACrB,MAAM,EAAE,YAAY;QACpB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAClC,CAAC;SACD,QAAQ,EAAE;CACd,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@substrat-run/contracts",
3
- "version": "0.195.0",
3
+ "version": "0.197.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": {