@bytexbyte/nxtlinq-ai-agent-sdk 1.0.2 → 1.0.4

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/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2025 ByteXByte
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
package/dist/index.js CHANGED
@@ -1,19 +1,26 @@
1
- import { ethers } from 'ethers';
2
- import stringify from 'json-stable-stringify';
3
- import { createNxtlinqApi } from './api/nxtlinq-api';
4
- export { ChatBot } from './components/ChatBot';
5
- export class NxtlinqAITSDK {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.NxtlinqAIAgent = exports.NxtlinqAITSDK = exports.ChatBot = void 0;
7
+ const ethers_1 = require("ethers");
8
+ const json_stable_stringify_1 = __importDefault(require("json-stable-stringify"));
9
+ const nxtlinq_api_1 = require("./api/nxtlinq-api");
10
+ var ChatBot_1 = require("./components/ChatBot");
11
+ Object.defineProperty(exports, "ChatBot", { enumerable: true, get: function () { return ChatBot_1.ChatBot; } });
12
+ class NxtlinqAITSDK {
6
13
  constructor(serviceId, apiKey, apiSecret) {
7
14
  this.signer = null;
8
15
  this.walletAddress = null;
9
16
  this.serviceId = serviceId;
10
- this.api = createNxtlinqApi(apiKey, apiSecret);
17
+ this.api = (0, nxtlinq_api_1.createNxtlinqApi)(apiKey, apiSecret);
11
18
  }
12
19
  async connectWallet() {
13
20
  if (typeof window === 'undefined' || !window.ethereum) {
14
21
  throw new Error('MetaMask is not installed');
15
22
  }
16
- const provider = new ethers.BrowserProvider(window.ethereum);
23
+ const provider = new ethers_1.ethers.BrowserProvider(window.ethereum);
17
24
  this.signer = await provider.getSigner();
18
25
  this.walletAddress = await this.signer.getAddress();
19
26
  return this.walletAddress;
@@ -46,7 +53,7 @@ export class NxtlinqAITSDK {
46
53
  code: nonceResponse.code,
47
54
  timestamp: nonceResponse.timestamp
48
55
  };
49
- const stringToSign = stringify(payload);
56
+ const stringToSign = (0, json_stable_stringify_1.default)(payload);
50
57
  const signature = await this.signer.signMessage(stringToSign || '');
51
58
  const response = await this.api.auth.signIn({
52
59
  ...payload,
@@ -72,8 +79,8 @@ export class NxtlinqAITSDK {
72
79
  permissions,
73
80
  issuedBy: this.walletAddress
74
81
  };
75
- const metadataStr = stringify(metadata);
76
- const metadataHash = ethers.keccak256(ethers.toUtf8Bytes(metadataStr || ''));
82
+ const metadataStr = (0, json_stable_stringify_1.default)(metadata);
83
+ const metadataHash = ethers_1.ethers.keccak256(ethers_1.ethers.toUtf8Bytes(metadataStr || ''));
77
84
  // Upload metadata
78
85
  const uploadResponse = await this.api.metadata.createMetadata({
79
86
  ...metadata,
@@ -84,8 +91,8 @@ export class NxtlinqAITSDK {
84
91
  }
85
92
  const { metadataCid } = uploadResponse;
86
93
  // Sign the message
87
- const messageHash = ethers.solidityPackedKeccak256(['string', 'address', 'string', 'bytes32', 'uint256'], [aitId, this.walletAddress, this.serviceId, metadataHash, timestamp]);
88
- const signature = await this.signer.signMessage(ethers.getBytes(messageHash));
94
+ const messageHash = ethers_1.ethers.solidityPackedKeccak256(['string', 'address', 'string', 'bytes32', 'uint256'], [aitId, this.walletAddress, this.serviceId, metadataHash, timestamp]);
95
+ const signature = await this.signer.signMessage(ethers_1.ethers.getBytes(messageHash));
89
96
  // Register AIT
90
97
  const response = await this.api.ait.createAIT({
91
98
  aitId,
@@ -145,12 +152,13 @@ export class NxtlinqAITSDK {
145
152
  return form.flatMap(group => group.options.filter((opt) => opt.isChecked).map((opt) => opt.value));
146
153
  }
147
154
  }
148
- export class NxtlinqAIAgent {
155
+ exports.NxtlinqAITSDK = NxtlinqAITSDK;
156
+ class NxtlinqAIAgent {
149
157
  constructor(projectId, apiKey, apiSecret) {
150
158
  this.permissions = [];
151
159
  this.projectId = projectId;
152
160
  this.apiKey = apiKey;
153
- this.api = createNxtlinqApi(apiKey, apiSecret);
161
+ this.api = (0, nxtlinq_api_1.createNxtlinqApi)(apiKey, apiSecret);
154
162
  }
155
163
  setAIT(ait, signer) {
156
164
  this.ait = ait;
@@ -207,8 +215,8 @@ export class NxtlinqAIAgent {
207
215
  permissions,
208
216
  issuedBy: hitAddress
209
217
  };
210
- const metadataStr = stringify(metadata);
211
- const metadataHash = ethers.keccak256(ethers.toUtf8Bytes(metadataStr || ''));
218
+ const metadataStr = (0, json_stable_stringify_1.default)(metadata);
219
+ const metadataHash = ethers_1.ethers.keccak256(ethers_1.ethers.toUtf8Bytes(metadataStr || ''));
212
220
  // Upload metadata
213
221
  const uploadResponse = await this.api.metadata.createMetadata({
214
222
  ...metadata,
@@ -219,8 +227,8 @@ export class NxtlinqAIAgent {
219
227
  }
220
228
  const { metadataCid } = uploadResponse;
221
229
  // Sign the message
222
- const messageHash = ethers.solidityPackedKeccak256(['string', 'address', 'string', 'bytes32', 'uint256'], [aitId, hitAddress, serviceId, metadataHash, timestamp]);
223
- const signature = await signer.signMessage(ethers.getBytes(messageHash));
230
+ const messageHash = ethers_1.ethers.solidityPackedKeccak256(['string', 'address', 'string', 'bytes32', 'uint256'], [aitId, hitAddress, serviceId, metadataHash, timestamp]);
231
+ const signature = await signer.signMessage(ethers_1.ethers.getBytes(messageHash));
224
232
  // Register AIT
225
233
  const response = await this.api.ait.createAIT({
226
234
  aitId,
@@ -276,7 +284,7 @@ export class NxtlinqAIAgent {
276
284
  throw new Error('请先连接钱包以访问权限');
277
285
  }
278
286
  const timestamp = Math.floor(Date.now() / 1000);
279
- const stringToSign = stringify({
287
+ const stringToSign = (0, json_stable_stringify_1.default)({
280
288
  message,
281
289
  aitId: this.ait.aitId,
282
290
  controller: this.ait.controller,
@@ -299,3 +307,4 @@ export class NxtlinqAIAgent {
299
307
  };
300
308
  }
301
309
  }
310
+ exports.NxtlinqAIAgent = NxtlinqAIAgent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytexbyte/nxtlinq-ai-agent-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Nxtlinq AI Agent SDK - Proprietary Software",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "sdk"
16
16
  ],
17
17
  "author": "ByteXByte",
18
- "license": "UNLICENSED",
18
+ "license": "MIT",
19
19
  "private": false,
20
20
  "peerDependencies": {
21
21
  "react": "^18.2.0"
package/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES2020",
4
- "module": "ESNext",
4
+ "module": "CommonJS",
5
5
  "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
6
  "declaration": true,
7
7
  "outDir": "dist",
@@ -9,7 +9,7 @@
9
9
  "esModuleInterop": true,
10
10
  "skipLibCheck": true,
11
11
  "forceConsistentCasingInFileNames": true,
12
- "moduleResolution": "bundler",
12
+ "moduleResolution": "node",
13
13
  "jsx": "react-jsx",
14
14
  "isolatedModules": true,
15
15
  "composite": false,