@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.
- package/README.md +365 -0
- package/dist/credential-nft-server.d.ts +75 -0
- package/dist/credential-nft-server.d.ts.map +1 -0
- package/dist/credential-nft-server.js +122 -0
- package/dist/credential-nft-server.js.map +1 -0
- package/dist/credential-nft.d.ts +31 -0
- package/dist/credential-nft.d.ts.map +1 -0
- package/dist/credential-nft.js +38 -0
- package/dist/credential-nft.js.map +1 -0
- package/dist/encryption.d.ts +107 -0
- package/dist/encryption.d.ts.map +1 -0
- package/dist/encryption.js +176 -0
- package/dist/encryption.js.map +1 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/dist/metadata.d.ts +161 -0
- package/dist/metadata.d.ts.map +1 -0
- package/dist/metadata.js +180 -0
- package/dist/metadata.js.map +1 -0
- package/dist/minting.d.ts +63 -0
- package/dist/minting.d.ts.map +1 -0
- package/dist/minting.js +194 -0
- package/dist/minting.js.map +1 -0
- package/dist/payloads.d.ts +120 -0
- package/dist/payloads.d.ts.map +1 -0
- package/dist/payloads.js +118 -0
- package/dist/payloads.js.map +1 -0
- package/dist/registry.d.ts +77 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +173 -0
- package/dist/registry.js.map +1 -0
- package/dist/sdk.d.ts +158 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/sdk.js +346 -0
- package/dist/sdk.js.map +1 -0
- package/dist/storage.d.ts +80 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +284 -0
- package/dist/storage.js.map +1 -0
- package/dist/types.d.ts +278 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -0
- package/package.json +64 -0
- package/src/credential-nft-server.ts +201 -0
- package/src/credential-nft.ts +64 -0
- package/src/encryption.ts +308 -0
- package/src/index.ts +151 -0
- package/src/metadata.ts +336 -0
- package/src/minting.ts +266 -0
- package/src/payloads.ts +238 -0
- package/src/registry.ts +236 -0
- package/src/sdk.ts +507 -0
- package/src/storage.ts +364 -0
- package/src/types.ts +318 -0
- package/wasm/README.md +33 -0
package/dist/payloads.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Yallet RWA SDK - Payload builders
|
|
3
|
+
*
|
|
4
|
+
* Build JSON payloads that match chrome-extension decryption expectations
|
|
5
|
+
* for invoice / statements / receipts / files / messages / pictures.
|
|
6
|
+
*/
|
|
7
|
+
// ======================================
|
|
8
|
+
// Helpers
|
|
9
|
+
// ======================================
|
|
10
|
+
function toExtensionLineItems(items) {
|
|
11
|
+
if (!items?.length)
|
|
12
|
+
return [];
|
|
13
|
+
return items.map((li) => ({
|
|
14
|
+
name: li.name ?? li.description,
|
|
15
|
+
price: li.unitPrice ?? 0,
|
|
16
|
+
qty: li.qty ?? li.quantity,
|
|
17
|
+
unit: li.unit ?? 'units',
|
|
18
|
+
total: li.total ?? li.amount ?? (li.quantity * (li.unitPrice ?? 0)),
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
// ======================================
|
|
22
|
+
// Payload builders
|
|
23
|
+
// ======================================
|
|
24
|
+
/**
|
|
25
|
+
* Build invoice payload bundle for minting.
|
|
26
|
+
* Matches chrome-extension format so the extension can decrypt and display.
|
|
27
|
+
*/
|
|
28
|
+
export function buildInvoicePayload(invoice, options) {
|
|
29
|
+
const lineItems = toExtensionLineItems(invoice.items);
|
|
30
|
+
const subtotal = invoice.subtotal ?? invoice.amount ?? 0;
|
|
31
|
+
const total = invoice.total ?? invoice.amount ?? subtotal;
|
|
32
|
+
const extensionInvoice = {
|
|
33
|
+
id: options?.id,
|
|
34
|
+
uuid: options?.uuid,
|
|
35
|
+
invoiceNo: invoice.invoiceId,
|
|
36
|
+
type: 'sent',
|
|
37
|
+
status: 'submitted',
|
|
38
|
+
billTo: invoice.billTo,
|
|
39
|
+
poNo: invoice.poNo,
|
|
40
|
+
dueDate: invoice.dueDate,
|
|
41
|
+
lineItems,
|
|
42
|
+
discountRate: invoice.discountRate ?? 0,
|
|
43
|
+
discountAmount: invoice.discountAmount,
|
|
44
|
+
taxRate: invoice.taxRate ?? 0,
|
|
45
|
+
subtotal,
|
|
46
|
+
taxAmount: invoice.taxAmount,
|
|
47
|
+
total,
|
|
48
|
+
currency: invoice.currency,
|
|
49
|
+
paymentMethod: invoice.paymentMethod,
|
|
50
|
+
paymentTerms: invoice.paymentTerms,
|
|
51
|
+
notePayee: invoice.notePayee ?? invoice.notes,
|
|
52
|
+
createdAt: invoice.date ?? new Date().toISOString(),
|
|
53
|
+
};
|
|
54
|
+
const bundle = {
|
|
55
|
+
invoice: extensionInvoice,
|
|
56
|
+
};
|
|
57
|
+
if (options?.pdfBase64)
|
|
58
|
+
bundle.pdf = options.pdfBase64;
|
|
59
|
+
if (options?.senderProfile)
|
|
60
|
+
bundle.senderProfile = options.senderProfile;
|
|
61
|
+
if (options?.recipientProfile)
|
|
62
|
+
bundle.recipientProfile = options.recipientProfile;
|
|
63
|
+
return bundle;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Build file payload for minting.
|
|
67
|
+
* Matches chrome-extension format (name, fileData base64, type, size).
|
|
68
|
+
*/
|
|
69
|
+
export function buildFilePayload(file, options) {
|
|
70
|
+
return {
|
|
71
|
+
id: options?.id,
|
|
72
|
+
name: file.filename,
|
|
73
|
+
originalName: file.filename,
|
|
74
|
+
description: file.metadata?.description,
|
|
75
|
+
tag: null,
|
|
76
|
+
size: file.size,
|
|
77
|
+
type: file.mimeType,
|
|
78
|
+
fileData: file.content,
|
|
79
|
+
createdAt: file.metadata?.createdAt ?? new Date().toISOString(),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Build message/note payload for minting.
|
|
84
|
+
* Matches chrome-extension format (title, content, replyTo). Type is always 'sent' (institution sends to users).
|
|
85
|
+
*/
|
|
86
|
+
export function buildMessagePayload(note, options) {
|
|
87
|
+
return {
|
|
88
|
+
id: options?.id,
|
|
89
|
+
uuid: options?.uuid,
|
|
90
|
+
title: note.title,
|
|
91
|
+
content: note.content,
|
|
92
|
+
tag: note.tags?.length ? note.tags.join(', ') : null,
|
|
93
|
+
type: 'sent',
|
|
94
|
+
recipientId: options?.recipientId ?? null,
|
|
95
|
+
recipientName: options?.recipientName ?? null,
|
|
96
|
+
replyTo: options?.replyTo ?? null,
|
|
97
|
+
createdAt: note.metadata?.createdAt ?? new Date().toISOString(),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Build picture/photo payload for minting.
|
|
102
|
+
* Matches chrome-extension format (imageData base64, mimeType, name).
|
|
103
|
+
*/
|
|
104
|
+
export function buildPhotoPayload(photo, options) {
|
|
105
|
+
const dataUrl = options?.dataUrl ?? (photo.content ? `data:${photo.mimeType};base64,${photo.content}` : undefined);
|
|
106
|
+
return {
|
|
107
|
+
id: options?.id,
|
|
108
|
+
name: photo.filename,
|
|
109
|
+
description: photo.metadata?.description,
|
|
110
|
+
tag: null,
|
|
111
|
+
imageData: photo.content,
|
|
112
|
+
mimeType: photo.mimeType,
|
|
113
|
+
dataUrl,
|
|
114
|
+
thumbnail: options?.thumbnail,
|
|
115
|
+
createdAt: photo.metadata?.createdAt ?? new Date().toISOString(),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=payloads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payloads.js","sourceRoot":"","sources":["../src/payloads.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA8FH,yCAAyC;AACzC,WAAW;AACX,yCAAyC;AAEzC,SAAS,oBAAoB,CAAC,KAAgC;IAC5D,IAAI,CAAC,KAAK,EAAE,MAAM;QAAE,OAAO,EAAE,CAAC;IAC9B,OAAO,KAAK,CAAC,GAAG,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 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Yallet RWA SDK - User Registry Module
|
|
3
|
+
*
|
|
4
|
+
* Manages registered users with their xidentity public keys
|
|
5
|
+
*/
|
|
6
|
+
import type { RegisteredUser, UserRegistry } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Simple in-memory user registry
|
|
9
|
+
* For production, implement a database-backed registry
|
|
10
|
+
*/
|
|
11
|
+
export declare class InMemoryRegistry implements UserRegistry {
|
|
12
|
+
private users;
|
|
13
|
+
getUser(solanaAddress: string): Promise<RegisteredUser | null>;
|
|
14
|
+
registerUser(user: RegisteredUser): Promise<void>;
|
|
15
|
+
updateUser(solanaAddress: string, updates: Partial<RegisteredUser>): Promise<void>;
|
|
16
|
+
deleteUser(solanaAddress: string): Promise<void>;
|
|
17
|
+
listUsers(): Promise<RegisteredUser[]>;
|
|
18
|
+
}
|
|
19
|
+
export interface HTTPRegistryConfig {
|
|
20
|
+
/** Base URL of the registry API */
|
|
21
|
+
baseUrl: string;
|
|
22
|
+
/** API key for authentication */
|
|
23
|
+
apiKey?: string;
|
|
24
|
+
/** Custom headers */
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* HTTP-backed user registry
|
|
29
|
+
* Connects to a backend API for user management
|
|
30
|
+
*/
|
|
31
|
+
export declare class HTTPRegistry implements UserRegistry {
|
|
32
|
+
private config;
|
|
33
|
+
constructor(config: HTTPRegistryConfig);
|
|
34
|
+
private fetch;
|
|
35
|
+
getUser(solanaAddress: string): Promise<RegisteredUser | null>;
|
|
36
|
+
registerUser(user: RegisteredUser): Promise<void>;
|
|
37
|
+
updateUser(solanaAddress: string, updates: Partial<RegisteredUser>): Promise<void>;
|
|
38
|
+
deleteUser(solanaAddress: string): Promise<void>;
|
|
39
|
+
listUsers(): Promise<RegisteredUser[]>;
|
|
40
|
+
}
|
|
41
|
+
export type RegistryType = 'memory' | 'http';
|
|
42
|
+
export interface RegistryOptions {
|
|
43
|
+
type: RegistryType;
|
|
44
|
+
httpConfig?: HTTPRegistryConfig;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create a user registry instance
|
|
48
|
+
*
|
|
49
|
+
* @param options - Registry options
|
|
50
|
+
* @returns UserRegistry instance
|
|
51
|
+
*/
|
|
52
|
+
export declare function createRegistry(options: RegistryOptions): UserRegistry;
|
|
53
|
+
/**
|
|
54
|
+
* Validate a Solana address
|
|
55
|
+
*
|
|
56
|
+
* @param address - Address to validate
|
|
57
|
+
* @returns true if valid
|
|
58
|
+
*/
|
|
59
|
+
export declare function isValidSolanaAddress(address: string): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Validate an xidentity public key (base64)
|
|
62
|
+
*
|
|
63
|
+
* @param xidentity - xidentity to validate
|
|
64
|
+
* @returns true if valid
|
|
65
|
+
*/
|
|
66
|
+
export declare function isValidXidentity(xidentity: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Validate a registered user
|
|
69
|
+
*
|
|
70
|
+
* @param user - User to validate
|
|
71
|
+
* @returns Validation result
|
|
72
|
+
*/
|
|
73
|
+
export declare function validateUser(user: Partial<RegisteredUser>): {
|
|
74
|
+
valid: boolean;
|
|
75
|
+
errors: string[];
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM/D;;;GAGG;AACH,qBAAa,gBAAiB,YAAW,YAAY;IACnD,OAAO,CAAC,KAAK,CAA0C;IAEjD,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAI9D,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAA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MAAM,GAAG,OAAO,CAI7D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAS3D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG;IAC3D,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAmBA"}
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Yallet RWA SDK - User Registry Module
|
|
3
|
+
*
|
|
4
|
+
* Manages registered users with their xidentity public keys
|
|
5
|
+
*/
|
|
6
|
+
// ======================================
|
|
7
|
+
// In-Memory Registry (For Development)
|
|
8
|
+
// ======================================
|
|
9
|
+
/**
|
|
10
|
+
* Simple in-memory user registry
|
|
11
|
+
* For production, implement a database-backed registry
|
|
12
|
+
*/
|
|
13
|
+
export class InMemoryRegistry {
|
|
14
|
+
users = new Map();
|
|
15
|
+
async getUser(solanaAddress) {
|
|
16
|
+
return this.users.get(solanaAddress) || null;
|
|
17
|
+
}
|
|
18
|
+
async registerUser(user) {
|
|
19
|
+
this.users.set(user.solanaAddress, {
|
|
20
|
+
...user,
|
|
21
|
+
registeredAt: user.registeredAt || Date.now(),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
async updateUser(solanaAddress, updates) {
|
|
25
|
+
const existing = this.users.get(solanaAddress);
|
|
26
|
+
if (!existing) {
|
|
27
|
+
throw new Error(`User not found: ${solanaAddress}`);
|
|
28
|
+
}
|
|
29
|
+
this.users.set(solanaAddress, { ...existing, ...updates });
|
|
30
|
+
}
|
|
31
|
+
async deleteUser(solanaAddress) {
|
|
32
|
+
this.users.delete(solanaAddress);
|
|
33
|
+
}
|
|
34
|
+
async listUsers() {
|
|
35
|
+
return Array.from(this.users.values());
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* HTTP-backed user registry
|
|
40
|
+
* Connects to a backend API for user management
|
|
41
|
+
*/
|
|
42
|
+
export class HTTPRegistry {
|
|
43
|
+
config;
|
|
44
|
+
constructor(config) {
|
|
45
|
+
this.config = config;
|
|
46
|
+
}
|
|
47
|
+
async fetch(path, options = {}) {
|
|
48
|
+
const url = `${this.config.baseUrl}${path}`;
|
|
49
|
+
const headers = {
|
|
50
|
+
'Content-Type': 'application/json',
|
|
51
|
+
...this.config.headers,
|
|
52
|
+
};
|
|
53
|
+
if (this.config.apiKey) {
|
|
54
|
+
headers['Authorization'] = `Bearer ${this.config.apiKey}`;
|
|
55
|
+
}
|
|
56
|
+
const response = await fetch(url, {
|
|
57
|
+
...options,
|
|
58
|
+
headers: { ...headers, ...options.headers },
|
|
59
|
+
});
|
|
60
|
+
if (!response.ok) {
|
|
61
|
+
const error = await response.text();
|
|
62
|
+
throw new Error(`Registry API error: ${response.status} - ${error}`);
|
|
63
|
+
}
|
|
64
|
+
return response.json();
|
|
65
|
+
}
|
|
66
|
+
async getUser(solanaAddress) {
|
|
67
|
+
try {
|
|
68
|
+
return await this.fetch(`/users/${encodeURIComponent(solanaAddress)}`);
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
if (err instanceof Error && err.message.includes('404')) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
throw err;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async registerUser(user) {
|
|
78
|
+
await this.fetch('/users', {
|
|
79
|
+
method: 'POST',
|
|
80
|
+
body: JSON.stringify(user),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async updateUser(solanaAddress, updates) {
|
|
84
|
+
await this.fetch(`/users/${encodeURIComponent(solanaAddress)}`, {
|
|
85
|
+
method: 'PATCH',
|
|
86
|
+
body: JSON.stringify(updates),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async deleteUser(solanaAddress) {
|
|
90
|
+
await this.fetch(`/users/${encodeURIComponent(solanaAddress)}`, {
|
|
91
|
+
method: 'DELETE',
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
async listUsers() {
|
|
95
|
+
return this.fetch('/users');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Create a user registry instance
|
|
100
|
+
*
|
|
101
|
+
* @param options - Registry options
|
|
102
|
+
* @returns UserRegistry instance
|
|
103
|
+
*/
|
|
104
|
+
export function createRegistry(options) {
|
|
105
|
+
switch (options.type) {
|
|
106
|
+
case 'memory':
|
|
107
|
+
return new InMemoryRegistry();
|
|
108
|
+
case 'http':
|
|
109
|
+
if (!options.httpConfig) {
|
|
110
|
+
throw new Error('httpConfig is required for HTTP registry');
|
|
111
|
+
}
|
|
112
|
+
return new HTTPRegistry(options.httpConfig);
|
|
113
|
+
default:
|
|
114
|
+
throw new Error(`Unknown registry type: ${options.type}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// ======================================
|
|
118
|
+
// Validation Helpers
|
|
119
|
+
// ======================================
|
|
120
|
+
/**
|
|
121
|
+
* Validate a Solana address
|
|
122
|
+
*
|
|
123
|
+
* @param address - Address to validate
|
|
124
|
+
* @returns true if valid
|
|
125
|
+
*/
|
|
126
|
+
export function isValidSolanaAddress(address) {
|
|
127
|
+
// Basic validation: 32-44 characters, base58
|
|
128
|
+
const base58Regex = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
129
|
+
return base58Regex.test(address);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Validate an xidentity public key (base64)
|
|
133
|
+
*
|
|
134
|
+
* @param xidentity - xidentity to validate
|
|
135
|
+
* @returns true if valid
|
|
136
|
+
*/
|
|
137
|
+
export function isValidXidentity(xidentity) {
|
|
138
|
+
// Check if it's valid base64
|
|
139
|
+
try {
|
|
140
|
+
const decoded = atob(xidentity);
|
|
141
|
+
// X25519 public key should be 32 bytes
|
|
142
|
+
return decoded.length === 32;
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Validate a registered user
|
|
150
|
+
*
|
|
151
|
+
* @param user - User to validate
|
|
152
|
+
* @returns Validation result
|
|
153
|
+
*/
|
|
154
|
+
export function validateUser(user) {
|
|
155
|
+
const errors = [];
|
|
156
|
+
if (!user.solanaAddress) {
|
|
157
|
+
errors.push('solanaAddress is required');
|
|
158
|
+
}
|
|
159
|
+
else if (!isValidSolanaAddress(user.solanaAddress)) {
|
|
160
|
+
errors.push('Invalid Solana address format');
|
|
161
|
+
}
|
|
162
|
+
if (!user.xidentity) {
|
|
163
|
+
errors.push('xidentity is required');
|
|
164
|
+
}
|
|
165
|
+
else if (!isValidXidentity(user.xidentity)) {
|
|
166
|
+
errors.push('Invalid xidentity format (must be base64-encoded 32-byte key)');
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
valid: errors.length === 0,
|
|
170
|
+
errors,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,yCAAyC;AACzC,wCAAwC;AACxC,yCAAyC;AAEzC;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IACnB,KAAK,GAAgC,IAAI,GAAG,EAAE,CAAC;IAEvD,KAAK,CAAC,OAAO,CAAC,aAAqB;QACjC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,IAAoB;QACrC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE;YACjC,GAAG,IAAI;YACP,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,GAAG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I,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAC3C,CAAC;SAAM,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QACrD,MAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACvC,CAAC;SAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7C,MAAM,CAAC,IAAI,CAAC,+DAA+D,CAAC,CAAC;IAC/E,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM;KACP,CAAC;AACJ,CAAC"}
|
package/dist/sdk.d.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Yallet RWA SDK - Main SDK Class
|
|
3
|
+
*
|
|
4
|
+
* High-level interface for minting encrypted RWA assets as Solana cNFTs
|
|
5
|
+
*/
|
|
6
|
+
import type { SDKConfig, MintRequest, MintResult, RegisteredUser, UserRegistry, InvoiceData, NoteData, FileData, PhotoData, EncryptFunction, TreeConfig } from './types.js';
|
|
7
|
+
import { AssetType } from './types.js';
|
|
8
|
+
import { type UploadOptions } from './storage.js';
|
|
9
|
+
import { type RegistryOptions } from './registry.js';
|
|
10
|
+
import type { Keypair } from '@metaplex-foundation/umi';
|
|
11
|
+
export declare class YalletRWASDK {
|
|
12
|
+
private config;
|
|
13
|
+
private registry;
|
|
14
|
+
private minter;
|
|
15
|
+
private encryptor;
|
|
16
|
+
private uploadOptions;
|
|
17
|
+
constructor(config: SDKConfig, options?: {
|
|
18
|
+
registry?: UserRegistry | RegistryOptions;
|
|
19
|
+
wasmEncryptFn?: EncryptFunction;
|
|
20
|
+
uploadOptions?: UploadOptions;
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Set the signer for minting transactions
|
|
24
|
+
*
|
|
25
|
+
* @param keypair - Umi keypair for signing
|
|
26
|
+
*/
|
|
27
|
+
setSigner(keypair: Keypair): void;
|
|
28
|
+
/**
|
|
29
|
+
* Set the Merkle tree configuration
|
|
30
|
+
*
|
|
31
|
+
* @param treeConfig - Tree configuration
|
|
32
|
+
*/
|
|
33
|
+
setTreeConfig(treeConfig: TreeConfig): void;
|
|
34
|
+
/**
|
|
35
|
+
* Get the user registry
|
|
36
|
+
*/
|
|
37
|
+
getRegistry(): UserRegistry;
|
|
38
|
+
/**
|
|
39
|
+
* Register a user with their xidentity
|
|
40
|
+
*
|
|
41
|
+
* @param user - User to register
|
|
42
|
+
*/
|
|
43
|
+
registerUser(user: RegisteredUser): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Get a registered user by Solana address
|
|
46
|
+
*
|
|
47
|
+
* @param solanaAddress - User's Solana address
|
|
48
|
+
* @returns Registered user or null
|
|
49
|
+
*/
|
|
50
|
+
getUser(solanaAddress: string): Promise<RegisteredUser | null>;
|
|
51
|
+
/**
|
|
52
|
+
* Mint an encrypted invoice to a recipient.
|
|
53
|
+
* Uses extension-compatible payload (invoice bundle) so the recipient's wallet can decrypt and display.
|
|
54
|
+
*
|
|
55
|
+
* @param invoice - Invoice data
|
|
56
|
+
* @param recipientAddress - Recipient's Solana address
|
|
57
|
+
* @param options - Name, description, and optional pdf/sender/recipient for extension compatibility
|
|
58
|
+
* @returns Mint result
|
|
59
|
+
*/
|
|
60
|
+
mintInvoice(invoice: InvoiceData, recipientAddress: string, options?: {
|
|
61
|
+
name?: string;
|
|
62
|
+
description?: string;
|
|
63
|
+
pdfBase64?: string;
|
|
64
|
+
senderProfile?: Record<string, unknown>;
|
|
65
|
+
recipientProfile?: Record<string, unknown>;
|
|
66
|
+
uuid?: string;
|
|
67
|
+
}): Promise<MintResult>;
|
|
68
|
+
/**
|
|
69
|
+
* Mint an encrypted file to a recipient (extension-compatible payload).
|
|
70
|
+
*/
|
|
71
|
+
mintFile(file: FileData, recipientAddress: string, options?: {
|
|
72
|
+
name?: string;
|
|
73
|
+
description?: string;
|
|
74
|
+
uuid?: string;
|
|
75
|
+
}): Promise<MintResult>;
|
|
76
|
+
/**
|
|
77
|
+
* Mint an encrypted message/note to a recipient (extension-compatible payload, type always 'sent').
|
|
78
|
+
*/
|
|
79
|
+
mintMessage(note: NoteData, recipientAddress: string, options?: {
|
|
80
|
+
name?: string;
|
|
81
|
+
description?: string;
|
|
82
|
+
uuid?: string;
|
|
83
|
+
recipientId?: string | null;
|
|
84
|
+
recipientName?: string | null;
|
|
85
|
+
replyTo?: string | null;
|
|
86
|
+
}): Promise<MintResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Mint an encrypted picture/photo to a recipient (extension-compatible payload).
|
|
89
|
+
*/
|
|
90
|
+
mintPhoto(photo: PhotoData, recipientAddress: string, options?: {
|
|
91
|
+
name?: string;
|
|
92
|
+
description?: string;
|
|
93
|
+
uuid?: string;
|
|
94
|
+
thumbnail?: string;
|
|
95
|
+
}): Promise<MintResult>;
|
|
96
|
+
/**
|
|
97
|
+
* Mint an encrypted asset to a recipient
|
|
98
|
+
*
|
|
99
|
+
* This is the main minting method that handles the full flow:
|
|
100
|
+
* 1. Look up recipient's xidentity from registry
|
|
101
|
+
* 2. Encrypt asset with recipient's xidentity
|
|
102
|
+
* 3. Upload encrypted data to Arweave
|
|
103
|
+
* 4. Generate and upload NFT metadata
|
|
104
|
+
* 5. Mint cNFT to recipient
|
|
105
|
+
*
|
|
106
|
+
* @param request - Mint request
|
|
107
|
+
* @returns Mint result
|
|
108
|
+
*/
|
|
109
|
+
mint(request: MintRequest): Promise<MintResult>;
|
|
110
|
+
/**
|
|
111
|
+
* Mint multiple invoices to different recipients
|
|
112
|
+
*
|
|
113
|
+
* @param invoices - Array of invoice requests
|
|
114
|
+
* @returns Array of mint results
|
|
115
|
+
*/
|
|
116
|
+
mintInvoiceBatch(invoices: Array<{
|
|
117
|
+
invoice: InvoiceData;
|
|
118
|
+
recipientAddress: string;
|
|
119
|
+
name?: string;
|
|
120
|
+
}>): Promise<MintResult[]>;
|
|
121
|
+
/**
|
|
122
|
+
* Check if a user is registered
|
|
123
|
+
*
|
|
124
|
+
* @param solanaAddress - User's Solana address
|
|
125
|
+
* @returns true if registered
|
|
126
|
+
*/
|
|
127
|
+
isUserRegistered(solanaAddress: string): Promise<boolean>;
|
|
128
|
+
/**
|
|
129
|
+
* Get the current tree configuration
|
|
130
|
+
*/
|
|
131
|
+
getTreeConfig(): Promise<TreeConfig | null>;
|
|
132
|
+
/**
|
|
133
|
+
* Encrypt and upload without minting
|
|
134
|
+
* Useful for testing or when you want to handle minting separately
|
|
135
|
+
*
|
|
136
|
+
* @param assetData - Asset data to encrypt
|
|
137
|
+
* @param assetType - Type of asset
|
|
138
|
+
* @param recipientXidentity - Recipient's xidentity (base64)
|
|
139
|
+
* @returns Upload results
|
|
140
|
+
*/
|
|
141
|
+
encryptAndUpload(assetData: unknown, assetType: AssetType, recipientXidentity: string): Promise<{
|
|
142
|
+
encryptedDataUri: string;
|
|
143
|
+
metadataUri: string;
|
|
144
|
+
}>;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Create a new RWA SDK instance
|
|
148
|
+
*
|
|
149
|
+
* @param config - SDK configuration
|
|
150
|
+
* @param options - Additional options
|
|
151
|
+
* @returns YalletRWASDK instance
|
|
152
|
+
*/
|
|
153
|
+
export declare function createRWASDK(config: SDKConfig, options?: {
|
|
154
|
+
registry?: UserRegistry | RegistryOptions;
|
|
155
|
+
wasmEncryptFn?: EncryptFunction;
|
|
156
|
+
uploadOptions?: UploadOptions;
|
|
157
|
+
}): YalletRWASDK;
|
|
158
|
+
//# sourceMappingURL=sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"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