@labacacia/nps-sdk 1.0.0-alpha.5 → 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 -93
- package/CHANGELOG.md +2 -102
- package/CONTRIBUTING.cn.md +0 -0
- package/CONTRIBUTING.md +0 -0
- package/LICENSE +0 -0
- package/NOTICE +0 -0
- package/README.cn.md +5 -12
- package/README.md +5 -12
- 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.nop.cn.md +0 -0
- package/doc/nps-sdk.nop.md +0 -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/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/frames.ts +0 -0
- package/src/ndp/registry.ts +0 -0
- package/src/ndp/validator.ts +0 -0
- 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 +0 -0
- 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 +0 -0
- package/src/nwp/frames.ts +0 -0
- package/src/nwp/index.ts +0 -1
- 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/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 -29
- package/dist/core/status-codes.d.ts.map +0 -1
- package/dist/core/status-codes.js +0 -39
- 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/dns-txt.d.ts +0 -35
- package/dist/ndp/dns-txt.d.ts.map +0 -1
- package/dist/ndp/dns-txt.js +0 -67
- package/dist/ndp/dns-txt.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 -6
- package/dist/ndp/index.d.ts.map +0 -1
- package/dist/ndp/index.js +0 -8
- package/dist/ndp/index.js.map +0 -1
- package/dist/ndp/ndp-registry.d.ts +0 -13
- package/dist/ndp/ndp-registry.d.ts.map +0 -1
- package/dist/ndp/ndp-registry.js +0 -104
- 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 -19
- package/dist/nip/assurance-level.d.ts.map +0 -1
- package/dist/nip/assurance-level.js +0 -38
- 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 -25
- package/dist/nip/error-codes.d.ts.map +0 -1
- package/dist/nip/error-codes.js +0 -32
- 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/error-codes.d.ts +0 -42
- package/dist/nwp/error-codes.d.ts.map +0 -1
- package/dist/nwp/error-codes.js +0 -53
- package/dist/nwp/error-codes.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 -5
- package/dist/nwp/index.d.ts.map +0 -1
- package/dist/nwp/index.js +0 -7
- 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/src/nwp/error-codes.ts +0 -62
package/dist/ncp/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/ncp/preamble.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/ncp/preamble.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 INNO LOTUS PTY LTD
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
/**
|
|
4
|
-
* NCP native-mode connection preamble — the 8-byte ASCII constant
|
|
5
|
-
* `"NPS/1.0\n"` that every native-mode client MUST emit immediately
|
|
6
|
-
* after the transport handshake and before its first HelloFrame.
|
|
7
|
-
* Defined by NPS-RFC-0001 and NPS-1 NCP §2.6.1.
|
|
8
|
-
*
|
|
9
|
-
* HTTP-mode connections do not use the preamble.
|
|
10
|
-
*/
|
|
11
|
-
export const PREAMBLE_LITERAL = "NPS/1.0\n";
|
|
12
|
-
export const PREAMBLE_LENGTH = 8;
|
|
13
|
-
export const PREAMBLE_BYTES = new TextEncoder().encode(PREAMBLE_LITERAL);
|
|
14
|
-
/** Validation timeout in milliseconds (NPS-RFC-0001 §4.1). */
|
|
15
|
-
export const PREAMBLE_READ_TIMEOUT_MS = 10_000;
|
|
16
|
-
/** Maximum delay before closing after a mismatch, in milliseconds. */
|
|
17
|
-
export const PREAMBLE_CLOSE_DEADLINE_MS = 500;
|
|
18
|
-
export const PREAMBLE_ERROR_CODE = "NCP-PREAMBLE-INVALID";
|
|
19
|
-
export const PREAMBLE_STATUS_CODE = "NPS-PROTO-PREAMBLE-INVALID";
|
|
20
|
-
export class NcpPreambleInvalidError extends Error {
|
|
21
|
-
errorCode = PREAMBLE_ERROR_CODE;
|
|
22
|
-
statusCode = PREAMBLE_STATUS_CODE;
|
|
23
|
-
constructor(reason) {
|
|
24
|
-
super(reason);
|
|
25
|
-
this.name = "NcpPreambleInvalidError";
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Returns `true` iff `buf` starts with the 8-byte NPS/1.0 preamble.
|
|
30
|
-
* Safe to call with shorter buffers.
|
|
31
|
-
*/
|
|
32
|
-
export function preambleMatches(buf) {
|
|
33
|
-
if (buf.length < PREAMBLE_LENGTH)
|
|
34
|
-
return false;
|
|
35
|
-
for (let i = 0; i < PREAMBLE_LENGTH; i++) {
|
|
36
|
-
if (buf[i] !== PREAMBLE_BYTES[i])
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Validates a presumed-preamble buffer.
|
|
43
|
-
* Returns `{ valid: true, reason: "" }` on success or `{ valid: false, reason }` on failure.
|
|
44
|
-
*/
|
|
45
|
-
export function tryValidatePreamble(buf) {
|
|
46
|
-
if (buf.length < PREAMBLE_LENGTH) {
|
|
47
|
-
return { valid: false, reason: `short read (${buf.length}/${PREAMBLE_LENGTH} bytes); peer is not speaking NCP` };
|
|
48
|
-
}
|
|
49
|
-
if (!preambleMatches(buf)) {
|
|
50
|
-
// "NPS/" = 0x4E 0x50 0x53 0x2F
|
|
51
|
-
const isNps = buf[0] === 0x4e && buf[1] === 0x50 && buf[2] === 0x53 && buf[3] === 0x2f;
|
|
52
|
-
if (isNps) {
|
|
53
|
-
return { valid: false, reason: "future-major-version NPS preamble; close with NPS-PREAMBLE-UNSUPPORTED-VERSION diagnostic" };
|
|
54
|
-
}
|
|
55
|
-
return { valid: false, reason: "preamble mismatch; peer is not speaking NPS/1.x" };
|
|
56
|
-
}
|
|
57
|
-
return { valid: true, reason: "" };
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Validates a presumed-preamble buffer, throwing {@link NcpPreambleInvalidError} on mismatch.
|
|
61
|
-
*/
|
|
62
|
-
export function validatePreamble(buf) {
|
|
63
|
-
const { valid, reason } = tryValidatePreamble(buf);
|
|
64
|
-
if (!valid)
|
|
65
|
-
throw new NcpPreambleInvalidError(reason);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Writes the preamble bytes to `writer`.
|
|
69
|
-
* `writer` must expose a `write(buf: Uint8Array): void` method (e.g. Node.js `net.Socket`).
|
|
70
|
-
*/
|
|
71
|
-
export function writePreamble(writer) {
|
|
72
|
-
writer.write(PREAMBLE_BYTES);
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=preamble.js.map
|
package/dist/ncp/preamble.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preamble.js","sourceRoot":"","sources":["../../src/ncp/preamble.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,sCAAsC;AAEtC;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAC5C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AACjC,MAAM,CAAC,MAAM,cAAc,GAAe,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACrF,8DAA8D;AAC9D,MAAM,C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AC,CAAC,CAAC,KAAK,IAAI,CAAC;QACvF,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,2FAA2F,EAAE,CAAC;QAC/H,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,iDAAiD,EAAE,CAAC;IACrF,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAe;IAC9C,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACnD,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC;AACxD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAAwC;IACpE,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AAC/B,CAAC"}
|
package/dist/ncp/registry.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/ncp/registry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAO/D"}
|
package/dist/ncp/registry.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 INNO LOTUS PTY LTD
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { FrameType } from "../core/frames.js";
|
|
4
|
-
import { AnchorFrame, CapsFrame, DiffFrame, ErrorFrame, HelloFrame, StreamFrame } from "./frames.js";
|
|
5
|
-
export function registerNcpFrames(registry) {
|
|
6
|
-
registry.register(FrameType.ANCHOR, AnchorFrame);
|
|
7
|
-
registry.register(FrameType.DIFF, DiffFrame);
|
|
8
|
-
registry.register(FrameType.STREAM, StreamFrame);
|
|
9
|
-
registry.register(FrameType.CAPS, CapsFrame);
|
|
10
|
-
registry.register(FrameType.HELLO, HelloFrame);
|
|
11
|
-
registry.register(FrameType.ERROR, ErrorFrame);
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=registry.js.map
|
package/dist/ncp/registry.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/ncp/registry.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,sCAAsC;AAGtC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAErG,MAAM,UAAU,iBAAiB,CAAC,QAAuB;IACvD,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACjD,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAI,SAAS,CAAC,CAAC;IAC/C,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACjD,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAI,SAAS,CAAC,CAAC;IAC/C,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAG,UAAU,CAAC,CAAC;IAChD,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAG,UAAU,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { StreamFrame } from "./frames/stream-frame.js";
|
|
2
|
-
/**
|
|
3
|
-
* Manages concurrent StreamFrame streams.
|
|
4
|
-
*
|
|
5
|
-
* - Tracks active streams by stream_id
|
|
6
|
-
* - Validates sequential seq numbers
|
|
7
|
-
* - Enforces max concurrent stream limit (NPS-1 §7.3, default 32)
|
|
8
|
-
* - Detects early termination via error_code
|
|
9
|
-
* - Enforces window-based flow control on outgoing streams (NCP-S-07–11)
|
|
10
|
-
*/
|
|
11
|
-
export declare class StreamManager {
|
|
12
|
-
private readonly streams;
|
|
13
|
-
private readonly outgoing;
|
|
14
|
-
private readonly maxConcurrent;
|
|
15
|
-
constructor(options?: {
|
|
16
|
-
maxConcurrent?: number;
|
|
17
|
-
});
|
|
18
|
-
/**
|
|
19
|
-
* Receive a StreamFrame chunk.
|
|
20
|
-
*
|
|
21
|
-
* @returns true if stream is complete (is_last=true or error_code set).
|
|
22
|
-
* @throws {NcpError} NCP-STREAM-LIMIT-EXCEEDED if too many concurrent streams.
|
|
23
|
-
* @throws {NcpError} NCP-STREAM-NOT-FOUND if frame.seq > 0 for a stream that was never opened.
|
|
24
|
-
* @throws {NcpError} NPS-CLIENT-CONFLICT if the stream_id was already completed (stream-id reuse; see test_cases NCP-S-04).
|
|
25
|
-
* @throws {NcpError} NCP-STREAM-SEQ-GAP if sequence number is not expected.
|
|
26
|
-
*/
|
|
27
|
-
receive(frame: StreamFrame): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Send a StreamFrame on an outgoing stream, enforcing window-based flow control.
|
|
30
|
-
*
|
|
31
|
-
* - seq=0 with window_size initialises remainingWindow (no decrement for opening frame).
|
|
32
|
-
* - Subsequent sends decrement remainingWindow when flow control is active.
|
|
33
|
-
* - Throws NCP-STREAM-WINDOW-OVERFLOW when remainingWindow === 0.
|
|
34
|
-
*
|
|
35
|
-
* @throws {NcpError} NCP-STREAM-WINDOW-OVERFLOW if window is exhausted.
|
|
36
|
-
*/
|
|
37
|
-
send(frame: StreamFrame): void;
|
|
38
|
-
/**
|
|
39
|
-
* Update the send window for a stream.
|
|
40
|
-
*
|
|
41
|
-
* Called when a reverse-direction StreamFrame arrives with data=[] and window_size set.
|
|
42
|
-
* Replaces remainingWindow with new_size. Sets paused=true when new_size === 0.
|
|
43
|
-
*/
|
|
44
|
-
updateWindow(streamId: string, newSize: number): void;
|
|
45
|
-
/**
|
|
46
|
-
* Returns true when the outgoing stream is paused (window=0 was received).
|
|
47
|
-
* Resumes (returns false) once a non-zero window update arrives.
|
|
48
|
-
*/
|
|
49
|
-
isPaused(streamId: string): boolean;
|
|
50
|
-
/** Get reassembled data for a completed stream. */
|
|
51
|
-
getData(streamId: string): unknown[] | null;
|
|
52
|
-
/** Get error code if stream terminated with error. */
|
|
53
|
-
getError(streamId: string): string | undefined;
|
|
54
|
-
/** Number of active (non-completed) streams. */
|
|
55
|
-
get activeCount(): number;
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=stream-manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream-manager.d.ts","sourceRoot":"","sources":["../../src/ncp/stream-manager.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAgB5D;;;;;;;;GAQG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmC;IAC3D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqC;IAC9D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;gBAE3B,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE;IAIhD;;;;;;;;OAQG;IACH,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO;IAwEpC;;;;;;;;OAQG;IACH,IAAI,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IA8B9B;;;;;OAKG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAerD;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAInC,mDAAmD;IACnD,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,EAAE,GAAG,IAAI;IAM3C,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI9C,gDAAgD;IAChD,IAAI,WAAW,IAAI,MAAM,CAMxB;CACF"}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
|
|
3
|
-
//
|
|
4
|
-
// StreamManager — Concurrent stream tracking, sequence validation, flow control
|
|
5
|
-
// NPS-1 §4.3, §7.3
|
|
6
|
-
import { NcpError } from "../core/frame-header.js";
|
|
7
|
-
import { NCP_ERROR_CODES } from "./ncp-error-codes.js";
|
|
8
|
-
/**
|
|
9
|
-
* Manages concurrent StreamFrame streams.
|
|
10
|
-
*
|
|
11
|
-
* - Tracks active streams by stream_id
|
|
12
|
-
* - Validates sequential seq numbers
|
|
13
|
-
* - Enforces max concurrent stream limit (NPS-1 §7.3, default 32)
|
|
14
|
-
* - Detects early termination via error_code
|
|
15
|
-
* - Enforces window-based flow control on outgoing streams (NCP-S-07–11)
|
|
16
|
-
*/
|
|
17
|
-
export class StreamManager {
|
|
18
|
-
streams = new Map();
|
|
19
|
-
outgoing = new Map();
|
|
20
|
-
maxConcurrent;
|
|
21
|
-
constructor(options) {
|
|
22
|
-
this.maxConcurrent = options?.maxConcurrent ?? 32;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Receive a StreamFrame chunk.
|
|
26
|
-
*
|
|
27
|
-
* @returns true if stream is complete (is_last=true or error_code set).
|
|
28
|
-
* @throws {NcpError} NCP-STREAM-LIMIT-EXCEEDED if too many concurrent streams.
|
|
29
|
-
* @throws {NcpError} NCP-STREAM-NOT-FOUND if frame.seq > 0 for a stream that was never opened.
|
|
30
|
-
* @throws {NcpError} NPS-CLIENT-CONFLICT if the stream_id was already completed (stream-id reuse; see test_cases NCP-S-04).
|
|
31
|
-
* @throws {NcpError} NCP-STREAM-SEQ-GAP if sequence number is not expected.
|
|
32
|
-
*/
|
|
33
|
-
receive(frame) {
|
|
34
|
-
let stream = this.streams.get(frame.stream_id);
|
|
35
|
-
if (!stream) {
|
|
36
|
-
// A stream is opened only by seq=0. Any other seq on an unknown stream_id
|
|
37
|
-
// means the opener was never seen (NCP-S-13: unknown stream_id).
|
|
38
|
-
if (frame.seq !== 0) {
|
|
39
|
-
throw new NcpError(NCP_ERROR_CODES.NCP_STREAM_NOT_FOUND, `Unknown stream_id ${frame.stream_id} — first frame must have seq=0`);
|
|
40
|
-
}
|
|
41
|
-
// New stream — check concurrent limit
|
|
42
|
-
if (this.streams.size >= this.maxConcurrent) {
|
|
43
|
-
throw new NcpError(NCP_ERROR_CODES.NCP_STREAM_LIMIT_EXCEEDED, `Max concurrent streams (${this.maxConcurrent}) exceeded`);
|
|
44
|
-
}
|
|
45
|
-
stream = {
|
|
46
|
-
streamId: frame.stream_id,
|
|
47
|
-
expectedSeq: 0,
|
|
48
|
-
chunks: [],
|
|
49
|
-
completed: false,
|
|
50
|
-
};
|
|
51
|
-
this.streams.set(frame.stream_id, stream);
|
|
52
|
-
}
|
|
53
|
-
// Reject writes to completed streams. Per test_cases NCP-S-04, the spec does
|
|
54
|
-
// not assign a dedicated NCP code for stream-id reuse; interim mapping uses
|
|
55
|
-
// the NPS-level NPS-CLIENT-CONFLICT until a spec-side code is added.
|
|
56
|
-
if (stream.completed) {
|
|
57
|
-
throw new NcpError("NPS-CLIENT-CONFLICT", `Stream ${frame.stream_id} is already completed — cannot reuse stream_id`);
|
|
58
|
-
}
|
|
59
|
-
// Sequence validation
|
|
60
|
-
if (frame.seq !== stream.expectedSeq) {
|
|
61
|
-
// Duplicate detection — same seq as last accepted
|
|
62
|
-
if (frame.seq < stream.expectedSeq) {
|
|
63
|
-
// Ignore duplicate (idempotent)
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
throw new NcpError(NCP_ERROR_CODES.NCP_STREAM_SEQ_GAP, `Expected seq ${stream.expectedSeq}, got ${frame.seq} on stream ${frame.stream_id}`);
|
|
67
|
-
}
|
|
68
|
-
stream.chunks.push(frame.data);
|
|
69
|
-
stream.expectedSeq = frame.seq + 1;
|
|
70
|
-
// Early termination via error_code
|
|
71
|
-
if (frame.error_code) {
|
|
72
|
-
stream.completed = true;
|
|
73
|
-
stream.errorCode = frame.error_code;
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
// Normal completion
|
|
77
|
-
if (frame.is_last) {
|
|
78
|
-
stream.completed = true;
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Send a StreamFrame on an outgoing stream, enforcing window-based flow control.
|
|
85
|
-
*
|
|
86
|
-
* - seq=0 with window_size initialises remainingWindow (no decrement for opening frame).
|
|
87
|
-
* - Subsequent sends decrement remainingWindow when flow control is active.
|
|
88
|
-
* - Throws NCP-STREAM-WINDOW-OVERFLOW when remainingWindow === 0.
|
|
89
|
-
*
|
|
90
|
-
* @throws {NcpError} NCP-STREAM-WINDOW-OVERFLOW if window is exhausted.
|
|
91
|
-
*/
|
|
92
|
-
send(frame) {
|
|
93
|
-
let out = this.outgoing.get(frame.stream_id);
|
|
94
|
-
if (!out) {
|
|
95
|
-
out = {
|
|
96
|
-
streamId: frame.stream_id,
|
|
97
|
-
remainingWindow: undefined,
|
|
98
|
-
paused: false,
|
|
99
|
-
};
|
|
100
|
-
this.outgoing.set(frame.stream_id, out);
|
|
101
|
-
}
|
|
102
|
-
// Opening frame: initialise window from window_size if provided.
|
|
103
|
-
if (frame.seq === 0 && frame.window_size !== undefined) {
|
|
104
|
-
out.remainingWindow = frame.window_size;
|
|
105
|
-
return; // opening frame does not consume a window slot
|
|
106
|
-
}
|
|
107
|
-
// Flow control check for subsequent frames.
|
|
108
|
-
if (out.remainingWindow !== undefined) {
|
|
109
|
-
if (out.remainingWindow === 0) {
|
|
110
|
-
throw new NcpError(NCP_ERROR_CODES.NCP_STREAM_WINDOW_OVERFLOW, `Window exhausted on stream ${frame.stream_id}`);
|
|
111
|
-
}
|
|
112
|
-
out.remainingWindow -= 1;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Update the send window for a stream.
|
|
117
|
-
*
|
|
118
|
-
* Called when a reverse-direction StreamFrame arrives with data=[] and window_size set.
|
|
119
|
-
* Replaces remainingWindow with new_size. Sets paused=true when new_size === 0.
|
|
120
|
-
*/
|
|
121
|
-
updateWindow(streamId, newSize) {
|
|
122
|
-
let out = this.outgoing.get(streamId);
|
|
123
|
-
if (!out) {
|
|
124
|
-
out = {
|
|
125
|
-
streamId,
|
|
126
|
-
remainingWindow: newSize,
|
|
127
|
-
paused: newSize === 0,
|
|
128
|
-
};
|
|
129
|
-
this.outgoing.set(streamId, out);
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
out.remainingWindow = newSize;
|
|
133
|
-
out.paused = newSize === 0;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Returns true when the outgoing stream is paused (window=0 was received).
|
|
137
|
-
* Resumes (returns false) once a non-zero window update arrives.
|
|
138
|
-
*/
|
|
139
|
-
isPaused(streamId) {
|
|
140
|
-
return this.outgoing.get(streamId)?.paused ?? false;
|
|
141
|
-
}
|
|
142
|
-
/** Get reassembled data for a completed stream. */
|
|
143
|
-
getData(streamId) {
|
|
144
|
-
const stream = this.streams.get(streamId);
|
|
145
|
-
if (!stream || !stream.completed)
|
|
146
|
-
return null;
|
|
147
|
-
return stream.chunks.flat();
|
|
148
|
-
}
|
|
149
|
-
/** Get error code if stream terminated with error. */
|
|
150
|
-
getError(streamId) {
|
|
151
|
-
return this.streams.get(streamId)?.errorCode;
|
|
152
|
-
}
|
|
153
|
-
/** Number of active (non-completed) streams. */
|
|
154
|
-
get activeCount() {
|
|
155
|
-
let count = 0;
|
|
156
|
-
for (const s of this.streams.values()) {
|
|
157
|
-
if (!s.completed)
|
|
158
|
-
count++;
|
|
159
|
-
}
|
|
160
|
-
return count;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
//# sourceMappingURL=stream-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream-manager.js","sourceRoot":"","sources":["../../src/ncp/stream-manager.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,oDAAoD;AACpD,EAAE;AACF,gFAAgF;AAChF,mBAAmB;AAEnB,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAiBvD;;;;;;;;GAQG;AACH,MAAM,OAAO,aAAa;IACP,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC1C,QAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC7C,aAAa,CAAS;IAEvC,YAAY,OAAoC;QAC9C,IAAI,CAAC,aAAa,GAAG,OAAO,EAAE,aAAa,IAAI,EAAE,CAAC;IACpD,CAAC;IAED;;;;;;;;OAQG;IACH,OAAO,CAAC,KAAkB;QACxB,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAE/C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,0EAA0E;YAC1E,iEAAiE;YACjE,IAAI,KAAK,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC;gBACpB,MAAM,IAAI,QAAQ,CAChB,eAAe,CAAC,oBAAoB,EACpC,qBAAqB,KAAK,CAAC,SAAS,gCAAgC,CACrE,CAAC;YACJ,CAAC;YAED,sCAAsC;YACtC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;gBAC5C,MAAM,IAAI,QAAQ,CAChB,eAAe,CAAC,yBAAyB,EACzC,2BAA2B,IAAI,CAAC,aAAa,YAAY,CAC1D,CAAC;YACJ,C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,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;YACjC,OAAO;QACT,CAAC;QACD,GAAG,CAAC,eAAe,GAAG,OAAO,CAAC;QAC9B,GAAG,CAAC,MAAM,GAAG,OAAO,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,QAAgB;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,KAAK,CAAC;IACtD,CAAC;IAED,mDAAmD;IACnD,OAAO,CAAC,QAAgB;QACtB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC1C,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC;QAC9C,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED,sDAAsD;IACtD,QAAQ,CAAC,QAAgB;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC/C,CAAC;IAED,gDAAgD;IAChD,IAAI,WAAW;QACb,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YACtC,IAAI,CAAC,CAAC,CAAC,SAAS;gBAAE,KAAK,EAAE,CAAC;QAC5B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
package/dist/ndp/dns-txt.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { NdpResolveResult } from "./frames.js";
|
|
2
|
-
export declare const DNS_TXT_DEFAULT_TTL = 300;
|
|
3
|
-
/**
|
|
4
|
-
* Extract the hostname from an NWP target URI.
|
|
5
|
-
* e.g. "nwp://api.example.com/products" → "api.example.com"
|
|
6
|
-
*/
|
|
7
|
-
export declare function extractHostFromTarget(target: string): string | undefined;
|
|
8
|
-
/**
|
|
9
|
-
* Parse one TXT record (array of string chunks) into an NdpResolveResult.
|
|
10
|
-
*
|
|
11
|
-
* Expected format (chunks joined with a single space):
|
|
12
|
-
* v=nps1 type=<type> port=<port> nid=<nid> fp=sha256:<fingerprint>
|
|
13
|
-
*
|
|
14
|
-
* Rules:
|
|
15
|
-
* - `v` MUST be present and equal to "nps1"
|
|
16
|
-
* - `nid` MUST be present
|
|
17
|
-
* - `port` defaults to 17433 when absent
|
|
18
|
-
* - `fp` is mapped to certFingerprint
|
|
19
|
-
*/
|
|
20
|
-
export declare function parseNpsTxtRecord(parts: string[], host: string): NdpResolveResult | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* Abstraction over DNS TXT lookups.
|
|
23
|
-
* The default implementation uses Node's `dns.promises`; pass a mock in tests.
|
|
24
|
-
*/
|
|
25
|
-
export interface DnsTxtLookup {
|
|
26
|
-
resolveTxt(hostname: string): Promise<string[][]>;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* System DNS TXT resolver backed by Node's built-in `dns.promises`.
|
|
30
|
-
* The dynamic `import()` keeps browser bundles from failing at parse time.
|
|
31
|
-
*/
|
|
32
|
-
export declare class SystemDnsTxtLookup implements DnsTxtLookup {
|
|
33
|
-
resolveTxt(hostname: string): Promise<string[][]>;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=dns-txt.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dns-txt.d.ts","sourceRoot":"","sources":["../../src/ndp/dns-txt.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMxE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,MAAM,GACX,gBAAgB,GAAG,SAAS,CAgC9B;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;CACnD;AAED;;;GAGG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IAC/C,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;CAIxD"}
|
package/dist/ndp/dns-txt.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 INNO LOTUS PTY LTD
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
export const DNS_TXT_DEFAULT_TTL = 300;
|
|
4
|
-
/**
|
|
5
|
-
* Extract the hostname from an NWP target URI.
|
|
6
|
-
* e.g. "nwp://api.example.com/products" → "api.example.com"
|
|
7
|
-
*/
|
|
8
|
-
export function extractHostFromTarget(target) {
|
|
9
|
-
if (!target.startsWith("nwp://"))
|
|
10
|
-
return undefined;
|
|
11
|
-
const rest = target.slice("nwp://".length);
|
|
12
|
-
const slashIdx = rest.indexOf("/");
|
|
13
|
-
const host = slashIdx === -1 ? rest : rest.slice(0, slashIdx);
|
|
14
|
-
return host.length > 0 ? host : undefined;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Parse one TXT record (array of string chunks) into an NdpResolveResult.
|
|
18
|
-
*
|
|
19
|
-
* Expected format (chunks joined with a single space):
|
|
20
|
-
* v=nps1 type=<type> port=<port> nid=<nid> fp=sha256:<fingerprint>
|
|
21
|
-
*
|
|
22
|
-
* Rules:
|
|
23
|
-
* - `v` MUST be present and equal to "nps1"
|
|
24
|
-
* - `nid` MUST be present
|
|
25
|
-
* - `port` defaults to 17433 when absent
|
|
26
|
-
* - `fp` is mapped to certFingerprint
|
|
27
|
-
*/
|
|
28
|
-
export function parseNpsTxtRecord(parts, host) {
|
|
29
|
-
const joined = parts.join(" ");
|
|
30
|
-
const kv = new Map();
|
|
31
|
-
for (const token of joined.split(/\s+/)) {
|
|
32
|
-
const eq = token.indexOf("=");
|
|
33
|
-
if (eq === -1)
|
|
34
|
-
continue;
|
|
35
|
-
const key = token.slice(0, eq);
|
|
36
|
-
const val = token.slice(eq + 1);
|
|
37
|
-
kv.set(key, val);
|
|
38
|
-
}
|
|
39
|
-
if (kv.get("v") !== "nps1")
|
|
40
|
-
return undefined;
|
|
41
|
-
const nid = kv.get("nid");
|
|
42
|
-
if (!nid)
|
|
43
|
-
return undefined;
|
|
44
|
-
const rawPort = kv.get("port");
|
|
45
|
-
const port = rawPort !== undefined ? Number(rawPort) : 17433;
|
|
46
|
-
const fp = kv.get("fp");
|
|
47
|
-
const result = {
|
|
48
|
-
host,
|
|
49
|
-
port,
|
|
50
|
-
ttl: DNS_TXT_DEFAULT_TTL,
|
|
51
|
-
};
|
|
52
|
-
if (fp !== undefined) {
|
|
53
|
-
result.certFingerprint = fp;
|
|
54
|
-
}
|
|
55
|
-
return result;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* System DNS TXT resolver backed by Node's built-in `dns.promises`.
|
|
59
|
-
* The dynamic `import()` keeps browser bundles from failing at parse time.
|
|
60
|
-
*/
|
|
61
|
-
export class SystemDnsTxtLookup {
|
|
62
|
-
async resolveTxt(hostname) {
|
|
63
|
-
const { promises: dns } = await import("node:dns");
|
|
64
|
-
return dns.resolveTxt(hostname);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=dns-txt.js.map
|
package/dist/ndp/dns-txt.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dns-txt.js","sourceRoot":"","sources":["../../src/ndp/dns-txt.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,sCAAsC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