@dynamic-labs/utils 4.0.0-alpha.45 → 4.0.0-alpha.47
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/CHANGELOG.md +28 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +5 -5
- package/src/encryption/convertPublicKeyCryptoKeyToHex/convertPublicKeyCryptoKeyToHex.cjs +31 -0
- package/src/encryption/convertPublicKeyCryptoKeyToHex/convertPublicKeyCryptoKeyToHex.d.ts +11 -0
- package/src/encryption/convertPublicKeyCryptoKeyToHex/convertPublicKeyCryptoKeyToHex.js +27 -0
- package/src/encryption/convertPublicKeyCryptoKeyToHex/index.d.ts +1 -0
- package/src/encryption/convertPublicKeyHexToCryptoKey/convertPublicKeyHexToCryptoKey.cjs +35 -0
- package/src/encryption/convertPublicKeyHexToCryptoKey/convertPublicKeyHexToCryptoKey.d.ts +8 -0
- package/src/encryption/convertPublicKeyHexToCryptoKey/convertPublicKeyHexToCryptoKey.js +31 -0
- package/src/encryption/convertPublicKeyHexToCryptoKey/index.d.ts +1 -0
- package/src/encryption/createKeyPair/createKeyPair.cjs +27 -0
- package/src/encryption/createKeyPair/createKeyPair.d.ts +9 -0
- package/src/encryption/createKeyPair/createKeyPair.js +23 -0
- package/src/encryption/createKeyPair/index.d.ts +1 -0
- package/src/encryption/decryptMessage/decryptMessage.cjs +48 -0
- package/src/encryption/decryptMessage/decryptMessage.d.ts +9 -0
- package/src/encryption/decryptMessage/decryptMessage.js +44 -0
- package/src/encryption/decryptMessage/index.d.ts +1 -0
- package/src/encryption/deriveSharedSecret/deriveSharedSecret.cjs +28 -0
- package/src/encryption/deriveSharedSecret/deriveSharedSecret.d.ts +10 -0
- package/src/encryption/deriveSharedSecret/deriveSharedSecret.js +24 -0
- package/src/encryption/deriveSharedSecret/index.d.ts +1 -0
- package/src/encryption/encryptMessage/encryptMessage.cjs +42 -0
- package/src/encryption/encryptMessage/encryptMessage.d.ts +13 -0
- package/src/encryption/encryptMessage/encryptMessage.js +38 -0
- package/src/encryption/encryptMessage/index.d.ts +1 -0
- package/src/encryption/index.d.ts +7 -0
- package/src/encryption/isEncryptedMessage/index.d.ts +1 -0
- package/src/encryption/isEncryptedMessage/isEncryptedMessage.cjs +28 -0
- package/src/encryption/isEncryptedMessage/isEncryptedMessage.d.ts +7 -0
- package/src/encryption/isEncryptedMessage/isEncryptedMessage.js +24 -0
- package/src/index.cjs +16 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +8 -0
- package/src/solToLamports/index.d.ts +1 -0
- package/src/solToLamports/solToLamports.cjs +11 -0
- package/src/solToLamports/solToLamports.d.ts +1 -0
- package/src/solToLamports/solToLamports.js +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.0.0-alpha.47](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.46...v4.0.0-alpha.47) (2024-12-17)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### ⚠ BREAKING CHANGES
|
|
6
|
+
|
|
7
|
+
* stop exposing authToken and minAuthToken from dynamic context (#7629)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* allow re-linking unknown wallet when there's another account of the same wallet provider already linked ([#7628](https://github.com/dynamic-labs/dynamic-auth/issues/7628)) ([20c6dc3](https://github.com/dynamic-labs/dynamic-auth/commit/20c6dc3b1847d82bd46f0df5abaef4efe1e24e38))
|
|
12
|
+
* ensure wallet connector will not get removed ([#7625](https://github.com/dynamic-labs/dynamic-auth/issues/7625)) ([b764846](https://github.com/dynamic-labs/dynamic-auth/commit/b764846b56428e2997d33858e29a87f44359eb6c))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
* stop exposing authToken and minAuthToken from dynamic context ([#7629](https://github.com/dynamic-labs/dynamic-auth/issues/7629)) ([9648870](https://github.com/dynamic-labs/dynamic-auth/commit/9648870478cdcecde279117ada2a1095dab54e2c))
|
|
16
|
+
|
|
17
|
+
## [4.0.0-alpha.46](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.45...v4.0.0-alpha.46) (2024-12-17)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **GVTY-2484:** add subdomain handle field ([#7613](https://github.com/dynamic-labs/dynamic-auth/issues/7613)) ([ee8df3b](https://github.com/dynamic-labs/dynamic-auth/commit/ee8df3b34fa9fed96d92d0b414334c370c9791bc))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* increase wait for transactions ([#7624](https://github.com/dynamic-labs/dynamic-auth/issues/7624)) ([2f7f01b](https://github.com/dynamic-labs/dynamic-auth/commit/2f7f01b024c2733f71ea0fd09dff24f815120acb))
|
|
28
|
+
* solana wallet standard signer connect ([#7614](https://github.com/dynamic-labs/dynamic-auth/issues/7614)) ([1836cf3](https://github.com/dynamic-labs/dynamic-auth/commit/1836cf343b45bae01cfdcf0c0d010bf38bf54d83))
|
|
29
|
+
|
|
2
30
|
## [4.0.0-alpha.45](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.44...v4.0.0-alpha.45) (2024-12-11)
|
|
3
31
|
|
|
4
32
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/utils",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.47",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
21
|
+
"@dynamic-labs/sdk-api-core": "0.0.576",
|
|
22
22
|
"tldts": "6.0.16",
|
|
23
|
-
"@dynamic-labs/assert-package-version": "4.0.0-alpha.
|
|
24
|
-
"@dynamic-labs/logger": "4.0.0-alpha.
|
|
25
|
-
"@dynamic-labs/types": "4.0.0-alpha.
|
|
23
|
+
"@dynamic-labs/assert-package-version": "4.0.0-alpha.47",
|
|
24
|
+
"@dynamic-labs/logger": "4.0.0-alpha.47",
|
|
25
|
+
"@dynamic-labs/types": "4.0.0-alpha.47",
|
|
26
26
|
"buffer": "6.0.3",
|
|
27
27
|
"eventemitter3": "5.0.1"
|
|
28
28
|
},
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Converts a CryptoKey public key to its hexadecimal string representation.
|
|
10
|
+
*
|
|
11
|
+
* @param publicKey - The public CryptoKey to convert. Must be extractable.
|
|
12
|
+
* @returns A Promise that resolves to the hexadecimal string representation of the public key.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const pair = await createKeyPair(...);
|
|
16
|
+
* const hexString = await convertPublicKeyCryptoKeyToHex(pair.publicKey);
|
|
17
|
+
*/
|
|
18
|
+
const convertPublicKeyCryptoKeyToHex = (publicKey) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
if (!publicKey.extractable) {
|
|
20
|
+
throw new Error('CryptoKey must be extractable to convert to hex.');
|
|
21
|
+
}
|
|
22
|
+
// Export the CryptoKey to a raw ArrayBuffer
|
|
23
|
+
const exportedKey = yield crypto.subtle.exportKey('raw', publicKey);
|
|
24
|
+
// Convert the ArrayBuffer to a hex string
|
|
25
|
+
const byteArray = new Uint8Array(exportedKey);
|
|
26
|
+
return encodeURIComponent(Array.from(byteArray)
|
|
27
|
+
.map((byte) => byte.toString(16).padStart(2, '0'))
|
|
28
|
+
.join(''));
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
exports.convertPublicKeyCryptoKeyToHex = convertPublicKeyCryptoKeyToHex;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a CryptoKey public key to its hexadecimal string representation.
|
|
3
|
+
*
|
|
4
|
+
* @param publicKey - The public CryptoKey to convert. Must be extractable.
|
|
5
|
+
* @returns A Promise that resolves to the hexadecimal string representation of the public key.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const pair = await createKeyPair(...);
|
|
9
|
+
* const hexString = await convertPublicKeyCryptoKeyToHex(pair.publicKey);
|
|
10
|
+
*/
|
|
11
|
+
export declare const convertPublicKeyCryptoKeyToHex: (publicKey: CryptoKey) => Promise<string>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Converts a CryptoKey public key to its hexadecimal string representation.
|
|
6
|
+
*
|
|
7
|
+
* @param publicKey - The public CryptoKey to convert. Must be extractable.
|
|
8
|
+
* @returns A Promise that resolves to the hexadecimal string representation of the public key.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const pair = await createKeyPair(...);
|
|
12
|
+
* const hexString = await convertPublicKeyCryptoKeyToHex(pair.publicKey);
|
|
13
|
+
*/
|
|
14
|
+
const convertPublicKeyCryptoKeyToHex = (publicKey) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
if (!publicKey.extractable) {
|
|
16
|
+
throw new Error('CryptoKey must be extractable to convert to hex.');
|
|
17
|
+
}
|
|
18
|
+
// Export the CryptoKey to a raw ArrayBuffer
|
|
19
|
+
const exportedKey = yield crypto.subtle.exportKey('raw', publicKey);
|
|
20
|
+
// Convert the ArrayBuffer to a hex string
|
|
21
|
+
const byteArray = new Uint8Array(exportedKey);
|
|
22
|
+
return encodeURIComponent(Array.from(byteArray)
|
|
23
|
+
.map((byte) => byte.toString(16).padStart(2, '0'))
|
|
24
|
+
.join(''));
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export { convertPublicKeyCryptoKeyToHex };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { convertPublicKeyCryptoKeyToHex } from './convertPublicKeyCryptoKeyToHex';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Converts a hexadecimal string representation of a public key into a CryptoKey object
|
|
10
|
+
*
|
|
11
|
+
* @param hex - The hexadecimal string representation of the public key
|
|
12
|
+
* @returns A Promise that resolves to a CryptoKey object suitable for ECDH operations
|
|
13
|
+
* @throws Error if the hex string length is invalid or doesn't represent a valid public key
|
|
14
|
+
*/
|
|
15
|
+
const convertPublicKeyHexToCryptoKey = (hex) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
// Validate hex string length (65 bytes = 130 hex characters)
|
|
18
|
+
if (hex.length !== 130) {
|
|
19
|
+
throw new Error('Invalid public key length. Expected 130 hex characters.');
|
|
20
|
+
}
|
|
21
|
+
// Validate hex string format (should start with '04' for uncompressed point)
|
|
22
|
+
if (!hex.startsWith('04')) {
|
|
23
|
+
throw new Error('Invalid public key format. Should start with "04".');
|
|
24
|
+
}
|
|
25
|
+
// Convert the hex string to an ArrayBuffer
|
|
26
|
+
const byteArray = new Uint8Array((_b = (_a = decodeURIComponent(hex)
|
|
27
|
+
.match(/.{1,2}/g)) === null || _a === void 0 ? void 0 : _a.map((byte) => parseInt(byte, 16))) !== null && _b !== void 0 ? _b : []);
|
|
28
|
+
// Import the ArrayBuffer as a CryptoKey
|
|
29
|
+
return crypto.subtle.importKey('raw', byteArray.buffer, {
|
|
30
|
+
name: 'ECDH',
|
|
31
|
+
namedCurve: 'P-256',
|
|
32
|
+
}, true, []);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
exports.convertPublicKeyHexToCryptoKey = convertPublicKeyHexToCryptoKey;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a hexadecimal string representation of a public key into a CryptoKey object
|
|
3
|
+
*
|
|
4
|
+
* @param hex - The hexadecimal string representation of the public key
|
|
5
|
+
* @returns A Promise that resolves to a CryptoKey object suitable for ECDH operations
|
|
6
|
+
* @throws Error if the hex string length is invalid or doesn't represent a valid public key
|
|
7
|
+
*/
|
|
8
|
+
export declare const convertPublicKeyHexToCryptoKey: (hex: string) => Promise<CryptoKey>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Converts a hexadecimal string representation of a public key into a CryptoKey object
|
|
6
|
+
*
|
|
7
|
+
* @param hex - The hexadecimal string representation of the public key
|
|
8
|
+
* @returns A Promise that resolves to a CryptoKey object suitable for ECDH operations
|
|
9
|
+
* @throws Error if the hex string length is invalid or doesn't represent a valid public key
|
|
10
|
+
*/
|
|
11
|
+
const convertPublicKeyHexToCryptoKey = (hex) => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
// Validate hex string length (65 bytes = 130 hex characters)
|
|
14
|
+
if (hex.length !== 130) {
|
|
15
|
+
throw new Error('Invalid public key length. Expected 130 hex characters.');
|
|
16
|
+
}
|
|
17
|
+
// Validate hex string format (should start with '04' for uncompressed point)
|
|
18
|
+
if (!hex.startsWith('04')) {
|
|
19
|
+
throw new Error('Invalid public key format. Should start with "04".');
|
|
20
|
+
}
|
|
21
|
+
// Convert the hex string to an ArrayBuffer
|
|
22
|
+
const byteArray = new Uint8Array((_b = (_a = decodeURIComponent(hex)
|
|
23
|
+
.match(/.{1,2}/g)) === null || _a === void 0 ? void 0 : _a.map((byte) => parseInt(byte, 16))) !== null && _b !== void 0 ? _b : []);
|
|
24
|
+
// Import the ArrayBuffer as a CryptoKey
|
|
25
|
+
return crypto.subtle.importKey('raw', byteArray.buffer, {
|
|
26
|
+
name: 'ECDH',
|
|
27
|
+
namedCurve: 'P-256',
|
|
28
|
+
}, true, []);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export { convertPublicKeyHexToCryptoKey };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { convertPublicKeyHexToCryptoKey } from './convertPublicKeyHexToCryptoKey';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Generates an ECDH key pair for cryptographic operations.
|
|
10
|
+
* Uses the P-256 curve for key generation, which provides 128-bit security level.
|
|
11
|
+
*
|
|
12
|
+
* @returns {Promise<{publicKey: CryptoKey, privateKey: CryptoKey}>} A promise that resolves to an object containing:
|
|
13
|
+
* - publicKey: The generated public key
|
|
14
|
+
* - privateKey: The generated private key
|
|
15
|
+
*/
|
|
16
|
+
const createKeyPair = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const keyPair = yield crypto.subtle.generateKey({
|
|
18
|
+
name: 'ECDH',
|
|
19
|
+
namedCurve: 'P-256',
|
|
20
|
+
}, true, ['deriveKey', 'deriveBits']);
|
|
21
|
+
return {
|
|
22
|
+
privateKey: keyPair.privateKey,
|
|
23
|
+
publicKey: keyPair.publicKey,
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
exports.createKeyPair = createKeyPair;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates an ECDH key pair for cryptographic operations.
|
|
3
|
+
* Uses the P-256 curve for key generation, which provides 128-bit security level.
|
|
4
|
+
*
|
|
5
|
+
* @returns {Promise<{publicKey: CryptoKey, privateKey: CryptoKey}>} A promise that resolves to an object containing:
|
|
6
|
+
* - publicKey: The generated public key
|
|
7
|
+
* - privateKey: The generated private key
|
|
8
|
+
*/
|
|
9
|
+
export declare const createKeyPair: () => Promise<CryptoKeyPair>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Generates an ECDH key pair for cryptographic operations.
|
|
6
|
+
* Uses the P-256 curve for key generation, which provides 128-bit security level.
|
|
7
|
+
*
|
|
8
|
+
* @returns {Promise<{publicKey: CryptoKey, privateKey: CryptoKey}>} A promise that resolves to an object containing:
|
|
9
|
+
* - publicKey: The generated public key
|
|
10
|
+
* - privateKey: The generated private key
|
|
11
|
+
*/
|
|
12
|
+
const createKeyPair = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
+
const keyPair = yield crypto.subtle.generateKey({
|
|
14
|
+
name: 'ECDH',
|
|
15
|
+
namedCurve: 'P-256',
|
|
16
|
+
}, true, ['deriveKey', 'deriveBits']);
|
|
17
|
+
return {
|
|
18
|
+
privateKey: keyPair.privateKey,
|
|
19
|
+
publicKey: keyPair.publicKey,
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export { createKeyPair };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createKeyPair } from './createKeyPair';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Decrypts an encrypted message using AES-GCM encryption with a shared secret key.
|
|
10
|
+
*
|
|
11
|
+
* @param sharedSecret - The shared secret key in hexadecimal format
|
|
12
|
+
* @param message - The encrypted message in base64 format
|
|
13
|
+
* @param iv - The initialization vector in hexadecimal format
|
|
14
|
+
* @returns A Promise that resolves to the decrypted message as a string
|
|
15
|
+
*/
|
|
16
|
+
const decryptMessage = (sharedSecret, message, iv) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const decoder = new TextDecoder();
|
|
19
|
+
const sharedSecretByteArray = new Uint8Array((_b = (_a = decodeURIComponent(sharedSecret)
|
|
20
|
+
.match(/.{1,2}/g)) === null || _a === void 0 ? void 0 : _a.map((byte) => parseInt(byte, 16))) !== null && _b !== void 0 ? _b : []);
|
|
21
|
+
// Import the ArrayBuffer as a CryptoKey
|
|
22
|
+
const sharedSecretCryptoKey = yield crypto.subtle.importKey('raw', sharedSecretByteArray.buffer, 'AES-GCM', true, ['encrypt', 'decrypt']);
|
|
23
|
+
const decryptedData = yield crypto.subtle.decrypt({ iv: hexToUint8Array(decodeURIComponent(iv)), name: 'AES-GCM' }, sharedSecretCryptoKey, base64ToArrayBuffer(decodeURIComponent(message)));
|
|
24
|
+
return decoder.decode(new Uint8Array(decryptedData));
|
|
25
|
+
});
|
|
26
|
+
const hexToUint8Array = (hex) => {
|
|
27
|
+
if (hex.length % 2 !== 0) {
|
|
28
|
+
throw new Error('Hex string must have an even number of characters');
|
|
29
|
+
}
|
|
30
|
+
if (!/^[0-9A-Fa-f]+$/.test(hex)) {
|
|
31
|
+
throw new Error('Invalid hex characters');
|
|
32
|
+
}
|
|
33
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
34
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
35
|
+
bytes[i / 2] = parseInt(hex.slice(i, i + 2), 16);
|
|
36
|
+
}
|
|
37
|
+
return bytes;
|
|
38
|
+
};
|
|
39
|
+
const base64ToArrayBuffer = (base64) => {
|
|
40
|
+
const binaryString = atob(base64);
|
|
41
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
42
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
43
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
44
|
+
}
|
|
45
|
+
return bytes.buffer;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.decryptMessage = decryptMessage;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decrypts an encrypted message using AES-GCM encryption with a shared secret key.
|
|
3
|
+
*
|
|
4
|
+
* @param sharedSecret - The shared secret key in hexadecimal format
|
|
5
|
+
* @param message - The encrypted message in base64 format
|
|
6
|
+
* @param iv - The initialization vector in hexadecimal format
|
|
7
|
+
* @returns A Promise that resolves to the decrypted message as a string
|
|
8
|
+
*/
|
|
9
|
+
export declare const decryptMessage: (sharedSecret: string, message: string, iv: string) => Promise<string>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Decrypts an encrypted message using AES-GCM encryption with a shared secret key.
|
|
6
|
+
*
|
|
7
|
+
* @param sharedSecret - The shared secret key in hexadecimal format
|
|
8
|
+
* @param message - The encrypted message in base64 format
|
|
9
|
+
* @param iv - The initialization vector in hexadecimal format
|
|
10
|
+
* @returns A Promise that resolves to the decrypted message as a string
|
|
11
|
+
*/
|
|
12
|
+
const decryptMessage = (sharedSecret, message, iv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const decoder = new TextDecoder();
|
|
15
|
+
const sharedSecretByteArray = new Uint8Array((_b = (_a = decodeURIComponent(sharedSecret)
|
|
16
|
+
.match(/.{1,2}/g)) === null || _a === void 0 ? void 0 : _a.map((byte) => parseInt(byte, 16))) !== null && _b !== void 0 ? _b : []);
|
|
17
|
+
// Import the ArrayBuffer as a CryptoKey
|
|
18
|
+
const sharedSecretCryptoKey = yield crypto.subtle.importKey('raw', sharedSecretByteArray.buffer, 'AES-GCM', true, ['encrypt', 'decrypt']);
|
|
19
|
+
const decryptedData = yield crypto.subtle.decrypt({ iv: hexToUint8Array(decodeURIComponent(iv)), name: 'AES-GCM' }, sharedSecretCryptoKey, base64ToArrayBuffer(decodeURIComponent(message)));
|
|
20
|
+
return decoder.decode(new Uint8Array(decryptedData));
|
|
21
|
+
});
|
|
22
|
+
const hexToUint8Array = (hex) => {
|
|
23
|
+
if (hex.length % 2 !== 0) {
|
|
24
|
+
throw new Error('Hex string must have an even number of characters');
|
|
25
|
+
}
|
|
26
|
+
if (!/^[0-9A-Fa-f]+$/.test(hex)) {
|
|
27
|
+
throw new Error('Invalid hex characters');
|
|
28
|
+
}
|
|
29
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
30
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
31
|
+
bytes[i / 2] = parseInt(hex.slice(i, i + 2), 16);
|
|
32
|
+
}
|
|
33
|
+
return bytes;
|
|
34
|
+
};
|
|
35
|
+
const base64ToArrayBuffer = (base64) => {
|
|
36
|
+
const binaryString = atob(base64);
|
|
37
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
38
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
39
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
40
|
+
}
|
|
41
|
+
return bytes.buffer;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { decryptMessage };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { decryptMessage } from './decryptMessage';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
var convertPublicKeyCryptoKeyToHex = require('../convertPublicKeyCryptoKeyToHex/convertPublicKeyCryptoKeyToHex.cjs');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Derives a shared secret key using ECDH (Elliptic Curve Diffie-Hellman) key agreement protocol.
|
|
11
|
+
* The resulting shared secret can be used for AES-GCM encryption/decryption operations.
|
|
12
|
+
*
|
|
13
|
+
* @param ownPrivateKey - The private key of the current party (CryptoKey format)
|
|
14
|
+
* @param peerPublicKey - The public key of the peer party (CryptoKey format)
|
|
15
|
+
* @returns A Promise that resolves to a hex string representing the derived shared secret
|
|
16
|
+
* configured for AES-GCM encryption/decryption operations
|
|
17
|
+
*/
|
|
18
|
+
const deriveSharedSecret = (ownPrivateKey, peerPublicKey) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
return convertPublicKeyCryptoKeyToHex.convertPublicKeyCryptoKeyToHex(yield crypto.subtle.deriveKey({
|
|
20
|
+
name: 'ECDH',
|
|
21
|
+
public: peerPublicKey,
|
|
22
|
+
}, ownPrivateKey, {
|
|
23
|
+
length: 256,
|
|
24
|
+
name: 'AES-GCM',
|
|
25
|
+
}, true, ['encrypt', 'decrypt']));
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
exports.deriveSharedSecret = deriveSharedSecret;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derives a shared secret key using ECDH (Elliptic Curve Diffie-Hellman) key agreement protocol.
|
|
3
|
+
* The resulting shared secret can be used for AES-GCM encryption/decryption operations.
|
|
4
|
+
*
|
|
5
|
+
* @param ownPrivateKey - The private key of the current party (CryptoKey format)
|
|
6
|
+
* @param peerPublicKey - The public key of the peer party (CryptoKey format)
|
|
7
|
+
* @returns A Promise that resolves to a hex string representing the derived shared secret
|
|
8
|
+
* configured for AES-GCM encryption/decryption operations
|
|
9
|
+
*/
|
|
10
|
+
export declare const deriveSharedSecret: (ownPrivateKey: CryptoKey, peerPublicKey: CryptoKey) => Promise<string>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
import { convertPublicKeyCryptoKeyToHex } from '../convertPublicKeyCryptoKeyToHex/convertPublicKeyCryptoKeyToHex.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Derives a shared secret key using ECDH (Elliptic Curve Diffie-Hellman) key agreement protocol.
|
|
7
|
+
* The resulting shared secret can be used for AES-GCM encryption/decryption operations.
|
|
8
|
+
*
|
|
9
|
+
* @param ownPrivateKey - The private key of the current party (CryptoKey format)
|
|
10
|
+
* @param peerPublicKey - The public key of the peer party (CryptoKey format)
|
|
11
|
+
* @returns A Promise that resolves to a hex string representing the derived shared secret
|
|
12
|
+
* configured for AES-GCM encryption/decryption operations
|
|
13
|
+
*/
|
|
14
|
+
const deriveSharedSecret = (ownPrivateKey, peerPublicKey) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
return convertPublicKeyCryptoKeyToHex(yield crypto.subtle.deriveKey({
|
|
16
|
+
name: 'ECDH',
|
|
17
|
+
public: peerPublicKey,
|
|
18
|
+
}, ownPrivateKey, {
|
|
19
|
+
length: 256,
|
|
20
|
+
name: 'AES-GCM',
|
|
21
|
+
}, true, ['encrypt', 'decrypt']));
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export { deriveSharedSecret };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { deriveSharedSecret } from './deriveSharedSecret';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Encrypts a message using AES-GCM encryption with a shared secret key
|
|
10
|
+
* @param sharedSecret - Hexadecimal string representing the shared secret key
|
|
11
|
+
* @param message - The plaintext message to encrypt
|
|
12
|
+
* @returns {Promise<{encryptedMessage: string, iv: string}>} Object containing:
|
|
13
|
+
* - encryptedMessage: Base64 encoded encrypted message
|
|
14
|
+
* - iv: Hexadecimal initialization vector used for encryption
|
|
15
|
+
*/
|
|
16
|
+
const encryptMessage = (sharedSecret, message) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const encoder = new TextEncoder();
|
|
19
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
20
|
+
const data = encoder.encode(message);
|
|
21
|
+
const sharedSecretByteArray = new Uint8Array((_b = (_a = sharedSecret.match(/.{1,2}/g)) === null || _a === void 0 ? void 0 : _a.map((byte) => parseInt(byte, 16))) !== null && _b !== void 0 ? _b : []);
|
|
22
|
+
// Import the ArrayBuffer as a CryptoKey
|
|
23
|
+
const sharedSecretCryptoKey = yield crypto.subtle.importKey('raw', sharedSecretByteArray.buffer, 'AES-GCM', true, ['encrypt', 'decrypt']);
|
|
24
|
+
const encryptedMessage = yield crypto.subtle.encrypt({ iv, name: 'AES-GCM' }, sharedSecretCryptoKey, data);
|
|
25
|
+
return {
|
|
26
|
+
encryptedMessage: encodeURIComponent(arrayBufferToBase64(encryptedMessage)),
|
|
27
|
+
iv: encodeURIComponent(uint8ArrayToHex(iv)),
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
const arrayBufferToBase64 = (buffer) => {
|
|
31
|
+
const bytes = new Uint8Array(buffer);
|
|
32
|
+
let binary = '';
|
|
33
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
34
|
+
binary += String.fromCharCode(bytes[i]);
|
|
35
|
+
}
|
|
36
|
+
return btoa(binary);
|
|
37
|
+
};
|
|
38
|
+
const uint8ArrayToHex = (arr) => Array.from(arr)
|
|
39
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
40
|
+
.join('');
|
|
41
|
+
|
|
42
|
+
exports.encryptMessage = encryptMessage;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type EncryptedMessage = {
|
|
2
|
+
encryptedMessage: string;
|
|
3
|
+
iv: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Encrypts a message using AES-GCM encryption with a shared secret key
|
|
7
|
+
* @param sharedSecret - Hexadecimal string representing the shared secret key
|
|
8
|
+
* @param message - The plaintext message to encrypt
|
|
9
|
+
* @returns {Promise<{encryptedMessage: string, iv: string}>} Object containing:
|
|
10
|
+
* - encryptedMessage: Base64 encoded encrypted message
|
|
11
|
+
* - iv: Hexadecimal initialization vector used for encryption
|
|
12
|
+
*/
|
|
13
|
+
export declare const encryptMessage: (sharedSecret: string, message: string) => Promise<EncryptedMessage>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Encrypts a message using AES-GCM encryption with a shared secret key
|
|
6
|
+
* @param sharedSecret - Hexadecimal string representing the shared secret key
|
|
7
|
+
* @param message - The plaintext message to encrypt
|
|
8
|
+
* @returns {Promise<{encryptedMessage: string, iv: string}>} Object containing:
|
|
9
|
+
* - encryptedMessage: Base64 encoded encrypted message
|
|
10
|
+
* - iv: Hexadecimal initialization vector used for encryption
|
|
11
|
+
*/
|
|
12
|
+
const encryptMessage = (sharedSecret, message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const encoder = new TextEncoder();
|
|
15
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
16
|
+
const data = encoder.encode(message);
|
|
17
|
+
const sharedSecretByteArray = new Uint8Array((_b = (_a = sharedSecret.match(/.{1,2}/g)) === null || _a === void 0 ? void 0 : _a.map((byte) => parseInt(byte, 16))) !== null && _b !== void 0 ? _b : []);
|
|
18
|
+
// Import the ArrayBuffer as a CryptoKey
|
|
19
|
+
const sharedSecretCryptoKey = yield crypto.subtle.importKey('raw', sharedSecretByteArray.buffer, 'AES-GCM', true, ['encrypt', 'decrypt']);
|
|
20
|
+
const encryptedMessage = yield crypto.subtle.encrypt({ iv, name: 'AES-GCM' }, sharedSecretCryptoKey, data);
|
|
21
|
+
return {
|
|
22
|
+
encryptedMessage: encodeURIComponent(arrayBufferToBase64(encryptedMessage)),
|
|
23
|
+
iv: encodeURIComponent(uint8ArrayToHex(iv)),
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
const arrayBufferToBase64 = (buffer) => {
|
|
27
|
+
const bytes = new Uint8Array(buffer);
|
|
28
|
+
let binary = '';
|
|
29
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
30
|
+
binary += String.fromCharCode(bytes[i]);
|
|
31
|
+
}
|
|
32
|
+
return btoa(binary);
|
|
33
|
+
};
|
|
34
|
+
const uint8ArrayToHex = (arr) => Array.from(arr)
|
|
35
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
36
|
+
.join('');
|
|
37
|
+
|
|
38
|
+
export { encryptMessage };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { encryptMessage, type EncryptedMessage } from './encryptMessage';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createKeyPair } from './createKeyPair';
|
|
2
|
+
export { deriveSharedSecret } from './deriveSharedSecret';
|
|
3
|
+
export { convertPublicKeyCryptoKeyToHex } from './convertPublicKeyCryptoKeyToHex';
|
|
4
|
+
export { convertPublicKeyHexToCryptoKey } from './convertPublicKeyHexToCryptoKey';
|
|
5
|
+
export { decryptMessage } from './decryptMessage';
|
|
6
|
+
export { encryptMessage } from './encryptMessage';
|
|
7
|
+
export { isEncryptedMessage } from './isEncryptedMessage';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isEncryptedMessage } from './isEncryptedMessage';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Type guard to check if a value is an encrypted message
|
|
8
|
+
* @param value - Value to check
|
|
9
|
+
* @returns boolean indicating if the value matches the EncryptedMessage format
|
|
10
|
+
*/
|
|
11
|
+
const isEncryptedMessage = (value) => {
|
|
12
|
+
if (!value ||
|
|
13
|
+
typeof value !== 'object' ||
|
|
14
|
+
Array.isArray(value) ||
|
|
15
|
+
value === null ||
|
|
16
|
+
typeof value === 'string') {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const candidate = value;
|
|
20
|
+
const keys = Object.keys(candidate);
|
|
21
|
+
return (keys.length === 2 &&
|
|
22
|
+
keys.includes('encryptedMessage') &&
|
|
23
|
+
keys.includes('iv') &&
|
|
24
|
+
typeof candidate['encryptedMessage'] === 'string' &&
|
|
25
|
+
typeof candidate['iv'] === 'string');
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.isEncryptedMessage = isEncryptedMessage;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EncryptedMessage } from '../encryptMessage';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a value is an encrypted message
|
|
4
|
+
* @param value - Value to check
|
|
5
|
+
* @returns boolean indicating if the value matches the EncryptedMessage format
|
|
6
|
+
*/
|
|
7
|
+
export declare const isEncryptedMessage: (value: unknown) => value is EncryptedMessage;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a value is an encrypted message
|
|
4
|
+
* @param value - Value to check
|
|
5
|
+
* @returns boolean indicating if the value matches the EncryptedMessage format
|
|
6
|
+
*/
|
|
7
|
+
const isEncryptedMessage = (value) => {
|
|
8
|
+
if (!value ||
|
|
9
|
+
typeof value !== 'object' ||
|
|
10
|
+
Array.isArray(value) ||
|
|
11
|
+
value === null ||
|
|
12
|
+
typeof value === 'string') {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const candidate = value;
|
|
16
|
+
const keys = Object.keys(candidate);
|
|
17
|
+
return (keys.length === 2 &&
|
|
18
|
+
keys.includes('encryptedMessage') &&
|
|
19
|
+
keys.includes('iv') &&
|
|
20
|
+
typeof candidate['encryptedMessage'] === 'string' &&
|
|
21
|
+
typeof candidate['iv'] === 'string');
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { isEncryptedMessage };
|
package/src/index.cjs
CHANGED
|
@@ -68,6 +68,13 @@ var sleep = require('./sleep/sleep.cjs');
|
|
|
68
68
|
var trimEnd = require('./trimEnd/trimEnd.cjs');
|
|
69
69
|
var uniq = require('./uniq/uniq.cjs');
|
|
70
70
|
var wrapMethodWithCallback = require('./wrapMethodWithCallback/wrapMethodWithCallback.cjs');
|
|
71
|
+
var createKeyPair = require('./encryption/createKeyPair/createKeyPair.cjs');
|
|
72
|
+
var deriveSharedSecret = require('./encryption/deriveSharedSecret/deriveSharedSecret.cjs');
|
|
73
|
+
var convertPublicKeyCryptoKeyToHex = require('./encryption/convertPublicKeyCryptoKeyToHex/convertPublicKeyCryptoKeyToHex.cjs');
|
|
74
|
+
var convertPublicKeyHexToCryptoKey = require('./encryption/convertPublicKeyHexToCryptoKey/convertPublicKeyHexToCryptoKey.cjs');
|
|
75
|
+
var decryptMessage = require('./encryption/decryptMessage/decryptMessage.cjs');
|
|
76
|
+
var encryptMessage = require('./encryption/encryptMessage/encryptMessage.cjs');
|
|
77
|
+
var isEncryptedMessage = require('./encryption/isEncryptedMessage/isEncryptedMessage.cjs');
|
|
71
78
|
var cloneObjectWithOverrides = require('./cloneObjectWithOverrides/cloneObjectWithOverrides.cjs');
|
|
72
79
|
var get = require('./get/get.cjs');
|
|
73
80
|
var hexToString = require('./hexToString/hexToString.cjs');
|
|
@@ -85,6 +92,7 @@ var StorageService = require('./services/StorageService/StorageService.cjs');
|
|
|
85
92
|
var createStorageService = require('./services/StorageService/createStorageService/createStorageService.cjs');
|
|
86
93
|
var applyPostfixToStorageService = require('./services/StorageService/applyPostfixToStorageService/applyPostfixToStorageService.cjs');
|
|
87
94
|
var connectWithAppleId = require('./services/Oauth2Service/utils/connectWithAppleId/connectWithAppleId.cjs');
|
|
95
|
+
var solToLamports = require('./solToLamports/solToLamports.cjs');
|
|
88
96
|
|
|
89
97
|
assertPackageVersion.assertPackageVersion('@dynamic-labs/utils', _package.version);
|
|
90
98
|
|
|
@@ -168,6 +176,13 @@ exports.sleep = sleep.sleep;
|
|
|
168
176
|
exports.trimEnd = trimEnd.trimEnd;
|
|
169
177
|
exports.uniq = uniq.uniq;
|
|
170
178
|
exports.wrapMethodWithCallback = wrapMethodWithCallback.wrapMethodWithCallback;
|
|
179
|
+
exports.createKeyPair = createKeyPair.createKeyPair;
|
|
180
|
+
exports.deriveSharedSecret = deriveSharedSecret.deriveSharedSecret;
|
|
181
|
+
exports.convertPublicKeyCryptoKeyToHex = convertPublicKeyCryptoKeyToHex.convertPublicKeyCryptoKeyToHex;
|
|
182
|
+
exports.convertPublicKeyHexToCryptoKey = convertPublicKeyHexToCryptoKey.convertPublicKeyHexToCryptoKey;
|
|
183
|
+
exports.decryptMessage = decryptMessage.decryptMessage;
|
|
184
|
+
exports.encryptMessage = encryptMessage.encryptMessage;
|
|
185
|
+
exports.isEncryptedMessage = isEncryptedMessage.isEncryptedMessage;
|
|
171
186
|
exports.cloneObjectWithOverrides = cloneObjectWithOverrides.cloneObjectWithOverrides;
|
|
172
187
|
exports.get = get.get;
|
|
173
188
|
exports.hexToString = hexToString.hexToString;
|
|
@@ -185,3 +200,4 @@ exports.StorageService = StorageService.StorageService;
|
|
|
185
200
|
exports.createStorageService = createStorageService.createStorageService;
|
|
186
201
|
exports.applyPostfixToStorageService = applyPostfixToStorageService.applyPostfixToStorageService;
|
|
187
202
|
exports.connectWithAppleId = connectWithAppleId.connectWithAppleId;
|
|
203
|
+
exports.solToLamports = solToLamports.solToLamports;
|
package/src/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export * from './sleep';
|
|
|
25
25
|
export * from './trimEnd';
|
|
26
26
|
export * from './uniq';
|
|
27
27
|
export * from './wrapMethodWithCallback';
|
|
28
|
+
export * from './encryption';
|
|
28
29
|
export { cloneObjectWithOverrides } from './cloneObjectWithOverrides';
|
|
29
30
|
export { get } from './get';
|
|
30
31
|
export { hexToString } from './hexToString';
|
|
@@ -38,3 +39,4 @@ export { FetchService } from './services/FetchService';
|
|
|
38
39
|
export { Oauth2Service, type GetOauthCodeError, type GetOauthCodeProps, type IOauth2Service, createWindowOauth2Service, } from './services/Oauth2Service';
|
|
39
40
|
export { type IStorageService, type StorageOptions, StorageService, createStorageService, applyPostfixToStorageService, } from './services/StorageService';
|
|
40
41
|
export { connectWithAppleId } from './services/Oauth2Service/utils/connectWithAppleId';
|
|
42
|
+
export { solToLamports } from './solToLamports';
|
package/src/index.js
CHANGED
|
@@ -64,6 +64,13 @@ export { sleep } from './sleep/sleep.js';
|
|
|
64
64
|
export { trimEnd } from './trimEnd/trimEnd.js';
|
|
65
65
|
export { uniq } from './uniq/uniq.js';
|
|
66
66
|
export { wrapMethodWithCallback } from './wrapMethodWithCallback/wrapMethodWithCallback.js';
|
|
67
|
+
export { createKeyPair } from './encryption/createKeyPair/createKeyPair.js';
|
|
68
|
+
export { deriveSharedSecret } from './encryption/deriveSharedSecret/deriveSharedSecret.js';
|
|
69
|
+
export { convertPublicKeyCryptoKeyToHex } from './encryption/convertPublicKeyCryptoKeyToHex/convertPublicKeyCryptoKeyToHex.js';
|
|
70
|
+
export { convertPublicKeyHexToCryptoKey } from './encryption/convertPublicKeyHexToCryptoKey/convertPublicKeyHexToCryptoKey.js';
|
|
71
|
+
export { decryptMessage } from './encryption/decryptMessage/decryptMessage.js';
|
|
72
|
+
export { encryptMessage } from './encryption/encryptMessage/encryptMessage.js';
|
|
73
|
+
export { isEncryptedMessage } from './encryption/isEncryptedMessage/isEncryptedMessage.js';
|
|
67
74
|
export { cloneObjectWithOverrides } from './cloneObjectWithOverrides/cloneObjectWithOverrides.js';
|
|
68
75
|
export { get } from './get/get.js';
|
|
69
76
|
export { hexToString } from './hexToString/hexToString.js';
|
|
@@ -81,5 +88,6 @@ export { StorageService } from './services/StorageService/StorageService.js';
|
|
|
81
88
|
export { createStorageService } from './services/StorageService/createStorageService/createStorageService.js';
|
|
82
89
|
export { applyPostfixToStorageService } from './services/StorageService/applyPostfixToStorageService/applyPostfixToStorageService.js';
|
|
83
90
|
export { connectWithAppleId } from './services/Oauth2Service/utils/connectWithAppleId/connectWithAppleId.js';
|
|
91
|
+
export { solToLamports } from './solToLamports/solToLamports.js';
|
|
84
92
|
|
|
85
93
|
assertPackageVersion('@dynamic-labs/utils', version);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { solToLamports } from './solToLamports';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const solToLamports = (solAmount) => {
|
|
7
|
+
const lamportsPerSol = 1000000000; // 1 SOL = 1,000,000,000 Lamports
|
|
8
|
+
return solAmount * lamportsPerSol;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.solToLamports = solToLamports;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const solToLamports: (solAmount: number) => number;
|