@kya-os/mcp-i-core 1.3.25 → 1.3.26

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.
@@ -111,7 +111,8 @@ export declare class BitstringManager {
111
111
  */
112
112
  private bytesToBase64;
113
113
  /**
114
- * Convert base64 to bytes
114
+ * Convert base64 or base64url to bytes
115
+ * Handles both standard base64 (+/) and base64url (-_) formats
115
116
  */
116
117
  private static base64ToBytes;
117
118
  /**
@@ -161,10 +161,16 @@ class BitstringManager {
161
161
  return btoa(binary);
162
162
  }
163
163
  /**
164
- * Convert base64 to bytes
164
+ * Convert base64 or base64url to bytes
165
+ * Handles both standard base64 (+/) and base64url (-_) formats
165
166
  */
166
167
  static base64ToBytes(base64) {
167
- const binary = atob(base64);
168
+ // Convert base64url to standard base64 if needed
169
+ let standardBase64 = base64.replace(/-/g, '+').replace(/_/g, '/');
170
+ // Add padding if needed
171
+ const paddingNeeded = (4 - (standardBase64.length % 4)) % 4;
172
+ standardBase64 += '='.repeat(paddingNeeded);
173
+ const binary = atob(standardBase64);
168
174
  const bytes = new Uint8Array(binary.length);
169
175
  for (let i = 0; i < binary.length; i++) {
170
176
  bytes[i] = binary.charCodeAt(i);
@@ -208,7 +208,8 @@ export declare class UserDidManager {
208
208
  */
209
209
  private base58Encode;
210
210
  /**
211
- * Convert base64 string to Uint8Array
211
+ * Convert base64 or base64url string to Uint8Array
212
+ * Handles both standard base64 (+/) and base64url (-_) formats
212
213
  */
213
214
  private base64ToBytes;
214
215
  /**
@@ -285,16 +285,23 @@ class UserDidManager {
285
285
  return result;
286
286
  }
287
287
  /**
288
- * Convert base64 string to Uint8Array
288
+ * Convert base64 or base64url string to Uint8Array
289
+ * Handles both standard base64 (+/) and base64url (-_) formats
289
290
  */
290
291
  base64ToBytes(base64) {
292
+ // Convert base64url to standard base64 if needed
293
+ // Base64url uses - instead of + and _ instead of /
294
+ let standardBase64 = base64.replace(/-/g, "+").replace(/_/g, "/");
295
+ // Add padding if needed (base64url often omits padding)
296
+ const paddingNeeded = (4 - (standardBase64.length % 4)) % 4;
297
+ standardBase64 += "=".repeat(paddingNeeded);
291
298
  if (typeof Buffer !== "undefined") {
292
299
  // Node.js environment
293
- return new Uint8Array(Buffer.from(base64, "base64"));
300
+ return new Uint8Array(Buffer.from(standardBase64, "base64"));
294
301
  }
295
302
  else {
296
303
  // Browser/Workers environment
297
- const binaryString = atob(base64);
304
+ const binaryString = atob(standardBase64);
298
305
  const bytes = new Uint8Array(binaryString.length);
299
306
  for (let i = 0; i < binaryString.length; i++) {
300
307
  bytes[i] = binaryString.charCodeAt(i);
@@ -190,6 +190,10 @@ export declare class MCPIRuntimeBase {
190
190
  rotateKeys(): Promise<AgentIdentity>;
191
191
  private signData;
192
192
  private generateNonce;
193
+ /**
194
+ * Generate a unique session ID
195
+ * Uses mcpi_{uuid} format for MCP protocol compliance and traceability
196
+ */
193
197
  private generateSessionId;
194
198
  /**
195
199
  * Log structured events in JSON format (NOT frozen audit format).
@@ -1063,9 +1063,18 @@ class MCPIRuntimeBase {
1063
1063
  const bytes = await this.crypto.randomBytes(32);
1064
1064
  return this.bytesToBase64(bytes);
1065
1065
  }
1066
+ /**
1067
+ * Generate a unique session ID
1068
+ * Uses mcpi_{uuid} format for MCP protocol compliance and traceability
1069
+ */
1066
1070
  async generateSessionId() {
1067
1071
  const bytes = await this.crypto.randomBytes(16);
1068
- return this.bytesToHex(bytes);
1072
+ // Set version (4) and variant (RFC4122)
1073
+ bytes[6] = (bytes[6] & 0x0f) | 0x40;
1074
+ bytes[8] = (bytes[8] & 0x3f) | 0x80;
1075
+ const hex = this.bytesToHex(bytes);
1076
+ const uuid = `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;
1077
+ return `mcpi_${uuid}`;
1069
1078
  }
1070
1079
  /**
1071
1080
  * Log structured events in JSON format (NOT frozen audit format).
@@ -54,7 +54,9 @@ class SessionRegistrationService {
54
54
  return { success: false, sessionId, error: errorMsg };
55
55
  }
56
56
  const url = `${this.config.baseUrl}${agentshield_api_1.AGENTSHIELD_ENDPOINTS.SESSIONS}`;
57
- this.config.logger("[SessionRegistration] Registering session", {
57
+ // NOTE: This registers the SESSION with AgentShield for dashboard visibility
58
+ // This is NOT the same as agent registration with Know That AI (which happens during deploy)
59
+ this.config.logger("[SessionRegistration] Registering session for dashboard visibility", {
58
60
  sessionId,
59
61
  agentDid: request.agent_did,
60
62
  clientName: request.client_info.name,
@@ -99,7 +101,7 @@ class SessionRegistrationService {
99
101
  // Still consider it a success if we got a 200 OK
100
102
  return { success: true, sessionId };
101
103
  }
102
- this.config.logger("[SessionRegistration] Session registered", {
104
+ this.config.logger("[SessionRegistration] Session now visible in AgentShield dashboard", {
103
105
  sessionId,
104
106
  registered: parseResult.data.registered,
105
107
  });
@@ -25,7 +25,8 @@ export declare function base64urlEncodeFromBytes(bytes: Uint8Array): string;
25
25
  */
26
26
  export declare function bytesToBase64(bytes: Uint8Array): string;
27
27
  /**
28
- * Convert standard base64 to bytes
28
+ * Convert standard base64 or base64url to bytes
29
+ * Handles both standard base64 (+/) and base64url (-_) formats
29
30
  */
30
31
  export declare function base64ToBytes(base64: string): Uint8Array;
31
32
  //# sourceMappingURL=base64.d.ts.map
@@ -137,12 +137,19 @@ function bytesToBase64(bytes) {
137
137
  return Buffer.from(bytes).toString("base64");
138
138
  }
139
139
  /**
140
- * Convert standard base64 to bytes
140
+ * Convert standard base64 or base64url to bytes
141
+ * Handles both standard base64 (+/) and base64url (-_) formats
141
142
  */
142
143
  function base64ToBytes(base64) {
144
+ // Convert base64url to standard base64 if needed
145
+ // Base64url uses - instead of + and _ instead of /
146
+ let standardBase64 = base64.replace(/-/g, "+").replace(/_/g, "/");
147
+ // Add padding if needed (base64url often omits padding)
148
+ const paddingNeeded = (4 - (standardBase64.length % 4)) % 4;
149
+ standardBase64 += "=".repeat(paddingNeeded);
143
150
  // For platforms that don't have Buffer
144
151
  if (typeof atob !== "undefined") {
145
- const binaryString = atob(base64);
152
+ const binaryString = atob(standardBase64);
146
153
  const bytes = new Uint8Array(binaryString.length);
147
154
  for (let i = 0; i < binaryString.length; i++) {
148
155
  bytes[i] = binaryString.charCodeAt(i);
@@ -150,7 +157,7 @@ function base64ToBytes(base64) {
150
157
  return bytes;
151
158
  }
152
159
  // For Node.js environments
153
- return new Uint8Array(Buffer.from(base64, "base64"));
160
+ return new Uint8Array(Buffer.from(standardBase64, "base64"));
154
161
  }
155
162
  /**
156
163
  * Add padding to base64url string if needed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kya-os/mcp-i-core",
3
- "version": "1.3.25",
3
+ "version": "1.3.26",
4
4
  "description": "Core runtime and types for MCP-I framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",