Skip to content

Commit 85f49e4

Browse files
committed
chore(jacsnpm): track index.js and index.d.ts in git
Remove from .gitignore for consistency with other JS files (simple.js, mcp.js, http.js) that are already tracked.
1 parent 90803ca commit 85f49e4

File tree

3 files changed

+521
-2
lines changed

3 files changed

+521
-2
lines changed

jacsnpm/.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
node_modules
2-
index.d.ts
3-
index.js
42
*.node

jacsnpm/index.d.ts

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
4+
/* auto-generated by NAPI-RS */
5+
6+
/** Hash a string using SHA-256. */
7+
export declare function hashString(data: string): string
8+
/** Create a JACS configuration object. */
9+
export declare function createConfig(jacsUseSecurity?: string | undefined | null, jacsDataDirectory?: string | undefined | null, jacsKeyDirectory?: string | undefined | null, jacsAgentPrivateKeyFilename?: string | undefined | null, jacsAgentPublicKeyFilename?: string | undefined | null, jacsAgentKeyAlgorithm?: string | undefined | null, jacsPrivateKeyPassword?: string | undefined | null, jacsAgentIdAndVersion?: string | undefined | null, jacsDefaultStorage?: string | undefined | null): string
10+
/** Create a JACS agent programmatically (non-interactive). */
11+
export declare function createAgent(name: string, password: string, algorithm?: string | undefined | null, dataDirectory?: string | undefined | null, keyDirectory?: string | undefined | null, configPath?: string | undefined | null, agentType?: string | undefined | null, description?: string | undefined | null, domain?: string | undefined | null, defaultStorage?: string | undefined | null): string
12+
/** Add an agent to the local trust store. */
13+
export declare function trustAgent(agentJson: string): string
14+
/** List all trusted agent IDs. */
15+
export declare function listTrustedAgents(): Array<string>
16+
/** Remove an agent from the trust store. */
17+
export declare function untrustAgent(agentId: string): void
18+
/** Check if an agent is in the trust store. */
19+
export declare function isTrusted(agentId: string): boolean
20+
/** Get a trusted agent's JSON document. */
21+
export declare function getTrustedAgent(agentId: string): string
22+
/**
23+
* Run a read-only security audit and health checks.
24+
* Returns the audit result as a JSON string (risks, health_checks, summary).
25+
*/
26+
export declare function audit(configPath?: string | undefined | null, recentN?: number | undefined | null): string
27+
/** @deprecated Use `new JacsAgent()` and `agent.load()` instead. */
28+
export declare function load(configPath: string): string
29+
/** @deprecated Use `new JacsAgent()` and instance methods instead. */
30+
export declare function signAgent(agentString: string, publicKey: Buffer, publicKeyEncType: string): string
31+
/** @deprecated Use `new JacsAgent()` and instance methods instead. */
32+
export declare function verifyString(data: string, signatureBase64: string, publicKey: Buffer, publicKeyEncType: string): boolean
33+
/** @deprecated Use `new JacsAgent()` and instance methods instead. */
34+
export declare function signString(data: string): string
35+
/** @deprecated Use `new JacsAgent()` and instance methods instead. */
36+
export declare function verifyAgent(agentfile?: string | undefined | null): boolean
37+
/** @deprecated Use `new JacsAgent()` and instance methods instead. */
38+
export declare function updateAgent(newAgentString: string): string
39+
/** Result of verify_document_standalone. Exposed to JS as { valid, signerId }. */
40+
export interface VerifyStandaloneResult {
41+
valid: boolean
42+
/** Signer agent ID; exposed to JS as signerId (camelCase). */
43+
signerId: string
44+
}
45+
/**
46+
* Verify a signed JACS document without loading an agent.
47+
* Returns { valid, signerId }. Does not use global agent state.
48+
*/
49+
export declare function verifyDocumentStandalone(signedDocument: string, keyResolution?: string | undefined | null, dataDirectory?: string | undefined | null, keyDirectory?: string | undefined | null): VerifyStandaloneResult
50+
/** @deprecated Use `new JacsAgent()` and instance methods instead. */
51+
export declare function verifyDocument(documentString: string): boolean
52+
/** @deprecated Use `new JacsAgent()` and instance methods instead. */
53+
export declare function updateDocument(documentKey: string, newDocumentString: string, attachments?: Array<string> | undefined | null, embed?: boolean | undefined | null): string
54+
/** @deprecated Use `new JacsAgent()` and instance methods instead. */
55+
export declare function verifySignature(documentString: string, signatureField?: string | undefined | null): boolean
56+
/** @deprecated Use `new JacsAgent()` and instance methods instead. */
57+
export declare function createAgreement(documentString: string, agentids: Array<string>, question?: string | undefined | null, context?: string | undefined | null, agreementFieldname?: string | undefined | null): string
58+
/** @deprecated Use `new JacsAgent()` and instance methods instead. */
59+
export declare function signAgreement(documentString: string, agreementFieldname?: string | undefined | null): string
60+
/** @deprecated Use `new JacsAgent()` and instance methods instead. */
61+
export declare function createDocument(documentString: string, customSchema?: string | undefined | null, outputfilename?: string | undefined | null, noSave?: boolean | undefined | null, attachments?: string | undefined | null, embed?: boolean | undefined | null): string
62+
/** @deprecated Use `new JacsAgent()` and instance methods instead. */
63+
export declare function checkAgreement(documentString: string, agreementFieldname?: string | undefined | null): string
64+
/** @deprecated Use `new JacsAgent()` and instance methods instead. */
65+
export declare function signRequest(params: any): string
66+
/** @deprecated Use `new JacsAgent()` and instance methods instead. */
67+
export declare function verifyResponse(documentString: string): object
68+
/** @deprecated Use `new JacsAgent()` and instance methods instead. */
69+
export declare function verifyResponseWithAgentId(documentString: string): object
70+
/**
71+
* Information about a public key fetched from HAI key service.
72+
*
73+
* This struct contains the public key data and metadata returned by
74+
* the HAI key distribution service.
75+
*/
76+
export interface RemotePublicKeyInfo {
77+
/** The raw public key bytes (DER encoded). */
78+
publicKey: Buffer
79+
/** The cryptographic algorithm (e.g., "ed25519", "rsa-pss-sha256"). */
80+
algorithm: string
81+
/** The hash of the public key (SHA-256). */
82+
publicKeyHash: string
83+
/** The agent ID the key belongs to. */
84+
agentId: string
85+
/** The version of the key. */
86+
version: string
87+
}
88+
/**
89+
* Fetch a public key from HAI's key distribution service.
90+
*
91+
* This function retrieves the public key for a specific agent and version
92+
* from the HAI key distribution service. It is used to obtain trusted public
93+
* keys for verifying agent signatures without requiring local key storage.
94+
*
95+
* # Arguments
96+
*
97+
* * `agent_id` - The unique identifier of the agent whose key to fetch.
98+
* * `version` - The version of the agent's key to fetch. Use "latest" for
99+
* the most recent version. If not provided, defaults to "latest".
100+
*
101+
* # Returns
102+
*
103+
* Returns a `RemotePublicKeyInfo` object containing the public key, algorithm, and hash.
104+
*
105+
* # Environment Variables
106+
*
107+
* * `HAI_KEYS_BASE_URL` - Base URL for the key service. Defaults to `https://keys.hai.ai`.
108+
*
109+
* # Example
110+
*
111+
* ```javascript
112+
* const { fetchRemoteKey } = require('@hai-ai/jacs');
113+
*
114+
* const keyInfo = fetchRemoteKey('550e8400-e29b-41d4-a716-446655440000', 'latest');
115+
* console.log('Algorithm:', keyInfo.algorithm);
116+
* console.log('Hash:', keyInfo.publicKeyHash);
117+
* ```
118+
*/
119+
export declare function fetchRemoteKey(agentId: string, version?: string | undefined | null): RemotePublicKeyInfo
120+
/**
121+
* Build a verification URL for a signed JACS document.
122+
*
123+
* Encodes `document` as URL-safe base64 (no padding) and returns a full URL
124+
* like `https://hai.ai/jacs/verify?s=...`. Throws if the URL would exceed 2048 chars.
125+
*/
126+
export declare function generateVerifyLink(document: string, baseUrl: string): string
127+
/**
128+
* JacsAgent is a handle to a JACS agent instance.
129+
* Each instance maintains its own state and can be used independently.
130+
* This allows multiple agents to be used concurrently in the same process.
131+
*/
132+
export declare class JacsAgent {
133+
/**
134+
* Create a new empty JacsAgent instance.
135+
* Call `load()` to initialize it with a configuration.
136+
*/
137+
constructor()
138+
/** Load an agent from a configuration file. */
139+
load(configPath: string): string
140+
/** Sign an external agent's document with this agent's registration signature. */
141+
signAgent(agentString: string, publicKey: Buffer, publicKeyEncType: string): string
142+
/** Verify a signature on arbitrary string data. */
143+
verifyString(data: string, signatureBase64: string, publicKey: Buffer, publicKeyEncType: string): boolean
144+
/** Sign arbitrary string data with this agent's private key. */
145+
signString(data: string): string
146+
/** Verify this agent's signature and hash. */
147+
verifyAgent(agentfile?: string | undefined | null): boolean
148+
/** Update the agent document with new data. */
149+
updateAgent(newAgentString: string): string
150+
/** Verify a document's signature and hash. */
151+
verifyDocument(documentString: string): boolean
152+
/** Update an existing document. */
153+
updateDocument(documentKey: string, newDocumentString: string, attachments?: Array<string> | undefined | null, embed?: boolean | undefined | null): string
154+
/** Verify a document's signature with an optional custom signature field. */
155+
verifySignature(documentString: string, signatureField?: string | undefined | null): boolean
156+
/** Create an agreement on a document. */
157+
createAgreement(documentString: string, agentids: Array<string>, question?: string | undefined | null, context?: string | undefined | null, agreementFieldname?: string | undefined | null): string
158+
/** Sign an agreement on a document. */
159+
signAgreement(documentString: string, agreementFieldname?: string | undefined | null): string
160+
/** Create a new JACS document. */
161+
createDocument(documentString: string, customSchema?: string | undefined | null, outputfilename?: string | undefined | null, noSave?: boolean | undefined | null, attachments?: string | undefined | null, embed?: boolean | undefined | null): string
162+
/** Check an agreement on a document. */
163+
checkAgreement(documentString: string, agreementFieldname?: string | undefined | null): string
164+
/**
165+
* Verify a document looked up by ID from storage.
166+
*
167+
* The document_id should be in "uuid:version" format.
168+
*/
169+
verifyDocumentById(documentId: string): boolean
170+
/** Re-encrypt the agent's private key with a new password. */
171+
reencryptKey(oldPassword: string, newPassword: string): void
172+
/** Sign a request payload (wraps in a JACS document). */
173+
signRequest(params: any): string
174+
/** Verify a response payload. */
175+
verifyResponse(documentString: string): object
176+
/** Verify a response payload and return the agent ID. */
177+
verifyResponseWithAgentId(documentString: string): object
178+
}

0 commit comments

Comments
 (0)