Skip to content

Commit

Permalink
Merge branch '2.0' into chore/lock-safety
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M authored Jan 11, 2024
2 parents 0c17f98 + 381c972 commit 74420d1
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
8 changes: 8 additions & 0 deletions bindings/core/src/method/secret_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
12 changes: 12 additions & 0 deletions bindings/core/src/method_handler/secret_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<StrongholdSecretManager>() {
secret_manager
} else if let Some(SecretManager::Stronghold(secret_manager)) = secret_manager.downcast::<SecretManager>() {
secret_manager
} else {
return Err(iota_sdk::client::Error::SecretManagerMismatch.into());
};
stronghold.set_password(password).await?;
Response::Ok
}
};
Ok(response)
}
10 changes: 10 additions & 0 deletions bindings/nodejs/lib/secret_manager/secret-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,14 @@ export class SecretManager {

return JSON.parse(response).payload;
}

/**
* Set the Stronghold password.
*/
async setStrongholdPassword(password: string): Promise<void> {
await this.methodHandler.callMethod({
name: 'setStrongholdPassword',
data: { password },
});
}
}
4 changes: 3 additions & 1 deletion bindings/nodejs/lib/types/secret_manager/bridge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
__SignatureUnlockMethod__,
__SignEd25519Method__,
__SignSecp256k1EcdsaMethod__,
__SetStrongholdPasswordMethod__,
} from './secret-manager';

export type __SecretManagerMethods__ =
Expand All @@ -19,4 +20,5 @@ export type __SecretManagerMethods__ =
| __SignatureUnlockMethod__
| __StoreMnemonicMethod__
| __SignEd25519Method__
| __SignSecp256k1EcdsaMethod__;
| __SignSecp256k1EcdsaMethod__
| __SetStrongholdPasswordMethod__;
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,8 @@ export interface __SignSecp256k1EcdsaMethod__ {
export interface __GetLedgerNanoStatusMethod__ {
name: 'getLedgerNanoStatus';
}

export interface __SetStrongholdPasswordMethod__ {
name: 'setStrongholdPassword';
data: { password: string };
}

0 comments on commit 74420d1

Please sign in to comment.