cordova-digital-onboarding 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/Changelog.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0 (Dec, 2025)
4
+
5
+ - PowerAuth Cordova SDK dependency now requires v. `4.2.0`.
6
+ - Process cache is now persistent across app restarts.
7
+ - Changes to `WDOError`:
8
+ - added `reason: WDOErrorReason` property to specify the error cause.
9
+ - added `allowOnboardingOtpRetry: boolean` property to indicate if OTP retry is allowed (during activation failure).
10
+ - modified `onboardingOtpRemainingAttempts` to parse the remaining attempts from the original exception (during activation failure).
11
+ - `WDOActivaitonService` changes:
12
+ - `hasActiveProcess()` now returns Promise<boolean> instead of boolean.
13
+ - `clear()` is now asynchronous and returns Promise<void>.
14
+ - `WDOActivaitonService` changes:
15
+ - removed `consent` state
16
+ - replaced `consentApprove` with `start` method with a `consent` argument.
17
+ - `consentGet` now returns Promise<string> instead of the verification state.
18
+ - `documentsInitSDK` method now returns strongly typed response.
19
+ - `presenceCheckInit` method now returns strongly typed response.
20
+ - `intro` state now contains `consentRequired: boolean` property in the corresponding union type.
21
+
3
22
  ## 1.0.0 (Nov, 2025)
4
23
 
5
24
  Initial release.
@@ -126,7 +126,7 @@ Use the `activate` function to create the activation.
126
126
  /**
127
127
  * Activate the PowerAuth instance that was passed in the initializer.
128
128
  *
129
- * @param activationName Name of the activation. Device name by default (usually something like John's iPhone or similar).
129
+ * @param activationName Name of the activation. Usually something like John's iPhone or similar.
130
130
  * @param otp OTP code received by the user (via SMS or email). Optional when not required.
131
131
  * @return Promise resolved with activation result.
132
132
  */
@@ -148,9 +148,9 @@ class MyUserService {
148
148
  // the PIN keyboard to finish the PowerAuthSDK initialization.
149
149
  // For more information, follow the PowerAuthSDK documentation.
150
150
  } catch (error) {
151
- if (allowOnboardingOtpRetry(error)) {
151
+ if (error instanceof WDOError && error.allowOnboardingOtpRetry) {
152
152
  // User entered the wrong OTP, prompt for a new one.
153
- // Remaining OTP attempts count: onboardingOtpRemainingAttempts(error)
153
+ // Remaining OTP attempts count: error.onboardingOtpRemainingAttempts
154
154
  } else {
155
155
  // show error UI
156
156
  }
@@ -57,14 +57,6 @@ declare enum WDOVerificationStateType {
57
57
  * The next step should be calling the `consentGet()`.
58
58
  */
59
59
  intro = "intro",
60
- /**
61
- * Show approve/cancel user consent.
62
- *
63
- * The content of the text depends on the server configuration and might be plain text or HTML.
64
- *
65
- * The next step should be calling the `consentApprove`.
66
- */
67
- consent = "consent",
68
60
  /**
69
61
  * Show document selection to the user. Which documents are available and how many
70
62
  * can the user select is up to your backend configuration.
@@ -119,6 +111,117 @@ declare enum WDOVerificationStateType {
119
111
  }
120
112
  ```
121
113
 
114
+ Based on the type value, additional data is provided in the union type `WDOVerificationState`.
115
+
116
+ Available data per state type:
117
+
118
+ ```typescript
119
+ export type WDOVerificationState =
120
+ | WDOIntroState
121
+ | WDODocumentsToScanSelectState
122
+ | WDOScanDocumentState
123
+ | WDOProcessingState
124
+ | WDOPresenceCheckState
125
+ | WDOOtpState
126
+ | WDOFailedState
127
+ | WDOEndStateState
128
+ | WDOSuccessState
129
+
130
+ /**
131
+ * Show the verification introduction screen where the user can start the activation.
132
+ *
133
+ * The next step should be calling the `start`.
134
+ */
135
+ export interface WDOIntroState {
136
+ type: WDOVerificationStateType.intro,
137
+ /** Indicates whether the user consent is required to proceed */
138
+ consentRequired: boolean
139
+ }
140
+
141
+ /**
142
+ * Show document selection to the user. Which documents are available and how many
143
+ * can the user select is up to your backend configuration.
144
+ *
145
+ * The next step should be calling the `documentsSetSelectedTypes`.
146
+ */
147
+ export interface WDODocumentsToScanSelectState {
148
+ type: WDOVerificationStateType.documentsToScanSelect
149
+ }
150
+
151
+ /**
152
+ * User should scan documents - display UI for the user to scan all necessary documents.
153
+ *
154
+ * The next step should be calling the `documentsSubmit`.
155
+ */
156
+ export interface WDOScanDocumentState {
157
+ type: WDOVerificationStateType.scanDocument
158
+ /** Scanning process that helps with the document scanning */
159
+ process: WDOVerificationScanProcess
160
+ }
161
+
162
+ /**
163
+ * The system is processing data - show loading with text hint from provided `WDOStatusCheckReason`.
164
+ *
165
+ * The next step should be calling the `status`.
166
+ */
167
+ export interface WDOProcessingState {
168
+ type: WDOVerificationStateType.processing
169
+ /** Reason for the current processing state */
170
+ item: WDOStatusCheckReason
171
+ }
172
+
173
+ /**
174
+ * The user should be presented with a presence check.
175
+ * Presence check is handled by third-party SDK based on the project setup.
176
+ *
177
+ * The next step should be calling the `presenceCheckInit` to start the check and `presenceCheckSubmit` to
178
+ * mark it finished. Note that these methods won't change the status and it's up to the app to handle the process of the presence check.
179
+ */
180
+ export interface WDOPresenceCheckState {
181
+ type: WDOVerificationStateType.presenceCheck
182
+ }
183
+
184
+ /**
185
+ * Show enter OTP screen with resend button.
186
+ *
187
+ * The next step should be calling the `verifyOTP` with user-entered OTP.
188
+ * The OTP is usually SMS or email.
189
+ */
190
+ export interface WDOOtpState {
191
+ type: WDOVerificationStateType.otp
192
+ /** Number of remaining attempts to enter the correct OTP */
193
+ remainingAttempts?: number
194
+ }
195
+
196
+ /**
197
+ * Verification failed and can be restarted
198
+ *
199
+ * The next step should be calling the `restartVerification` or `cancelWholeProcess` based on
200
+ * the user's decision if he wants to try it again or cancel the process.
201
+ */
202
+ export interface WDOFailedState {
203
+ type: WDOVerificationStateType.failed
204
+ }
205
+
206
+ /**
207
+ * Verification is canceled and the user needs to start again with a new PowerAuth activation.
208
+ *
209
+ * The next step should be calling the `PowerAuth.removeActivationLocal()` and starting activation from scratch.
210
+ */
211
+ export interface WDOEndStateState {
212
+ type: WDOVerificationStateType.endState
213
+ /** Reason for the end state */
214
+ reason: WDOEndStateReason
215
+ }
216
+
217
+ /**
218
+ * Verification was successfully ended. Continue into your app flow.
219
+ */
220
+ export interface WDOSuccessState {
221
+ type: WDOVerificationStateType.success
222
+ }
223
+ ```
224
+
122
225
  ## Creating an instance
123
226
 
124
227
  To create an instance you will need a `PowerAuth` instance that is __already activated__.
@@ -156,6 +259,16 @@ const verification: WDOVerificationService // configured instance
156
259
  try {
157
260
  const vfStatus = await verification.status()
158
261
  // handle `WDOVerificationState` state and navigate to the expected screen
262
+ if (vfStatus.type === WDOVerificationStateType.intro) {
263
+ // display intro screen
264
+ const consentRequired = vfStatus.consentRequired // accessible based on union type 'intro'
265
+ // show consent info if needed
266
+ verification.start(WDOConsentResponse.approved) // example of starting the process
267
+
268
+ } else if (vfStatus.type === WDOVerificationStateType.documentsToScanSelect) {
269
+ // display document selector
270
+ }
271
+ // ... other states
159
272
  } catch (error) {
160
273
  if (error.verificationState) {
161
274
  // show expected screen based on the state
@@ -165,37 +278,26 @@ try {
165
278
  }
166
279
  ```
167
280
 
168
- ## Getting the user consent text
281
+ ## Starting the identity verification
169
282
 
170
- When the state is `intro`, the first step in the flow is to get the context text for the user to approve.
283
+ When the state is `intro`, the first step in the flow is to start the verification process by calling `start` function.
171
284
 
172
285
  ```typescript
286
+ const state: WDOVerificationState // we're assuming that the state is `intro` here (WDOIntroState)
173
287
  const verification: WDOVerificationService // configured instance
174
288
  try {
175
- const consentTextResponse = await verification.consentGet()
176
- // state will be in the `consent` case here - display the consent screen
177
- } catch (error) {
178
- if (error.verificationState) {
179
- // show expected screen based on the state
289
+ let consentResult: WDOConsentResponse
290
+ const introState = state as WDOIntroState
291
+ if (introState.consentRequired) {
292
+ const consentTextResponse = await verification.consentGet()
293
+ // show consent screen to the user and get his approval
294
+ // assuming user approved the consent here
295
+ consentResult = WDOConsentResponse.approved
180
296
  } else {
181
- // navigate to error screen
297
+ consentResult = WDOConsentResponse.notRequired
182
298
  }
183
- }
184
- ```
185
-
186
- ## Approving the user consent
187
-
188
- When the state is `consent`, you should display the consent text to the user to approve or reject.
189
-
190
- If the user __rejects the consent__, just return him to the intro screen, there's no API call for reject.
191
-
192
- If the user chooses to accept the consent, call `consentApprove` function. If successful, `documentsToScanSelect` state will be returned.
193
-
194
- ```typescript
195
- const verification: WDOVerificationService // configured instance
196
- try {
197
- const approvalResult = await verification.consentApprove()
198
- // state will be in the `documentsToScanSelect` case here - display the document selector
299
+ const startResult = await verification.start(consentResult)
300
+ // process the returned state, should be `documentsToScanSelect` now
199
301
  } catch (error) {
200
302
  if (error.verificationState) {
201
303
  // show expected screen based on the state
@@ -238,6 +340,15 @@ Since the document scanning itself is not provided by this library but by a 3rd
238
340
 
239
341
  If your chosen scanning SDK requires such a step, use this function to retrieve necessary data from the server.
240
342
 
343
+ Example:
344
+
345
+ ```typescript
346
+ const verification: WDOVerificationService // configured instance
347
+ const challengeFromSDK = "..." // optional challenge from the scanning SDK
348
+ const initResult = await verification.documentsInitSDK(challengeFromSDK)
349
+ // use the `initResult` to initialize the scanning SDK
350
+ ```
351
+
241
352
  ## Scanning a document
242
353
 
243
354
  When the state of the process is `scanDocument` with the `WDOVerificationScanProcess` parameter, you need to present a document scan UI to the user. This UI needs