aboutsummaryrefslogtreecommitdiff
path: root/packages/aml-backoffice-ui/src/hooks/officer.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/aml-backoffice-ui/src/hooks/officer.ts')
-rw-r--r--packages/aml-backoffice-ui/src/hooks/officer.ts18
1 files changed, 9 insertions, 9 deletions
diff --git a/packages/aml-backoffice-ui/src/hooks/officer.ts b/packages/aml-backoffice-ui/src/hooks/officer.ts
index 3ac4c857c..dabe866d3 100644
--- a/packages/aml-backoffice-ui/src/hooks/officer.ts
+++ b/packages/aml-backoffice-ui/src/hooks/officer.ts
@@ -19,6 +19,7 @@ import {
LockedAccount,
OfficerAccount,
OfficerId,
+ OperationOk,
SigningKey,
buildCodecForObject,
codecForAbsoluteTime,
@@ -26,6 +27,7 @@ import {
createNewOfficerAccount,
decodeCrock,
encodeCrock,
+ opFixedSuccess,
unlockOfficerAccount,
} from "@gnu-taler/taler-util";
import { buildStorageKey, useExchangeApiContext, useLocalStorage } from "@gnu-taler/web-util/browser";
@@ -60,7 +62,7 @@ export type OfficerState = OfficerNotReady | OfficerReady;
export type OfficerNotReady = OfficerNotFound | OfficerLocked;
interface OfficerNotFound {
state: "not-found";
- create: (password: string) => Promise<void>;
+ create: (password: string) => Promise<OperationOk<OfficerId>>;
}
interface OfficerLocked {
state: "locked";
@@ -81,7 +83,7 @@ const DEV_ACCOUNT_KEY = buildStorageKey(
);
export function useOfficer(): OfficerState {
- const exchangeContext = useExchangeApiContext();
+ const {lib:{exchange: api}} = useExchangeApiContext();
const [pref] = usePreferences();
pref.keepSessionAfterReload;
// dev account, is kept on reloaded.
@@ -105,16 +107,12 @@ export function useOfficer(): OfficerState {
return {
state: "not-found",
create: async (pwd: string) => {
- const req = await fetch(
- new URL("seed", exchangeContext.lib.exchange.baseUrl).href,
- );
- const b = await req.blob();
- const ar = await b.arrayBuffer();
- const uintar = new Uint8Array(ar);
+ const resp = await api.getSeed()
+ const extraEntropy = resp.type === "ok" ? resp.body : new Uint8Array();
const { id, safe, signingKey } = await createNewOfficerAccount(
pwd,
- uintar,
+ extraEntropy,
);
officerStorage.update({
account: safe,
@@ -124,6 +122,8 @@ export function useOfficer(): OfficerState {
// accountStorage.update({ id, signingKey });
const strKey = encodeCrock(signingKey);
accountStorage.update({ id, strKey });
+
+ return opFixedSuccess(id)
},
};
}