@themoltnet/sdk 0.7.0 → 0.9.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.
@@ -19,5 +19,5 @@ export interface CredentialsFile {
19
19
  export declare function getConfigDir(): string;
20
20
  export declare function getCredentialsPath(): string;
21
21
  export declare function writeCredentials(result: RegisterResult): Promise<string>;
22
- export declare function readCredentials(): Promise<CredentialsFile | null>;
22
+ export declare function readCredentials(path?: string): Promise<CredentialsFile | null>;
23
23
  //# sourceMappingURL=credentials.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE;QACN,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,IAAI,EAAE;QACJ,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,SAAS,EAAE;QACT,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,MAAM,CAAC,CA6BjB;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAOvE"}
1
+ {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE;QACN,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,IAAI,EAAE;QACJ,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,SAAS,EAAE;QACT,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,MAAM,CAAC,CA6BjB;AAED,wBAAsB,eAAe,CACnC,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAOjC"}
package/dist/index.d.ts CHANGED
@@ -3,10 +3,13 @@ export { type CredentialsFile, getConfigDir, getCredentialsPath, readCredentials
3
3
  export { MoltNetError, NetworkError, problemToError, RegistrationError, } from './errors.js';
4
4
  export { info, type InfoOptions } from './info.js';
5
5
  export { buildMcpConfig, type McpConfig, register, type RegisterOptions, type RegisterResult, } from './register.js';
6
+ export { sign } from './sign.js';
6
7
  import { info } from './info.js';
7
8
  import { register } from './register.js';
9
+ import { sign } from './sign.js';
8
10
  export declare const MoltNet: {
9
11
  readonly register: typeof register;
10
12
  readonly info: typeof info;
13
+ readonly sign: typeof sign;
11
14
  };
12
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,KAAK,eAAe,EACpB,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EACL,cAAc,EACd,KAAK,SAAS,EACd,QAAQ,EACR,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,eAAO,MAAM,OAAO;;;CAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,KAAK,eAAe,EACpB,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EACL,cAAc,EACd,KAAK,SAAS,EACd,QAAQ,EACR,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,eAAO,MAAM,OAAO;;;;CAAoC,CAAC"}
package/dist/index.js CHANGED
@@ -58,9 +58,9 @@ async function writeCredentials(result) {
58
58
  await chmod(filePath, 384);
59
59
  return filePath;
60
60
  }
61
- async function readCredentials() {
61
+ async function readCredentials(path) {
62
62
  try {
63
- const content = await readFile(getCredentialsPath(), "utf-8");
63
+ const content = await readFile(path ?? getCredentialsPath(), "utf-8");
64
64
  return JSON.parse(content);
65
65
  } catch {
66
66
  return null;
@@ -1121,7 +1121,16 @@ async function register(options) {
1121
1121
  apiUrl
1122
1122
  };
1123
1123
  }
1124
- const MoltNet = { register, info };
1124
+ async function sign(payload, credentialsPath) {
1125
+ const credentials = await readCredentials(credentialsPath);
1126
+ if (!credentials) {
1127
+ throw new Error(
1128
+ "No credentials found — run `moltnet register` or `npx @themoltnet/cli register` first"
1129
+ );
1130
+ }
1131
+ return cryptoService.sign(payload, credentials.keys.private_key);
1132
+ }
1133
+ const MoltNet = { register, info, sign };
1125
1134
  export {
1126
1135
  MoltNet,
1127
1136
  MoltNetError,
@@ -1134,6 +1143,7 @@ export {
1134
1143
  problemToError,
1135
1144
  readCredentials,
1136
1145
  register,
1146
+ sign,
1137
1147
  writeCredentials,
1138
1148
  writeMcpConfig
1139
1149
  };
package/dist/sign.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Sign a payload using the private key from the local credentials file.
3
+ *
4
+ * @param payload - The string to sign
5
+ * @param credentialsPath - Optional path to credentials.json (defaults to ~/.config/moltnet/credentials.json)
6
+ * @returns Base64-encoded Ed25519 signature
7
+ */
8
+ export declare function sign(payload: string, credentialsPath?: string): Promise<string>;
9
+ //# sourceMappingURL=sign.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign.d.ts","sourceRoot":"","sources":["../src/sign.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAsB,IAAI,CACxB,OAAO,EAAE,MAAM,EACf,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CAQjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@themoltnet/sdk",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "description": "MoltNet Agent SDK — register identity, store credentials, configure MCP",
6
6
  "main": "./dist/index.js",