Skip to content
Snippets Groups Projects
Commit 82cb8e81 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Convert GetOrInitPassword to return a promise and throw the exception directly

parent 0c7288d1
No related branches found
No related tags found
1 merge request!109Project/haven beta
......@@ -93,17 +93,20 @@ const (
// Parameters:
// - args[0] - The user supplied password (string).
//
// Returns:
// Returns a promise:
// - Internal password (Uint8Array).
// - Throws TypeError on failure.
func GetOrInitPassword(_ js.Value, args []js.Value) any {
internalPassword, err := getOrInit(args[0].String())
if err != nil {
exception.ThrowTrace(err)
return nil
promiseFn := func(resolve, reject func(args ...any) js.Value) {
internalPassword, err := getOrInit(args[0].String())
if err != nil {
reject(exception.NewTrace(err))
} else {
resolve(utils.CopyBytesToJS(internalPassword))
}
}
return utils.CopyBytesToJS(internalPassword)
return utils.CreatePromise(promiseFn)
}
// ChangeExternalPassword allows a user to change their external password.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment