@labacacia/nps-sdk 1.0.0-alpha.4 → 1.0.0-alpha.6
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 +2 -73
- package/CHANGELOG.md +2 -82
- package/CONTRIBUTING.cn.md +0 -0
- package/CONTRIBUTING.md +0 -0
- package/LICENSE +0 -0
- package/NOTICE +0 -0
- package/README.cn.md +3 -3
- package/README.md +3 -3
- package/doc/nps-sdk.core.cn.md +0 -0
- package/doc/nps-sdk.core.md +0 -0
- package/doc/nps-sdk.ncp.cn.md +0 -0
- package/doc/nps-sdk.ncp.md +0 -0
- package/doc/nps-sdk.ndp.cn.md +0 -0
- package/doc/nps-sdk.ndp.md +0 -0
- package/doc/nps-sdk.nip.cn.md +30 -0
- package/doc/nps-sdk.nip.md +30 -0
- package/doc/nps-sdk.nop.cn.md +0 -0
- package/doc/nps-sdk.nop.md +0 -0
- package/doc/nps-sdk.nwp.cn.md +71 -0
- package/doc/nps-sdk.nwp.md +71 -0
- package/doc/overview.cn.md +0 -0
- package/doc/overview.md +0 -0
- package/nip-ca-server/Dockerfile +0 -0
- package/nip-ca-server/README.md +1 -1
- package/nip-ca-server/db/001_init.sql +0 -0
- package/nip-ca-server/docker-compose.yml +0 -0
- package/nip-ca-server/package.json +0 -0
- package/nip-ca-server/src/ca.ts +0 -0
- package/nip-ca-server/src/db.ts +0 -0
- package/nip-ca-server/src/index.ts +0 -0
- package/nip-ca-server/tsconfig.json +0 -0
- package/package.json +1 -1
- package/src/core/anchor-cache.ts +0 -0
- package/src/core/cache.ts +0 -0
- package/src/core/canonical-json.ts +0 -0
- package/src/core/codec.ts +0 -0
- package/src/core/codecs/index.ts +0 -0
- package/src/core/codecs/ncp-codec.ts +0 -0
- package/src/core/codecs/tier1-json-codec.ts +0 -0
- package/src/core/codecs/tier2-msgpack-codec.ts +0 -0
- package/src/core/crypto-provider.ts +0 -0
- package/src/core/exceptions.ts +0 -0
- package/src/core/frame-header.ts +0 -0
- package/src/core/frame-registry.ts +0 -0
- package/src/core/frames.ts +0 -0
- package/src/core/index.ts +0 -0
- package/src/core/registry.ts +0 -0
- package/src/core/status-codes.ts +1 -0
- package/src/ncp/frames/anchor-frame.ts +0 -0
- package/src/ncp/frames/caps-frame.ts +0 -0
- package/src/ncp/frames/diff-frame.ts +0 -0
- package/src/ncp/frames/error-frame.ts +0 -0
- package/src/ncp/frames/hello-frame.ts +0 -0
- package/src/ncp/frames/stream-frame.ts +0 -0
- package/src/ncp/frames.ts +0 -0
- package/src/ncp/handshake.ts +0 -0
- package/src/ncp/ncp-patch-format.ts +0 -0
- package/src/ncp/registry.ts +0 -0
- package/src/ncp/stream-manager.ts +0 -0
- package/src/ndp/dns-txt.ts +86 -0
- package/src/ndp/frames.ts +0 -0
- package/src/ndp/index.ts +1 -0
- package/src/ndp/ndp-registry.ts +34 -0
- package/src/ndp/registry.ts +0 -0
- package/src/ndp/validator.ts +0 -0
- package/src/nip/assurance-level.ts +6 -1
- package/src/nip/error-codes.ts +4 -2
- package/src/nip/identity.ts +0 -0
- package/src/nip/registry.ts +0 -0
- package/src/nip/x509/oids.ts +3 -4
- package/src/nop/client.ts +1 -1
- package/src/nop/frames.ts +0 -0
- package/src/nop/index.ts +0 -0
- package/src/nop/models.ts +0 -0
- package/src/nop/nop-types.ts +0 -0
- package/src/nop/registry.ts +0 -0
- package/src/nwp/client.ts +4 -4
- package/src/nwp/frames.ts +0 -0
- package/src/nwp/index.ts +0 -0
- package/src/nwp/registry.ts +0 -0
- package/src/setup.ts +0 -0
- package/tests/core/anchor-cache.test.ts +0 -0
- package/tests/core/codec.test.ts +0 -0
- package/tests/core/frame-registry.test.ts +0 -0
- package/tests/core.test.ts +0 -0
- package/tests/ncp/diff-binary-bitset.test.ts +0 -0
- package/tests/ncp/e2e-enc-reject.test.ts +0 -0
- package/tests/ncp/err-error-frame.test.ts +0 -0
- package/tests/ncp/frames.test.ts +0 -0
- package/tests/ncp/framing.test.ts +0 -0
- package/tests/ncp/hello-frame.test.ts +0 -0
- package/tests/ncp/inline-anchor.test.ts +0 -0
- package/tests/ncp/security.test.ts +0 -0
- package/tests/ncp/stream-window.test.ts +0 -0
- package/tests/ncp/stream.test.ts +0 -0
- package/tests/ncp/version-negotiation.test.ts +0 -0
- package/tests/ndp.test.ts +106 -0
- package/tests/nip.test.ts +0 -0
- package/tests/nop.test.ts +0 -0
- package/tests/nwp.test.ts +0 -0
- package/tsconfig.json +0 -0
- package/tsup.config.ts +0 -0
- package/vitest.config.ts +0 -0
- package/dist/core/anchor-cache.d.ts +0 -42
- package/dist/core/anchor-cache.d.ts.map +0 -1
- package/dist/core/anchor-cache.js +0 -104
- package/dist/core/anchor-cache.js.map +0 -1
- package/dist/core/cache.d.ts +0 -14
- package/dist/core/cache.d.ts.map +0 -1
- package/dist/core/cache.js +0 -80
- package/dist/core/cache.js.map +0 -1
- package/dist/core/canonical-json.d.ts +0 -12
- package/dist/core/canonical-json.d.ts.map +0 -1
- package/dist/core/canonical-json.js +0 -44
- package/dist/core/canonical-json.js.map +0 -1
- package/dist/core/codec.d.ts +0 -32
- package/dist/core/codec.d.ts.map +0 -1
- package/dist/core/codec.js +0 -119
- package/dist/core/codec.js.map +0 -1
- package/dist/core/codecs/index.d.ts +0 -4
- package/dist/core/codecs/index.d.ts.map +0 -1
- package/dist/core/codecs/index.js +0 -6
- package/dist/core/codecs/index.js.map +0 -1
- package/dist/core/codecs/ncp-codec.d.ts +0 -39
- package/dist/core/codecs/ncp-codec.d.ts.map +0 -1
- package/dist/core/codecs/ncp-codec.js +0 -93
- package/dist/core/codecs/ncp-codec.js.map +0 -1
- package/dist/core/codecs/tier1-json-codec.d.ts +0 -10
- package/dist/core/codecs/tier1-json-codec.d.ts.map +0 -1
- package/dist/core/codecs/tier1-json-codec.js +0 -28
- package/dist/core/codecs/tier1-json-codec.js.map +0 -1
- package/dist/core/codecs/tier2-msgpack-codec.d.ts +0 -10
- package/dist/core/codecs/tier2-msgpack-codec.d.ts.map +0 -1
- package/dist/core/codecs/tier2-msgpack-codec.js +0 -26
- package/dist/core/codecs/tier2-msgpack-codec.js.map +0 -1
- package/dist/core/crypto-provider.d.ts +0 -31
- package/dist/core/crypto-provider.d.ts.map +0 -1
- package/dist/core/crypto-provider.js +0 -10
- package/dist/core/crypto-provider.js.map +0 -1
- package/dist/core/exceptions.d.ts +0 -27
- package/dist/core/exceptions.d.ts.map +0 -1
- package/dist/core/exceptions.js +0 -52
- package/dist/core/exceptions.js.map +0 -1
- package/dist/core/frame-header.d.ts +0 -87
- package/dist/core/frame-header.d.ts.map +0 -1
- package/dist/core/frame-header.js +0 -185
- package/dist/core/frame-header.js.map +0 -1
- package/dist/core/frame-registry.d.ts +0 -35
- package/dist/core/frame-registry.d.ts.map +0 -1
- package/dist/core/frame-registry.js +0 -63
- package/dist/core/frame-registry.js.map +0 -1
- package/dist/core/frames.d.ts +0 -81
- package/dist/core/frames.d.ts.map +0 -1
- package/dist/core/frames.js +0 -154
- package/dist/core/frames.js.map +0 -1
- package/dist/core/index.d.ts +0 -11
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -22
- package/dist/core/index.js.map +0 -1
- package/dist/core/registry.d.ts +0 -11
- package/dist/core/registry.d.ts.map +0 -1
- package/dist/core/registry.js +0 -17
- package/dist/core/registry.js.map +0 -1
- package/dist/core/status-codes.d.ts +0 -28
- package/dist/core/status-codes.d.ts.map +0 -1
- package/dist/core/status-codes.js +0 -38
- package/dist/core/status-codes.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -10
- package/dist/index.js.map +0 -1
- package/dist/ncp/frames/anchor-frame.d.ts +0 -29
- package/dist/ncp/frames/anchor-frame.d.ts.map +0 -1
- package/dist/ncp/frames/anchor-frame.js +0 -54
- package/dist/ncp/frames/anchor-frame.js.map +0 -1
- package/dist/ncp/frames/caps-frame.d.ts +0 -29
- package/dist/ncp/frames/caps-frame.d.ts.map +0 -1
- package/dist/ncp/frames/caps-frame.js +0 -29
- package/dist/ncp/frames/caps-frame.js.map +0 -1
- package/dist/ncp/frames/diff-frame.d.ts +0 -32
- package/dist/ncp/frames/diff-frame.d.ts.map +0 -1
- package/dist/ncp/frames/diff-frame.js +0 -37
- package/dist/ncp/frames/diff-frame.js.map +0 -1
- package/dist/ncp/frames/error-frame.d.ts +0 -16
- package/dist/ncp/frames/error-frame.d.ts.map +0 -1
- package/dist/ncp/frames/error-frame.js +0 -13
- package/dist/ncp/frames/error-frame.js.map +0 -1
- package/dist/ncp/frames/hello-frame.d.ts +0 -21
- package/dist/ncp/frames/hello-frame.d.ts.map +0 -1
- package/dist/ncp/frames/hello-frame.js +0 -25
- package/dist/ncp/frames/hello-frame.js.map +0 -1
- package/dist/ncp/frames/stream-frame.d.ts +0 -16
- package/dist/ncp/frames/stream-frame.d.ts.map +0 -1
- package/dist/ncp/frames/stream-frame.js +0 -18
- package/dist/ncp/frames/stream-frame.js.map +0 -1
- package/dist/ncp/frames.d.ts +0 -94
- package/dist/ncp/frames.d.ts.map +0 -1
- package/dist/ncp/frames.js +0 -192
- package/dist/ncp/frames.js.map +0 -1
- package/dist/ncp/handshake.d.ts +0 -30
- package/dist/ncp/handshake.d.ts.map +0 -1
- package/dist/ncp/handshake.js +0 -80
- package/dist/ncp/handshake.js.map +0 -1
- package/dist/ncp/index.d.ts +0 -12
- package/dist/ncp/index.d.ts.map +0 -1
- package/dist/ncp/index.js +0 -14
- package/dist/ncp/index.js.map +0 -1
- package/dist/ncp/ncp-error-codes.d.ts +0 -23
- package/dist/ncp/ncp-error-codes.d.ts.map +0 -1
- package/dist/ncp/ncp-error-codes.js +0 -34
- package/dist/ncp/ncp-error-codes.js.map +0 -1
- package/dist/ncp/ncp-patch-format.d.ts +0 -7
- package/dist/ncp/ncp-patch-format.d.ts.map +0 -1
- package/dist/ncp/ncp-patch-format.js +0 -13
- package/dist/ncp/ncp-patch-format.js.map +0 -1
- package/dist/ncp/preamble.d.ts +0 -47
- package/dist/ncp/preamble.d.ts.map +0 -1
- package/dist/ncp/preamble.js +0 -74
- package/dist/ncp/preamble.js.map +0 -1
- package/dist/ncp/registry.d.ts +0 -3
- package/dist/ncp/registry.d.ts.map +0 -1
- package/dist/ncp/registry.js +0 -13
- package/dist/ncp/registry.js.map +0 -1
- package/dist/ncp/stream-manager.d.ts +0 -57
- package/dist/ncp/stream-manager.d.ts.map +0 -1
- package/dist/ncp/stream-manager.js +0 -163
- package/dist/ncp/stream-manager.js.map +0 -1
- package/dist/ndp/frames.d.ts +0 -56
- package/dist/ndp/frames.d.ts.map +0 -1
- package/dist/ndp/frames.js +0 -87
- package/dist/ndp/frames.js.map +0 -1
- package/dist/ndp/index.d.ts +0 -5
- package/dist/ndp/index.d.ts.map +0 -1
- package/dist/ndp/index.js +0 -7
- package/dist/ndp/index.js.map +0 -1
- package/dist/ndp/ndp-registry.d.ts +0 -11
- package/dist/ndp/ndp-registry.d.ts.map +0 -1
- package/dist/ndp/ndp-registry.js +0 -79
- package/dist/ndp/ndp-registry.js.map +0 -1
- package/dist/ndp/registry.d.ts +0 -3
- package/dist/ndp/registry.d.ts.map +0 -1
- package/dist/ndp/registry.js +0 -10
- package/dist/ndp/registry.js.map +0 -1
- package/dist/ndp/validator.d.ts +0 -18
- package/dist/ndp/validator.d.ts.map +0 -1
- package/dist/ndp/validator.js +0 -48
- package/dist/ndp/validator.js.map +0 -1
- package/dist/nip/acme/client.d.ts +0 -31
- package/dist/nip/acme/client.d.ts.map +0 -1
- package/dist/nip/acme/client.js +0 -136
- package/dist/nip/acme/client.js.map +0 -1
- package/dist/nip/acme/index.d.ts +0 -6
- package/dist/nip/acme/index.d.ts.map +0 -1
- package/dist/nip/acme/index.js +0 -8
- package/dist/nip/acme/index.js.map +0 -1
- package/dist/nip/acme/jws.d.ts +0 -31
- package/dist/nip/acme/jws.d.ts.map +0 -1
- package/dist/nip/acme/jws.js +0 -76
- package/dist/nip/acme/jws.js.map +0 -1
- package/dist/nip/acme/messages.d.ts +0 -71
- package/dist/nip/acme/messages.d.ts.map +0 -1
- package/dist/nip/acme/messages.js +0 -4
- package/dist/nip/acme/messages.js.map +0 -1
- package/dist/nip/acme/server.d.ts +0 -41
- package/dist/nip/acme/server.d.ts.map +0 -1
- package/dist/nip/acme/server.js +0 -458
- package/dist/nip/acme/server.js.map +0 -1
- package/dist/nip/acme/wire.d.ts +0 -19
- package/dist/nip/acme/wire.d.ts.map +0 -1
- package/dist/nip/acme/wire.js +0 -21
- package/dist/nip/acme/wire.js.map +0 -1
- package/dist/nip/assurance-level.d.ts +0 -14
- package/dist/nip/assurance-level.d.ts.map +0 -1
- package/dist/nip/assurance-level.js +0 -33
- package/dist/nip/assurance-level.js.map +0 -1
- package/dist/nip/cert-format.d.ts +0 -5
- package/dist/nip/cert-format.d.ts.map +0 -1
- package/dist/nip/cert-format.js +0 -6
- package/dist/nip/cert-format.js.map +0 -1
- package/dist/nip/error-codes.d.ts +0 -23
- package/dist/nip/error-codes.d.ts.map +0 -1
- package/dist/nip/error-codes.js +0 -30
- package/dist/nip/error-codes.js.map +0 -1
- package/dist/nip/frames.d.ts +0 -53
- package/dist/nip/frames.d.ts.map +0 -1
- package/dist/nip/frames.js +0 -106
- package/dist/nip/frames.js.map +0 -1
- package/dist/nip/identity.d.ts +0 -18
- package/dist/nip/identity.d.ts.map +0 -1
- package/dist/nip/identity.js +0 -94
- package/dist/nip/identity.js.map +0 -1
- package/dist/nip/index.d.ts +0 -10
- package/dist/nip/index.d.ts.map +0 -1
- package/dist/nip/index.js +0 -13
- package/dist/nip/index.js.map +0 -1
- package/dist/nip/registry.d.ts +0 -3
- package/dist/nip/registry.d.ts.map +0 -1
- package/dist/nip/registry.js +0 -10
- package/dist/nip/registry.js.map +0 -1
- package/dist/nip/verifier.d.ts +0 -23
- package/dist/nip/verifier.d.ts.map +0 -1
- package/dist/nip/verifier.js +0 -90
- package/dist/nip/verifier.js.map +0 -1
- package/dist/nip/x509/builder.d.ts +0 -35
- package/dist/nip/x509/builder.d.ts.map +0 -1
- package/dist/nip/x509/builder.js +0 -59
- package/dist/nip/x509/builder.js.map +0 -1
- package/dist/nip/x509/index.d.ts +0 -4
- package/dist/nip/x509/index.d.ts.map +0 -1
- package/dist/nip/x509/index.js +0 -6
- package/dist/nip/x509/index.js.map +0 -1
- package/dist/nip/x509/oids.d.ts +0 -17
- package/dist/nip/x509/oids.d.ts.map +0 -1
- package/dist/nip/x509/oids.js +0 -23
- package/dist/nip/x509/oids.js.map +0 -1
- package/dist/nip/x509/verifier.d.ts +0 -26
- package/dist/nip/x509/verifier.d.ts.map +0 -1
- package/dist/nip/x509/verifier.js +0 -171
- package/dist/nip/x509/verifier.js.map +0 -1
- package/dist/nop/client.d.ts +0 -34
- package/dist/nop/client.d.ts.map +0 -1
- package/dist/nop/client.js +0 -90
- package/dist/nop/client.js.map +0 -1
- package/dist/nop/frames.d.ts +0 -65
- package/dist/nop/frames.d.ts.map +0 -1
- package/dist/nop/frames.js +0 -148
- package/dist/nop/frames.js.map +0 -1
- package/dist/nop/index.d.ts +0 -5
- package/dist/nop/index.d.ts.map +0 -1
- package/dist/nop/index.js +0 -7
- package/dist/nop/index.js.map +0 -1
- package/dist/nop/models.d.ts +0 -58
- package/dist/nop/models.d.ts.map +0 -1
- package/dist/nop/models.js +0 -50
- package/dist/nop/models.js.map +0 -1
- package/dist/nop/nop-types.d.ts +0 -136
- package/dist/nop/nop-types.d.ts.map +0 -1
- package/dist/nop/nop-types.js +0 -44
- package/dist/nop/nop-types.js.map +0 -1
- package/dist/nop/registry.d.ts +0 -3
- package/dist/nop/registry.d.ts.map +0 -1
- package/dist/nop/registry.js +0 -11
- package/dist/nop/registry.js.map +0 -1
- package/dist/nwp/client.d.ts +0 -22
- package/dist/nwp/client.d.ts.map +0 -1
- package/dist/nwp/client.js +0 -101
- package/dist/nwp/client.js.map +0 -1
- package/dist/nwp/frames.d.ts +0 -46
- package/dist/nwp/frames.d.ts.map +0 -1
- package/dist/nwp/frames.js +0 -81
- package/dist/nwp/frames.js.map +0 -1
- package/dist/nwp/index.d.ts +0 -4
- package/dist/nwp/index.d.ts.map +0 -1
- package/dist/nwp/index.js +0 -6
- package/dist/nwp/index.js.map +0 -1
- package/dist/nwp/registry.d.ts +0 -3
- package/dist/nwp/registry.d.ts.map +0 -1
- package/dist/nwp/registry.js +0 -9
- package/dist/nwp/registry.js.map +0 -1
- package/dist/setup.d.ts +0 -10
- package/dist/setup.d.ts.map +0 -1
- package/dist/setup.js +0 -29
- package/dist/setup.js.map +0 -1
package/dist/core/frames.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 INNO LOTUS PTY LTD
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
/**
|
|
4
|
-
* NPS wire-level frame primitives: FrameType, FrameFlags, EncodingTier, FrameHeader.
|
|
5
|
-
*/
|
|
6
|
-
import { NpsFrameError } from "./exceptions.js";
|
|
7
|
-
// ── FrameType ────────────────────────────────────────────────────────────────
|
|
8
|
-
/** Unified frame byte namespace for the full NPS suite (NPS-0 §9). */
|
|
9
|
-
export var FrameType;
|
|
10
|
-
(function (FrameType) {
|
|
11
|
-
// NCP 0x01–0x0F
|
|
12
|
-
FrameType[FrameType["ANCHOR"] = 1] = "ANCHOR";
|
|
13
|
-
FrameType[FrameType["DIFF"] = 2] = "DIFF";
|
|
14
|
-
FrameType[FrameType["STREAM"] = 3] = "STREAM";
|
|
15
|
-
FrameType[FrameType["CAPS"] = 4] = "CAPS";
|
|
16
|
-
FrameType[FrameType["ALIGN"] = 5] = "ALIGN";
|
|
17
|
-
FrameType[FrameType["HELLO"] = 6] = "HELLO";
|
|
18
|
-
// NWP 0x10–0x1F
|
|
19
|
-
FrameType[FrameType["QUERY"] = 16] = "QUERY";
|
|
20
|
-
FrameType[FrameType["ACTION"] = 17] = "ACTION";
|
|
21
|
-
// NIP 0x20–0x2F
|
|
22
|
-
FrameType[FrameType["IDENT"] = 32] = "IDENT";
|
|
23
|
-
FrameType[FrameType["TRUST"] = 33] = "TRUST";
|
|
24
|
-
FrameType[FrameType["REVOKE"] = 34] = "REVOKE";
|
|
25
|
-
// NDP 0x30–0x3F
|
|
26
|
-
FrameType[FrameType["ANNOUNCE"] = 48] = "ANNOUNCE";
|
|
27
|
-
FrameType[FrameType["RESOLVE"] = 49] = "RESOLVE";
|
|
28
|
-
FrameType[FrameType["GRAPH"] = 50] = "GRAPH";
|
|
29
|
-
// NOP 0x40–0x4F
|
|
30
|
-
FrameType[FrameType["TASK"] = 64] = "TASK";
|
|
31
|
-
FrameType[FrameType["DELEGATE"] = 65] = "DELEGATE";
|
|
32
|
-
FrameType[FrameType["SYNC"] = 66] = "SYNC";
|
|
33
|
-
FrameType[FrameType["ALIGN_STREAM"] = 67] = "ALIGN_STREAM";
|
|
34
|
-
// Reserved / System 0xF0–0xFF
|
|
35
|
-
FrameType[FrameType["ERROR"] = 254] = "ERROR";
|
|
36
|
-
})(FrameType || (FrameType = {}));
|
|
37
|
-
// ── EncodingTier ─────────────────────────────────────────────────────────────
|
|
38
|
-
/**
|
|
39
|
-
* Wire encoding tier, stored in the lower 2 bits of the flags byte (NPS-1 §3.2).
|
|
40
|
-
* 0x00 = Tier-1 JSON — human-readable; development / compatibility.
|
|
41
|
-
* 0x01 = Tier-2 MsgPack — binary, ~60 % smaller; production default.
|
|
42
|
-
*/
|
|
43
|
-
export var EncodingTier;
|
|
44
|
-
(function (EncodingTier) {
|
|
45
|
-
EncodingTier[EncodingTier["JSON"] = 0] = "JSON";
|
|
46
|
-
EncodingTier[EncodingTier["MSGPACK"] = 1] = "MSGPACK";
|
|
47
|
-
})(EncodingTier || (EncodingTier = {}));
|
|
48
|
-
// ── FrameFlags ───────────────────────────────────────────────────────────────
|
|
49
|
-
/**
|
|
50
|
-
* Flags byte in the NPS frame header (NPS-1 §3.2).
|
|
51
|
-
* Bit layout (LSB = bit 0):
|
|
52
|
-
* Bits 0–1 (T0,T1) : Encoding tier
|
|
53
|
-
* Bit 2 (FINAL) : Last chunk of a StreamFrame; non-stream frames MUST set this
|
|
54
|
-
* Bit 3 (ENC) : Payload encrypted
|
|
55
|
-
* Bits 4–6 (RSV) : Reserved — sender MUST write 0
|
|
56
|
-
* Bit 7 (EXT) : Extended 8-byte header
|
|
57
|
-
*/
|
|
58
|
-
export const FrameFlags = {
|
|
59
|
-
NONE: 0x00,
|
|
60
|
-
TIER1_JSON: 0x00,
|
|
61
|
-
TIER2_MSGPACK: 0x01,
|
|
62
|
-
FINAL: 0x04,
|
|
63
|
-
ENCRYPTED: 0x08,
|
|
64
|
-
EXT: 0x80,
|
|
65
|
-
};
|
|
66
|
-
// ── Constants ─────────────────────────────────────────────────────────────────
|
|
67
|
-
export const DEFAULT_HEADER_SIZE = 4;
|
|
68
|
-
export const EXTENDED_HEADER_SIZE = 8;
|
|
69
|
-
export const DEFAULT_MAX_PAYLOAD = 0xffff; // 65 535 bytes
|
|
70
|
-
export const EXTENDED_MAX_PAYLOAD = 0xffffffff; // 4 GiB - 1
|
|
71
|
-
// ── FrameHeader ──────────────────────────────────────────────────────────────
|
|
72
|
-
/**
|
|
73
|
-
* NPS frame header, present at the start of every wire message (NPS-1 §3.1).
|
|
74
|
-
*
|
|
75
|
-
* Default (4 bytes, EXT=0):
|
|
76
|
-
* Byte 0 : FrameType
|
|
77
|
-
* Byte 1 : Flags
|
|
78
|
-
* Byte 2–3 : PayloadLength (big-endian uint16)
|
|
79
|
-
*
|
|
80
|
-
* Extended (8 bytes, EXT=1):
|
|
81
|
-
* Byte 0 : FrameType
|
|
82
|
-
* Byte 1 : Flags (bit 7 = 1)
|
|
83
|
-
* Byte 2–3 : Reserved (must be 0)
|
|
84
|
-
* Byte 4–7 : PayloadLength (big-endian uint32)
|
|
85
|
-
*/
|
|
86
|
-
export class FrameHeader {
|
|
87
|
-
frameType;
|
|
88
|
-
flags;
|
|
89
|
-
payloadLength;
|
|
90
|
-
constructor(frameType, flags, payloadLength) {
|
|
91
|
-
this.frameType = frameType;
|
|
92
|
-
this.flags = flags;
|
|
93
|
-
this.payloadLength = payloadLength;
|
|
94
|
-
}
|
|
95
|
-
get isExtended() {
|
|
96
|
-
return (this.flags & FrameFlags.EXT) !== 0;
|
|
97
|
-
}
|
|
98
|
-
get headerSize() {
|
|
99
|
-
return this.isExtended ? EXTENDED_HEADER_SIZE : DEFAULT_HEADER_SIZE;
|
|
100
|
-
}
|
|
101
|
-
get encodingTier() {
|
|
102
|
-
return (this.flags & 0x03);
|
|
103
|
-
}
|
|
104
|
-
get isFinal() {
|
|
105
|
-
return (this.flags & 0x04) !== 0;
|
|
106
|
-
}
|
|
107
|
-
get isEncrypted() {
|
|
108
|
-
return (this.flags & 0x08) !== 0;
|
|
109
|
-
}
|
|
110
|
-
// ── Parsing ───────────────────────────────────────────────────────────────
|
|
111
|
-
static parse(buf) {
|
|
112
|
-
if (buf.length < 2) {
|
|
113
|
-
throw new NpsFrameError(`Buffer too small to read frame type and flags: need >= 2 bytes, got ${buf.length}.`);
|
|
114
|
-
}
|
|
115
|
-
const flags = buf[1];
|
|
116
|
-
const ext = (flags & FrameFlags.EXT) !== 0;
|
|
117
|
-
if (ext) {
|
|
118
|
-
if (buf.length < EXTENDED_HEADER_SIZE) {
|
|
119
|
-
throw new NpsFrameError(`Buffer too small for extended frame header: need ${EXTENDED_HEADER_SIZE} bytes, got ${buf.length}.`);
|
|
120
|
-
}
|
|
121
|
-
const view = new DataView(buf.buffer, buf.byteOffset);
|
|
122
|
-
const payloadLength = view.getUint32(4, false); // big-endian
|
|
123
|
-
return new FrameHeader(buf[0], flags, payloadLength);
|
|
124
|
-
}
|
|
125
|
-
if (buf.length < DEFAULT_HEADER_SIZE) {
|
|
126
|
-
throw new NpsFrameError(`Buffer too small for frame header: need ${DEFAULT_HEADER_SIZE} bytes, got ${buf.length}.`);
|
|
127
|
-
}
|
|
128
|
-
const view = new DataView(buf.buffer, buf.byteOffset);
|
|
129
|
-
const payloadLength = view.getUint16(2, false); // big-endian
|
|
130
|
-
return new FrameHeader(buf[0], flags, payloadLength);
|
|
131
|
-
}
|
|
132
|
-
// ── Serialisation ─────────────────────────────────────────────────────────
|
|
133
|
-
toBytes() {
|
|
134
|
-
if (this.isExtended) {
|
|
135
|
-
const buf = new Uint8Array(EXTENDED_HEADER_SIZE);
|
|
136
|
-
const view = new DataView(buf.buffer);
|
|
137
|
-
view.setUint8(0, this.frameType);
|
|
138
|
-
view.setUint8(1, this.flags);
|
|
139
|
-
view.setUint16(2, 0, false); // reserved
|
|
140
|
-
view.setUint32(4, this.payloadLength, false);
|
|
141
|
-
return buf;
|
|
142
|
-
}
|
|
143
|
-
const buf = new Uint8Array(DEFAULT_HEADER_SIZE);
|
|
144
|
-
const view = new DataView(buf.buffer);
|
|
145
|
-
view.setUint8(0, this.frameType);
|
|
146
|
-
view.setUint8(1, this.flags);
|
|
147
|
-
view.setUint16(2, this.payloadLength, false);
|
|
148
|
-
return buf;
|
|
149
|
-
}
|
|
150
|
-
toString() {
|
|
151
|
-
return `FrameHeader(frameType=0x${this.frameType.toString(16).padStart(2, "0")}, flags=0x${this.flags.toString(16).padStart(2, "0")}, payloadLength=${this.payloadLength})`;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
//# sourceMappingURL=frames.js.map
|
package/dist/core/frames.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"frames.js","sourceRoot":"","sources":["../../src/core/frames.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,sCAAsC;AAEtC;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,gFAAgF;AAEhF,sEAAsE;AACtE,MAAM,CAAN,IAAY,SA+BX;AA/BD,WAAY,SAAS;IACnB,iBAAiB;IACjB,6CAAmB,CAAA;IACnB,yCAAmB,CAAA;IACnB,6CAAmB,CAAA;IACnB,yCAAmB,CAAA;IACnB,2CAAmB,CAAA;IACnB,2CAAmB,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C,GAAG,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACjC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;QAC7C,OAAO,GAAG,CAAC;IACb,CAAC;IAED,QAAQ;QACN,OAAO,2BAA2B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,mBAAmB,IAAI,CAAC,aAAa,GAAG,CAAC;IAC9K,CAAC;CACF"}
|
package/dist/core/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { FrameType, EncodingTier, FrameFlags, FrameHeader, DEFAULT_HEADER_SIZE, EXTENDED_HEADER_SIZE, DEFAULT_MAX_PAYLOAD, EXTENDED_MAX_PAYLOAD, } from "./frames.js";
|
|
2
|
-
export { Tier1JsonCodec, Tier2MsgPackCodec, NpsFrameCodec, } from "./codec.js";
|
|
3
|
-
export type { NpsFrame } from "./codec.js";
|
|
4
|
-
export { FrameRegistry } from "./registry.js";
|
|
5
|
-
export type { FrameClass } from "./registry.js";
|
|
6
|
-
export { AnchorFrameCache } from "./cache.js";
|
|
7
|
-
export * from "./exceptions.js";
|
|
8
|
-
export * from "./status-codes.js";
|
|
9
|
-
export { jcsStringify, sortKeysStringify } from "./canonical-json.js";
|
|
10
|
-
export type { CryptoProvider } from "./crypto-provider.js";
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG9C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACtE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/core/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 INNO LOTUS PTY LTD
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
//
|
|
4
|
-
// @labacacia/nps-sdk/core — public re-exports for NCP wire primitives.
|
|
5
|
-
//
|
|
6
|
-
// This module exposes the shipped OOP codec API used by NWP / NOP / NIP / NDP
|
|
7
|
-
// clients. The parallel functional API under ./codecs/ and ./frame-header.js
|
|
8
|
-
// remains importable by direct path but is not re-exported here to avoid
|
|
9
|
-
// symbol collisions (both files define FrameType / EncodingTier / FrameHeader).
|
|
10
|
-
// ── Frame primitives (OOP) ────────────────────────────────────────────────────
|
|
11
|
-
export { FrameType, EncodingTier, FrameFlags, FrameHeader, DEFAULT_HEADER_SIZE, EXTENDED_HEADER_SIZE, DEFAULT_MAX_PAYLOAD, EXTENDED_MAX_PAYLOAD, } from "./frames.js";
|
|
12
|
-
// ── Codec (OOP) ───────────────────────────────────────────────────────────────
|
|
13
|
-
export { Tier1JsonCodec, Tier2MsgPackCodec, NpsFrameCodec, } from "./codec.js";
|
|
14
|
-
// ── Registry (OOP) ────────────────────────────────────────────────────────────
|
|
15
|
-
export { FrameRegistry } from "./registry.js";
|
|
16
|
-
// ── Anchor cache (OOP) ────────────────────────────────────────────────────────
|
|
17
|
-
export { AnchorFrameCache } from "./cache.js";
|
|
18
|
-
// ── Exceptions / Status / Canonical JSON ──────────────────────────────────────
|
|
19
|
-
export * from "./exceptions.js";
|
|
20
|
-
export * from "./status-codes.js";
|
|
21
|
-
export { jcsStringify, sortKeysStringify } from "./canonical-json.js";
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
package/dist/core/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,sCAAsC;AACtC,EAAE;AACF,uEAAuE;AACvE,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,yEAAyE;AACzE,gFAAgF;AAEhF,iFAAiF;AACjF,OAAO,EACL,SAAS,EACT,YAAY,EACZ,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAErB,iFAAiF;AACjF,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,aAAa,GACd,MAAM,YAAY,CAAC;AAGpB,iFAAiF;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,iFAAiF;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,iFAAiF;AACjF,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/core/registry.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { FrameType } from "./frames.js";
|
|
2
|
-
import type { NpsFrame } from "./codec.js";
|
|
3
|
-
export interface FrameClass {
|
|
4
|
-
fromDict(data: Record<string, unknown>): NpsFrame;
|
|
5
|
-
}
|
|
6
|
-
export declare class FrameRegistry {
|
|
7
|
-
private readonly _map;
|
|
8
|
-
register(frameType: FrameType, cls: FrameClass): void;
|
|
9
|
-
resolve(frameType: FrameType): FrameClass;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/core/registry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC;CACnD;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAoC;IAEzD,QAAQ,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,GAAG,IAAI;IAIrD,OAAO,CAAC,SAAS,EAAE,SAAS,GAAG,UAAU;CAS1C"}
|
package/dist/core/registry.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 INNO LOTUS PTY LTD
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { NpsFrameError } from "./exceptions.js";
|
|
4
|
-
export class FrameRegistry {
|
|
5
|
-
_map = new Map();
|
|
6
|
-
register(frameType, cls) {
|
|
7
|
-
this._map.set(frameType, cls);
|
|
8
|
-
}
|
|
9
|
-
resolve(frameType) {
|
|
10
|
-
const cls = this._map.get(frameType);
|
|
11
|
-
if (cls === undefined) {
|
|
12
|
-
throw new NpsFrameError(`No frame class registered for type 0x${frameType.toString(16).padStart(2, "0")}.`);
|
|
13
|
-
}
|
|
14
|
-
return cls;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/core/registry.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,sCAAsC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAQhD,MAAM,OAAO,aAAa;IACP,IAAI,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEzD,QAAQ,CAAC,SAAoB,EAAE,GAAe;QAC5C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,CAAC,SAAoB;QAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACrC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,IAAI,aAAa,CACrB,wCAAwC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CACnF,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/** NPS native status code constants. */
|
|
2
|
-
export declare const NpsStatusCodes: {
|
|
3
|
-
readonly NPS_OK: "NPS-OK";
|
|
4
|
-
readonly NPS_OK_ACCEPTED: "NPS-OK-ACCEPTED";
|
|
5
|
-
readonly NPS_OK_NO_CONTENT: "NPS-OK-NO-CONTENT";
|
|
6
|
-
readonly NPS_AUTH_UNAUTHENTICATED: "NPS-AUTH-UNAUTHENTICATED";
|
|
7
|
-
readonly NPS_AUTH_FORBIDDEN: "NPS-AUTH-FORBIDDEN";
|
|
8
|
-
readonly NPS_CLIENT_BAD_FRAME: "NPS-CLIENT-BAD-FRAME";
|
|
9
|
-
readonly NPS_CLIENT_BAD_PARAM: "NPS-CLIENT-BAD-PARAM";
|
|
10
|
-
readonly NPS_CLIENT_NOT_FOUND: "NPS-CLIENT-NOT-FOUND";
|
|
11
|
-
readonly NPS_CLIENT_CONFLICT: "NPS-CLIENT-CONFLICT";
|
|
12
|
-
readonly NPS_CLIENT_GONE: "NPS-CLIENT-GONE";
|
|
13
|
-
readonly NPS_CLIENT_UNPROCESSABLE: "NPS-CLIENT-UNPROCESSABLE";
|
|
14
|
-
readonly NPS_SERVER_INTERNAL: "NPS-SERVER-INTERNAL";
|
|
15
|
-
readonly NPS_SERVER_UNAVAILABLE: "NPS-SERVER-UNAVAILABLE";
|
|
16
|
-
readonly NPS_SERVER_TIMEOUT: "NPS-SERVER-TIMEOUT";
|
|
17
|
-
readonly NPS_SERVER_ENCODING_UNSUPPORTED: "NPS-SERVER-ENCODING-UNSUPPORTED";
|
|
18
|
-
readonly NPS_STREAM_SEQ_GAP: "NPS-STREAM-SEQ-GAP";
|
|
19
|
-
readonly NPS_STREAM_NOT_FOUND: "NPS-STREAM-NOT-FOUND";
|
|
20
|
-
readonly NPS_STREAM_LIMIT: "NPS-STREAM-LIMIT";
|
|
21
|
-
readonly NPS_LIMIT_RATE: "NPS-LIMIT-RATE";
|
|
22
|
-
readonly NPS_LIMIT_BUDGET: "NPS-LIMIT-BUDGET";
|
|
23
|
-
readonly NPS_LIMIT_PAYLOAD: "NPS-LIMIT-PAYLOAD";
|
|
24
|
-
readonly NPS_LIMIT_EXCEEDED: "NPS-LIMIT-EXCEEDED";
|
|
25
|
-
readonly NPS_PROTO_VERSION_INCOMPATIBLE: "NPS-PROTO-VERSION-INCOMPATIBLE";
|
|
26
|
-
};
|
|
27
|
-
export type NpsStatusCode = (typeof NpsStatusCodes)[keyof typeof NpsStatusCodes];
|
|
28
|
-
//# sourceMappingURL=status-codes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"status-codes.d.ts","sourceRoot":"","sources":["../../src/core/status-codes.ts"],"names":[],"mappings":"AAKA,wCAAwC;AACxC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;CAqCjB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC"}
|
|
@@ -1,38 +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
|
-
/** NPS native status code constants. */
|
|
6
|
-
export const NpsStatusCodes = {
|
|
7
|
-
// Success
|
|
8
|
-
NPS_OK: "NPS-OK",
|
|
9
|
-
NPS_OK_ACCEPTED: "NPS-OK-ACCEPTED",
|
|
10
|
-
NPS_OK_NO_CONTENT: "NPS-OK-NO-CONTENT",
|
|
11
|
-
// Auth
|
|
12
|
-
NPS_AUTH_UNAUTHENTICATED: "NPS-AUTH-UNAUTHENTICATED",
|
|
13
|
-
NPS_AUTH_FORBIDDEN: "NPS-AUTH-FORBIDDEN",
|
|
14
|
-
// Client errors
|
|
15
|
-
NPS_CLIENT_BAD_FRAME: "NPS-CLIENT-BAD-FRAME",
|
|
16
|
-
NPS_CLIENT_BAD_PARAM: "NPS-CLIENT-BAD-PARAM",
|
|
17
|
-
NPS_CLIENT_NOT_FOUND: "NPS-CLIENT-NOT-FOUND",
|
|
18
|
-
NPS_CLIENT_CONFLICT: "NPS-CLIENT-CONFLICT",
|
|
19
|
-
NPS_CLIENT_GONE: "NPS-CLIENT-GONE",
|
|
20
|
-
NPS_CLIENT_UNPROCESSABLE: "NPS-CLIENT-UNPROCESSABLE",
|
|
21
|
-
// Server errors
|
|
22
|
-
NPS_SERVER_INTERNAL: "NPS-SERVER-INTERNAL",
|
|
23
|
-
NPS_SERVER_UNAVAILABLE: "NPS-SERVER-UNAVAILABLE",
|
|
24
|
-
NPS_SERVER_TIMEOUT: "NPS-SERVER-TIMEOUT",
|
|
25
|
-
NPS_SERVER_ENCODING_UNSUPPORTED: "NPS-SERVER-ENCODING-UNSUPPORTED",
|
|
26
|
-
// Stream
|
|
27
|
-
NPS_STREAM_SEQ_GAP: "NPS-STREAM-SEQ-GAP",
|
|
28
|
-
NPS_STREAM_NOT_FOUND: "NPS-STREAM-NOT-FOUND",
|
|
29
|
-
NPS_STREAM_LIMIT: "NPS-STREAM-LIMIT",
|
|
30
|
-
// Limit
|
|
31
|
-
NPS_LIMIT_RATE: "NPS-LIMIT-RATE",
|
|
32
|
-
NPS_LIMIT_BUDGET: "NPS-LIMIT-BUDGET",
|
|
33
|
-
NPS_LIMIT_PAYLOAD: "NPS-LIMIT-PAYLOAD",
|
|
34
|
-
NPS_LIMIT_EXCEEDED: "NPS-LIMIT-EXCEEDED",
|
|
35
|
-
// Protocol
|
|
36
|
-
NPS_PROTO_VERSION_INCOMPATIBLE: "NPS-PROTO-VERSION-INCOMPATIBLE",
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=status-codes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"status-codes.js","sourceRoot":"","sources":["../../src/core/status-codes.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,oDAAoD;AACpD,EAAE;AACF,qDAAqD;AAErD,wCAAwC;AACxC,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,UAAU;IACV,MAAM,EAAE,QAAQ;IAChB,eAAe,EAAE,iBAAiB;IAClC,iBAAiB,EAAE,mBAAmB;IAEtC,OAAO;IACP,wBAAwB,EAAE,0BAA0B;IACpD,kBAAkB,EAAE,oBAAoB;IAExC,gBAAgB;IAChB,oBAAoB,EAAE,sBAAsB;IAC5C,oBAAoB,EAAE,sBAAsB;IAC5C,oBAAoB,EAAE,sBAAsB;IAC5C,mBAAmB,EAAE,qBAAqB;IAC1C,eAAe,EAAE,iBAAiB;IAClC,wBAAwB,EAAE,0BAA0B;IAEpD,gBAAgB;IAChB,mBAAmB,EAAE,qBAAqB;IAC1C,sBAAsB,EAAE,wBAAwB;IAChD,kBAAkB,EAAE,oBAAoB;IACxC,+BAA+B,EAAE,iCAAiC;IAElE,SAAS;IACT,kBAAkB,EAAE,oBAAoB;IACxC,oBAAoB,EAAE,sBAAsB;IAC5C,gBAAgB,EAAE,kBAAkB;IAEpC,QAAQ;IACR,cAAc,EAAE,gBAAgB;IAChC,gBAAgB,EAAE,kBAAkB;IACpC,iBAAiB,EAAE,mBAAmB;IACtC,kBAAkB,EAAE,oBAAoB;IAExC,WAAW;IACX,8BAA8B,EAAE,gCAAgC;CACxD,CAAC"}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,OAAO,kBAAkB,CAAC"}
|
package/dist/index.js
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
|
-
export const VERSION = "1.0.0-alpha.2";
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,oDAAoD;AACpD,EAAE;AACF,yCAAyC;AACzC,iEAAiE;AACjE,0DAA0D;AAC1D,kDAAkD;AAClD,iDAAiD;AAEjD,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
declare const VALID_FIELD_TYPES: readonly ["string", "uint64", "int64", "decimal", "bool", "timestamp", "bytes", "object", "array"];
|
|
2
|
-
export type SchemaFieldType = (typeof VALID_FIELD_TYPES)[number];
|
|
3
|
-
export interface SchemaField {
|
|
4
|
-
name: string;
|
|
5
|
-
type: string;
|
|
6
|
-
semantic?: string;
|
|
7
|
-
nullable?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface FrameSchema {
|
|
10
|
-
fields: SchemaField[];
|
|
11
|
-
}
|
|
12
|
-
export interface AnchorFrame {
|
|
13
|
-
frame: string;
|
|
14
|
-
anchor_id: string;
|
|
15
|
-
schema: FrameSchema;
|
|
16
|
-
ttl?: number;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Compute anchor_id from schema using RFC 8785 JCS canonicalization + SHA-256.
|
|
20
|
-
* Format: "sha256:{64 lowercase hex chars}"
|
|
21
|
-
*/
|
|
22
|
-
export declare function computeAnchorId(schema: FrameSchema): string;
|
|
23
|
-
/**
|
|
24
|
-
* Validate an AnchorFrame.
|
|
25
|
-
* @throws {NcpError} NCP-ANCHOR-SCHEMA-INVALID if anchor_id doesn't match or schema is invalid.
|
|
26
|
-
*/
|
|
27
|
-
export declare function validateAnchorFrame(frame: AnchorFrame): void;
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=anchor-frame.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anchor-frame.d.ts","sourceRoot":"","sources":["../../../src/ncp/frames/anchor-frame.ts"],"names":[],"mappings":"AAgBA,QAAA,MAAM,iBAAiB,oGAGb,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjE,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAMD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAO3D;AAMD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAoB5D"}
|
|
@@ -1,54 +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
|
-
import { createHash } from "node:crypto";
|
|
7
|
-
// canonicalize ships CJS with TS `export default` — NodeNext resolves as namespace
|
|
8
|
-
import canonicalizeDefault from "canonicalize";
|
|
9
|
-
const canonicalize = canonicalizeDefault;
|
|
10
|
-
import { NcpError } from "../../core/frame-header.js";
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
// Types
|
|
13
|
-
// ---------------------------------------------------------------------------
|
|
14
|
-
const VALID_FIELD_TYPES = [
|
|
15
|
-
"string", "uint64", "int64", "decimal", "bool",
|
|
16
|
-
"timestamp", "bytes", "object", "array",
|
|
17
|
-
];
|
|
18
|
-
// ---------------------------------------------------------------------------
|
|
19
|
-
// anchor_id computation (RFC 8785 JCS + SHA-256)
|
|
20
|
-
// ---------------------------------------------------------------------------
|
|
21
|
-
/**
|
|
22
|
-
* Compute anchor_id from schema using RFC 8785 JCS canonicalization + SHA-256.
|
|
23
|
-
* Format: "sha256:{64 lowercase hex chars}"
|
|
24
|
-
*/
|
|
25
|
-
export function computeAnchorId(schema) {
|
|
26
|
-
const canonical = canonicalize(schema);
|
|
27
|
-
if (!canonical) {
|
|
28
|
-
throw new NcpError("NCP-ANCHOR-SCHEMA-INVALID", "Schema cannot be canonicalized");
|
|
29
|
-
}
|
|
30
|
-
const hash = createHash("sha256").update(canonical).digest("hex");
|
|
31
|
-
return `sha256:${hash}`;
|
|
32
|
-
}
|
|
33
|
-
// ---------------------------------------------------------------------------
|
|
34
|
-
// Validation
|
|
35
|
-
// ---------------------------------------------------------------------------
|
|
36
|
-
/**
|
|
37
|
-
* Validate an AnchorFrame.
|
|
38
|
-
* @throws {NcpError} NCP-ANCHOR-SCHEMA-INVALID if anchor_id doesn't match or schema is invalid.
|
|
39
|
-
*/
|
|
40
|
-
export function validateAnchorFrame(frame) {
|
|
41
|
-
// Validate schema field types
|
|
42
|
-
for (const field of frame.schema.fields) {
|
|
43
|
-
if (!VALID_FIELD_TYPES.includes(field.type)) {
|
|
44
|
-
throw new NcpError("NCP-ANCHOR-SCHEMA-INVALID", `Unsupported field type "${field.type}" for field "${field.name}". ` +
|
|
45
|
-
`Valid types: ${VALID_FIELD_TYPES.join(", ")}`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
// Validate anchor_id matches computed hash
|
|
49
|
-
const expected = computeAnchorId(frame.schema);
|
|
50
|
-
if (frame.anchor_id !== expected) {
|
|
51
|
-
throw new NcpError("NCP-ANCHOR-SCHEMA-INVALID", `anchor_id mismatch: expected ${expected}, got ${frame.anchor_id}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=anchor-frame.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anchor-frame.js","sourceR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ChB,2BAA2B,EAC3B,2BAA2B,KAAK,CAAC,IAAI,gBAAgB,KAAK,CAAC,IAAI,KAAK;gBAClE,gBAAgB,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACjD,CAAC;QACJ,CAAC;IACH,CAAC;IAED,2CAA2C;IAC3C,MAAM,QAAQ,GAAG,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/C,IAAI,KAAK,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;QACjC,MAAM,IAAI,QAAQ,CAChB,2BAA2B,EAC3B,gCAAgC,QAAQ,SAAS,KAAK,CAAC,SAAS,EAAE,CACnE,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { type FrameSchema } from "./anchor-frame.js";
|
|
2
|
-
export interface CapsFrameInlineAnchor {
|
|
3
|
-
anchor_id: string;
|
|
4
|
-
schema: FrameSchema;
|
|
5
|
-
ttl?: number;
|
|
6
|
-
}
|
|
7
|
-
export interface CapsFrame {
|
|
8
|
-
frame: string;
|
|
9
|
-
anchor_ref: string;
|
|
10
|
-
count: number;
|
|
11
|
-
data: unknown[];
|
|
12
|
-
next_cursor?: string | null;
|
|
13
|
-
token_est?: number;
|
|
14
|
-
tokenizer_used?: string;
|
|
15
|
-
cached?: boolean;
|
|
16
|
-
inline_anchor?: CapsFrameInlineAnchor;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Validate a CapsFrame.
|
|
20
|
-
*
|
|
21
|
-
* Checks:
|
|
22
|
-
* - count matches data.length (NPS-CLIENT-BAD-FRAME)
|
|
23
|
-
* - if inline_anchor present, recomputes anchor_id and validates match (NCP-ANCHOR-SCHEMA-INVALID)
|
|
24
|
-
*
|
|
25
|
-
* @throws {NcpError} NPS-CLIENT-BAD-FRAME if count doesn't match data length.
|
|
26
|
-
* @throws {NcpError} NCP-ANCHOR-SCHEMA-INVALID if inline_anchor.anchor_id doesn't match schema.
|
|
27
|
-
*/
|
|
28
|
-
export declare function validateCapsFrame(frame: CapsFrame): void;
|
|
29
|
-
//# sourceMappingURL=caps-frame.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"caps-frame.d.ts","sourceRoot":"","sources":["../../../src/ncp/frames/caps-frame.ts"],"names":[],"mappings":"AAOA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,qBAAqB,CAAC;CACvC;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAiBxD"}
|
|
@@ -1,29 +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
|
-
import { NcpError } from "../../core/frame-header.js";
|
|
7
|
-
import { computeAnchorId, } from "./anchor-frame.js";
|
|
8
|
-
/**
|
|
9
|
-
* Validate a CapsFrame.
|
|
10
|
-
*
|
|
11
|
-
* Checks:
|
|
12
|
-
* - count matches data.length (NPS-CLIENT-BAD-FRAME)
|
|
13
|
-
* - if inline_anchor present, recomputes anchor_id and validates match (NCP-ANCHOR-SCHEMA-INVALID)
|
|
14
|
-
*
|
|
15
|
-
* @throws {NcpError} NPS-CLIENT-BAD-FRAME if count doesn't match data length.
|
|
16
|
-
* @throws {NcpError} NCP-ANCHOR-SCHEMA-INVALID if inline_anchor.anchor_id doesn't match schema.
|
|
17
|
-
*/
|
|
18
|
-
export function validateCapsFrame(frame) {
|
|
19
|
-
if (frame.count !== frame.data.length) {
|
|
20
|
-
throw new NcpError("NPS-CLIENT-BAD-FRAME", `CapsFrame count mismatch: count=${frame.count}, data.length=${frame.data.length}`);
|
|
21
|
-
}
|
|
22
|
-
if (frame.inline_anchor !== undefined) {
|
|
23
|
-
const computed = computeAnchorId(frame.inline_anchor.schema);
|
|
24
|
-
if (frame.inline_anchor.anchor_id !== computed) {
|
|
25
|
-
throw new NcpError("NCP-ANCHOR-SCHEMA-INVALID", `inline_anchor anchor_id mismatch: expected ${computed}, got ${frame.inline_anchor.anchor_id}`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=caps-frame.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"caps-frame.js","sourceRoot":"","sources":["../../../src/ncp/frames/caps-frame.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,oDAAoD;AACpD,EAAE;AACF,+CAA+C;AAC/C,aAAa;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EACL,eAAe,GAGhB,MAAM,mBAAmB,CAAC;AAoB3B;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAgB;IAChD,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACtC,MAAM,IAAI,QAAQ,CAChB,sBAAsB,EACtB,mCAAmC,KAAK,CAAC,KAAK,iBAAiB,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CACnF,CAAC;IACJ,CAAC;IAED,IAAI,KAAK,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QACtC,MAAM,QAAQ,GAAG,eAAe,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC7D,IAAI,KAAK,CAAC,aAAa,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC/C,MAAM,IAAI,QAAQ,CAChB,2BAA2B,EAC3B,8CAA8C,QAAQ,SAAS,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE,CAC/F,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { EncodingTier } from "../../core/frame-header.js";
|
|
2
|
-
import { type PatchFormat } from "../ncp-patch-format.js";
|
|
3
|
-
export interface JsonPatchOperation {
|
|
4
|
-
op: "add" | "remove" | "replace" | "move" | "copy" | "test";
|
|
5
|
-
path: string;
|
|
6
|
-
value?: unknown;
|
|
7
|
-
from?: string;
|
|
8
|
-
}
|
|
9
|
-
export interface DiffFrame {
|
|
10
|
-
frame: string;
|
|
11
|
-
anchor_ref: string;
|
|
12
|
-
base_seq: number;
|
|
13
|
-
patch_format?: PatchFormat;
|
|
14
|
-
patch: JsonPatchOperation[] | Uint8Array;
|
|
15
|
-
entity_id?: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Validate DiffFrame base_seq against current sequence.
|
|
19
|
-
* @throws {NcpError} NCP-STREAM-SEQ-GAP if sequences don't match.
|
|
20
|
-
*/
|
|
21
|
-
export declare function validateDiffSeq(frame: DiffFrame, currentSeq: number): void;
|
|
22
|
-
/**
|
|
23
|
-
* Validate DiffFrame patch_format against the encoding tier.
|
|
24
|
-
*
|
|
25
|
-
* binary_bitset is only supported on Tier-2 (MsgPack) frames.
|
|
26
|
-
* Unknown patch_format values are also rejected.
|
|
27
|
-
*
|
|
28
|
-
* @throws {NcpError} NCP-DIFF-FORMAT-UNSUPPORTED if binary_bitset on non-Tier-2,
|
|
29
|
-
* or if patch_format is an unknown value.
|
|
30
|
-
*/
|
|
31
|
-
export declare function validateDiffFrame(frame: DiffFrame, encodingTier: EncodingTier | number): void;
|
|
32
|
-
//# sourceMappingURL=diff-frame.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diff-frame.d.ts","sourceRoot":"","sources":["../../../src/ncp/frames/diff-frame.ts"],"names":[],"mappings":"AAMA,OAAO,EAAY,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE9E,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,KAAK,EAAE,kBAAkB,EAAE,GAAG,UAAU,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAO1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,SAAS,EAChB,YAAY,EAAE,YAAY,GAAG,MAAM,GAClC,IAAI,CAkBN"}
|
|
@@ -1,37 +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
|
-
import { NcpError, EncodingTier } from "../../core/frame-header.js";
|
|
7
|
-
import { isValidPatchFormat } from "../ncp-patch-format.js";
|
|
8
|
-
/**
|
|
9
|
-
* Validate DiffFrame base_seq against current sequence.
|
|
10
|
-
* @throws {NcpError} NCP-STREAM-SEQ-GAP if sequences don't match.
|
|
11
|
-
*/
|
|
12
|
-
export function validateDiffSeq(frame, currentSeq) {
|
|
13
|
-
if (frame.base_seq !== currentSeq) {
|
|
14
|
-
throw new NcpError("NCP-STREAM-SEQ-GAP", `DiffFrame base_seq=${frame.base_seq} does not match current seq=${currentSeq}`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Validate DiffFrame patch_format against the encoding tier.
|
|
19
|
-
*
|
|
20
|
-
* binary_bitset is only supported on Tier-2 (MsgPack) frames.
|
|
21
|
-
* Unknown patch_format values are also rejected.
|
|
22
|
-
*
|
|
23
|
-
* @throws {NcpError} NCP-DIFF-FORMAT-UNSUPPORTED if binary_bitset on non-Tier-2,
|
|
24
|
-
* or if patch_format is an unknown value.
|
|
25
|
-
*/
|
|
26
|
-
export function validateDiffFrame(frame, encodingTier) {
|
|
27
|
-
const fmt = frame.patch_format;
|
|
28
|
-
// Unknown patch_format
|
|
29
|
-
if (fmt !== undefined && !isValidPatchFormat(fmt)) {
|
|
30
|
-
throw new NcpError("NCP-DIFF-FORMAT-UNSUPPORTED", `Unknown patch_format "${String(fmt)}"`);
|
|
31
|
-
}
|
|
32
|
-
// binary_bitset requires Tier-2 MsgPack
|
|
33
|
-
if (fmt === "binary_bitset" && encodingTier !== EncodingTier.MsgPack) {
|
|
34
|
-
throw new NcpError("NCP-DIFF-FORMAT-UNSUPPORTED", "patch_format=binary_bitset requires Tier-2 MsgPack encoding");
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=diff-frame.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diff-frame.js","sourceRoot":"","sources":["../../../src/ncp/frames/diff-frame.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,oDAAoD;AACpD,EAAE;AACF,4CAA4C;AAC5C,aAAa;AAEb,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAoB,MAAM,wBAAwB,CAAC;AAkB9E;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAgB,EAAE,UAAkB;IAClE,IAAI,KAAK,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;QAClC,MAAM,IAAI,QAAQ,CAChB,oBAAoB,EACpB,sBAAsB,KAAK,CAAC,QAAQ,+BAA+B,UAAU,EAAE,CAChF,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAgB,EAChB,YAAmC;IAEnC,MAAM,GAAG,GAAG,KAAK,CAAC,YAAY,CAAC;IAE/B,uBAAuB;IACvB,IAAI,GAAG,KAAK,SAAS,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,QAAQ,CAChB,6BAA6B,EAC7B,yBAAyB,MAAM,CAAC,GAAG,CAAC,GAAG,CACxC,CAAC;IACJ,CAAC;IAED,wCAAwC;IACxC,IAAI,GAAG,KAAK,eAAe,IAAI,YAAY,KAAK,YAAY,CAAC,OAAO,EAAE,CAAC;QACrE,MAAM,IAAI,QAAQ,CAChB,6BAA6B,EAC7B,6DAA6D,CAC9D,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/** Unified error frame shared across all NPS protocol layers. */
|
|
2
|
-
export interface ErrorFrame {
|
|
3
|
-
/** Fixed value "0xFE". */
|
|
4
|
-
frame: string;
|
|
5
|
-
/** NPS status code, e.g. "NPS-CLIENT-NOT-FOUND". */
|
|
6
|
-
status: string;
|
|
7
|
-
/** Protocol-level error code, e.g. "NCP-ANCHOR-NOT-FOUND". */
|
|
8
|
-
error: string;
|
|
9
|
-
/** Human-readable error description. */
|
|
10
|
-
message?: string;
|
|
11
|
-
/** Structured error details (e.g. anchor_ref, stream_id). */
|
|
12
|
-
details?: Record<string, unknown>;
|
|
13
|
-
}
|
|
14
|
-
/** Type guard for ErrorFrame. */
|
|
15
|
-
export declare function isErrorFrame(obj: unknown): obj is ErrorFrame;
|
|
16
|
-
//# sourceMappingURL=error-frame.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-frame.d.ts","sourceRoot":"","sources":["../../../src/ncp/frames/error-frame.ts"],"names":[],"mappings":"AAMA,iEAAiE;AACjE,MAAM,WAAW,UAAU;IACzB,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,iCAAiC;AACjC,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,UAAU,CAI5D"}
|
|
@@ -1,13 +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
|
-
/** Type guard for ErrorFrame. */
|
|
7
|
-
export function isErrorFrame(obj) {
|
|
8
|
-
if (typeof obj !== "object" || obj === null)
|
|
9
|
-
return false;
|
|
10
|
-
const o = obj;
|
|
11
|
-
return o.frame === "0xFE" && typeof o.status === "string" && typeof o.error === "string";
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=error-frame.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-frame.js","sourceRoot":"","sources":["../../../src/ncp/frames/error-frame.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,oDAAoD;AACpD,EAAE;AACF,sEAAsE;AACtE,aAAa;AAgBb,iCAAiC;AACjC,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC1D,MAAM,CAAC,GAAG,GAA8B,CAAC;IACzC,OAAO,CAAC,CAAC,KAAK,KAAK,MAAM,IAAI,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC;AAC3F,CAAC"}
|