@amadeus-protocol/sdk 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/LICENSE +21 -0
- package/README.md +410 -0
- package/dist/api/chain.d.ts +119 -0
- package/dist/api/chain.d.ts.map +1 -0
- package/dist/api/chain.js +147 -0
- package/dist/api/chain.js.map +1 -0
- package/dist/api/contract.d.ts +62 -0
- package/dist/api/contract.d.ts.map +1 -0
- package/dist/api/contract.js +76 -0
- package/dist/api/contract.js.map +1 -0
- package/dist/api/epoch.d.ts +68 -0
- package/dist/api/epoch.d.ts.map +1 -0
- package/dist/api/epoch.js +99 -0
- package/dist/api/epoch.js.map +1 -0
- package/dist/api/index.d.ts +8 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +8 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/peer.d.ts +80 -0
- package/dist/api/peer.d.ts.map +1 -0
- package/dist/api/peer.js +95 -0
- package/dist/api/peer.js.map +1 -0
- package/dist/api/proof.d.ts +25 -0
- package/dist/api/proof.d.ts.map +1 -0
- package/dist/api/proof.js +30 -0
- package/dist/api/proof.js.map +1 -0
- package/dist/api/transaction.d.ts +71 -0
- package/dist/api/transaction.d.ts.map +1 -0
- package/dist/api/transaction.js +85 -0
- package/dist/api/transaction.js.map +1 -0
- package/dist/api/wallet.d.ts +39 -0
- package/dist/api/wallet.d.ts.map +1 -0
- package/dist/api/wallet.js +51 -0
- package/dist/api/wallet.js.map +1 -0
- package/dist/client.d.ts +70 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +280 -0
- package/dist/client.js.map +1 -0
- package/dist/constants.d.ts +42 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +42 -0
- package/dist/constants.js.map +1 -0
- package/dist/conversion.d.ts +32 -0
- package/dist/conversion.d.ts.map +1 -0
- package/dist/conversion.js +50 -0
- package/dist/conversion.js.map +1 -0
- package/dist/crypto.d.ts +93 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +156 -0
- package/dist/crypto.js.map +1 -0
- package/dist/encoding.d.ts +108 -0
- package/dist/encoding.d.ts.map +1 -0
- package/dist/encoding.js +165 -0
- package/dist/encoding.js.map +1 -0
- package/dist/encryption.d.ts +76 -0
- package/dist/encryption.d.ts.map +1 -0
- package/dist/encryption.js +137 -0
- package/dist/encryption.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas.d.ts +67 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +103 -0
- package/dist/schemas.js.map +1 -0
- package/dist/sdk.d.ts +100 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/sdk.js +120 -0
- package/dist/sdk.js.map +1 -0
- package/dist/serialization.d.ts +42 -0
- package/dist/serialization.d.ts.map +1 -0
- package/dist/serialization.js +247 -0
- package/dist/serialization.js.map +1 -0
- package/dist/transaction-builder.d.ts +267 -0
- package/dist/transaction-builder.d.ts.map +1 -0
- package/dist/transaction-builder.js +397 -0
- package/dist/transaction-builder.js.map +1 -0
- package/dist/types.d.ts +550 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +78 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +15 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +39 -0
- package/dist/validation.js.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Password-Based Encryption Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides secure password-based encryption using PBKDF2 key derivation
|
|
5
|
+
* and AES-GCM encryption. Suitable for encrypting sensitive wallet data.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Derive a cryptographic key from a password using PBKDF2
|
|
9
|
+
*
|
|
10
|
+
* @param password - Password string
|
|
11
|
+
* @param salt - Salt as Uint8Array or ArrayBuffer
|
|
12
|
+
* @param iterations - Number of PBKDF2 iterations (default: 100,000)
|
|
13
|
+
* @returns Derived AES-GCM key
|
|
14
|
+
*/
|
|
15
|
+
export declare function deriveKey(password: string, salt: Uint8Array | ArrayBuffer, iterations?: number): Promise<CryptoKey>;
|
|
16
|
+
/**
|
|
17
|
+
* Generate a cryptographically secure random salt
|
|
18
|
+
*
|
|
19
|
+
* @returns Random salt (16 bytes)
|
|
20
|
+
*/
|
|
21
|
+
export declare function generateSalt(): Uint8Array;
|
|
22
|
+
/**
|
|
23
|
+
* Generate a cryptographically secure random initialization vector
|
|
24
|
+
*
|
|
25
|
+
* @returns Random IV (12 bytes)
|
|
26
|
+
*/
|
|
27
|
+
export declare function generateIV(): Uint8Array;
|
|
28
|
+
/**
|
|
29
|
+
* Encrypted data payload (Base64 encoded)
|
|
30
|
+
*
|
|
31
|
+
* Uses Base64 encoding for binary payloads like vaults (more efficient than Base58).
|
|
32
|
+
* Base58 is reserved for addresses, keys, and hashes.
|
|
33
|
+
*/
|
|
34
|
+
export interface EncryptedPayload {
|
|
35
|
+
/** Encrypted data (Base64 encoded) */
|
|
36
|
+
encryptedData: string;
|
|
37
|
+
/** Initialization vector (Base64 encoded) */
|
|
38
|
+
iv: string;
|
|
39
|
+
/** Salt used for key derivation (Base64 encoded) */
|
|
40
|
+
salt: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Encrypt plaintext with a password using AES-GCM
|
|
44
|
+
*
|
|
45
|
+
* Uses PBKDF2 for key derivation and Base64 encoding for output.
|
|
46
|
+
* Suitable for encrypting sensitive wallet data like private keys.
|
|
47
|
+
*
|
|
48
|
+
* **Encoding Standard**: Uses Base64 encoding for binary payloads (RFC 4648).
|
|
49
|
+
* Base58 is used for addresses, keys, and hashes elsewhere in the SDK.
|
|
50
|
+
*
|
|
51
|
+
* @param plaintext - Plaintext string to encrypt
|
|
52
|
+
* @param password - Password for encryption
|
|
53
|
+
* @returns Encrypted payload with encryptedData, IV, and salt (all Base64 encoded)
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* const encrypted = await encryptWithPassword('sensitive data', 'my-password')
|
|
58
|
+
* // Store encrypted.encryptedData, encrypted.iv, encrypted.salt
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function encryptWithPassword(plaintext: string, password: string): Promise<EncryptedPayload>;
|
|
62
|
+
/**
|
|
63
|
+
* Decrypt encrypted data with a password
|
|
64
|
+
*
|
|
65
|
+
* @param payload - Encrypted payload (Base64 encoded)
|
|
66
|
+
* @param password - Password used for encryption
|
|
67
|
+
* @returns Decrypted plaintext string
|
|
68
|
+
* @throws {Error} If decryption fails (wrong password or corrupted data)
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const decrypted = await decryptWithPassword(encrypted, 'my-password')
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function decryptWithPassword(payload: EncryptedPayload, password: string): Promise<string>;
|
|
76
|
+
//# sourceMappingURL=encryption.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../src/encryption.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqCH;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAC9B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,UAAU,GAAG,WAAW,EAC9B,UAAU,GAAE,MAA0B,GACpC,OAAO,CAAC,SAAS,CAAC,CAgBpB;AAMD;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,UAAU,CAIzC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,UAAU,CAIvC;AAMD;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAChC,sCAAsC;IACtC,aAAa,EAAE,MAAM,CAAA;IACrB,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAA;IACV,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAA;CACZ;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,mBAAmB,CACxC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,gBAAgB,CAAC,CAkB3B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CACxC,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CAgBjB"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Password-Based Encryption Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides secure password-based encryption using PBKDF2 key derivation
|
|
5
|
+
* and AES-GCM encryption. Suitable for encrypting sensitive wallet data.
|
|
6
|
+
*/
|
|
7
|
+
import { uint8ArrayToBase64, base64ToUint8Array } from './encoding';
|
|
8
|
+
import { uint8ArrayToArrayBuffer } from './encoding';
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// Constants
|
|
11
|
+
// ============================================================================
|
|
12
|
+
/**
|
|
13
|
+
* PBKDF2 iterations for key derivation (100,000 iterations for security)
|
|
14
|
+
* Matches web wallet implementation for consistency
|
|
15
|
+
*/
|
|
16
|
+
const PBKDF2_ITERATIONS = 100_000;
|
|
17
|
+
/**
|
|
18
|
+
* Salt length in bytes (128 bits)
|
|
19
|
+
*/
|
|
20
|
+
const SALT_LENGTH = 16;
|
|
21
|
+
/**
|
|
22
|
+
* IV length in bytes for AES-GCM (96 bits)
|
|
23
|
+
*/
|
|
24
|
+
const IV_LENGTH = 12;
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// Helper Functions
|
|
27
|
+
// ============================================================================
|
|
28
|
+
/**
|
|
29
|
+
* Import password as a PBKDF2 key
|
|
30
|
+
*/
|
|
31
|
+
async function importPbkdf2Key(password) {
|
|
32
|
+
const enc = new TextEncoder();
|
|
33
|
+
return crypto.subtle.importKey('raw', enc.encode(password), 'PBKDF2', false, ['deriveKey']);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Derive a cryptographic key from a password using PBKDF2
|
|
37
|
+
*
|
|
38
|
+
* @param password - Password string
|
|
39
|
+
* @param salt - Salt as Uint8Array or ArrayBuffer
|
|
40
|
+
* @param iterations - Number of PBKDF2 iterations (default: 100,000)
|
|
41
|
+
* @returns Derived AES-GCM key
|
|
42
|
+
*/
|
|
43
|
+
export async function deriveKey(password, salt, iterations = PBKDF2_ITERATIONS) {
|
|
44
|
+
const baseKey = await importPbkdf2Key(password);
|
|
45
|
+
const saltBuffer = salt instanceof Uint8Array ? uint8ArrayToArrayBuffer(salt) : salt;
|
|
46
|
+
return crypto.subtle.deriveKey({
|
|
47
|
+
name: 'PBKDF2',
|
|
48
|
+
salt: saltBuffer,
|
|
49
|
+
iterations,
|
|
50
|
+
hash: 'SHA-256'
|
|
51
|
+
}, baseKey, { name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']);
|
|
52
|
+
}
|
|
53
|
+
// ============================================================================
|
|
54
|
+
// Random Generation
|
|
55
|
+
// ============================================================================
|
|
56
|
+
/**
|
|
57
|
+
* Generate a cryptographically secure random salt
|
|
58
|
+
*
|
|
59
|
+
* @returns Random salt (16 bytes)
|
|
60
|
+
*/
|
|
61
|
+
export function generateSalt() {
|
|
62
|
+
const salt = new Uint8Array(SALT_LENGTH);
|
|
63
|
+
crypto.getRandomValues(salt);
|
|
64
|
+
return salt;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Generate a cryptographically secure random initialization vector
|
|
68
|
+
*
|
|
69
|
+
* @returns Random IV (12 bytes)
|
|
70
|
+
*/
|
|
71
|
+
export function generateIV() {
|
|
72
|
+
const iv = new Uint8Array(IV_LENGTH);
|
|
73
|
+
crypto.getRandomValues(iv);
|
|
74
|
+
return iv;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Encrypt plaintext with a password using AES-GCM
|
|
78
|
+
*
|
|
79
|
+
* Uses PBKDF2 for key derivation and Base64 encoding for output.
|
|
80
|
+
* Suitable for encrypting sensitive wallet data like private keys.
|
|
81
|
+
*
|
|
82
|
+
* **Encoding Standard**: Uses Base64 encoding for binary payloads (RFC 4648).
|
|
83
|
+
* Base58 is used for addresses, keys, and hashes elsewhere in the SDK.
|
|
84
|
+
*
|
|
85
|
+
* @param plaintext - Plaintext string to encrypt
|
|
86
|
+
* @param password - Password for encryption
|
|
87
|
+
* @returns Encrypted payload with encryptedData, IV, and salt (all Base64 encoded)
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* const encrypted = await encryptWithPassword('sensitive data', 'my-password')
|
|
92
|
+
* // Store encrypted.encryptedData, encrypted.iv, encrypted.salt
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export async function encryptWithPassword(plaintext, password) {
|
|
96
|
+
const enc = new TextEncoder();
|
|
97
|
+
const iv = generateIV();
|
|
98
|
+
const salt = generateSalt();
|
|
99
|
+
const key = await deriveKey(password, salt);
|
|
100
|
+
const ivBuffer = uint8ArrayToArrayBuffer(iv);
|
|
101
|
+
const encryptedBuf = await crypto.subtle.encrypt({ name: 'AES-GCM', iv: ivBuffer }, key, enc.encode(plaintext));
|
|
102
|
+
return {
|
|
103
|
+
encryptedData: uint8ArrayToBase64(new Uint8Array(encryptedBuf)),
|
|
104
|
+
iv: uint8ArrayToBase64(iv),
|
|
105
|
+
salt: uint8ArrayToBase64(salt)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Decrypt encrypted data with a password
|
|
110
|
+
*
|
|
111
|
+
* @param payload - Encrypted payload (Base64 encoded)
|
|
112
|
+
* @param password - Password used for encryption
|
|
113
|
+
* @returns Decrypted plaintext string
|
|
114
|
+
* @throws {Error} If decryption fails (wrong password or corrupted data)
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* const decrypted = await decryptWithPassword(encrypted, 'my-password')
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export async function decryptWithPassword(payload, password) {
|
|
122
|
+
const dec = new TextDecoder();
|
|
123
|
+
const ivBytes = base64ToUint8Array(payload.iv);
|
|
124
|
+
const saltBytes = base64ToUint8Array(payload.salt);
|
|
125
|
+
const encryptedBytes = base64ToUint8Array(payload.encryptedData);
|
|
126
|
+
const key = await deriveKey(password, saltBytes);
|
|
127
|
+
const iv = uint8ArrayToArrayBuffer(ivBytes);
|
|
128
|
+
const encrypted = uint8ArrayToArrayBuffer(encryptedBytes);
|
|
129
|
+
try {
|
|
130
|
+
const plaintextBuf = await crypto.subtle.decrypt({ name: 'AES-GCM', iv }, key, encrypted);
|
|
131
|
+
return dec.decode(plaintextBuf);
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
throw new Error('Decryption failed. Incorrect password or corrupted data.');
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=encryption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.js","sourceRoot":"","sources":["../src/encryption.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAEpD,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,iBAAiB,GAAG,OAAO,CAAA;AAEjC;;GAEG;AACH,MAAM,WAAW,GAAG,EAAE,CAAA;AAEtB;;GAEG;AACH,MAAM,SAAS,GAAG,EAAE,CAAA;AAEpB,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;GAEG;AACH,KAAK,UAAU,eAAe,CAAC,QAAgB;IAC9C,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;IAC7B,OAAO,MAAM,CAAC,MAAM,C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CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,CAAC,CAAA;QACzF,OAAO,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IAChC,CAAC;IAAC,MAAM,CAAC;QACR,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAA;IAC5E,CAAC;AACF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @amadeus-protocol/sdk
|
|
3
|
+
*
|
|
4
|
+
* Official TypeScript/JavaScript SDK for Amadeus Protocol
|
|
5
|
+
*
|
|
6
|
+
* This SDK provides:
|
|
7
|
+
* - Canonical serialization (VecPack)
|
|
8
|
+
* - Cryptographic operations (BLS12-381, Base58)
|
|
9
|
+
* - Transaction building and signing
|
|
10
|
+
* - Token amount conversions
|
|
11
|
+
* - Full-featured API client for Amadeus nodes
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { AmadeusSDK, TransactionBuilder, generateKeypair } from '@amadeus-protocol/sdk'
|
|
16
|
+
*
|
|
17
|
+
* // Initialize SDK
|
|
18
|
+
* const sdk = new AmadeusSDK()
|
|
19
|
+
*
|
|
20
|
+
* // Generate keypair
|
|
21
|
+
* const keypair = generateKeypair()
|
|
22
|
+
*
|
|
23
|
+
* // Build and submit transaction
|
|
24
|
+
* const builder = new TransactionBuilder(keypair.privateKey)
|
|
25
|
+
* const { txHash, txPacked } = builder.transfer({
|
|
26
|
+
* recipient: '5Kd3N...',
|
|
27
|
+
* amount: 10.5,
|
|
28
|
+
* symbol: 'AMA'
|
|
29
|
+
* })
|
|
30
|
+
*
|
|
31
|
+
* const result = await sdk.transaction.submit(txPacked)
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @packageDocumentation
|
|
35
|
+
*/
|
|
36
|
+
export * from './types';
|
|
37
|
+
export * from './constants';
|
|
38
|
+
export * from './serialization';
|
|
39
|
+
export * from './crypto';
|
|
40
|
+
export * from './conversion';
|
|
41
|
+
export * from './encoding';
|
|
42
|
+
export * from './encryption';
|
|
43
|
+
export * from './transaction-builder';
|
|
44
|
+
export * from './client';
|
|
45
|
+
export * from './api';
|
|
46
|
+
export * from './sdk';
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,UAAU,CAAA;AACxB,cAAc,OAAO,CAAA;AACrB,cAAc,OAAO,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @amadeus-protocol/sdk
|
|
3
|
+
*
|
|
4
|
+
* Official TypeScript/JavaScript SDK for Amadeus Protocol
|
|
5
|
+
*
|
|
6
|
+
* This SDK provides:
|
|
7
|
+
* - Canonical serialization (VecPack)
|
|
8
|
+
* - Cryptographic operations (BLS12-381, Base58)
|
|
9
|
+
* - Transaction building and signing
|
|
10
|
+
* - Token amount conversions
|
|
11
|
+
* - Full-featured API client for Amadeus nodes
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { AmadeusSDK, TransactionBuilder, generateKeypair } from '@amadeus-protocol/sdk'
|
|
16
|
+
*
|
|
17
|
+
* // Initialize SDK
|
|
18
|
+
* const sdk = new AmadeusSDK()
|
|
19
|
+
*
|
|
20
|
+
* // Generate keypair
|
|
21
|
+
* const keypair = generateKeypair()
|
|
22
|
+
*
|
|
23
|
+
* // Build and submit transaction
|
|
24
|
+
* const builder = new TransactionBuilder(keypair.privateKey)
|
|
25
|
+
* const { txHash, txPacked } = builder.transfer({
|
|
26
|
+
* recipient: '5Kd3N...',
|
|
27
|
+
* amount: 10.5,
|
|
28
|
+
* symbol: 'AMA'
|
|
29
|
+
* })
|
|
30
|
+
*
|
|
31
|
+
* const result = await sdk.transaction.submit(txPacked)
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @packageDocumentation
|
|
35
|
+
*/
|
|
36
|
+
export * from './types';
|
|
37
|
+
export * from './constants';
|
|
38
|
+
export * from './serialization';
|
|
39
|
+
export * from './crypto';
|
|
40
|
+
export * from './conversion';
|
|
41
|
+
export * from './encoding';
|
|
42
|
+
export * from './encryption';
|
|
43
|
+
export * from './transaction-builder';
|
|
44
|
+
export * from './client';
|
|
45
|
+
export * from './api';
|
|
46
|
+
export * from './sdk';
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,UAAU,CAAA;AACxB,cAAc,OAAO,CAAA;AACrB,cAAc,OAAO,CAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effect Schema definitions for validation
|
|
3
|
+
*
|
|
4
|
+
* Provides reusable schemas for validating common data types used throughout the SDK
|
|
5
|
+
*/
|
|
6
|
+
import { Schema } from 'effect';
|
|
7
|
+
/**
|
|
8
|
+
* Schema for Base58 encoded hash (used for transaction IDs, entry hashes, etc.)
|
|
9
|
+
*/
|
|
10
|
+
export declare const Base58HashSchema: Schema.filter<Schema.filter<typeof Schema.String>>;
|
|
11
|
+
/**
|
|
12
|
+
* Schema for Base58 encoded address
|
|
13
|
+
*/
|
|
14
|
+
export declare const Base58AddressSchema: Schema.filter<Schema.filter<typeof Schema.String>>;
|
|
15
|
+
/**
|
|
16
|
+
* Schema for Base58 encoded public key
|
|
17
|
+
*/
|
|
18
|
+
export declare const Base58PublicKeySchema: Schema.filter<Schema.filter<typeof Schema.String>>;
|
|
19
|
+
/**
|
|
20
|
+
* Schema for transaction sort order
|
|
21
|
+
*/
|
|
22
|
+
export declare const TransactionSortSchema: Schema.Literal<["asc", "desc"]>;
|
|
23
|
+
/**
|
|
24
|
+
* Schema for transaction filters
|
|
25
|
+
* Validates optional fields when they are present
|
|
26
|
+
*/
|
|
27
|
+
export declare const TransactionFiltersSchema: Schema.Struct<{
|
|
28
|
+
limit: Schema.optional<Schema.refine<number, typeof Schema.NonNegative>>;
|
|
29
|
+
offset: Schema.optional<Schema.refine<number, typeof Schema.NonNegative>>;
|
|
30
|
+
sort: Schema.optional<Schema.Literal<["asc", "desc"]>>;
|
|
31
|
+
cursor: Schema.optional<typeof Schema.String>;
|
|
32
|
+
cursor_b58: Schema.optional<typeof Schema.String>;
|
|
33
|
+
contract: Schema.optional<typeof Schema.String>;
|
|
34
|
+
contract_b58: Schema.optional<typeof Schema.String>;
|
|
35
|
+
function: Schema.optional<typeof Schema.String>;
|
|
36
|
+
type: Schema.optional<Schema.Literal<["sent", "recv"]>>;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Schema for non-empty string
|
|
40
|
+
*/
|
|
41
|
+
export declare const NonEmptyStringSchema: Schema.filter<typeof Schema.String>;
|
|
42
|
+
/**
|
|
43
|
+
* Schema for non-empty Uint8Array
|
|
44
|
+
*/
|
|
45
|
+
export declare const NonEmptyUint8ArraySchema: Schema.filter<Schema.instanceOf<Uint8Array<ArrayBuffer>>>;
|
|
46
|
+
/**
|
|
47
|
+
* Schema for ArrayBuffer (can be converted to Uint8Array)
|
|
48
|
+
*/
|
|
49
|
+
export declare const NonEmptyArrayBufferSchema: Schema.filter<Schema.instanceOf<ArrayBuffer>>;
|
|
50
|
+
/**
|
|
51
|
+
* Schema for transaction data (Uint8Array or non-empty Base58 string)
|
|
52
|
+
*/
|
|
53
|
+
export declare const TransactionDataSchema: Schema.Union<[Schema.filter<Schema.instanceOf<Uint8Array<ArrayBuffer>>>, Schema.filter<Schema.filter<typeof Schema.String>>]>;
|
|
54
|
+
/**
|
|
55
|
+
* Schema for contract key (Uint8Array or Base58 string)
|
|
56
|
+
*/
|
|
57
|
+
export declare const ContractKeySchema: Schema.Union<[Schema.filter<Schema.instanceOf<Uint8Array<ArrayBuffer>>>, Schema.filter<Schema.filter<typeof Schema.String>>]>;
|
|
58
|
+
/**
|
|
59
|
+
* Schema for bytecode (Uint8Array or ArrayBuffer)
|
|
60
|
+
*/
|
|
61
|
+
export declare const BytecodeSchema: Schema.Union<[Schema.filter<Schema.instanceOf<Uint8Array<ArrayBuffer>>>, Schema.filter<Schema.instanceOf<ArrayBuffer>>]>;
|
|
62
|
+
/**
|
|
63
|
+
* Schema for safe positive integer (>= 1, within safe integer range)
|
|
64
|
+
* Uses built-in Schema.Int and Schema.positive() with MAX_SAFE_INTEGER constraint
|
|
65
|
+
*/
|
|
66
|
+
export declare const SafePositiveNumberSchema: Schema.filter<Schema.filter<typeof Schema.Int>>;
|
|
67
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAQ/B;;GAEG;AACH,eAAO,MAAM,gBAAgB,oDAM5B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,oDAM/B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,oDAMjC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,iCAEhC,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;EAYnC,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,qCAA8C,CAAA;AAE/E;;GAEG;AACH,eAAO,MAAM,wBAAwB,2DAKpC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB,+CAKrC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,+HAMhC,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,+HAM5B,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,0HAMzB,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,iDAMpC,CAAA"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effect Schema definitions for validation
|
|
3
|
+
*
|
|
4
|
+
* Provides reusable schemas for validating common data types used throughout the SDK
|
|
5
|
+
*/
|
|
6
|
+
import { Schema } from 'effect';
|
|
7
|
+
/**
|
|
8
|
+
* Base58 character set regex pattern
|
|
9
|
+
* Base58 excludes 0, O, I, l to avoid visual confusion
|
|
10
|
+
*/
|
|
11
|
+
const BASE58_PATTERN = /^[1-9A-HJ-NP-Za-km-z]+$/;
|
|
12
|
+
/**
|
|
13
|
+
* Schema for Base58 encoded hash (used for transaction IDs, entry hashes, etc.)
|
|
14
|
+
*/
|
|
15
|
+
export const Base58HashSchema = Schema.String.pipe(Schema.nonEmptyString(), Schema.pattern(BASE58_PATTERN, {
|
|
16
|
+
identifier: 'Base58Hash',
|
|
17
|
+
description: 'Base58 encoded hash string'
|
|
18
|
+
}));
|
|
19
|
+
/**
|
|
20
|
+
* Schema for Base58 encoded address
|
|
21
|
+
*/
|
|
22
|
+
export const Base58AddressSchema = Schema.String.pipe(Schema.nonEmptyString(), Schema.pattern(BASE58_PATTERN, {
|
|
23
|
+
identifier: 'Base58Address',
|
|
24
|
+
description: 'Base58 encoded address string'
|
|
25
|
+
}));
|
|
26
|
+
/**
|
|
27
|
+
* Schema for Base58 encoded public key
|
|
28
|
+
*/
|
|
29
|
+
export const Base58PublicKeySchema = Schema.String.pipe(Schema.nonEmptyString(), Schema.pattern(BASE58_PATTERN, {
|
|
30
|
+
identifier: 'Base58PublicKey',
|
|
31
|
+
description: 'Base58 encoded public key string'
|
|
32
|
+
}));
|
|
33
|
+
/**
|
|
34
|
+
* Schema for transaction sort order
|
|
35
|
+
*/
|
|
36
|
+
export const TransactionSortSchema = Schema.Literal('asc', 'desc').annotations({
|
|
37
|
+
identifier: 'TransactionSort'
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* Schema for transaction filters
|
|
41
|
+
* Validates optional fields when they are present
|
|
42
|
+
*/
|
|
43
|
+
export const TransactionFiltersSchema = Schema.Struct({
|
|
44
|
+
limit: Schema.optional(Schema.NonNegativeInt),
|
|
45
|
+
offset: Schema.optional(Schema.NonNegativeInt),
|
|
46
|
+
sort: Schema.optional(TransactionSortSchema),
|
|
47
|
+
cursor: Schema.optional(Schema.String),
|
|
48
|
+
cursor_b58: Schema.optional(Schema.String),
|
|
49
|
+
contract: Schema.optional(Schema.String),
|
|
50
|
+
contract_b58: Schema.optional(Schema.String),
|
|
51
|
+
function: Schema.optional(Schema.String),
|
|
52
|
+
type: Schema.optional(Schema.Literal('sent', 'recv'))
|
|
53
|
+
}).annotations({
|
|
54
|
+
identifier: 'TransactionFilters'
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* Schema for non-empty string
|
|
58
|
+
*/
|
|
59
|
+
export const NonEmptyStringSchema = Schema.String.pipe(Schema.nonEmptyString());
|
|
60
|
+
/**
|
|
61
|
+
* Schema for non-empty Uint8Array
|
|
62
|
+
*/
|
|
63
|
+
export const NonEmptyUint8ArraySchema = Schema.instanceOf(Uint8Array).pipe(Schema.filter((arr) => arr.length > 0, {
|
|
64
|
+
identifier: 'NonEmptyUint8Array',
|
|
65
|
+
description: 'Non-empty Uint8Array'
|
|
66
|
+
}));
|
|
67
|
+
/**
|
|
68
|
+
* Schema for ArrayBuffer (can be converted to Uint8Array)
|
|
69
|
+
*/
|
|
70
|
+
export const NonEmptyArrayBufferSchema = Schema.instanceOf(ArrayBuffer).pipe(Schema.filter((buf) => buf.byteLength > 0, {
|
|
71
|
+
identifier: 'NonEmptyArrayBuffer',
|
|
72
|
+
description: 'Non-empty ArrayBuffer'
|
|
73
|
+
}));
|
|
74
|
+
/**
|
|
75
|
+
* Schema for transaction data (Uint8Array or non-empty Base58 string)
|
|
76
|
+
*/
|
|
77
|
+
export const TransactionDataSchema = Schema.Union(NonEmptyUint8ArraySchema, Base58HashSchema).annotations({
|
|
78
|
+
identifier: 'TransactionData',
|
|
79
|
+
description: 'Transaction data as Uint8Array or Base58 encoded string'
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* Schema for contract key (Uint8Array or Base58 string)
|
|
83
|
+
*/
|
|
84
|
+
export const ContractKeySchema = Schema.Union(NonEmptyUint8ArraySchema, Base58HashSchema).annotations({
|
|
85
|
+
identifier: 'ContractKey',
|
|
86
|
+
description: 'Contract key as Uint8Array or Base58 encoded string'
|
|
87
|
+
});
|
|
88
|
+
/**
|
|
89
|
+
* Schema for bytecode (Uint8Array or ArrayBuffer)
|
|
90
|
+
*/
|
|
91
|
+
export const BytecodeSchema = Schema.Union(NonEmptyUint8ArraySchema, NonEmptyArrayBufferSchema).annotations({
|
|
92
|
+
identifier: 'Bytecode',
|
|
93
|
+
description: 'Contract bytecode as Uint8Array or ArrayBuffer'
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* Schema for safe positive integer (>= 1, within safe integer range)
|
|
97
|
+
* Uses built-in Schema.Int and Schema.positive() with MAX_SAFE_INTEGER constraint
|
|
98
|
+
*/
|
|
99
|
+
export const SafePositiveNumberSchema = Schema.Int.pipe(Schema.positive(), Schema.filter((n) => n <= Number.MAX_SAFE_INTEGER, {
|
|
100
|
+
identifier: 'SafePositiveNumber',
|
|
101
|
+
description: 'Positive integer within safe integer range'
|
|
102
|
+
}));
|
|
103
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B;;;GAGG;AACH,MAAM,cAAc,GAAG,yBAAyB,CAAA;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CACjD,MAAM,CAAC,cAAc,EAAE,EACvB,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE;IAC9B,UAAU,EAAE,YAAY;IACxB,WAAW,EAAE,4BAA4B;CACzC,CAAC,CACF,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CACpD,MAAM,CAAC,cAAc,EAAE,EACvB,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE;IAC9B,UAAU,EAAE,eAAe;IAC3B,WAAW,EAAE,+BAA+B;CAC5C,CAAC,CACF,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CACtD,MAAM,CAAC,cAAc,EAAE,EACvB,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE;IAC9B,UAAU,EAAE,iBAAiB;IAC7B,WAAW,EAAE,kCAAkC;CAC/C,CAAC,CACF,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,OAA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|
+
/**
|
|
2
|
+
* Amadeus SDK
|
|
3
|
+
*
|
|
4
|
+
* Main SDK class that provides access to all API modules and utilities.
|
|
5
|
+
* This is the primary entry point for interacting with the Amadeus Protocol.
|
|
6
|
+
*/
|
|
7
|
+
import { AmadeusClient } from './client';
|
|
8
|
+
import type { AmadeusSDKConfig } from './types';
|
|
9
|
+
import { ChainAPI, PeerAPI, TransactionAPI, WalletAPI, ContractAPI, EpochAPI, ProofAPI } from './api';
|
|
10
|
+
/**
|
|
11
|
+
* Main Amadeus SDK class
|
|
12
|
+
*
|
|
13
|
+
* Provides a unified interface to interact with the Amadeus Protocol.
|
|
14
|
+
* All API modules are accessible through this class instance.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { AmadeusSDK } from '@amadeus-protocol/sdk'
|
|
19
|
+
*
|
|
20
|
+
* // Initialize SDK with default node URL
|
|
21
|
+
* const sdk = new AmadeusSDK({
|
|
22
|
+
* baseUrl: 'https://nodes.amadeus.bot/api'
|
|
23
|
+
* })
|
|
24
|
+
*
|
|
25
|
+
* // Query chain
|
|
26
|
+
* const tip = await sdk.chain.getTip()
|
|
27
|
+
* const stats = await sdk.chain.getStats()
|
|
28
|
+
*
|
|
29
|
+
* // Query wallet balances
|
|
30
|
+
* const balance = await sdk.wallet.getBalance('5Kd3N...', 'AMA')
|
|
31
|
+
* const allBalances = await sdk.wallet.getAllBalances('5Kd3N...')
|
|
32
|
+
*
|
|
33
|
+
* // Submit transaction
|
|
34
|
+
* const result = await sdk.transaction.submit(txPacked)
|
|
35
|
+
*
|
|
36
|
+
* // Query contracts
|
|
37
|
+
* const contractData = await sdk.contract.get(key)
|
|
38
|
+
*
|
|
39
|
+
* // Query epoch data
|
|
40
|
+
* const scores = await sdk.epoch.getScore()
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare class AmadeusSDK {
|
|
44
|
+
/** HTTP client instance */
|
|
45
|
+
readonly client: AmadeusClient;
|
|
46
|
+
/** Chain API module for blockchain queries */
|
|
47
|
+
readonly chain: ChainAPI;
|
|
48
|
+
/** Peer API module for network information */
|
|
49
|
+
readonly peer: PeerAPI;
|
|
50
|
+
/** Transaction API module for submitting transactions */
|
|
51
|
+
readonly transaction: TransactionAPI;
|
|
52
|
+
/** Wallet API module for balance queries */
|
|
53
|
+
readonly wallet: WalletAPI;
|
|
54
|
+
/** Contract API module for smart contract interactions */
|
|
55
|
+
readonly contract: ContractAPI;
|
|
56
|
+
/** Epoch API module for epoch and validator data */
|
|
57
|
+
readonly epoch: EpochAPI;
|
|
58
|
+
/** Proof API module for validator proofs */
|
|
59
|
+
readonly proof: ProofAPI;
|
|
60
|
+
/**
|
|
61
|
+
* Create a new AmadeusSDK instance
|
|
62
|
+
*
|
|
63
|
+
* @param config - SDK configuration
|
|
64
|
+
* @throws {AmadeusSDKError} If configuration is invalid
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* // Use default node URL
|
|
69
|
+
* const sdk = new AmadeusSDK({})
|
|
70
|
+
*
|
|
71
|
+
* // Use custom node URL
|
|
72
|
+
* const sdk = new AmadeusSDK({
|
|
73
|
+
* baseUrl: 'https://custom-node.com/api',
|
|
74
|
+
* timeout: 60000
|
|
75
|
+
* })
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
constructor(config?: AmadeusSDKConfig);
|
|
79
|
+
/**
|
|
80
|
+
* Get SDK version
|
|
81
|
+
*/
|
|
82
|
+
static getVersion(): string;
|
|
83
|
+
/**
|
|
84
|
+
* Get the current configuration
|
|
85
|
+
*/
|
|
86
|
+
getConfig(): AmadeusSDKConfig;
|
|
87
|
+
/**
|
|
88
|
+
* Update the base URL
|
|
89
|
+
*/
|
|
90
|
+
setBaseUrl(url: string): void;
|
|
91
|
+
/**
|
|
92
|
+
* Update headers
|
|
93
|
+
*/
|
|
94
|
+
setHeaders(headers: Record<string, string>): void;
|
|
95
|
+
/**
|
|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