hiloop-sdk 0.6.0 → 0.7.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/dist/client.d.ts CHANGED
@@ -842,6 +842,17 @@ export declare class HiloopClient {
842
842
  }>;
843
843
  /** Decrypt an encrypted session message (e.g., from a webhook payload). */
844
844
  decryptSessionMessage(encryptedContent: string): Promise<string | null>;
845
+ /**
846
+ * Decrypt an interaction webhook payload in place.
847
+ * Decrypts encryptedTitle, encryptedResponse, encryptedComment using contentWrappings.
848
+ * Returns the payload with added `title`, `response`, `comment` fields.
849
+ */
850
+ decryptWebhookPayload<T extends Record<string, unknown>>(payload: T): Promise<T & {
851
+ title?: string;
852
+ response?: string;
853
+ comment?: string;
854
+ content?: string;
855
+ }>;
845
856
  static generateKeyPair(): KeyPair;
846
857
  /** Encrypt plaintext with AES-256-GCM for session messages. */
847
858
  static encryptAes(plaintext: string, keyBase64: string): Promise<string>;
package/dist/client.js CHANGED
@@ -1237,6 +1237,33 @@ export class HiloopClient {
1237
1237
  await this.ensureInitialized();
1238
1238
  return this.crypto.decryptSessionMessage(encryptedContent);
1239
1239
  }
1240
+ /**
1241
+ * Decrypt an interaction webhook payload in place.
1242
+ * Decrypts encryptedTitle, encryptedResponse, encryptedComment using contentWrappings.
1243
+ * Returns the payload with added `title`, `response`, `comment` fields.
1244
+ */
1245
+ async decryptWebhookPayload(payload) {
1246
+ await this.ensureInitialized();
1247
+ const result = { ...payload };
1248
+ const wrappings = payload.contentWrappings;
1249
+ // Session message
1250
+ if (typeof payload.encryptedContent === "string") {
1251
+ const plain = await this.crypto.decryptSessionMessage(payload.encryptedContent);
1252
+ if (plain !== null)
1253
+ result.content = plain;
1254
+ }
1255
+ // Interaction fields (need content wrappings)
1256
+ if (wrappings?.length) {
1257
+ for (const [encrypted, decrypted] of [["encryptedTitle", "title"], ["encryptedResponse", "response"], ["encryptedComment", "comment"]]) {
1258
+ if (typeof payload[encrypted] === "string") {
1259
+ const plain = await this.crypto.decryptWrappedContent(payload[encrypted], wrappings);
1260
+ if (plain !== null)
1261
+ result[decrypted] = plain;
1262
+ }
1263
+ }
1264
+ }
1265
+ return result;
1266
+ }
1240
1267
  // -- Crypto -----------------------------------------------------------------
1241
1268
  static generateKeyPair() {
1242
1269
  return generateKeyPair();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hiloop-sdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "TypeScript SDK for Hiloop — zero-trust human-AI agent interaction platform",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",