\r
static #isKeyPair (input: unknown): input is KeyPair {\r
if (typeof input === 'object') {\r
- const obj = input as { [key: string]: unknown }\r
+ const obj = input as Record<string, unknown>\r
if ('index' in obj && typeof obj.index === 'number') {\r
return true\r
}\r
if (typeof block !== 'object') {
throw new TypeError('Invalid block')
}
- const b = block as { [key: string]: unknown }
+ const b = block as Record<string, unknown>
if (b.account == null) {
throw new Error('Account missing')
}
*
* @returns {string} JSON representation of the block
*/
- toJSON (): { [key: string]: string } {
+ toJSON (): Record<string, string> {
try {
if (this.link == null) {
throw new Error('Link is required')
export const DIFFICULTY_SEND = 0xfffffff800000000n
export const XNO = 'ΣΎ'
-export const UNITS: { [key: string]: number } = Object.freeze({
+export const UNITS: Record<string, number> = Object.freeze({
RAW: 0,
RAI: 24,
NYANO: 24,
export class WalletAesGcm {
static encoder: TextEncoder = new TextEncoder()
- static decrypt (type: string, key: CryptoKey, iv: ArrayBuffer, encrypted: ArrayBuffer): Promise<{ [key: string]: ArrayBuffer }> {
+ static decrypt (type: string, key: CryptoKey, iv: ArrayBuffer, encrypted: ArrayBuffer): Promise<Record<string, ArrayBuffer>> {
const seedLength = type === 'BLAKE2b' ? 32 : 64
const additionalData = this.encoder.encode(type)
return crypto.subtle
})
}
- static encrypt (type: string, key: CryptoKey, seed: ArrayBuffer, mnemonic?: ArrayBuffer): Promise<{ [key: string]: ArrayBuffer }> {
+ static encrypt (type: string, key: CryptoKey, seed: ArrayBuffer, mnemonic?: ArrayBuffer): Promise<Record<string, ArrayBuffer>> {
if (type == null) {
throw new Error('Wallet type missing')
}
static #queue: { task: Function, resolve: Function, reject: Function }[] = []
static #status: LedgerStatus = 'DISCONNECTED'
static #transport: typeof TransportHID | typeof TransportBLE | typeof TransportUSB
- static #ADPU_CODES: { [key: string]: number } = Object.freeze({
+ static #ADPU_CODES: Record<string, number> = Object.freeze({
class: 0xa1,
bip32DerivationLevel: 0x03,
version: 0x01,
* @param {object} [data] - JSON to send to the node as defined by the action
* @returns {Promise<any>} JSON-formatted RPC results from the node
*/
- async post (action: string, data?: { [key: string]: unknown }): Promise<any> {
+ async post (action: string, data?: Record<string, unknown>): Promise<any> {
var process: any = process || null
this.#validate(action)
- const headers: { [key: string]: string } = {}
+ const headers: Record<string, string> = {}
headers['Content-Type'] = 'application/json'
if (this.#n && process?.env?.LIBNEMO_RPC_API_KEY) {
headers[this.#n] = process.env.LIBNEMO_RPC_API_KEY
//! SPDX-License-Identifier: GPL-3.0-or-later
export class Passkey {
- static create (action: string, salt: ArrayBuffer, data: { [key: string]: unknown }): Promise<CryptoKey | undefined> {
+ static create (action: string, salt: ArrayBuffer, data: Record<string, unknown>): Promise<CryptoKey | undefined> {
// Allowlisted wallet actions
if (['create', 'load', 'unlock', 'update'].includes(action)) {
/**
* Parse inbound message from main thread into typechecked variables.
*/
-function _extractData (action: string, data: { [key: string]: unknown }) {
+function _extractData (action: string, data: Record<string, unknown>) {
try {
// Import requires seed or mnemonic phrase
if (action === 'load' && data.seed == null && data.mnemonicPhrase == null) {
}
// Action for selecting method execution
-function _parseAction (data: { [key: string]: unknown }) {
+function _parseAction (data: Record<string, unknown>) {
if (data.action == null) {
throw new TypeError('Wallet action is required')
}
// Salt created to derive CryptoKey from password; subsequently required to
// derive the same key for unlock requests
-function _parseKeySalt (action: string, data: { [key: string]: unknown }): ArrayBuffer {
+function _parseKeySalt (action: string, data: Record<string, unknown>): ArrayBuffer {
if (action === 'unlock') {
if (data.keySalt instanceof ArrayBuffer) {
return data.keySalt
// Initialization vector created to encrypt and lock the vault; subsequently
// required to decrypt and unlock the vault
-function _parseIv (action: string, data: { [key: string]: unknown }) {
+function _parseIv (action: string, data: Record<string, unknown>): ArrayBuffer | undefined {
if (action === 'unlock') {
if (!(data.iv instanceof ArrayBuffer)) {
throw new TypeError('Initialization vector required to unlock wallet')
}
// Algorithm used for wallet functions
-function _parseType (action: string, data: { [key: string]: unknown }) {
+function _parseType (action: string, data: Record<string, unknown>) {
if (['create', 'load', 'unlock'].includes(action)) {
if (data.type !== 'BIP-44' && data.type !== 'BLAKE2b' && data.type !== 'Exodus' && data.type !== 'Ledger') {
throw new TypeError(`Type is required to ${action} wallet`)
//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
//! SPDX-License-Identifier: GPL-3.0-or-later
+import { WalletType } from '.'
import { Ledger } from '../ledger'
import { Vault } from '../vault'
-import { WalletType } from '.'
export async function _config (type: WalletType, vault: Vault, settings: { connection: 'hid' | 'ble' | 'usb' } | { timeout: number }): Promise<void>
export async function _config (type: WalletType, vault: Vault, settings: unknown): Promise<void> {
if (settings == null || typeof settings !== 'object') {
throw new TypeError('Invalid configuration settings')
}
- const { connection, timeout } = settings as { [key: string]: unknown }
+ const { connection, timeout } = settings as Record<string, unknown>
if (type === 'Ledger') {
if (connection !== undefined && connection !== 'hid' && connection !== 'ble' && connection !== 'usb') {
throw new Error('Ledger connection must be hid, ble, or usb', { cause: connection })
if (type === 'Ledger') {
return await Ledger.verify(secret)
} else {
- const data: { [key: string]: string | ArrayBuffer } = {
+ const data: Record<string, string | ArrayBuffer> = {
action: 'verify'
}
if (/^(?:[A-F0-9]{64}){1,2}$/i.test(secret)) {