feat(dangerous protections): disable dangerous operations by default

This commit is contained in:
2025-07-29 12:13:26 +00:00
parent cb6e79ba50
commit dfbf66e339
3 changed files with 16 additions and 0 deletions

View File

@@ -170,6 +170,11 @@ export class BunqMonetaryAccount {
* Update account settings
*/
public async update(updates: any): Promise<void> {
// Check if this is a dangerous operation
if (updates.status === 'CANCELLED' && !this.bunqAccountRef.options.dangerousOperations) {
throw new Error('Dangerous operations are not enabled. Initialize the BunqAccount with dangerousOperations: true to allow cancelling accounts.');
}
await this.bunqAccountRef.apiContext.ensureValidSession();
const endpoint = `/v1/user/${this.bunqAccountRef.userId}/monetary-account/${this.id}`;
@@ -235,6 +240,10 @@ export class BunqMonetaryAccount {
* Close this monetary account
*/
public async close(reason: string): Promise<void> {
if (!this.bunqAccountRef.options.dangerousOperations) {
throw new Error('Dangerous operations are not enabled. Initialize the BunqAccount with dangerousOperations: true to allow closing accounts.');
}
await this.update({
status: 'CANCELLED',
sub_status: 'REDEMPTION_VOLUNTARY',