@labacacia/nps-sdk 1.0.0-alpha.6 → 1.0.0-alpha.8
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 +126 -0
- package/CHANGELOG.md +135 -0
- package/README.cn.md +9 -2
- package/README.md +9 -2
- package/dist/core/anchor-cache.d.ts +42 -0
- package/dist/core/anchor-cache.d.ts.map +1 -0
- package/dist/core/anchor-cache.js +104 -0
- package/dist/core/anchor-cache.js.map +1 -0
- package/dist/core/cache.d.ts +14 -0
- package/dist/core/cache.d.ts.map +1 -0
- package/dist/core/cache.js +80 -0
- package/dist/core/cache.js.map +1 -0
- package/dist/core/canonical-json.d.ts +12 -0
- package/dist/core/canonical-json.d.ts.map +1 -0
- package/dist/core/canonical-json.js +44 -0
- package/dist/core/canonical-json.js.map +1 -0
- package/dist/core/codec.d.ts +32 -0
- package/dist/core/codec.d.ts.map +1 -0
- package/dist/core/codec.js +119 -0
- package/dist/core/codec.js.map +1 -0
- package/dist/core/codecs/index.d.ts +4 -0
- package/dist/core/codecs/index.d.ts.map +1 -0
- package/{src/core/codecs/index.ts → dist/core/codecs/index.js} +1 -0
- package/dist/core/codecs/index.js.map +1 -0
- package/dist/core/codecs/ncp-codec.d.ts +39 -0
- package/dist/core/codecs/ncp-codec.d.ts.map +1 -0
- package/dist/core/codecs/ncp-codec.js +93 -0
- package/dist/core/codecs/ncp-codec.js.map +1 -0
- package/dist/core/codecs/tier1-json-codec.d.ts +10 -0
- package/dist/core/codecs/tier1-json-codec.d.ts.map +1 -0
- package/{src/core/codecs/tier1-json-codec.ts → dist/core/codecs/tier1-json-codec.js} +11 -16
- package/dist/core/codecs/tier1-json-codec.js.map +1 -0
- package/dist/core/codecs/tier2-msgpack-codec.d.ts +10 -0
- package/dist/core/codecs/tier2-msgpack-codec.d.ts.map +1 -0
- package/{src/core/codecs/tier2-msgpack-codec.ts → dist/core/codecs/tier2-msgpack-codec.js} +10 -14
- package/dist/core/codecs/tier2-msgpack-codec.js.map +1 -0
- package/dist/core/crypto-provider.d.ts +31 -0
- package/dist/core/crypto-provider.d.ts.map +1 -0
- package/dist/core/crypto-provider.js +10 -0
- package/dist/core/crypto-provider.js.map +1 -0
- package/dist/core/exceptions.d.ts +27 -0
- package/dist/core/exceptions.d.ts.map +1 -0
- package/dist/core/exceptions.js +52 -0
- package/dist/core/exceptions.js.map +1 -0
- package/dist/core/frame-header.d.ts +87 -0
- package/dist/core/frame-header.d.ts.map +1 -0
- package/dist/core/frame-header.js +185 -0
- package/dist/core/frame-header.js.map +1 -0
- package/dist/core/frame-registry.d.ts +35 -0
- package/dist/core/frame-registry.d.ts.map +1 -0
- package/dist/core/frame-registry.js +63 -0
- package/dist/core/frame-registry.js.map +1 -0
- package/dist/core/frames.d.ts +82 -0
- package/dist/core/frames.d.ts.map +1 -0
- package/dist/core/frames.js +155 -0
- package/dist/core/frames.js.map +1 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/index.d.ts.map +1 -0
- package/{src/core/index.ts → dist/core/index.js} +3 -23
- package/dist/core/index.js.map +1 -0
- package/dist/core/registry.d.ts +11 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +17 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/status-codes.d.ts +29 -0
- package/dist/core/status-codes.d.ts.map +1 -0
- package/dist/core/status-codes.js +39 -0
- package/dist/core/status-codes.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/{src/index.ts → dist/index.js} +1 -1
- package/dist/index.js.map +1 -0
- package/dist/ncp/frames/anchor-frame.d.ts +29 -0
- package/dist/ncp/frames/anchor-frame.d.ts.map +1 -0
- package/dist/ncp/frames/anchor-frame.js +54 -0
- package/dist/ncp/frames/anchor-frame.js.map +1 -0
- package/dist/ncp/frames/caps-frame.d.ts +29 -0
- package/dist/ncp/frames/caps-frame.d.ts.map +1 -0
- package/dist/ncp/frames/caps-frame.js +29 -0
- package/dist/ncp/frames/caps-frame.js.map +1 -0
- package/dist/ncp/frames/diff-frame.d.ts +32 -0
- package/dist/ncp/frames/diff-frame.d.ts.map +1 -0
- package/dist/ncp/frames/diff-frame.js +37 -0
- package/dist/ncp/frames/diff-frame.js.map +1 -0
- package/dist/ncp/frames/error-frame.d.ts +16 -0
- package/dist/ncp/frames/error-frame.d.ts.map +1 -0
- package/dist/ncp/frames/error-frame.js +13 -0
- package/dist/ncp/frames/error-frame.js.map +1 -0
- package/dist/ncp/frames/hello-frame.d.ts +21 -0
- package/dist/ncp/frames/hello-frame.d.ts.map +1 -0
- package/dist/ncp/frames/hello-frame.js +25 -0
- package/dist/ncp/frames/hello-frame.js.map +1 -0
- package/dist/ncp/frames/stream-frame.d.ts +16 -0
- package/dist/ncp/frames/stream-frame.d.ts.map +1 -0
- package/dist/ncp/frames/stream-frame.js +18 -0
- package/dist/ncp/frames/stream-frame.js.map +1 -0
- package/dist/ncp/frames.d.ts +94 -0
- package/dist/ncp/frames.d.ts.map +1 -0
- package/dist/ncp/frames.js +192 -0
- package/dist/ncp/frames.js.map +1 -0
- package/dist/ncp/handshake.d.ts +30 -0
- package/dist/ncp/handshake.d.ts.map +1 -0
- package/dist/ncp/handshake.js +80 -0
- package/dist/ncp/handshake.js.map +1 -0
- package/dist/ncp/index.d.ts +12 -0
- package/dist/ncp/index.d.ts.map +1 -0
- package/{src/ncp/index.ts → dist/ncp/index.js} +1 -0
- package/dist/ncp/index.js.map +1 -0
- package/dist/ncp/ncp-error-codes.d.ts +23 -0
- package/dist/ncp/ncp-error-codes.d.ts.map +1 -0
- package/dist/ncp/ncp-error-codes.js +34 -0
- package/dist/ncp/ncp-error-codes.js.map +1 -0
- package/dist/ncp/ncp-patch-format.d.ts +7 -0
- package/dist/ncp/ncp-patch-format.d.ts.map +1 -0
- package/dist/ncp/ncp-patch-format.js +13 -0
- package/dist/ncp/ncp-patch-format.js.map +1 -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 +3 -0
- package/dist/ncp/registry.d.ts.map +1 -0
- package/dist/ncp/registry.js +13 -0
- package/dist/ncp/registry.js.map +1 -0
- package/dist/ncp/stream-manager.d.ts +57 -0
- package/dist/ncp/stream-manager.d.ts.map +1 -0
- package/dist/ncp/stream-manager.js +163 -0
- package/dist/ncp/stream-manager.js.map +1 -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 +56 -0
- package/dist/ndp/frames.d.ts.map +1 -0
- package/dist/ndp/frames.js +87 -0
- package/dist/ndp/frames.js.map +1 -0
- package/dist/ndp/index.d.ts +6 -0
- package/dist/ndp/index.d.ts.map +1 -0
- package/{src/ndp/index.ts → dist/ndp/index.js} +1 -1
- package/dist/ndp/index.js.map +1 -0
- package/dist/ndp/ndp-registry.d.ts +13 -0
- package/dist/ndp/ndp-registry.d.ts.map +1 -0
- package/dist/ndp/ndp-registry.js +104 -0
- package/dist/ndp/ndp-registry.js.map +1 -0
- package/dist/ndp/registry.d.ts +3 -0
- package/dist/ndp/registry.d.ts.map +1 -0
- package/dist/ndp/registry.js +10 -0
- package/dist/ndp/registry.js.map +1 -0
- package/dist/ndp/validator.d.ts +18 -0
- package/dist/ndp/validator.d.ts.map +1 -0
- package/dist/ndp/validator.js +48 -0
- package/dist/ndp/validator.js.map +1 -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/{src/nip/acme/index.ts → dist/nip/acme/index.js} +1 -1
- 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 +25 -0
- package/dist/nip/error-codes.d.ts.map +1 -0
- package/{src/nip/error-codes.ts → dist/nip/error-codes.js} +19 -25
- package/dist/nip/error-codes.js.map +1 -0
- package/dist/nip/frames.d.ts +53 -0
- package/dist/nip/frames.d.ts.map +1 -0
- package/dist/nip/frames.js +106 -0
- package/dist/nip/frames.js.map +1 -0
- package/dist/nip/identity.d.ts +18 -0
- package/dist/nip/identity.d.ts.map +1 -0
- package/dist/nip/identity.js +94 -0
- package/dist/nip/identity.js.map +1 -0
- package/dist/nip/index.d.ts +11 -0
- package/dist/nip/index.d.ts.map +1 -0
- package/{src/nip/index.ts → dist/nip/index.js} +3 -2
- package/dist/nip/index.js.map +1 -0
- package/dist/nip/registry.d.ts +3 -0
- package/dist/nip/registry.d.ts.map +1 -0
- package/dist/nip/registry.js +10 -0
- package/dist/nip/registry.js.map +1 -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/{src/nip/x509/index.ts → dist/nip/x509/index.js} +1 -1
- 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/{src/nip/x509/oids.ts → dist/nip/x509/oids.js} +5 -10
- 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 +34 -0
- package/dist/nop/client.d.ts.map +1 -0
- package/dist/nop/client.js +90 -0
- package/dist/nop/client.js.map +1 -0
- package/dist/nop/frames.d.ts +65 -0
- package/dist/nop/frames.d.ts.map +1 -0
- package/dist/nop/frames.js +148 -0
- package/dist/nop/frames.js.map +1 -0
- package/dist/nop/index.d.ts +5 -0
- package/dist/nop/index.d.ts.map +1 -0
- package/{src/nop/index.ts → dist/nop/index.js} +1 -1
- package/dist/nop/index.js.map +1 -0
- package/dist/nop/models.d.ts +58 -0
- package/dist/nop/models.d.ts.map +1 -0
- package/dist/nop/models.js +50 -0
- package/dist/nop/models.js.map +1 -0
- package/dist/nop/nop-types.d.ts +136 -0
- package/dist/nop/nop-types.d.ts.map +1 -0
- package/dist/nop/nop-types.js +44 -0
- package/dist/nop/nop-types.js.map +1 -0
- package/dist/nop/registry.d.ts +3 -0
- package/dist/nop/registry.d.ts.map +1 -0
- package/dist/nop/registry.js +11 -0
- package/dist/nop/registry.js.map +1 -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/client.d.ts +28 -0
- package/dist/nwp/client.d.ts.map +1 -0
- package/dist/nwp/client.js +142 -0
- package/dist/nwp/client.js.map +1 -0
- package/dist/nwp/frames.d.ts +107 -0
- package/dist/nwp/frames.d.ts.map +1 -0
- package/dist/nwp/frames.js +198 -0
- package/dist/nwp/frames.js.map +1 -0
- package/dist/nwp/index.d.ts +6 -0
- package/dist/nwp/index.d.ts.map +1 -0
- package/{src/nwp/index.ts → dist/nwp/index.js} +3 -1
- package/dist/nwp/index.js.map +1 -0
- package/dist/nwp/manifest.d.ts +69 -0
- package/dist/nwp/manifest.d.ts.map +1 -0
- package/dist/nwp/manifest.js +4 -0
- package/dist/nwp/manifest.js.map +1 -0
- package/dist/nwp/registry.d.ts +3 -0
- package/dist/nwp/registry.d.ts.map +1 -0
- package/dist/nwp/registry.js +10 -0
- package/dist/nwp/registry.js.map +1 -0
- package/dist/setup.d.ts +10 -0
- package/dist/setup.d.ts.map +1 -0
- package/{src/setup.ts → dist/setup.js} +13 -16
- package/dist/setup.js.map +1 -0
- package/package.json +12 -1
- package/CONTRIBUTING.cn.md +0 -35
- package/CONTRIBUTING.md +0 -35
- 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/ncp-codec.ts +0 -170
- 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 -184
- package/src/core/registry.ts +0 -28
- package/src/core/status-codes.ts +0 -47
- 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 -251
- package/src/ncp/handshake.ts +0 -95
- package/src/ncp/ncp-error-codes.ts +0 -36
- package/src/ncp/ncp-patch-format.ts +0 -16
- package/src/ncp/preamble.ts +0 -79
- package/src/ncp/registry.ts +0 -15
- package/src/ncp/stream-manager.ts +0 -212
- package/src/ndp/dns-txt.ts +0 -86
- package/src/ndp/frames.ts +0 -124
- package/src/ndp/ndp-registry.ts +0 -116
- package/src/ndp/registry.ts +0 -12
- package/src/ndp/validator.ts +0 -64
- package/src/nip/acme/client.ts +0 -185
- package/src/nip/acme/jws.ts +0 -109
- package/src/nip/acme/messages.ts +0 -85
- package/src/nip/acme/server.ts +0 -480
- package/src/nip/acme/wire.ts +0 -24
- package/src/nip/assurance-level.ts +0 -40
- package/src/nip/cert-format.ts +0 -9
- package/src/nip/frames.ts +0 -138
- package/src/nip/identity.ts +0 -113
- package/src/nip/registry.ts +0 -12
- package/src/nip/verifier.ts +0 -122
- package/src/nip/x509/builder.ts +0 -91
- package/src/nip/x509/verifier.ts +0 -214
- package/src/nop/client.ts +0 -103
- package/src/nop/frames.ts +0 -181
- 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/registry.ts +0 -11
- package/tests/_rfc0002-keys.ts +0 -57
- 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/preamble.test.ts +0 -93
- 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 -377
- package/tests/nip-acme-agent01.test.ts +0 -192
- package/tests/nip-x509.test.ts +0 -280
- 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
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { EncodingTier, FrameType } from "../core/frames.js";
|
|
2
|
+
import type { NpsFrame } from "../core/codec.js";
|
|
3
|
+
export interface SchemaField {
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
semantic?: string;
|
|
7
|
+
nullable?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface FrameSchema {
|
|
10
|
+
fields: readonly SchemaField[];
|
|
11
|
+
}
|
|
12
|
+
export declare class AnchorFrame implements NpsFrame {
|
|
13
|
+
readonly anchorId: string;
|
|
14
|
+
readonly schema: FrameSchema;
|
|
15
|
+
readonly ttl: number;
|
|
16
|
+
readonly frameType = FrameType.ANCHOR;
|
|
17
|
+
readonly preferredTier = EncodingTier.MSGPACK;
|
|
18
|
+
constructor(anchorId: string, schema: FrameSchema, ttl?: number);
|
|
19
|
+
toDict(): Record<string, unknown>;
|
|
20
|
+
static fromDict(data: Record<string, unknown>): AnchorFrame;
|
|
21
|
+
}
|
|
22
|
+
export interface JsonPatchOperation {
|
|
23
|
+
op: string;
|
|
24
|
+
path: string;
|
|
25
|
+
value?: unknown;
|
|
26
|
+
}
|
|
27
|
+
export declare class DiffFrame implements NpsFrame {
|
|
28
|
+
readonly anchorRef: string;
|
|
29
|
+
readonly baseSeq: number;
|
|
30
|
+
readonly patch: readonly JsonPatchOperation[];
|
|
31
|
+
readonly entityId?: string | undefined;
|
|
32
|
+
readonly frameType = FrameType.DIFF;
|
|
33
|
+
readonly preferredTier = EncodingTier.MSGPACK;
|
|
34
|
+
constructor(anchorRef: string, baseSeq: number, patch: readonly JsonPatchOperation[], entityId?: string | undefined);
|
|
35
|
+
toDict(): Record<string, unknown>;
|
|
36
|
+
static fromDict(data: Record<string, unknown>): DiffFrame;
|
|
37
|
+
}
|
|
38
|
+
export declare class StreamFrame implements NpsFrame {
|
|
39
|
+
readonly streamId: string;
|
|
40
|
+
readonly seq: number;
|
|
41
|
+
readonly isLast: boolean;
|
|
42
|
+
readonly data: readonly Record<string, unknown>[];
|
|
43
|
+
readonly anchorRef?: string | undefined;
|
|
44
|
+
readonly windowSize?: number | undefined;
|
|
45
|
+
readonly frameType = FrameType.STREAM;
|
|
46
|
+
readonly preferredTier = EncodingTier.MSGPACK;
|
|
47
|
+
constructor(streamId: string, seq: number, isLast: boolean, data: readonly Record<string, unknown>[], anchorRef?: string | undefined, windowSize?: number | undefined);
|
|
48
|
+
toDict(): Record<string, unknown>;
|
|
49
|
+
static fromDict(data: Record<string, unknown>): StreamFrame;
|
|
50
|
+
}
|
|
51
|
+
export declare class CapsFrame implements NpsFrame {
|
|
52
|
+
readonly anchorRef: string;
|
|
53
|
+
readonly count: number;
|
|
54
|
+
readonly data: readonly Record<string, unknown>[];
|
|
55
|
+
readonly nextCursor?: string | undefined;
|
|
56
|
+
readonly tokenEst?: number | undefined;
|
|
57
|
+
readonly cached?: boolean | undefined;
|
|
58
|
+
readonly tokenizerUsed?: string | undefined;
|
|
59
|
+
readonly frameType = FrameType.CAPS;
|
|
60
|
+
readonly preferredTier = EncodingTier.MSGPACK;
|
|
61
|
+
constructor(anchorRef: string, count: number, data: readonly Record<string, unknown>[], nextCursor?: string | undefined, tokenEst?: number | undefined, cached?: boolean | undefined, tokenizerUsed?: string | undefined);
|
|
62
|
+
toDict(): Record<string, unknown>;
|
|
63
|
+
static fromDict(data: Record<string, unknown>): CapsFrame;
|
|
64
|
+
}
|
|
65
|
+
export declare class ErrorFrame implements NpsFrame {
|
|
66
|
+
readonly status: string;
|
|
67
|
+
readonly error: string;
|
|
68
|
+
readonly message?: string | undefined;
|
|
69
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
70
|
+
readonly frameType = FrameType.ERROR;
|
|
71
|
+
readonly preferredTier = EncodingTier.MSGPACK;
|
|
72
|
+
constructor(status: string, error: string, message?: string | undefined, details?: Record<string, unknown> | undefined);
|
|
73
|
+
toDict(): Record<string, unknown>;
|
|
74
|
+
static fromDict(data: Record<string, unknown>): ErrorFrame;
|
|
75
|
+
}
|
|
76
|
+
export declare class HelloFrame implements NpsFrame {
|
|
77
|
+
readonly npsVersion: string;
|
|
78
|
+
readonly supportedEncodings: readonly string[];
|
|
79
|
+
readonly supportedProtocols: readonly string[];
|
|
80
|
+
minVersion?: string | undefined;
|
|
81
|
+
agentId?: string | undefined;
|
|
82
|
+
maxFramePayload: number;
|
|
83
|
+
extSupport: boolean;
|
|
84
|
+
maxConcurrentStreams: number;
|
|
85
|
+
e2eEncAlgorithms?: readonly string[] | undefined;
|
|
86
|
+
readonly frameType = FrameType.HELLO;
|
|
87
|
+
readonly preferredTier = EncodingTier.JSON;
|
|
88
|
+
static readonly DEFAULT_MAX_FRAME_PAYLOAD = 65535;
|
|
89
|
+
static readonly DEFAULT_MAX_CONCURRENT_STREAMS = 32;
|
|
90
|
+
constructor(npsVersion: string, supportedEncodings: readonly string[], supportedProtocols: readonly string[], minVersion?: string | undefined, agentId?: string | undefined, maxFramePayload?: number, extSupport?: boolean, maxConcurrentStreams?: number, e2eEncAlgorithms?: readonly string[] | undefined);
|
|
91
|
+
toDict(): Record<string, unknown>;
|
|
92
|
+
static fromDict(data: Record<string, unknown>): HelloFrame;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=frames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frames.d.ts","sourceRoot":"","sources":["../../src/ncp/frames.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAO,MAAM,CAAC;IAClB,IAAI,EAAO,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;CAChC;AAID,qBAAa,WAAY,YAAW,QAAQ;aAKxB,QAAQ,EAAE,MAAM;aAChB,MAAM,EAAI,WAAW;aACrB,GAAG,EAAO,MAAM;IANlC,QAAQ,CAAC,SAAS,oBAAwB;IAC1C,QAAQ,CAAC,aAAa,wBAAwB;gBAG5B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAI,WAAW,EACrB,GAAG,GAAO,MAAa;IAGzC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAQjC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAA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ameType } from "../core/frames.js";
|
|
4
|
+
// ── AnchorFrame ───────────────────────────────────────────────────────────────
|
|
5
|
+
export class AnchorFrame {
|
|
6
|
+
anchorId;
|
|
7
|
+
schema;
|
|
8
|
+
ttl;
|
|
9
|
+
frameType = FrameType.ANCHOR;
|
|
10
|
+
preferredTier = EncodingTier.MSGPACK;
|
|
11
|
+
constructor(anchorId, schema, ttl = 3600) {
|
|
12
|
+
this.anchorId = anchorId;
|
|
13
|
+
this.schema = schema;
|
|
14
|
+
this.ttl = ttl;
|
|
15
|
+
}
|
|
16
|
+
toDict() {
|
|
17
|
+
return {
|
|
18
|
+
anchor_id: this.anchorId,
|
|
19
|
+
schema: { fields: this.schema.fields.map((f) => ({ ...f })) },
|
|
20
|
+
ttl: this.ttl,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
static fromDict(data) {
|
|
24
|
+
const schemaRaw = data["schema"];
|
|
25
|
+
return new AnchorFrame(data["anchor_id"], { fields: schemaRaw.fields }, data["ttl"] ?? 3600);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// ── DiffFrame ─────────────────────────────────────────────────────────────────
|
|
29
|
+
export class DiffFrame {
|
|
30
|
+
anchorRef;
|
|
31
|
+
baseSeq;
|
|
32
|
+
patch;
|
|
33
|
+
entityId;
|
|
34
|
+
frameType = FrameType.DIFF;
|
|
35
|
+
preferredTier = EncodingTier.MSGPACK;
|
|
36
|
+
constructor(anchorRef, baseSeq, patch, entityId) {
|
|
37
|
+
this.anchorRef = anchorRef;
|
|
38
|
+
this.baseSeq = baseSeq;
|
|
39
|
+
this.patch = patch;
|
|
40
|
+
this.entityId = entityId;
|
|
41
|
+
}
|
|
42
|
+
toDict() {
|
|
43
|
+
return {
|
|
44
|
+
anchor_ref: this.anchorRef,
|
|
45
|
+
base_seq: this.baseSeq,
|
|
46
|
+
patch: this.patch.map((p) => ({ ...p })),
|
|
47
|
+
entity_id: this.entityId ?? null,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
static fromDict(data) {
|
|
51
|
+
return new DiffFrame(data["anchor_ref"], data["base_seq"], data["patch"], data["entity_id"] ?? undefined);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// ── StreamFrame ───────────────────────────────────────────────────────────────
|
|
55
|
+
export class StreamFrame {
|
|
56
|
+
streamId;
|
|
57
|
+
seq;
|
|
58
|
+
isLast;
|
|
59
|
+
data;
|
|
60
|
+
anchorRef;
|
|
61
|
+
windowSize;
|
|
62
|
+
frameType = FrameType.STREAM;
|
|
63
|
+
preferredTier = EncodingTier.MSGPACK;
|
|
64
|
+
constructor(streamId, seq, isLast, data, anchorRef, windowSize) {
|
|
65
|
+
this.streamId = streamId;
|
|
66
|
+
this.seq = seq;
|
|
67
|
+
this.isLast = isLast;
|
|
68
|
+
this.data = data;
|
|
69
|
+
this.anchorRef = anchorRef;
|
|
70
|
+
this.windowSize = windowSize;
|
|
71
|
+
}
|
|
72
|
+
toDict() {
|
|
73
|
+
return {
|
|
74
|
+
stream_id: this.streamId,
|
|
75
|
+
seq: this.seq,
|
|
76
|
+
is_last: this.isLast,
|
|
77
|
+
data: this.data,
|
|
78
|
+
anchor_ref: this.anchorRef ?? null,
|
|
79
|
+
window_size: this.windowSize ?? null,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
static fromDict(data) {
|
|
83
|
+
return new StreamFrame(data["stream_id"], data["seq"], data["is_last"], data["data"], data["anchor_ref"] ?? undefined, data["window_size"] ?? undefined);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// ── CapsFrame ─────────────────────────────────────────────────────────────────
|
|
87
|
+
export class CapsFrame {
|
|
88
|
+
anchorRef;
|
|
89
|
+
count;
|
|
90
|
+
data;
|
|
91
|
+
nextCursor;
|
|
92
|
+
tokenEst;
|
|
93
|
+
cached;
|
|
94
|
+
tokenizerUsed;
|
|
95
|
+
frameType = FrameType.CAPS;
|
|
96
|
+
preferredTier = EncodingTier.MSGPACK;
|
|
97
|
+
constructor(anchorRef, count, data, nextCursor, tokenEst, cached, tokenizerUsed) {
|
|
98
|
+
this.anchorRef = anchorRef;
|
|
99
|
+
this.count = count;
|
|
100
|
+
this.data = data;
|
|
101
|
+
this.nextCursor = nextCursor;
|
|
102
|
+
this.tokenEst = tokenEst;
|
|
103
|
+
this.cached = cached;
|
|
104
|
+
this.tokenizerUsed = tokenizerUsed;
|
|
105
|
+
}
|
|
106
|
+
toDict() {
|
|
107
|
+
return {
|
|
108
|
+
anchor_ref: this.anchorRef,
|
|
109
|
+
count: this.count,
|
|
110
|
+
data: this.data,
|
|
111
|
+
next_cursor: this.nextCursor ?? null,
|
|
112
|
+
token_est: this.tokenEst ?? null,
|
|
113
|
+
cached: this.cached ?? null,
|
|
114
|
+
tokenizer_used: this.tokenizerUsed ?? null,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
static fromDict(data) {
|
|
118
|
+
return new CapsFrame(data["anchor_ref"], data["count"], data["data"], data["next_cursor"] ?? undefined, data["token_est"] ?? undefined, data["cached"] ?? undefined, data["tokenizer_used"] ?? undefined);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// ── ErrorFrame ────────────────────────────────────────────────────────────────
|
|
122
|
+
export class ErrorFrame {
|
|
123
|
+
status;
|
|
124
|
+
error;
|
|
125
|
+
message;
|
|
126
|
+
details;
|
|
127
|
+
frameType = FrameType.ERROR;
|
|
128
|
+
preferredTier = EncodingTier.MSGPACK;
|
|
129
|
+
constructor(status, error, message, details) {
|
|
130
|
+
this.status = status;
|
|
131
|
+
this.error = error;
|
|
132
|
+
this.message = message;
|
|
133
|
+
this.details = details;
|
|
134
|
+
}
|
|
135
|
+
toDict() {
|
|
136
|
+
return {
|
|
137
|
+
status: this.status,
|
|
138
|
+
error: this.error,
|
|
139
|
+
message: this.message ?? null,
|
|
140
|
+
details: this.details ?? null,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
static fromDict(data) {
|
|
144
|
+
return new ErrorFrame(data["status"], data["error"], data["message"] ?? undefined, data["details"] ?? undefined);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// ── HelloFrame ────────────────────────────────────────────────────────────────
|
|
148
|
+
// NPS-1 §4.6 — Native-mode handshake (0x06). Always Tier-1 JSON: encoding
|
|
149
|
+
// is not yet negotiated when this frame is sent.
|
|
150
|
+
export class HelloFrame {
|
|
151
|
+
npsVersion;
|
|
152
|
+
supportedEncodings;
|
|
153
|
+
supportedProtocols;
|
|
154
|
+
minVersion;
|
|
155
|
+
agentId;
|
|
156
|
+
maxFramePayload;
|
|
157
|
+
extSupport;
|
|
158
|
+
maxConcurrentStreams;
|
|
159
|
+
e2eEncAlgorithms;
|
|
160
|
+
frameType = FrameType.HELLO;
|
|
161
|
+
preferredTier = EncodingTier.JSON;
|
|
162
|
+
static DEFAULT_MAX_FRAME_PAYLOAD = 0xFFFF;
|
|
163
|
+
static DEFAULT_MAX_CONCURRENT_STREAMS = 32;
|
|
164
|
+
constructor(npsVersion, supportedEncodings, supportedProtocols, minVersion, agentId, maxFramePayload = HelloFrame.DEFAULT_MAX_FRAME_PAYLOAD, extSupport = false, maxConcurrentStreams = HelloFrame.DEFAULT_MAX_CONCURRENT_STREAMS, e2eEncAlgorithms) {
|
|
165
|
+
this.npsVersion = npsVersion;
|
|
166
|
+
this.supportedEncodings = supportedEncodings;
|
|
167
|
+
this.supportedProtocols = supportedProtocols;
|
|
168
|
+
this.minVersion = minVersion;
|
|
169
|
+
this.agentId = agentId;
|
|
170
|
+
this.maxFramePayload = maxFramePayload;
|
|
171
|
+
this.extSupport = extSupport;
|
|
172
|
+
this.maxConcurrentStreams = maxConcurrentStreams;
|
|
173
|
+
this.e2eEncAlgorithms = e2eEncAlgorithms;
|
|
174
|
+
}
|
|
175
|
+
toDict() {
|
|
176
|
+
return {
|
|
177
|
+
nps_version: this.npsVersion,
|
|
178
|
+
supported_encodings: [...this.supportedEncodings],
|
|
179
|
+
supported_protocols: [...this.supportedProtocols],
|
|
180
|
+
min_version: this.minVersion ?? null,
|
|
181
|
+
agent_id: this.agentId ?? null,
|
|
182
|
+
max_frame_payload: this.maxFramePayload,
|
|
183
|
+
ext_support: this.extSupport,
|
|
184
|
+
max_concurrent_streams: this.maxConcurrentStreams,
|
|
185
|
+
e2e_enc_algorithms: this.e2eEncAlgorithms ? [...this.e2eEncAlgorithms] : null,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
static fromDict(data) {
|
|
189
|
+
return new HelloFrame(data["nps_version"], data["supported_encodings"] ?? [], data["supported_protocols"] ?? [], data["min_version"] ?? undefined, data["agent_id"] ?? undefined, data["max_frame_payload"] ?? HelloFrame.DEFAULT_MAX_FRAME_PAYLOAD, data["ext_support"] ?? false, data["max_concurrent_streams"] ?? HelloFrame.DEFAULT_MAX_CONCURRENT_STREAMS, data["e2e_enc_algorithms"] ?? undefined);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=frames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frames.js","sourceRoot":"","sources":["../../src/ncp/frames.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,sCAAsC;AAEtC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAgB5D,iFAAiF;AAEjF,MAAM,OAAO,WAAW;IAKJ;IACA;IACA;IANT,SAAS,GAAO,SAAS,CAAC,MAAM,CAAC;IACjC,aAAa,GAAG,YAAY,CAAC,OAAO,CAAC;IAE9C,YACkB,QAAgB,EAChB,MAAqB,EACrB,MAAmB,IAAI;QAFvB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,WAAM,GAAN,MAAM,CAAe;QACrB,QAAG,GAAH,GAAG,CAAoB;IACtC,CAAC;IAEJ,MAAM;QACJ,OAAO;YACL,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,MAAM,EAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAA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I,SAAS,CAC7D,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Negotiate the session NPS version between client and server.
|
|
3
|
+
*
|
|
4
|
+
* Session version = numeric min of client.nps_version and server.nps_version
|
|
5
|
+
* (component-wise — "0.9" < "0.10" < "1.0").
|
|
6
|
+
* If the effective client minimum (min_version ?? nps_version) > server.nps_version,
|
|
7
|
+
* the versions are incompatible.
|
|
8
|
+
*
|
|
9
|
+
* Spec: NPS-1 §2.6
|
|
10
|
+
*/
|
|
11
|
+
export declare function negotiateVersion(client: {
|
|
12
|
+
nps_version: string;
|
|
13
|
+
min_version?: string;
|
|
14
|
+
}, server: {
|
|
15
|
+
nps_version: string;
|
|
16
|
+
}): {
|
|
17
|
+
session_version: string;
|
|
18
|
+
compatible: boolean;
|
|
19
|
+
error_code?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Negotiate the encoding between client and server preferred lists.
|
|
23
|
+
*
|
|
24
|
+
* Returns the first mutually supported encoding, preferring "msgpack" over "json".
|
|
25
|
+
* Returns null if there is no intersection.
|
|
26
|
+
*/
|
|
27
|
+
export declare function negotiateEncoding(client: string[], server: string[]): {
|
|
28
|
+
encoding: string | null;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=handshake.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handshake.d.ts","sourceRoot":"","sources":["../../src/ncp/handshake.ts"],"names":[],"mappings":"AAgCA;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,EACrD,MAAM,EAAE;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAmBvE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EAAE,EAChB,MAAM,EAAE,MAAM,EAAE,GACf;IAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAmB7B"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
|
|
3
|
+
//
|
|
4
|
+
// Handshake — Version negotiation and encoding negotiation
|
|
5
|
+
// NPS-1 §2.6
|
|
6
|
+
/**
|
|
7
|
+
* Parse a "major.minor" (optionally "major.minor.patch") version string into a
|
|
8
|
+
* tuple of numeric components. Invalid parts become NaN which makes subsequent
|
|
9
|
+
* comparisons return false in both directions (safe failure).
|
|
10
|
+
*/
|
|
11
|
+
function parseVersion(v) {
|
|
12
|
+
return v.split(".").map((p) => Number.parseInt(p, 10));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Numeric component-wise comparison of two version strings.
|
|
16
|
+
* Returns negative if a < b, zero if equal, positive if a > b.
|
|
17
|
+
* Avoids the lexicographic pitfall where "0.9" > "0.10".
|
|
18
|
+
*/
|
|
19
|
+
function compareVersions(a, b) {
|
|
20
|
+
const partsA = parseVersion(a);
|
|
21
|
+
const partsB = parseVersion(b);
|
|
22
|
+
const len = Math.max(partsA.length, partsB.length);
|
|
23
|
+
for (let i = 0; i < len; i += 1) {
|
|
24
|
+
const x = partsA[i] ?? 0;
|
|
25
|
+
const y = partsB[i] ?? 0;
|
|
26
|
+
if (x !== y)
|
|
27
|
+
return x - y;
|
|
28
|
+
}
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Negotiate the session NPS version between client and server.
|
|
33
|
+
*
|
|
34
|
+
* Session version = numeric min of client.nps_version and server.nps_version
|
|
35
|
+
* (component-wise — "0.9" < "0.10" < "1.0").
|
|
36
|
+
* If the effective client minimum (min_version ?? nps_version) > server.nps_version,
|
|
37
|
+
* the versions are incompatible.
|
|
38
|
+
*
|
|
39
|
+
* Spec: NPS-1 §2.6
|
|
40
|
+
*/
|
|
41
|
+
export function negotiateVersion(client, server) {
|
|
42
|
+
const clientMin = client.min_version ?? client.nps_version;
|
|
43
|
+
const serverVersion = server.nps_version;
|
|
44
|
+
if (compareVersions(clientMin, serverVersion) > 0) {
|
|
45
|
+
return {
|
|
46
|
+
session_version: serverVersion,
|
|
47
|
+
compatible: false,
|
|
48
|
+
error_code: "NCP-VERSION-INCOMPATIBLE",
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// Session version = component-wise min of client.nps_version and server.nps_version
|
|
52
|
+
const sessionVersion = compareVersions(client.nps_version, serverVersion) <= 0
|
|
53
|
+
? client.nps_version
|
|
54
|
+
: serverVersion;
|
|
55
|
+
return { session_version: sessionVersion, compatible: true };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Negotiate the encoding between client and server preferred lists.
|
|
59
|
+
*
|
|
60
|
+
* Returns the first mutually supported encoding, preferring "msgpack" over "json".
|
|
61
|
+
* Returns null if there is no intersection.
|
|
62
|
+
*/
|
|
63
|
+
export function negotiateEncoding(client, server) {
|
|
64
|
+
const serverSet = new Set(server);
|
|
65
|
+
// Prefer msgpack over json (and over any other encoding)
|
|
66
|
+
if (client.includes("msgpack") && serverSet.has("msgpack")) {
|
|
67
|
+
return { encoding: "msgpack" };
|
|
68
|
+
}
|
|
69
|
+
if (client.includes("json") && serverSet.has("json")) {
|
|
70
|
+
return { encoding: "json" };
|
|
71
|
+
}
|
|
72
|
+
// Fall back to first intersection in client-preference order
|
|
73
|
+
for (const enc of client) {
|
|
74
|
+
if (serverSet.has(enc)) {
|
|
75
|
+
return { encoding: enc };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return { encoding: null };
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=handshake.js.map
|
|
@@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frames/diff-frame.js";
|
|
4
|
+
export * from "./frames/error-frame.js";
|
|
5
|
+
export * from "./frames/hello-frame.js";
|
|
6
|
+
export * from "./frames/stream-frame.js";
|
|
7
|
+
export * from "./ncp-error-codes.js";
|
|
8
|
+
export * from "./ncp-patch-format.js";
|
|
9
|
+
export * from "./handshake.js";
|
|
10
|
+
export * from "./stream-manager.js";
|
|
11
|
+
export * from "./preamble.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ncp/index.ts"],"names":[],"mappings":"AAEA,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ncp/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,oDAAoD;AACpD,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const NCP_ERROR_CODES: {
|
|
2
|
+
readonly NCP_FRAME_PARSE_ERROR: "NCP-FRAME-PARSE-ERROR";
|
|
3
|
+
readonly NCP_FRAME_INCOMPLETE: "NCP-FRAME-INCOMPLETE";
|
|
4
|
+
readonly NCP_PREAMBLE_INVALID: "NCP-PREAMBLE-INVALID";
|
|
5
|
+
readonly NCP_FRAME_UNKNOWN_TYPE: "NCP-FRAME-UNKNOWN-TYPE";
|
|
6
|
+
readonly NCP_FRAME_PAYLOAD_TOO_LARGE: "NCP-FRAME-PAYLOAD-TOO-LARGE";
|
|
7
|
+
readonly NCP_FRAME_FLAGS_INVALID: "NCP-FRAME-FLAGS-INVALID";
|
|
8
|
+
readonly NCP_ANCHOR_NOT_FOUND: "NCP-ANCHOR-NOT-FOUND";
|
|
9
|
+
readonly NCP_ANCHOR_SCHEMA_INVALID: "NCP-ANCHOR-SCHEMA-INVALID";
|
|
10
|
+
readonly NCP_ANCHOR_ID_MISMATCH: "NCP-ANCHOR-ID-MISMATCH";
|
|
11
|
+
readonly NCP_ANCHOR_STALE: "NCP-ANCHOR-STALE";
|
|
12
|
+
readonly NCP_STREAM_SEQ_GAP: "NCP-STREAM-SEQ-GAP";
|
|
13
|
+
readonly NCP_STREAM_NOT_FOUND: "NCP-STREAM-NOT-FOUND";
|
|
14
|
+
readonly NCP_STREAM_LIMIT_EXCEEDED: "NCP-STREAM-LIMIT-EXCEEDED";
|
|
15
|
+
readonly NCP_STREAM_WINDOW_OVERFLOW: "NCP-STREAM-WINDOW-OVERFLOW";
|
|
16
|
+
readonly NCP_ENCODING_UNSUPPORTED: "NCP-ENCODING-UNSUPPORTED";
|
|
17
|
+
readonly NCP_DIFF_FORMAT_UNSUPPORTED: "NCP-DIFF-FORMAT-UNSUPPORTED";
|
|
18
|
+
readonly NCP_VERSION_INCOMPATIBLE: "NCP-VERSION-INCOMPATIBLE";
|
|
19
|
+
readonly NCP_ENC_NOT_NEGOTIATED: "NCP-ENC-NOT-NEGOTIATED";
|
|
20
|
+
readonly NCP_ENC_AUTH_FAILED: "NCP-ENC-AUTH-FAILED";
|
|
21
|
+
};
|
|
22
|
+
export type NcpErrorCode = typeof NCP_ERROR_CODES[keyof typeof NCP_ERROR_CODES];
|
|
23
|
+
//# sourceMappingURL=ncp-error-codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ncp-error-codes.d.ts","sourceRoot":"","sources":["../../src/ncp/ncp-error-codes.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;CAuBlB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,OAAO,eAAe,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
|
|
3
|
+
//
|
|
4
|
+
// NCP Error Codes — All v0.4 protocol error codes
|
|
5
|
+
// NPS-1 §6 + §7.4
|
|
6
|
+
//
|
|
7
|
+
// Implementation-only codes (NCP_FRAME_PARSE_ERROR, NCP_FRAME_INCOMPLETE) cover
|
|
8
|
+
// wire-layer parse failures not in spec §6. See test/ncp_test_results.md spec
|
|
9
|
+
// question 2 for the proposal to register them upstream.
|
|
10
|
+
export const NCP_ERROR_CODES = {
|
|
11
|
+
// Implementation-only codes (not in spec §6 — see test_results.md spec question 2)
|
|
12
|
+
NCP_FRAME_PARSE_ERROR: "NCP-FRAME-PARSE-ERROR",
|
|
13
|
+
NCP_FRAME_INCOMPLETE: "NCP-FRAME-INCOMPLETE",
|
|
14
|
+
// NPS-RFC-0001 — native-mode preamble
|
|
15
|
+
NCP_PREAMBLE_INVALID: "NCP-PREAMBLE-INVALID",
|
|
16
|
+
// Spec-defined codes
|
|
17
|
+
NCP_FRAME_UNKNOWN_TYPE: "NCP-FRAME-UNKNOWN-TYPE",
|
|
18
|
+
NCP_FRAME_PAYLOAD_TOO_LARGE: "NCP-FRAME-PAYLOAD-TOO-LARGE",
|
|
19
|
+
NCP_FRAME_FLAGS_INVALID: "NCP-FRAME-FLAGS-INVALID",
|
|
20
|
+
NCP_ANCHOR_NOT_FOUND: "NCP-ANCHOR-NOT-FOUND",
|
|
21
|
+
NCP_ANCHOR_SCHEMA_INVALID: "NCP-ANCHOR-SCHEMA-INVALID",
|
|
22
|
+
NCP_ANCHOR_ID_MISMATCH: "NCP-ANCHOR-ID-MISMATCH",
|
|
23
|
+
NCP_ANCHOR_STALE: "NCP-ANCHOR-STALE",
|
|
24
|
+
NCP_STREAM_SEQ_GAP: "NCP-STREAM-SEQ-GAP",
|
|
25
|
+
NCP_STREAM_NOT_FOUND: "NCP-STREAM-NOT-FOUND",
|
|
26
|
+
NCP_STREAM_LIMIT_EXCEEDED: "NCP-STREAM-LIMIT-EXCEEDED",
|
|
27
|
+
NCP_STREAM_WINDOW_OVERFLOW: "NCP-STREAM-WINDOW-OVERFLOW",
|
|
28
|
+
NCP_ENCODING_UNSUPPORTED: "NCP-ENCODING-UNSUPPORTED",
|
|
29
|
+
NCP_DIFF_FORMAT_UNSUPPORTED: "NCP-DIFF-FORMAT-UNSUPPORTED",
|
|
30
|
+
NCP_VERSION_INCOMPATIBLE: "NCP-VERSION-INCOMPATIBLE",
|
|
31
|
+
NCP_ENC_NOT_NEGOTIATED: "NCP-ENC-NOT-NEGOTIATED",
|
|
32
|
+
NCP_ENC_AUTH_FAILED: "NCP-ENC-AUTH-FAILED",
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=ncp-error-codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ncp-error-codes.js","sourceRoot":"","sources":["../../src/ncp/ncp-error-codes.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,oDAAoD;AACpD,EAAE;AACF,kDAAkD;AAClD,kBAAkB;AAClB,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,yDAAyD;AAEzD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,mFAAmF;IACnF,qBAAqB,EAAE,uBAAuB;IAC9C,oBAAoB,EAAE,sBAAsB;IAC5C,sCAAsC;IACtC,oBAAoB,EAAE,sBAAsB;IAC5C,qBAAqB;IACrB,sBAAsB,EAAE,wBAAwB;IAChD,2BAA2B,EAAE,6BAA6B;IAC1D,uBAAuB,EAAE,yBAAyB;IAClD,oBAAoB,EAAE,sBAAsB;IAC5C,yBAAyB,EAAE,2BAA2B;IACtD,sBAAsB,EAAE,wBAAwB;IAChD,gBAAgB,EAAE,kBAAkB;IACpC,kBAAkB,EAAE,oBAAoB;IACxC,oBAAoB,EAAE,sBAAsB;IAC5C,yBAAyB,EAAE,2BAA2B;IACtD,0BAA0B,EAAE,4BAA4B;IACxD,wBAAwB,EAAE,0BAA0B;IACpD,2BAA2B,EAAE,6BAA6B;IAC1D,wBAAwB,EAAE,0BAA0B;IACpD,sBAAsB,EAAE,wBAAwB;IAChD,mBAAmB,EAAE,qBAAqB;CAClC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const PATCH_FORMAT: {
|
|
2
|
+
readonly JSON_PATCH: "json_patch";
|
|
3
|
+
readonly BINARY_BITSET: "binary_bitset";
|
|
4
|
+
};
|
|
5
|
+
export type PatchFormat = typeof PATCH_FORMAT[keyof typeof PATCH_FORMAT];
|
|
6
|
+
export declare function isValidPatchFormat(v: unknown): v is PatchFormat;
|
|
7
|
+
//# sourceMappingURL=ncp-patch-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ncp-patch-format.d.ts","sourceRoot":"","sources":["../../src/ncp/ncp-patch-format.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY;;;CAGf,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,OAAO,YAAY,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAEzE,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,WAAW,CAE/D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
|
|
3
|
+
//
|
|
4
|
+
// NCP Patch Format — DiffFrame patch encoding types
|
|
5
|
+
// NPS-1 §4.2
|
|
6
|
+
export const PATCH_FORMAT = {
|
|
7
|
+
JSON_PATCH: "json_patch",
|
|
8
|
+
BINARY_BITSET: "binary_bitset",
|
|
9
|
+
};
|
|
10
|
+
export function isValidPatchFormat(v) {
|
|
11
|
+
return v === PATCH_FORMAT.JSON_PATCH || v === PATCH_FORMAT.BINARY_BITSET;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=ncp-patch-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ncp-patch-format.js","sourceRoot":"","sources":["../../src/ncp/ncp-patch-format.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,oDAAoD;AACpD,EAAE;AACF,oDAAoD;AACpD,aAAa;AAEb,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,UAAU,EAAE,YAAY;IACxB,aAAa,EAAE,eAAe;CACtB,CAAC;AAIX,MAAM,UAAU,kBAAkB,CAAC,CAAU;IAC3C,OAAO,CAAC,KAAK,YAAY,CAAC,UAAU,IAAI,CAAC,KAAK,YAAY,CAAC,aAAa,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NCP native-mode connection preamble — the 8-byte ASCII constant
|
|
3
|
+
* `"NPS/1.0\n"` that every native-mode client MUST emit immediately
|
|
4
|
+
* after the transport handshake and before its first HelloFrame.
|
|
5
|
+
* Defined by NPS-RFC-0001 and NPS-1 NCP §2.6.1.
|
|
6
|
+
*
|
|
7
|
+
* HTTP-mode connections do not use the preamble.
|
|
8
|
+
*/
|
|
9
|
+
export declare const PREAMBLE_LITERAL = "NPS/1.0\n";
|
|
10
|
+
export declare const PREAMBLE_LENGTH = 8;
|
|
11
|
+
export declare const PREAMBLE_BYTES: Uint8Array;
|
|
12
|
+
/** Validation timeout in milliseconds (NPS-RFC-0001 §4.1). */
|
|
13
|
+
export declare const PREAMBLE_READ_TIMEOUT_MS = 10000;
|
|
14
|
+
/** Maximum delay before closing after a mismatch, in milliseconds. */
|
|
15
|
+
export declare const PREAMBLE_CLOSE_DEADLINE_MS = 500;
|
|
16
|
+
export declare const PREAMBLE_ERROR_CODE = "NCP-PREAMBLE-INVALID";
|
|
17
|
+
export declare const PREAMBLE_STATUS_CODE = "NPS-PROTO-PREAMBLE-INVALID";
|
|
18
|
+
export declare class NcpPreambleInvalidError extends Error {
|
|
19
|
+
readonly errorCode = "NCP-PREAMBLE-INVALID";
|
|
20
|
+
readonly statusCode = "NPS-PROTO-PREAMBLE-INVALID";
|
|
21
|
+
constructor(reason: string);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns `true` iff `buf` starts with the 8-byte NPS/1.0 preamble.
|
|
25
|
+
* Safe to call with shorter buffers.
|
|
26
|
+
*/
|
|
27
|
+
export declare function preambleMatches(buf: Uint8Array): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Validates a presumed-preamble buffer.
|
|
30
|
+
* Returns `{ valid: true, reason: "" }` on success or `{ valid: false, reason }` on failure.
|
|
31
|
+
*/
|
|
32
|
+
export declare function tryValidatePreamble(buf: Uint8Array): {
|
|
33
|
+
valid: boolean;
|
|
34
|
+
reason: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Validates a presumed-preamble buffer, throwing {@link NcpPreambleInvalidError} on mismatch.
|
|
38
|
+
*/
|
|
39
|
+
export declare function validatePreamble(buf: Uint8Array): void;
|
|
40
|
+
/**
|
|
41
|
+
* Writes the preamble bytes to `writer`.
|
|
42
|
+
* `writer` must expose a `write(buf: Uint8Array): void` method (e.g. Node.js `net.Socket`).
|
|
43
|
+
*/
|
|
44
|
+
export declare function writePreamble(writer: {
|
|
45
|
+
write(buf: Uint8Array): void;
|
|
46
|
+
}): void;
|
|
47
|
+
//# sourceMappingURL=preamble.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preamble.d.ts","sourceRoot":"","sources":["../../src/ncp/preamble.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAC5C,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,cAAc,EAAE,UAAuD,CAAC;AACrF,8DAA8D;AAC9D,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,sEAAsE;AACtE,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,eAAO,MAAM,mBAAmB,yBAA0B,CAAC;AAC3D,eAAO,MAAM,oBAAoB,+BAA+B,CAAC;AAEjE,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,SAAS,0BAAwB;IAC1C,QAAQ,CAAC,UAAU,gCAAwB;gBAE/B,MAAM,EAAE,MAAM;CAI3B;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAMxD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,UAAU,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAavF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,CAGtD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE;IAAE,KAAK,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,CAE5E"}
|