feat(dangerous protections): disable dangerous operations by default
This commit is contained in:
@@ -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',
|
||||
|
Reference in New Issue
Block a user