@abbababa/sdk 0.7.0 → 1.0.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 +178 -60
- package/dist/agents.d.ts +15 -4
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +14 -1
- package/dist/agents.js.map +1 -1
- package/dist/buyer.d.ts +136 -25
- package/dist/buyer.d.ts.map +1 -1
- package/dist/buyer.js +277 -45
- package/dist/buyer.js.map +1 -1
- package/dist/channels.d.ts +2 -2
- package/dist/channels.d.ts.map +1 -1
- package/dist/channels.js.map +1 -1
- package/dist/checkout.d.ts +2 -2
- package/dist/checkout.d.ts.map +1 -1
- package/dist/checkout.js.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -6
- package/dist/client.js.map +1 -1
- package/dist/crypto.d.ts +93 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +298 -0
- package/dist/crypto.js.map +1 -0
- package/dist/errors.d.ts +7 -7
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +8 -8
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/memory.d.ts +2 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js.map +1 -1
- package/dist/messages.d.ts +27 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +35 -0
- package/dist/messages.js.map +1 -1
- package/dist/register.d.ts +0 -1
- package/dist/register.d.ts.map +1 -1
- package/dist/register.js +3 -4
- package/dist/register.js.map +1 -1
- package/dist/seller.d.ts +102 -22
- package/dist/seller.d.ts.map +1 -1
- package/dist/seller.js +190 -45
- package/dist/seller.js.map +1 -1
- package/dist/services.d.ts +2 -2
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js.map +1 -1
- package/dist/transactions.d.ts +2 -2
- package/dist/transactions.d.ts.map +1 -1
- package/dist/transactions.js.map +1 -1
- package/dist/types.d.ts +131 -57
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/wallet/abi.d.ts +15 -0
- package/dist/wallet/abi.d.ts.map +1 -1
- package/dist/wallet/abi.js +18 -8
- package/dist/wallet/abi.js.map +1 -1
- package/dist/wallet/constants.d.ts +8 -6
- package/dist/wallet/constants.d.ts.map +1 -1
- package/dist/wallet/constants.js +38 -23
- package/dist/wallet/constants.js.map +1 -1
- package/dist/wallet/eoa-wallet.d.ts +21 -0
- package/dist/wallet/eoa-wallet.d.ts.map +1 -0
- package/dist/wallet/eoa-wallet.js +37 -0
- package/dist/wallet/eoa-wallet.js.map +1 -0
- package/dist/wallet/escrow.d.ts +38 -8
- package/dist/wallet/escrow.d.ts.map +1 -1
- package/dist/wallet/escrow.js +71 -18
- package/dist/wallet/escrow.js.map +1 -1
- package/dist/wallet/index.d.ts +0 -2
- package/dist/wallet/index.d.ts.map +1 -1
- package/dist/wallet/index.js +0 -2
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/session-key.d.ts +71 -0
- package/dist/wallet/session-key.d.ts.map +1 -0
- package/dist/wallet/session-key.js +82 -0
- package/dist/wallet/session-key.js.map +1 -0
- package/dist/wallet/session-keys.js +8 -8
- package/dist/wallet/smart-account.d.ts +2 -2
- package/dist/wallet/smart-account.js +4 -4
- package/package.json +14 -32
package/dist/crypto.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abba Baba E2E Encryption — ECIES with Dual ECDH + Forward Secrecy
|
|
3
|
+
*
|
|
4
|
+
* Protocol: abba-e2e-v1
|
|
5
|
+
*
|
|
6
|
+
* Per-message encryption:
|
|
7
|
+
* 1. Generate ephemeral secp256k1 key pair (epk_priv, epk_pub)
|
|
8
|
+
* 2. ECDH_1 = getSharedSecret(epk_priv, recipient_pub) — ephemeral ↔ recipient
|
|
9
|
+
* 3. ECDH_2 = getSharedSecret(sender_priv, recipient_pub) — static ↔ static
|
|
10
|
+
* 4. ikm = ECDH_1.x || ECDH_2.x (64 bytes)
|
|
11
|
+
* 5. aad = JSON({ v, from, to, epk, ts })
|
|
12
|
+
* 6. enc_key = HKDF-SHA256(ikm, salt=random16, info="abba-e2e-v1-enc", 32)
|
|
13
|
+
* 7. ct = AES-256-GCM(enc_key, iv=random12, plaintext, aad)
|
|
14
|
+
* 8. sig = secp256k1.sign(sha256(iv || ct || aad), sender_priv)
|
|
15
|
+
*
|
|
16
|
+
* Wire: body field `_e2e` carries the EncryptedEnvelope JSON.
|
|
17
|
+
*/
|
|
18
|
+
import type { EncryptedEnvelope, E2EDecryptResult, DeliveryAttestation } from './types.js';
|
|
19
|
+
/**
|
|
20
|
+
* Encrypt a plaintext object for a recipient's secp256k1 public key.
|
|
21
|
+
*
|
|
22
|
+
* @param plaintext - Object to encrypt (JSON-serialized)
|
|
23
|
+
* @param recipientPubKey - Recipient's compressed secp256k1 public key, hex (33 bytes)
|
|
24
|
+
* @param senderPrivKey - Sender's secp256k1 private key, hex (32 bytes)
|
|
25
|
+
* @param senderPubKey - Sender's compressed secp256k1 public key, hex (33 bytes)
|
|
26
|
+
*/
|
|
27
|
+
export declare function encrypt(plaintext: Record<string, unknown>, recipientPubKey: string, senderPrivKey: string, senderPubKey: string): Promise<EncryptedEnvelope>;
|
|
28
|
+
/**
|
|
29
|
+
* Decrypt an EncryptedEnvelope using the recipient's private key.
|
|
30
|
+
* Verifies the sender's ECDSA signature. Throws on tampered ciphertext
|
|
31
|
+
* (GCM auth tag failure) or malformed envelope.
|
|
32
|
+
*
|
|
33
|
+
* @param envelope - EncryptedEnvelope from the `_e2e` body field
|
|
34
|
+
* @param recipientPrivKey - Recipient's secp256k1 private key, hex (32 bytes)
|
|
35
|
+
*/
|
|
36
|
+
export declare function decrypt(envelope: EncryptedEnvelope, recipientPrivKey: string): Promise<E2EDecryptResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Generate a `DeliveryAttestation` from a plaintext payload before encrypting.
|
|
39
|
+
*
|
|
40
|
+
* The attestation is stored in plaintext alongside the `_e2e` envelope so the
|
|
41
|
+
* dispute resolver can reason about the delivery without decrypting it. The
|
|
42
|
+
* `hash` ties every semantic field to the actual content — fabricating fields
|
|
43
|
+
* causes hash mismatch when the seller reveals plaintext.
|
|
44
|
+
*/
|
|
45
|
+
export declare function generateAttestation(payload: Record<string, unknown>): DeliveryAttestation;
|
|
46
|
+
/**
|
|
47
|
+
* Verify that a `DeliveryAttestation` hash matches the given plaintext.
|
|
48
|
+
* Returns `true` if the hash is valid, `false` if tampered.
|
|
49
|
+
*
|
|
50
|
+
* Call this before accepting dispute evidence that claims to reveal plaintext.
|
|
51
|
+
*/
|
|
52
|
+
export declare function verifyAttestation(plaintext: Record<string, unknown>, attestation: DeliveryAttestation): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Derive the compressed secp256k1 public key (33 bytes, hex) from a private key.
|
|
55
|
+
*/
|
|
56
|
+
export declare function getPublicKey(privateKeyHex: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Generate a new random secp256k1 private key (hex, 32 bytes).
|
|
59
|
+
*/
|
|
60
|
+
export declare function generatePrivateKey(): string;
|
|
61
|
+
/**
|
|
62
|
+
* Holds a secp256k1 keypair for an agent and provides encrypt/decrypt helpers.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* const crypto = AgentCrypto.fromPrivateKey(process.env.AGENT_E2E_PRIVATE_KEY!)
|
|
66
|
+
* // Encrypt a message for a known recipient public key:
|
|
67
|
+
* const envelope = await crypto.encryptFor({ action: 'quote', amount: 10 }, recipientPubKey)
|
|
68
|
+
* // Decrypt a received message:
|
|
69
|
+
* const result = await crypto.decrypt(message.body._e2e)
|
|
70
|
+
* if (!result.verified) throw new Error('Signature mismatch — reject message')
|
|
71
|
+
*/
|
|
72
|
+
export declare class AgentCrypto {
|
|
73
|
+
private readonly privateKey;
|
|
74
|
+
readonly publicKey: string;
|
|
75
|
+
private constructor();
|
|
76
|
+
/**
|
|
77
|
+
* Encrypt a plaintext object for a recipient identified by their compressed
|
|
78
|
+
* secp256k1 public key (hex). Produces a new envelope with a fresh ephemeral
|
|
79
|
+
* key pair and random salt/IV — identical calls produce different ciphertexts.
|
|
80
|
+
*/
|
|
81
|
+
encryptFor(plaintext: Record<string, unknown>, recipientPubKey: string): Promise<EncryptedEnvelope>;
|
|
82
|
+
/**
|
|
83
|
+
* Decrypt an EncryptedEnvelope addressed to this agent.
|
|
84
|
+
* Verifies the sender's ECDSA signature.
|
|
85
|
+
* Throws if the ciphertext is tampered or the key is wrong.
|
|
86
|
+
*/
|
|
87
|
+
decrypt(envelope: EncryptedEnvelope): Promise<E2EDecryptResult>;
|
|
88
|
+
/** Create an AgentCrypto from an existing secp256k1 private key (hex). */
|
|
89
|
+
static fromPrivateKey(privateKeyHex: string): AgentCrypto;
|
|
90
|
+
/** Generate a brand-new random keypair. Useful for testing. */
|
|
91
|
+
static generate(): AgentCrypto;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAgC1F;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,iBAAiB,CAAC,CAgE5B;AAED;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAC3B,QAAQ,EAAE,iBAAiB,EAC3B,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,gBAAgB,CAAC,CA6D3B;AAwDD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,mBAAmB,CAczF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAI/G;AAID;;GAEG;AACH,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAID;;;;;;;;;;GAUG;AACH,qBAAa,WAAW;IAIpB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAH7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAE1B,OAAO;IAOP;;;;OAIG;IACG,UAAU,CACd,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,iBAAiB,CAAC;IAI7B;;;;OAIG;IACG,OAAO,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIrE,0EAA0E;IAC1E,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,WAAW;IAIzD,+DAA+D;IAC/D,MAAM,CAAC,QAAQ,IAAI,WAAW;CAI/B"}
|
package/dist/crypto.js
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abba Baba E2E Encryption — ECIES with Dual ECDH + Forward Secrecy
|
|
3
|
+
*
|
|
4
|
+
* Protocol: abba-e2e-v1
|
|
5
|
+
*
|
|
6
|
+
* Per-message encryption:
|
|
7
|
+
* 1. Generate ephemeral secp256k1 key pair (epk_priv, epk_pub)
|
|
8
|
+
* 2. ECDH_1 = getSharedSecret(epk_priv, recipient_pub) — ephemeral ↔ recipient
|
|
9
|
+
* 3. ECDH_2 = getSharedSecret(sender_priv, recipient_pub) — static ↔ static
|
|
10
|
+
* 4. ikm = ECDH_1.x || ECDH_2.x (64 bytes)
|
|
11
|
+
* 5. aad = JSON({ v, from, to, epk, ts })
|
|
12
|
+
* 6. enc_key = HKDF-SHA256(ikm, salt=random16, info="abba-e2e-v1-enc", 32)
|
|
13
|
+
* 7. ct = AES-256-GCM(enc_key, iv=random12, plaintext, aad)
|
|
14
|
+
* 8. sig = secp256k1.sign(sha256(iv || ct || aad), sender_priv)
|
|
15
|
+
*
|
|
16
|
+
* Wire: body field `_e2e` carries the EncryptedEnvelope JSON.
|
|
17
|
+
*/
|
|
18
|
+
import { secp256k1 } from '@noble/curves/secp256k1';
|
|
19
|
+
import { hkdf } from '@noble/hashes/hkdf';
|
|
20
|
+
import { sha256 } from '@noble/hashes/sha2';
|
|
21
|
+
import { randomBytes } from '@noble/hashes/utils';
|
|
22
|
+
// ─── Hex helpers ──────────────────────────────────────────────────────────────
|
|
23
|
+
function toHex(bytes) {
|
|
24
|
+
return Array.from(bytes)
|
|
25
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
26
|
+
.join('');
|
|
27
|
+
}
|
|
28
|
+
function fromHex(hex) {
|
|
29
|
+
if (hex.length % 2 !== 0)
|
|
30
|
+
throw new Error('Invalid hex string length');
|
|
31
|
+
const arr = new Uint8Array(hex.length / 2);
|
|
32
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
33
|
+
arr[i / 2] = parseInt(hex.slice(i, i + 2), 16);
|
|
34
|
+
}
|
|
35
|
+
return arr;
|
|
36
|
+
}
|
|
37
|
+
// ─── ECDH helper ─────────────────────────────────────────────────────────────
|
|
38
|
+
/**
|
|
39
|
+
* Perform ECDH and return the 32-byte x-coordinate of the shared point.
|
|
40
|
+
* secp256k1.getSharedSecret returns a 33-byte compressed point (prefix + x).
|
|
41
|
+
*/
|
|
42
|
+
function ecdhX(privKeyHex, pubKeyHex) {
|
|
43
|
+
const shared = secp256k1.getSharedSecret(privKeyHex, pubKeyHex);
|
|
44
|
+
return shared.slice(1, 33); // x-coordinate only
|
|
45
|
+
}
|
|
46
|
+
// ─── Core encrypt / decrypt ───────────────────────────────────────────────────
|
|
47
|
+
/**
|
|
48
|
+
* Encrypt a plaintext object for a recipient's secp256k1 public key.
|
|
49
|
+
*
|
|
50
|
+
* @param plaintext - Object to encrypt (JSON-serialized)
|
|
51
|
+
* @param recipientPubKey - Recipient's compressed secp256k1 public key, hex (33 bytes)
|
|
52
|
+
* @param senderPrivKey - Sender's secp256k1 private key, hex (32 bytes)
|
|
53
|
+
* @param senderPubKey - Sender's compressed secp256k1 public key, hex (33 bytes)
|
|
54
|
+
*/
|
|
55
|
+
export async function encrypt(plaintext, recipientPubKey, senderPrivKey, senderPubKey) {
|
|
56
|
+
const ts = Date.now();
|
|
57
|
+
// 1. Ephemeral key pair
|
|
58
|
+
const epkPrivBytes = secp256k1.utils.randomPrivateKey();
|
|
59
|
+
const epkPubBytes = secp256k1.getPublicKey(epkPrivBytes, true);
|
|
60
|
+
const epkPrivHex = toHex(epkPrivBytes);
|
|
61
|
+
const epkHex = toHex(epkPubBytes);
|
|
62
|
+
// 2 & 3. Dual ECDH
|
|
63
|
+
const ecdh1 = ecdhX(epkPrivHex, recipientPubKey); // ephemeral ↔ recipient
|
|
64
|
+
const ecdh2 = ecdhX(senderPrivKey, recipientPubKey); // static sender ↔ recipient
|
|
65
|
+
// 4. Combine IKM (64 bytes)
|
|
66
|
+
const ikm = new Uint8Array(64);
|
|
67
|
+
ikm.set(ecdh1, 0);
|
|
68
|
+
ikm.set(ecdh2, 32);
|
|
69
|
+
// 5. AAD — binds all envelope metadata to the ciphertext
|
|
70
|
+
const aadObj = { v: 1, from: senderPubKey, to: recipientPubKey, epk: epkHex, ts };
|
|
71
|
+
const aad = new TextEncoder().encode(JSON.stringify(aadObj));
|
|
72
|
+
// 6. HKDF-SHA256 → 32-byte encryption key
|
|
73
|
+
// Use new Uint8Array(...) to produce ArrayBuffer-backed views that WebCrypto accepts.
|
|
74
|
+
const salt = new Uint8Array(randomBytes(16));
|
|
75
|
+
const info = new TextEncoder().encode('abba-e2e-v1-enc');
|
|
76
|
+
const encKey = new Uint8Array(hkdf(sha256, ikm, salt, info, 32));
|
|
77
|
+
// 7. AES-256-GCM encrypt
|
|
78
|
+
const iv = new Uint8Array(randomBytes(12));
|
|
79
|
+
const plaintextBytes = new TextEncoder().encode(JSON.stringify(plaintext));
|
|
80
|
+
const cryptoKey = await globalThis.crypto.subtle.importKey('raw', encKey, { name: 'AES-GCM' }, false, ['encrypt']);
|
|
81
|
+
const ctWithTag = await globalThis.crypto.subtle.encrypt({ name: 'AES-GCM', iv, additionalData: aad }, cryptoKey, plaintextBytes);
|
|
82
|
+
const ctBytes = new Uint8Array(ctWithTag);
|
|
83
|
+
// 8. Sign sha256(iv || ct || aad) with sender's static private key
|
|
84
|
+
const sigInput = new Uint8Array(iv.length + ctBytes.length + aad.length);
|
|
85
|
+
sigInput.set(iv, 0);
|
|
86
|
+
sigInput.set(ctBytes, iv.length);
|
|
87
|
+
sigInput.set(aad, iv.length + ctBytes.length);
|
|
88
|
+
const sigHash = new Uint8Array(sha256(sigInput));
|
|
89
|
+
const sig = secp256k1.sign(sigHash, senderPrivKey);
|
|
90
|
+
return {
|
|
91
|
+
v: 1,
|
|
92
|
+
from: senderPubKey,
|
|
93
|
+
to: recipientPubKey,
|
|
94
|
+
epk: epkHex,
|
|
95
|
+
salt: toHex(salt),
|
|
96
|
+
iv: toHex(iv),
|
|
97
|
+
ct: toHex(ctBytes),
|
|
98
|
+
sig: sig.toDERHex(),
|
|
99
|
+
ts,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Decrypt an EncryptedEnvelope using the recipient's private key.
|
|
104
|
+
* Verifies the sender's ECDSA signature. Throws on tampered ciphertext
|
|
105
|
+
* (GCM auth tag failure) or malformed envelope.
|
|
106
|
+
*
|
|
107
|
+
* @param envelope - EncryptedEnvelope from the `_e2e` body field
|
|
108
|
+
* @param recipientPrivKey - Recipient's secp256k1 private key, hex (32 bytes)
|
|
109
|
+
*/
|
|
110
|
+
export async function decrypt(envelope, recipientPrivKey) {
|
|
111
|
+
const { v, from, to, epk, salt, iv, ct, sig, ts } = envelope;
|
|
112
|
+
if (v !== 1)
|
|
113
|
+
throw new Error(`Unsupported envelope version: ${v}`);
|
|
114
|
+
// Re-derive encryption key using symmetric ECDH property
|
|
115
|
+
const ecdh1 = ecdhX(recipientPrivKey, epk); // recipient ↔ ephemeral (== epk_priv ↔ recipient_pub)
|
|
116
|
+
const ecdh2 = ecdhX(recipientPrivKey, from); // recipient ↔ static sender
|
|
117
|
+
const ikm = new Uint8Array(64);
|
|
118
|
+
ikm.set(ecdh1, 0);
|
|
119
|
+
ikm.set(ecdh2, 32);
|
|
120
|
+
const aadObj = { v: 1, from, to, epk, ts };
|
|
121
|
+
const aad = new TextEncoder().encode(JSON.stringify(aadObj));
|
|
122
|
+
const saltBytes = fromHex(salt);
|
|
123
|
+
const info = new TextEncoder().encode('abba-e2e-v1-enc');
|
|
124
|
+
const encKey = new Uint8Array(hkdf(sha256, ikm, saltBytes, info, 32));
|
|
125
|
+
const ivBytes = fromHex(iv);
|
|
126
|
+
const ctBytes = fromHex(ct);
|
|
127
|
+
const cryptoKey = await globalThis.crypto.subtle.importKey('raw', encKey, { name: 'AES-GCM' }, false, ['decrypt']);
|
|
128
|
+
let plaintextBuffer;
|
|
129
|
+
try {
|
|
130
|
+
plaintextBuffer = await globalThis.crypto.subtle.decrypt({ name: 'AES-GCM', iv: ivBytes, additionalData: aad }, cryptoKey, ctBytes);
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
throw new Error('Decryption failed: invalid key or tampered ciphertext');
|
|
134
|
+
}
|
|
135
|
+
const plaintext = JSON.parse(new TextDecoder().decode(plaintextBuffer));
|
|
136
|
+
// Verify sender's ECDSA signature over sha256(iv || ct || aad)
|
|
137
|
+
const sigInput = new Uint8Array(ivBytes.length + ctBytes.length + aad.length);
|
|
138
|
+
sigInput.set(ivBytes, 0);
|
|
139
|
+
sigInput.set(ctBytes, ivBytes.length);
|
|
140
|
+
sigInput.set(aad, ivBytes.length + ctBytes.length);
|
|
141
|
+
// Wrap in new Uint8Array to get ArrayBuffer-backed view (required for noble/curves overload resolution).
|
|
142
|
+
const sigHash = new Uint8Array(sha256(sigInput));
|
|
143
|
+
// Pass sig as Uint8Array (DER bytes) so noble/curves overload resolves cleanly.
|
|
144
|
+
let verified = false;
|
|
145
|
+
try {
|
|
146
|
+
verified = secp256k1.verify(fromHex(sig), sigHash, fromHex(from));
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
verified = false;
|
|
150
|
+
}
|
|
151
|
+
return { plaintext, verified, from, ts };
|
|
152
|
+
}
|
|
153
|
+
// ─── Attestation ──────────────────────────────────────────────────────────────
|
|
154
|
+
const POSITIVE_KEYWORDS = ['success', 'complete', 'delivered', 'result', 'done', 'ok', 'found', 'created'];
|
|
155
|
+
const NEGATIVE_KEYWORDS = ['error', 'fail', 'reject', 'invalid', 'unable', 'missing', 'not found', 'exception'];
|
|
156
|
+
function detectSentiment(text) {
|
|
157
|
+
const lower = text.toLowerCase();
|
|
158
|
+
const hasNeg = NEGATIVE_KEYWORDS.some((kw) => lower.includes(kw));
|
|
159
|
+
if (hasNeg)
|
|
160
|
+
return 'negative';
|
|
161
|
+
const hasPos = POSITIVE_KEYWORDS.some((kw) => lower.includes(kw));
|
|
162
|
+
if (hasPos)
|
|
163
|
+
return 'positive';
|
|
164
|
+
return 'neutral';
|
|
165
|
+
}
|
|
166
|
+
function estimateTokens(json) {
|
|
167
|
+
return Math.ceil(json.length / 4);
|
|
168
|
+
}
|
|
169
|
+
function checkCodeExecutable(payload) {
|
|
170
|
+
const codeFields = Object.entries(payload).filter(([k]) => ['code', 'source', 'script', 'program', 'snippet', 'function'].some((kw) => k.toLowerCase().includes(kw)));
|
|
171
|
+
if (codeFields.length === 0)
|
|
172
|
+
return null;
|
|
173
|
+
for (const [, v] of codeFields) {
|
|
174
|
+
if (typeof v !== 'string')
|
|
175
|
+
continue;
|
|
176
|
+
const trimmed = v.trim();
|
|
177
|
+
// JSON value check
|
|
178
|
+
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
|
|
179
|
+
try {
|
|
180
|
+
JSON.parse(trimmed);
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// Balanced braces check for code
|
|
188
|
+
let depth = 0;
|
|
189
|
+
for (const ch of trimmed) {
|
|
190
|
+
if (ch === '{')
|
|
191
|
+
depth++;
|
|
192
|
+
else if (ch === '}')
|
|
193
|
+
depth--;
|
|
194
|
+
if (depth < 0)
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
return depth === 0;
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
function checkFlaggedContent(text) {
|
|
202
|
+
const lower = text.toLowerCase();
|
|
203
|
+
const blocklist = ['<script', 'javascript:', 'eval(', 'exec(', 'system(', 'os.system', '__import__'];
|
|
204
|
+
return blocklist.some((kw) => lower.includes(kw));
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Generate a `DeliveryAttestation` from a plaintext payload before encrypting.
|
|
208
|
+
*
|
|
209
|
+
* The attestation is stored in plaintext alongside the `_e2e` envelope so the
|
|
210
|
+
* dispute resolver can reason about the delivery without decrypting it. The
|
|
211
|
+
* `hash` ties every semantic field to the actual content — fabricating fields
|
|
212
|
+
* causes hash mismatch when the seller reveals plaintext.
|
|
213
|
+
*/
|
|
214
|
+
export function generateAttestation(payload) {
|
|
215
|
+
const json = JSON.stringify(payload);
|
|
216
|
+
const hashBytes = sha256(new TextEncoder().encode(json));
|
|
217
|
+
return {
|
|
218
|
+
format: 'json',
|
|
219
|
+
length: json.length,
|
|
220
|
+
sections: Object.keys(payload),
|
|
221
|
+
hash: 'sha256:' + toHex(hashBytes),
|
|
222
|
+
delivered_at: new Date().toISOString(),
|
|
223
|
+
tokenCount: estimateTokens(json),
|
|
224
|
+
sentiment: detectSentiment(json),
|
|
225
|
+
codeExecutable: checkCodeExecutable(payload),
|
|
226
|
+
flaggedContent: checkFlaggedContent(json),
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Verify that a `DeliveryAttestation` hash matches the given plaintext.
|
|
231
|
+
* Returns `true` if the hash is valid, `false` if tampered.
|
|
232
|
+
*
|
|
233
|
+
* Call this before accepting dispute evidence that claims to reveal plaintext.
|
|
234
|
+
*/
|
|
235
|
+
export function verifyAttestation(plaintext, attestation) {
|
|
236
|
+
const json = JSON.stringify(plaintext);
|
|
237
|
+
const computed = 'sha256:' + toHex(sha256(new TextEncoder().encode(json)));
|
|
238
|
+
return computed === attestation.hash;
|
|
239
|
+
}
|
|
240
|
+
// ─── Key utilities ────────────────────────────────────────────────────────────
|
|
241
|
+
/**
|
|
242
|
+
* Derive the compressed secp256k1 public key (33 bytes, hex) from a private key.
|
|
243
|
+
*/
|
|
244
|
+
export function getPublicKey(privateKeyHex) {
|
|
245
|
+
return toHex(secp256k1.getPublicKey(privateKeyHex, true));
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Generate a new random secp256k1 private key (hex, 32 bytes).
|
|
249
|
+
*/
|
|
250
|
+
export function generatePrivateKey() {
|
|
251
|
+
return toHex(secp256k1.utils.randomPrivateKey());
|
|
252
|
+
}
|
|
253
|
+
// ─── AgentCrypto class ────────────────────────────────────────────────────────
|
|
254
|
+
/**
|
|
255
|
+
* Holds a secp256k1 keypair for an agent and provides encrypt/decrypt helpers.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* const crypto = AgentCrypto.fromPrivateKey(process.env.AGENT_E2E_PRIVATE_KEY!)
|
|
259
|
+
* // Encrypt a message for a known recipient public key:
|
|
260
|
+
* const envelope = await crypto.encryptFor({ action: 'quote', amount: 10 }, recipientPubKey)
|
|
261
|
+
* // Decrypt a received message:
|
|
262
|
+
* const result = await crypto.decrypt(message.body._e2e)
|
|
263
|
+
* if (!result.verified) throw new Error('Signature mismatch — reject message')
|
|
264
|
+
*/
|
|
265
|
+
export class AgentCrypto {
|
|
266
|
+
privateKey;
|
|
267
|
+
publicKey;
|
|
268
|
+
constructor(privateKey, publicKey) {
|
|
269
|
+
this.privateKey = privateKey;
|
|
270
|
+
this.publicKey = publicKey;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Encrypt a plaintext object for a recipient identified by their compressed
|
|
274
|
+
* secp256k1 public key (hex). Produces a new envelope with a fresh ephemeral
|
|
275
|
+
* key pair and random salt/IV — identical calls produce different ciphertexts.
|
|
276
|
+
*/
|
|
277
|
+
async encryptFor(plaintext, recipientPubKey) {
|
|
278
|
+
return encrypt(plaintext, recipientPubKey, this.privateKey, this.publicKey);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Decrypt an EncryptedEnvelope addressed to this agent.
|
|
282
|
+
* Verifies the sender's ECDSA signature.
|
|
283
|
+
* Throws if the ciphertext is tampered or the key is wrong.
|
|
284
|
+
*/
|
|
285
|
+
async decrypt(envelope) {
|
|
286
|
+
return decrypt(envelope, this.privateKey);
|
|
287
|
+
}
|
|
288
|
+
/** Create an AgentCrypto from an existing secp256k1 private key (hex). */
|
|
289
|
+
static fromPrivateKey(privateKeyHex) {
|
|
290
|
+
return new AgentCrypto(privateKeyHex, getPublicKey(privateKeyHex));
|
|
291
|
+
}
|
|
292
|
+
/** Generate a brand-new random keypair. Useful for testing. */
|
|
293
|
+
static generate() {
|
|
294
|
+
const privKey = generatePrivateKey();
|
|
295
|
+
return AgentCrypto.fromPrivateKey(privKey);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
//# sourceMappingURL=crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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AAA;IAC3C,CAAC;IAED,0EAA0E;IAC1E,MAAM,CAAC,cAAc,CAAC,aAAqB;QACzC,OAAO,IAAI,WAAW,CAAC,aAAa,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC,CAAA;IACpE,CAAC;IAED,+DAA+D;IAC/D,MAAM,CAAC,QAAQ;QACb,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAA;QACpC,OAAO,WAAW,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;IAC5C,CAAC;CACF"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export declare class
|
|
1
|
+
export declare class AbbaBabaError extends Error {
|
|
2
2
|
statusCode: number;
|
|
3
3
|
details?: unknown | undefined;
|
|
4
4
|
constructor(statusCode: number, message: string, details?: unknown | undefined);
|
|
5
5
|
}
|
|
6
|
-
export declare class AuthenticationError extends
|
|
6
|
+
export declare class AuthenticationError extends AbbaBabaError {
|
|
7
7
|
constructor(message?: string);
|
|
8
8
|
}
|
|
9
|
-
export declare class ForbiddenError extends
|
|
9
|
+
export declare class ForbiddenError extends AbbaBabaError {
|
|
10
10
|
constructor(message?: string);
|
|
11
11
|
}
|
|
12
|
-
export declare class NotFoundError extends
|
|
12
|
+
export declare class NotFoundError extends AbbaBabaError {
|
|
13
13
|
constructor(message?: string);
|
|
14
14
|
}
|
|
15
|
-
export declare class ValidationError extends
|
|
15
|
+
export declare class ValidationError extends AbbaBabaError {
|
|
16
16
|
constructor(message?: string, details?: unknown);
|
|
17
17
|
}
|
|
18
|
-
export declare class PaymentRequiredError extends
|
|
18
|
+
export declare class PaymentRequiredError extends AbbaBabaError {
|
|
19
19
|
paymentRequirements: unknown;
|
|
20
20
|
constructor(message?: string, paymentRequirements?: unknown);
|
|
21
21
|
}
|
|
22
|
-
export declare class RateLimitError extends
|
|
22
|
+
export declare class RateLimitError extends AbbaBabaError {
|
|
23
23
|
retryAfter: number;
|
|
24
24
|
constructor(message?: string, retryAfter?: number);
|
|
25
25
|
}
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAc,SAAQ,KAAK;IAE7B,UAAU,EAAE,MAAM;IAElB,OAAO,CAAC,EAAE,OAAO;gBAFjB,UAAU,EAAE,MAAM,EACzB,OAAO,EAAE,MAAM,EACR,OAAO,CAAC,EAAE,OAAO,YAAA;CAK3B;AAED,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,OAAO,SAA+B;CAInD;AAED,qBAAa,cAAe,SAAQ,aAAa;gBACnC,OAAO,SAAc;CAIlC;AAED,qBAAa,aAAc,SAAQ,aAAa;gBAClC,OAAO,SAAuB;CAI3C;AAED,qBAAa,eAAgB,SAAQ,aAAa;gBACpC,OAAO,SAAsB,EAAE,OAAO,CAAC,EAAE,OAAO;CAI7D;AAED,qBAAa,oBAAqB,SAAQ,aAAa;IAC9C,mBAAmB,EAAE,OAAO,CAAA;gBAEvB,OAAO,SAAqB,EAAE,mBAAmB,CAAC,EAAE,OAAO;CAKxE;AAED,qBAAa,cAAe,SAAQ,aAAa;IACxC,UAAU,EAAE,MAAM,CAAA;gBAEb,OAAO,SAAwB,EAAE,UAAU,SAAK;CAK7D"}
|
package/dist/errors.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
export class
|
|
1
|
+
export class AbbaBabaError extends Error {
|
|
2
2
|
statusCode;
|
|
3
3
|
details;
|
|
4
4
|
constructor(statusCode, message, details) {
|
|
5
5
|
super(message);
|
|
6
6
|
this.statusCode = statusCode;
|
|
7
7
|
this.details = details;
|
|
8
|
-
this.name = '
|
|
8
|
+
this.name = 'AbbaBabaError';
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
export class AuthenticationError extends
|
|
11
|
+
export class AuthenticationError extends AbbaBabaError {
|
|
12
12
|
constructor(message = 'Invalid or missing API key') {
|
|
13
13
|
super(401, message);
|
|
14
14
|
this.name = 'AuthenticationError';
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
export class ForbiddenError extends
|
|
17
|
+
export class ForbiddenError extends AbbaBabaError {
|
|
18
18
|
constructor(message = 'Forbidden') {
|
|
19
19
|
super(403, message);
|
|
20
20
|
this.name = 'ForbiddenError';
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
export class NotFoundError extends
|
|
23
|
+
export class NotFoundError extends AbbaBabaError {
|
|
24
24
|
constructor(message = 'Resource not found') {
|
|
25
25
|
super(404, message);
|
|
26
26
|
this.name = 'NotFoundError';
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
export class ValidationError extends
|
|
29
|
+
export class ValidationError extends AbbaBabaError {
|
|
30
30
|
constructor(message = 'Validation failed', details) {
|
|
31
31
|
super(400, message, details);
|
|
32
32
|
this.name = 'ValidationError';
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
export class PaymentRequiredError extends
|
|
35
|
+
export class PaymentRequiredError extends AbbaBabaError {
|
|
36
36
|
paymentRequirements;
|
|
37
37
|
constructor(message = 'Payment required', paymentRequirements) {
|
|
38
38
|
super(402, message);
|
|
@@ -40,7 +40,7 @@ export class PaymentRequiredError extends AbbabaError {
|
|
|
40
40
|
this.paymentRequirements = paymentRequirements;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
export class RateLimitError extends
|
|
43
|
+
export class RateLimitError extends AbbaBabaError {
|
|
44
44
|
retryAfter;
|
|
45
45
|
constructor(message = 'Rate limit exceeded', retryAfter = 60) {
|
|
46
46
|
super(429, message);
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,
|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AI,CAAC,IAAI,GAAG,sBAAsB,CAAA;QAClC,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAA;IAChD,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,aAAa;IACxC,UAAU,CAAQ;IAEzB,YAAY,OAAO,GAAG,qBAAqB,EAAE,UAAU,GAAG,EAAE;QAC1D,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QACnB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;QAC5B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { AbbaBabaClient } from './client.js';
|
|
2
2
|
export { register } from './register.js';
|
|
3
3
|
export { SellerAgent } from './seller.js';
|
|
4
4
|
export { BuyerAgent } from './buyer.js';
|
|
@@ -10,9 +10,15 @@ export { MessagesClient } from './messages.js';
|
|
|
10
10
|
export { ChannelsClient } from './channels.js';
|
|
11
11
|
export { AgentsClient } from './agents.js';
|
|
12
12
|
export { WebhookServer, verifyWebhookSignature } from './webhook.js';
|
|
13
|
-
export {
|
|
14
|
-
export
|
|
13
|
+
export { AgentCrypto, encrypt, decrypt, getPublicKey, generatePrivateKey, generateAttestation, verifyAttestation } from './crypto.js';
|
|
14
|
+
export { AbbaBabaError, AuthenticationError, ForbiddenError, NotFoundError, PaymentRequiredError, ValidationError, RateLimitError, } from './errors.js';
|
|
15
|
+
export type { EncryptedEnvelope, E2EDecryptResult, E2EPublicKeyResult, DeliveryAttestation, AbbaBabaConfig, ApiResponse, ServiceCategory, PriceUnit, ServiceCurrency, DeliveryType, ServiceStatus, PaymentMethod, PaymentStatus, TransactionStatus, DisputeOutcome, WalletChain, CreateServiceInput, UpdateServiceInput, Service, ServiceSearchParams, ServiceListResult, AgentSummary, CheckoutInput, CheckoutResult, CryptoPaymentInstructions, PaymentInstructions, Transaction, TransactionListParams, TransactionListResult, DeliverInput, DisputeInput, DisputeStatus, EvidenceInput, FundInput, FundResult, AgentListParams, FeeTierResult, AgentScoreResult, MarketplacePulse, MarketplacePulseCategory, MemoryRenewResult, DiscoveryScoreResult, WebhookEvent, WebhookHandler, EscrowDetails, AgentStats, PollOptions, X402PaymentRequirements, CreateSessionOpts, SessionInfo, } from './types.js';
|
|
15
16
|
export { EscrowStatus, OnChainDisputeOutcome } from './types.js';
|
|
17
|
+
export { POLYGON_AMOY_CHAIN_ID, POLYGON_MAINNET_CHAIN_ID, BASE_SEPOLIA_CHAIN_ID, BASE_MAINNET_CHAIN_ID, ESCROW_V2_ADDRESSES, SCORE_V2_ADDRESSES, RESOLVER_V2_ADDRESSES, MAINNET_GRADUATION_SCORE, TESTNET_USDC_ADDRESS, TOKEN_REGISTRY, MAINNET_CHAIN_IDS, TESTNET_CHAIN_IDS, getToken, getTokensByTier, isTokenSupported, } from './wallet/constants.js';
|
|
18
|
+
export type { TokenInfo } from './wallet/constants.js';
|
|
19
|
+
export { createEOAWallet } from './wallet/eoa-wallet.js';
|
|
20
|
+
export { generateSessionWallet, generateE2EKeypair, SessionBundle } from './wallet/session-key.js';
|
|
21
|
+
export type { SessionBundlePayload } from './wallet/session-key.js';
|
|
16
22
|
export type { RegisterOptions, RegisterResult } from './register.js';
|
|
17
23
|
export type { MemoryWriteInput, MemoryEntry, MemorySearchInput, MemorySearchResult, MemoryHistoryParams, } from './memory.js';
|
|
18
24
|
export type { SendMessageInput, AgentMessage, InboxParams, SubscribeInput, MessageSubscription, } from './messages.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAG5C,OAAO,E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bbaBabaClient } from './client.js';
|
|
3
3
|
// Headless registration
|
|
4
4
|
export { register } from './register.js';
|
|
5
5
|
// Agent orchestrators
|
|
@@ -15,8 +15,14 @@ export { ChannelsClient } from './channels.js';
|
|
|
15
15
|
export { AgentsClient } from './agents.js';
|
|
16
16
|
// Webhook server + signature verification
|
|
17
17
|
export { WebhookServer, verifyWebhookSignature } from './webhook.js';
|
|
18
|
+
// E2E encryption
|
|
19
|
+
export { AgentCrypto, encrypt, decrypt, getPublicKey, generatePrivateKey, generateAttestation, verifyAttestation } from './crypto.js';
|
|
18
20
|
// Errors
|
|
19
|
-
export {
|
|
21
|
+
export { AbbaBabaError, AuthenticationError, ForbiddenError, NotFoundError, PaymentRequiredError, ValidationError, RateLimitError, } from './errors.js';
|
|
20
22
|
// V2 on-chain enums
|
|
21
23
|
export { EscrowStatus, OnChainDisputeOutcome } from './types.js';
|
|
24
|
+
// Wallet constants (chain IDs, contract addresses, token registry)
|
|
25
|
+
export { POLYGON_AMOY_CHAIN_ID, POLYGON_MAINNET_CHAIN_ID, BASE_SEPOLIA_CHAIN_ID, BASE_MAINNET_CHAIN_ID, ESCROW_V2_ADDRESSES, SCORE_V2_ADDRESSES, RESOLVER_V2_ADDRESSES, MAINNET_GRADUATION_SCORE, TESTNET_USDC_ADDRESS, TOKEN_REGISTRY, MAINNET_CHAIN_IDS, TESTNET_CHAIN_IDS, getToken, getTokensByTier, isTokenSupported, } from './wallet/constants.js';
|
|
26
|
+
export { createEOAWallet } from './wallet/eoa-wallet.js';
|
|
27
|
+
export { generateSessionWallet, generateE2EKeypair, SessionBundle } from './wallet/session-key.js';
|
|
22
28
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"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iB,EACjB,QAAQ,EACR,eAAe,EACf,gBAAgB,GACjB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA"}
|
package/dist/memory.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AbbaBabaClient } from './client.js';
|
|
2
2
|
import type { ApiResponse, MemoryRenewResult } from './types.js';
|
|
3
3
|
export interface MemoryWriteInput {
|
|
4
4
|
key: string;
|
|
@@ -47,7 +47,7 @@ export interface MemoryHistoryParams {
|
|
|
47
47
|
}
|
|
48
48
|
export declare class MemoryClient {
|
|
49
49
|
private client;
|
|
50
|
-
constructor(client:
|
|
50
|
+
constructor(client: AbbaBabaClient);
|
|
51
51
|
write(input: MemoryWriteInput): Promise<ApiResponse<MemoryEntry>>;
|
|
52
52
|
read(key: string, namespace?: string): Promise<ApiResponse<MemoryEntry>>;
|
|
53
53
|
search(input: MemorySearchInput): Promise<ApiResponse<MemorySearchResult[]>>;
|
package/dist/memory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEhE,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,OAAO,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,WAAW,GAAG,SAAS,GAAG,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IAEpC,KAAK,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAIjE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAWxE,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAI5E,OAAO,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC;IAYhF;;;;;;;;;;OAUG;IACG,KAAK,CACT,GAAG,EAAE,MAAM,EACX,kBAAkB,CAAC,EAAE,MAAM,EAC3B,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;IAMpC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAUzF"}
|
package/dist/memory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAqDA,MAAM,OAAO,YAAY;IACH;IAApB,YAAoB,
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAqDA,MAAM,OAAO,YAAY;IACH;IAApB,YAAoB,MAAsB;QAAtB,WAAM,GAAN,MAAM,CAAgB;IAAG,CAAC;IAE9C,KAAK,CAAC,KAAK,CAAC,KAAuB;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAc,MAAM,EAAE,gBAAgB,EAAE,KAAK,CAAC,CAAA;IAC1E,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAW,EA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