@mysten-incubation/memwal 0.0.1-dev.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 +59 -0
- package/dist/account-entry.d.ts +14 -0
- package/dist/account-entry.d.ts.map +1 -0
- package/dist/account-entry.js +14 -0
- package/dist/account-entry.js.map +1 -0
- package/dist/account.d.ts +87 -0
- package/dist/account.d.ts.map +1 -0
- package/dist/account.js +273 -0
- package/dist/account.js.map +1 -0
- package/dist/ai/index.d.ts +3 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +2 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/middleware.d.ts +55 -0
- package/dist/ai/middleware.d.ts.map +1 -0
- package/dist/ai/middleware.js +145 -0
- package/dist/ai/middleware.js.map +1 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/manual-entry.d.ts +12 -0
- package/dist/manual-entry.d.ts.map +1 -0
- package/dist/manual-entry.js +11 -0
- package/dist/manual-entry.js.map +1 -0
- package/dist/manual.d.ts +97 -0
- package/dist/manual.d.ts.map +1 -0
- package/dist/manual.js +498 -0
- package/dist/manual.js.map +1 -0
- package/dist/memwal.d.ts +174 -0
- package/dist/memwal.d.ts.map +1 -0
- package/dist/memwal.js +283 -0
- package/dist/memwal.js.map +1 -0
- package/dist/types.d.ts +237 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +38 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +84 -0
- package/dist/utils.js.map +1 -0
- package/package.json +88 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* memwal — Core Types
|
|
3
|
+
*
|
|
4
|
+
* Ed25519 delegate key based SDK that communicates with
|
|
5
|
+
* the MemWal Rust server (TEE).
|
|
6
|
+
*/
|
|
7
|
+
export interface MemWalConfig {
|
|
8
|
+
/** Ed25519 private key (hex string). This is the delegate key from app.memwal.com */
|
|
9
|
+
key: string;
|
|
10
|
+
/** MemWalAccount object ID on Sui (ensures correct account when delegate key exists in multiple accounts) */
|
|
11
|
+
accountId: string;
|
|
12
|
+
/** Server URL (default: http://localhost:8000) */
|
|
13
|
+
serverUrl?: string;
|
|
14
|
+
/** Default namespace for memory isolation (default: "default") */
|
|
15
|
+
namespace?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Result from remember() */
|
|
18
|
+
export interface RememberResult {
|
|
19
|
+
id: string;
|
|
20
|
+
blob_id: string;
|
|
21
|
+
owner: string;
|
|
22
|
+
namespace: string;
|
|
23
|
+
}
|
|
24
|
+
/** A single recalled memory */
|
|
25
|
+
export interface RecallMemory {
|
|
26
|
+
blob_id: string;
|
|
27
|
+
text: string;
|
|
28
|
+
distance: number;
|
|
29
|
+
}
|
|
30
|
+
/** Result from recall() */
|
|
31
|
+
export interface RecallResult {
|
|
32
|
+
results: RecallMemory[];
|
|
33
|
+
total: number;
|
|
34
|
+
}
|
|
35
|
+
/** Result from embed() */
|
|
36
|
+
export interface EmbedResult {
|
|
37
|
+
vector: number[];
|
|
38
|
+
}
|
|
39
|
+
/** A single extracted fact */
|
|
40
|
+
export interface AnalyzedFact {
|
|
41
|
+
text: string;
|
|
42
|
+
id: string;
|
|
43
|
+
blob_id: string;
|
|
44
|
+
}
|
|
45
|
+
/** Result from analyze() */
|
|
46
|
+
export interface AnalyzeResult {
|
|
47
|
+
facts: AnalyzedFact[];
|
|
48
|
+
total: number;
|
|
49
|
+
owner: string;
|
|
50
|
+
}
|
|
51
|
+
/** Server health response */
|
|
52
|
+
export interface HealthResult {
|
|
53
|
+
status: string;
|
|
54
|
+
version: string;
|
|
55
|
+
}
|
|
56
|
+
/** Options for rememberManual() on MemWal class */
|
|
57
|
+
export interface RememberManualOptions {
|
|
58
|
+
/** Walrus blob ID (user already uploaded encrypted data) */
|
|
59
|
+
blobId: string;
|
|
60
|
+
/** Embedding vector (user already generated) */
|
|
61
|
+
vector: number[];
|
|
62
|
+
/** Namespace (default: config namespace or "default") */
|
|
63
|
+
namespace?: string;
|
|
64
|
+
}
|
|
65
|
+
/** Result from rememberManual() */
|
|
66
|
+
export interface RememberManualResult {
|
|
67
|
+
id: string;
|
|
68
|
+
blob_id: string;
|
|
69
|
+
owner: string;
|
|
70
|
+
namespace: string;
|
|
71
|
+
}
|
|
72
|
+
/** Options for recallManual() on MemWal class */
|
|
73
|
+
export interface RecallManualOptions {
|
|
74
|
+
/** Pre-computed query embedding vector */
|
|
75
|
+
vector: number[];
|
|
76
|
+
/** Max number of results (default: 10) */
|
|
77
|
+
limit?: number;
|
|
78
|
+
/** Namespace (default: config namespace or "default") */
|
|
79
|
+
namespace?: string;
|
|
80
|
+
}
|
|
81
|
+
/** A single search hit — raw blobId + distance (no decrypted text) */
|
|
82
|
+
export interface RecallManualHit {
|
|
83
|
+
blob_id: string;
|
|
84
|
+
distance: number;
|
|
85
|
+
}
|
|
86
|
+
/** Result from restore() */
|
|
87
|
+
export interface RestoreResult {
|
|
88
|
+
restored: number;
|
|
89
|
+
skipped: number;
|
|
90
|
+
total: number;
|
|
91
|
+
namespace: string;
|
|
92
|
+
owner: string;
|
|
93
|
+
}
|
|
94
|
+
/** Config for MemWalManual (full client-side: SEAL + Walrus + embedding) */
|
|
95
|
+
export interface MemWalManualConfig {
|
|
96
|
+
/** Ed25519 delegate private key (hex) for server auth */
|
|
97
|
+
key: string;
|
|
98
|
+
/** Server URL (default: http://localhost:8000) */
|
|
99
|
+
serverUrl?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Sui private key (bech32 suiprivkey1...) for SEAL + Walrus signing.
|
|
102
|
+
* Provide EITHER this OR `walletSigner` — not both.
|
|
103
|
+
*/
|
|
104
|
+
suiPrivateKey?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Connected wallet signer (e.g. from dapp-kit).
|
|
107
|
+
* Use this when the user's wallet is already connected in the browser.
|
|
108
|
+
* Provide EITHER this OR `suiPrivateKey` — not both.
|
|
109
|
+
*/
|
|
110
|
+
walletSigner?: WalletSigner;
|
|
111
|
+
/**
|
|
112
|
+
* Pre-configured Sui client instance (e.g. from dapp-kit's useSuiClient()).
|
|
113
|
+
* If omitted, the SDK will try to create one internally.
|
|
114
|
+
* Recommended for browser environments where @mysten/sui v2.x removed SuiClient.
|
|
115
|
+
*/
|
|
116
|
+
suiClient?: any;
|
|
117
|
+
/** OpenAI/OpenRouter API key for embeddings (required for client-side embedding) */
|
|
118
|
+
embeddingApiKey: string;
|
|
119
|
+
/** OpenAI-compatible API base URL (default: https://api.openai.com/v1) */
|
|
120
|
+
embeddingApiBase?: string;
|
|
121
|
+
/** Embedding model name (default: text-embedding-3-small) */
|
|
122
|
+
embeddingModel?: string;
|
|
123
|
+
/** MemWal contract package ID on Sui */
|
|
124
|
+
packageId: string;
|
|
125
|
+
/** MemWalAccount object ID (for SEAL seal_approve) */
|
|
126
|
+
accountId: string;
|
|
127
|
+
/** Sui network (default: mainnet) */
|
|
128
|
+
suiNetwork?: "testnet" | "mainnet";
|
|
129
|
+
/**
|
|
130
|
+
* Custom SEAL key server object IDs (overrides built-in defaults per network).
|
|
131
|
+
* Array of on-chain object IDs, e.g. ["0x..."].
|
|
132
|
+
* If omitted, uses built-in defaults for the selected suiNetwork.
|
|
133
|
+
*/
|
|
134
|
+
sealKeyServers?: string[];
|
|
135
|
+
/** Walrus storage epochs (default: 50) */
|
|
136
|
+
walrusEpochs?: number;
|
|
137
|
+
/** Walrus aggregator URL for direct blob downloads (default: mainnet aggregator) */
|
|
138
|
+
walrusAggregatorUrl?: string;
|
|
139
|
+
/** Walrus publisher URL for direct blob uploads (default: mainnet publisher) */
|
|
140
|
+
walrusPublisherUrl?: string;
|
|
141
|
+
/** Default namespace for memory isolation (default: "default") */
|
|
142
|
+
namespace?: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Wallet signer interface — pass a connected wallet adapter.
|
|
146
|
+
* Compatible with @mysten/dapp-kit's useSignAndExecuteTransaction.
|
|
147
|
+
*/
|
|
148
|
+
export interface WalletSigner {
|
|
149
|
+
/** Wallet address (Sui address, 0x...) */
|
|
150
|
+
address: string;
|
|
151
|
+
/** Sign and execute a transaction, returns the digest */
|
|
152
|
+
signAndExecuteTransaction: (input: {
|
|
153
|
+
transaction: any;
|
|
154
|
+
}) => Promise<{
|
|
155
|
+
digest: string;
|
|
156
|
+
}>;
|
|
157
|
+
/** Sign a personal message (for SEAL SessionKey) */
|
|
158
|
+
signPersonalMessage: (input: {
|
|
159
|
+
message: Uint8Array;
|
|
160
|
+
}) => Promise<{
|
|
161
|
+
signature: string;
|
|
162
|
+
}>;
|
|
163
|
+
}
|
|
164
|
+
/** A recalled memory with decrypted text (from MemWalManual.recallManual) */
|
|
165
|
+
export interface RecallManualMemory {
|
|
166
|
+
blob_id: string;
|
|
167
|
+
text: string;
|
|
168
|
+
distance: number;
|
|
169
|
+
}
|
|
170
|
+
/** Result from recallManual() — full client-side variant with decrypted text */
|
|
171
|
+
export interface RecallManualResult {
|
|
172
|
+
results: (RecallManualHit | RecallManualMemory)[];
|
|
173
|
+
total: number;
|
|
174
|
+
}
|
|
175
|
+
/** Base options for on-chain account transactions */
|
|
176
|
+
interface AccountTxOpts {
|
|
177
|
+
/** MemWal contract package ID on Sui */
|
|
178
|
+
packageId: string;
|
|
179
|
+
/**
|
|
180
|
+
* Sui private key (bech32 suiprivkey1...) for signing.
|
|
181
|
+
* Provide EITHER this OR `walletSigner` — not both.
|
|
182
|
+
*/
|
|
183
|
+
suiPrivateKey?: string;
|
|
184
|
+
/**
|
|
185
|
+
* Connected wallet signer (e.g. from dapp-kit).
|
|
186
|
+
* Provide EITHER this OR `suiPrivateKey` — not both.
|
|
187
|
+
*/
|
|
188
|
+
walletSigner?: WalletSigner;
|
|
189
|
+
/**
|
|
190
|
+
* Pre-configured Sui client instance.
|
|
191
|
+
* If omitted, the SDK will create one internally.
|
|
192
|
+
*/
|
|
193
|
+
suiClient?: any;
|
|
194
|
+
/** Sui network (default: mainnet) */
|
|
195
|
+
suiNetwork?: "testnet" | "mainnet";
|
|
196
|
+
}
|
|
197
|
+
/** Options for createAccount() */
|
|
198
|
+
export interface CreateAccountOpts extends AccountTxOpts {
|
|
199
|
+
/** AccountRegistry shared object ID */
|
|
200
|
+
registryId: string;
|
|
201
|
+
}
|
|
202
|
+
/** Result from createAccount() */
|
|
203
|
+
export interface CreateAccountResult {
|
|
204
|
+
/** Created MemWalAccount object ID */
|
|
205
|
+
accountId: string;
|
|
206
|
+
/** Owner Sui address */
|
|
207
|
+
owner: string;
|
|
208
|
+
/** Transaction digest */
|
|
209
|
+
digest: string;
|
|
210
|
+
}
|
|
211
|
+
/** Options for addDelegateKey() */
|
|
212
|
+
export interface AddDelegateKeyOpts extends AccountTxOpts {
|
|
213
|
+
/** MemWalAccount object ID */
|
|
214
|
+
accountId: string;
|
|
215
|
+
/** Ed25519 public key (32 bytes Uint8Array or hex string) */
|
|
216
|
+
publicKey: Uint8Array | string;
|
|
217
|
+
/** Human-readable label (e.g. "MacBook Pro", "Production Server") */
|
|
218
|
+
label: string;
|
|
219
|
+
}
|
|
220
|
+
/** Result from addDelegateKey() */
|
|
221
|
+
export interface AddDelegateKeyResult {
|
|
222
|
+
/** Transaction digest */
|
|
223
|
+
digest: string;
|
|
224
|
+
/** Public key hex */
|
|
225
|
+
publicKey: string;
|
|
226
|
+
/** Derived Sui address for this delegate key */
|
|
227
|
+
suiAddress: string;
|
|
228
|
+
}
|
|
229
|
+
/** Options for removeDelegateKey() */
|
|
230
|
+
export interface RemoveDelegateKeyOpts extends AccountTxOpts {
|
|
231
|
+
/** MemWalAccount object ID */
|
|
232
|
+
accountId: string;
|
|
233
|
+
/** Ed25519 public key to remove (32 bytes Uint8Array or hex string) */
|
|
234
|
+
publicKey: Uint8Array | string;
|
|
235
|
+
}
|
|
236
|
+
export {};
|
|
237
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,YAAY;IACzB,qFAAqF;IACrF,GAAG,EAAE,MAAM,CAAC;IACZ,6GAA6G;IAC7G,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAMD,6BAA6B;AAC7B,MAAM,WAAW,cAAc;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,+BAA+B;AAC/B,MAAM,WAAW,YAAY;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,2BAA2B;AAC3B,MAAM,WAAW,YAAY;IACzB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,0BAA0B;AAC1B,MAAM,WAAW,WAAW;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,8BAA8B;AAC9B,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,4BAA4B;AAC5B,MAAM,WAAW,aAAa;IAC1B,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,6BAA6B;AAC7B,MAAM,WAAW,YAAY;IACzB,MA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qDAAqD;AACrD,UAAU,aAAa;IACnB,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;;OAGG;IACH,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,qCAAqC;IACrC,UAAU,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACtC;AAED,kCAAkC;AAClC,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACpD,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,kCAAkC;AAClC,MAAM,WAAW,mBAAmB;IAChC,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,mCAAmC;AACnC,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACrD,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,SAAS,EAAE,UAAU,GAAG,MAAM,CAAC;IAC/B,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,mCAAmC;AACnC,MAAM,WAAW,oBAAoB;IACjC,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,sCAAsC;AACtC,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IACxD,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,SAAS,EAAE,UAAU,GAAG,MAAM,CAAC;CAClC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* memwal — Shared Utilities
|
|
3
|
+
*
|
|
4
|
+
* Common crypto and encoding helpers used across the SDK.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Isomorphic SHA-256 hash — uses Web Crypto API (browser) or Node.js crypto (server).
|
|
8
|
+
*/
|
|
9
|
+
export declare function sha256hex(data: string): Promise<string>;
|
|
10
|
+
export declare function hexToBytes(hex: string): Uint8Array;
|
|
11
|
+
export declare function bytesToHex(bytes: Uint8Array): string;
|
|
12
|
+
/**
|
|
13
|
+
* Derive the Sui address from an Ed25519 delegate key (private key hex).
|
|
14
|
+
*
|
|
15
|
+
* Sui Ed25519 address = blake2b256(0x00 || public_key)[0..32]
|
|
16
|
+
* where 0x00 is the Ed25519 scheme flag.
|
|
17
|
+
*
|
|
18
|
+
* This allows a delegate key to be used as a Sui keypair for signing transactions
|
|
19
|
+
* (e.g. calling seal_approve for SEAL decryption).
|
|
20
|
+
*
|
|
21
|
+
* @param privateKeyHex - Ed25519 private key as hex string
|
|
22
|
+
* @returns Sui address as 0x-prefixed hex string
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const suiAddress = await delegateKeyToSuiAddress("abcdef1234...")
|
|
27
|
+
* // "0x1a2b3c..."
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function delegateKeyToSuiAddress(privateKeyHex: string): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Get the Ed25519 public key bytes from a delegate key private key hex.
|
|
33
|
+
*
|
|
34
|
+
* @param privateKeyHex - Ed25519 private key as hex string
|
|
35
|
+
* @returns 32-byte public key as Uint8Array
|
|
36
|
+
*/
|
|
37
|
+
export declare function delegateKeyToPublicKey(privateKeyHex: string): Promise<Uint8Array>;
|
|
38
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;GAEG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAY7D;AAMD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAOlD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIpD;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,uBAAuB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAcpF;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAGvF"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* memwal — Shared Utilities
|
|
3
|
+
*
|
|
4
|
+
* Common crypto and encoding helpers used across the SDK.
|
|
5
|
+
*/
|
|
6
|
+
// ============================================================
|
|
7
|
+
// SHA-256 (Isomorphic)
|
|
8
|
+
// ============================================================
|
|
9
|
+
/**
|
|
10
|
+
* Isomorphic SHA-256 hash — uses Web Crypto API (browser) or Node.js crypto (server).
|
|
11
|
+
*/
|
|
12
|
+
export async function sha256hex(data) {
|
|
13
|
+
const bytes = new TextEncoder().encode(data);
|
|
14
|
+
// Try Web Crypto API first (browser + modern Node.js)
|
|
15
|
+
if (typeof globalThis.crypto?.subtle?.digest === "function") {
|
|
16
|
+
const hashBuf = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
17
|
+
return Array.from(new Uint8Array(hashBuf))
|
|
18
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
19
|
+
.join("");
|
|
20
|
+
}
|
|
21
|
+
// Fallback to Node.js crypto
|
|
22
|
+
const crypto = await import("crypto");
|
|
23
|
+
return crypto.createHash("sha256").update(data).digest("hex");
|
|
24
|
+
}
|
|
25
|
+
// ============================================================
|
|
26
|
+
// Hex Encoding
|
|
27
|
+
// ============================================================
|
|
28
|
+
export function hexToBytes(hex) {
|
|
29
|
+
const clean = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
30
|
+
const bytes = new Uint8Array(clean.length / 2);
|
|
31
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
32
|
+
bytes[i] = parseInt(clean.substring(i * 2, i * 2 + 2), 16);
|
|
33
|
+
}
|
|
34
|
+
return bytes;
|
|
35
|
+
}
|
|
36
|
+
export function bytesToHex(bytes) {
|
|
37
|
+
return Array.from(bytes)
|
|
38
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
39
|
+
.join("");
|
|
40
|
+
}
|
|
41
|
+
// ============================================================
|
|
42
|
+
// Delegate Key → Sui Address Derivation
|
|
43
|
+
// ============================================================
|
|
44
|
+
/**
|
|
45
|
+
* Derive the Sui address from an Ed25519 delegate key (private key hex).
|
|
46
|
+
*
|
|
47
|
+
* Sui Ed25519 address = blake2b256(0x00 || public_key)[0..32]
|
|
48
|
+
* where 0x00 is the Ed25519 scheme flag.
|
|
49
|
+
*
|
|
50
|
+
* This allows a delegate key to be used as a Sui keypair for signing transactions
|
|
51
|
+
* (e.g. calling seal_approve for SEAL decryption).
|
|
52
|
+
*
|
|
53
|
+
* @param privateKeyHex - Ed25519 private key as hex string
|
|
54
|
+
* @returns Sui address as 0x-prefixed hex string
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const suiAddress = await delegateKeyToSuiAddress("abcdef1234...")
|
|
59
|
+
* // "0x1a2b3c..."
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export async function delegateKeyToSuiAddress(privateKeyHex) {
|
|
63
|
+
const ed = await import("@noble/ed25519");
|
|
64
|
+
const { blake2b } = await import("@noble/hashes/blake2.js");
|
|
65
|
+
const privateKey = hexToBytes(privateKeyHex);
|
|
66
|
+
const publicKey = await ed.getPublicKeyAsync(privateKey);
|
|
67
|
+
// Sui Ed25519 address = blake2b256(0x00 || public_key)
|
|
68
|
+
const input = new Uint8Array(33);
|
|
69
|
+
input[0] = 0x00; // Ed25519 scheme flag
|
|
70
|
+
input.set(publicKey, 1);
|
|
71
|
+
const addressBytes = blake2b(input, { dkLen: 32 });
|
|
72
|
+
return "0x" + bytesToHex(addressBytes);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get the Ed25519 public key bytes from a delegate key private key hex.
|
|
76
|
+
*
|
|
77
|
+
* @param privateKeyHex - Ed25519 private key as hex string
|
|
78
|
+
* @returns 32-byte public key as Uint8Array
|
|
79
|
+
*/
|
|
80
|
+
export async function delegateKeyToPublicKey(privateKeyHex) {
|
|
81
|
+
const ed = await import("@noble/ed25519");
|
|
82
|
+
return ed.getPublicKeyAsync(hexToBytes(privateKeyHex));
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+DAA+D;AAC/D,uBAAuB;AACvB,+DAA+D;AAE/D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAY;IACxC,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7C,sDAAsD;IACtD,IAAI,OAAO,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,UAAU,EAAE,CAAC;QAC1D,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QACxE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;aACrC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AC,EAAE,CAAC,CAAC;AAClB,CAAC;AAED,+DAA+D;AAC/D,wCAAwC;AACxC,+DAA+D;AAE/D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,aAAqB;IAC/D,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAC;IAE5D,MAAM,UAAU,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAC7C,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAEzD,uDAAuD;IACvD,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IACjC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,sBAAsB;IACvC,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAExB,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IACnD,OAAO,IAAI,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,aAAqB;IAC9D,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAC1C,OAAO,EAAE,CAAC,iBAAiB,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mysten-incubation/memwal",
|
|
3
|
+
"version": "0.0.1-dev.0",
|
|
4
|
+
"description": "MemWal — Privacy-first AI memory SDK with Ed25519 delegate key auth",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./account": {
|
|
14
|
+
"import": "./dist/account-entry.js",
|
|
15
|
+
"types": "./dist/account-entry.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"./manual": {
|
|
18
|
+
"import": "./dist/manual-entry.js",
|
|
19
|
+
"types": "./dist/manual-entry.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./ai": {
|
|
22
|
+
"import": "./dist/ai/index.js",
|
|
23
|
+
"types": "./dist/ai/index.d.ts"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"dev": "tsc --watch",
|
|
29
|
+
"typecheck": "tsc --noEmit"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@noble/ed25519": "^2.3.0",
|
|
33
|
+
"@noble/hashes": "^2.0.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@ai-sdk/provider": "^2.0.0",
|
|
37
|
+
"@types/node": "^20.0.0",
|
|
38
|
+
"typescript": "^5.5.0"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"ai": ">=4.0.0",
|
|
42
|
+
"zod": "^3.23.0",
|
|
43
|
+
"@mysten/sui": ">=2.5.0",
|
|
44
|
+
"@mysten/seal": ">=1.1.0",
|
|
45
|
+
"@mysten/walrus": ">=1.0.3"
|
|
46
|
+
},
|
|
47
|
+
"peerDependenciesMeta": {
|
|
48
|
+
"ai": {
|
|
49
|
+
"optional": true
|
|
50
|
+
},
|
|
51
|
+
"zod": {
|
|
52
|
+
"optional": true
|
|
53
|
+
},
|
|
54
|
+
"@mysten/sui": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
57
|
+
"@mysten/seal": {
|
|
58
|
+
"optional": true
|
|
59
|
+
},
|
|
60
|
+
"@mysten/walrus": {
|
|
61
|
+
"optional": true
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"files": [
|
|
65
|
+
"dist",
|
|
66
|
+
"README.md"
|
|
67
|
+
],
|
|
68
|
+
"keywords": [
|
|
69
|
+
"ai",
|
|
70
|
+
"memory",
|
|
71
|
+
"privacy",
|
|
72
|
+
"walrus",
|
|
73
|
+
"sui",
|
|
74
|
+
"encryption",
|
|
75
|
+
"ed25519",
|
|
76
|
+
"tee"
|
|
77
|
+
],
|
|
78
|
+
"license": "Apache-2.0",
|
|
79
|
+
"repository": {
|
|
80
|
+
"type": "git",
|
|
81
|
+
"url": "https://github.com/CommandOSSLabs/MemWal.git",
|
|
82
|
+
"directory": "packages/sdk"
|
|
83
|
+
},
|
|
84
|
+
"publishConfig": {
|
|
85
|
+
"access": "public",
|
|
86
|
+
"registry": "https://registry.npmjs.org/"
|
|
87
|
+
}
|
|
88
|
+
}
|