@orqenix-pro/mesh-delegation 0.5.0-phase-5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ All notable changes to this package will be documented in this file.
4
+
5
+ The format is based on https://keepachangelog.com/en/1.1.0/,
6
+ and this project adheres to https://semver.org/spec/v2.0.0.html.
7
+
8
+ ## [Unreleased]
package/LICENSE ADDED
@@ -0,0 +1,30 @@
1
+ Business Source License 1.1
2
+
3
+ Licensor: Milo Nguyen / Orqenix
4
+ Licensed Work: The Licensed Work is (c) 2026 Milo Nguyen / Orqenix
5
+ Change Date: 2030-06-03
6
+ Change License: Apache License, Version 2.0
7
+
8
+ Additional Use Grant:
9
+ You may make production use of the Licensed Work, provided that your use
10
+ does not include offering the Licensed Work as a hosted or managed service
11
+ to third parties.
12
+
13
+ Terms:
14
+
15
+ The Licensor hereby grants you the right to copy, modify, create derivative
16
+ works, redistribute, and make non-production use of the Licensed Work. The
17
+ Licensor may make additional rights available upon the occurrence of the
18
+ Change Date, at which time the Licensed Work will be made available under
19
+ the Change License.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27
+ DEALINGS IN THE SOFTWARE.
28
+
29
+ See the Business Source License 1.1 at https://mariadb.com/bsl11/ for
30
+ full terms and conditions.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # @orqenix-pro/mesh-delegation
2
+
3
+ Multi-hop delegation chains for the Orqenix mesh (Pro tier, BSL-1.1).
4
+
5
+ ## What OSS gives you (single-hop)
6
+
7
+ `@orqenix/mesh-routing` lets scope A query scope B if A has an active outbound link to B. One hop, no chaining.
8
+
9
+ ## What Pro adds
10
+
11
+ A `DelegationChain` lets A → B → C → D up to `maxDepth = 8`, where each step:
12
+ - Carries its own capability token (`tokenJti`)
13
+ - Narrows the cap set vs the previous step (cannot widen)
14
+ - Decrements `remainingHops` so anybody in the chain can refuse to forward past their limit
15
+
16
+ ## Invariants enforced
17
+
18
+ | Check | Function |
19
+ |-------|----------|
20
+ | Step[i].delegate == step[i+1].delegator | `validateChainLinkage` |
21
+ | chain.steps.length <= maxDepth | `validateDepth` |
22
+ | step[i+1].caps ⊆ step[i].caps | `validateCapNarrowing` |
23
+ | step[i].remainingHops == maxDepth - i | `validateRemainingHops` |
24
+
25
+ Charter gate: **G36-pro Mesh Delegation Chain**.
@@ -0,0 +1 @@
1
+ {"fileNames":["../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.array.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.object.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/typealiases.d.cts","../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.d.cts","../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/index.d.cts","../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/zoderror.d.cts","../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.d.cts","../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.d.cts","../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseutil.d.cts","../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/enumutil.d.cts","../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorutil.d.cts","../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/partialutil.d.cts","../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/standard-schema.d.cts","../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.d.cts","../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.d.cts","../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/index.d.cts","../../../node_modules/.pnpm/@orqenix+core@file+..+orqenix+packages+core_vfkkodkzzruxb6ko4e2mst24j4/node_modules/@orqenix/core/dist/scope-vmihx63u.d.ts","../../../node_modules/.pnpm/@orqenix+core@file+..+orqenix+packages+core_vfkkodkzzruxb6ko4e2mst24j4/node_modules/@orqenix/core/dist/config-ccrluavy.d.ts","../../../node_modules/.pnpm/@orqenix+core@file+..+orqenix+packages+core_vfkkodkzzruxb6ko4e2mst24j4/node_modules/@orqenix/core/dist/index-cw3kwbex.d.ts","../../../node_modules/.pnpm/@orqenix+core@file+..+orqenix+packages+core_vfkkodkzzruxb6ko4e2mst24j4/node_modules/@orqenix/core/dist/index-d_tqpb7y.d.ts","../../../node_modules/.pnpm/@orqenix+core@file+..+orqenix+packages+core_vfkkodkzzruxb6ko4e2mst24j4/node_modules/@orqenix/core/dist/index-dfkd5rhw.d.ts","../../../node_modules/.pnpm/@orqenix+core@file+..+orqenix+packages+core_vfkkodkzzruxb6ko4e2mst24j4/node_modules/@orqenix/core/dist/index-cznauncx.d.ts","../../../node_modules/.pnpm/@orqenix+core@file+..+orqenix+packages+core_vfkkodkzzruxb6ko4e2mst24j4/node_modules/@orqenix/core/dist/index-bjglc7be.d.ts","../../../node_modules/.pnpm/@orqenix+core@file+..+orqenix+packages+core_vfkkodkzzruxb6ko4e2mst24j4/node_modules/@orqenix/core/dist/index.d.ts","../../../node_modules/.pnpm/@orqenix+scope-identity@file+..+orqenix+packages+scope-identity_pohkmsf3edrntao67qzcnwqttu/node_modules/@orqenix/scope-identity/dist/contracts.d.ts","../../../node_modules/.pnpm/@orqenix+scope-identity@file+..+orqenix+packages+scope-identity_pohkmsf3edrntao67qzcnwqttu/node_modules/@orqenix/scope-identity/dist/keypair.d.ts","../../../node_modules/.pnpm/@orqenix+scope-identity@file+..+orqenix+packages+scope-identity_pohkmsf3edrntao67qzcnwqttu/node_modules/@orqenix/scope-identity/dist/scope-id.d.ts","../../../node_modules/.pnpm/@orqenix+scope-identity@file+..+orqenix+packages+scope-identity_pohkmsf3edrntao67qzcnwqttu/node_modules/@orqenix/scope-identity/dist/scope-yaml.d.ts","../../../node_modules/.pnpm/@orqenix+scope-identity@file+..+orqenix+packages+scope-identity_pohkmsf3edrntao67qzcnwqttu/node_modules/@orqenix/scope-identity/dist/init.d.ts","../../../node_modules/.pnpm/@orqenix+scope-identity@file+..+orqenix+packages+scope-identity_pohkmsf3edrntao67qzcnwqttu/node_modules/@orqenix/scope-identity/dist/index.d.ts","../../../node_modules/.pnpm/@orqenix+capability-tokens@file+..+orqenix+packages+capability-tokens_2ikcvfzxg36yirqq2tb2kodz6e/node_modules/@orqenix/capability-tokens/dist/contracts.d.ts","../../../node_modules/.pnpm/@orqenix+capability-tokens@file+..+orqenix+packages+capability-tokens_2ikcvfzxg36yirqq2tb2kodz6e/node_modules/@orqenix/capability-tokens/dist/format.d.ts","../../../node_modules/.pnpm/@orqenix+capability-tokens@file+..+orqenix+packages+capability-tokens_2ikcvfzxg36yirqq2tb2kodz6e/node_modules/@orqenix/capability-tokens/dist/signing.d.ts","../../../node_modules/.pnpm/@orqenix+capability-tokens@file+..+orqenix+packages+capability-tokens_2ikcvfzxg36yirqq2tb2kodz6e/node_modules/@orqenix/capability-tokens/dist/permissions.d.ts","../../../node_modules/.pnpm/@orqenix+capability-tokens@file+..+orqenix+packages+capability-tokens_2ikcvfzxg36yirqq2tb2kodz6e/node_modules/@orqenix/capability-tokens/dist/revocation.d.ts","../../../node_modules/.pnpm/@orqenix+capability-tokens@file+..+orqenix+packages+capability-tokens_2ikcvfzxg36yirqq2tb2kodz6e/node_modules/@orqenix/capability-tokens/dist/issuer.d.ts","../../../node_modules/.pnpm/@orqenix+capability-tokens@file+..+orqenix+packages+capability-tokens_2ikcvfzxg36yirqq2tb2kodz6e/node_modules/@orqenix/capability-tokens/dist/verifier.d.ts","../../../node_modules/.pnpm/@orqenix+capability-tokens@file+..+orqenix+packages+capability-tokens_2ikcvfzxg36yirqq2tb2kodz6e/node_modules/@orqenix/capability-tokens/dist/index.d.ts","../src/contracts.ts","../src/chain.ts","../../../node_modules/.pnpm/@orqenix+provenance@file+..+orqenix+packages+provenance_5obdljiwbbcf7nagkgd3kfxr6u/node_modules/@orqenix/provenance/dist/contracts.d.ts","../../../node_modules/.pnpm/@orqenix+storage-diff@file+..+orqenix+packages+storage-diff_r2gakjtcvj5ed3tl3vcuf6w5pa/node_modules/@orqenix/storage-diff/dist/contracts.d.ts","../../../node_modules/.pnpm/@orqenix+storage-diff@file+..+orqenix+packages+storage-diff_r2gakjtcvj5ed3tl3vcuf6w5pa/node_modules/@orqenix/storage-diff/dist/hash.d.ts","../../../node_modules/.pnpm/@orqenix+storage-diff@file+..+orqenix+packages+storage-diff_r2gakjtcvj5ed3tl3vcuf6w5pa/node_modules/@orqenix/storage-diff/dist/delta.d.ts","../../../node_modules/.pnpm/@orqenix+storage-diff@file+..+orqenix+packages+storage-diff_r2gakjtcvj5ed3tl3vcuf6w5pa/node_modules/@orqenix/storage-diff/dist/chain.d.ts","../../../node_modules/.pnpm/@orqenix+storage-diff@file+..+orqenix+packages+storage-diff_r2gakjtcvj5ed3tl3vcuf6w5pa/node_modules/@orqenix/storage-diff/dist/index.d.ts","../../../node_modules/.pnpm/@orqenix+provenance@file+..+orqenix+packages+provenance_5obdljiwbbcf7nagkgd3kfxr6u/node_modules/@orqenix/provenance/dist/chain.d.ts","../../../node_modules/.pnpm/@orqenix+provenance@file+..+orqenix+packages+provenance_5obdljiwbbcf7nagkgd3kfxr6u/node_modules/@orqenix/provenance/dist/index.d.ts","../../../node_modules/.pnpm/@orqenix+mesh-routing@file+..+orqenix+packages+mesh-routing_x2fw6usdp4775fygpnfdlsrj2i/node_modules/@orqenix/mesh-routing/dist/contracts.d.ts","../../../node_modules/.pnpm/@orqenix+mesh-routing@file+..+orqenix+packages+mesh-routing_x2fw6usdp4775fygpnfdlsrj2i/node_modules/@orqenix/mesh-routing/dist/transport.d.ts","../../../node_modules/.pnpm/@orqenix+scope-link@file+..+orqenix+packages+scope-link_mqxzzmie44eiymba2f3km2pdhi/node_modules/@orqenix/scope-link/dist/contracts.d.ts","../../../node_modules/.pnpm/@orqenix+storage-sqlite@file+..+orqenix+packages+storage-sqlite_yx5l6vutmwpbbrfbgyyoxeax3y/node_modules/@orqenix/storage-sqlite/dist/contracts.d.ts","../../../node_modules/.pnpm/@orqenix+storage-sqlite@file+..+orqenix+packages+storage-sqlite_yx5l6vutmwpbbrfbgyyoxeax3y/node_modules/@orqenix/storage-sqlite/dist/connection.d.ts","../../../node_modules/.pnpm/@orqenix+storage-sqlite@file+..+orqenix+packages+storage-sqlite_yx5l6vutmwpbbrfbgyyoxeax3y/node_modules/@orqenix/storage-sqlite/dist/migrations.d.ts","../../../node_modules/.pnpm/@orqenix+storage-sqlite@file+..+orqenix+packages+storage-sqlite_yx5l6vutmwpbbrfbgyyoxeax3y/node_modules/@orqenix/storage-sqlite/dist/vec.d.ts","../../../node_modules/.pnpm/@orqenix+storage-sqlite@file+..+orqenix+packages+storage-sqlite_yx5l6vutmwpbbrfbgyyoxeax3y/node_modules/@orqenix/storage-sqlite/dist/index.d.ts","../../../node_modules/.pnpm/@orqenix+scope-link@file+..+orqenix+packages+scope-link_mqxzzmie44eiymba2f3km2pdhi/node_modules/@orqenix/scope-link/dist/schema.d.ts","../../../node_modules/.pnpm/@orqenix+scope-link@file+..+orqenix+packages+scope-link_mqxzzmie44eiymba2f3km2pdhi/node_modules/@orqenix/scope-link/dist/store.d.ts","../../../node_modules/.pnpm/@orqenix+scope-link@file+..+orqenix+packages+scope-link_mqxzzmie44eiymba2f3km2pdhi/node_modules/@orqenix/scope-link/dist/index.d.ts","../../../node_modules/.pnpm/@orqenix+hooks@file+..+orqenix+packages+hooks_psw3qvtgw2b7wh7mycko2y5nui/node_modules/@orqenix/hooks/dist/contracts.d.ts","../../../node_modules/.pnpm/@orqenix+hooks@file+..+orqenix+packages+hooks_psw3qvtgw2b7wh7mycko2y5nui/node_modules/@orqenix/hooks/dist/bus.d.ts","../../../node_modules/.pnpm/@orqenix+hooks@file+..+orqenix+packages+hooks_psw3qvtgw2b7wh7mycko2y5nui/node_modules/@orqenix/hooks/dist/index.d.ts","../../../node_modules/.pnpm/@orqenix+telemetry@file+..+orqenix+packages+telemetry_idrhvir6tupgc4jojgtluyox4e/node_modules/@orqenix/telemetry/dist/contracts.d.ts","../../../node_modules/.pnpm/@orqenix+telemetry@file+..+orqenix+packages+telemetry_idrhvir6tupgc4jojgtluyox4e/node_modules/@orqenix/telemetry/dist/registry.d.ts","../../../node_modules/.pnpm/@orqenix+telemetry@file+..+orqenix+packages+telemetry_idrhvir6tupgc4jojgtluyox4e/node_modules/@orqenix/telemetry/dist/index.d.ts","../../../node_modules/.pnpm/@orqenix+mesh-routing@file+..+orqenix+packages+mesh-routing_x2fw6usdp4775fygpnfdlsrj2i/node_modules/@orqenix/mesh-routing/dist/router.d.ts","../../../node_modules/.pnpm/@orqenix+mesh-routing@file+..+orqenix+packages+mesh-routing_x2fw6usdp4775fygpnfdlsrj2i/node_modules/@orqenix/mesh-routing/dist/index.d.ts","../src/delegated-router.ts","../src/index.ts"],"fileIdsList":[[71,79],[86],[86,87,88,89,90,91,92],[71,86],[86,90],[72],[73],[71,73],[71,72,73,74,75,76,77,78],[115],[79],[115,116],[71,79,103],[104,105,121],[104,105,114,117,120],[104],[96,101],[96,102],[80,81,82,83,84],[80],[106,112,113],[111],[106,111],[97],[97,98,99,100],[107],[107,108,109,110],[107,108],[108],[118,119],[118],[70],[61,62],[58,59,61,63,64,69],[59,61],[69],[61],[58,59,61,64,65,66,67,68],[58,59,60],[94],[71,79,85,93],[94,95,103,114,122],[94,95,123]],"fileInfos":[{"version":"c430d44666289dae81f30fa7b2edebf186ecc91a2d4c71266ea6ae76388792e1","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"ee7bad0c15b58988daa84371e0b89d313b762ab83cb5b31b8a2d1162e8eb41c2","impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb0f136d372979348d59b3f5020b4cdb81b5504192b1cacff5d1fbba29378aa1","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a680117f487a4d2f30ea46f1b4b7f58bef1480456e18ba53ee85c2746eeca012","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d6d7ae4d1f1f3772e2a3cde568ed08991a8ae34a080ff1151af28b7f798e22ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"959d36cddf5e7d572a65045b876f2956c973a586da58e5d26cde519184fd9b8a","affectsGlobalScope":true,"impliedFormat":1},{"version":"965f36eae237dd74e6cca203a43e9ca801ce38824ead814728a2807b1910117d","affectsGlobalScope":true,"impliedFormat":1},{"version":"3925a6c820dcb1a06506c90b1577db1fdbf7705d65b62b99dce4be75c637e26b","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a3d63ef2b853447ec4f749d3f368ce642264246e02911fcb1590d8c161b8005","affectsGlobalScope":true,"impliedFormat":1},{"version":"8cdf8847677ac7d20486e54dd3fcf09eda95812ac8ace44b4418da1bbbab6eb8","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"d3cfde44f8089768ebb08098c96d01ca260b88bccf238d55eee93f1c620ff5a5","impliedFormat":1},{"version":"293eadad9dead44c6fd1db6de552663c33f215c55a1bfa2802a1bceed88ff0ec","impliedFormat":1},{"version":"833e92c058d033cde3f29a6c7603f517001d1ddd8020bc94d2067a3bc69b2a8e","impliedFormat":1},{"version":"08b2fae7b0f553ad9f79faec864b179fc58bc172e295a70943e8585dd85f600c","impliedFormat":1},{"version":"f12edf1672a94c578eca32216839604f1e1c16b40a1896198deabf99c882b340","impliedFormat":1},{"version":"e3498cf5e428e6c6b9e97bd88736f26d6cf147dedbfa5a8ad3ed8e05e059af8a","impliedFormat":1},{"version":"dba3f34531fd9b1b6e072928b6f885aa4d28dd6789cbd0e93563d43f4b62da53","impliedFormat":1},{"version":"f672c876c1a04a223cf2023b3d91e8a52bb1544c576b81bf64a8fec82be9969c","impliedFormat":1},{"version":"e4b03ddcf8563b1c0aee782a185286ed85a255ce8a30df8453aade2188bbc904","impliedFormat":1},{"version":"2329d90062487e1eaca87b5e06abcbbeeecf80a82f65f949fd332cfcf824b87b","impliedFormat":1},{"version":"25b3f581e12ede11e5739f57a86e8668fbc0124f6649506def306cad2c59d262","impliedFormat":1},{"version":"4fdb529707247a1a917a4626bfb6a293d52cd8ee57ccf03830ec91d39d606d6d","impliedFormat":1},{"version":"a9ebb67d6bbead6044b43714b50dcb77b8f7541ffe803046fdec1714c1eba206","impliedFormat":1},{"version":"5780b706cece027f0d4444fbb4e1af62dc51e19da7c3d3719f67b22b033859b9","impliedFormat":1},{"version":"302aef7d0db852f388ed3a5956f397bef07bb1c9557e0f529585810a9fd7b20f","impliedFormat":99},{"version":"a084f13924439b0ad7fec5a5c35794d6f35fed80411f36e775e4e2a29c7fc627","impliedFormat":99},{"version":"4be8fe3d4f627df14d1dd811072ed240928961d82335b405be7546ac538db843","impliedFormat":99},{"version":"97c4c3ea2015025e2b434b3b1ad0133253399286a2f1b14b2e7d76346256971b","impliedFormat":99},{"version":"5cdbf47f4ccd6da35761306ab01e37614fe49f0fb7116a2f6607da3c9c537b1d","impliedFormat":99},{"version":"bfa9414567c4c106f680cb8b6bdafaf1175d23092282a2e1dda5f318e0895b98","impliedFormat":99},{"version":"f37f0136cc0a5734d4a62244ae2052a3f37e9181aedde6e4596cef7bb11387bd","impliedFormat":99},{"version":"69aef1156107de01308ed1ae43ac37c7d5e12e1b05a47f7665cb99c10ae04321","impliedFormat":99},{"version":"199911c1777dde46e77528a78f9ed34aef365043ad8e1a2c87295dabb9749d64","impliedFormat":99},{"version":"cd42d6a1674231e31ac423b1decab5ceedbe2f4e57aecfbd7dd6f5ffa7603a9c","impliedFormat":99},{"version":"6d555d67b2edf021de8ce3b1b0bb0a7e43ec5f73947c43fad49d5b77775e7a37","impliedFormat":99},{"version":"fb34ef99e03f9d16b32fd9f6a15fd5900cdc6048af4a65f648e51123f08c80f1","impliedFormat":99},{"version":"bbd3db59bbad7d6b2a64b96b5bee680894667041ce271567f0ac5c93b1d61e2a","impliedFormat":99},{"version":"b5cf1e5e6233b53eb1bb06b55c7951d0561fd5ab06919b31c138e35d7f2fcd33","impliedFormat":99},{"version":"7dbcf650378e007562bcff2db05c9f1071d5d09d70ad9d401e3aa6f1c1070729","impliedFormat":99},{"version":"75649977a1f6b3cb7d75871d3ddb42635865307334ba93a9b8e7b6631037db22","impliedFormat":99},{"version":"9932f6ad87acd0c290a768e996646c226a7fc33377d94acfbabc75f82bbd9b94","impliedFormat":99},{"version":"c775fdcfd8cf9a28700c92d75bf79475d620ae50a91b29099aeebe7db7163071","impliedFormat":99},{"version":"3ff25fac756aa6f1cbe30190964b73cba8bf9f9a312d54da7a30dbaaf3bba5c4","impliedFormat":99},{"version":"0490f5adad34384bb31abfaba264dc01c3274442a825e7076107ec7448cdd475","impliedFormat":99},{"version":"426fbaf5e35226628805f53fcad3900f0bf14852a817a231c9129c412e98c5c0","impliedFormat":99},{"version":"2dff5cc7d41600d03239eb45d34642fc8342a0a605c5502edc563f63e08150e4","impliedFormat":99},{"version":"169866451afd3748fe16f3003cff180fe0c43d8afa9f144bfde45074e492f986","signature":"b269f9dcbd4a14d8c67ca4083221a263a57470a239c50c3e724d1233b7796f50"},{"version":"87bfdf2f77de18fb8b38841758e38a6b5a30a834d8f30d73c14c033acb966d4e","signature":"c479442f6743e93f394767c3d952410c0030d19f1915dbfb5871598811ec06ec"},{"version":"1adff29ca790a950e2284b2f9493de7d7153cb51af9c288ec9219cfbf2da2040","impliedFormat":99},{"version":"51bc80eb4eadc6e93d793a09bee1768bc5cc8af29ff670d968745137493e6b1a","impliedFormat":99},{"version":"3cce49930e2297ca9aebb4220701f177c4b711df60ca68b5ff5bb6a9f106b877","impliedFormat":99},{"version":"b81a2020e9977059d8948867e67c49e38a924aa9f290b549c540f50a38cbce09","impliedFormat":99},{"version":"5df52c0e613a2703c9ce3ec4ce1aa8bf9dd2de0e6cca921a48898dbfe57a616b","impliedFormat":99},{"version":"73489fb85ca238297d1f63c635cbbc75605d02d2015dd5d9338b9b6a4c6ad613","impliedFormat":99},{"version":"0e07ac45b4b0cdc25f8d0f29f4e8479767415ad1c626395b39f768eedd0665cf","impliedFormat":99},{"version":"e0f252b76c498f347fc4c41d7ba56b4f5be2aff742465775fcd507f531d58c3c","impliedFormat":99},{"version":"ec59a39fcd3f432ec9c45fd0c5712611ad6da886495b187bd9b439068434a7df","impliedFormat":99},{"version":"86e14dacfb1489106db2b9970f052ef96225436f55869de4c9271f43bd698668","impliedFormat":99},{"version":"617f224353b5c40132c8c2a0eabad7991817e50824be7db73da71082d0846aed","impliedFormat":99},{"version":"acfb8dbb3d8e4ab6c2fdb4a53badff2de7bb237fb1cbb05ac54b4e121e27a756","impliedFormat":99},{"version":"8b05bcd7316b13b3a42d10bfb7c3575bdbb50fb56d010c129a4cba95ef436344","impliedFormat":99},{"version":"c8b86a664b7059a24e629a4367ad055c20afd5168a01b9c69458909b9039cb72","impliedFormat":99},{"version":"8b8cf6e2d7928a35319683b0e8b30c67b5e01b69b31b7604dfa5424fbaafa42f","impliedFormat":99},{"version":"56a9ca5b75fd29f4434fbc12094b2ea204aa4deceda5bae4cc232807c548c455","impliedFormat":99},{"version":"3a6e9910af0744f538191a20286880fb8f8b868f93ee81c35bb7e9d22a1fe9a7","impliedFormat":99},{"version":"bb6d5bbdaffdf168f34e5981ab796d067eaa5f4efd77b8fa21170159c57a76a6","impliedFormat":99},{"version":"8e30bd47b4d65184986a9f79dc4d129d50fd8a71fd6dcd1f49daedee8a9acc83","impliedFormat":99},{"version":"1949cfbe64ce25be587474715d887291993d77fd39a7a8380cfba5d754d0415e","impliedFormat":99},{"version":"41e1030cf76168d44090d860478076fcb5927b24de08104ca81344a4bb71572b","impliedFormat":99},{"version":"97a0aa5526547386db45a38daad4573b6dbfd866054d7e97f2c108e383819496","impliedFormat":99},{"version":"ae06dd47eb8e785f41223eef23dc3a58041dc9e8aac1fbd21cd07adc536d6c7f","impliedFormat":99},{"version":"bc805bcb4b26ee831166b2d55e2bf3b19d3ded9edd7985d2c6c825cd73e172c6","impliedFormat":99},{"version":"873b6edec516e4b8c322fddd152e2926b81d46a43bc10fa7518b38bbe26b9108","impliedFormat":99},{"version":"3176f31ba92c7d2d5fa607879a61ff773490e3ad238108811ad00e310a88aec0","impliedFormat":99},{"version":"d65a4d75eec3770fb522fab486daf5d62d2ae86aae60ea7264e1145b32db12a6","impliedFormat":99},{"version":"dc7b7a91573b7dca2e6e09cad2d1903922046f8379d995dc0f996dfac62944a3","signature":"a7691922ab8be3dd693a2dbb650da9c5cfd392484174cff5c8b030753937acc4"},{"version":"a3e4d9ea061a96f3b1ab497399101227de9370a871bff0982cba9b50e1016e9c","signature":"58ebe0d9b5631ff7121a2fac6035d6c9399f8743558294384125d731ba7cf9ff"}],"root":[94,95,123,124],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationMap":true,"esModuleInterop":true,"exactOptionalPropertyTypes":false,"module":7,"noFallthroughCasesInSwitch":true,"noImplicitAny":true,"noImplicitReturns":true,"noUncheckedIndexedAccess":true,"outDir":"./","rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":9,"tsBuildInfoFile":"./.tsbuildinfo","verbatimModuleSyntax":false},"referencedMap":[[86,1],[87,2],[93,3],[91,2],[89,2],[90,4],[88,2],[92,5],[78,6],[74,7],[75,6],[76,8],[79,9],[116,10],[115,11],[117,12],[104,13],[122,14],[121,15],[105,16],[102,17],[96,1],[103,18],[80,1],[85,19],[84,20],[81,20],[82,20],[83,20],[106,1],[114,21],[112,22],[113,23],[100,24],[97,11],[98,24],[101,25],[108,26],[107,11],[111,27],[109,28],[110,29],[118,11],[120,30],[119,31],[71,32],[63,33],[70,34],[64,35],[67,36],[60,32],[62,37],[69,38],[61,39],[95,40],[94,41],[123,42],[124,43]],"latestChangedDtsFile":"./delegated-router.d.ts","version":"5.9.3"}
@@ -0,0 +1,15 @@
1
+ import { type DelegationChain, type DelegationStep } from './contracts.js';
2
+ export declare function validateChainLinkage(chain: DelegationChain): void;
3
+ export declare function validateDepth(chain: DelegationChain): void;
4
+ export declare function validateCapNarrowing(chain: DelegationChain): void;
5
+ export declare function validateRemainingHops(chain: DelegationChain): void;
6
+ export declare function validate(chain: DelegationChain): void;
7
+ export interface AppendStepInput {
8
+ delegateScopeId: string;
9
+ tokenJti: string;
10
+ caps: string[];
11
+ delegatedAt: string;
12
+ }
13
+ export declare function appendStep(chain: DelegationChain, input: AppendStepInput): DelegationChain;
14
+ export declare function startChain(originScopeId: string, firstStep: Omit<DelegationStep, 'delegatorScopeId' | 'remainingHops'>, maxDepth: number): DelegationChain;
15
+ //# sourceMappingURL=chain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,eAAe,EAAE,KAAK,cAAc,EAC1C,MAAM,gBAAgB,CAAC;AAExB,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAQjE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAI1D;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAWjE;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CASlE;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAMrD;AAED,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,GAAG,eAAe,CA8B1F;AAED,wBAAgB,UAAU,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,kBAAkB,GAAG,eAAe,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,CAgB1J"}
package/dist/chain.js ADDED
@@ -0,0 +1,90 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // @bc CS-pro-006 Chain Validation
3
+ // @gate G36-pro.1, G36-pro.2
4
+ import { DelegationChainSchema, DelegationStepSchema, DelegationChainBrokenError, DelegationDepthExceededError, CapabilityNarrowingViolation, } from './contracts.js';
5
+ export function validateChainLinkage(chain) {
6
+ for (let i = 0; i < chain.steps.length - 1; i++) {
7
+ if (chain.steps[i].delegateScopeId !== chain.steps[i + 1].delegatorScopeId) {
8
+ throw new DelegationChainBrokenError(`step ${i + 1} delegator ${chain.steps[i + 1].delegatorScopeId} does not match step ${i} delegate ${chain.steps[i].delegateScopeId}`);
9
+ }
10
+ }
11
+ }
12
+ export function validateDepth(chain) {
13
+ if (chain.steps.length > chain.maxDepth) {
14
+ throw new DelegationDepthExceededError(chain.steps.length, chain.maxDepth);
15
+ }
16
+ }
17
+ export function validateCapNarrowing(chain) {
18
+ for (let i = 1; i < chain.steps.length; i++) {
19
+ const parent = new Set(chain.steps[i - 1].caps);
20
+ for (const cap of chain.steps[i].caps) {
21
+ if (!parent.has(cap)) {
22
+ throw new CapabilityNarrowingViolation(`step ${i} introduces capability "${cap}" not present in parent step ${i - 1}`);
23
+ }
24
+ }
25
+ }
26
+ }
27
+ export function validateRemainingHops(chain) {
28
+ for (let i = 0; i < chain.steps.length; i++) {
29
+ const expected = chain.maxDepth - i;
30
+ if (chain.steps[i].remainingHops !== expected) {
31
+ throw new DelegationChainBrokenError(`step ${i} remainingHops ${chain.steps[i].remainingHops} expected ${expected}`);
32
+ }
33
+ }
34
+ }
35
+ export function validate(chain) {
36
+ DelegationChainSchema.parse(chain);
37
+ validateDepth(chain);
38
+ validateChainLinkage(chain);
39
+ validateCapNarrowing(chain);
40
+ validateRemainingHops(chain);
41
+ }
42
+ export function appendStep(chain, input) {
43
+ const last = chain.steps[chain.steps.length - 1];
44
+ if (last.remainingHops <= 0) {
45
+ throw new DelegationDepthExceededError(chain.steps.length, chain.maxDepth);
46
+ }
47
+ if (chain.steps.length >= chain.maxDepth) {
48
+ throw new DelegationDepthExceededError(chain.steps.length, chain.maxDepth);
49
+ }
50
+ // cap narrowing: new step's caps must subset last step's caps
51
+ const parentCaps = new Set(last.caps);
52
+ for (const c of input.caps) {
53
+ if (!parentCaps.has(c)) {
54
+ throw new CapabilityNarrowingViolation(`new step introduces capability "${c}" not in parent`);
55
+ }
56
+ }
57
+ const newStep = DelegationStepSchema.parse({
58
+ delegatorScopeId: last.delegateScopeId,
59
+ delegateScopeId: input.delegateScopeId,
60
+ tokenJti: input.tokenJti,
61
+ caps: input.caps,
62
+ delegatedAt: input.delegatedAt,
63
+ remainingHops: last.remainingHops - 1,
64
+ });
65
+ const newChain = {
66
+ steps: [...chain.steps, newStep],
67
+ originScopeId: chain.originScopeId,
68
+ maxDepth: chain.maxDepth,
69
+ };
70
+ validate(newChain);
71
+ return newChain;
72
+ }
73
+ export function startChain(originScopeId, firstStep, maxDepth) {
74
+ const step = DelegationStepSchema.parse({
75
+ delegatorScopeId: originScopeId,
76
+ delegateScopeId: firstStep.delegateScopeId,
77
+ tokenJti: firstStep.tokenJti,
78
+ caps: firstStep.caps,
79
+ delegatedAt: firstStep.delegatedAt,
80
+ remainingHops: maxDepth,
81
+ });
82
+ const chain = {
83
+ steps: [step],
84
+ originScopeId,
85
+ maxDepth,
86
+ };
87
+ validate(chain);
88
+ return chain;
89
+ }
90
+ //# sourceMappingURL=chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.js","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kCAAkC;AAClC,6BAA6B;AAE7B,OAAO,EACL,qBAAqB,EAAE,oBAAoB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,EAAE,SAAS,CAAC,eAAe;QAC1C,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,WAAW,EAAE,SAAS,CAAC,WAAW;QAClC,aAAa,EAAE,QAAQ;KACxB,CAAC,CAAC;IACH,MAAM,KAAK,GAAoB;QAC7B,KAAK,EAAE,CAAC,IAAI,CAAC;QACb,aAAa;QACb,QAAQ;KACT,CAAC;IACF,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChB,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,115 @@
1
+ import { z } from 'zod';
2
+ import { OrqenixError } from '@orqenix/core';
3
+ export declare const DelegationStepSchema: z.ZodObject<{
4
+ delegatorScopeId: z.ZodString;
5
+ delegateScopeId: z.ZodString;
6
+ tokenJti: z.ZodString;
7
+ caps: z.ZodArray<z.ZodString, "many">;
8
+ delegatedAt: z.ZodString;
9
+ remainingHops: z.ZodNumber;
10
+ }, "strict", z.ZodTypeAny, {
11
+ delegatorScopeId: string;
12
+ delegateScopeId: string;
13
+ tokenJti: string;
14
+ caps: string[];
15
+ delegatedAt: string;
16
+ remainingHops: number;
17
+ }, {
18
+ delegatorScopeId: string;
19
+ delegateScopeId: string;
20
+ tokenJti: string;
21
+ caps: string[];
22
+ delegatedAt: string;
23
+ remainingHops: number;
24
+ }>;
25
+ export type DelegationStep = z.infer<typeof DelegationStepSchema>;
26
+ export declare const DelegationChainSchema: z.ZodEffects<z.ZodObject<{
27
+ steps: z.ZodArray<z.ZodObject<{
28
+ delegatorScopeId: z.ZodString;
29
+ delegateScopeId: z.ZodString;
30
+ tokenJti: z.ZodString;
31
+ caps: z.ZodArray<z.ZodString, "many">;
32
+ delegatedAt: z.ZodString;
33
+ remainingHops: z.ZodNumber;
34
+ }, "strict", z.ZodTypeAny, {
35
+ delegatorScopeId: string;
36
+ delegateScopeId: string;
37
+ tokenJti: string;
38
+ caps: string[];
39
+ delegatedAt: string;
40
+ remainingHops: number;
41
+ }, {
42
+ delegatorScopeId: string;
43
+ delegateScopeId: string;
44
+ tokenJti: string;
45
+ caps: string[];
46
+ delegatedAt: string;
47
+ remainingHops: number;
48
+ }>, "many">;
49
+ originScopeId: z.ZodString;
50
+ maxDepth: z.ZodNumber;
51
+ }, "strict", z.ZodTypeAny, {
52
+ steps: {
53
+ delegatorScopeId: string;
54
+ delegateScopeId: string;
55
+ tokenJti: string;
56
+ caps: string[];
57
+ delegatedAt: string;
58
+ remainingHops: number;
59
+ }[];
60
+ originScopeId: string;
61
+ maxDepth: number;
62
+ }, {
63
+ steps: {
64
+ delegatorScopeId: string;
65
+ delegateScopeId: string;
66
+ tokenJti: string;
67
+ caps: string[];
68
+ delegatedAt: string;
69
+ remainingHops: number;
70
+ }[];
71
+ originScopeId: string;
72
+ maxDepth: number;
73
+ }>, {
74
+ steps: {
75
+ delegatorScopeId: string;
76
+ delegateScopeId: string;
77
+ tokenJti: string;
78
+ caps: string[];
79
+ delegatedAt: string;
80
+ remainingHops: number;
81
+ }[];
82
+ originScopeId: string;
83
+ maxDepth: number;
84
+ }, {
85
+ steps: {
86
+ delegatorScopeId: string;
87
+ delegateScopeId: string;
88
+ tokenJti: string;
89
+ caps: string[];
90
+ delegatedAt: string;
91
+ remainingHops: number;
92
+ }[];
93
+ originScopeId: string;
94
+ maxDepth: number;
95
+ }>;
96
+ export type DelegationChain = z.infer<typeof DelegationChainSchema>;
97
+ export interface DelegatedQueryInput {
98
+ text: string;
99
+ k?: number;
100
+ timeoutMs?: number;
101
+ chain: DelegationChain;
102
+ }
103
+ export declare class DelegationDepthExceededError extends OrqenixError {
104
+ constructor(depth: number, max: number);
105
+ }
106
+ export declare class DelegationChainBrokenError extends OrqenixError {
107
+ constructor(reason: string);
108
+ }
109
+ export declare class CapabilityNarrowingViolation extends OrqenixError {
110
+ constructor(reason: string);
111
+ }
112
+ export declare class DelegationUnauthorizedError extends OrqenixError {
113
+ constructor(reason: string);
114
+ }
115
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAI7C,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;EAOtB,CAAC;AACZ,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,eAAe,CAAC;CACxB;AAED,qBAAa,4BAA6B,SAAQ,YAAY;gBAChD,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;CACvC;AACD,qBAAa,0BAA2B,SAAQ,YAAY;gBAC9C,MAAM,EAAE,MAAM;CAC3B;AACD,qBAAa,4BAA6B,SAAQ,YAAY;gBAChD,MAAM,EAAE,MAAM;CAC3B;AACD,qBAAa,2BAA4B,SAAQ,YAAY;gBAC/C,MAAM,EAAE,MAAM;CAC3B"}
@@ -0,0 +1,35 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // @bc CS-pro-006 Mesh Delegation Contracts
3
+ // @gate G36-pro
4
+ import { z } from 'zod';
5
+ import { OrqenixError } from '@orqenix/core';
6
+ import { SCOPE_ID_PATTERN } from '@orqenix/scope-identity';
7
+ import { TOKEN_ID_PATTERN } from '@orqenix/capability-tokens';
8
+ export const DelegationStepSchema = z.object({
9
+ delegatorScopeId: z.string().regex(SCOPE_ID_PATTERN),
10
+ delegateScopeId: z.string().regex(SCOPE_ID_PATTERN),
11
+ tokenJti: z.string().regex(TOKEN_ID_PATTERN),
12
+ caps: z.array(z.string()).min(1).max(64),
13
+ delegatedAt: z.string(),
14
+ remainingHops: z.number().int().min(0).max(8),
15
+ }).strict();
16
+ export const DelegationChainSchema = z.object({
17
+ steps: z.array(DelegationStepSchema).min(1).max(8),
18
+ originScopeId: z.string().regex(SCOPE_ID_PATTERN),
19
+ maxDepth: z.number().int().min(1).max(8),
20
+ }).strict().refine((c) => c.steps[0].delegatorScopeId === c.originScopeId, {
21
+ message: 'first step delegator must equal originScopeId',
22
+ });
23
+ export class DelegationDepthExceededError extends OrqenixError {
24
+ constructor(depth, max) { super(`delegation depth ${depth} exceeds max ${max}`, 'DELEGATION_DEPTH'); }
25
+ }
26
+ export class DelegationChainBrokenError extends OrqenixError {
27
+ constructor(reason) { super(`delegation chain broken: ${reason}`, 'DELEGATION_CHAIN'); }
28
+ }
29
+ export class CapabilityNarrowingViolation extends OrqenixError {
30
+ constructor(reason) { super(`capability narrowing violation: ${reason}`, 'DELEGATION_NARROW'); }
31
+ }
32
+ export class DelegationUnauthorizedError extends OrqenixError {
33
+ constructor(reason) { super(`delegation unauthorized: ${reason}`, 'DELEGATION_UNAUTH'); }
34
+ }
35
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,2CAA2C;AAC3C,gBAAgB;AAEhB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE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AAQ,YAAY;IAC5D,YAAY,KAAa,EAAE,GAAW,IAAI,KAAK,CAAC,oBAAoB,KAAK,gBAAgB,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC;CACvH;AACD,MAAM,OAAO,0BAA2B,SAAQ,YAAY;IAC1D,YAAY,MAAc,IAAI,KAAK,CAAC,4BAA4B,MAAM,EAAE,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC;CACjG;AACD,MAAM,OAAO,4BAA6B,SAAQ,YAAY;IAC5D,YAAY,MAAc,IAAI,KAAK,CAAC,mCAAmC,MAAM,EAAE,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;CACzG;AACD,MAAM,OAAO,2BAA4B,SAAQ,YAAY;IAC3D,YAAY,MAAc,IAAI,KAAK,CAAC,4BAA4B,MAAM,EAAE,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;CAClG"}
@@ -0,0 +1,32 @@
1
+ import type { MeshRouter, MeshQueryResponse } from '@orqenix/mesh-routing';
2
+ import type { ScopeLinkStore } from '@orqenix/scope-link';
3
+ import { type DelegatedQueryInput, type DelegationChain } from './contracts.js';
4
+ export interface DelegatedQueryResponse extends MeshQueryResponse {
5
+ chainHops: number;
6
+ originScopeId: string;
7
+ delegationChain: DelegationChain;
8
+ }
9
+ export interface DelegatedMeshRouterOptions {
10
+ localScopeId: string;
11
+ baseRouter: MeshRouter;
12
+ linkStore: ScopeLinkStore;
13
+ now?: () => string;
14
+ }
15
+ export declare class DelegatedMeshRouter {
16
+ private readonly localScopeId;
17
+ private readonly baseRouter;
18
+ private readonly linkStore;
19
+ private readonly now;
20
+ constructor(opts: DelegatedMeshRouterOptions);
21
+ private tagHitsWithChain;
22
+ delegatedQuery(input: DelegatedQueryInput): Promise<DelegatedQueryResponse>;
23
+ /**
24
+ * Forward a delegated query received from upstream. Validates chain and either:
25
+ * - resolves locally (if this scope is the final delegate), or
26
+ * - extends the chain by 1 hop toward the next link (if remaining hops allow it).
27
+ */
28
+ forwardQuery(input: DelegatedQueryInput, nextDelegateScopeId?: string): Promise<DelegatedQueryResponse>;
29
+ getMaxAllowedDepth(): number;
30
+ assertChainSane(chain: DelegationChain): void;
31
+ }
32
+ //# sourceMappingURL=delegated-router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegated-router.d.ts","sourceRoot":"","sources":["../src/delegated-router.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAgB,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK1D,OAAO,EACL,KAAK,mBAAmB,EAAE,KAAK,eAAe,EAE/C,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,eAAe,CAAC;CAClC;AAED,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,cAAc,CAAC;IAC1B,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiB;IAC3C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;gBAEvB,IAAI,EAAE,0BAA0B;IAO5C,OAAO,CAAC,gBAAgB;IAqBlB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IA6BjF;;;;OAIG;IACG,YAAY,CAAC,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAiD7G,kBAAkB,IAAI,MAAM;IAE5B,eAAe,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;CAI9C"}
@@ -0,0 +1,115 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // @bc CS-pro-006 Delegated Router
3
+ // @gate G36-pro.3, G36-pro.4
4
+ import { appendTag } from '@orqenix/provenance';
5
+ import { validate, validateDepth, } from './chain.js';
6
+ import { DelegationDepthExceededError, DelegationUnauthorizedError, } from './contracts.js';
7
+ export class DelegatedMeshRouter {
8
+ localScopeId;
9
+ baseRouter;
10
+ linkStore;
11
+ now;
12
+ constructor(opts) {
13
+ this.localScopeId = opts.localScopeId;
14
+ this.baseRouter = opts.baseRouter;
15
+ this.linkStore = opts.linkStore;
16
+ this.now = opts.now ?? (() => new Date().toISOString());
17
+ }
18
+ tagHitsWithChain(hits, chain) {
19
+ return hits.map((h) => {
20
+ let provenance = h.provenance;
21
+ // Append a tag for each delegation step so downstream verifiers see the lineage.
22
+ for (const step of chain.steps) {
23
+ try {
24
+ provenance = appendTag(provenance, {
25
+ sourceScopeId: step.delegateScopeId,
26
+ sourceKind: 'mesh',
27
+ tokenJti: step.tokenJti,
28
+ producedAt: step.delegatedAt,
29
+ });
30
+ }
31
+ catch {
32
+ // if the chain rejects (broken provenance), keep original
33
+ return h;
34
+ }
35
+ }
36
+ return { ...h, provenance };
37
+ });
38
+ }
39
+ async delegatedQuery(input) {
40
+ validate(input.chain);
41
+ if (input.chain.steps[0].delegatorScopeId !== this.localScopeId) {
42
+ throw new DelegationUnauthorizedError(`chain originates at ${input.chain.steps[0].delegatorScopeId}, not local ${this.localScopeId}`);
43
+ }
44
+ // Determine the actual target (last delegate in chain)
45
+ const finalStep = input.chain.steps[input.chain.steps.length - 1];
46
+ const targetScopeId = finalStep.delegateScopeId;
47
+ const base = await this.baseRouter.query({
48
+ text: input.text,
49
+ k: input.k ?? 5,
50
+ timeoutMs: input.timeoutMs ?? 5_000,
51
+ targetScopeIds: [targetScopeId],
52
+ });
53
+ const taggedHits = this.tagHitsWithChain(base.hits, input.chain);
54
+ return {
55
+ ...base,
56
+ hits: taggedHits,
57
+ chainHops: input.chain.steps.length,
58
+ originScopeId: input.chain.originScopeId,
59
+ delegationChain: input.chain,
60
+ };
61
+ }
62
+ /**
63
+ * Forward a delegated query received from upstream. Validates chain and either:
64
+ * - resolves locally (if this scope is the final delegate), or
65
+ * - extends the chain by 1 hop toward the next link (if remaining hops allow it).
66
+ */
67
+ async forwardQuery(input, nextDelegateScopeId) {
68
+ validate(input.chain);
69
+ const finalStep = input.chain.steps[input.chain.steps.length - 1];
70
+ const amIFinal = finalStep.delegateScopeId === this.localScopeId;
71
+ if (amIFinal && !nextDelegateScopeId) {
72
+ // Resolve locally; behave as if base router had this scope as the target.
73
+ const base = await this.baseRouter.query({
74
+ text: input.text,
75
+ k: input.k ?? 5,
76
+ timeoutMs: input.timeoutMs ?? 5_000,
77
+ });
78
+ const taggedHits = this.tagHitsWithChain(base.hits, input.chain);
79
+ return {
80
+ ...base,
81
+ hits: taggedHits,
82
+ chainHops: input.chain.steps.length,
83
+ originScopeId: input.chain.originScopeId,
84
+ delegationChain: input.chain,
85
+ };
86
+ }
87
+ if (!nextDelegateScopeId) {
88
+ throw new DelegationUnauthorizedError(`local scope ${this.localScopeId} is not the final delegate and no next hop provided`);
89
+ }
90
+ if (finalStep.remainingHops <= 0) {
91
+ throw new DelegationDepthExceededError(input.chain.steps.length, input.chain.maxDepth);
92
+ }
93
+ // Forward to the next hop by querying baseRouter with the next scope as the explicit target.
94
+ const base = await this.baseRouter.query({
95
+ text: input.text,
96
+ k: input.k ?? 5,
97
+ timeoutMs: input.timeoutMs ?? 5_000,
98
+ targetScopeIds: [nextDelegateScopeId],
99
+ });
100
+ const taggedHits = this.tagHitsWithChain(base.hits, input.chain);
101
+ return {
102
+ ...base,
103
+ hits: taggedHits,
104
+ chainHops: input.chain.steps.length,
105
+ originScopeId: input.chain.originScopeId,
106
+ delegationChain: input.chain,
107
+ };
108
+ }
109
+ getMaxAllowedDepth() { return 8; }
110
+ assertChainSane(chain) {
111
+ validate(chain);
112
+ validateDepth(chain);
113
+ }
114
+ }
115
+ //# sourceMappingURL=delegated-router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegated-router.js","sourceRoot":"","sources":["../src/delegated-router.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kCAAkC;AAClC,6BAA6B;AAI7B,OAAO,EAAW,SAAS,EAAwB,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EACL,QAAQ,EAAE,aAAa,GACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,4BAA4B,EAAE,2BAA2B,GAC1D,MAAM,gBAAgB,CAAC;AAexB,MAAM,OAAO,mBAAmB;IACb,YAAY,CAAS;IACrB,UAAU,CAAa;IACvB,SAAS,CAAiB;IAC1B,GAAG,CAAe;IAEnC,YAAY,IAAgC;QAC1C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IAC1D,CAAC;IAEO,gBAAgB,CAAC,IAAoB,EAAE,KAAsB;QACnE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YACpB,IAAI,UAAU,GAAoB,CAAC,CAAC,UAAU,CAAC;YAC/C,iFAAiF;YACjF,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBAC/B,IAAI,CAAC;oBACH,UAAU,GAAG,SAAS,CAAC,UAAU,EAAE;wBACjC,aAAa,EAAE,IAAI,CAAC,eAAe;wBACnC,UAAU,EAAE,MAAM;wBAClB,QAAQ,EAAE,IAAI,CA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AAI,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,4BAA4B,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACzF,CAAC;QAED,6FAA6F;QAC7F,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;YACvC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC;YACf,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,KAAK;YACnC,cAAc,EAAE,CAAC,mBAAmB,CAAC;SACtC,CAAC,CAAC;QACH,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QACjE,OAAO;YACL,GAAG,IAAI;YACP,IAAI,EAAE,UAAU;YAChB,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM;YACnC,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,aAAa;YACxC,eAAe,EAAE,KAAK,CAAC,KAAK;SAC7B,CAAC;IACJ,CAAC;IAED,kBAAkB,KAAa,OAAO,CAAC,CAAC,CAAC,CAAC;IAE1C,eAAe,CAAC,KAAsB;QACpC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAChB,aAAa,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ export * from './contracts.js';
2
+ export * from './chain.js';
3
+ export * from './delegated-router.js';
4
+ export declare const MESH_DELEGATION_VERSION = "0.5.0-phase-5";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,eAAO,MAAM,uBAAuB,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ export * from './contracts.js';
3
+ export * from './chain.js';
4
+ export * from './delegated-router.js';
5
+ export const MESH_DELEGATION_VERSION = '0.5.0-phase-5';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,MAAM,CAAC,MAAM,uBAAuB,GAAG,eAAe,CAAC"}
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@orqenix-pro/mesh-delegation",
3
+ "version": "0.5.0-phase-5",
4
+ "description": "Multi-hop mesh delegation chains with capability token + provenance lineage (Orqenix-Pro)",
5
+ "license": "BUSL-1.1",
6
+ "author": {
7
+ "name": "Milo Nguyen",
8
+ "email": "milo@orqenix.dev",
9
+ "url": "https://orqenix.dev"
10
+ },
11
+ "homepage": "https://orqenix.dev",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/milosaysyolo/Orqenix-Pro.git",
15
+ "directory": "packages\\mesh-delegation"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/milosaysyolo/Orqenix-Pro/issues"
19
+ },
20
+ "keywords": [
21
+ "orqenix",
22
+ "ai-agents",
23
+ "mesh"
24
+ ],
25
+ "type": "module",
26
+ "main": "./dist/index.js",
27
+ "module": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js",
33
+ "require": "./dist/index.cjs"
34
+ },
35
+ "./package.json": "./package.json"
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "README.md",
40
+ "LICENSE",
41
+ "CHANGELOG.md"
42
+ ],
43
+ "sideEffects": false,
44
+ "publishConfig": {
45
+ "access": "public",
46
+ "registry": "https://registry.npmjs.org/",
47
+ "provenance": false
48
+ },
49
+ "engines": {
50
+ "node": ">=20.0.0"
51
+ },
52
+ "dependencies": {
53
+ "@orqenix/core": "file:../../../Orqenix/packages/core",
54
+ "@orqenix/scope-identity": "file:../../../Orqenix/packages/scope-identity",
55
+ "@orqenix/capability-tokens": "file:../../../Orqenix/packages/capability-tokens",
56
+ "@orqenix/scope-link": "file:../../../Orqenix/packages/scope-link",
57
+ "@orqenix/mesh-routing": "file:../../../Orqenix/packages/mesh-routing",
58
+ "@orqenix/provenance": "file:../../../Orqenix/packages/provenance",
59
+ "@orqenix/storage-sqlite": "file:../../../Orqenix/packages/storage-sqlite",
60
+ "zod": "^3.23.8"
61
+ },
62
+ "devDependencies": {
63
+ "vitest": "^1.6.0",
64
+ "typescript": "^5.5.0"
65
+ },
66
+ "scripts": {
67
+ "build": "tsc --build",
68
+ "test": "vitest run",
69
+ "typecheck": "tsc --noEmit",
70
+ "clean": "rm -rf dist"
71
+ }
72
+ }