diff options
author | Sebastian <sebasjm@gmail.com> | 2023-05-26 16:52:30 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-05-26 16:52:30 -0300 |
commit | 69b66e715eae039330898f470a8993d1d154b583 (patch) | |
tree | 794cbd7ba6ae8657dbadc96b0576f33ce488546b /packages/exchange-backoffice-ui/src/account.ts | |
parent | be27647ff73d1529372a80c3e145f3ee4f229a17 (diff) |
account as hook
Diffstat (limited to 'packages/exchange-backoffice-ui/src/account.ts')
-rw-r--r-- | packages/exchange-backoffice-ui/src/account.ts | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/packages/exchange-backoffice-ui/src/account.ts b/packages/exchange-backoffice-ui/src/account.ts index 05f0f8984..bd3c2003e 100644 --- a/packages/exchange-backoffice-ui/src/account.ts +++ b/packages/exchange-backoffice-ui/src/account.ts @@ -16,7 +16,7 @@ export interface Account { } /** - * Restore previous session and unlock account + * Restore previous session and unlock account with password * * @param salt string from which crypto params will be derived * @param key secured private key @@ -55,7 +55,7 @@ declare const opaque_SigningKey: unique symbol; export type SigningKey = Uint8Array & { [opaque_SigningKey]: true }; /** - * Create new account (secured private key) under session + * Create new account (secured private key) * secured with the given password * * @param sessionId @@ -64,8 +64,8 @@ export type SigningKey = Uint8Array & { [opaque_SigningKey]: true }; */ export async function createNewAccount( password: string, -): Promise<LockedAccount> { - const { eddsaPriv } = createEddsaKeyPair(); +): Promise<Account & { safe: LockedAccount }> { + const { eddsaPriv, eddsaPub } = createEddsaKeyPair(); const key = stringToBytes(password); @@ -76,9 +76,11 @@ export async function createNewAccount( password, ); - const protectedPriv = encodeCrock(protectedPrivKey); + const signingKey = eddsaPriv as SigningKey; + const accountId = encodeCrock(eddsaPub) as AccountId; + const safe = encodeCrock(protectedPrivKey) as LockedAccount; - return protectedPriv as LockedAccount; + return { accountId, signingKey, safe }; } export class UnwrapKeyError extends Error { |