diff --git a/bindings/core/src/method/secret_manager.rs b/bindings/core/src/method/secret_manager.rs index d8e9150b31..3df9f6f0a1 100644 --- a/bindings/core/src/method/secret_manager.rs +++ b/bindings/core/src/method/secret_manager.rs @@ -79,6 +79,14 @@ pub enum SecretManagerMethod { #[derivative(Debug(format_with = "OmittedDebug::omitted_fmt"))] mnemonic: String, }, + /// Set the stronghold password. + /// Expected response: [`Ok`](crate::Response::Ok) + #[cfg(feature = "stronghold")] + #[cfg_attr(docsrs, doc(cfg(feature = "stronghold")))] + SetStrongholdPassword { + #[derivative(Debug(format_with = "OmittedDebug::omitted_fmt"))] + password: String, + }, } #[cfg(test)] diff --git a/bindings/core/src/method_handler/secret_manager.rs b/bindings/core/src/method_handler/secret_manager.rs index d766194ee1..09d1f690fb 100644 --- a/bindings/core/src/method_handler/secret_manager.rs +++ b/bindings/core/src/method_handler/secret_manager.rs @@ -135,6 +135,18 @@ where return Err(iota_sdk::client::Error::SecretManagerMismatch.into()); } } + #[cfg(feature = "stronghold")] + SecretManagerMethod::SetStrongholdPassword { password } => { + let stronghold = if let Some(secret_manager) = secret_manager.downcast::() { + secret_manager + } else if let Some(SecretManager::Stronghold(secret_manager)) = secret_manager.downcast::() { + secret_manager + } else { + return Err(iota_sdk::client::Error::SecretManagerMismatch.into()); + }; + stronghold.set_password(password).await?; + Response::Ok + } }; Ok(response) } diff --git a/bindings/nodejs/lib/secret_manager/secret-manager.ts b/bindings/nodejs/lib/secret_manager/secret-manager.ts index c1f4366b7c..ca6bcc3258 100644 --- a/bindings/nodejs/lib/secret_manager/secret-manager.ts +++ b/bindings/nodejs/lib/secret_manager/secret-manager.ts @@ -216,4 +216,14 @@ export class SecretManager { return JSON.parse(response).payload; } + + /** + * Set the Stronghold password. + */ + async setStrongholdPassword(password: string): Promise { + await this.methodHandler.callMethod({ + name: 'setStrongholdPassword', + data: { password }, + }); + } } diff --git a/bindings/nodejs/lib/types/secret_manager/bridge/index.ts b/bindings/nodejs/lib/types/secret_manager/bridge/index.ts index c9901c3440..0584199625 100644 --- a/bindings/nodejs/lib/types/secret_manager/bridge/index.ts +++ b/bindings/nodejs/lib/types/secret_manager/bridge/index.ts @@ -8,6 +8,7 @@ import type { __SignatureUnlockMethod__, __SignEd25519Method__, __SignSecp256k1EcdsaMethod__, + __SetStrongholdPasswordMethod__, } from './secret-manager'; export type __SecretManagerMethods__ = @@ -19,4 +20,5 @@ export type __SecretManagerMethods__ = | __SignatureUnlockMethod__ | __StoreMnemonicMethod__ | __SignEd25519Method__ - | __SignSecp256k1EcdsaMethod__; + | __SignSecp256k1EcdsaMethod__ + | __SetStrongholdPasswordMethod__; diff --git a/bindings/nodejs/lib/types/secret_manager/bridge/secret-manager.ts b/bindings/nodejs/lib/types/secret_manager/bridge/secret-manager.ts index 31bca06493..6daf86dffb 100644 --- a/bindings/nodejs/lib/types/secret_manager/bridge/secret-manager.ts +++ b/bindings/nodejs/lib/types/secret_manager/bridge/secret-manager.ts @@ -70,3 +70,8 @@ export interface __SignSecp256k1EcdsaMethod__ { export interface __GetLedgerNanoStatusMethod__ { name: 'getLedgerNanoStatus'; } + +export interface __SetStrongholdPasswordMethod__ { + name: 'setStrongholdPassword'; + data: { password: string }; +}