Skip to content

Commit 1d3e4ad

Browse files
committed
fix: set onboarding pin
1 parent 1d6ee27 commit 1d3e4ad

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

infrastructure/eid-wallet/src/lib/global/controllers/security.ts

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { invoke } from "@tauri-apps/api/core";
22
import { type Status, checkStatus } from "@tauri-apps/plugin-biometric";
33
import type { Store } from "@tauri-apps/plugin-store";
44
/**
5-
* @author SoSweetHam <soham@auvo.io>
5+
* @author SoSweetHam <soham@ensombl.io>
66
* @description A security controller that can enable/disable biometric authentication for the app and provide for basic pin based application authentication schemes.
77
*
88
* Uses the following namespaces in the store:
@@ -29,7 +29,7 @@ export class SecurityController {
2929
}
3030

3131
/**
32-
* @author SoSweetHam <soham@auvo.io>
32+
* @author SoSweetHam <soham@ensombl.io>
3333
* @description Store hash of app pin lock by providing the pin in 4 digit plain text
3434
* @memberof SecurityController
3535
* @param pin - The pin in plain text
@@ -51,7 +51,7 @@ export class SecurityController {
5151
}
5252

5353
/**
54-
* @author SoSweetHam <soham@auvo.io>
54+
* @author SoSweetHam <soham@ensombl.io>
5555
* @returns The pin hash if set, else undefined
5656
* @throws Error if the pin is not set
5757
* @description Get the pin hash for the app if set
@@ -66,7 +66,7 @@ export class SecurityController {
6666
}
6767

6868
/**
69-
* @author SoSweetHam <soham@auvo.io>
69+
* @author SoSweetHam <soham@ensombl.io>
7070
* @description Clear the pin for the app - For debug use only, ideally.
7171
* @memberof SecurityController
7272
* @returns void
@@ -76,7 +76,7 @@ export class SecurityController {
7676
}
7777

7878
/**
79-
* @author SoSweetHam <soham@auvo.io>
79+
* @author SoSweetHam <soham@ensombl.io>
8080
* @description Verify the pin for the app
8181
* @memberof SecurityController
8282
* @param pin The pin in plain text.
@@ -93,7 +93,7 @@ export class SecurityController {
9393
}
9494

9595
/**
96-
* @author SoSweetHam <soham@auvo.io>
96+
* @author SoSweetHam <soham@ensombl.io>
9797
* @memberof SecurityController
9898
* @description Set/Update the pin for the app
9999
* @param newPin The new pin in plain text
@@ -136,7 +136,28 @@ export class SecurityController {
136136
}
137137

138138
/**
139-
* @author SoSweetHam <soham@auvo.io>
139+
* @author SoSweetHam <soham@ensombl.io>
140+
* @memberof SecurityController
141+
* @description Set the onboarding pin for the app
142+
* @param pin - The pin in plain text
143+
* @param confirmPin - The confirm pin in plain text
144+
* @returns void
145+
* @throws Error if the pins are not the same
146+
* @example
147+
* ```ts
148+
* const globalState = await GlobalState.create();
149+
* globalState.securityController.setOnboardingPin("1234", "1234");
150+
* ```
151+
*/
152+
async setOnboardingPin(pin: string, confirmPin: string) {
153+
if (pin !== confirmPin) {
154+
throw new Error("Pins are not the same!");
155+
}
156+
return await this.#setPin(pin);
157+
}
158+
159+
/**
160+
* @author SoSweetHam <soham@ensombl.io>
140161
* @memberof SecurityController
141162
* @description Get the pin hash for the app if set
142163
* @returns A promise for the pin hash
@@ -152,7 +173,7 @@ export class SecurityController {
152173
}
153174

154175
/**
155-
* @author SoSweetHam <soham@auvo.io>
176+
* @author SoSweetHam <soham@ensombl.io>
156177
* @memberof SecurityController
157178
* @description Set the biometric authentication for the app
158179
* @param value - Enable/Disable biometric authentication
@@ -177,7 +198,7 @@ export class SecurityController {
177198
}
178199

179200
/**
180-
* @author SoSweetHam <soham@auvo.io>
201+
* @author SoSweetHam <soham@ensombl.io>
181202
* @memberof SecurityController
182203
* @description Set the biometric authentication status for the app, if the biometric is not supported, it will be set to false
183204
* @param value - Enable/Disable biometric authentication
@@ -197,7 +218,7 @@ export class SecurityController {
197218
}
198219

199220
/**
200-
* @author SoSweetHam <soham@auvo.io>
221+
* @author SoSweetHam <soham@ensombl.io>
201222
* @memberof SecurityController
202223
* @description Get the biometric authentication status for the app
203224
* @returns A promise for the biometric authentication status

infrastructure/eid-wallet/src/routes/(auth)/register/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ onMount(async () => {
9696
9797
isError = false;
9898
try {
99-
await globalState?.securityController.updatePin(pin, repeatPin);
99+
await globalState?.securityController.setOnboardingPin(pin, repeatPin);
100100
showDrawer = true;
101101
} catch (error) {
102102
console.error("Failed to update PIN:", error);

0 commit comments

Comments
 (0)