@kashscript/lexicons 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/LICENSE +199 -0
  2. package/README.md +73 -0
  3. package/dist/engine.d.ts +48 -0
  4. package/dist/engine.d.ts.map +1 -0
  5. package/dist/engine.js +110 -0
  6. package/dist/engine.js.map +1 -0
  7. package/dist/envelope.d.ts +59 -0
  8. package/dist/envelope.d.ts.map +1 -0
  9. package/dist/envelope.js +43 -0
  10. package/dist/envelope.js.map +1 -0
  11. package/dist/extensions/social.d.ts +82 -0
  12. package/dist/extensions/social.d.ts.map +1 -0
  13. package/dist/extensions/social.js +99 -0
  14. package/dist/extensions/social.js.map +1 -0
  15. package/dist/extensions/trade.d.ts +94 -0
  16. package/dist/extensions/trade.d.ts.map +1 -0
  17. package/dist/extensions/trade.js +116 -0
  18. package/dist/extensions/trade.js.map +1 -0
  19. package/dist/extensions/zkp.d.ts +76 -0
  20. package/dist/extensions/zkp.d.ts.map +1 -0
  21. package/dist/extensions/zkp.js +68 -0
  22. package/dist/extensions/zkp.js.map +1 -0
  23. package/dist/index.d.ts +26 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +28 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/json-schema.d.ts +18 -0
  28. package/dist/json-schema.d.ts.map +1 -0
  29. package/dist/json-schema.js +125 -0
  30. package/dist/json-schema.js.map +1 -0
  31. package/dist/lexicons/index.d.ts +32 -0
  32. package/dist/lexicons/index.d.ts.map +1 -0
  33. package/dist/lexicons/index.js +59 -0
  34. package/dist/lexicons/index.js.map +1 -0
  35. package/dist/lexicons/kash-id-audit.d.ts +32 -0
  36. package/dist/lexicons/kash-id-audit.d.ts.map +1 -0
  37. package/dist/lexicons/kash-id-audit.js +21 -0
  38. package/dist/lexicons/kash-id-audit.js.map +1 -0
  39. package/dist/lexicons/kash-id-preferences.d.ts +60 -0
  40. package/dist/lexicons/kash-id-preferences.d.ts.map +1 -0
  41. package/dist/lexicons/kash-id-preferences.js +43 -0
  42. package/dist/lexicons/kash-id-preferences.js.map +1 -0
  43. package/dist/lexicons/kash-id-profile.d.ts +46 -0
  44. package/dist/lexicons/kash-id-profile.d.ts.map +1 -0
  45. package/dist/lexicons/kash-id-profile.js +31 -0
  46. package/dist/lexicons/kash-id-profile.js.map +1 -0
  47. package/dist/registry.d.ts +78 -0
  48. package/dist/registry.d.ts.map +1 -0
  49. package/dist/registry.js +133 -0
  50. package/dist/registry.js.map +1 -0
  51. package/dist/schema.d.ts +101 -0
  52. package/dist/schema.d.ts.map +1 -0
  53. package/dist/schema.js +224 -0
  54. package/dist/schema.js.map +1 -0
  55. package/dist/semver.d.ts +29 -0
  56. package/dist/semver.d.ts.map +1 -0
  57. package/dist/semver.js +42 -0
  58. package/dist/semver.js.map +1 -0
  59. package/dist/types.d.ts +21 -0
  60. package/dist/types.d.ts.map +1 -0
  61. package/dist/types.js +8 -0
  62. package/dist/types.js.map +1 -0
  63. package/package.json +80 -0
  64. package/src/engine.ts +141 -0
  65. package/src/envelope.ts +128 -0
  66. package/src/extensions/social.ts +179 -0
  67. package/src/extensions/trade.ts +210 -0
  68. package/src/extensions/zkp.ts +108 -0
  69. package/src/index.ts +30 -0
  70. package/src/json-schema.ts +141 -0
  71. package/src/lexicons/index.ts +68 -0
  72. package/src/lexicons/kash-id-audit.ts +61 -0
  73. package/src/lexicons/kash-id-preferences.ts +114 -0
  74. package/src/lexicons/kash-id-profile.ts +82 -0
  75. package/src/registry.ts +168 -0
  76. package/src/schema.ts +347 -0
  77. package/src/semver.ts +56 -0
  78. package/src/types.ts +27 -0
package/LICENSE ADDED
@@ -0,0 +1,199 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may accept and charge a
167
+ fee for, or grant any of the rights granted herein, additional
168
+ support, warranty, indemnity, or other liability obligations and/or
169
+ rights consistent with this License. However, in accepting such
170
+ obligations, You may act only on Your own behalf and on Your sole
171
+ responsibility, not on behalf of any other Contributor, and only
172
+ if You agree to indemnify, defend, and hold each Contributor
173
+ harmless for any liability incurred by, or claims asserted against,
174
+ such Contributor by reason of your accepting any such warranty or
175
+ additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2026 KashScript Studio
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
192
+
193
+ ─────────────────────────────────────────────────────────────────────
194
+
195
+ This package is also covered by the KashScript Sovereign Software
196
+ License Agreement (SSLA) v1.0, Schedule A (Permissive Packages).
197
+ The SSLA grant is at-least-as-permissive as Apache-2.0 and exists to
198
+ give the entire Foundry a single agreement to point at. Full text:
199
+ https://kashscript.dev/legal/SSLA
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # @kashscript/lexicons
2
+
3
+ > **Zero-dependency lexicon framework — envelope, schema DSL, registry, validator.** Domain-agnostic core; vocabularies ship as opt-in extensions.
4
+
5
+ ```bash
6
+ bun add @kashscript/lexicons
7
+ ```
8
+
9
+ A *lexicon* is the Kash equivalent of an AT-Protocol record schema: a
10
+ versioned, NSID-addressed JSON shape that describes what valid `kash.*`
11
+ records look like. This package gives you the primitives to **define**,
12
+ **register**, and **validate** lexicons — but ships zero domain content
13
+ out of the box. The domain extensions (`social`, `trade`, `zkp`) are
14
+ explicit subpath imports.
15
+
16
+ ---
17
+
18
+ ## What's in the box
19
+
20
+ | Subpath | Purpose |
21
+ |----------------------------------------|------------------------------------------------------|
22
+ | `@kashscript/lexicons` | Default — re-exports `envelope`, `schema`, `registry`, `engine` |
23
+ | `@kashscript/lexicons/envelope` | Record envelope shape + `wrap()` / `unwrap()` |
24
+ | `@kashscript/lexicons/schema` | Schema DSL — `string()`, `object()`, `union()`, etc. |
25
+ | `@kashscript/lexicons/registry` | `LexiconRegistry` — register, lookup, version-resolve |
26
+ | `@kashscript/lexicons/engine` | `validate(envelope, registry)` — pure-TS validator |
27
+ | `@kashscript/lexicons/json-schema` | Export lexicons as JSON Schema (draft 2020-12) |
28
+ | `@kashscript/lexicons/semver` | Strict semver for lexicon evolution |
29
+ | `@kashscript/lexicons/extensions/social` | The `kash.social.*` vocabulary |
30
+ | `@kashscript/lexicons/extensions/trade` | The `kash.trade.*` vocabulary |
31
+ | `@kashscript/lexicons/extensions/zkp` | The `kash.zkp.*` vocabulary |
32
+
33
+ ---
34
+
35
+ ## Quickstart
36
+
37
+ ```typescript
38
+ import { object, string, number } from "@kashscript/lexicons/schema";
39
+ import { LexiconRegistry } from "@kashscript/lexicons/registry";
40
+ import { validate } from "@kashscript/lexicons/engine";
41
+
42
+ // 1. Define a lexicon
43
+ const myPost = {
44
+ nsid: "com.example.post",
45
+ version: "1.0.0",
46
+ shape: object({
47
+ text: string({ maxLength: 280 }),
48
+ createdAt: number(),
49
+ }),
50
+ };
51
+
52
+ // 2. Register it
53
+ const registry = new LexiconRegistry();
54
+ registry.register(myPost);
55
+
56
+ // 3. Validate a record
57
+ const result = validate(
58
+ {
59
+ $type: "com.example.post",
60
+ $version:"1.0.0",
61
+ text: "hello world",
62
+ createdAt: Date.now(),
63
+ },
64
+ registry,
65
+ );
66
+ if (!result.ok) console.error(result.errors);
67
+ ```
68
+
69
+ ---
70
+
71
+ ## License
72
+
73
+ Apache-2.0. Also covered by SSLA v1.0 Schedule A (Permissive). See [LICENSE](./LICENSE).
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Validation Engine — pure-function entry points that compose a registry
3
+ * with the schema engine.
4
+ *
5
+ * validateEvent(event, registry)
6
+ * 1. Validate the Kash-Event envelope shape (header + signature; body deferred).
7
+ * 2. Parse the declared Lexicon ID from `header.lexicon`.
8
+ * 3. Look up a forward-compatible registered schema via the registry.
9
+ * 4. Deep-validate `body` against the registered schema.
10
+ *
11
+ * getSchemaDefinition(lexiconId, registry)
12
+ * Returns a JSON-Schema Draft-2020-12 representation of the body schema for
13
+ * a given Lexicon ID. Used by Oreoasis (and any external AI/tooling) to
14
+ * "teach" itself a new data type at runtime without code changes.
15
+ *
16
+ * Both functions are pure and stateless. No network, no crypto, no storage.
17
+ */
18
+ import { type KashEvent } from "./envelope";
19
+ import { type JsonSchema } from "./json-schema";
20
+ import type { LexiconRegistry } from "./registry";
21
+ import { type Schema, type ValidationResult } from "./schema";
22
+ /**
23
+ * Full envelope-and-body validation against a registry.
24
+ *
25
+ * Returns the typed `KashEvent<Body>` on success, or a flat list of errors
26
+ * keyed by JSON-pointer-style path on failure. All errors are collected
27
+ * (not fail-fast) so the caller can render a complete diagnostic.
28
+ */
29
+ export declare function validateEvent<Body = unknown>(event: unknown, registry: LexiconRegistry): ValidationResult<KashEvent<Body>>;
30
+ /**
31
+ * Validate a raw body against a registered lexicon — bypasses the envelope.
32
+ * Useful when constructing a record locally before signing it.
33
+ */
34
+ export declare function validateBody<Body = unknown>(lexiconId: string, body: unknown, registry: LexiconRegistry): ValidationResult<Body>;
35
+ /**
36
+ * Return a JSON-Schema-Draft-2020-12 representation of the registered lexicon.
37
+ *
38
+ * Used by Oreoasis (and any external AI / tooling) to load a previously
39
+ * unknown lexicon's structure at runtime. The returned object includes
40
+ * `$schema`, `$id`, `title`, and `description` metadata.
41
+ *
42
+ * Returns `null` if the Lexicon ID is malformed or no compatible entry is
43
+ * registered.
44
+ */
45
+ export declare function getSchemaDefinition(lexiconId: string, registry: LexiconRegistry): JsonSchema | null;
46
+ /** Return the raw internal Schema (not JSON-Schema) for advanced consumers. */
47
+ export declare function getRawSchema(lexiconId: string, registry: LexiconRegistry): Schema | null;
48
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAEL,KAAK,MAAM,EAEX,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AAGlB;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,GAAG,OAAO,EAC1C,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,eAAe,GACxB,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAmCnC;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAG,OAAO,EACzC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,eAAe,GACxB,gBAAgB,CAAC,IAAI,CAAC,CAUxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,eAAe,GACxB,UAAU,GAAG,IAAI,CAenB;AAED,+EAA+E;AAC/E,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,CAKxF"}
package/dist/engine.js ADDED
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Validation Engine — pure-function entry points that compose a registry
3
+ * with the schema engine.
4
+ *
5
+ * validateEvent(event, registry)
6
+ * 1. Validate the Kash-Event envelope shape (header + signature; body deferred).
7
+ * 2. Parse the declared Lexicon ID from `header.lexicon`.
8
+ * 3. Look up a forward-compatible registered schema via the registry.
9
+ * 4. Deep-validate `body` against the registered schema.
10
+ *
11
+ * getSchemaDefinition(lexiconId, registry)
12
+ * Returns a JSON-Schema Draft-2020-12 representation of the body schema for
13
+ * a given Lexicon ID. Used by Oreoasis (and any external AI/tooling) to
14
+ * "teach" itself a new data type at runtime without code changes.
15
+ *
16
+ * Both functions are pure and stateless. No network, no crypto, no storage.
17
+ */
18
+ import { BASE_ENVELOPE_SCHEMA } from "./envelope";
19
+ import { toJsonSchema } from "./json-schema";
20
+ import { validate, } from "./schema";
21
+ import { parseLexiconId } from "./semver";
22
+ /**
23
+ * Full envelope-and-body validation against a registry.
24
+ *
25
+ * Returns the typed `KashEvent<Body>` on success, or a flat list of errors
26
+ * keyed by JSON-pointer-style path on failure. All errors are collected
27
+ * (not fail-fast) so the caller can render a complete diagnostic.
28
+ */
29
+ export function validateEvent(event, registry) {
30
+ // Stage 1 — envelope shape (header + signature; body permissive).
31
+ const envResult = validate(BASE_ENVELOPE_SCHEMA, event);
32
+ if (!envResult.ok)
33
+ return envResult;
34
+ const env = envResult.value;
35
+ // Stage 2 — parse declared Lexicon ID.
36
+ const parsed = parseLexiconId(env.header.lexicon);
37
+ if (parsed === null) {
38
+ return failOne(["header", "lexicon"], "unparseable lexicon ID", env.header.lexicon);
39
+ }
40
+ // Stage 3 — resolve from registry (forward-compatible within major).
41
+ const entry = registry.resolve(parsed.nsid, parsed.semver);
42
+ if (!entry) {
43
+ return failOne(["header", "lexicon"], `no registered lexicon supports "${env.header.lexicon}"`, env.header.lexicon);
44
+ }
45
+ // Stage 4 — deep-validate body against the registered schema.
46
+ const bodyResult = validate(entry.bodySchema, env.body);
47
+ if (!bodyResult.ok) {
48
+ const rebased = bodyResult.errors.map((e) => ({
49
+ path: ["body", ...e.path],
50
+ message: e.message,
51
+ received: e.received,
52
+ }));
53
+ return { ok: false, errors: rebased };
54
+ }
55
+ return { ok: true, value: env };
56
+ }
57
+ /**
58
+ * Validate a raw body against a registered lexicon — bypasses the envelope.
59
+ * Useful when constructing a record locally before signing it.
60
+ */
61
+ export function validateBody(lexiconId, body, registry) {
62
+ const parsed = parseLexiconId(lexiconId);
63
+ if (parsed === null) {
64
+ return failOne([], `invalid lexicon ID "${lexiconId}"`, lexiconId);
65
+ }
66
+ const entry = registry.resolve(parsed.nsid, parsed.semver);
67
+ if (!entry) {
68
+ return failOne([], `no registered lexicon supports "${lexiconId}"`, lexiconId);
69
+ }
70
+ return validate(entry.bodySchema, body);
71
+ }
72
+ /**
73
+ * Return a JSON-Schema-Draft-2020-12 representation of the registered lexicon.
74
+ *
75
+ * Used by Oreoasis (and any external AI / tooling) to load a previously
76
+ * unknown lexicon's structure at runtime. The returned object includes
77
+ * `$schema`, `$id`, `title`, and `description` metadata.
78
+ *
79
+ * Returns `null` if the Lexicon ID is malformed or no compatible entry is
80
+ * registered.
81
+ */
82
+ export function getSchemaDefinition(lexiconId, registry) {
83
+ const parsed = parseLexiconId(lexiconId);
84
+ if (parsed === null)
85
+ return null;
86
+ const entry = registry.resolve(parsed.nsid, parsed.semver);
87
+ if (!entry)
88
+ return null;
89
+ const body = toJsonSchema(entry.bodySchema);
90
+ const out = {
91
+ $schema: "https://json-schema.org/draft/2020-12/schema",
92
+ $id: `https://kashscript.com/lexicons/${entry.id}`,
93
+ title: entry.title ?? entry.id,
94
+ description: entry.description ?? `Body schema for ${entry.id}`,
95
+ ...body,
96
+ };
97
+ return out;
98
+ }
99
+ /** Return the raw internal Schema (not JSON-Schema) for advanced consumers. */
100
+ export function getRawSchema(lexiconId, registry) {
101
+ const parsed = parseLexiconId(lexiconId);
102
+ if (parsed === null)
103
+ return null;
104
+ const entry = registry.resolve(parsed.nsid, parsed.semver);
105
+ return entry?.bodySchema ?? null;
106
+ }
107
+ function failOne(path, message, received) {
108
+ return { ok: false, errors: [{ path, message, received }] };
109
+ }
110
+ //# sourceMappingURL=engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,oBAAoB,EAAkB,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,YAAY,EAAmB,MAAM,eAAe,CAAC;AAE9D,OAAO,EACL,QAAQ,GAIT,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAc,EACd,QAAyB;IAEzB,kEAAkE;IAClE,MAAM,SAAS,GAAG,QAAQ,CAAY,oBAAoB,EAAE,KAAK,CAAC,CAAC;IACnE,IAAI,CAAC,SAAS,CAAC,EAAE;QAAE,OAAO,SAA8C,CAAC;IAEzE,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC;IAE5B,uCAAuC;IACvC,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,OAAO,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,wBAAwB,EAAE,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtF,CAAC;IAED,qEAAqE;IACrE,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC3D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,OAAO,CACZ,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,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The Kash-Event Envelope.
3
+ *
4
+ * Every record stored in a PDS conforms to this shape. The envelope is
5
+ * lexicon-agnostic — only the `body` shape is governed by a specific lexicon.
6
+ * Signatures are bound by a Domain-Separation Tag (DST) to prevent
7
+ * cross-protocol replay (see Identity Protocol §5.5).
8
+ */
9
+ import { type ObjectSchema, type Schema } from "./schema";
10
+ import { type CID, type DID, type Iso8601, type KashRecordDST, type LexiconId, type Multibase, type SignatureAlgorithm } from "./types";
11
+ /** Cryptographic signature produced by a Signer under a `purpose: "active"` key. */
12
+ export interface KashSignature {
13
+ /** verificationMethod id, e.g., "did:kash:5g7q…#sig-1". */
14
+ readonly kid: string;
15
+ /** Must match the verification method's `algorithm` field at verification time. */
16
+ readonly alg: SignatureAlgorithm;
17
+ /** Multibase-encoded signature bytes (z-prefix, base58-btc). */
18
+ readonly sig: Multibase;
19
+ /** Fixed DST: "kash-record-v1\n". Prevents cross-protocol replay. */
20
+ readonly dst: KashRecordDST;
21
+ }
22
+ /** Header carried by every record, lexicon-agnostic. */
23
+ export interface KashHeader {
24
+ /** Author DID. */
25
+ readonly did: DID;
26
+ /** Lexicon ID — <nsid>@<semver>. */
27
+ readonly lexicon: LexiconId;
28
+ /** Issued-at timestamp (ISO-8601 with offset). */
29
+ readonly iat: Iso8601;
30
+ /** Per-record nonce — 32-128 hex chars (≥128 bits of entropy). */
31
+ readonly nonce: string;
32
+ /** CID of the canonicalized body (computed at envelope-build time). */
33
+ readonly cid: CID;
34
+ /** Optional monotonic sequence within this (did, nsid) collection. */
35
+ readonly seq?: number;
36
+ /** Optional CID of the previous record in the same collection. */
37
+ readonly prev?: CID;
38
+ /** Optional record key — opaque, app-chosen. */
39
+ readonly rkey?: string;
40
+ }
41
+ /** Standard Kash-Event envelope. Every PDS record IS a KashEvent<Body>. */
42
+ export interface KashEvent<Body = unknown> {
43
+ readonly header: KashHeader;
44
+ readonly body: Body;
45
+ readonly signature: KashSignature;
46
+ }
47
+ export declare const SIGNATURE_SCHEMA: ObjectSchema;
48
+ export declare const HEADER_SCHEMA: ObjectSchema;
49
+ /** Envelope schema parameterised by the body's schema. */
50
+ export declare function envelopeSchema(body: Schema): ObjectSchema;
51
+ /** Envelope schema that accepts any body (used during pre-lexicon shape validation). */
52
+ export declare const BASE_ENVELOPE_SCHEMA: ObjectSchema;
53
+ export interface RecordRef {
54
+ readonly cid: CID;
55
+ readonly uri: string;
56
+ }
57
+ export declare const AT_URI_PATTERN: RegExp;
58
+ export declare const RECORD_REF_SCHEMA: ObjectSchema;
59
+ //# sourceMappingURL=envelope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../src/envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAK,KAAK,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAEL,KAAK,GAAG,EACR,KAAK,GAAG,EACR,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,kBAAkB,EACxB,MAAM,SAAS,CAAC;AAIjB,oFAAoF;AACpF,MAAM,WAAW,aAAa;IAC5B,2DAA2D;IAC3D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,mFAAmF;IACnF,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAAC;IACjC,gEAAgE;IAChE,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,qEAAqE;IACrE,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;CAC7B;AAED,wDAAwD;AACxD,MAAM,WAAW,UAAU;IACzB,kBAAkB;IAClB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,uEAAuE;IACvE,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,sEAAsE;IACtE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC;IACpB,gDAAgD;IAChD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,2EAA2E;AAC3E,MAAM,WAAW,SAAS,CAAC,IAAI,GAAG,OAAO;IACvC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;CACnC;AAID,eAAO,MAAM,gBAAgB,EAAE,YAQ9B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,YAY3B,CAAC;AAEF,0DAA0D;AAC1D,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CASzD;AAED,wFAAwF;AACxF,eAAO,MAAM,oBAAoB,EAAE,YAAsC,CAAC;AAa1E,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,cAAc,QAA+E,CAAC;AAE3G,eAAO,MAAM,iBAAiB,EAAE,YAM/B,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The Kash-Event Envelope.
3
+ *
4
+ * Every record stored in a PDS conforms to this shape. The envelope is
5
+ * lexicon-agnostic — only the `body` shape is governed by a specific lexicon.
6
+ * Signatures are bound by a Domain-Separation Tag (DST) to prevent
7
+ * cross-protocol replay (see Identity Protocol §5.5).
8
+ */
9
+ import { S } from "./schema";
10
+ import { KASH_RECORD_DST, } from "./types";
11
+ /* ── runtime schemas ────────────────────────────────────────────── */
12
+ export const SIGNATURE_SCHEMA = S.object({
13
+ kid: S.string({ minLength: 1, maxLength: 256 }),
14
+ alg: S.enum("ed25519", "es256", "bls12-381-g2"),
15
+ sig: S.string({ format: "multibase" }),
16
+ dst: S.literal(KASH_RECORD_DST),
17
+ }, ["kid", "alg", "sig", "dst"]);
18
+ export const HEADER_SCHEMA = S.object({
19
+ did: S.string({ format: "did-ks" }),
20
+ lexicon: S.string({ format: "lexicon-id" }),
21
+ iat: S.string({ format: "iso8601" }),
22
+ nonce: S.string({ minLength: 32, maxLength: 128, pattern: /^[0-9a-f]+$/ }),
23
+ cid: S.string({ format: "cid" }),
24
+ seq: S.optional(S.number({ integer: true, min: 0 })),
25
+ prev: S.optional(S.string({ format: "cid" })),
26
+ rkey: S.optional(S.string({ minLength: 1, maxLength: 128 })),
27
+ }, ["did", "lexicon", "iat", "nonce", "cid"]);
28
+ /** Envelope schema parameterised by the body's schema. */
29
+ export function envelopeSchema(body) {
30
+ return S.object({
31
+ header: HEADER_SCHEMA,
32
+ body,
33
+ signature: SIGNATURE_SCHEMA,
34
+ }, ["header", "body", "signature"]);
35
+ }
36
+ /** Envelope schema that accepts any body (used during pre-lexicon shape validation). */
37
+ export const BASE_ENVELOPE_SCHEMA = envelopeSchema(S.any());
38
+ export const AT_URI_PATTERN = /^at:\/\/did:kash:[1-9A-HJ-NP-Za-km-z]{32,48}\/[a-z0-9.-]+\/[A-Za-z0-9_-]+$/;
39
+ export const RECORD_REF_SCHEMA = S.object({
40
+ cid: S.string({ format: "cid" }),
41
+ uri: S.string({ pattern: AT_URI_PATTERN }),
42
+ }, ["cid", "uri"]);
43
+ //# sourceMappingURL=envelope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envelope.js","sourceRoot":"","sources":["../src/envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAkC,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,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAChD,IAAI,EAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;CAChE,EACD,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAC1C,CAAC;AAEF,0DAA0D;AAC1D,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,CAAC,CAAC,MAAM,CACb;QACE,MAAM,EAAE,aAAa;QACrB,IAAI;QACJ,SAAS,EAAE,gBAAgB;KAC5B,EACD,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,CAChC,CAAC;AACJ,CAAC;AAED,wFAAwF;AACxF,MAAM,CAAC,MAAM,oBAAoB,GAAiB,cAAc,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;AAkB1E,MAAM,CAAC,MAAM,cAAc,GAAG,4EAA4E,CAAC;AAE3G,MAAM,CAAC,MAAM,iBAAiB,GAAiB,CAAC,CAAC,MAAM,CACrD;IACE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAChC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;CAC3C,EACD,CAAC,KAAK,EAAE,KAAK,CAAC,CACf,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Social Extension — domain lexicons (Indusland-shaped but Indusland-agnostic).
3
+ *
4
+ * kash.social.post@1.0.0 — a post (text, media, optional Bento metadata).
5
+ * kash.social.interaction@1.0.0 — unified like / share / react event.
6
+ * kash.social.follow@1.0.0 — directed relationship between two DIDs.
7
+ *
8
+ * Import path: `@kashscript/lexicons/extensions/social`.
9
+ *
10
+ * This file is an **extension**: the Foundry core never auto-loads it.
11
+ * Consumers explicitly register `SOCIAL_EXTENSION` against their
12
+ * `LexiconRegistry` to opt in to social-domain validation.
13
+ *
14
+ * Data minimisation: every field that is not load-bearing for the specific
15
+ * action is optional.
16
+ */
17
+ import { type RecordRef } from "../envelope";
18
+ import type { LexiconDef } from "../registry";
19
+ import { type ObjectSchema } from "../schema";
20
+ export declare const KASH_SOCIAL_POST_NSID: "kash.social.post";
21
+ export declare const KASH_SOCIAL_POST_VERSION: {
22
+ readonly major: 1;
23
+ readonly minor: 0;
24
+ readonly patch: 0;
25
+ };
26
+ export declare const KASH_SOCIAL_POST_ID: "kash.social.post@1.0.0";
27
+ export type BentoAccent = "sun" | "poppy" | "sky" | "lilac" | "sage" | "rose";
28
+ export type BentoSize = "small" | "medium" | "large";
29
+ export interface BentoMeta {
30
+ readonly title?: string;
31
+ readonly accent?: BentoAccent;
32
+ readonly size?: BentoSize;
33
+ }
34
+ export type PostMediaMime = "image/jpeg" | "image/png" | "image/webp" | "image/avif" | "video/mp4" | "video/webm" | "audio/mpeg" | "audio/ogg";
35
+ export interface PostMediaRef {
36
+ readonly cid: string;
37
+ readonly mimeType: PostMediaMime;
38
+ readonly altText?: string;
39
+ readonly width?: number;
40
+ readonly height?: number;
41
+ readonly durationMs?: number;
42
+ }
43
+ export interface KashSocialPostBody {
44
+ readonly text?: string;
45
+ readonly media?: readonly PostMediaRef[];
46
+ readonly bento?: BentoMeta;
47
+ readonly replyTo?: RecordRef;
48
+ readonly repostOf?: RecordRef;
49
+ readonly mentions?: readonly string[];
50
+ readonly tags?: readonly string[];
51
+ readonly lang?: string;
52
+ }
53
+ export declare const KASH_SOCIAL_POST_BODY_SCHEMA: ObjectSchema;
54
+ export declare const KASH_SOCIAL_INTERACTION_NSID: "kash.social.interaction";
55
+ export declare const KASH_SOCIAL_INTERACTION_VERSION: {
56
+ readonly major: 1;
57
+ readonly minor: 0;
58
+ readonly patch: 0;
59
+ };
60
+ export declare const KASH_SOCIAL_INTERACTION_ID: "kash.social.interaction@1.0.0";
61
+ export type InteractionType = "like" | "share" | "react";
62
+ export interface KashSocialInteractionBody {
63
+ readonly type: InteractionType;
64
+ readonly target: RecordRef;
65
+ readonly reaction?: string;
66
+ }
67
+ export declare const KASH_SOCIAL_INTERACTION_BODY_SCHEMA: ObjectSchema;
68
+ export declare const KASH_SOCIAL_FOLLOW_NSID: "kash.social.follow";
69
+ export declare const KASH_SOCIAL_FOLLOW_VERSION: {
70
+ readonly major: 1;
71
+ readonly minor: 0;
72
+ readonly patch: 0;
73
+ };
74
+ export declare const KASH_SOCIAL_FOLLOW_ID: "kash.social.follow@1.0.0";
75
+ export interface KashSocialFollowBody {
76
+ readonly subject: string;
77
+ readonly subjectHandle?: string;
78
+ }
79
+ export declare const KASH_SOCIAL_FOLLOW_BODY_SCHEMA: ObjectSchema;
80
+ /** All Social-domain lexicons. Pass to `LexiconRegistry.registerAll()`. */
81
+ export declare const SOCIAL_EXTENSION: readonly LexiconDef[];
82
+ //# sourceMappingURL=social.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"social.d.ts","sourceRoot":"","sources":["../../src/extensions/social.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAK,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAMjD,eAAO,MAAM,qBAAqB,EAAM,kBAA2B,CAAC;AACpE,eAAO,MAAM,wBAAwB;;;;CAA4C,CAAC;AAClF,eAAO,MAAM,mBAAmB,EAAQ,wBAAiC,CAAC;AAE1E,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAC9E,MAAM,MAAM,SAAS,GAAK,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEvD,MAAM,WAAW,SAAS;IAC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