@newtype-ai/nit 0.2.5 → 0.3.0

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/README.md CHANGED
@@ -132,7 +132,7 @@ your-project/
132
132
  ## Programmatic API
133
133
 
134
134
  ```typescript
135
- import { init, commit, checkout, branch, push, status, sign, loginPayload } from '@newtype-ai/nit';
135
+ import { init, commit, checkout, branch, push, status, sign, loginPayload, loadRawKeyPair } from '@newtype-ai/nit';
136
136
 
137
137
  await init();
138
138
 
@@ -143,6 +143,10 @@ const payload = await loginPayload('faam.io');
143
143
  // Customize card, then commit & push
144
144
  await commit('FAAM config');
145
145
  await push({ all: true });
146
+
147
+ // Access raw Ed25519 keypair (64 bytes: [seed || pubkey])
148
+ const keypair = await loadRawKeyPair('/path/to/.nit');
149
+ // → Uint8Array(64) — compatible with Solana and other Ed25519 libraries
146
150
  ```
147
151
 
148
152
  ## Design Principles
@@ -232,6 +232,24 @@ async function loadPrivateKey(nitDir) {
232
232
  format: "jwk"
233
233
  });
234
234
  }
235
+ async function loadRawKeyPair(nitDir) {
236
+ const pubBase64 = await loadPublicKey(nitDir);
237
+ const keyPath = join3(nitDir, "identity", "agent.key");
238
+ let privBase64;
239
+ try {
240
+ privBase64 = (await fs3.readFile(keyPath, "utf-8")).trim();
241
+ } catch {
242
+ throw new Error(
243
+ "Private key not found at .nit/identity/agent.key. Regenerate with `nit init`."
244
+ );
245
+ }
246
+ const seed = Buffer.from(privBase64, "base64");
247
+ const pubkey = Buffer.from(pubBase64, "base64");
248
+ const keypair = new Uint8Array(64);
249
+ keypair.set(seed, 0);
250
+ keypair.set(pubkey, 32);
251
+ return keypair;
252
+ }
235
253
  function formatPublicKeyField(pubBase64) {
236
254
  return `ed25519:${pubBase64}`;
237
255
  }
@@ -249,19 +267,6 @@ async function signChallenge(nitDir, challenge) {
249
267
  const sig = sign(null, Buffer.from(challenge, "utf-8"), privateKey);
250
268
  return sig.toString("base64");
251
269
  }
252
- function verifySignature(pubBase64, challenge, signatureBase64) {
253
- const xB64url = base64ToBase64url(pubBase64);
254
- const publicKeyObj = createPublicKey({
255
- key: { kty: "OKP", crv: "Ed25519", x: xB64url },
256
- format: "jwk"
257
- });
258
- return verify(
259
- null,
260
- Buffer.from(challenge, "utf-8"),
261
- publicKeyObj,
262
- Buffer.from(signatureBase64, "base64")
263
- );
264
- }
265
270
  async function signMessage(nitDir, message) {
266
271
  const privateKey = await loadPrivateKey(nitDir);
267
272
  const sig = sign(null, Buffer.from(message, "utf-8"), privateKey);
@@ -1150,10 +1155,10 @@ async function remoteSetUrl(name, url, options) {
1150
1155
  }
1151
1156
 
1152
1157
  export {
1158
+ loadRawKeyPair,
1153
1159
  formatPublicKeyField,
1154
1160
  parsePublicKeyField,
1155
1161
  signChallenge,
1156
- verifySignature,
1157
1162
  signMessage,
1158
1163
  NIT_NAMESPACE,
1159
1164
  deriveAgentId,
package/dist/cli.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  remoteSetUrl,
16
16
  sign,
17
17
  status
18
- } from "./chunk-U6PEH4IJ.js";
18
+ } from "./chunk-CJUMX46F.js";
19
19
 
20
20
  // src/cli.ts
21
21
  var bold = (s) => `\x1B[1m${s}\x1B[0m`;
package/dist/index.d.ts CHANGED
@@ -135,6 +135,12 @@ declare function diffCards(oldCard: AgentCard, newCard: AgentCard): DiffResult;
135
135
  */
136
136
  declare function formatDiff(diff: DiffResult): string;
137
137
 
138
+ /**
139
+ * Load the Ed25519 keypair as raw bytes (64-byte Uint8Array).
140
+ * Format: [32-byte seed || 32-byte public key]
141
+ * Compatible with Solana keypair format and other Ed25519 libraries.
142
+ */
143
+ declare function loadRawKeyPair(nitDir: string): Promise<Uint8Array>;
138
144
  /**
139
145
  * Format a raw base64 public key as the value for the agent card's
140
146
  * `publicKey` field: "ed25519:<base64>".
@@ -149,12 +155,6 @@ declare function parsePublicKeyField(field: string): string;
149
155
  * Returns a standard base64-encoded signature.
150
156
  */
151
157
  declare function signChallenge(nitDir: string, challenge: string): Promise<string>;
152
- /**
153
- * Verify a signature against a challenge using the raw base64 public key.
154
- * This is a utility for consumers; nit itself uses it in the remote module
155
- * for challenge-response flows.
156
- */
157
- declare function verifySignature(pubBase64: string, challenge: string, signatureBase64: string): boolean;
158
158
  /**
159
159
  * Sign an arbitrary message with the agent's private key.
160
160
  * Returns a standard base64-encoded signature.
@@ -311,4 +311,4 @@ declare function remoteSetUrl(name: string, url: string, options?: {
311
311
  projectDir?: string;
312
312
  }): Promise<void>;
313
313
 
314
- export { type AgentCard, type AgentCardSkill, type DiffResult, type FieldDiff, type InitResult, type LoginPayload, NIT_NAMESPACE, type NitBranch, type NitCommit, type NitConfig, type NitHead, type NitRemoteConfig, type PushResult, type RemoteInfo, type SkillMetadata, type StatusResult, branch, checkout, commit, deriveAgentId, diff, diffCards, fetchBranchCard, findNitDir, formatDiff, formatPublicKeyField, init, loadAgentId, log, loginPayload, parsePublicKeyField, push, remote, remoteAdd, remoteSetUrl, sign, signChallenge, signMessage, status, verifySignature };
314
+ export { type AgentCard, type AgentCardSkill, type DiffResult, type FieldDiff, type InitResult, type LoginPayload, NIT_NAMESPACE, type NitBranch, type NitCommit, type NitConfig, type NitHead, type NitRemoteConfig, type PushResult, type RemoteInfo, type SkillMetadata, type StatusResult, branch, checkout, commit, deriveAgentId, diff, diffCards, fetchBranchCard, findNitDir, formatDiff, formatPublicKeyField, init, loadAgentId, loadRawKeyPair, log, loginPayload, parsePublicKeyField, push, remote, remoteAdd, remoteSetUrl, sign, signChallenge, signMessage, status };
package/dist/index.js CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  formatPublicKeyField,
14
14
  init,
15
15
  loadAgentId,
16
+ loadRawKeyPair,
16
17
  log,
17
18
  loginPayload,
18
19
  parsePublicKeyField,
@@ -23,9 +24,8 @@ import {
23
24
  sign,
24
25
  signChallenge,
25
26
  signMessage,
26
- status,
27
- verifySignature
28
- } from "./chunk-U6PEH4IJ.js";
27
+ status
28
+ } from "./chunk-CJUMX46F.js";
29
29
  export {
30
30
  NIT_NAMESPACE,
31
31
  branch,
@@ -40,6 +40,7 @@ export {
40
40
  formatPublicKeyField,
41
41
  init,
42
42
  loadAgentId,
43
+ loadRawKeyPair,
43
44
  log,
44
45
  loginPayload,
45
46
  parsePublicKeyField,
@@ -50,6 +51,5 @@ export {
50
51
  sign,
51
52
  signChallenge,
52
53
  signMessage,
53
- status,
54
- verifySignature
54
+ status
55
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newtype-ai/nit",
3
- "version": "0.2.5",
3
+ "version": "0.3.0",
4
4
  "description": "Version control for agent cards",
5
5
  "type": "module",
6
6
  "bin": {