@aster-rpc/aster 0.1.2
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/dist/capabilities.d.ts +26 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +29 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/client.d.ts +65 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +108 -0
- package/dist/client.js.map +1 -0
- package/dist/codec.d.ts +156 -0
- package/dist/codec.d.ts.map +1 -0
- package/dist/codec.js +477 -0
- package/dist/codec.js.map +1 -0
- package/dist/config.d.ts +102 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +454 -0
- package/dist/config.js.map +1 -0
- package/dist/contract/identity.d.ts +115 -0
- package/dist/contract/identity.d.ts.map +1 -0
- package/dist/contract/identity.js +188 -0
- package/dist/contract/identity.js.map +1 -0
- package/dist/contract/manifest.d.ts +77 -0
- package/dist/contract/manifest.d.ts.map +1 -0
- package/dist/contract/manifest.js +127 -0
- package/dist/contract/manifest.js.map +1 -0
- package/dist/contract/publication.d.ts +71 -0
- package/dist/contract/publication.d.ts.map +1 -0
- package/dist/contract/publication.js +85 -0
- package/dist/contract/publication.js.map +1 -0
- package/dist/decorators.d.ts +139 -0
- package/dist/decorators.d.ts.map +1 -0
- package/dist/decorators.js +175 -0
- package/dist/decorators.js.map +1 -0
- package/dist/dynamic.d.ts +61 -0
- package/dist/dynamic.d.ts.map +1 -0
- package/dist/dynamic.js +147 -0
- package/dist/dynamic.js.map +1 -0
- package/dist/framing.d.ts +74 -0
- package/dist/framing.d.ts.map +1 -0
- package/dist/framing.js +162 -0
- package/dist/framing.js.map +1 -0
- package/dist/health.d.ts +127 -0
- package/dist/health.d.ts.map +1 -0
- package/dist/health.js +236 -0
- package/dist/health.js.map +1 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +101 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptors/audit.d.ts +25 -0
- package/dist/interceptors/audit.d.ts.map +1 -0
- package/dist/interceptors/audit.js +46 -0
- package/dist/interceptors/audit.js.map +1 -0
- package/dist/interceptors/auth.d.ts +13 -0
- package/dist/interceptors/auth.d.ts.map +1 -0
- package/dist/interceptors/auth.js +34 -0
- package/dist/interceptors/auth.js.map +1 -0
- package/dist/interceptors/base.d.ts +74 -0
- package/dist/interceptors/base.d.ts.map +1 -0
- package/dist/interceptors/base.js +103 -0
- package/dist/interceptors/base.js.map +1 -0
- package/dist/interceptors/capability.d.ts +16 -0
- package/dist/interceptors/capability.d.ts.map +1 -0
- package/dist/interceptors/capability.js +63 -0
- package/dist/interceptors/capability.js.map +1 -0
- package/dist/interceptors/circuit-breaker.d.ts +40 -0
- package/dist/interceptors/circuit-breaker.d.ts.map +1 -0
- package/dist/interceptors/circuit-breaker.js +91 -0
- package/dist/interceptors/circuit-breaker.js.map +1 -0
- package/dist/interceptors/compression.d.ts +11 -0
- package/dist/interceptors/compression.d.ts.map +1 -0
- package/dist/interceptors/compression.js +12 -0
- package/dist/interceptors/compression.js.map +1 -0
- package/dist/interceptors/deadline.d.ts +12 -0
- package/dist/interceptors/deadline.d.ts.map +1 -0
- package/dist/interceptors/deadline.js +28 -0
- package/dist/interceptors/deadline.js.map +1 -0
- package/dist/interceptors/metrics.d.ts +43 -0
- package/dist/interceptors/metrics.d.ts.map +1 -0
- package/dist/interceptors/metrics.js +132 -0
- package/dist/interceptors/metrics.js.map +1 -0
- package/dist/interceptors/rate-limit.d.ts +24 -0
- package/dist/interceptors/rate-limit.d.ts.map +1 -0
- package/dist/interceptors/rate-limit.js +84 -0
- package/dist/interceptors/rate-limit.js.map +1 -0
- package/dist/interceptors/retry.d.ts +25 -0
- package/dist/interceptors/retry.d.ts.map +1 -0
- package/dist/interceptors/retry.js +55 -0
- package/dist/interceptors/retry.js.map +1 -0
- package/dist/limits.d.ts +77 -0
- package/dist/limits.d.ts.map +1 -0
- package/dist/limits.js +137 -0
- package/dist/limits.js.map +1 -0
- package/dist/logging.d.ts +40 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +92 -0
- package/dist/logging.js.map +1 -0
- package/dist/metadata.d.ts +14 -0
- package/dist/metadata.d.ts.map +1 -0
- package/dist/metadata.js +68 -0
- package/dist/metadata.js.map +1 -0
- package/dist/metrics.d.ts +40 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +92 -0
- package/dist/metrics.js.map +1 -0
- package/dist/peer-store.d.ts +53 -0
- package/dist/peer-store.d.ts.map +1 -0
- package/dist/peer-store.js +105 -0
- package/dist/peer-store.js.map +1 -0
- package/dist/protocol.d.ts +44 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +59 -0
- package/dist/protocol.js.map +1 -0
- package/dist/registration.d.ts +81 -0
- package/dist/registration.d.ts.map +1 -0
- package/dist/registration.js +161 -0
- package/dist/registration.js.map +1 -0
- package/dist/registry/acl.d.ts +57 -0
- package/dist/registry/acl.d.ts.map +1 -0
- package/dist/registry/acl.js +104 -0
- package/dist/registry/acl.js.map +1 -0
- package/dist/registry/client.d.ts +70 -0
- package/dist/registry/client.d.ts.map +1 -0
- package/dist/registry/client.js +115 -0
- package/dist/registry/client.js.map +1 -0
- package/dist/registry/gossip.d.ts +43 -0
- package/dist/registry/gossip.d.ts.map +1 -0
- package/dist/registry/gossip.js +102 -0
- package/dist/registry/gossip.js.map +1 -0
- package/dist/registry/keys.d.ts +25 -0
- package/dist/registry/keys.d.ts.map +1 -0
- package/dist/registry/keys.js +47 -0
- package/dist/registry/keys.js.map +1 -0
- package/dist/registry/models.d.ts +80 -0
- package/dist/registry/models.d.ts.map +1 -0
- package/dist/registry/models.js +35 -0
- package/dist/registry/models.js.map +1 -0
- package/dist/registry/publisher.d.ts +65 -0
- package/dist/registry/publisher.d.ts.map +1 -0
- package/dist/registry/publisher.js +164 -0
- package/dist/registry/publisher.js.map +1 -0
- package/dist/runtime.d.ts +267 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1366 -0
- package/dist/runtime.js.map +1 -0
- package/dist/server.d.ts +100 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +511 -0
- package/dist/server.js.map +1 -0
- package/dist/service.d.ts +72 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +98 -0
- package/dist/service.js.map +1 -0
- package/dist/session.d.ts +64 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +350 -0
- package/dist/session.js.map +1 -0
- package/dist/status.d.ts +113 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +206 -0
- package/dist/status.js.map +1 -0
- package/dist/transport/base.d.ts +46 -0
- package/dist/transport/base.d.ts.map +1 -0
- package/dist/transport/base.js +10 -0
- package/dist/transport/base.js.map +1 -0
- package/dist/transport/iroh.d.ts +45 -0
- package/dist/transport/iroh.d.ts.map +1 -0
- package/dist/transport/iroh.js +225 -0
- package/dist/transport/iroh.js.map +1 -0
- package/dist/transport/local.d.ts +48 -0
- package/dist/transport/local.d.ts.map +1 -0
- package/dist/transport/local.js +139 -0
- package/dist/transport/local.js.map +1 -0
- package/dist/trust/admission.d.ts +60 -0
- package/dist/trust/admission.d.ts.map +1 -0
- package/dist/trust/admission.js +149 -0
- package/dist/trust/admission.js.map +1 -0
- package/dist/trust/bootstrap.d.ts +109 -0
- package/dist/trust/bootstrap.d.ts.map +1 -0
- package/dist/trust/bootstrap.js +311 -0
- package/dist/trust/bootstrap.js.map +1 -0
- package/dist/trust/clock.d.ts +93 -0
- package/dist/trust/clock.d.ts.map +1 -0
- package/dist/trust/clock.js +154 -0
- package/dist/trust/clock.js.map +1 -0
- package/dist/trust/consumer.d.ts +139 -0
- package/dist/trust/consumer.d.ts.map +1 -0
- package/dist/trust/consumer.js +323 -0
- package/dist/trust/consumer.js.map +1 -0
- package/dist/trust/credentials.d.ts +98 -0
- package/dist/trust/credentials.d.ts.map +1 -0
- package/dist/trust/credentials.js +250 -0
- package/dist/trust/credentials.js.map +1 -0
- package/dist/trust/delegated.d.ts +118 -0
- package/dist/trust/delegated.d.ts.map +1 -0
- package/dist/trust/delegated.js +292 -0
- package/dist/trust/delegated.js.map +1 -0
- package/dist/trust/gossip.d.ts +146 -0
- package/dist/trust/gossip.d.ts.map +1 -0
- package/dist/trust/gossip.js +334 -0
- package/dist/trust/gossip.js.map +1 -0
- package/dist/trust/hooks.d.ts +84 -0
- package/dist/trust/hooks.d.ts.map +1 -0
- package/dist/trust/hooks.js +125 -0
- package/dist/trust/hooks.js.map +1 -0
- package/dist/trust/iid.d.ts +65 -0
- package/dist/trust/iid.d.ts.map +1 -0
- package/dist/trust/iid.js +104 -0
- package/dist/trust/iid.js.map +1 -0
- package/dist/trust/mesh.d.ts +43 -0
- package/dist/trust/mesh.d.ts.map +1 -0
- package/dist/trust/mesh.js +105 -0
- package/dist/trust/mesh.js.map +1 -0
- package/dist/trust/nonce.d.ts +39 -0
- package/dist/trust/nonce.d.ts.map +1 -0
- package/dist/trust/nonce.js +46 -0
- package/dist/trust/nonce.js.map +1 -0
- package/dist/trust/producer.d.ts +80 -0
- package/dist/trust/producer.d.ts.map +1 -0
- package/dist/trust/producer.js +151 -0
- package/dist/trust/producer.js.map +1 -0
- package/dist/trust/rcan.d.ts +29 -0
- package/dist/trust/rcan.d.ts.map +1 -0
- package/dist/trust/rcan.js +57 -0
- package/dist/trust/rcan.js.map +1 -0
- package/dist/types.d.ts +57 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +50 -0
- package/dist/types.js.map +1 -0
- package/dist/xlang.d.ts +26 -0
- package/dist/xlang.d.ts.map +1 -0
- package/dist/xlang.js +55 -0
- package/dist/xlang.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consumer admission — client-side and server-side admission handshake.
|
|
3
|
+
*
|
|
4
|
+
* Spec reference: Aster-trust-spec.md S5
|
|
5
|
+
*
|
|
6
|
+
* Client side (performAdmission):
|
|
7
|
+
* 1. Open a stream on the admission ALPN
|
|
8
|
+
* 2. Send a ConsumerAdmissionRequest (credential + optional IID token)
|
|
9
|
+
* 3. Receive a ConsumerAdmissionResponse (services list + registry namespace)
|
|
10
|
+
*
|
|
11
|
+
* Server side (handleConsumerAdmissionRpc, serveConsumerAdmission):
|
|
12
|
+
* Verify credential, admit peer, return response with services + registry namespace.
|
|
13
|
+
*
|
|
14
|
+
* Wire format: newline-delimited JSON over a QUIC bidi-stream on
|
|
15
|
+
* aster.consumer_admission ALPN. Client sends one JSON line; server
|
|
16
|
+
* responds with one JSON line and closes the stream.
|
|
17
|
+
*/
|
|
18
|
+
import { type ConsumerEnrollmentCredential } from './credentials.js';
|
|
19
|
+
import type { MeshEndpointHook } from './hooks.js';
|
|
20
|
+
import type { NonceStore } from './nonce.js';
|
|
21
|
+
import { type PeerAttributeStore } from '../peer-store.js';
|
|
22
|
+
/**
|
|
23
|
+
* Service summary returned in admission response.
|
|
24
|
+
*
|
|
25
|
+
* NOTE: Wire format uses snake_case keys (contract_id) for Python interop.
|
|
26
|
+
* The camelCase interface fields here need mapping when parsing from wire.
|
|
27
|
+
* TODO: Add proper wire-format mapping for ServiceSummary (pre-existing gap).
|
|
28
|
+
*/
|
|
29
|
+
export interface ServiceSummary {
|
|
30
|
+
name: string;
|
|
31
|
+
version: number;
|
|
32
|
+
contractId: string;
|
|
33
|
+
pattern: string;
|
|
34
|
+
methods: string[];
|
|
35
|
+
channels?: Record<string, string>;
|
|
36
|
+
/** Serialization modes the server supports for this service.
|
|
37
|
+
* Values: "xlang" (Fory), "json", "row", "native". A consumer must
|
|
38
|
+
* pick one of these for any RPC call. The TypeScript binding only
|
|
39
|
+
* publishes "json" because Fory JS is not yet XLANG-compliant. */
|
|
40
|
+
serializationModes?: string[];
|
|
41
|
+
}
|
|
42
|
+
/** Consumer admission request. */
|
|
43
|
+
export interface ConsumerAdmissionRequest {
|
|
44
|
+
credentialJson: string;
|
|
45
|
+
iidToken?: string;
|
|
46
|
+
}
|
|
47
|
+
/** Consumer admission response from producer. */
|
|
48
|
+
export interface ConsumerAdmissionResponse {
|
|
49
|
+
admitted: boolean;
|
|
50
|
+
reason?: string;
|
|
51
|
+
services: ServiceSummary[];
|
|
52
|
+
registryNamespace?: string;
|
|
53
|
+
attributes?: Record<string, string>;
|
|
54
|
+
rootPubkey?: string;
|
|
55
|
+
/** Hex-encoded 32-byte gossip topic — only populated for root node. */
|
|
56
|
+
gossipTopic?: string;
|
|
57
|
+
}
|
|
58
|
+
/** Options for server-side consumer admission handlers. */
|
|
59
|
+
export interface ConsumerAdmissionOpts {
|
|
60
|
+
nonceStore?: NonceStore;
|
|
61
|
+
services?: ServiceSummary[];
|
|
62
|
+
registryNamespace?: string;
|
|
63
|
+
allowUnenrolled?: boolean;
|
|
64
|
+
/** Gossip topic ID (32 bytes). Included in response only for root node. */
|
|
65
|
+
gossipTopicId?: Uint8Array;
|
|
66
|
+
/** When supplied, successful admissions are recorded so the RPC dispatch
|
|
67
|
+
* layer can read the peer's attributes from CallContext. */
|
|
68
|
+
peerStore?: PeerAttributeStore;
|
|
69
|
+
logger?: {
|
|
70
|
+
info(msg: string, ...args: unknown[]): void;
|
|
71
|
+
warn(msg: string, ...args: unknown[]): void;
|
|
72
|
+
error(msg: string, ...args: unknown[]): void;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Perform the consumer admission handshake.
|
|
77
|
+
*
|
|
78
|
+
* @param connection - The QUIC connection to the producer (admission ALPN)
|
|
79
|
+
* @param credential - The consumer enrollment credential
|
|
80
|
+
* @param iidToken - Optional cloud instance identity token
|
|
81
|
+
* @returns The admission response with services and registry namespace
|
|
82
|
+
*/
|
|
83
|
+
export declare function performAdmission(connection: {
|
|
84
|
+
openBi(): Promise<{
|
|
85
|
+
takeSend(): any;
|
|
86
|
+
takeRecv(): any;
|
|
87
|
+
}>;
|
|
88
|
+
}, credential: ConsumerEnrollmentCredential, iidToken?: string): Promise<ConsumerAdmissionResponse>;
|
|
89
|
+
/**
|
|
90
|
+
* Serialise a ConsumerEnrollmentCredential to the wire JSON format.
|
|
91
|
+
* Hex-encodes rootPubkey, nonce, and signature fields.
|
|
92
|
+
*/
|
|
93
|
+
export declare function consumerCredToJson(cred: ConsumerEnrollmentCredential): string;
|
|
94
|
+
/**
|
|
95
|
+
* Deserialise a ConsumerEnrollmentCredential from the wire JSON format.
|
|
96
|
+
* Validates hex field lengths (pubkey=64, nonce=64, signature=128 hex chars).
|
|
97
|
+
*/
|
|
98
|
+
export declare function consumerCredFromJson(json: string): ConsumerEnrollmentCredential;
|
|
99
|
+
/**
|
|
100
|
+
* Server-side handler for the aster.consumer_admission ALPN.
|
|
101
|
+
*
|
|
102
|
+
* @param requestJson - JSON-serialised ConsumerAdmissionRequest.
|
|
103
|
+
* @param rootPubkey - The server's root public key (hex string, 64 chars).
|
|
104
|
+
* @param hook - MeshEndpointHook; addPeer is called on successful admission.
|
|
105
|
+
* @param peerNodeId - QUIC peer identity from the connection handshake.
|
|
106
|
+
* @param opts - Additional options (nonceStore, services, registryNamespace, allowUnenrolled, logger).
|
|
107
|
+
* @returns ConsumerAdmissionResponse — always returned, never throws.
|
|
108
|
+
*/
|
|
109
|
+
export declare function handleConsumerAdmissionRpc(requestJson: string, rootPubkey: string, hook: MeshEndpointHook, peerNodeId: string, opts?: ConsumerAdmissionOpts): Promise<ConsumerAdmissionResponse>;
|
|
110
|
+
/**
|
|
111
|
+
* Handle one consumer admission connection: read request, write response.
|
|
112
|
+
*
|
|
113
|
+
* @param conn - A QUIC connection with acceptBi() and remoteId() methods.
|
|
114
|
+
* @param rootPubkey - Hex-encoded root public key.
|
|
115
|
+
* @param hook - MeshEndpointHook for peer admission tracking.
|
|
116
|
+
* @param opts - Additional options.
|
|
117
|
+
*/
|
|
118
|
+
export declare function handleConsumerAdmissionConnection(conn: {
|
|
119
|
+
acceptBi(): Promise<{
|
|
120
|
+
takeSend(): any;
|
|
121
|
+
takeRecv(): any;
|
|
122
|
+
}>;
|
|
123
|
+
remoteId(): string;
|
|
124
|
+
}, rootPubkey: string, hook: MeshEndpointHook, opts?: ConsumerAdmissionOpts): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Accept and process connections on aster.consumer_admission until cancelled.
|
|
127
|
+
*
|
|
128
|
+
* Runs as a background task alongside the main server. Each connection is
|
|
129
|
+
* handled concurrently so one slow consumer cannot block others.
|
|
130
|
+
*
|
|
131
|
+
* @param node - An endpoint/node bound to the consumer admission ALPN, with accept().
|
|
132
|
+
* @param rootPubkey - Hex-encoded root public key.
|
|
133
|
+
* @param hook - MeshEndpointHook allowlist manager.
|
|
134
|
+
* @param opts - Additional options.
|
|
135
|
+
*/
|
|
136
|
+
export declare function serveConsumerAdmission(node: {
|
|
137
|
+
accept(): Promise<any>;
|
|
138
|
+
}, rootPubkey: string, hook: MeshEndpointHook, opts?: ConsumerAdmissionOpts): Promise<void>;
|
|
139
|
+
//# sourceMappingURL=consumer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consumer.d.ts","sourceRoot":"","sources":["../../src/trust/consumer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAc,KAAK,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAEjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAuB,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEhF;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MA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+
*
|
|
4
|
+
* Spec reference: Aster-trust-spec.md S5
|
|
5
|
+
*
|
|
6
|
+
* Client side (performAdmission):
|
|
7
|
+
* 1. Open a stream on the admission ALPN
|
|
8
|
+
* 2. Send a ConsumerAdmissionRequest (credential + optional IID token)
|
|
9
|
+
* 3. Receive a ConsumerAdmissionResponse (services list + registry namespace)
|
|
10
|
+
*
|
|
11
|
+
* Server side (handleConsumerAdmissionRpc, serveConsumerAdmission):
|
|
12
|
+
* Verify credential, admit peer, return response with services + registry namespace.
|
|
13
|
+
*
|
|
14
|
+
* Wire format: newline-delimited JSON over a QUIC bidi-stream on
|
|
15
|
+
* aster.consumer_admission ALPN. Client sends one JSON line; server
|
|
16
|
+
* responds with one JSON line and closes the stream.
|
|
17
|
+
*/
|
|
18
|
+
import { bytesToHex } from './credentials.js';
|
|
19
|
+
import { admit } from './admission.js';
|
|
20
|
+
import { MAX_ADMISSION_PAYLOAD_SIZE, MAX_SERVICES_IN_ADMISSION, validateHexField } from '../limits.js';
|
|
21
|
+
import { createPeerAdmission } from '../peer-store.js';
|
|
22
|
+
// ── Client-side ───────────────────────────────────────────────────────────────
|
|
23
|
+
/**
|
|
24
|
+
* Perform the consumer admission handshake.
|
|
25
|
+
*
|
|
26
|
+
* @param connection - The QUIC connection to the producer (admission ALPN)
|
|
27
|
+
* @param credential - The consumer enrollment credential
|
|
28
|
+
* @param iidToken - Optional cloud instance identity token
|
|
29
|
+
* @returns The admission response with services and registry namespace
|
|
30
|
+
*/
|
|
31
|
+
export async function performAdmission(connection, credential, iidToken) {
|
|
32
|
+
const bi = await connection.openBi();
|
|
33
|
+
const send = bi.takeSend();
|
|
34
|
+
const recv = bi.takeRecv();
|
|
35
|
+
// Build and send request (snake_case keys for Python interop).
|
|
36
|
+
// The credential is serialised to its snake_case wire form via
|
|
37
|
+
// consumerCredToJson — JSON.stringify on the camelCase TS interface
|
|
38
|
+
// would produce the wrong keys and the server would reject it.
|
|
39
|
+
const wireRequest = {
|
|
40
|
+
credential_json: credential ? consumerCredToJson(credential) : '',
|
|
41
|
+
iid_token: iidToken ?? '',
|
|
42
|
+
};
|
|
43
|
+
const reqBytes = new TextEncoder().encode(JSON.stringify(wireRequest));
|
|
44
|
+
if (reqBytes.byteLength > MAX_ADMISSION_PAYLOAD_SIZE) {
|
|
45
|
+
throw new Error(`admission request too large: ${reqBytes.byteLength} > ${MAX_ADMISSION_PAYLOAD_SIZE}`);
|
|
46
|
+
}
|
|
47
|
+
// Write request + finish send side
|
|
48
|
+
await send.writeAll(reqBytes);
|
|
49
|
+
await send.finish();
|
|
50
|
+
// Read response (snake_case keys from Python wire format)
|
|
51
|
+
const respBytes = await recv.readToEnd(MAX_ADMISSION_PAYLOAD_SIZE);
|
|
52
|
+
const respText = new TextDecoder().decode(respBytes);
|
|
53
|
+
if (!respText || respText.length === 0) {
|
|
54
|
+
throw new Error('admission failed: server returned empty response (may be overloaded, retry)');
|
|
55
|
+
}
|
|
56
|
+
const d = JSON.parse(respText);
|
|
57
|
+
const response = {
|
|
58
|
+
admitted: d.admitted,
|
|
59
|
+
reason: d.reason,
|
|
60
|
+
services: d.services ?? [],
|
|
61
|
+
registryNamespace: d.registry_namespace ?? d.registryNamespace ?? '',
|
|
62
|
+
attributes: d.attributes ?? {},
|
|
63
|
+
rootPubkey: d.root_pubkey ?? d.rootPubkey ?? '',
|
|
64
|
+
gossipTopic: d.gossip_topic ?? d.gossipTopic,
|
|
65
|
+
};
|
|
66
|
+
// Validate
|
|
67
|
+
if (response.services && response.services.length > MAX_SERVICES_IN_ADMISSION) {
|
|
68
|
+
throw new Error(`admission response has ${response.services.length} services, max is ${MAX_SERVICES_IN_ADMISSION}`);
|
|
69
|
+
}
|
|
70
|
+
return response;
|
|
71
|
+
}
|
|
72
|
+
// ── Credential serialisation helpers ──────────────────────────────────────────
|
|
73
|
+
/**
|
|
74
|
+
* Serialise a ConsumerEnrollmentCredential to the wire JSON format.
|
|
75
|
+
* Hex-encodes rootPubkey, nonce, and signature fields.
|
|
76
|
+
*/
|
|
77
|
+
export function consumerCredToJson(cred) {
|
|
78
|
+
return JSON.stringify({
|
|
79
|
+
credential_type: cred.credentialType,
|
|
80
|
+
root_pubkey: cred.rootPubkey, // already hex in TS type
|
|
81
|
+
expires_at: cred.expiresAt,
|
|
82
|
+
attributes: cred.attributes,
|
|
83
|
+
endpoint_id: cred.endpointId ?? null,
|
|
84
|
+
nonce: cred.nonce ?? null,
|
|
85
|
+
signature: cred.signature,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Deserialise a ConsumerEnrollmentCredential from the wire JSON format.
|
|
90
|
+
* Validates hex field lengths (pubkey=64, nonce=64, signature=128 hex chars).
|
|
91
|
+
*/
|
|
92
|
+
export function consumerCredFromJson(json) {
|
|
93
|
+
const d = JSON.parse(json);
|
|
94
|
+
// Validate hex field lengths
|
|
95
|
+
validateHexField('root_pubkey', d.root_pubkey ?? '');
|
|
96
|
+
const nonceHex = d.nonce ?? '';
|
|
97
|
+
if (nonceHex) {
|
|
98
|
+
validateHexField('nonce', nonceHex);
|
|
99
|
+
}
|
|
100
|
+
const sigHex = d.signature ?? '';
|
|
101
|
+
if (sigHex) {
|
|
102
|
+
validateHexField('signature', sigHex);
|
|
103
|
+
}
|
|
104
|
+
const eid = d.endpoint_id ?? '';
|
|
105
|
+
if (eid) {
|
|
106
|
+
validateHexField('endpoint_id', eid);
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
credentialType: d.credential_type,
|
|
110
|
+
rootPubkey: d.root_pubkey,
|
|
111
|
+
expiresAt: Number(d.expires_at),
|
|
112
|
+
attributes: d.attributes ?? {},
|
|
113
|
+
endpointId: d.endpoint_id || undefined,
|
|
114
|
+
nonce: nonceHex || undefined,
|
|
115
|
+
signature: sigHex || '',
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
// ── Server-side handler ─────────────────────────────────────────────────────
|
|
119
|
+
/**
|
|
120
|
+
* Server-side handler for the aster.consumer_admission ALPN.
|
|
121
|
+
*
|
|
122
|
+
* @param requestJson - JSON-serialised ConsumerAdmissionRequest.
|
|
123
|
+
* @param rootPubkey - The server's root public key (hex string, 64 chars).
|
|
124
|
+
* @param hook - MeshEndpointHook; addPeer is called on successful admission.
|
|
125
|
+
* @param peerNodeId - QUIC peer identity from the connection handshake.
|
|
126
|
+
* @param opts - Additional options (nonceStore, services, registryNamespace, allowUnenrolled, logger).
|
|
127
|
+
* @returns ConsumerAdmissionResponse — always returned, never throws.
|
|
128
|
+
*/
|
|
129
|
+
export async function handleConsumerAdmissionRpc(requestJson, rootPubkey, hook, peerNodeId, opts = {}) {
|
|
130
|
+
const log = opts.logger ?? console;
|
|
131
|
+
const denied = {
|
|
132
|
+
admitted: false,
|
|
133
|
+
reason: '', // oracle protection — never leak reason on wire
|
|
134
|
+
services: [],
|
|
135
|
+
rootPubkey,
|
|
136
|
+
};
|
|
137
|
+
// Parse the outer request envelope
|
|
138
|
+
let req;
|
|
139
|
+
try {
|
|
140
|
+
const parsed = JSON.parse(requestJson);
|
|
141
|
+
req = {
|
|
142
|
+
credentialJson: parsed.credentialJson ?? parsed.credential_json ?? '',
|
|
143
|
+
iidToken: parsed.iidToken ?? parsed.iid_token ?? '',
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
log.warn(`consumer admission: malformed request from ${peerNodeId}: ${err}`);
|
|
148
|
+
return denied;
|
|
149
|
+
}
|
|
150
|
+
// Include gossip topic only when the connecting peer IS the root node
|
|
151
|
+
// (its endpoint_id == root_pubkey hex). This lets the operator's shell
|
|
152
|
+
// observe the producer mesh without exposing the topic to other consumers.
|
|
153
|
+
let topicForPeer = '';
|
|
154
|
+
if (opts.gossipTopicId && peerNodeId === rootPubkey) {
|
|
155
|
+
topicForPeer = bytesToHex(opts.gossipTopicId);
|
|
156
|
+
log.info('consumer admission: root node detected — including gossip topic');
|
|
157
|
+
}
|
|
158
|
+
// Dev mode / open gate: empty credential -> auto-admit
|
|
159
|
+
const isEmptyCredential = !req.credentialJson || req.credentialJson === '{}' || req.credentialJson === 'null';
|
|
160
|
+
if (isEmptyCredential && opts.allowUnenrolled) {
|
|
161
|
+
hook.addPeer(peerNodeId);
|
|
162
|
+
if (opts.peerStore) {
|
|
163
|
+
opts.peerStore.admit(createPeerAdmission({
|
|
164
|
+
endpointId: peerNodeId,
|
|
165
|
+
attributes: new Map(),
|
|
166
|
+
admissionPath: 'aster.consumer_admission',
|
|
167
|
+
}));
|
|
168
|
+
}
|
|
169
|
+
const role = topicForPeer ? 'root' : 'open gate';
|
|
170
|
+
log.info(`consumer admission: auto-admitted ${peerNodeId} (${role})`);
|
|
171
|
+
return {
|
|
172
|
+
admitted: true,
|
|
173
|
+
attributes: {},
|
|
174
|
+
services: opts.services ?? [],
|
|
175
|
+
registryNamespace: opts.registryNamespace ?? '',
|
|
176
|
+
rootPubkey,
|
|
177
|
+
gossipTopic: topicForPeer || undefined,
|
|
178
|
+
reason: '',
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
// Parse the inner credential
|
|
182
|
+
let cred;
|
|
183
|
+
try {
|
|
184
|
+
cred = consumerCredFromJson(req.credentialJson);
|
|
185
|
+
}
|
|
186
|
+
catch (err) {
|
|
187
|
+
log.warn(`consumer admission: malformed credential from ${peerNodeId}: ${err}`);
|
|
188
|
+
return denied;
|
|
189
|
+
}
|
|
190
|
+
// Trust anchor check: credential's rootPubkey must match server's
|
|
191
|
+
if (!cred.rootPubkey || cred.rootPubkey !== rootPubkey) {
|
|
192
|
+
log.warn(`consumer admission: untrusted root key from ${peerNodeId} ` +
|
|
193
|
+
`(got ${(cred.rootPubkey ?? '(none)').slice(0, 12)}, expected ${rootPubkey.slice(0, 12)})`);
|
|
194
|
+
return denied;
|
|
195
|
+
}
|
|
196
|
+
// Run admission checks (offline + runtime)
|
|
197
|
+
const result = await admit(cred, peerNodeId, {
|
|
198
|
+
nonceStore: opts.nonceStore,
|
|
199
|
+
iidToken: req.iidToken || undefined,
|
|
200
|
+
});
|
|
201
|
+
if (!result.admitted) {
|
|
202
|
+
log.info(`consumer admission: denied ${peerNodeId}`);
|
|
203
|
+
return denied;
|
|
204
|
+
}
|
|
205
|
+
hook.addPeer(peerNodeId);
|
|
206
|
+
if (opts.peerStore) {
|
|
207
|
+
const attrMap = new Map();
|
|
208
|
+
for (const [k, v] of Object.entries(result.attributes ?? {})) {
|
|
209
|
+
attrMap.set(k, String(v));
|
|
210
|
+
}
|
|
211
|
+
opts.peerStore.admit(createPeerAdmission({
|
|
212
|
+
endpointId: peerNodeId,
|
|
213
|
+
attributes: attrMap,
|
|
214
|
+
expiresAt: cred.expiresAt ?? 0,
|
|
215
|
+
admissionPath: 'aster.consumer_admission',
|
|
216
|
+
}));
|
|
217
|
+
}
|
|
218
|
+
log.info(`consumer admission: admitted ${peerNodeId}`);
|
|
219
|
+
return {
|
|
220
|
+
admitted: true,
|
|
221
|
+
attributes: result.attributes ?? {},
|
|
222
|
+
services: opts.services ?? [],
|
|
223
|
+
registryNamespace: opts.registryNamespace ?? '',
|
|
224
|
+
rootPubkey,
|
|
225
|
+
gossipTopic: topicForPeer || undefined,
|
|
226
|
+
reason: '',
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
// ── Per-connection handler ──────────────────────────────────────────────────
|
|
230
|
+
/**
|
|
231
|
+
* Handle one consumer admission connection: read request, write response.
|
|
232
|
+
*
|
|
233
|
+
* @param conn - A QUIC connection with acceptBi() and remoteId() methods.
|
|
234
|
+
* @param rootPubkey - Hex-encoded root public key.
|
|
235
|
+
* @param hook - MeshEndpointHook for peer admission tracking.
|
|
236
|
+
* @param opts - Additional options.
|
|
237
|
+
*/
|
|
238
|
+
export async function handleConsumerAdmissionConnection(conn, rootPubkey, hook, opts = {}) {
|
|
239
|
+
const peerNodeId = conn.remoteId();
|
|
240
|
+
const log = opts.logger ?? console;
|
|
241
|
+
try {
|
|
242
|
+
const bi = await conn.acceptBi();
|
|
243
|
+
const send = bi.takeSend();
|
|
244
|
+
const recv = bi.takeRecv();
|
|
245
|
+
const raw = await recv.readToEnd(MAX_ADMISSION_PAYLOAD_SIZE);
|
|
246
|
+
if (!raw || raw.length === 0) {
|
|
247
|
+
log.warn(`consumer admission: empty request from ${peerNodeId}`);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const requestJson = new TextDecoder().decode(raw);
|
|
251
|
+
const response = await handleConsumerAdmissionRpc(requestJson, rootPubkey, hook, peerNodeId, opts);
|
|
252
|
+
// Serialise response — snake_case keys for Python interop.
|
|
253
|
+
// Strip reason on wire (oracle protection).
|
|
254
|
+
// Convert ServiceSummary to snake_case for wire compat
|
|
255
|
+
const wireServices = (response.services ?? []).map((s) => ({
|
|
256
|
+
name: s.name,
|
|
257
|
+
version: s.version,
|
|
258
|
+
contract_id: s.contractId ?? s.contract_id ?? '',
|
|
259
|
+
pattern: s.pattern,
|
|
260
|
+
methods: s.methods,
|
|
261
|
+
channels: s.channels ?? {},
|
|
262
|
+
serialization_modes: s.serializationModes ?? s.serialization_modes ?? [],
|
|
263
|
+
}));
|
|
264
|
+
const wireResponse = {
|
|
265
|
+
admitted: response.admitted,
|
|
266
|
+
attributes: response.attributes ?? {},
|
|
267
|
+
services: wireServices,
|
|
268
|
+
registry_namespace: response.registryNamespace ?? '',
|
|
269
|
+
root_pubkey: response.rootPubkey ?? '',
|
|
270
|
+
reason: '', // never leak reason on wire
|
|
271
|
+
};
|
|
272
|
+
if (response.gossipTopic) {
|
|
273
|
+
wireResponse.gossip_topic = response.gossipTopic;
|
|
274
|
+
}
|
|
275
|
+
const responseBytes = new TextEncoder().encode(JSON.stringify(wireResponse));
|
|
276
|
+
try {
|
|
277
|
+
await send.writeAll(responseBytes);
|
|
278
|
+
await send.finish();
|
|
279
|
+
}
|
|
280
|
+
catch (writeErr) {
|
|
281
|
+
log.warn(`consumer admission: failed to send response to ${peerNodeId}: ${writeErr}`);
|
|
282
|
+
// Stream write failed — client will see an empty/closed stream.
|
|
283
|
+
// Nothing more we can do; the connection may already be gone.
|
|
284
|
+
}
|
|
285
|
+
// Don't conn.close() — let QUIC drain the streams naturally.
|
|
286
|
+
// Calling close() sends CONNECTION_CLOSE which kills in-flight
|
|
287
|
+
// data before the consumer can readToEnd().
|
|
288
|
+
}
|
|
289
|
+
catch (err) {
|
|
290
|
+
log.warn(`consumer admission: error handling ${peerNodeId}: ${err}`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
// ── Accept loop ─────────────────────────────────────────────────────────────
|
|
294
|
+
/**
|
|
295
|
+
* Accept and process connections on aster.consumer_admission until cancelled.
|
|
296
|
+
*
|
|
297
|
+
* Runs as a background task alongside the main server. Each connection is
|
|
298
|
+
* handled concurrently so one slow consumer cannot block others.
|
|
299
|
+
*
|
|
300
|
+
* @param node - An endpoint/node bound to the consumer admission ALPN, with accept().
|
|
301
|
+
* @param rootPubkey - Hex-encoded root public key.
|
|
302
|
+
* @param hook - MeshEndpointHook allowlist manager.
|
|
303
|
+
* @param opts - Additional options.
|
|
304
|
+
*/
|
|
305
|
+
export async function serveConsumerAdmission(node, rootPubkey, hook, opts = {}) {
|
|
306
|
+
const log = opts.logger ?? console;
|
|
307
|
+
try {
|
|
308
|
+
while (true) {
|
|
309
|
+
const conn = await node.accept();
|
|
310
|
+
// Fire-and-forget: handle each connection concurrently
|
|
311
|
+
handleConsumerAdmissionConnection(conn, rootPubkey, hook, opts).catch((err) => {
|
|
312
|
+
log.warn(`consumer admission: connection handler error: ${err}`);
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
catch (err) {
|
|
317
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
318
|
+
if (msg.includes('abort') || msg.includes('cancel'))
|
|
319
|
+
return;
|
|
320
|
+
log.error(`serveConsumerAdmission: unexpected error: ${msg}`);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
//# sourceMappingURL=consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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AAC,IAAI,CAAC,sCAAsC,UAAU,KAAK,GAAG,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC;AAED,+EAA+E;AAE/E;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,IAAgC,EAChC,UAAkB,EAClB,IAAsB,EACtB,OAA8B,EAAE;IAEhC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC;IACnC,IAAI,CAAC;QACH,OAAO,IAAI,EAAE,CAAC;YACZ,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;YACjC,uDAAuD;YACvD,iCAAiC,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC5E,GAAG,CAAC,IAAI,CAAC,iDAAiD,GAAG,EAAE,CAAC,CAAC;YACnE,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7D,IAAI,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAAE,OAAO;QAC5D,GAAG,CAAC,KAAK,CAAC,6CAA6C,GAAG,EAAE,CAAC,CAAC;IAChE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential types and ed25519 signing/verification.
|
|
3
|
+
*
|
|
4
|
+
* Spec reference: Aster-trust-spec.md
|
|
5
|
+
*
|
|
6
|
+
* Signing bytes computation delegates to Rust core via NAPI.
|
|
7
|
+
* Ed25519 operations use @noble/ed25519 for portability.
|
|
8
|
+
*/
|
|
9
|
+
/** Producer enrollment credential. */
|
|
10
|
+
export interface EnrollmentCredential {
|
|
11
|
+
endpointId: string;
|
|
12
|
+
rootPubkey: string;
|
|
13
|
+
expiresAt: number;
|
|
14
|
+
attributes: Record<string, string>;
|
|
15
|
+
signature: string;
|
|
16
|
+
}
|
|
17
|
+
/** Consumer enrollment credential. */
|
|
18
|
+
export interface ConsumerEnrollmentCredential {
|
|
19
|
+
credentialType: 'policy' | 'ott';
|
|
20
|
+
rootPubkey: string;
|
|
21
|
+
expiresAt: number;
|
|
22
|
+
attributes: Record<string, string>;
|
|
23
|
+
endpointId?: string;
|
|
24
|
+
nonce?: string;
|
|
25
|
+
signature: string;
|
|
26
|
+
}
|
|
27
|
+
/** Reserved attribute keys. */
|
|
28
|
+
export declare const ATTR_ROLE = "aster.role";
|
|
29
|
+
export declare const ATTR_NAME = "aster.name";
|
|
30
|
+
export declare const ATTR_IID_PROVIDER = "aster.iid_provider";
|
|
31
|
+
export declare const ATTR_IID_ACCOUNT = "aster.iid_account";
|
|
32
|
+
export declare const ATTR_IID_REGION = "aster.iid_region";
|
|
33
|
+
export declare const ATTR_IID_ROLE_ARN = "aster.iid_role_arn";
|
|
34
|
+
/**
|
|
35
|
+
* Generate an ed25519 keypair.
|
|
36
|
+
* Returns [privateKey (32 bytes), publicKey (32 bytes)].
|
|
37
|
+
*
|
|
38
|
+
* Requires @noble/ed25519:
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { utils } from '@noble/ed25519';
|
|
41
|
+
* const privKey = utils.randomPrivateKey();
|
|
42
|
+
* const pubKey = await getPublicKeyAsync(privKey);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function generateKeypair(): Promise<[Uint8Array, Uint8Array]>;
|
|
46
|
+
/**
|
|
47
|
+
* Sign a message with an ed25519 private key.
|
|
48
|
+
* Returns 64-byte signature.
|
|
49
|
+
*/
|
|
50
|
+
export declare function sign(privateKey: Uint8Array, message: Uint8Array): Promise<Uint8Array>;
|
|
51
|
+
/**
|
|
52
|
+
* Verify an ed25519 signature.
|
|
53
|
+
*/
|
|
54
|
+
export declare function verify(publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array): Promise<boolean>;
|
|
55
|
+
declare function hexToBytes(hex: string): Uint8Array;
|
|
56
|
+
declare function bytesToHex(bytes: Uint8Array): string;
|
|
57
|
+
/** Canonical JSON: UTF-8, sorted keys, no extra whitespace. */
|
|
58
|
+
export declare function canonicalJson(attributes: Record<string, string>): Uint8Array;
|
|
59
|
+
/** Signing bytes for EnrollmentCredential (producer). */
|
|
60
|
+
export declare function producerSigningBytes(cred: EnrollmentCredential): Uint8Array;
|
|
61
|
+
/** Signing bytes for ConsumerEnrollmentCredential. */
|
|
62
|
+
export declare function consumerSigningBytes(cred: ConsumerEnrollmentCredential): Uint8Array;
|
|
63
|
+
/** Compute signing bytes for any credential type. */
|
|
64
|
+
export declare function credentialSigningBytes(cred: EnrollmentCredential | ConsumerEnrollmentCredential): Uint8Array;
|
|
65
|
+
/**
|
|
66
|
+
* Sign a credential with the root private key.
|
|
67
|
+
* Returns 64-byte signature as hex string.
|
|
68
|
+
*/
|
|
69
|
+
export declare function signCredential(cred: EnrollmentCredential | ConsumerEnrollmentCredential, rootPrivkeyRaw: Uint8Array): Promise<string>;
|
|
70
|
+
/**
|
|
71
|
+
* Verify a credential's signature.
|
|
72
|
+
* If rootPubkeyHex is provided, it overrides cred.rootPubkey.
|
|
73
|
+
* Returns true on success, false on any failure.
|
|
74
|
+
*/
|
|
75
|
+
export declare function verifyCredentialSignature(cred: EnrollmentCredential | ConsumerEnrollmentCredential, rootPubkeyHex?: string): Promise<boolean>;
|
|
76
|
+
declare function concatBytes(arrays: Uint8Array[]): Uint8Array;
|
|
77
|
+
/**
|
|
78
|
+
* Generate a root keypair (alias for generateKeypair).
|
|
79
|
+
* Returns [privateKey, publicKey] as raw 32-byte arrays.
|
|
80
|
+
*/
|
|
81
|
+
export declare function generateRootKeypair(): Promise<[Uint8Array, Uint8Array]>;
|
|
82
|
+
/**
|
|
83
|
+
* Load a raw 32-byte private key.
|
|
84
|
+
* Returns the key as-is (validates length).
|
|
85
|
+
*/
|
|
86
|
+
export declare function loadPrivateKey(privRaw: Uint8Array): Uint8Array;
|
|
87
|
+
/**
|
|
88
|
+
* Load a raw 32-byte public key.
|
|
89
|
+
* Returns the key as-is (validates length).
|
|
90
|
+
*/
|
|
91
|
+
export declare function loadPublicKey(pubRaw: Uint8Array): Uint8Array;
|
|
92
|
+
/**
|
|
93
|
+
* Verify an ed25519 signature.
|
|
94
|
+
* Alias for the low-level `verify()` with a consistent signature.
|
|
95
|
+
*/
|
|
96
|
+
export declare function verifySignature(publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array): Promise<boolean>;
|
|
97
|
+
export { hexToBytes, bytesToHex, concatBytes };
|
|
98
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/trust/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,sCAAsC;AACtC,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,sCAAsC;AACtC,MAAM,WAAW,4BAA4B;IAC3C,cAAc,EAAE,QAAQ,GAAG,KAAK,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,+BAA+B;AAC/B,eAAO,MAAM,SAAS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