@prove-identity/prove-auth 2.15.2 → 3.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.
Files changed (49) hide show
  1. package/README.md +2 -2
  2. package/build/bundle/release/prove-auth.js +1 -1
  3. package/build/lib/index.d.ts +7 -3
  4. package/build/lib/index.js +23 -9
  5. package/build/lib/proveauth/authenticator-builder.d.ts +9 -11
  6. package/build/lib/proveauth/authenticator-builder.js +54 -114
  7. package/build/lib/proveauth/common/base64.js +2 -1
  8. package/build/lib/proveauth/common/logger.js +2 -2
  9. package/build/lib/proveauth/device-context-options.d.ts +0 -8
  10. package/build/lib/proveauth/device-context-options.js +2 -12
  11. package/build/lib/proveauth/device-role.d.ts +4 -0
  12. package/build/lib/proveauth/device-role.js +8 -0
  13. package/build/lib/proveauth/docv.d.ts +11 -0
  14. package/build/lib/proveauth/docv.js +2 -0
  15. package/build/lib/proveauth/instantlink.js +1 -1
  16. package/build/lib/proveauth/internal/auth-request.d.ts +6 -1
  17. package/build/lib/proveauth/internal/auth-response-status.js +1 -1
  18. package/build/lib/proveauth/internal/auth-response.d.ts +6 -0
  19. package/build/lib/proveauth/internal/auth-session.d.ts +1 -2
  20. package/build/lib/proveauth/internal/auth-session.js +57 -32
  21. package/build/lib/proveauth/internal/auth-token-claims.d.ts +4 -0
  22. package/build/lib/proveauth/internal/auth-token-claims.js +1 -1
  23. package/build/lib/proveauth/internal/device-passive-step.d.ts +2 -1
  24. package/build/lib/proveauth/internal/device-passive-step.js +6 -6
  25. package/build/lib/proveauth/internal/device-universal-redirect-steps.js +2 -2
  26. package/build/lib/proveauth/internal/external-integrations.d.ts +34 -0
  27. package/build/lib/proveauth/internal/external-integrations.js +49 -0
  28. package/build/lib/proveauth/internal/fido-options-error.js +1 -1
  29. package/build/lib/proveauth/internal/main-authenticator.d.ts +2 -0
  30. package/build/lib/proveauth/internal/main-authenticator.js +3 -0
  31. package/build/lib/proveauth/internal/mobile-instant-step.d.ts +2 -3
  32. package/build/lib/proveauth/internal/mobile-instant-step.js +61 -67
  33. package/build/lib/proveauth/internal/platform.d.ts +9 -13
  34. package/build/lib/proveauth/internal/platform.js +7 -6
  35. package/build/lib/proveauth/internal/report-error-step.d.ts +1 -0
  36. package/build/lib/proveauth/internal/report-error-step.js +8 -3
  37. package/build/lib/proveauth/internal/user-docv-steps.d.ts +13 -0
  38. package/build/lib/proveauth/internal/user-docv-steps.js +104 -0
  39. package/build/lib/proveauth/internal/user-ppb-steps.js +37 -33
  40. package/build/lib/proveauth/internal/web-device-auth.js +4 -1
  41. package/build/lib/proveauth/internal/web-platform.d.ts +6 -6
  42. package/build/lib/proveauth/internal/web-platform.js +11 -93
  43. package/build/lib/proveauth/internal/web-socket-close-reasons.js +1 -1
  44. package/build/lib/proveauth/otp.js +1 -1
  45. package/build/lib/proveauth/version.d.ts +2 -2
  46. package/build/lib/proveauth/version.js +1 -1
  47. package/package.json +35 -39
  48. package/build/lib/proveauth/external/@authid/web-component/authid-web-component.d.ts +0 -3
  49. package/build/lib/proveauth/external/@authid/web-component/authid-web-component.js +0 -55
@@ -15,24 +15,35 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.InstantLinkResultType = exports.BuildConfig = exports.PhoneValidationError = exports.OtpError = exports.OtpFinishResultType = exports.MobileAuthImplementation = exports.LogLevel = exports.LoggerFactory = exports.DeviceRole = exports.CancelablePromise = exports.AuthResponseStatus = exports.AuthenticatorBuilder = exports.VERSION = void 0;
39
+ exports.InstantLinkResultType = exports.BuildConfig = exports.PhoneValidationError = exports.OtpError = exports.OtpFinishResultType = exports.MobileAuthImplementation = exports.LogLevel = exports.LoggerFactory = exports.DeviceRole = exports.CancelablePromise = exports.AuthResponseStatus = exports.DeviceContextIntegration = exports.PpbIntegration = exports.AuthenticatorBuilder = exports.VERSION = void 0;
30
40
  const version_1 = require("./proveauth/version");
31
41
  Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_1.VERSION; } });
32
42
  const authenticator_builder_1 = __importStar(require("./proveauth/authenticator-builder"));
33
43
  exports.AuthenticatorBuilder = authenticator_builder_1.default;
34
- Object.defineProperty(exports, "DeviceRole", { enumerable: true, get: function () { return authenticator_builder_1.DeviceRole; } });
35
44
  Object.defineProperty(exports, "MobileAuthImplementation", { enumerable: true, get: function () { return authenticator_builder_1.MobileAuthImplementation; } });
45
+ const device_role_1 = require("./proveauth/device-role");
46
+ Object.defineProperty(exports, "DeviceRole", { enumerable: true, get: function () { return device_role_1.DeviceRole; } });
36
47
  const device_context_options_1 = require("./proveauth/device-context-options");
37
48
  Object.defineProperty(exports, "BuildConfig", { enumerable: true, get: function () { return device_context_options_1.BuildConfig; } });
38
49
  const auth_response_status_1 = require("./proveauth/internal/auth-response-status");
@@ -49,3 +60,6 @@ Object.defineProperty(exports, "OtpError", { enumerable: true, get: function ()
49
60
  Object.defineProperty(exports, "OtpFinishResultType", { enumerable: true, get: function () { return otp_1.OtpFinishResultType; } });
50
61
  const instantlink_1 = require("./proveauth/instantlink");
51
62
  Object.defineProperty(exports, "InstantLinkResultType", { enumerable: true, get: function () { return instantlink_1.InstantLinkResultType; } });
63
+ const external_integrations_1 = require("./proveauth/internal/external-integrations");
64
+ Object.defineProperty(exports, "PpbIntegration", { enumerable: true, get: function () { return external_integrations_1.PpbIntegration; } });
65
+ Object.defineProperty(exports, "DeviceContextIntegration", { enumerable: true, get: function () { return external_integrations_1.DeviceContextIntegration; } });
@@ -5,16 +5,13 @@ import { AuthResponseStatus } from './internal/auth-response-status';
5
5
  import Platform from './internal/platform';
6
6
  import { OtpFinishStep, OtpFinishStepFn, OtpStartStep, OtpStartStepFn } from './otp';
7
7
  import { InstantLinkRetryStep, InstantLinkRetryStepFn, InstantLinkStartStep, InstantLinkStartStepFn } from './instantlink';
8
- import type { Region } from '@fingerprintjs/fingerprintjs-pro';
9
- import DeviceContextOptions, { BuildConfig } from './device-context-options';
8
+ import DeviceContextOptions from './device-context-options';
10
9
  import UserConsentStep, { UserConsentStepFn } from './user-consent-step';
11
10
  import { PpbFinishStep, PpbFinishStepFn, PpbStartStep, PpbStartStepFn } from './ppb';
11
+ import { DocVFinishStep, DocVFinishStepFn, DocVStartStep, DocVStartStepFn } from './docv';
12
+ import { DeviceRole } from './device-role';
12
13
  export type AuthMessageHandler = (message: AuthMessage) => Promise<AuthResponseStatus>;
13
14
  export type PasskeyAlreadyExistCallback = () => Promise<AuthResponseStatus>;
14
- export declare enum DeviceRole {
15
- Primary = 0,
16
- Secondary = 1
17
- }
18
15
  export declare enum MobileAuthImplementation {
19
16
  Pixel = "pixel",
20
17
  Fetch = "fetch"
@@ -38,8 +35,11 @@ export default class AuthenticatorBuilder {
38
35
  private ppbEnabled;
39
36
  private ppbStartStep?;
40
37
  private ppbFinishStep?;
41
- private readonly log;
38
+ private docvEnabled;
39
+ private docvStartStep?;
40
+ private docvFinishStep?;
42
41
  private deviceContextOptions?;
42
+ private readonly log;
43
43
  constructor();
44
44
  withDeviceContext(options: DeviceContextOptions): AuthenticatorBuilder;
45
45
  withAuthFinishStep(step: AuthFinishStep | AuthFinishStepFn): AuthenticatorBuilder;
@@ -52,12 +52,10 @@ export default class AuthenticatorBuilder {
52
52
  withDeviceIpAddress(deviceIp: string | (() => string | null) | null): AuthenticatorBuilder;
53
53
  withOtpFallback(startStep: OtpStartStep | OtpStartStepFn, finishStep: OtpFinishStep | OtpFinishStepFn): AuthenticatorBuilder;
54
54
  withInstantLinkFallback(startStep: InstantLinkStartStep | InstantLinkStartStepFn, retryStep?: InstantLinkRetryStep | InstantLinkRetryStepFn): AuthenticatorBuilder;
55
- withUPKEnabled(): this;
56
55
  withUniversalProveKey(step?: UserConsentStep | UserConsentStepFn): this;
57
56
  withPrivacyPreservingBiometrics(startStep?: PpbStartStep | PpbStartStepFn, finishStep?: PpbFinishStep | PpbFinishStepFn): this;
58
- getUrlsByBuildConfig(buildConfig?: BuildConfig): [string | undefined, string | undefined];
59
- getRegionByBuildConfig(buildConfig?: BuildConfig): Region;
60
- private getFpPromiseInstanceFromOptions;
57
+ withDocumentVerification(startStep: DocVStartStep | DocVStartStepFn, finishStep?: DocVFinishStep | DocVFinishStepFn): this;
61
58
  withPasskeyAlreadyExistCallback(handler: PasskeyAlreadyExistCallback): AuthenticatorBuilder;
62
59
  build(): Authenticator;
60
+ private getAuthSteps;
63
61
  }
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.MobileAuthImplementation = exports.DeviceRole = void 0;
6
+ exports.MobileAuthImplementation = void 0;
7
7
  const web_platform_1 = require("./internal/web-platform");
8
8
  const device_passive_register_step_1 = __importDefault(require("./internal/device-passive-register-step"));
9
9
  const device_passive_step_1 = __importDefault(require("./internal/device-passive-step"));
@@ -20,24 +20,21 @@ const device_universal_redirect_steps_1 = require("./internal/device-universal-r
20
20
  const main_authenticator_1 = __importDefault(require("./internal/main-authenticator"));
21
21
  const logger_1 = require("./common/logger");
22
22
  const settings_1 = __importDefault(require("./internal/settings"));
23
- const device_context_options_1 = require("./device-context-options");
24
23
  const user_ppb_steps_1 = require("./internal/user-ppb-steps");
25
- var DeviceRole;
26
- (function (DeviceRole) {
27
- DeviceRole[DeviceRole["Primary"] = 0] = "Primary";
28
- DeviceRole[DeviceRole["Secondary"] = 1] = "Secondary";
29
- })(DeviceRole = exports.DeviceRole || (exports.DeviceRole = {}));
24
+ const user_docv_steps_1 = require("./internal/user-docv-steps");
25
+ const device_role_1 = require("./device-role");
30
26
  var MobileAuthImplementation;
31
27
  (function (MobileAuthImplementation) {
32
28
  MobileAuthImplementation["Pixel"] = "pixel";
33
29
  MobileAuthImplementation["Fetch"] = "fetch";
34
- })(MobileAuthImplementation = exports.MobileAuthImplementation || (exports.MobileAuthImplementation = {}));
30
+ })(MobileAuthImplementation || (exports.MobileAuthImplementation = MobileAuthImplementation = {}));
35
31
  class AuthenticatorBuilder {
36
32
  constructor() {
37
- this.role = DeviceRole.Primary;
33
+ this.role = device_role_1.DeviceRole.Primary;
38
34
  this.mobileAuthImplementation = MobileAuthImplementation.Fetch;
39
35
  this.upkEnabled = false;
40
36
  this.ppbEnabled = false;
37
+ this.docvEnabled = false;
41
38
  this.log = logger_1.LoggerFactory.getLogger('authenticator-builder');
42
39
  if (typeof window !== 'undefined') {
43
40
  this.storage = window.localStorage;
@@ -117,9 +114,6 @@ class AuthenticatorBuilder {
117
114
  }
118
115
  return this;
119
116
  }
120
- withUPKEnabled() {
121
- return this.withUniversalProveKey();
122
- }
123
117
  withUniversalProveKey(step) {
124
118
  if (!step) {
125
119
  this.userConsentStep = { execute: () => Promise.resolve({ consentGranted: true }) };
@@ -149,127 +143,73 @@ class AuthenticatorBuilder {
149
143
  }
150
144
  return this;
151
145
  }
152
- getUrlsByBuildConfig(buildConfig) {
153
- switch (buildConfig) {
154
- case device_context_options_1.BuildConfig.US_PROD:
155
- return [
156
- device_context_options_1.ProveAuthProxyScriptUrl.DEFAULT_US_PROD_SCRIPT_URL.toString(),
157
- device_context_options_1.ProveAuthProxyEndpoint.DEFAULT_US_PROD_ENDPOINT.toString(),
158
- ];
159
- case device_context_options_1.BuildConfig.US_UAT:
160
- return [
161
- device_context_options_1.ProveAuthProxyScriptUrl.DEFAULT_US_UAT_SCRIPT_URL.toString(),
162
- device_context_options_1.ProveAuthProxyEndpoint.DEFAULT_US_UAT_ENDPOINT.toString(),
163
- ];
164
- case device_context_options_1.BuildConfig.DEV:
165
- this.log.debug("Recommended for Prove's internal testing only, BuildConfig.DEV " +
166
- 'might need custom endpoint URL and custom script URL values to bypass ad blockers');
167
- return [undefined, undefined];
168
- default:
169
- this.log.warn('Unknown BuildConfig value: ' + buildConfig);
170
- return [undefined, undefined];
146
+ withDocumentVerification(startStep, finishStep) {
147
+ this.docvEnabled = true;
148
+ if (typeof startStep === 'function') {
149
+ this.docvStartStep = { execute: startStep };
171
150
  }
172
- }
173
- getRegionByBuildConfig(buildConfig) {
174
- var region;
175
- switch (buildConfig) {
176
- case device_context_options_1.BuildConfig.DEV:
177
- case device_context_options_1.BuildConfig.US_PROD:
178
- case device_context_options_1.BuildConfig.US_UAT:
179
- region = 'us';
180
- break;
181
- default:
182
- this.log.warn('Unknown BuildConfig value, set Region to default value: us');
183
- region = 'us';
184
- break;
151
+ else {
152
+ this.docvStartStep = startStep;
185
153
  }
186
- return region;
187
- }
188
- getFpPromiseInstanceFromOptions(options) {
189
- try {
190
- const FingerprintJS = require('@fingerprintjs/fingerprintjs-pro');
191
- if (!FingerprintJS) {
192
- this.log.debug('fingerprintjs package is not installed or failed to load');
193
- }
194
- else if (!options) {
195
- this.log.warn('Prove Key Persistence feature is not enabled');
196
- }
197
- else {
198
- let region = this.getRegionByBuildConfig(options.buildConfig);
199
- let [scriptUrl, endpointUrl] = this.getUrlsByBuildConfig(options.buildConfig);
200
- if (options.customScriptUrl && options.customEndpointUrl) {
201
- scriptUrl = options.customScriptUrl;
202
- endpointUrl = options.customEndpointUrl;
203
- }
204
- const scriptUrlPattern = scriptUrl
205
- ? [
206
- `${scriptUrl}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,
207
- FingerprintJS.defaultScriptUrlPattern,
208
- ]
209
- : [FingerprintJS.defaultScriptUrlPattern];
210
- const endpoint = endpointUrl
211
- ? [`${endpointUrl}?region=${region}`, FingerprintJS.defaultEndpoint]
212
- : [FingerprintJS.defaultEndpoint];
213
- const fpPromise = FingerprintJS.load({
214
- apiKey: options.publicApiKey,
215
- endpoint: endpoint,
216
- scriptUrlPattern: scriptUrlPattern,
217
- region: region,
218
- });
219
- const status = fpPromise ? 'successfully' : 'unsuccessfully with null instance';
220
- this.log.trace(`Instantiating FingerprintJS ${status}`);
221
- return fpPromise;
222
- }
154
+ if (typeof finishStep === 'function') {
155
+ this.docvFinishStep = { execute: finishStep };
223
156
  }
224
- catch (error) {
225
- this.log.trace('FingerprintJS is not installed or failed to load', error);
157
+ else {
158
+ this.docvFinishStep = finishStep;
226
159
  }
160
+ return this;
227
161
  }
228
162
  withPasskeyAlreadyExistCallback(handler) {
229
163
  this.passkeyCreationHandler = handler;
230
164
  return this;
231
165
  }
232
166
  build() {
233
- var _a;
234
167
  if (!this.platform) {
235
168
  throw new Error('Implementation of Platform is required');
236
169
  }
237
170
  if (!this.storage) {
238
171
  throw new Error('Implementation of Storage is required');
239
172
  }
240
- const fpPromise = this.getFpPromiseInstanceFromOptions(this.deviceContextOptions);
241
- if (fpPromise) {
242
- (_a = this.platform) === null || _a === void 0 ? void 0 : _a.setFpPromise(fpPromise);
243
- }
244
173
  const settings = new settings_1.default(this.storage);
245
174
  settings.upkEnabled = this.upkEnabled;
246
- if (this.role === DeviceRole.Primary) {
247
- return new main_authenticator_1.default(this.platform, settings, this.authFinishStep, [
248
- new device_universal_step_1.default(this.upkEnabled),
249
- new device_universal_redirect_steps_1.DeviceUniversalRedirectExchangeStep(),
250
- new device_universal_redirect_steps_1.DeviceUniversalRedirectFinishStep(),
251
- new device_passive_step_1.default(this.getDisplayName, this.passkeyCreationHandler, this.role),
252
- new device_passive_stepup_step_1.default(this.getDisplayName, this.passkeyCreationHandler),
253
- new device_passive_silent_step_1.default(this.upkEnabled, this.userConsentStep),
254
- new device_passive_register_step_1.default(),
255
- new device_passive_verify_step_1.default(),
256
- new mobile_instant_step_1.default(this.mobileAuthImplementation, this.getDeviceIp),
257
- new mobile_instantlink_step_1.default(this.instantLinkStartStep, this.instantLinkRetryStep, this.getDeviceIp),
258
- new mobile_otp_step_1.default(this.otpStartStep, this.otpFinishStep),
259
- new scan_message_step_1.default(this.authMessageHandler),
260
- new user_mobileactive_step_1.default(),
261
- new user_ppb_steps_1.UserPpbEnrollStep(this.ppbEnabled, this.ppbStartStep, this.ppbFinishStep),
262
- new user_ppb_steps_1.UserPpbVerifyStep(this.ppbEnabled, this.ppbStartStep, this.ppbFinishStep),
263
- ]);
175
+ if (this.deviceContextOptions) {
176
+ this.platform.initDeviceContext(this.deviceContextOptions);
264
177
  }
265
- else {
266
- return new main_authenticator_1.default(this.platform, settings, this.authFinishStep, [
267
- new device_passive_step_1.default(this.getDisplayName, undefined, this.role),
268
- new mobile_instant_step_1.default(this.mobileAuthImplementation, this.getDeviceIp),
269
- new mobile_instantlink_step_1.default(this.instantLinkStartStep, this.instantLinkRetryStep, this.getDeviceIp),
270
- new user_ppb_steps_1.UserPpbEnrollStep(this.ppbEnabled, this.ppbStartStep, this.ppbFinishStep),
271
- new user_ppb_steps_1.UserPpbVerifyStep(this.ppbEnabled, this.ppbStartStep, this.ppbFinishStep),
272
- ]);
178
+ const steps = this.getAuthSteps(this.role);
179
+ return new main_authenticator_1.default(this.platform, settings, this.authFinishStep, steps);
180
+ }
181
+ getAuthSteps(role) {
182
+ switch (this.role) {
183
+ case device_role_1.DeviceRole.Primary:
184
+ return [
185
+ new device_universal_step_1.default(this.upkEnabled),
186
+ new device_universal_redirect_steps_1.DeviceUniversalRedirectExchangeStep(),
187
+ new device_universal_redirect_steps_1.DeviceUniversalRedirectFinishStep(),
188
+ new device_passive_step_1.default(this.getDisplayName, this.passkeyCreationHandler, this.role),
189
+ new device_passive_stepup_step_1.default(this.getDisplayName, this.passkeyCreationHandler),
190
+ new device_passive_silent_step_1.default(this.upkEnabled, this.userConsentStep),
191
+ new device_passive_register_step_1.default(),
192
+ new device_passive_verify_step_1.default(),
193
+ new mobile_instant_step_1.default(this.mobileAuthImplementation, this.getDeviceIp),
194
+ new mobile_instantlink_step_1.default(this.instantLinkStartStep, this.instantLinkRetryStep, this.getDeviceIp),
195
+ new mobile_otp_step_1.default(this.otpStartStep, this.otpFinishStep),
196
+ new scan_message_step_1.default(this.authMessageHandler),
197
+ new user_mobileactive_step_1.default(),
198
+ new user_ppb_steps_1.UserPpbEnrollStep(this.ppbEnabled, this.ppbStartStep, this.ppbFinishStep),
199
+ new user_ppb_steps_1.UserPpbVerifyStep(this.ppbEnabled, this.ppbStartStep, this.ppbFinishStep),
200
+ new user_docv_steps_1.UserDocVerifyStep(this.docvEnabled, this.docvStartStep, this.docvFinishStep),
201
+ ];
202
+ case device_role_1.DeviceRole.Secondary:
203
+ return [
204
+ new device_passive_step_1.default(this.getDisplayName, undefined, this.role),
205
+ new mobile_instant_step_1.default(this.mobileAuthImplementation, this.getDeviceIp),
206
+ new mobile_instantlink_step_1.default(this.instantLinkStartStep, this.instantLinkRetryStep, this.getDeviceIp),
207
+ new user_ppb_steps_1.UserPpbEnrollStep(this.ppbEnabled, this.ppbStartStep, this.ppbFinishStep),
208
+ new user_ppb_steps_1.UserPpbVerifyStep(this.ppbEnabled, this.ppbStartStep, this.ppbFinishStep),
209
+ new user_docv_steps_1.UserDocVerifyStep(this.docvEnabled, this.docvStartStep, this.docvFinishStep),
210
+ ];
211
+ default:
212
+ throw new Error(`Unknown role: ${this.role}`);
273
213
  }
274
214
  }
275
215
  }
@@ -6,7 +6,8 @@ class Base64 {
6
6
  '='.repeat(value.length % 4 ? 4 - (value.length % 4) : 0));
7
7
  }
8
8
  static bufferDecode(value) {
9
- return Uint8Array.from(atob(Base64.stringToBase64(value)), (c) => c.charCodeAt(0));
9
+ const uint8Array = Uint8Array.from(atob(Base64.stringToBase64(value)), (c) => c.charCodeAt(0));
10
+ return uint8Array.buffer.slice(uint8Array.byteOffset, uint8Array.byteOffset + uint8Array.byteLength);
10
11
  }
11
12
  static bufferEncode(value) {
12
13
  const arrayValue = ArrayBuffer.isView(value) ? value.buffer : value;
@@ -9,7 +9,7 @@ var LogLevel;
9
9
  LogLevel[LogLevel["info"] = 3] = "info";
10
10
  LogLevel[LogLevel["debug"] = 4] = "debug";
11
11
  LogLevel[LogLevel["trace"] = 5] = "trace";
12
- })(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
12
+ })(LogLevel || (exports.LogLevel = LogLevel = {}));
13
13
  class ConsoleLogger {
14
14
  trace(...args) {
15
15
  console.info(...args);
@@ -80,6 +80,6 @@ class LoggerFactory {
80
80
  };
81
81
  }
82
82
  }
83
+ exports.LoggerFactory = LoggerFactory;
83
84
  LoggerFactory.logWriter = new ConsoleLogWriter();
84
85
  LoggerFactory.logLevel = LogLevel.info;
85
- exports.LoggerFactory = LoggerFactory;
@@ -1,11 +1,3 @@
1
- export declare enum ProveAuthProxyScriptUrl {
2
- DEFAULT_US_UAT_SCRIPT_URL = "https://upk.uat.prove-auth.proveapis.com/vFqZceQyx8/uqLttozA7q",
3
- DEFAULT_US_PROD_SCRIPT_URL = "https://upk.prove-auth.proveapis.com/vf82rhgDRK/r4VnwuwPUd"
4
- }
5
- export declare enum ProveAuthProxyEndpoint {
6
- DEFAULT_US_UAT_ENDPOINT = "https://upk.uat.prove-auth.proveapis.com/vFqZceQyx8/bt9xhGAgQw",
7
- DEFAULT_US_PROD_ENDPOINT = "https://upk.prove-auth.proveapis.com/vf82rhgDRK/ePaZsNne4X"
8
- }
9
1
  export declare enum BuildConfig {
10
2
  DEV = "DEV",
11
3
  US_UAT = "US_UAT",
@@ -1,19 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BuildConfig = exports.ProveAuthProxyEndpoint = exports.ProveAuthProxyScriptUrl = void 0;
4
- var ProveAuthProxyScriptUrl;
5
- (function (ProveAuthProxyScriptUrl) {
6
- ProveAuthProxyScriptUrl["DEFAULT_US_UAT_SCRIPT_URL"] = "https://upk.uat.prove-auth.proveapis.com/vFqZceQyx8/uqLttozA7q";
7
- ProveAuthProxyScriptUrl["DEFAULT_US_PROD_SCRIPT_URL"] = "https://upk.prove-auth.proveapis.com/vf82rhgDRK/r4VnwuwPUd";
8
- })(ProveAuthProxyScriptUrl = exports.ProveAuthProxyScriptUrl || (exports.ProveAuthProxyScriptUrl = {}));
9
- var ProveAuthProxyEndpoint;
10
- (function (ProveAuthProxyEndpoint) {
11
- ProveAuthProxyEndpoint["DEFAULT_US_UAT_ENDPOINT"] = "https://upk.uat.prove-auth.proveapis.com/vFqZceQyx8/bt9xhGAgQw";
12
- ProveAuthProxyEndpoint["DEFAULT_US_PROD_ENDPOINT"] = "https://upk.prove-auth.proveapis.com/vf82rhgDRK/ePaZsNne4X";
13
- })(ProveAuthProxyEndpoint = exports.ProveAuthProxyEndpoint || (exports.ProveAuthProxyEndpoint = {}));
3
+ exports.BuildConfig = void 0;
14
4
  var BuildConfig;
15
5
  (function (BuildConfig) {
16
6
  BuildConfig["DEV"] = "DEV";
17
7
  BuildConfig["US_UAT"] = "US_UAT";
18
8
  BuildConfig["US_PROD"] = "US_PROD";
19
- })(BuildConfig = exports.BuildConfig || (exports.BuildConfig = {}));
9
+ })(BuildConfig || (exports.BuildConfig = BuildConfig = {}));
@@ -0,0 +1,4 @@
1
+ export declare enum DeviceRole {
2
+ Primary = 0,
3
+ Secondary = 1
4
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeviceRole = void 0;
4
+ var DeviceRole;
5
+ (function (DeviceRole) {
6
+ DeviceRole[DeviceRole["Primary"] = 0] = "Primary";
7
+ DeviceRole[DeviceRole["Secondary"] = 1] = "Secondary";
8
+ })(DeviceRole || (exports.DeviceRole = DeviceRole = {}));
@@ -0,0 +1,11 @@
1
+ export default interface DocumentTypeInput {
2
+ documentType: string;
3
+ }
4
+ export interface DocVStartStep {
5
+ execute: () => Promise<DocumentTypeInput>;
6
+ }
7
+ export interface DocVFinishStep {
8
+ execute: (error?: Error) => Promise<void>;
9
+ }
10
+ export type DocVStartStepFn = () => Promise<DocumentTypeInput>;
11
+ export type DocVFinishStepFn = (error?: Error) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -5,4 +5,4 @@ var InstantLinkResultType;
5
5
  (function (InstantLinkResultType) {
6
6
  InstantLinkResultType[InstantLinkResultType["OnResend"] = 0] = "OnResend";
7
7
  InstantLinkResultType[InstantLinkResultType["OnMobileNumberChange"] = 1] = "OnMobileNumberChange";
8
- })(InstantLinkResultType = exports.InstantLinkResultType || (exports.InstantLinkResultType = {}));
8
+ })(InstantLinkResultType || (exports.InstantLinkResultType = InstantLinkResultType = {}));
@@ -1,6 +1,6 @@
1
1
  import { MobileAuthImplementation } from '../authenticator-builder';
2
2
  import { AuthResponseStatus } from './auth-response-status';
3
- export type AuthRequest = V1ClientDeviceFido2RegisterStart | V1ClientDeviceFido2RegisterFinish | V1ClientDeviceFido2VerifyStart | V1ClientDeviceFido2VerifyFinish | V1ClientDevicePassiveRegister | V1ClientDevicePassiveVerify | V1ClientUserResponse | V1ClientAnyError | V1ClientChallenge | V1ClientMobileInstantLinkStart | V1ClientMobileInstantStart | V1ClientMobileInstantFinish | V1ClientOtpStart | V1ClientOtpFinish | V1ClientPpbFinish;
3
+ export type AuthRequest = V1ClientDeviceFido2RegisterStart | V1ClientDeviceFido2RegisterFinish | V1ClientDeviceFido2VerifyStart | V1ClientDeviceFido2VerifyFinish | V1ClientDevicePassiveRegister | V1ClientDevicePassiveVerify | V1ClientUserResponse | V1ClientAnyError | V1ClientChallenge | V1ClientMobileInstantLinkStart | V1ClientMobileInstantStart | V1ClientMobileInstantFinish | V1ClientOtpStart | V1ClientOtpFinish | V1ClientPpbFinish | V1ClientDocVStart | V1ClientDocVFinish;
4
4
  export type AuthRegistration = PassiveRegistration | Fido2Registration;
5
5
  export interface PublicKey {
6
6
  id: string;
@@ -102,3 +102,8 @@ export interface V1ClientPpbFinish {
102
102
  requestId: string;
103
103
  operationId: string;
104
104
  }
105
+ export interface V1ClientDocVStart {
106
+ requestId: string;
107
+ documentType: string;
108
+ }
109
+ export type V1ClientDocVFinish = V1ClientPpbFinish;
@@ -9,4 +9,4 @@ var AuthResponseStatus;
9
9
  AuthResponseStatus["Unexpected"] = "unexpected";
10
10
  AuthResponseStatus["Timeout"] = "timeout";
11
11
  AuthResponseStatus["Unknown"] = "unknown";
12
- })(AuthResponseStatus = exports.AuthResponseStatus || (exports.AuthResponseStatus = {}));
12
+ })(AuthResponseStatus || (exports.AuthResponseStatus = AuthResponseStatus = {}));
@@ -22,6 +22,8 @@ export type OtpFinishResponse = AuthResponse;
22
22
  export type InstantLinkStartResponse = AuthResponse;
23
23
  export type PpbStartResponse = AuthResponse;
24
24
  export type PpbFinishResponse = AuthResponse;
25
+ export type DocVStartResponse = AuthResponse;
26
+ export type DocVFinishResponse = AuthResponse;
25
27
  export interface RegisterStartAuthResponseData {
26
28
  credCreateOptions?: PublicKeyCredentialCreationOptions;
27
29
  credRequestOptions?: PublicKeyCredentialRequestOptions;
@@ -60,3 +62,7 @@ export interface PpbOperation {
60
62
  export interface PpbResponseData extends ResponseData {
61
63
  ppb?: PpbOperation;
62
64
  }
65
+ export type DocVOperation = PpbOperation;
66
+ export interface DocVResponseData extends ResponseData {
67
+ docv?: DocVOperation;
68
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="webappsec-credential-management" />
2
1
  import AuthMessage from './auth-message';
3
2
  import { AuthRequest, Signal } from './auth-request';
4
3
  import AuthResponse, { ResponseData } from './auth-response';
@@ -36,7 +35,7 @@ export default class AuthSession implements AuthSessionIntegration {
36
35
  private getCurrentTimestampInSeconds;
37
36
  markNewFptts(ts?: number): void;
38
37
  resetFptts(): void;
39
- getFingerprintData(): Promise<Signal | undefined>;
38
+ getDeviceContextData(): Promise<Signal | undefined>;
40
39
  shouldCollectFP(): boolean;
41
40
  shouldRefreshFpSignal(currentTimestamp: number): boolean;
42
41
  private parseJwt;
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
@@ -77,7 +86,23 @@ class AuthSession {
77
86
  headers: headers,
78
87
  body: bodyStr,
79
88
  })
80
- .then((response) => response.json())
89
+ .then((response) => __awaiter(this, void 0, void 0, function* () {
90
+ if (!response.ok) {
91
+ const statusSuffix = response.statusText ? ` - ${response.statusText}` : '';
92
+ const errorMessage = `Got ${response.status} HTTP error${statusSuffix}`;
93
+ throw new auth_error_1.default(errorMessage, undefined, undefined, false);
94
+ }
95
+ const responseText = yield response.text();
96
+ if (!responseText) {
97
+ throw new auth_error_1.default('Empty response from server');
98
+ }
99
+ try {
100
+ return JSON.parse(responseText);
101
+ }
102
+ catch (parseError) {
103
+ throw new auth_error_1.default(`Failed to parse JSON response: ${parseError.message}`);
104
+ }
105
+ }))
81
106
  .then((response) => {
82
107
  if (response.error) {
83
108
  if (response.error.code === error_code_1.default.ERROR_NO_DEVICE_FOUND) {
@@ -220,7 +245,7 @@ class AuthSession {
220
245
  }
221
246
  embedFpResultToDeviceRegistration(registration) {
222
247
  return new Promise((resolve) => {
223
- this.getFingerprintData()
248
+ this.getDeviceContextData()
224
249
  .then((result) => {
225
250
  if (result) {
226
251
  registration.setFpSignal(result);
@@ -228,7 +253,7 @@ class AuthSession {
228
253
  resolve(registration);
229
254
  })
230
255
  .catch((error) => {
231
- const errorMsg = `Unexpected error happened during Fingerprint data collection: ${auth_error_1.default.extractMessage(error)}`;
256
+ const errorMsg = `Unexpected error happened during Device Context data collection: ${auth_error_1.default.extractMessage(error)}`;
232
257
  this.log.warn(error);
233
258
  registration.setFpSignal({ error: errorMsg });
234
259
  });
@@ -245,51 +270,50 @@ class AuthSession {
245
270
  resetFptts() {
246
271
  this.settings.fingerPrintTimestamp = null;
247
272
  }
248
- getFingerprintData() {
273
+ getDeviceContextData() {
249
274
  return new Promise((resolve) => {
250
- var fpPromise = this.platform.getFpPromise();
251
275
  if (!this.shouldCollectFP()) {
252
- this.log.trace('Fingerprint is not enabled from AuthToken');
276
+ this.log.trace('DeviceContext is not enabled in the AuthToken');
253
277
  resolve(undefined);
278
+ return;
254
279
  }
255
- else if (!fpPromise) {
256
- const msg = 'Found null instance of Fingerprint, check if your input API key is valid';
257
- this.log.warn(msg);
258
- resolve({ error: msg });
259
- }
260
- else if (!this.shouldRefreshFpSignal(this.getCurrentTimestampInSeconds())) {
261
- this.log.trace('Existing FP signal is not yet expired, skip new collection');
262
- resolve(undefined);
263
- }
264
- else {
265
- this.log.trace('Collect new FP signal');
266
- fpPromise
267
- .then((fp) => fp.get())
268
- .then((result) => {
269
- if (result.sealedResult) {
270
- this.log.debug(`FP result: ${result.sealedResult}`);
271
- resolve({ results: result.sealedResult });
272
- }
273
- else {
274
- const msg = 'Cannot found sealed result in Fingerprint returned payload';
280
+ this.platform.getDataCollector().then((collector) => {
281
+ if (!collector) {
282
+ const msg = 'Found null instance of data collector, check if your input API key is valid ' +
283
+ 'and prove-auth-device-context integration module is properly initialized';
284
+ this.log.warn(msg);
285
+ resolve({ error: msg });
286
+ return;
287
+ }
288
+ if (!this.shouldRefreshFpSignal(this.getCurrentTimestampInSeconds())) {
289
+ this.log.trace('Existing Device Context signal has not yet expired, skipping new collection');
290
+ resolve(undefined);
291
+ return;
292
+ }
293
+ this.log.trace('Collect new Device Context data');
294
+ collector
295
+ .getCollectedData()
296
+ .then((data) => {
297
+ if (!data) {
298
+ const msg = 'Data collector returned no result data';
275
299
  this.log.warn(msg);
276
300
  resolve({ error: msg });
301
+ return;
277
302
  }
303
+ resolve({ results: data });
304
+ return;
278
305
  })
279
306
  .catch((error) => {
280
- const msg = `Error in collecting Fingerprint data: ${auth_error_1.default.extractMessage(error)}`;
307
+ const msg = `Error in collecting Device Context data: ${auth_error_1.default.extractMessage(error)}`;
281
308
  this.log.warn(error);
282
309
  resolve({ error: msg });
283
310
  });
284
- }
311
+ });
285
312
  });
286
313
  }
287
314
  shouldCollectFP() {
288
315
  var _a, _b, _c;
289
- if ((_c = (_b = (_a = this.claims) === null || _a === void 0 ? void 0 : _a.auth.subs.dev) === null || _b === void 0 ? void 0 : _b.sgnls) === null || _c === void 0 ? void 0 : _c.fpt) {
290
- return true;
291
- }
292
- return false;
316
+ return (_c = (_b = (_a = this.claims) === null || _a === void 0 ? void 0 : _a.auth.subs.dev) === null || _b === void 0 ? void 0 : _b.sgnls) === null || _c === void 0 ? void 0 : _c.fpt;
293
317
  }
294
318
  shouldRefreshFpSignal(currentTimestamp) {
295
319
  var _a, _b, _c, _d;
@@ -298,6 +322,7 @@ class AuthSession {
298
322
  return true;
299
323
  }
300
324
  const refreshRate = (_d = (_c = (_b = (_a = this.claims) === null || _a === void 0 ? void 0 : _a.auth.subs.dev) === null || _b === void 0 ? void 0 : _b.sgnls) === null || _c === void 0 ? void 0 : _c.fptrr) !== null && _d !== void 0 ? _d : 0;
325
+ this.log.debug(`Device Context refresh rate: ${refreshRate}`);
301
326
  const interval = currentTimestamp - this.settings.fingerPrintTimestamp;
302
327
  return interval >= refreshRate;
303
328
  }