Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(2.0 nodejs) Add clearStrongholdPassword to SecretManager #1830

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bindings/core/src/method/secret_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ pub enum SecretManagerMethod {
#[derivative(Debug(format_with = "OmittedDebug::omitted_fmt"))]
password: String,
},
/// Clear the stronghold password.
/// Expected response: [`Ok`](crate::Response::Ok)
#[cfg(feature = "stronghold")]
#[cfg_attr(docsrs, doc(cfg(feature = "stronghold")))]
ClearStrongholdPassword
}

#[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 @@ -159,6 +159,18 @@ where
stronghold.change_password(password).await?;
Response::Ok
}
#[cfg(feature = "stronghold")]
SecretManagerMethod::ClearStrongholdPassword => {
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.clear_key().await;
Response::Ok
}
};
Ok(response)
}
9 changes: 9 additions & 0 deletions bindings/nodejs/lib/secret_manager/secret-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,13 @@ export class SecretManager {
data: { password },
});
}

/**
* Clear the Stronghold password.
*/
async clearStrongholdPassword(): Promise<void> {
await this.methodHandler.callMethod({
name: 'clearStrongholdPassword',
});
}
}
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 @@ -10,6 +10,7 @@ import type {
__SignSecp256k1EcdsaMethod__,
__SetStrongholdPasswordMethod__,
__ChangeStrongholdPasswordMethod__,
__ClearStrongholdPasswordMethod__,
} from './secret-manager';

export type __SecretManagerMethods__ =
Expand All @@ -23,4 +24,5 @@ export type __SecretManagerMethods__ =
| __SignEd25519Method__
| __SignSecp256k1EcdsaMethod__
| __SetStrongholdPasswordMethod__
| __ChangeStrongholdPasswordMethod__;
| __ChangeStrongholdPasswordMethod__
| __ClearStrongholdPasswordMethod__;
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ export interface __ChangeStrongholdPasswordMethod__ {
name: 'changeStrongholdPassword';
data: { password: string };
}

export interface __ClearStrongholdPasswordMethod__ {
name: 'clearStrongholdPassword';
}