From c1ed5e959ce106daf39fc33a0e52826b8647a2d9 Mon Sep 17 00:00:00 2001 From: Nikita Kuznetsov Date: Wed, 28 May 2025 05:06:13 +0300 Subject: [PATCH 1/3] feat(stronghold): support secp256k1 curve --- plugins/stronghold/guest-js/index.ts | 66 ++++++++++++++++++++++++++++ plugins/stronghold/src/lib.rs | 35 +++++++++++++-- 2 files changed, 97 insertions(+), 4 deletions(-) diff --git a/plugins/stronghold/guest-js/index.ts b/plugins/stronghold/guest-js/index.ts index c1945a21..09b1e758 100644 --- a/plugins/stronghold/guest-js/index.ts +++ b/plugins/stronghold/guest-js/index.ts @@ -256,6 +256,72 @@ class ProcedureExecutor { } }).then((n) => Uint8Array.from(n)) } + + /** + * Gets the Secp256k1Ecdsa public key of a SLIP10 private key. + * @param privateKeyLocation The location of the private key. Must be the `outputLocation` of a previous call to `deriveSLIP10`. + * @returns A promise resolving to the public key hex string. + * + * @since 2.1.0 + */ + async getSecp256k1EcdsaPublicKey(privateKeyLocation: Location): Promise { + return await invoke('plugin:stronghold|execute_procedure', { + ...this.procedureArgs, + procedure: { + type: 'PublicKey', + payload: { + type: 'Secp256k1Ecdsa', + privateKey: privateKeyLocation + } + } + }).then((n) => Uint8Array.from(n)) + } + + /** + * Gets the EVM address of a SLIP10 private key. + * @param privateKeyLocation The location of the private key. Must be the `outputLocation` of a previous call to `deriveSLIP10`. + * @returns A promise resolving to the EVM address + * + * @since 2.1.0 + */ + async getSecp256k1EcdsaEvmAddress(privateKeyLocation: Location): Promise { + return await invoke('plugin:stronghold|execute_procedure', { + ...this.procedureArgs, + procedure: { + type: 'GetEvmAddress', + payload: { + privateKey: privateKeyLocation + } + } + }).then((n) => Uint8Array.from(n)) + } + + /** + * Creates a Secp256k1Ecdsa signature from a private key. + * @param flavor The hash type + * @param privateKeyLocation The location of the record where the private key is stored. Must be the `outputLocation` of a previous call to `deriveSLIP10`. + * @param msg The message to sign. + * @returns A promise resolving to the signature hex string. + * + * @since 2.1.0 + */ + async signSecp256k1Ecdsa( + flavor: 'Keccak256' | 'Sha256', + privateKeyLocation: Location, + msg: string + ): Promise { + return await invoke('plugin:stronghold|execute_procedure', { + ...this.procedureArgs, + procedure: { + type: 'Secp256k1EcdsaSign', + payload: { + flavor, + privateKey: privateKeyLocation, + msg + } + } + }).then((n) => Uint8Array.from(n)) + } } export class Client { diff --git a/plugins/stronghold/src/lib.rs b/plugins/stronghold/src/lib.rs index 23acc3a2..4d02c4c8 100644 --- a/plugins/stronghold/src/lib.rs +++ b/plugins/stronghold/src/lib.rs @@ -20,9 +20,9 @@ use std::{ use crypto::keys::bip39; use iota_stronghold::{ procedures::{ - BIP39Generate, BIP39Recover, Curve, Ed25519Sign, KeyType as StrongholdKeyType, - MnemonicLanguage, PublicKey, Slip10Derive, Slip10DeriveInput, Slip10Generate, - StrongholdProcedure, + BIP39Generate, BIP39Recover, Curve, Ed25519Sign, GetEvmAddress, + KeyType as StrongholdKeyType, MnemonicLanguage, PublicKey, Secp256k1EcdsaFlavor, + Secp256k1EcdsaSign, Slip10Derive, Slip10DeriveInput, Slip10Generate, StrongholdProcedure, }, Client, Location, }; @@ -107,6 +107,7 @@ impl From for Slip10DeriveInput { pub enum KeyType { Ed25519, X25519, + Secp256k1Ecdsa, } impl From for StrongholdKeyType { @@ -114,6 +115,7 @@ impl From for StrongholdKeyType { match ty { KeyType::Ed25519 => StrongholdKeyType::Ed25519, KeyType::X25519 => StrongholdKeyType::X25519, + KeyType::Secp256k1Ecdsa => StrongholdKeyType::Secp256k1Ecdsa, } } } @@ -129,7 +131,7 @@ impl<'de> Deserialize<'de> for KeyType { type Value = KeyType; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("ed25519 or x25519") + formatter.write_str("ed25519, x25519, or secp256k1_ecdsa") } fn visit_str(self, value: &str) -> std::result::Result @@ -139,6 +141,7 @@ impl<'de> Deserialize<'de> for KeyType { match value.to_lowercase().as_str() { "ed25519" => Ok(KeyType::Ed25519), "x25519" => Ok(KeyType::X25519), + "secp256k1_ecdsa" => Ok(KeyType::Secp256k1Ecdsa), _ => Err(serde::de::Error::custom("unknown key type")), } } @@ -182,6 +185,16 @@ enum ProcedureDto { private_key: LocationDto, msg: String, }, + GetEvmAddress { + #[serde(rename = "privateKey")] + private_key: LocationDto, + }, + Secp256k1EcdsaSign { + flavor: Secp256k1EcdsaFlavor, + #[serde(rename = "privateKey")] + private_key: LocationDto, + msg: String, + }, } impl From for StrongholdProcedure { @@ -231,6 +244,20 @@ impl From for StrongholdProcedure { msg: msg.as_bytes().to_vec(), }) } + ProcedureDto::GetEvmAddress { private_key } => { + StrongholdProcedure::GetEvmAddress(GetEvmAddress { + private_key: private_key.into(), + }) + } + ProcedureDto::Secp256k1EcdsaSign { + flavor, + private_key, + msg, + } => StrongholdProcedure::Secp256k1EcdsaSign(Secp256k1EcdsaSign { + flavor, + private_key: private_key.into(), + msg: msg.as_bytes().to_vec(), + }), } } } From 4bbe1aa57d212270033def579c0b22b6bfa380e3 Mon Sep 17 00:00:00 2001 From: Nikita Kuznetsov Date: Thu, 29 May 2025 02:33:53 +0300 Subject: [PATCH 2/3] fix: fix prettier warning --- plugins/stronghold/CHANGELOG.md | 2 +- plugins/stronghold/api-iife.js | 181 +++++++++++++++++- plugins/stronghold/guest-js/index.ts | 10 +- .../permissions/autogenerated/reference.md | 3 - .../permissions/schemas/schema.json | 71 ++----- 5 files changed, 204 insertions(+), 63 deletions(-) diff --git a/plugins/stronghold/CHANGELOG.md b/plugins/stronghold/CHANGELOG.md index 5d7ea2d1..342c046f 100644 --- a/plugins/stronghold/CHANGELOG.md +++ b/plugins/stronghold/CHANGELOG.md @@ -22,7 +22,7 @@ ## \[2.0.0-beta.8] -- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. +- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the _minimum_ `@tauri-apps/api` version instead of a single exact version. - [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. ## \[2.0.0-beta.7] diff --git a/plugins/stronghold/api-iife.js b/plugins/stronghold/api-iife.js index aabe9ed2..b6aedcd2 100644 --- a/plugins/stronghold/api-iife.js +++ b/plugins/stronghold/api-iife.js @@ -1 +1,180 @@ -if("__TAURI__"in window){var __TAURI_PLUGIN_STRONGHOLD__=function(t){"use strict";async function e(t,e={},r){return window.__TAURI_INTERNALS__.invoke(t,e,r)}"function"==typeof SuppressedError&&SuppressedError;class r{constructor(t,e){this.type=t,this.payload=e}static generic(t,e){return new r("Generic",{vault:t,record:e})}static counter(t,e){return new r("Counter",{vault:t,counter:e})}}class n{constructor(t){this.procedureArgs=t}async generateSLIP10Seed(t,r){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"SLIP10Generate",payload:{output:t,sizeBytes:r}}}).then((t=>Uint8Array.from(t)))}async deriveSLIP10(t,r,n,a){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"SLIP10Derive",payload:{chain:t,input:{type:r,payload:n},output:a}}}).then((t=>Uint8Array.from(t)))}async recoverBIP39(t,r,n){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"BIP39Recover",payload:{mnemonic:t,passphrase:n,output:r}}}).then((t=>Uint8Array.from(t)))}async generateBIP39(t,r){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"BIP39Generate",payload:{output:t,passphrase:r}}}).then((t=>Uint8Array.from(t)))}async getEd25519PublicKey(t){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"PublicKey",payload:{type:"Ed25519",privateKey:t}}}).then((t=>Uint8Array.from(t)))}async signEd25519(t,r){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"Ed25519Sign",payload:{privateKey:t,msg:r}}}).then((t=>Uint8Array.from(t)))}}class a{constructor(t,e){this.path=t,this.name=e}getVault(t){return new o(this.path,this.name,t)}getStore(){return new s(this.path,this.name)}}class s{constructor(t,e){this.path=t,this.client=e}async get(t){return await e("plugin:stronghold|get_store_record",{snapshotPath:this.path,client:this.client,key:t}).then((t=>t&&Uint8Array.from(t)))}async insert(t,r,n){await e("plugin:stronghold|save_store_record",{snapshotPath:this.path,client:this.client,key:t,value:r,lifetime:n})}async remove(t){return await e("plugin:stronghold|remove_store_record",{snapshotPath:this.path,client:this.client,key:t}).then((t=>t&&Uint8Array.from(t)))}}class o extends n{constructor(t,e,r){super({snapshotPath:t,client:e,vault:r}),this.path=t,this.client=e,this.name=r}async insert(t,r){await e("plugin:stronghold|save_secret",{snapshotPath:this.path,client:this.client,vault:this.name,recordPath:t,secret:r})}async remove(t){await e("plugin:stronghold|remove_secret",{snapshotPath:this.path,client:this.client,vault:this.name,recordPath:t.payload.record})}}class i{constructor(t){this.path=t}static async load(t,r){return await e("plugin:stronghold|initialize",{snapshotPath:t,password:r}).then((()=>new i(t)))}async unload(){await e("plugin:stronghold|destroy",{snapshotPath:this.path})}async loadClient(t){return await e("plugin:stronghold|load_client",{snapshotPath:this.path,client:t}).then((()=>new a(this.path,t)))}async createClient(t){return await e("plugin:stronghold|create_client",{snapshotPath:this.path,client:t}).then((()=>new a(this.path,t)))}async save(){await e("plugin:stronghold|save",{snapshotPath:this.path})}}return t.Client=a,t.Location=r,t.Store=s,t.Stronghold=i,t.Vault=o,t}({});Object.defineProperty(window.__TAURI__,"stronghold",{value:__TAURI_PLUGIN_STRONGHOLD__})} +if ('__TAURI__' in window) { + var __TAURI_PLUGIN_STRONGHOLD__ = (function (t) { + 'use strict' + async function e(t, e = {}, r) { + return window.__TAURI_INTERNALS__.invoke(t, e, r) + } + 'function' == typeof SuppressedError && SuppressedError + class r { + constructor(t, e) { + ;(this.type = t), (this.payload = e) + } + static generic(t, e) { + return new r('Generic', { vault: t, record: e }) + } + static counter(t, e) { + return new r('Counter', { vault: t, counter: e }) + } + } + class n { + constructor(t) { + this.procedureArgs = t + } + async generateSLIP10Seed(t, r) { + return await e('plugin:stronghold|execute_procedure', { + ...this.procedureArgs, + procedure: { + type: 'SLIP10Generate', + payload: { output: t, sizeBytes: r } + } + }).then((t) => Uint8Array.from(t)) + } + async deriveSLIP10(t, r, n, a) { + return await e('plugin:stronghold|execute_procedure', { + ...this.procedureArgs, + procedure: { + type: 'SLIP10Derive', + payload: { chain: t, input: { type: r, payload: n }, output: a } + } + }).then((t) => Uint8Array.from(t)) + } + async recoverBIP39(t, r, n) { + return await e('plugin:stronghold|execute_procedure', { + ...this.procedureArgs, + procedure: { + type: 'BIP39Recover', + payload: { mnemonic: t, passphrase: n, output: r } + } + }).then((t) => Uint8Array.from(t)) + } + async generateBIP39(t, r) { + return await e('plugin:stronghold|execute_procedure', { + ...this.procedureArgs, + procedure: { + type: 'BIP39Generate', + payload: { output: t, passphrase: r } + } + }).then((t) => Uint8Array.from(t)) + } + async getEd25519PublicKey(t) { + return await e('plugin:stronghold|execute_procedure', { + ...this.procedureArgs, + procedure: { + type: 'PublicKey', + payload: { type: 'Ed25519', privateKey: t } + } + }).then((t) => Uint8Array.from(t)) + } + async signEd25519(t, r) { + return await e('plugin:stronghold|execute_procedure', { + ...this.procedureArgs, + procedure: { type: 'Ed25519Sign', payload: { privateKey: t, msg: r } } + }).then((t) => Uint8Array.from(t)) + } + } + class a { + constructor(t, e) { + ;(this.path = t), (this.name = e) + } + getVault(t) { + return new o(this.path, this.name, t) + } + getStore() { + return new s(this.path, this.name) + } + } + class s { + constructor(t, e) { + ;(this.path = t), (this.client = e) + } + async get(t) { + return await e('plugin:stronghold|get_store_record', { + snapshotPath: this.path, + client: this.client, + key: t + }).then((t) => t && Uint8Array.from(t)) + } + async insert(t, r, n) { + await e('plugin:stronghold|save_store_record', { + snapshotPath: this.path, + client: this.client, + key: t, + value: r, + lifetime: n + }) + } + async remove(t) { + return await e('plugin:stronghold|remove_store_record', { + snapshotPath: this.path, + client: this.client, + key: t + }).then((t) => t && Uint8Array.from(t)) + } + } + class o extends n { + constructor(t, e, r) { + super({ snapshotPath: t, client: e, vault: r }), + (this.path = t), + (this.client = e), + (this.name = r) + } + async insert(t, r) { + await e('plugin:stronghold|save_secret', { + snapshotPath: this.path, + client: this.client, + vault: this.name, + recordPath: t, + secret: r + }) + } + async remove(t) { + await e('plugin:stronghold|remove_secret', { + snapshotPath: this.path, + client: this.client, + vault: this.name, + recordPath: t.payload.record + }) + } + } + class i { + constructor(t) { + this.path = t + } + static async load(t, r) { + return await e('plugin:stronghold|initialize', { + snapshotPath: t, + password: r + }).then(() => new i(t)) + } + async unload() { + await e('plugin:stronghold|destroy', { snapshotPath: this.path }) + } + async loadClient(t) { + return await e('plugin:stronghold|load_client', { + snapshotPath: this.path, + client: t + }).then(() => new a(this.path, t)) + } + async createClient(t) { + return await e('plugin:stronghold|create_client', { + snapshotPath: this.path, + client: t + }).then(() => new a(this.path, t)) + } + async save() { + await e('plugin:stronghold|save', { snapshotPath: this.path }) + } + } + return ( + (t.Client = a), + (t.Location = r), + (t.Store = s), + (t.Stronghold = i), + (t.Vault = o), + t + ) + })({}) + Object.defineProperty(window.__TAURI__, 'stronghold', { + value: __TAURI_PLUGIN_STRONGHOLD__ + }) +} diff --git a/plugins/stronghold/guest-js/index.ts b/plugins/stronghold/guest-js/index.ts index 09b1e758..e2d9cd70 100644 --- a/plugins/stronghold/guest-js/index.ts +++ b/plugins/stronghold/guest-js/index.ts @@ -264,7 +264,9 @@ class ProcedureExecutor { * * @since 2.1.0 */ - async getSecp256k1EcdsaPublicKey(privateKeyLocation: Location): Promise { + async getSecp256k1EcdsaPublicKey( + privateKeyLocation: Location + ): Promise { return await invoke('plugin:stronghold|execute_procedure', { ...this.procedureArgs, procedure: { @@ -284,7 +286,9 @@ class ProcedureExecutor { * * @since 2.1.0 */ - async getSecp256k1EcdsaEvmAddress(privateKeyLocation: Location): Promise { + async getSecp256k1EcdsaEvmAddress( + privateKeyLocation: Location + ): Promise { return await invoke('plugin:stronghold|execute_procedure', { ...this.procedureArgs, procedure: { @@ -306,7 +310,7 @@ class ProcedureExecutor { * @since 2.1.0 */ async signSecp256k1Ecdsa( - flavor: 'Keccak256' | 'Sha256', + flavor: 'Keccak256' | 'Sha256', privateKeyLocation: Location, msg: string ): Promise { diff --git a/plugins/stronghold/permissions/autogenerated/reference.md b/plugins/stronghold/permissions/autogenerated/reference.md index c00e56c3..39170d04 100644 --- a/plugins/stronghold/permissions/autogenerated/reference.md +++ b/plugins/stronghold/permissions/autogenerated/reference.md @@ -7,8 +7,6 @@ operations are available from the stronghold plugin. All non-destructive operations are enabled by default. - - #### This default permission set includes the following: - `allow-create-client` @@ -28,7 +26,6 @@ All non-destructive operations are enabled by default. Description - diff --git a/plugins/stronghold/permissions/schemas/schema.json b/plugins/stronghold/permissions/schemas/schema.json index 6af87c6a..96c67e5b 100644 --- a/plugins/stronghold/permissions/schemas/schema.json +++ b/plugins/stronghold/permissions/schemas/schema.json @@ -35,25 +35,17 @@ "DefaultPermission": { "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", "type": "object", - "required": [ - "permissions" - ], + "required": ["permissions"], "properties": { "version": { "description": "The version of the permission.", - "type": [ - "integer", - "null" - ], + "type": ["integer", "null"], "format": "uint64", "minimum": 1.0 }, "description": { "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", - "type": [ - "string", - "null" - ] + "type": ["string", "null"] }, "permissions": { "description": "All permissions this set contains.", @@ -67,11 +59,7 @@ "PermissionSet": { "description": "A set of direct permissions grouped together under a new name.", "type": "object", - "required": [ - "description", - "identifier", - "permissions" - ], + "required": ["description", "identifier", "permissions"], "properties": { "identifier": { "description": "A unique identifier for the permission.", @@ -93,16 +81,11 @@ "Permission": { "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", "type": "object", - "required": [ - "identifier" - ], + "required": ["identifier"], "properties": { "version": { "description": "The version of the permission.", - "type": [ - "integer", - "null" - ], + "type": ["integer", "null"], "format": "uint64", "minimum": 1.0 }, @@ -112,10 +95,7 @@ }, "description": { "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", - "type": [ - "string", - "null" - ] + "type": ["string", "null"] }, "commands": { "description": "Allowed or denied commands when using this permission.", @@ -139,10 +119,7 @@ }, "platforms": { "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", - "type": [ - "array", - "null" - ], + "type": ["array", "null"], "items": { "$ref": "#/definitions/Target" } @@ -177,20 +154,14 @@ "properties": { "allow": { "description": "Data that defines what is allowed by the scope.", - "type": [ - "array", - "null" - ], + "type": ["array", "null"], "items": { "$ref": "#/definitions/Value" } }, "deny": { "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", - "type": [ - "array", - "null" - ], + "type": ["array", "null"], "items": { "$ref": "#/definitions/Value" } @@ -257,37 +228,27 @@ { "description": "MacOS.", "type": "string", - "enum": [ - "macOS" - ] + "enum": ["macOS"] }, { "description": "Windows.", "type": "string", - "enum": [ - "windows" - ] + "enum": ["windows"] }, { "description": "Linux.", "type": "string", - "enum": [ - "linux" - ] + "enum": ["linux"] }, { "description": "Android.", "type": "string", - "enum": [ - "android" - ] + "enum": ["android"] }, { "description": "iOS.", "type": "string", - "enum": [ - "iOS" - ] + "enum": ["iOS"] } ] }, @@ -435,4 +396,4 @@ ] } } -} \ No newline at end of file +} From 4303383d214909e499fa8952a87cf6849b60fd9a Mon Sep 17 00:00:00 2001 From: Nikita Kuznetsov Date: Thu, 29 May 2025 19:52:59 +0300 Subject: [PATCH 3/3] fix: update api-iife.js --- plugins/stronghold/api-iife.js | 181 +-------------------------------- 1 file changed, 1 insertion(+), 180 deletions(-) diff --git a/plugins/stronghold/api-iife.js b/plugins/stronghold/api-iife.js index b6aedcd2..969927d0 100644 --- a/plugins/stronghold/api-iife.js +++ b/plugins/stronghold/api-iife.js @@ -1,180 +1 @@ -if ('__TAURI__' in window) { - var __TAURI_PLUGIN_STRONGHOLD__ = (function (t) { - 'use strict' - async function e(t, e = {}, r) { - return window.__TAURI_INTERNALS__.invoke(t, e, r) - } - 'function' == typeof SuppressedError && SuppressedError - class r { - constructor(t, e) { - ;(this.type = t), (this.payload = e) - } - static generic(t, e) { - return new r('Generic', { vault: t, record: e }) - } - static counter(t, e) { - return new r('Counter', { vault: t, counter: e }) - } - } - class n { - constructor(t) { - this.procedureArgs = t - } - async generateSLIP10Seed(t, r) { - return await e('plugin:stronghold|execute_procedure', { - ...this.procedureArgs, - procedure: { - type: 'SLIP10Generate', - payload: { output: t, sizeBytes: r } - } - }).then((t) => Uint8Array.from(t)) - } - async deriveSLIP10(t, r, n, a) { - return await e('plugin:stronghold|execute_procedure', { - ...this.procedureArgs, - procedure: { - type: 'SLIP10Derive', - payload: { chain: t, input: { type: r, payload: n }, output: a } - } - }).then((t) => Uint8Array.from(t)) - } - async recoverBIP39(t, r, n) { - return await e('plugin:stronghold|execute_procedure', { - ...this.procedureArgs, - procedure: { - type: 'BIP39Recover', - payload: { mnemonic: t, passphrase: n, output: r } - } - }).then((t) => Uint8Array.from(t)) - } - async generateBIP39(t, r) { - return await e('plugin:stronghold|execute_procedure', { - ...this.procedureArgs, - procedure: { - type: 'BIP39Generate', - payload: { output: t, passphrase: r } - } - }).then((t) => Uint8Array.from(t)) - } - async getEd25519PublicKey(t) { - return await e('plugin:stronghold|execute_procedure', { - ...this.procedureArgs, - procedure: { - type: 'PublicKey', - payload: { type: 'Ed25519', privateKey: t } - } - }).then((t) => Uint8Array.from(t)) - } - async signEd25519(t, r) { - return await e('plugin:stronghold|execute_procedure', { - ...this.procedureArgs, - procedure: { type: 'Ed25519Sign', payload: { privateKey: t, msg: r } } - }).then((t) => Uint8Array.from(t)) - } - } - class a { - constructor(t, e) { - ;(this.path = t), (this.name = e) - } - getVault(t) { - return new o(this.path, this.name, t) - } - getStore() { - return new s(this.path, this.name) - } - } - class s { - constructor(t, e) { - ;(this.path = t), (this.client = e) - } - async get(t) { - return await e('plugin:stronghold|get_store_record', { - snapshotPath: this.path, - client: this.client, - key: t - }).then((t) => t && Uint8Array.from(t)) - } - async insert(t, r, n) { - await e('plugin:stronghold|save_store_record', { - snapshotPath: this.path, - client: this.client, - key: t, - value: r, - lifetime: n - }) - } - async remove(t) { - return await e('plugin:stronghold|remove_store_record', { - snapshotPath: this.path, - client: this.client, - key: t - }).then((t) => t && Uint8Array.from(t)) - } - } - class o extends n { - constructor(t, e, r) { - super({ snapshotPath: t, client: e, vault: r }), - (this.path = t), - (this.client = e), - (this.name = r) - } - async insert(t, r) { - await e('plugin:stronghold|save_secret', { - snapshotPath: this.path, - client: this.client, - vault: this.name, - recordPath: t, - secret: r - }) - } - async remove(t) { - await e('plugin:stronghold|remove_secret', { - snapshotPath: this.path, - client: this.client, - vault: this.name, - recordPath: t.payload.record - }) - } - } - class i { - constructor(t) { - this.path = t - } - static async load(t, r) { - return await e('plugin:stronghold|initialize', { - snapshotPath: t, - password: r - }).then(() => new i(t)) - } - async unload() { - await e('plugin:stronghold|destroy', { snapshotPath: this.path }) - } - async loadClient(t) { - return await e('plugin:stronghold|load_client', { - snapshotPath: this.path, - client: t - }).then(() => new a(this.path, t)) - } - async createClient(t) { - return await e('plugin:stronghold|create_client', { - snapshotPath: this.path, - client: t - }).then(() => new a(this.path, t)) - } - async save() { - await e('plugin:stronghold|save', { snapshotPath: this.path }) - } - } - return ( - (t.Client = a), - (t.Location = r), - (t.Store = s), - (t.Stronghold = i), - (t.Vault = o), - t - ) - })({}) - Object.defineProperty(window.__TAURI__, 'stronghold', { - value: __TAURI_PLUGIN_STRONGHOLD__ - }) -} +if("__TAURI__"in window){var __TAURI_PLUGIN_STRONGHOLD__=function(t){"use strict";async function e(t,e={},r){return window.__TAURI_INTERNALS__.invoke(t,e,r)}"function"==typeof SuppressedError&&SuppressedError;class r{constructor(t,e){this.type=t,this.payload=e}static generic(t,e){return new r("Generic",{vault:t,record:e})}static counter(t,e){return new r("Counter",{vault:t,counter:e})}}class a{constructor(t){this.procedureArgs=t}async generateSLIP10Seed(t,r){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"SLIP10Generate",payload:{output:t,sizeBytes:r}}}).then((t=>Uint8Array.from(t)))}async deriveSLIP10(t,r,a,n){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"SLIP10Derive",payload:{chain:t,input:{type:r,payload:a},output:n}}}).then((t=>Uint8Array.from(t)))}async recoverBIP39(t,r,a){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"BIP39Recover",payload:{mnemonic:t,passphrase:a,output:r}}}).then((t=>Uint8Array.from(t)))}async generateBIP39(t,r){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"BIP39Generate",payload:{output:t,passphrase:r}}}).then((t=>Uint8Array.from(t)))}async getEd25519PublicKey(t){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"PublicKey",payload:{type:"Ed25519",privateKey:t}}}).then((t=>Uint8Array.from(t)))}async signEd25519(t,r){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"Ed25519Sign",payload:{privateKey:t,msg:r}}}).then((t=>Uint8Array.from(t)))}async getSecp256k1EcdsaPublicKey(t){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"PublicKey",payload:{type:"Secp256k1Ecdsa",privateKey:t}}}).then((t=>Uint8Array.from(t)))}async getSecp256k1EcdsaEvmAddress(t){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"GetEvmAddress",payload:{privateKey:t}}}).then((t=>Uint8Array.from(t)))}async signSecp256k1Ecdsa(t,r,a){return await e("plugin:stronghold|execute_procedure",{...this.procedureArgs,procedure:{type:"Secp256k1EcdsaSign",payload:{flavor:t,privateKey:r,msg:a}}}).then((t=>Uint8Array.from(t)))}}class n{constructor(t,e){this.path=t,this.name=e}getVault(t){return new o(this.path,this.name,t)}getStore(){return new s(this.path,this.name)}}class s{constructor(t,e){this.path=t,this.client=e}async get(t){return await e("plugin:stronghold|get_store_record",{snapshotPath:this.path,client:this.client,key:t}).then((t=>t&&Uint8Array.from(t)))}async insert(t,r,a){await e("plugin:stronghold|save_store_record",{snapshotPath:this.path,client:this.client,key:t,value:r,lifetime:a})}async remove(t){return await e("plugin:stronghold|remove_store_record",{snapshotPath:this.path,client:this.client,key:t}).then((t=>t&&Uint8Array.from(t)))}}class o extends a{constructor(t,e,r){super({snapshotPath:t,client:e,vault:r}),this.path=t,this.client=e,this.name=r}async insert(t,r){await e("plugin:stronghold|save_secret",{snapshotPath:this.path,client:this.client,vault:this.name,recordPath:t,secret:r})}async remove(t){await e("plugin:stronghold|remove_secret",{snapshotPath:this.path,client:this.client,vault:this.name,recordPath:t.payload.record})}}class i{constructor(t){this.path=t}static async load(t,r){return await e("plugin:stronghold|initialize",{snapshotPath:t,password:r}).then((()=>new i(t)))}async unload(){await e("plugin:stronghold|destroy",{snapshotPath:this.path})}async loadClient(t){return await e("plugin:stronghold|load_client",{snapshotPath:this.path,client:t}).then((()=>new n(this.path,t)))}async createClient(t){return await e("plugin:stronghold|create_client",{snapshotPath:this.path,client:t}).then((()=>new n(this.path,t)))}async save(){await e("plugin:stronghold|save",{snapshotPath:this.path})}}return t.Client=n,t.Location=r,t.Store=s,t.Stronghold=i,t.Vault=o,t}({});Object.defineProperty(window.__TAURI__,"stronghold",{value:__TAURI_PLUGIN_STRONGHOLD__})}