@labacacia/nps-sdk 1.0.0-alpha.1 → 1.0.0-alpha.13
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.cn.md +181 -0
- package/CHANGELOG.md +234 -0
- package/LICENSE +0 -0
- package/NOTICE +0 -0
- package/README.cn.md +163 -0
- package/README.md +16 -6
- package/dist/core/anchor-cache.d.ts +0 -0
- package/dist/core/anchor-cache.d.ts.map +0 -0
- package/dist/core/anchor-cache.js +0 -0
- package/dist/core/anchor-cache.js.map +0 -0
- package/dist/core/cache.d.ts +0 -0
- package/dist/core/cache.d.ts.map +0 -0
- package/dist/core/cache.js +0 -0
- package/dist/core/cache.js.map +0 -0
- package/dist/core/canonical-json.d.ts +0 -0
- package/dist/core/canonical-json.d.ts.map +0 -0
- package/dist/core/canonical-json.js +0 -0
- package/dist/core/canonical-json.js.map +0 -0
- package/dist/core/codec.d.ts +0 -0
- package/dist/core/codec.d.ts.map +0 -0
- package/dist/core/codec.js +0 -0
- package/dist/core/codec.js.map +0 -0
- package/dist/core/codecs/index.d.ts +0 -0
- package/dist/core/codecs/index.d.ts.map +0 -0
- package/dist/core/codecs/index.js +0 -0
- package/dist/core/codecs/index.js.map +0 -0
- package/dist/core/codecs/ncp-codec.d.ts +0 -0
- package/dist/core/codecs/ncp-codec.d.ts.map +0 -0
- package/dist/core/codecs/ncp-codec.js +0 -0
- package/dist/core/codecs/ncp-codec.js.map +0 -0
- package/dist/core/codecs/tier1-json-codec.d.ts +0 -0
- package/dist/core/codecs/tier1-json-codec.d.ts.map +0 -0
- package/dist/core/codecs/tier1-json-codec.js +0 -0
- package/dist/core/codecs/tier1-json-codec.js.map +0 -0
- package/dist/core/codecs/tier2-msgpack-codec.d.ts +0 -0
- package/dist/core/codecs/tier2-msgpack-codec.d.ts.map +0 -0
- package/dist/core/codecs/tier2-msgpack-codec.js +0 -0
- package/dist/core/codecs/tier2-msgpack-codec.js.map +0 -0
- package/dist/core/crypto-provider.d.ts +0 -0
- package/dist/core/crypto-provider.d.ts.map +0 -0
- package/dist/core/crypto-provider.js +0 -0
- package/dist/core/crypto-provider.js.map +0 -0
- package/dist/core/exceptions.d.ts +0 -0
- package/dist/core/exceptions.d.ts.map +0 -0
- package/dist/core/exceptions.js +0 -0
- package/dist/core/exceptions.js.map +0 -0
- package/dist/core/frame-header.d.ts +1 -0
- package/dist/core/frame-header.d.ts.map +1 -1
- package/dist/core/frame-header.js +1 -0
- package/dist/core/frame-header.js.map +1 -1
- package/dist/core/frame-registry.d.ts +0 -0
- package/dist/core/frame-registry.d.ts.map +1 -1
- package/dist/core/frame-registry.js +1 -0
- package/dist/core/frame-registry.js.map +1 -1
- package/dist/core/frames.d.ts +3 -0
- package/dist/core/frames.d.ts.map +1 -1
- package/dist/core/frames.js +3 -0
- package/dist/core/frames.js.map +1 -1
- package/dist/core/index.d.ts +6 -4
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +17 -5
- package/dist/core/index.js.map +1 -1
- package/dist/core/registry.d.ts +0 -0
- package/dist/core/registry.d.ts.map +0 -0
- package/dist/core/registry.js +0 -0
- package/dist/core/registry.js.map +0 -0
- package/dist/core/status-codes.d.ts +20 -0
- package/dist/core/status-codes.d.ts.map +1 -1
- package/dist/core/status-codes.js +51 -0
- package/dist/core/status-codes.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/ncp/frames/anchor-frame.d.ts +0 -0
- package/dist/ncp/frames/anchor-frame.d.ts.map +0 -0
- package/dist/ncp/frames/anchor-frame.js +0 -0
- package/dist/ncp/frames/anchor-frame.js.map +0 -0
- package/dist/ncp/frames/caps-frame.d.ts +0 -0
- package/dist/ncp/frames/caps-frame.d.ts.map +0 -0
- package/dist/ncp/frames/caps-frame.js +0 -0
- package/dist/ncp/frames/caps-frame.js.map +0 -0
- package/dist/ncp/frames/diff-frame.d.ts +0 -0
- package/dist/ncp/frames/diff-frame.d.ts.map +0 -0
- package/dist/ncp/frames/diff-frame.js +0 -0
- package/dist/ncp/frames/diff-frame.js.map +0 -0
- package/dist/ncp/frames/error-frame.d.ts +0 -0
- package/dist/ncp/frames/error-frame.d.ts.map +0 -0
- package/dist/ncp/frames/error-frame.js +0 -0
- package/dist/ncp/frames/error-frame.js.map +0 -0
- package/dist/ncp/frames/hello-frame.d.ts +0 -0
- package/dist/ncp/frames/hello-frame.d.ts.map +0 -0
- package/dist/ncp/frames/hello-frame.js +0 -0
- package/dist/ncp/frames/hello-frame.js.map +0 -0
- package/dist/ncp/frames/stream-frame.d.ts +0 -0
- package/dist/ncp/frames/stream-frame.d.ts.map +0 -0
- package/dist/ncp/frames/stream-frame.js +0 -0
- package/dist/ncp/frames/stream-frame.js.map +0 -0
- package/dist/ncp/frames.d.ts +25 -0
- package/dist/ncp/frames.d.ts.map +1 -1
- package/dist/ncp/frames.js +61 -0
- package/dist/ncp/frames.js.map +1 -1
- package/dist/ncp/handshake.d.ts +0 -0
- package/dist/ncp/handshake.d.ts.map +0 -0
- package/dist/ncp/handshake.js +0 -0
- package/dist/ncp/handshake.js.map +0 -0
- package/dist/ncp/index.d.ts +1 -0
- package/dist/ncp/index.d.ts.map +1 -1
- package/dist/ncp/index.js +1 -0
- package/dist/ncp/index.js.map +1 -1
- package/dist/ncp/ncp-error-codes.d.ts +5 -0
- package/dist/ncp/ncp-error-codes.d.ts.map +1 -1
- package/dist/ncp/ncp-error-codes.js +27 -0
- package/dist/ncp/ncp-error-codes.js.map +1 -1
- package/dist/ncp/ncp-patch-format.d.ts +0 -0
- package/dist/ncp/ncp-patch-format.d.ts.map +0 -0
- package/dist/ncp/ncp-patch-format.js +0 -0
- package/dist/ncp/ncp-patch-format.js.map +0 -0
- package/dist/ncp/preamble.d.ts +47 -0
- package/dist/ncp/preamble.d.ts.map +1 -0
- package/dist/ncp/preamble.js +74 -0
- package/dist/ncp/preamble.js.map +1 -0
- package/dist/ncp/registry.d.ts +0 -0
- package/dist/ncp/registry.d.ts.map +1 -1
- package/dist/ncp/registry.js +2 -1
- package/dist/ncp/registry.js.map +1 -1
- package/dist/ncp/stream-manager.d.ts +0 -0
- package/dist/ncp/stream-manager.d.ts.map +0 -0
- package/dist/ncp/stream-manager.js +0 -0
- package/dist/ncp/stream-manager.js.map +0 -0
- package/dist/ndp/dns-txt.d.ts +35 -0
- package/dist/ndp/dns-txt.d.ts.map +1 -0
- package/dist/ndp/dns-txt.js +67 -0
- package/dist/ndp/dns-txt.js.map +1 -0
- package/dist/ndp/frames.d.ts +34 -9
- package/dist/ndp/frames.d.ts.map +1 -1
- package/dist/ndp/frames.js +54 -15
- package/dist/ndp/frames.js.map +1 -1
- package/dist/ndp/index.d.ts +3 -0
- package/dist/ndp/index.d.ts.map +1 -1
- package/dist/ndp/index.js +3 -0
- package/dist/ndp/index.js.map +1 -1
- package/dist/ndp/ndp-error-codes.d.ts +25 -0
- package/dist/ndp/ndp-error-codes.d.ts.map +1 -0
- package/dist/ndp/ndp-error-codes.js +48 -0
- package/dist/ndp/ndp-error-codes.js.map +1 -0
- package/dist/ndp/ndp-registry.d.ts +2 -0
- package/dist/ndp/ndp-registry.d.ts.map +1 -1
- package/dist/ndp/ndp-registry.js +25 -0
- package/dist/ndp/ndp-registry.js.map +1 -1
- package/dist/ndp/registry.d.ts +0 -0
- package/dist/ndp/registry.d.ts.map +0 -0
- package/dist/ndp/registry.js +0 -0
- package/dist/ndp/registry.js.map +0 -0
- package/dist/ndp/security.d.ts +8 -0
- package/dist/ndp/security.d.ts.map +1 -0
- package/dist/ndp/security.js +9 -0
- package/dist/ndp/security.js.map +1 -0
- package/dist/ndp/validator.d.ts +0 -0
- package/dist/ndp/validator.d.ts.map +0 -0
- package/dist/ndp/validator.js +0 -0
- package/dist/ndp/validator.js.map +0 -0
- package/dist/nip/acme/client.d.ts +31 -0
- package/dist/nip/acme/client.d.ts.map +1 -0
- package/dist/nip/acme/client.js +136 -0
- package/dist/nip/acme/client.js.map +1 -0
- package/dist/nip/acme/index.d.ts +6 -0
- package/dist/nip/acme/index.d.ts.map +1 -0
- package/dist/nip/acme/index.js +8 -0
- package/dist/nip/acme/index.js.map +1 -0
- package/dist/nip/acme/jws.d.ts +31 -0
- package/dist/nip/acme/jws.d.ts.map +1 -0
- package/dist/nip/acme/jws.js +76 -0
- package/dist/nip/acme/jws.js.map +1 -0
- package/dist/nip/acme/messages.d.ts +71 -0
- package/dist/nip/acme/messages.d.ts.map +1 -0
- package/dist/nip/acme/messages.js +4 -0
- package/dist/nip/acme/messages.js.map +1 -0
- package/dist/nip/acme/server.d.ts +41 -0
- package/dist/nip/acme/server.d.ts.map +1 -0
- package/dist/nip/acme/server.js +458 -0
- package/dist/nip/acme/server.js.map +1 -0
- package/dist/nip/acme/wire.d.ts +19 -0
- package/dist/nip/acme/wire.d.ts.map +1 -0
- package/dist/nip/acme/wire.js +21 -0
- package/dist/nip/acme/wire.js.map +1 -0
- package/dist/nip/assurance-level.d.ts +19 -0
- package/dist/nip/assurance-level.d.ts.map +1 -0
- package/dist/nip/assurance-level.js +38 -0
- package/dist/nip/assurance-level.js.map +1 -0
- package/dist/nip/cert-format.d.ts +5 -0
- package/dist/nip/cert-format.d.ts.map +1 -0
- package/dist/nip/cert-format.js +6 -0
- package/dist/nip/cert-format.js.map +1 -0
- package/dist/nip/error-codes.d.ts +44 -0
- package/dist/nip/error-codes.d.ts.map +1 -0
- package/dist/nip/error-codes.js +97 -0
- package/dist/nip/error-codes.js.map +1 -0
- package/dist/nip/frames.d.ts +19 -1
- package/dist/nip/frames.d.ts.map +1 -1
- package/dist/nip/frames.js +39 -4
- package/dist/nip/frames.js.map +1 -1
- package/dist/nip/identity.d.ts +0 -0
- package/dist/nip/identity.d.ts.map +0 -0
- package/dist/nip/identity.js +0 -0
- package/dist/nip/identity.js.map +0 -0
- package/dist/nip/index.d.ts +7 -0
- package/dist/nip/index.d.ts.map +1 -1
- package/dist/nip/index.js +9 -0
- package/dist/nip/index.js.map +1 -1
- package/dist/nip/registry.d.ts +0 -0
- package/dist/nip/registry.d.ts.map +0 -0
- package/dist/nip/registry.js +0 -0
- package/dist/nip/registry.js.map +0 -0
- package/dist/nip/reputation-client.d.ts +116 -0
- package/dist/nip/reputation-client.d.ts.map +1 -0
- package/dist/nip/reputation-client.js +261 -0
- package/dist/nip/reputation-client.js.map +1 -0
- package/dist/nip/verifier.d.ts +23 -0
- package/dist/nip/verifier.d.ts.map +1 -0
- package/dist/nip/verifier.js +90 -0
- package/dist/nip/verifier.js.map +1 -0
- package/dist/nip/x509/builder.d.ts +35 -0
- package/dist/nip/x509/builder.d.ts.map +1 -0
- package/dist/nip/x509/builder.js +59 -0
- package/dist/nip/x509/builder.js.map +1 -0
- package/dist/nip/x509/index.d.ts +4 -0
- package/dist/nip/x509/index.d.ts.map +1 -0
- package/dist/nip/x509/index.js +6 -0
- package/dist/nip/x509/index.js.map +1 -0
- package/dist/nip/x509/oids.d.ts +16 -0
- package/dist/nip/x509/oids.d.ts.map +1 -0
- package/dist/nip/x509/oids.js +22 -0
- package/dist/nip/x509/oids.js.map +1 -0
- package/dist/nip/x509/verifier.d.ts +26 -0
- package/dist/nip/x509/verifier.d.ts.map +1 -0
- package/dist/nip/x509/verifier.js +171 -0
- package/dist/nip/x509/verifier.js.map +1 -0
- package/dist/nop/client.d.ts +0 -0
- package/dist/nop/client.d.ts.map +0 -0
- package/dist/nop/client.js +0 -0
- package/dist/nop/client.js.map +1 -1
- package/dist/nop/dag-validator.d.ts +15 -0
- package/dist/nop/dag-validator.d.ts.map +1 -0
- package/dist/nop/dag-validator.js +91 -0
- package/dist/nop/dag-validator.js.map +1 -0
- package/dist/nop/frames.d.ts +8 -3
- package/dist/nop/frames.d.ts.map +1 -1
- package/dist/nop/frames.js +21 -6
- package/dist/nop/frames.js.map +1 -1
- package/dist/nop/index.d.ts +3 -0
- package/dist/nop/index.d.ts.map +1 -1
- package/dist/nop/index.js +3 -0
- package/dist/nop/index.js.map +1 -1
- package/dist/nop/models.d.ts +13 -2
- package/dist/nop/models.d.ts.map +1 -1
- package/dist/nop/models.js +9 -0
- package/dist/nop/models.js.map +1 -1
- package/dist/nop/nop-error-codes.d.ts +31 -0
- package/dist/nop/nop-error-codes.d.ts.map +1 -0
- package/dist/nop/nop-error-codes.js +61 -0
- package/dist/nop/nop-error-codes.js.map +1 -0
- package/dist/nop/nop-types.d.ts +0 -0
- package/dist/nop/nop-types.d.ts.map +0 -0
- package/dist/nop/nop-types.js +0 -0
- package/dist/nop/nop-types.js.map +0 -0
- package/dist/nop/orchestrator.d.ts +66 -0
- package/dist/nop/orchestrator.d.ts.map +1 -0
- package/dist/nop/orchestrator.js +229 -0
- package/dist/nop/orchestrator.js.map +1 -0
- package/dist/nop/registry.d.ts +0 -0
- package/dist/nop/registry.d.ts.map +0 -0
- package/dist/nop/registry.js +0 -0
- package/dist/nop/registry.js.map +0 -0
- package/dist/nwp/anchor-client.d.ts +109 -0
- package/dist/nwp/anchor-client.d.ts.map +1 -0
- package/dist/nwp/anchor-client.js +279 -0
- package/dist/nwp/anchor-client.js.map +1 -0
- package/dist/nwp/anchor-server.d.ts +127 -0
- package/dist/nwp/anchor-server.d.ts.map +1 -0
- package/dist/nwp/anchor-server.js +649 -0
- package/dist/nwp/anchor-server.js.map +1 -0
- package/dist/nwp/bridge.d.ts +24 -0
- package/dist/nwp/bridge.d.ts.map +1 -0
- package/dist/nwp/bridge.js +26 -0
- package/dist/nwp/bridge.js.map +1 -0
- package/dist/nwp/cgn.d.ts +19 -0
- package/dist/nwp/cgn.d.ts.map +1 -0
- package/dist/nwp/cgn.js +29 -0
- package/dist/nwp/cgn.js.map +1 -0
- package/dist/nwp/client.d.ts +10 -3
- package/dist/nwp/client.d.ts.map +1 -1
- package/dist/nwp/client.js +58 -7
- package/dist/nwp/client.js.map +1 -1
- package/dist/nwp/frames.d.ts +56 -2
- package/dist/nwp/frames.d.ts.map +1 -1
- package/dist/nwp/frames.js +86 -4
- package/dist/nwp/frames.js.map +1 -1
- package/dist/nwp/http-headers.d.ts +24 -0
- package/dist/nwp/http-headers.d.ts.map +1 -0
- package/dist/nwp/http-headers.js +29 -0
- package/dist/nwp/http-headers.js.map +1 -0
- package/dist/nwp/index.d.ts +9 -0
- package/dist/nwp/index.d.ts.map +1 -1
- package/dist/nwp/index.js +9 -0
- package/dist/nwp/index.js.map +1 -1
- package/dist/nwp/manifest.d.ts +75 -0
- package/dist/nwp/manifest.d.ts.map +1 -0
- package/dist/nwp/manifest.js +5 -0
- package/dist/nwp/manifest.js.map +1 -0
- package/dist/nwp/memory-node-server.d.ts +70 -0
- package/dist/nwp/memory-node-server.d.ts.map +1 -0
- package/dist/nwp/memory-node-server.js +315 -0
- package/dist/nwp/memory-node-server.js.map +1 -0
- package/dist/nwp/nwp-error-codes.d.ts +48 -0
- package/dist/nwp/nwp-error-codes.d.ts.map +1 -0
- package/dist/nwp/nwp-error-codes.js +108 -0
- package/dist/nwp/nwp-error-codes.js.map +1 -0
- package/dist/nwp/registry.d.ts +0 -0
- package/dist/nwp/registry.d.ts.map +0 -0
- package/dist/nwp/registry.js +0 -0
- package/dist/nwp/registry.js.map +0 -0
- package/dist/nwp/reputation.d.ts +37 -0
- package/dist/nwp/reputation.d.ts.map +1 -0
- package/dist/nwp/reputation.js +118 -0
- package/dist/nwp/reputation.js.map +1 -0
- package/dist/setup.d.ts +0 -0
- package/dist/setup.d.ts.map +0 -0
- package/dist/setup.js +0 -0
- package/dist/setup.js.map +0 -0
- package/doc/nps-sdk.core.cn.md +321 -0
- package/doc/nps-sdk.core.md +326 -0
- package/doc/nps-sdk.ncp.cn.md +270 -0
- package/doc/nps-sdk.ncp.md +276 -0
- package/doc/nps-sdk.ndp.cn.md +267 -0
- package/doc/nps-sdk.ndp.md +273 -0
- package/doc/nps-sdk.nip.cn.md +265 -0
- package/doc/nps-sdk.nip.md +272 -0
- package/doc/nps-sdk.nop.cn.md +329 -0
- package/doc/nps-sdk.nop.md +332 -0
- package/doc/nps-sdk.nwp.cn.md +288 -0
- package/doc/nps-sdk.nwp.md +295 -0
- package/doc/overview.cn.md +149 -0
- package/doc/overview.md +153 -0
- package/package.json +33 -4
- package/CONTRIBUTING.md +0 -33
- package/dist/codec-CmHeovTV.d.cts +0 -120
- package/dist/codec-CmHeovTV.d.ts +0 -120
- package/dist/core/index.cjs +0 -371
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.d.cts +0 -41
- package/dist/frames-B3qLdl_g.d.cts +0 -77
- package/dist/frames-Ff7-ZPUl.d.ts +0 -77
- package/dist/index.cjs +0 -1556
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -21
- package/dist/ncp/index.cjs +0 -188
- package/dist/ncp/index.cjs.map +0 -1
- package/dist/ncp/index.d.cts +0 -6
- package/dist/ndp/index.cjs +0 -252
- package/dist/ndp/index.cjs.map +0 -1
- package/dist/ndp/index.d.cts +0 -86
- package/dist/nip/index.cjs +0 -214
- package/dist/nip/index.cjs.map +0 -1
- package/dist/nip/index.d.cts +0 -65
- package/dist/nop/index.cjs +0 -762
- package/dist/nop/index.cjs.map +0 -1
- package/dist/nop/index.d.cts +0 -155
- package/dist/nwp/index.cjs +0 -658
- package/dist/nwp/index.cjs.map +0 -1
- package/dist/nwp/index.d.cts +0 -65
- package/nip-ca-server/Dockerfile +0 -27
- package/nip-ca-server/README.md +0 -45
- package/nip-ca-server/db/001_init.sql +0 -25
- package/nip-ca-server/docker-compose.yml +0 -29
- package/nip-ca-server/package.json +0 -23
- package/nip-ca-server/src/ca.ts +0 -155
- package/nip-ca-server/src/db.ts +0 -104
- package/nip-ca-server/src/index.ts +0 -157
- package/nip-ca-server/tsconfig.json +0 -13
- package/src/core/anchor-cache.ts +0 -129
- package/src/core/cache.ts +0 -93
- package/src/core/canonical-json.ts +0 -50
- package/src/core/codec.ts +0 -158
- package/src/core/codecs/index.ts +0 -5
- package/src/core/codecs/ncp-codec.ts +0 -170
- package/src/core/codecs/tier1-json-codec.ts +0 -33
- package/src/core/codecs/tier2-msgpack-codec.ts +0 -30
- package/src/core/crypto-provider.ts +0 -47
- package/src/core/exceptions.ts +0 -57
- package/src/core/frame-header.ts +0 -282
- package/src/core/frame-registry.ts +0 -91
- package/src/core/frames.ts +0 -183
- package/src/core/index.ts +0 -10
- package/src/core/registry.ts +0 -28
- package/src/core/status-codes.ts +0 -46
- package/src/index.ts +0 -10
- package/src/ncp/frames/anchor-frame.ts +0 -87
- package/src/ncp/frames/caps-frame.ts +0 -59
- package/src/ncp/frames/diff-frame.ts +0 -69
- package/src/ncp/frames/error-frame.ts +0 -26
- package/src/ncp/frames/hello-frame.ts +0 -50
- package/src/ncp/frames/stream-frame.ts +0 -35
- package/src/ncp/frames.ts +0 -199
- package/src/ncp/handshake.ts +0 -95
- package/src/ncp/index.ts +0 -12
- package/src/ncp/ncp-error-codes.ts +0 -34
- package/src/ncp/ncp-patch-format.ts +0 -16
- package/src/ncp/registry.ts +0 -14
- package/src/ncp/stream-manager.ts +0 -212
- package/src/ndp/frames.ts +0 -124
- package/src/ndp/index.ts +0 -7
- package/src/ndp/ndp-registry.ts +0 -82
- package/src/ndp/registry.ts +0 -12
- package/src/ndp/validator.ts +0 -64
- package/src/nip/frames.ts +0 -106
- package/src/nip/identity.ts +0 -113
- package/src/nip/index.ts +0 -6
- package/src/nip/registry.ts +0 -12
- package/src/nop/client.ts +0 -103
- package/src/nop/frames.ts +0 -181
- package/src/nop/index.ts +0 -7
- package/src/nop/models.ts +0 -79
- package/src/nop/nop-types.ts +0 -208
- package/src/nop/registry.ts +0 -13
- package/src/nwp/client.ts +0 -114
- package/src/nwp/frames.ts +0 -116
- package/src/nwp/index.ts +0 -6
- package/src/nwp/registry.ts +0 -11
- package/src/setup.ts +0 -32
- package/tests/core/anchor-cache.test.ts +0 -242
- package/tests/core/codec.test.ts +0 -205
- package/tests/core/frame-registry.test.ts +0 -46
- package/tests/core.test.ts +0 -327
- package/tests/ncp/diff-binary-bitset.test.ts +0 -107
- package/tests/ncp/e2e-enc-reject.test.ts +0 -93
- package/tests/ncp/err-error-frame.test.ts +0 -152
- package/tests/ncp/frames.test.ts +0 -359
- package/tests/ncp/framing.test.ts +0 -233
- package/tests/ncp/hello-frame.test.ts +0 -122
- package/tests/ncp/inline-anchor.test.ts +0 -88
- package/tests/ncp/security.test.ts +0 -184
- package/tests/ncp/stream-window.test.ts +0 -167
- package/tests/ncp/stream.test.ts +0 -242
- package/tests/ncp/version-negotiation.test.ts +0 -123
- package/tests/ndp.test.ts +0 -271
- package/tests/nip.test.ts +0 -184
- package/tests/nop.test.ts +0 -344
- package/tests/nwp.test.ts +0 -237
- package/tsconfig.json +0 -20
- package/tsup.config.ts +0 -20
- package/vitest.config.ts +0 -10
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
|
|
3
|
-
//
|
|
4
|
-
// NCP Frame Registry — Maps frame type bytes to protocol identifiers
|
|
5
|
-
// NPS-0 §9 Unified frame namespace
|
|
6
|
-
|
|
7
|
-
import { FrameType, NcpError } from "./frame-header.js";
|
|
8
|
-
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
// Protocol identifier for routing
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
|
|
13
|
-
export type Protocol = "ncp" | "nwp" | "nip" | "ndp" | "nop" | "system";
|
|
14
|
-
|
|
15
|
-
export interface FrameRegistryEntry {
|
|
16
|
-
/** Frame type byte. */
|
|
17
|
-
frameType: number;
|
|
18
|
-
/** Human-readable name. */
|
|
19
|
-
name: string;
|
|
20
|
-
/** Protocol this frame belongs to. */
|
|
21
|
-
protocol: Protocol;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// ---------------------------------------------------------------------------
|
|
25
|
-
// Registry
|
|
26
|
-
// ---------------------------------------------------------------------------
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Maps frame type bytes to metadata.
|
|
30
|
-
* Built once at startup, then read-only.
|
|
31
|
-
*/
|
|
32
|
-
export class FrameRegistry {
|
|
33
|
-
private readonly map: Map<number, FrameRegistryEntry>;
|
|
34
|
-
|
|
35
|
-
constructor(entries: FrameRegistryEntry[]) {
|
|
36
|
-
this.map = new Map(entries.map((e) => [e.frameType, e]));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Resolve a frame type byte to its registry entry.
|
|
41
|
-
* @throws {NcpError} NCP-FRAME-UNKNOWN-TYPE if not registered.
|
|
42
|
-
*/
|
|
43
|
-
resolve(frameType: number): FrameRegistryEntry {
|
|
44
|
-
const entry = this.map.get(frameType);
|
|
45
|
-
if (!entry) {
|
|
46
|
-
throw new NcpError(
|
|
47
|
-
"NCP-FRAME-UNKNOWN-TYPE",
|
|
48
|
-
`No entry registered for frame type 0x${frameType.toString(16).padStart(2, "0")}`,
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
return entry;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** Check if a frame type is registered. */
|
|
55
|
-
has(frameType: number): boolean {
|
|
56
|
-
return this.map.has(frameType);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Create a registry pre-populated with all NCP core frames.
|
|
61
|
-
* Upper-layer protocols can extend via the builder.
|
|
62
|
-
*/
|
|
63
|
-
static createDefault(): FrameRegistry {
|
|
64
|
-
return new FrameRegistryBuilder()
|
|
65
|
-
.add(FrameType.Anchor, "AnchorFrame", "ncp")
|
|
66
|
-
.add(FrameType.Diff, "DiffFrame", "ncp")
|
|
67
|
-
.add(FrameType.Stream, "StreamFrame", "ncp")
|
|
68
|
-
.add(FrameType.Caps, "CapsFrame", "ncp")
|
|
69
|
-
.add(FrameType.Align, "AlignFrame", "ncp") // deprecated
|
|
70
|
-
.add(FrameType.Hello, "HelloFrame", "ncp")
|
|
71
|
-
.add(FrameType.Error, "ErrorFrame", "system")
|
|
72
|
-
.build();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// ---------------------------------------------------------------------------
|
|
77
|
-
// Builder
|
|
78
|
-
// ---------------------------------------------------------------------------
|
|
79
|
-
|
|
80
|
-
export class FrameRegistryBuilder {
|
|
81
|
-
private readonly entries: FrameRegistryEntry[] = [];
|
|
82
|
-
|
|
83
|
-
add(frameType: number, name: string, protocol: Protocol): this {
|
|
84
|
-
this.entries.push({ frameType, name, protocol });
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
build(): FrameRegistry {
|
|
89
|
-
return new FrameRegistry(this.entries);
|
|
90
|
-
}
|
|
91
|
-
}
|
package/src/core/frames.ts
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 INNO LOTUS PTY LTD
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* NPS wire-level frame primitives: FrameType, FrameFlags, EncodingTier, FrameHeader.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { NpsFrameError } from "./exceptions.js";
|
|
9
|
-
|
|
10
|
-
// ── FrameType ────────────────────────────────────────────────────────────────
|
|
11
|
-
|
|
12
|
-
/** Unified frame byte namespace for the full NPS suite (NPS-0 §9). */
|
|
13
|
-
export enum FrameType {
|
|
14
|
-
// NCP 0x01–0x0F
|
|
15
|
-
ANCHOR = 0x01,
|
|
16
|
-
DIFF = 0x02,
|
|
17
|
-
STREAM = 0x03,
|
|
18
|
-
CAPS = 0x04,
|
|
19
|
-
ALIGN = 0x05, // deprecated — use AlignStream (0x43)
|
|
20
|
-
|
|
21
|
-
// NWP 0x10–0x1F
|
|
22
|
-
QUERY = 0x10,
|
|
23
|
-
ACTION = 0x11,
|
|
24
|
-
|
|
25
|
-
// NIP 0x20–0x2F
|
|
26
|
-
IDENT = 0x20,
|
|
27
|
-
TRUST = 0x21,
|
|
28
|
-
REVOKE = 0x22,
|
|
29
|
-
|
|
30
|
-
// NDP 0x30–0x3F
|
|
31
|
-
ANNOUNCE = 0x30,
|
|
32
|
-
RESOLVE = 0x31,
|
|
33
|
-
GRAPH = 0x32,
|
|
34
|
-
|
|
35
|
-
// NOP 0x40–0x4F
|
|
36
|
-
TASK = 0x40,
|
|
37
|
-
DELEGATE = 0x41,
|
|
38
|
-
SYNC = 0x42,
|
|
39
|
-
ALIGN_STREAM = 0x43,
|
|
40
|
-
|
|
41
|
-
// Reserved / System 0xF0–0xFF
|
|
42
|
-
ERROR = 0xFE,
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// ── EncodingTier ─────────────────────────────────────────────────────────────
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Wire encoding tier, stored in the lower 2 bits of the flags byte (NPS-1 §3.2).
|
|
49
|
-
* 0x00 = Tier-1 JSON — human-readable; development / compatibility.
|
|
50
|
-
* 0x01 = Tier-2 MsgPack — binary, ~60 % smaller; production default.
|
|
51
|
-
*/
|
|
52
|
-
export enum EncodingTier {
|
|
53
|
-
JSON = 0x00,
|
|
54
|
-
MSGPACK = 0x01,
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// ── FrameFlags ───────────────────────────────────────────────────────────────
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Flags byte in the NPS frame header (NPS-1 §3.2).
|
|
61
|
-
* Bit layout (LSB = bit 0):
|
|
62
|
-
* Bits 0–1 (T0,T1) : Encoding tier
|
|
63
|
-
* Bit 2 (FINAL) : Last chunk of a StreamFrame; non-stream frames MUST set this
|
|
64
|
-
* Bit 3 (ENC) : Payload encrypted
|
|
65
|
-
* Bits 4–6 (RSV) : Reserved — sender MUST write 0
|
|
66
|
-
* Bit 7 (EXT) : Extended 8-byte header
|
|
67
|
-
*/
|
|
68
|
-
export const FrameFlags = {
|
|
69
|
-
NONE: 0x00,
|
|
70
|
-
TIER1_JSON: 0x00,
|
|
71
|
-
TIER2_MSGPACK: 0x01,
|
|
72
|
-
FINAL: 0x04,
|
|
73
|
-
ENCRYPTED: 0x08,
|
|
74
|
-
EXT: 0x80,
|
|
75
|
-
} as const;
|
|
76
|
-
|
|
77
|
-
// ── Constants ─────────────────────────────────────────────────────────────────
|
|
78
|
-
|
|
79
|
-
export const DEFAULT_HEADER_SIZE = 4;
|
|
80
|
-
export const EXTENDED_HEADER_SIZE = 8;
|
|
81
|
-
export const DEFAULT_MAX_PAYLOAD = 0xffff; // 65 535 bytes
|
|
82
|
-
export const EXTENDED_MAX_PAYLOAD = 0xffffffff; // 4 GiB - 1
|
|
83
|
-
|
|
84
|
-
// ── FrameHeader ──────────────────────────────────────────────────────────────
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* NPS frame header, present at the start of every wire message (NPS-1 §3.1).
|
|
88
|
-
*
|
|
89
|
-
* Default (4 bytes, EXT=0):
|
|
90
|
-
* Byte 0 : FrameType
|
|
91
|
-
* Byte 1 : Flags
|
|
92
|
-
* Byte 2–3 : PayloadLength (big-endian uint16)
|
|
93
|
-
*
|
|
94
|
-
* Extended (8 bytes, EXT=1):
|
|
95
|
-
* Byte 0 : FrameType
|
|
96
|
-
* Byte 1 : Flags (bit 7 = 1)
|
|
97
|
-
* Byte 2–3 : Reserved (must be 0)
|
|
98
|
-
* Byte 4–7 : PayloadLength (big-endian uint32)
|
|
99
|
-
*/
|
|
100
|
-
export class FrameHeader {
|
|
101
|
-
constructor(
|
|
102
|
-
public readonly frameType: FrameType,
|
|
103
|
-
public readonly flags: number,
|
|
104
|
-
public readonly payloadLength: number,
|
|
105
|
-
) {}
|
|
106
|
-
|
|
107
|
-
get isExtended(): boolean {
|
|
108
|
-
return (this.flags & FrameFlags.EXT) !== 0;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
get headerSize(): number {
|
|
112
|
-
return this.isExtended ? EXTENDED_HEADER_SIZE : DEFAULT_HEADER_SIZE;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
get encodingTier(): EncodingTier {
|
|
116
|
-
return (this.flags & 0x03) as EncodingTier;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
get isFinal(): boolean {
|
|
120
|
-
return (this.flags & 0x04) !== 0;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
get isEncrypted(): boolean {
|
|
124
|
-
return (this.flags & 0x08) !== 0;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// ── Parsing ───────────────────────────────────────────────────────────────
|
|
128
|
-
|
|
129
|
-
static parse(buf: Uint8Array): FrameHeader {
|
|
130
|
-
if (buf.length < 2) {
|
|
131
|
-
throw new NpsFrameError(
|
|
132
|
-
`Buffer too small to read frame type and flags: need >= 2 bytes, got ${buf.length}.`,
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const flags = buf[1]!;
|
|
137
|
-
const ext = (flags & FrameFlags.EXT) !== 0;
|
|
138
|
-
|
|
139
|
-
if (ext) {
|
|
140
|
-
if (buf.length < EXTENDED_HEADER_SIZE) {
|
|
141
|
-
throw new NpsFrameError(
|
|
142
|
-
`Buffer too small for extended frame header: need ${EXTENDED_HEADER_SIZE} bytes, got ${buf.length}.`,
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
const view = new DataView(buf.buffer, buf.byteOffset);
|
|
146
|
-
const payloadLength = view.getUint32(4, false); // big-endian
|
|
147
|
-
return new FrameHeader(buf[0]! as FrameType, flags, payloadLength);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (buf.length < DEFAULT_HEADER_SIZE) {
|
|
151
|
-
throw new NpsFrameError(
|
|
152
|
-
`Buffer too small for frame header: need ${DEFAULT_HEADER_SIZE} bytes, got ${buf.length}.`,
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
const view = new DataView(buf.buffer, buf.byteOffset);
|
|
156
|
-
const payloadLength = view.getUint16(2, false); // big-endian
|
|
157
|
-
return new FrameHeader(buf[0]! as FrameType, flags, payloadLength);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// ── Serialisation ─────────────────────────────────────────────────────────
|
|
161
|
-
|
|
162
|
-
toBytes(): Uint8Array {
|
|
163
|
-
if (this.isExtended) {
|
|
164
|
-
const buf = new Uint8Array(EXTENDED_HEADER_SIZE);
|
|
165
|
-
const view = new DataView(buf.buffer);
|
|
166
|
-
view.setUint8(0, this.frameType);
|
|
167
|
-
view.setUint8(1, this.flags);
|
|
168
|
-
view.setUint16(2, 0, false); // reserved
|
|
169
|
-
view.setUint32(4, this.payloadLength, false);
|
|
170
|
-
return buf;
|
|
171
|
-
}
|
|
172
|
-
const buf = new Uint8Array(DEFAULT_HEADER_SIZE);
|
|
173
|
-
const view = new DataView(buf.buffer);
|
|
174
|
-
view.setUint8(0, this.frameType);
|
|
175
|
-
view.setUint8(1, this.flags);
|
|
176
|
-
view.setUint16(2, this.payloadLength, false);
|
|
177
|
-
return buf;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
toString(): string {
|
|
181
|
-
return `FrameHeader(frameType=0x${this.frameType.toString(16).padStart(2, "0")}, flags=0x${this.flags.toString(16).padStart(2, "0")}, payloadLength=${this.payloadLength})`;
|
|
182
|
-
}
|
|
183
|
-
}
|
package/src/core/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
|
|
3
|
-
export * from "./frame-header.js";
|
|
4
|
-
export * from "./frame-registry.js";
|
|
5
|
-
export * from "./anchor-cache.js";
|
|
6
|
-
export * from "./exceptions.js";
|
|
7
|
-
export * from "./status-codes.js";
|
|
8
|
-
export { jcsStringify, sortKeysStringify } from "./canonical-json.js";
|
|
9
|
-
export type { CryptoProvider } from "./crypto-provider.js";
|
|
10
|
-
export * from "./codecs/index.js";
|
package/src/core/registry.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 INNO LOTUS PTY LTD
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import { NpsFrameError } from "./exceptions.js";
|
|
5
|
-
import { FrameType } from "./frames.js";
|
|
6
|
-
import type { NpsFrame } from "./codec.js";
|
|
7
|
-
|
|
8
|
-
export interface FrameClass {
|
|
9
|
-
fromDict(data: Record<string, unknown>): NpsFrame;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class FrameRegistry {
|
|
13
|
-
private readonly _map = new Map<FrameType, FrameClass>();
|
|
14
|
-
|
|
15
|
-
register(frameType: FrameType, cls: FrameClass): void {
|
|
16
|
-
this._map.set(frameType, cls);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
resolve(frameType: FrameType): FrameClass {
|
|
20
|
-
const cls = this._map.get(frameType);
|
|
21
|
-
if (cls === undefined) {
|
|
22
|
-
throw new NpsFrameError(
|
|
23
|
-
`No frame class registered for type 0x${frameType.toString(16).padStart(2, "0")}.`,
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
return cls;
|
|
27
|
-
}
|
|
28
|
-
}
|
package/src/core/status-codes.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
|
|
3
|
-
//
|
|
4
|
-
// NPS native status codes — per spec/status-codes.md
|
|
5
|
-
|
|
6
|
-
/** NPS native status code constants. */
|
|
7
|
-
export const NpsStatusCodes = {
|
|
8
|
-
// Success
|
|
9
|
-
NPS_OK: "NPS-OK",
|
|
10
|
-
NPS_OK_ACCEPTED: "NPS-OK-ACCEPTED",
|
|
11
|
-
NPS_OK_NO_CONTENT: "NPS-OK-NO-CONTENT",
|
|
12
|
-
|
|
13
|
-
// Auth
|
|
14
|
-
NPS_AUTH_UNAUTHENTICATED: "NPS-AUTH-UNAUTHENTICATED",
|
|
15
|
-
NPS_AUTH_FORBIDDEN: "NPS-AUTH-FORBIDDEN",
|
|
16
|
-
|
|
17
|
-
// Client errors
|
|
18
|
-
NPS_CLIENT_BAD_FRAME: "NPS-CLIENT-BAD-FRAME",
|
|
19
|
-
NPS_CLIENT_BAD_PARAM: "NPS-CLIENT-BAD-PARAM",
|
|
20
|
-
NPS_CLIENT_NOT_FOUND: "NPS-CLIENT-NOT-FOUND",
|
|
21
|
-
NPS_CLIENT_CONFLICT: "NPS-CLIENT-CONFLICT",
|
|
22
|
-
NPS_CLIENT_GONE: "NPS-CLIENT-GONE",
|
|
23
|
-
NPS_CLIENT_UNPROCESSABLE: "NPS-CLIENT-UNPROCESSABLE",
|
|
24
|
-
|
|
25
|
-
// Server errors
|
|
26
|
-
NPS_SERVER_INTERNAL: "NPS-SERVER-INTERNAL",
|
|
27
|
-
NPS_SERVER_UNAVAILABLE: "NPS-SERVER-UNAVAILABLE",
|
|
28
|
-
NPS_SERVER_TIMEOUT: "NPS-SERVER-TIMEOUT",
|
|
29
|
-
NPS_SERVER_ENCODING_UNSUPPORTED: "NPS-SERVER-ENCODING-UNSUPPORTED",
|
|
30
|
-
|
|
31
|
-
// Stream
|
|
32
|
-
NPS_STREAM_SEQ_GAP: "NPS-STREAM-SEQ-GAP",
|
|
33
|
-
NPS_STREAM_NOT_FOUND: "NPS-STREAM-NOT-FOUND",
|
|
34
|
-
NPS_STREAM_LIMIT: "NPS-STREAM-LIMIT",
|
|
35
|
-
|
|
36
|
-
// Limit
|
|
37
|
-
NPS_LIMIT_RATE: "NPS-LIMIT-RATE",
|
|
38
|
-
NPS_LIMIT_BUDGET: "NPS-LIMIT-BUDGET",
|
|
39
|
-
NPS_LIMIT_PAYLOAD: "NPS-LIMIT-PAYLOAD",
|
|
40
|
-
NPS_LIMIT_EXCEEDED: "NPS-LIMIT-EXCEEDED",
|
|
41
|
-
|
|
42
|
-
// Protocol
|
|
43
|
-
NPS_PROTO_VERSION_INCOMPATIBLE: "NPS-PROTO-VERSION-INCOMPATIBLE",
|
|
44
|
-
} as const;
|
|
45
|
-
|
|
46
|
-
export type NpsStatusCode = (typeof NpsStatusCodes)[keyof typeof NpsStatusCodes];
|
package/src/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
|
|
3
|
-
//
|
|
4
|
-
// @labacacia/nps-sdk — root entry point.
|
|
5
|
-
// Mirrors Python root __init__.py: exports only the SDK version.
|
|
6
|
-
// All protocol APIs are accessed via sub-package imports:
|
|
7
|
-
// import { ... } from "@labacacia/nps-sdk/core"
|
|
8
|
-
// import { ... } from "@labacacia/nps-sdk/ncp"
|
|
9
|
-
|
|
10
|
-
export const VERSION = "0.1.0";
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
|
|
3
|
-
//
|
|
4
|
-
// AnchorFrame (0x01) — Schema anchor for global reference
|
|
5
|
-
// NPS-1 §4.1
|
|
6
|
-
|
|
7
|
-
import { createHash } from "node:crypto";
|
|
8
|
-
// canonicalize ships CJS with TS `export default` — NodeNext resolves as namespace
|
|
9
|
-
import canonicalizeDefault from "canonicalize";
|
|
10
|
-
const canonicalize = canonicalizeDefault as unknown as (input: unknown) => string | undefined;
|
|
11
|
-
import { NcpError } from "../../core/frame-header.js";
|
|
12
|
-
|
|
13
|
-
// ---------------------------------------------------------------------------
|
|
14
|
-
// Types
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
|
|
17
|
-
const VALID_FIELD_TYPES = [
|
|
18
|
-
"string", "uint64", "int64", "decimal", "bool",
|
|
19
|
-
"timestamp", "bytes", "object", "array",
|
|
20
|
-
] as const;
|
|
21
|
-
|
|
22
|
-
export type SchemaFieldType = (typeof VALID_FIELD_TYPES)[number];
|
|
23
|
-
|
|
24
|
-
export interface SchemaField {
|
|
25
|
-
name: string;
|
|
26
|
-
type: string;
|
|
27
|
-
semantic?: string;
|
|
28
|
-
nullable?: boolean;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface FrameSchema {
|
|
32
|
-
fields: SchemaField[];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface AnchorFrame {
|
|
36
|
-
frame: string;
|
|
37
|
-
anchor_id: string;
|
|
38
|
-
schema: FrameSchema;
|
|
39
|
-
ttl?: number;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// ---------------------------------------------------------------------------
|
|
43
|
-
// anchor_id computation (RFC 8785 JCS + SHA-256)
|
|
44
|
-
// ---------------------------------------------------------------------------
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Compute anchor_id from schema using RFC 8785 JCS canonicalization + SHA-256.
|
|
48
|
-
* Format: "sha256:{64 lowercase hex chars}"
|
|
49
|
-
*/
|
|
50
|
-
export function computeAnchorId(schema: FrameSchema): string {
|
|
51
|
-
const canonical = canonicalize(schema);
|
|
52
|
-
if (!canonical) {
|
|
53
|
-
throw new NcpError("NCP-ANCHOR-SCHEMA-INVALID", "Schema cannot be canonicalized");
|
|
54
|
-
}
|
|
55
|
-
const hash = createHash("sha256").update(canonical).digest("hex");
|
|
56
|
-
return `sha256:${hash}`;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// ---------------------------------------------------------------------------
|
|
60
|
-
// Validation
|
|
61
|
-
// ---------------------------------------------------------------------------
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Validate an AnchorFrame.
|
|
65
|
-
* @throws {NcpError} NCP-ANCHOR-SCHEMA-INVALID if anchor_id doesn't match or schema is invalid.
|
|
66
|
-
*/
|
|
67
|
-
export function validateAnchorFrame(frame: AnchorFrame): void {
|
|
68
|
-
// Validate schema field types
|
|
69
|
-
for (const field of frame.schema.fields) {
|
|
70
|
-
if (!VALID_FIELD_TYPES.includes(field.type as SchemaFieldType)) {
|
|
71
|
-
throw new NcpError(
|
|
72
|
-
"NCP-ANCHOR-SCHEMA-INVALID",
|
|
73
|
-
`Unsupported field type "${field.type}" for field "${field.name}". ` +
|
|
74
|
-
`Valid types: ${VALID_FIELD_TYPES.join(", ")}`,
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Validate anchor_id matches computed hash
|
|
80
|
-
const expected = computeAnchorId(frame.schema);
|
|
81
|
-
if (frame.anchor_id !== expected) {
|
|
82
|
-
throw new NcpError(
|
|
83
|
-
"NCP-ANCHOR-SCHEMA-INVALID",
|
|
84
|
-
`anchor_id mismatch: expected ${expected}, got ${frame.anchor_id}`,
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
|
|
3
|
-
//
|
|
4
|
-
// CapsFrame (0x04) — Capsule response envelope
|
|
5
|
-
// NPS-1 §4.4
|
|
6
|
-
|
|
7
|
-
import { NcpError } from "../../core/frame-header.js";
|
|
8
|
-
import {
|
|
9
|
-
computeAnchorId,
|
|
10
|
-
type AnchorFrame,
|
|
11
|
-
type FrameSchema,
|
|
12
|
-
} from "./anchor-frame.js";
|
|
13
|
-
|
|
14
|
-
export interface CapsFrameInlineAnchor {
|
|
15
|
-
anchor_id: string;
|
|
16
|
-
schema: FrameSchema;
|
|
17
|
-
ttl?: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface CapsFrame {
|
|
21
|
-
frame: string;
|
|
22
|
-
anchor_ref: string;
|
|
23
|
-
count: number;
|
|
24
|
-
data: unknown[];
|
|
25
|
-
next_cursor?: string | null;
|
|
26
|
-
token_est?: number;
|
|
27
|
-
tokenizer_used?: string;
|
|
28
|
-
cached?: boolean;
|
|
29
|
-
inline_anchor?: CapsFrameInlineAnchor;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Validate a CapsFrame.
|
|
34
|
-
*
|
|
35
|
-
* Checks:
|
|
36
|
-
* - count matches data.length (NPS-CLIENT-BAD-FRAME)
|
|
37
|
-
* - if inline_anchor present, recomputes anchor_id and validates match (NCP-ANCHOR-SCHEMA-INVALID)
|
|
38
|
-
*
|
|
39
|
-
* @throws {NcpError} NPS-CLIENT-BAD-FRAME if count doesn't match data length.
|
|
40
|
-
* @throws {NcpError} NCP-ANCHOR-SCHEMA-INVALID if inline_anchor.anchor_id doesn't match schema.
|
|
41
|
-
*/
|
|
42
|
-
export function validateCapsFrame(frame: CapsFrame): void {
|
|
43
|
-
if (frame.count !== frame.data.length) {
|
|
44
|
-
throw new NcpError(
|
|
45
|
-
"NPS-CLIENT-BAD-FRAME",
|
|
46
|
-
`CapsFrame count mismatch: count=${frame.count}, data.length=${frame.data.length}`,
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (frame.inline_anchor !== undefined) {
|
|
51
|
-
const computed = computeAnchorId(frame.inline_anchor.schema);
|
|
52
|
-
if (frame.inline_anchor.anchor_id !== computed) {
|
|
53
|
-
throw new NcpError(
|
|
54
|
-
"NCP-ANCHOR-SCHEMA-INVALID",
|
|
55
|
-
`inline_anchor anchor_id mismatch: expected ${computed}, got ${frame.inline_anchor.anchor_id}`,
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
|
|
3
|
-
//
|
|
4
|
-
// DiffFrame (0x02) — Incremental data patch
|
|
5
|
-
// NPS-1 §4.2
|
|
6
|
-
|
|
7
|
-
import { NcpError, EncodingTier } from "../../core/frame-header.js";
|
|
8
|
-
import { isValidPatchFormat, type PatchFormat } from "../ncp-patch-format.js";
|
|
9
|
-
|
|
10
|
-
export interface JsonPatchOperation {
|
|
11
|
-
op: "add" | "remove" | "replace" | "move" | "copy" | "test";
|
|
12
|
-
path: string;
|
|
13
|
-
value?: unknown;
|
|
14
|
-
from?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface DiffFrame {
|
|
18
|
-
frame: string;
|
|
19
|
-
anchor_ref: string;
|
|
20
|
-
base_seq: number;
|
|
21
|
-
patch_format?: PatchFormat;
|
|
22
|
-
patch: JsonPatchOperation[] | Uint8Array;
|
|
23
|
-
entity_id?: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Validate DiffFrame base_seq against current sequence.
|
|
28
|
-
* @throws {NcpError} NCP-STREAM-SEQ-GAP if sequences don't match.
|
|
29
|
-
*/
|
|
30
|
-
export function validateDiffSeq(frame: DiffFrame, currentSeq: number): void {
|
|
31
|
-
if (frame.base_seq !== currentSeq) {
|
|
32
|
-
throw new NcpError(
|
|
33
|
-
"NCP-STREAM-SEQ-GAP",
|
|
34
|
-
`DiffFrame base_seq=${frame.base_seq} does not match current seq=${currentSeq}`,
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Validate DiffFrame patch_format against the encoding tier.
|
|
41
|
-
*
|
|
42
|
-
* binary_bitset is only supported on Tier-2 (MsgPack) frames.
|
|
43
|
-
* Unknown patch_format values are also rejected.
|
|
44
|
-
*
|
|
45
|
-
* @throws {NcpError} NCP-DIFF-FORMAT-UNSUPPORTED if binary_bitset on non-Tier-2,
|
|
46
|
-
* or if patch_format is an unknown value.
|
|
47
|
-
*/
|
|
48
|
-
export function validateDiffFrame(
|
|
49
|
-
frame: DiffFrame,
|
|
50
|
-
encodingTier: EncodingTier | number,
|
|
51
|
-
): void {
|
|
52
|
-
const fmt = frame.patch_format;
|
|
53
|
-
|
|
54
|
-
// Unknown patch_format
|
|
55
|
-
if (fmt !== undefined && !isValidPatchFormat(fmt)) {
|
|
56
|
-
throw new NcpError(
|
|
57
|
-
"NCP-DIFF-FORMAT-UNSUPPORTED",
|
|
58
|
-
`Unknown patch_format "${String(fmt)}"`,
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// binary_bitset requires Tier-2 MsgPack
|
|
63
|
-
if (fmt === "binary_bitset" && encodingTier !== EncodingTier.MsgPack) {
|
|
64
|
-
throw new NcpError(
|
|
65
|
-
"NCP-DIFF-FORMAT-UNSUPPORTED",
|
|
66
|
-
"patch_format=binary_bitset requires Tier-2 MsgPack encoding",
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
|
|
3
|
-
//
|
|
4
|
-
// ErrorFrame (0xFE) — Unified error frame for all NPS protocol layers
|
|
5
|
-
// NPS-1 §4.7
|
|
6
|
-
|
|
7
|
-
/** Unified error frame shared across all NPS protocol layers. */
|
|
8
|
-
export interface ErrorFrame {
|
|
9
|
-
/** Fixed value "0xFE". */
|
|
10
|
-
frame: string;
|
|
11
|
-
/** NPS status code, e.g. "NPS-CLIENT-NOT-FOUND". */
|
|
12
|
-
status: string;
|
|
13
|
-
/** Protocol-level error code, e.g. "NCP-ANCHOR-NOT-FOUND". */
|
|
14
|
-
error: string;
|
|
15
|
-
/** Human-readable error description. */
|
|
16
|
-
message?: string;
|
|
17
|
-
/** Structured error details (e.g. anchor_ref, stream_id). */
|
|
18
|
-
details?: Record<string, unknown>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** Type guard for ErrorFrame. */
|
|
22
|
-
export function isErrorFrame(obj: unknown): obj is ErrorFrame {
|
|
23
|
-
if (typeof obj !== "object" || obj === null) return false;
|
|
24
|
-
const o = obj as Record<string, unknown>;
|
|
25
|
-
return o.frame === "0xFE" && typeof o.status === "string" && typeof o.error === "string";
|
|
26
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
|
|
3
|
-
//
|
|
4
|
-
// HelloFrame (0x06) — Native-mode client handshake
|
|
5
|
-
// NPS-1 §4.6
|
|
6
|
-
|
|
7
|
-
import { NcpError } from "../../core/frame-header.js";
|
|
8
|
-
|
|
9
|
-
export interface HelloFrame {
|
|
10
|
-
frame: string;
|
|
11
|
-
nps_version: string;
|
|
12
|
-
min_version?: string;
|
|
13
|
-
supported_encodings: string[];
|
|
14
|
-
supported_protocols: string[];
|
|
15
|
-
agent_id?: string;
|
|
16
|
-
max_frame_payload?: number;
|
|
17
|
-
ext_support?: boolean;
|
|
18
|
-
max_concurrent_streams?: number;
|
|
19
|
-
e2e_enc_algorithms?: string[];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Validate a HelloFrame.
|
|
24
|
-
*
|
|
25
|
-
* Required fields: nps_version, supported_encodings (non-empty), supported_protocols (non-empty).
|
|
26
|
-
*
|
|
27
|
-
* @throws {NcpError} NPS-CLIENT-BAD-FRAME if any required field is missing or empty.
|
|
28
|
-
*/
|
|
29
|
-
export function validateHelloFrame(frame: HelloFrame): void {
|
|
30
|
-
if (!frame.nps_version) {
|
|
31
|
-
throw new NcpError(
|
|
32
|
-
"NPS-CLIENT-BAD-FRAME",
|
|
33
|
-
"HelloFrame missing required field: nps_version",
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!frame.supported_encodings || frame.supported_encodings.length === 0) {
|
|
38
|
-
throw new NcpError(
|
|
39
|
-
"NPS-CLIENT-BAD-FRAME",
|
|
40
|
-
"HelloFrame missing required field: supported_encodings (must be non-empty)",
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (!frame.supported_protocols || frame.supported_protocols.length === 0) {
|
|
45
|
-
throw new NcpError(
|
|
46
|
-
"NPS-CLIENT-BAD-FRAME",
|
|
47
|
-
"HelloFrame missing required field: supported_protocols (must be non-empty)",
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
}
|