@yallet/rwa-sdk 0.2.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.
Files changed (58) hide show
  1. package/README.md +365 -0
  2. package/dist/credential-nft-server.d.ts +75 -0
  3. package/dist/credential-nft-server.d.ts.map +1 -0
  4. package/dist/credential-nft-server.js +122 -0
  5. package/dist/credential-nft-server.js.map +1 -0
  6. package/dist/credential-nft.d.ts +31 -0
  7. package/dist/credential-nft.d.ts.map +1 -0
  8. package/dist/credential-nft.js +38 -0
  9. package/dist/credential-nft.js.map +1 -0
  10. package/dist/encryption.d.ts +107 -0
  11. package/dist/encryption.d.ts.map +1 -0
  12. package/dist/encryption.js +176 -0
  13. package/dist/encryption.js.map +1 -0
  14. package/dist/index.d.ts +56 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +66 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/metadata.d.ts +161 -0
  19. package/dist/metadata.d.ts.map +1 -0
  20. package/dist/metadata.js +180 -0
  21. package/dist/metadata.js.map +1 -0
  22. package/dist/minting.d.ts +63 -0
  23. package/dist/minting.d.ts.map +1 -0
  24. package/dist/minting.js +194 -0
  25. package/dist/minting.js.map +1 -0
  26. package/dist/payloads.d.ts +120 -0
  27. package/dist/payloads.d.ts.map +1 -0
  28. package/dist/payloads.js +118 -0
  29. package/dist/payloads.js.map +1 -0
  30. package/dist/registry.d.ts +77 -0
  31. package/dist/registry.d.ts.map +1 -0
  32. package/dist/registry.js +173 -0
  33. package/dist/registry.js.map +1 -0
  34. package/dist/sdk.d.ts +158 -0
  35. package/dist/sdk.d.ts.map +1 -0
  36. package/dist/sdk.js +346 -0
  37. package/dist/sdk.js.map +1 -0
  38. package/dist/storage.d.ts +80 -0
  39. package/dist/storage.d.ts.map +1 -0
  40. package/dist/storage.js +284 -0
  41. package/dist/storage.js.map +1 -0
  42. package/dist/types.d.ts +278 -0
  43. package/dist/types.d.ts.map +1 -0
  44. package/dist/types.js +19 -0
  45. package/dist/types.js.map +1 -0
  46. package/package.json +64 -0
  47. package/src/credential-nft-server.ts +201 -0
  48. package/src/credential-nft.ts +64 -0
  49. package/src/encryption.ts +308 -0
  50. package/src/index.ts +151 -0
  51. package/src/metadata.ts +336 -0
  52. package/src/minting.ts +266 -0
  53. package/src/payloads.ts +238 -0
  54. package/src/registry.ts +236 -0
  55. package/src/sdk.ts +507 -0
  56. package/src/storage.ts +364 -0
  57. package/src/types.ts +318 -0
  58. package/wasm/README.md +33 -0
package/dist/sdk.js ADDED
@@ -0,0 +1,346 @@
1
+ /**
2
+ * Yallet RWA SDK - Main SDK Class
3
+ *
4
+ * High-level interface for minting encrypted RWA assets as Solana cNFTs
5
+ */
6
+ import { AssetType } from './types.js';
7
+ import { ECIESEncryptor, createWasmEncryptor, encryptAsset } from './encryption.js';
8
+ import { buildInvoicePayload, buildFilePayload, buildMessagePayload, buildPhotoPayload, } from './payloads.js';
9
+ import { uploadEncryptedAsset, uploadMetadata } from './storage.js';
10
+ import { generateNFTMetadata } from './metadata.js';
11
+ import { createMinter } from './minting.js';
12
+ import { InMemoryRegistry, createRegistry } from './registry.js';
13
+ // ======================================
14
+ // RWA SDK Class
15
+ // ======================================
16
+ export class YalletRWASDK {
17
+ config;
18
+ registry;
19
+ minter;
20
+ encryptor;
21
+ uploadOptions;
22
+ constructor(config, options = {}) {
23
+ this.config = config;
24
+ // Initialize registry
25
+ if (options.registry) {
26
+ if ('getUser' in options.registry) {
27
+ this.registry = options.registry;
28
+ }
29
+ else {
30
+ this.registry = createRegistry(options.registry);
31
+ }
32
+ }
33
+ else {
34
+ this.registry = new InMemoryRegistry();
35
+ }
36
+ // Initialize encryptor
37
+ if (options.wasmEncryptFn) {
38
+ this.encryptor = createWasmEncryptor(options.wasmEncryptFn);
39
+ }
40
+ else {
41
+ this.encryptor = new ECIESEncryptor();
42
+ }
43
+ // Initialize minter
44
+ this.minter = createMinter(config);
45
+ // Upload options
46
+ this.uploadOptions = {
47
+ network: config.network,
48
+ apiKey: config.arweaveApiKey,
49
+ endpoint: config.arweaveEndpoint,
50
+ ...options.uploadOptions,
51
+ };
52
+ }
53
+ // ======================================
54
+ // Configuration
55
+ // ======================================
56
+ /**
57
+ * Set the signer for minting transactions
58
+ *
59
+ * @param keypair - Umi keypair for signing
60
+ */
61
+ setSigner(keypair) {
62
+ this.minter.setSigner(keypair);
63
+ }
64
+ /**
65
+ * Set the Merkle tree configuration
66
+ *
67
+ * @param treeConfig - Tree configuration
68
+ */
69
+ setTreeConfig(treeConfig) {
70
+ this.minter.setTreeConfig(treeConfig);
71
+ }
72
+ /**
73
+ * Get the user registry
74
+ */
75
+ getRegistry() {
76
+ return this.registry;
77
+ }
78
+ // ======================================
79
+ // User Management
80
+ // ======================================
81
+ /**
82
+ * Register a user with their xidentity
83
+ *
84
+ * @param user - User to register
85
+ */
86
+ async registerUser(user) {
87
+ await this.registry.registerUser(user);
88
+ }
89
+ /**
90
+ * Get a registered user by Solana address
91
+ *
92
+ * @param solanaAddress - User's Solana address
93
+ * @returns Registered user or null
94
+ */
95
+ async getUser(solanaAddress) {
96
+ return this.registry.getUser(solanaAddress);
97
+ }
98
+ // ======================================
99
+ // Minting Methods
100
+ // ======================================
101
+ /**
102
+ * Mint an encrypted invoice to a recipient.
103
+ * Uses extension-compatible payload (invoice bundle) so the recipient's wallet can decrypt and display.
104
+ *
105
+ * @param invoice - Invoice data
106
+ * @param recipientAddress - Recipient's Solana address
107
+ * @param options - Name, description, and optional pdf/sender/recipient for extension compatibility
108
+ * @returns Mint result
109
+ */
110
+ async mintInvoice(invoice, recipientAddress, options = {}) {
111
+ const bundle = buildInvoicePayload(invoice, {
112
+ uuid: options.uuid,
113
+ pdfBase64: options.pdfBase64,
114
+ senderProfile: options.senderProfile,
115
+ recipientProfile: options.recipientProfile,
116
+ });
117
+ return this.mint({
118
+ assetType: AssetType.INVOICE,
119
+ assetData: bundle,
120
+ recipientAddress,
121
+ name: options.name || `Invoice #${invoice.invoiceId}`,
122
+ description: options.description,
123
+ uuid: options.uuid,
124
+ });
125
+ }
126
+ /**
127
+ * Mint an encrypted file to a recipient (extension-compatible payload).
128
+ */
129
+ async mintFile(file, recipientAddress, options = {}) {
130
+ const payload = buildFilePayload(file, { id: options.uuid });
131
+ return this.mint({
132
+ assetType: AssetType.FILE,
133
+ assetData: payload,
134
+ recipientAddress,
135
+ name: options.name || file.filename,
136
+ description: options.description,
137
+ uuid: options.uuid,
138
+ });
139
+ }
140
+ /**
141
+ * Mint an encrypted message/note to a recipient (extension-compatible payload, type always 'sent').
142
+ */
143
+ async mintMessage(note, recipientAddress, options = {}) {
144
+ const payload = buildMessagePayload(note, {
145
+ uuid: options.uuid,
146
+ recipientId: options.recipientId,
147
+ recipientName: options.recipientName,
148
+ replyTo: options.replyTo,
149
+ });
150
+ return this.mint({
151
+ assetType: AssetType.NOTE,
152
+ assetData: payload,
153
+ recipientAddress,
154
+ name: options.name || note.title,
155
+ description: options.description,
156
+ uuid: options.uuid,
157
+ });
158
+ }
159
+ /**
160
+ * Mint an encrypted picture/photo to a recipient (extension-compatible payload).
161
+ */
162
+ async mintPhoto(photo, recipientAddress, options = {}) {
163
+ const payload = buildPhotoPayload(photo, {
164
+ id: options.uuid,
165
+ thumbnail: options.thumbnail,
166
+ });
167
+ return this.mint({
168
+ assetType: AssetType.PHOTO,
169
+ assetData: payload,
170
+ recipientAddress,
171
+ name: options.name || photo.filename,
172
+ description: options.description,
173
+ uuid: options.uuid,
174
+ });
175
+ }
176
+ /**
177
+ * Mint an encrypted asset to a recipient
178
+ *
179
+ * This is the main minting method that handles the full flow:
180
+ * 1. Look up recipient's xidentity from registry
181
+ * 2. Encrypt asset with recipient's xidentity
182
+ * 3. Upload encrypted data to Arweave
183
+ * 4. Generate and upload NFT metadata
184
+ * 5. Mint cNFT to recipient
185
+ *
186
+ * @param request - Mint request
187
+ * @returns Mint result
188
+ */
189
+ async mint(request) {
190
+ const { assetType, assetData, recipientAddress, name, description, attributes = [],
191
+ // New fields
192
+ uuid, previousToken, schema, mimeType, dataSize, } = request;
193
+ try {
194
+ // 1. Look up recipient's xidentity
195
+ const recipient = await this.registry.getUser(recipientAddress);
196
+ if (!recipient) {
197
+ return {
198
+ success: false,
199
+ error: `Recipient not registered: ${recipientAddress}. User must register their xidentity first.`,
200
+ };
201
+ }
202
+ console.log(`[RWA SDK] Minting ${assetType} to ${recipientAddress}`);
203
+ // 2. Encrypt asset with recipient's xidentity
204
+ console.log('[RWA SDK] Encrypting asset...');
205
+ const encryptedPayload = await encryptAsset(assetData, assetType, recipient.xidentity, this.encryptor, { uuid, previousToken, schema });
206
+ // 3. Upload encrypted data to Arweave
207
+ console.log('[RWA SDK] Uploading encrypted data to Arweave...');
208
+ const dataUploadResult = await uploadEncryptedAsset(encryptedPayload, {
209
+ assetType,
210
+ direction: 'received',
211
+ network: this.config.network,
212
+ }, this.uploadOptions);
213
+ console.log('[RWA SDK] Encrypted data uploaded:', dataUploadResult.id);
214
+ // 4. Generate NFT metadata with new fields
215
+ const nftMetadata = generateNFTMetadata({
216
+ name,
217
+ description,
218
+ assetType,
219
+ encryptedDataUri: dataUploadResult.arweaveUri,
220
+ owner: recipientAddress,
221
+ direction: 'received',
222
+ additionalAttributes: attributes,
223
+ // New fields from encryption result
224
+ uuid: encryptedPayload.uuid,
225
+ timestamp: Math.floor(encryptedPayload.timestamp / 1000), // Convert to seconds
226
+ previousToken,
227
+ schema,
228
+ mimeType,
229
+ dataSize: dataSize || encryptedPayload.dataSize,
230
+ });
231
+ // 5. Upload metadata to Arweave
232
+ console.log('[RWA SDK] Uploading metadata to Arweave...');
233
+ const metadataUploadResult = await uploadMetadata(nftMetadata, this.uploadOptions);
234
+ console.log('[RWA SDK] Metadata uploaded:', metadataUploadResult.id);
235
+ // 6. Mint cNFT
236
+ console.log('[RWA SDK] Minting cNFT...');
237
+ const mintResult = await this.minter.mint({
238
+ metadataUri: metadataUploadResult.arweaveUri,
239
+ name,
240
+ recipient: recipientAddress,
241
+ });
242
+ if (!mintResult.success) {
243
+ return { ...mintResult, uuid: encryptedPayload.uuid };
244
+ }
245
+ console.log('[RWA SDK] cNFT minted successfully!');
246
+ return {
247
+ success: true,
248
+ assetId: mintResult.assetId,
249
+ signature: mintResult.signature,
250
+ arweaveTxId: dataUploadResult.id,
251
+ metadataArweaveTxId: metadataUploadResult.id,
252
+ uuid: encryptedPayload.uuid,
253
+ };
254
+ }
255
+ catch (err) {
256
+ const errorMessage = err instanceof Error ? err.message : 'Unknown error';
257
+ console.error('[RWA SDK] Minting failed:', errorMessage);
258
+ return {
259
+ success: false,
260
+ error: errorMessage,
261
+ };
262
+ }
263
+ }
264
+ // ======================================
265
+ // Batch Minting
266
+ // ======================================
267
+ /**
268
+ * Mint multiple invoices to different recipients
269
+ *
270
+ * @param invoices - Array of invoice requests
271
+ * @returns Array of mint results
272
+ */
273
+ async mintInvoiceBatch(invoices) {
274
+ const results = [];
275
+ for (const item of invoices) {
276
+ const result = await this.mintInvoice(item.invoice, item.recipientAddress, { name: item.name });
277
+ results.push(result);
278
+ }
279
+ return results;
280
+ }
281
+ // ======================================
282
+ // Utility Methods
283
+ // ======================================
284
+ /**
285
+ * Check if a user is registered
286
+ *
287
+ * @param solanaAddress - User's Solana address
288
+ * @returns true if registered
289
+ */
290
+ async isUserRegistered(solanaAddress) {
291
+ const user = await this.registry.getUser(solanaAddress);
292
+ return user !== null;
293
+ }
294
+ /**
295
+ * Get the current tree configuration
296
+ */
297
+ async getTreeConfig() {
298
+ return this.minter.getTreeConfig();
299
+ }
300
+ /**
301
+ * Encrypt and upload without minting
302
+ * Useful for testing or when you want to handle minting separately
303
+ *
304
+ * @param assetData - Asset data to encrypt
305
+ * @param assetType - Type of asset
306
+ * @param recipientXidentity - Recipient's xidentity (base64)
307
+ * @returns Upload results
308
+ */
309
+ async encryptAndUpload(assetData, assetType, recipientXidentity) {
310
+ // Encrypt
311
+ const encryptedPayload = await encryptAsset(assetData, assetType, recipientXidentity, this.encryptor);
312
+ // Upload encrypted data
313
+ const dataUploadResult = await uploadEncryptedAsset(encryptedPayload, {
314
+ assetType,
315
+ direction: 'received',
316
+ network: this.config.network,
317
+ }, this.uploadOptions);
318
+ // Generate and upload metadata
319
+ const nftMetadata = generateNFTMetadata({
320
+ name: `Encrypted ${assetType}`,
321
+ assetType,
322
+ encryptedDataUri: dataUploadResult.arweaveUri,
323
+ owner: 'pending', // Will be set during minting
324
+ direction: 'received',
325
+ });
326
+ const metadataUploadResult = await uploadMetadata(nftMetadata, this.uploadOptions);
327
+ return {
328
+ encryptedDataUri: dataUploadResult.arweaveUri,
329
+ metadataUri: metadataUploadResult.arweaveUri,
330
+ };
331
+ }
332
+ }
333
+ // ======================================
334
+ // Factory Function
335
+ // ======================================
336
+ /**
337
+ * Create a new RWA SDK instance
338
+ *
339
+ * @param config - SDK configuration
340
+ * @param options - Additional options
341
+ * @returns YalletRWASDK instance
342
+ */
343
+ export function createRWASDK(config, options) {
344
+ return new YalletRWASDK(config, options);
345
+ }
346
+ //# sourceMappingURL=sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgBH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpF,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAsB,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAA2B,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAc,YAAY,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAwB,MAAM,eAAe,CAAC;AAGvF,yCAAyC;AACzC,iBAAiB;AACjB,yC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
5
+ */
6
+ import type { EncryptedPayload, AssetType } from './types.js';
7
+ export interface UploadOptions {
8
+ /** Arweave API key (for ArDrive Turbo uploads) */
9
+ apiKey?: string;
10
+ /** Network: mainnet or devnet */
11
+ network?: 'mainnet' | 'devnet';
12
+ /** Custom endpoint */
13
+ endpoint?: string;
14
+ /** Content type */
15
+ contentType?: string;
16
+ /** Custom tags */
17
+ tags?: Record<string, string>;
18
+ }
19
+ export interface UploadResult {
20
+ /** Arweave transaction ID */
21
+ id: string;
22
+ /** Full Arweave URL */
23
+ url: string;
24
+ /** ar:// URI */
25
+ arweaveUri: string;
26
+ /** Upload timestamp */
27
+ timestamp: number;
28
+ }
29
+ /**
30
+ * Upload data to Arweave.
31
+ * Default: POST to Yallet backend (api.yallet.xyz → backend ArDrive Turbo).
32
+ * If options.endpoint is set to an Irys URL (e.g. turbo.irys.xyz), uses direct Irys /tx instead.
33
+ *
34
+ * @param data - Data to upload (string or Uint8Array)
35
+ * @param options - Upload options
36
+ * @returns Upload result with transaction ID
37
+ */
38
+ export declare function uploadToArweave(data: string | Uint8Array, options?: UploadOptions): Promise<UploadResult>;
39
+ /**
40
+ * Upload encrypted asset to Arweave
41
+ *
42
+ * @param encryptedPayload - Encrypted asset data (with extended fields)
43
+ * @param metadata - Additional metadata
44
+ * @param options - Upload options
45
+ * @returns Upload result
46
+ */
47
+ export declare function uploadEncryptedAsset(encryptedPayload: EncryptedPayload & {
48
+ assetType: AssetType;
49
+ version: number;
50
+ uuid?: string;
51
+ timestamp?: number;
52
+ dataSize?: number;
53
+ }, metadata: {
54
+ assetType: AssetType;
55
+ direction?: 'owned' | 'sent' | 'received';
56
+ network?: 'mainnet' | 'devnet';
57
+ }, options?: UploadOptions): Promise<UploadResult>;
58
+ /**
59
+ * Upload NFT metadata to Arweave
60
+ *
61
+ * @param metadata - NFT metadata object
62
+ * @param options - Upload options
63
+ * @returns Upload result
64
+ */
65
+ export declare function uploadMetadata(metadata: Record<string, unknown>, options?: UploadOptions): Promise<UploadResult>;
66
+ /**
67
+ * Download data from Arweave
68
+ *
69
+ * @param txIdOrUri - Transaction ID or ar:// URI
70
+ * @returns Fetched data
71
+ */
72
+ export declare function downloadFromArweave(txIdOrUri: string): Promise<Response>;
73
+ /**
74
+ * Download and parse JSON from Arweave
75
+ *
76
+ * @param txIdOrUri - Transaction ID or ar:// URI
77
+ * @returns Parsed JSON
78
+ */
79
+ export declare function downloadJsonFromArweave<T = unknown>(txIdOrUri: string): Promise<T>;
80
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAkG9D,MAAM,WAAW,aAAa;IAC5B,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,OAAO,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC/B,sBAAsB;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,YAAY;IAC3B,6BAA6B;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,uBAAuB;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,uBAAuB;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,GAAG,UAAU,EACzB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAqFvB;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,gBAAgB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