@prove-identity/prove-auth 2.15.2 → 3.0.3
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/README.md +2 -2
- package/build/bundle/release/prove-auth.js +1 -1
- package/build/lib/index.d.ts +7 -3
- package/build/lib/index.js +23 -9
- package/build/lib/proveauth/authenticator-builder.d.ts +9 -11
- package/build/lib/proveauth/authenticator-builder.js +54 -114
- package/build/lib/proveauth/common/base64.js +2 -1
- package/build/lib/proveauth/common/logger.js +2 -2
- package/build/lib/proveauth/device-context-options.d.ts +0 -8
- package/build/lib/proveauth/device-context-options.js +2 -12
- package/build/lib/proveauth/device-role.d.ts +4 -0
- package/build/lib/proveauth/device-role.js +8 -0
- package/build/lib/proveauth/docv.d.ts +11 -0
- package/build/lib/proveauth/docv.js +2 -0
- package/build/lib/proveauth/instantlink.js +1 -1
- package/build/lib/proveauth/internal/auth-request.d.ts +6 -1
- package/build/lib/proveauth/internal/auth-response-status.js +1 -1
- package/build/lib/proveauth/internal/auth-response.d.ts +6 -0
- package/build/lib/proveauth/internal/auth-session.d.ts +0 -1
- package/build/lib/proveauth/internal/auth-session.js +54 -29
- package/build/lib/proveauth/internal/auth-token-claims.d.ts +4 -0
- package/build/lib/proveauth/internal/auth-token-claims.js +1 -1
- package/build/lib/proveauth/internal/device-passive-step.d.ts +2 -1
- package/build/lib/proveauth/internal/device-passive-step.js +4 -4
- package/build/lib/proveauth/internal/device-universal-redirect-steps.js +2 -2
- package/build/lib/proveauth/internal/external-integrations.d.ts +34 -0
- package/build/lib/proveauth/internal/external-integrations.js +49 -0
- package/build/lib/proveauth/internal/fido-options-error.js +1 -1
- package/build/lib/proveauth/internal/main-authenticator.d.ts +2 -0
- package/build/lib/proveauth/internal/main-authenticator.js +3 -0
- package/build/lib/proveauth/internal/platform.d.ts +9 -13
- package/build/lib/proveauth/internal/platform.js +7 -6
- package/build/lib/proveauth/internal/report-error-step.d.ts +1 -0
- package/build/lib/proveauth/internal/report-error-step.js +8 -3
- package/build/lib/proveauth/internal/user-docv-steps.d.ts +13 -0
- package/build/lib/proveauth/internal/user-docv-steps.js +105 -0
- package/build/lib/proveauth/internal/user-ppb-steps.js +37 -33
- package/build/lib/proveauth/internal/web-device-auth.js +4 -1
- package/build/lib/proveauth/internal/web-platform.d.ts +6 -6
- package/build/lib/proveauth/internal/web-platform.js +11 -93
- package/build/lib/proveauth/internal/web-socket-close-reasons.js +1 -1
- package/build/lib/proveauth/otp.js +1 -1
- package/build/lib/proveauth/version.d.ts +2 -2
- package/build/lib/proveauth/version.js +1 -1
- package/package.json +35 -39
- package/build/lib/proveauth/external/@authid/web-component/authid-web-component.d.ts +0 -3
- package/build/lib/proveauth/external/@authid/web-component/authid-web-component.js +0 -55
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import AuthSession from './auth-session';
|
|
2
2
|
import AuthStep from './auth-step';
|
|
3
|
-
import {
|
|
3
|
+
import { PasskeyAlreadyExistCallback } from '../authenticator-builder';
|
|
4
|
+
import { DeviceRole } from '../device-role';
|
|
4
5
|
import { AuthStatusActions } from './auth-status-actions';
|
|
5
6
|
import { Signals } from './auth-request';
|
|
6
7
|
export declare class DevicePassiveActions extends AuthStatusActions {
|
|
@@ -9,7 +9,7 @@ const base64_1 = __importDefault(require("../common/base64"));
|
|
|
9
9
|
const device_passive_silent_step_1 = __importDefault(require("./device-passive-silent-step"));
|
|
10
10
|
const auth_token_claims_1 = require("./auth-token-claims");
|
|
11
11
|
const auth_error_1 = __importDefault(require("./auth-error"));
|
|
12
|
-
const
|
|
12
|
+
const device_role_1 = require("../device-role");
|
|
13
13
|
const auth_status_actions_1 = require("./auth-status-actions");
|
|
14
14
|
const fido_options_error_1 = require("./fido-options-error");
|
|
15
15
|
const auth_response_status_1 = require("./auth-response-status");
|
|
@@ -195,19 +195,19 @@ class DevicePassiveActions extends auth_status_actions_1.AuthStatusActions {
|
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
+
exports.DevicePassiveActions = DevicePassiveActions;
|
|
198
199
|
DevicePassiveActions.NO_REQUEST_CREDS_FOUND = 'Passkey has already been registered but found no CredentialRequestOptions in the fido/register/start response payload';
|
|
199
200
|
DevicePassiveActions.NO_CREDS_FOUND = 'Neither credCreateOptions nor credRequestOptions are found in the fido/register/start response payload';
|
|
200
201
|
DevicePassiveActions.USER_NOT_ACCEPTING_RESPONSE = 'User not accepting to continue by reusing the existing passkey with user response';
|
|
201
|
-
exports.DevicePassiveActions = DevicePassiveActions;
|
|
202
202
|
class DevicePassiveStep extends DevicePassiveActions {
|
|
203
203
|
constructor(getDisplayName, handler, role) {
|
|
204
204
|
super(getDisplayName, handler);
|
|
205
205
|
this.name = DevicePassiveStep.NAME;
|
|
206
|
-
this.role = role !== null && role !== void 0 ? role :
|
|
206
|
+
this.role = role !== null && role !== void 0 ? role : device_role_1.DeviceRole.Primary;
|
|
207
207
|
this.log = logger_1.LoggerFactory.getLogger('device-passive-step');
|
|
208
208
|
}
|
|
209
209
|
execute(session) {
|
|
210
|
-
if (this.role ==
|
|
210
|
+
if (this.role == device_role_1.DeviceRole.Secondary) {
|
|
211
211
|
return this.waitForStatus(session);
|
|
212
212
|
}
|
|
213
213
|
if (!session.platform.isFidoSupported() ||
|
|
@@ -43,13 +43,13 @@ class DeviceUniversalRedirectFinishStep extends DeviceUniversalRedirectBaseStep
|
|
|
43
43
|
this.name = DeviceUniversalRedirectFinishStep.NAME;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
DeviceUniversalRedirectFinishStep.NAME = 'redirect/finish';
|
|
47
46
|
exports.DeviceUniversalRedirectFinishStep = DeviceUniversalRedirectFinishStep;
|
|
47
|
+
DeviceUniversalRedirectFinishStep.NAME = 'redirect/finish';
|
|
48
48
|
class DeviceUniversalRedirectExchangeStep extends DeviceUniversalRedirectBaseStep {
|
|
49
49
|
constructor() {
|
|
50
50
|
super(...arguments);
|
|
51
51
|
this.name = DeviceUniversalRedirectExchangeStep.NAME;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
DeviceUniversalRedirectExchangeStep.NAME = 'redirect/exchange';
|
|
55
54
|
exports.DeviceUniversalRedirectExchangeStep = DeviceUniversalRedirectExchangeStep;
|
|
55
|
+
DeviceUniversalRedirectExchangeStep.NAME = 'redirect/exchange';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import DeviceContextOptions from '../device-context-options';
|
|
2
|
+
export declare abstract class ExternalIntegration {
|
|
3
|
+
protected static readonly log: import("../common/logger").Logger;
|
|
4
|
+
private static readonly instances;
|
|
5
|
+
private readonly name;
|
|
6
|
+
protected constructor(name: string);
|
|
7
|
+
protected static getInstance(name: string): ExternalIntegration;
|
|
8
|
+
protected static activate(instance: ExternalIntegration): void;
|
|
9
|
+
}
|
|
10
|
+
export interface AuthIDResult {
|
|
11
|
+
authIdSuccess?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface AuthIDOptions {
|
|
14
|
+
endpointUrl?: string;
|
|
15
|
+
ppbOperation?: string;
|
|
16
|
+
operationId?: string;
|
|
17
|
+
oneTimeSecret?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare abstract class AuthIDIntegration extends ExternalIntegration {
|
|
20
|
+
static readonly NAME = "AuthID";
|
|
21
|
+
static get instance(): AuthIDIntegration;
|
|
22
|
+
constructor();
|
|
23
|
+
abstract activateWebComponent(options: AuthIDOptions): Promise<AuthIDResult>;
|
|
24
|
+
}
|
|
25
|
+
export interface DataCollector {
|
|
26
|
+
getCollectedData(): Promise<string | undefined>;
|
|
27
|
+
}
|
|
28
|
+
export declare abstract class FingerprintJSIntegration extends ExternalIntegration {
|
|
29
|
+
static readonly NAME = "FingerprintJS";
|
|
30
|
+
static get instance(): FingerprintJSIntegration;
|
|
31
|
+
constructor();
|
|
32
|
+
abstract init(options: DeviceContextOptions): void;
|
|
33
|
+
abstract getDataCollector(): Promise<DataCollector | undefined>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FingerprintJSIntegration = exports.AuthIDIntegration = exports.ExternalIntegration = void 0;
|
|
4
|
+
const logger_1 = require("../common/logger");
|
|
5
|
+
class ExternalIntegration {
|
|
6
|
+
constructor(name) {
|
|
7
|
+
this.name = name;
|
|
8
|
+
ExternalIntegration.activate(this);
|
|
9
|
+
}
|
|
10
|
+
static getInstance(name) {
|
|
11
|
+
const instances = ExternalIntegration.instances;
|
|
12
|
+
if (!instances.has(name)) {
|
|
13
|
+
throw new Error(`${name} integration is not available`);
|
|
14
|
+
}
|
|
15
|
+
return instances.get(name);
|
|
16
|
+
}
|
|
17
|
+
static activate(instance) {
|
|
18
|
+
if (!ExternalIntegration.instances.has(instance.name)) {
|
|
19
|
+
ExternalIntegration.instances.set(instance.name, instance);
|
|
20
|
+
ExternalIntegration.log.info(`${instance.name} integration activated`);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
ExternalIntegration.log.debug(`${instance.name} integration already activated, ignoring`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.ExternalIntegration = ExternalIntegration;
|
|
28
|
+
ExternalIntegration.log = logger_1.LoggerFactory.getLogger('external-integrations');
|
|
29
|
+
ExternalIntegration.instances = new Map();
|
|
30
|
+
class AuthIDIntegration extends ExternalIntegration {
|
|
31
|
+
static get instance() {
|
|
32
|
+
return ExternalIntegration.getInstance(AuthIDIntegration.NAME);
|
|
33
|
+
}
|
|
34
|
+
constructor() {
|
|
35
|
+
super(AuthIDIntegration.NAME);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.AuthIDIntegration = AuthIDIntegration;
|
|
39
|
+
AuthIDIntegration.NAME = 'AuthID';
|
|
40
|
+
class FingerprintJSIntegration extends ExternalIntegration {
|
|
41
|
+
static get instance() {
|
|
42
|
+
return ExternalIntegration.getInstance(FingerprintJSIntegration.NAME);
|
|
43
|
+
}
|
|
44
|
+
constructor() {
|
|
45
|
+
super(FingerprintJSIntegration.NAME);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.FingerprintJSIntegration = FingerprintJSIntegration;
|
|
49
|
+
FingerprintJSIntegration.NAME = 'FingerprintJS';
|
|
@@ -146,6 +146,7 @@ class FidoOptionsError extends Error {
|
|
|
146
146
|
return error;
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
+
exports.FidoOptionsError = FidoOptionsError;
|
|
149
150
|
FidoOptionsError.MISSING_PUBLIC_KEY_PROPERTY = 'options missing publicKey property';
|
|
150
151
|
FidoOptionsError.ABORT_SIGNAL = 'Authentication was sent an abort signal';
|
|
151
152
|
FidoOptionsError.INVALID_STATE_ERROR = 'The authenticator was already registered';
|
|
@@ -158,4 +159,3 @@ FidoOptionsError.NO_MATCHING_AUTHENTICATOR = 'User verification is required but
|
|
|
158
159
|
FidoOptionsError.INVALID_CRED_PARAMS = 'No entry in pubKeyCredParams having the type of public-key';
|
|
159
160
|
FidoOptionsError.NO_MATCHING_AUTHENTICATOR_FOR_PARAMS_ALGO = 'No available authenticator supported any of the specified pubKeyCredParams algorithms';
|
|
160
161
|
FidoOptionsError.INVALID_USER_ID_LENGTH = 'User ID has invalid length';
|
|
161
|
-
exports.FidoOptionsError = FidoOptionsError;
|
|
@@ -5,6 +5,7 @@ import Platform from './platform';
|
|
|
5
5
|
import CancelablePromise from '../common/cancelable-promise';
|
|
6
6
|
import AuthSession from './auth-session';
|
|
7
7
|
import AuthStep from './auth-step';
|
|
8
|
+
import DeviceContextOptions from '../device-context-options';
|
|
8
9
|
export default class MainAuthenticator implements Authenticator {
|
|
9
10
|
static readonly AUTH_DONE = "done";
|
|
10
11
|
static readonly AUTH_EMPTY = "";
|
|
@@ -14,6 +15,7 @@ export default class MainAuthenticator implements Authenticator {
|
|
|
14
15
|
protected readonly platform: Platform;
|
|
15
16
|
protected readonly settings: Settings;
|
|
16
17
|
protected readonly authFinishStep?: AuthFinishStep;
|
|
18
|
+
protected readonly deviceContextOptions?: DeviceContextOptions;
|
|
17
19
|
constructor(platform: Platform, settings: Settings, finishStep?: AuthFinishStep, steps?: Array<AuthStep>);
|
|
18
20
|
isPasskeyRegistered(): boolean;
|
|
19
21
|
isFidoSupported(): boolean;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
/// <reference types="webappsec-credential-management" />
|
|
2
1
|
import { AuthenticatorBuilder } from '@prove-identity/mobile-auth';
|
|
3
2
|
import { AuthRequest } from './auth-request';
|
|
4
3
|
import AuthResponse from './auth-response';
|
|
5
4
|
import DeviceAuth, { DeviceRegistration } from './device-auth';
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
5
|
+
import DeviceContextOptions from '../device-context-options';
|
|
6
|
+
import { AuthIDOptions, AuthIDResult, DataCollector as DataCollector } from './external-integrations';
|
|
8
7
|
export declare const DEVICE_CAPABILITY_WEBAUTHN = "webauthn";
|
|
9
8
|
export interface MessageChannel {
|
|
10
9
|
addEventListener: (type: string, listener: (event: any) => void) => void;
|
|
@@ -28,14 +27,11 @@ export interface AuthSessionIntegration {
|
|
|
28
27
|
getDeviceRegistration: () => Promise<DeviceRegistration | null>;
|
|
29
28
|
fetchFromBackend: (query: string, body: AuthRequest) => Promise<AuthResponse>;
|
|
30
29
|
}
|
|
31
|
-
export interface
|
|
32
|
-
|
|
30
|
+
export interface DocVOptions {
|
|
31
|
+
documentTypeId: string;
|
|
32
|
+
accountNumber: string;
|
|
33
33
|
}
|
|
34
|
-
export interface
|
|
35
|
-
authIdEndpointUrl?: string;
|
|
36
|
-
authIdOperation?: PpbOperation;
|
|
37
|
-
authIdOperationId?: string;
|
|
38
|
-
authIdOneTimeSecret?: string;
|
|
34
|
+
export interface DocVResult {
|
|
39
35
|
}
|
|
40
36
|
export default interface Platform {
|
|
41
37
|
readonly webauthn: WebAuthN;
|
|
@@ -50,10 +46,10 @@ export default interface Platform {
|
|
|
50
46
|
getMobileAuthBuilder: () => AuthenticatorBuilder<any>;
|
|
51
47
|
exit: (code?: number) => void;
|
|
52
48
|
urlRedirect: (url: string) => void;
|
|
53
|
-
getFpPromise: () => Promise<Agent> | undefined;
|
|
54
|
-
setFpPromise: (fpPromise: Promise<Agent>) => void;
|
|
55
49
|
getOrigin: () => string;
|
|
56
|
-
|
|
50
|
+
activateAuthID: (options: AuthIDOptions) => Promise<AuthIDResult>;
|
|
51
|
+
initFingerprintJS: (options: DeviceContextOptions) => void;
|
|
52
|
+
getDataCollector: () => Promise<DataCollector | undefined>;
|
|
57
53
|
}
|
|
58
54
|
export declare function stringToArrayBuffer(input: string): ArrayBuffer;
|
|
59
55
|
export declare function arrayBufferToString(input: ArrayBuffer): string;
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DEVICE_CAPABILITY_WEBAUTHN = void 0;
|
|
4
|
+
exports.stringToArrayBuffer = stringToArrayBuffer;
|
|
5
|
+
exports.arrayBufferToString = arrayBufferToString;
|
|
6
|
+
exports.arrayBufferToHexString = arrayBufferToHexString;
|
|
7
|
+
exports.getUnixTime = getUnixTime;
|
|
4
8
|
exports.DEVICE_CAPABILITY_WEBAUTHN = 'webauthn';
|
|
5
9
|
function stringToArrayBuffer(input) {
|
|
6
|
-
|
|
10
|
+
const uint8Array = new TextEncoder().encode(input);
|
|
11
|
+
return uint8Array.buffer.slice(uint8Array.byteOffset, uint8Array.byteOffset + uint8Array.byteLength);
|
|
7
12
|
}
|
|
8
|
-
exports.stringToArrayBuffer = stringToArrayBuffer;
|
|
9
13
|
function arrayBufferToString(input) {
|
|
10
14
|
return String.fromCharCode.apply(null, Array.from(new Uint8Array(input)));
|
|
11
15
|
}
|
|
12
|
-
exports.arrayBufferToString = arrayBufferToString;
|
|
13
16
|
function arrayBufferToHexString(input) {
|
|
14
17
|
return Array.from(new Uint8Array(input), (x) => ('00' + x.toString(16)).slice(-2)).join('');
|
|
15
18
|
}
|
|
16
|
-
exports.arrayBufferToHexString = arrayBufferToHexString;
|
|
17
19
|
function getUnixTime() {
|
|
18
20
|
return Math.floor(Date.now() / 1000);
|
|
19
21
|
}
|
|
20
|
-
exports.getUnixTime = getUnixTime;
|
|
@@ -2,6 +2,7 @@ import AuthSession from './auth-session';
|
|
|
2
2
|
import AuthStep from './auth-step';
|
|
3
3
|
export default class ReportErrorStep implements AuthStep {
|
|
4
4
|
private static readonly endpointMap;
|
|
5
|
+
private static readonly DEFAULT_MESSAGE;
|
|
5
6
|
private readonly logger;
|
|
6
7
|
private _message;
|
|
7
8
|
private _code?;
|
|
@@ -17,10 +17,11 @@ const user_present_step_1 = __importDefault(require("./user-present-step"));
|
|
|
17
17
|
const device_passive_stepup_step_1 = __importDefault(require("./device-passive-stepup-step"));
|
|
18
18
|
const device_universal_redirect_steps_1 = require("./device-universal-redirect-steps");
|
|
19
19
|
const user_ppb_steps_1 = require("./user-ppb-steps");
|
|
20
|
+
const user_docv_steps_1 = require("./user-docv-steps");
|
|
20
21
|
class ReportErrorStep {
|
|
21
22
|
constructor(error) {
|
|
22
23
|
this.logger = logger_1.LoggerFactory.getLogger('report-error-step');
|
|
23
|
-
this._message =
|
|
24
|
+
this._message = ReportErrorStep.DEFAULT_MESSAGE;
|
|
24
25
|
this.reportable = true;
|
|
25
26
|
this.name = 'error';
|
|
26
27
|
if (error instanceof auth_error_1.default) {
|
|
@@ -44,6 +45,7 @@ class ReportErrorStep {
|
|
|
44
45
|
return this._message;
|
|
45
46
|
}
|
|
46
47
|
execute(session) {
|
|
48
|
+
var _a;
|
|
47
49
|
let logMessage = `Authentication step ${session.lastStep} failed`;
|
|
48
50
|
if (this._code) {
|
|
49
51
|
logMessage = logMessage + ', code: ' + this._code;
|
|
@@ -58,7 +60,7 @@ class ReportErrorStep {
|
|
|
58
60
|
const endpoint = session.lastStep
|
|
59
61
|
? ReportErrorStep.endpointMap.get(session.lastStep)
|
|
60
62
|
: undefined;
|
|
61
|
-
if (endpoint &&
|
|
63
|
+
if (endpoint && this.reportable) {
|
|
62
64
|
return new Promise((resolve, reject) => {
|
|
63
65
|
session
|
|
64
66
|
.fetchFromBackend(`/v1/client/${endpoint}/error`, {
|
|
@@ -73,7 +75,8 @@ class ReportErrorStep {
|
|
|
73
75
|
return Promise.resolve(this.nextStep);
|
|
74
76
|
}
|
|
75
77
|
else {
|
|
76
|
-
|
|
78
|
+
const errorMessage = (_a = this._message) !== null && _a !== void 0 ? _a : ReportErrorStep.DEFAULT_MESSAGE;
|
|
79
|
+
return Promise.reject(new auth_error_1.default(errorMessage, this._code, undefined, false));
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
82
|
}
|
|
@@ -91,5 +94,7 @@ ReportErrorStep.endpointMap = new Map([
|
|
|
91
94
|
[user_present_step_1.default.NAME, 'user/mobileactive'],
|
|
92
95
|
[user_ppb_steps_1.UserPpbEnrollStep.NAME, 'user/ppb'],
|
|
93
96
|
[user_ppb_steps_1.UserPpbVerifyStep.NAME, 'user/ppb'],
|
|
97
|
+
[user_docv_steps_1.UserDocVerifyStep.NAME, 'user/docv'],
|
|
94
98
|
]);
|
|
99
|
+
ReportErrorStep.DEFAULT_MESSAGE = 'Unexpected error, authentication cannot continue';
|
|
95
100
|
exports.default = ReportErrorStep;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import AuthStep from './auth-step';
|
|
2
|
+
import AuthSession from './auth-session';
|
|
3
|
+
import { DocVFinishStep, DocVStartStep } from '../docv';
|
|
4
|
+
export declare class UserDocVerifyStep implements AuthStep {
|
|
5
|
+
static readonly NAME = "user/docv";
|
|
6
|
+
readonly name = "user/docv";
|
|
7
|
+
private readonly log;
|
|
8
|
+
private readonly enabled;
|
|
9
|
+
private readonly startStep;
|
|
10
|
+
private readonly finishStep;
|
|
11
|
+
constructor(enabled: boolean, startStep?: DocVStartStep, finishStep?: DocVFinishStep);
|
|
12
|
+
execute(session: AuthSession): Promise<string>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.UserDocVerifyStep = void 0;
|
|
7
|
+
const logger_1 = require("../common/logger");
|
|
8
|
+
const auth_error_1 = __importDefault(require("./auth-error"));
|
|
9
|
+
class UserDocVerifyStep {
|
|
10
|
+
constructor(enabled, startStep, finishStep) {
|
|
11
|
+
this.name = UserDocVerifyStep.NAME;
|
|
12
|
+
this.log = logger_1.LoggerFactory.getLogger('user-docv-verify-step');
|
|
13
|
+
this.enabled = enabled;
|
|
14
|
+
this.startStep = startStep;
|
|
15
|
+
this.finishStep = finishStep;
|
|
16
|
+
}
|
|
17
|
+
execute(session) {
|
|
18
|
+
if (!this.enabled) {
|
|
19
|
+
return Promise.reject(new auth_error_1.default('Document Verification is not enabled'));
|
|
20
|
+
}
|
|
21
|
+
if (!this.startStep) {
|
|
22
|
+
return Promise.reject(new auth_error_1.default('Document Verification start step is required'));
|
|
23
|
+
}
|
|
24
|
+
const callStart = () => new Promise((resolve, reject) => {
|
|
25
|
+
this.startStep
|
|
26
|
+
.execute()
|
|
27
|
+
.then((output) => {
|
|
28
|
+
session
|
|
29
|
+
.fetchFromBackend('/v1/client/user/docv/start', {
|
|
30
|
+
requestId: crypto.randomUUID(),
|
|
31
|
+
documentType: output.documentType,
|
|
32
|
+
})
|
|
33
|
+
.catch(reject)
|
|
34
|
+
.then((response) => {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
const docvResponse = response;
|
|
37
|
+
if (docvResponse.error) {
|
|
38
|
+
reject(new auth_error_1.default(docvResponse.error.message, docvResponse.error.code, docvResponse.next, false));
|
|
39
|
+
}
|
|
40
|
+
const respData = docvResponse.data;
|
|
41
|
+
resolve({
|
|
42
|
+
documentType: output.documentType,
|
|
43
|
+
operationId: (_a = respData.docv) === null || _a === void 0 ? void 0 : _a.operationId,
|
|
44
|
+
oneTimeSecret: (_b = respData.docv) === null || _b === void 0 ? void 0 : _b.oneTimeSecret,
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
})
|
|
48
|
+
.catch(reject);
|
|
49
|
+
});
|
|
50
|
+
const callFinish = (error) => {
|
|
51
|
+
try {
|
|
52
|
+
if (this.finishStep) {
|
|
53
|
+
return this.finishStep.execute(error);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return Promise.resolve();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
this.log.warn('Document Verification finish step has failed:', e);
|
|
61
|
+
return Promise.reject(e);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
return new Promise((resolve, reject) => {
|
|
65
|
+
callStart()
|
|
66
|
+
.then((startResult) => {
|
|
67
|
+
var _a, _b, _c;
|
|
68
|
+
this.log.debug('Activating AuthID web component');
|
|
69
|
+
session.platform
|
|
70
|
+
.activateAuthID({
|
|
71
|
+
endpointUrl: (_c = (_b = (_a = session.claims) === null || _a === void 0 ? void 0 : _a.auth.subs.usr) === null || _b === void 0 ? void 0 : _b.auths.docv) === null || _c === void 0 ? void 0 : _c.endp,
|
|
72
|
+
ppbOperation: 'enroll',
|
|
73
|
+
operationId: startResult.operationId,
|
|
74
|
+
oneTimeSecret: startResult.oneTimeSecret,
|
|
75
|
+
})
|
|
76
|
+
.catch((e) => {
|
|
77
|
+
this.log.error('AuthID web component failed:', e);
|
|
78
|
+
callFinish(e).then(() => reject(e));
|
|
79
|
+
})
|
|
80
|
+
.then((result) => {
|
|
81
|
+
this.log.info('DocV authentication result', result);
|
|
82
|
+
return session.fetchFromBackend('/v1/client/user/docv/finish', {
|
|
83
|
+
requestId: crypto.randomUUID(),
|
|
84
|
+
operationId: startResult.operationId,
|
|
85
|
+
});
|
|
86
|
+
})
|
|
87
|
+
.then((response) => {
|
|
88
|
+
var _a, _b;
|
|
89
|
+
const docvResponse = response;
|
|
90
|
+
if (docvResponse.error) {
|
|
91
|
+
const message = (_b = (_a = response.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : 'Document verification failed';
|
|
92
|
+
callFinish(new Error(message)).then(() => reject(new auth_error_1.default(response.error.message, response.error.code, response.next, false)));
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
callFinish().then(() => resolve(docvResponse.next));
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
.catch(reject);
|
|
99
|
+
})
|
|
100
|
+
.catch(reject);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.UserDocVerifyStep = UserDocVerifyStep;
|
|
105
|
+
UserDocVerifyStep.NAME = 'user/docv';
|
|
@@ -22,46 +22,50 @@ class UserPpbBaseStep {
|
|
|
22
22
|
if (!data || !data.ppb) {
|
|
23
23
|
return Promise.reject(new auth_error_1.default('PPB session is not initialized'));
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return this.startStep.execute(this.operation);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
return Promise.resolve();
|
|
33
|
-
}
|
|
25
|
+
const callStart = () => {
|
|
26
|
+
try {
|
|
27
|
+
if (this.startStep) {
|
|
28
|
+
return this.startStep.execute(this.operation);
|
|
34
29
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return Promise.reject(e);
|
|
30
|
+
else {
|
|
31
|
+
return Promise.resolve();
|
|
38
32
|
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
this.log.warn('PPB start step has failed:', e);
|
|
36
|
+
return Promise.reject(e);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const callFinish = (error) => {
|
|
40
|
+
try {
|
|
41
|
+
if (this.finishStep) {
|
|
42
|
+
return this.finishStep.execute(this.operation, error);
|
|
48
43
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return Promise.reject(e);
|
|
44
|
+
else {
|
|
45
|
+
return Promise.resolve();
|
|
52
46
|
}
|
|
53
|
-
}
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
this.log.warn('PPB finish step has failed:', e);
|
|
50
|
+
return Promise.reject(e);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
54
|
callStart()
|
|
55
55
|
.then(() => {
|
|
56
56
|
var _a, _b, _c, _d, _e;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
this.log.debug('Activating AuthID web component');
|
|
58
|
+
return session.platform.activateAuthID({
|
|
59
|
+
ppbOperation: this.operation,
|
|
60
|
+
endpointUrl: (_c = (_b = (_a = session.claims) === null || _a === void 0 ? void 0 : _a.auth.subs.usr) === null || _b === void 0 ? void 0 : _b.auths.ppb) === null || _c === void 0 ? void 0 : _c.endp,
|
|
61
|
+
operationId: (_d = data.ppb) === null || _d === void 0 ? void 0 : _d.operationId,
|
|
62
|
+
oneTimeSecret: (_e = data.ppb) === null || _e === void 0 ? void 0 : _e.oneTimeSecret,
|
|
62
63
|
});
|
|
63
64
|
})
|
|
64
|
-
.catch(
|
|
65
|
+
.catch((e) => {
|
|
66
|
+
this.log.error('AuthID web component failed:', e);
|
|
67
|
+
callFinish(e).then(() => reject(e));
|
|
68
|
+
})
|
|
65
69
|
.then((result) => {
|
|
66
70
|
var _a;
|
|
67
71
|
this.log.info('PPB authentication result', result);
|
|
@@ -91,13 +95,13 @@ class UserPpbEnrollStep extends UserPpbBaseStep {
|
|
|
91
95
|
this.name = UserPpbEnrollStep.NAME;
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
|
-
UserPpbEnrollStep.NAME = 'user/ppb/register';
|
|
95
98
|
exports.UserPpbEnrollStep = UserPpbEnrollStep;
|
|
99
|
+
UserPpbEnrollStep.NAME = 'user/ppb/register';
|
|
96
100
|
class UserPpbVerifyStep extends UserPpbBaseStep {
|
|
97
101
|
constructor(enabled, startStep, finishStep) {
|
|
98
102
|
super(enabled, 'verify', startStep, finishStep);
|
|
99
103
|
this.name = UserPpbVerifyStep.NAME;
|
|
100
104
|
}
|
|
101
105
|
}
|
|
102
|
-
UserPpbVerifyStep.NAME = 'user/ppb/verify';
|
|
103
106
|
exports.UserPpbVerifyStep = UserPpbVerifyStep;
|
|
107
|
+
UserPpbVerifyStep.NAME = 'user/ppb/verify';
|
|
@@ -120,7 +120,10 @@ class WebDeviceRegistration {
|
|
|
120
120
|
.toString(16)
|
|
121
121
|
.padStart(2, '0')}${rString}${sString}`;
|
|
122
122
|
const matchSig = derSig.match(/[\da-f]{2}/gi);
|
|
123
|
-
|
|
123
|
+
const uint8Array = matchSig
|
|
124
|
+
? new Uint8Array(matchSig.map((h) => parseInt(h, 16)))
|
|
125
|
+
: new Uint8Array();
|
|
126
|
+
return uint8Array.buffer.slice(uint8Array.byteOffset, uint8Array.byteOffset + uint8Array.byteLength);
|
|
124
127
|
}
|
|
125
128
|
lenVal(val) {
|
|
126
129
|
if (typeof val === 'string' || val instanceof String) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AuthenticatorBuilder } from '@prove-identity/mobile-auth';
|
|
2
|
-
import Platform, { AuthSessionIntegration, MessageChannel,
|
|
2
|
+
import Platform, { AuthSessionIntegration, MessageChannel, RequestSigner } from './platform';
|
|
3
3
|
import WebDeviceAuth from './web-device-auth';
|
|
4
|
-
import {
|
|
4
|
+
import { AuthIDOptions, AuthIDResult, DataCollector } from './external-integrations';
|
|
5
|
+
import DeviceContextOptions from '../device-context-options';
|
|
5
6
|
export declare class WebSocketMessageChannel implements MessageChannel {
|
|
6
7
|
private readonly webSocket;
|
|
7
8
|
constructor(endpointUrl: string);
|
|
@@ -11,7 +12,6 @@ export declare class WebSocketMessageChannel implements MessageChannel {
|
|
|
11
12
|
}
|
|
12
13
|
export declare class WebPlatform implements Platform {
|
|
13
14
|
private readonly log;
|
|
14
|
-
private fpPromise;
|
|
15
15
|
readonly webauthn: {
|
|
16
16
|
getCredentials: (options?: CredentialRequestOptions) => Promise<CredentialType | null>;
|
|
17
17
|
createCredentials: (options: CredentialCreationOptions) => Promise<CredentialType | null>;
|
|
@@ -23,7 +23,9 @@ export declare class WebPlatform implements Platform {
|
|
|
23
23
|
fetch(input: string, init?: RequestInit): Promise<Response>;
|
|
24
24
|
createMessageChannel(input: string): MessageChannel;
|
|
25
25
|
createRequestSigner(session: AuthSessionIntegration): RequestSigner;
|
|
26
|
-
|
|
26
|
+
activateAuthID(options: AuthIDOptions): Promise<AuthIDResult>;
|
|
27
|
+
initFingerprintJS(options: DeviceContextOptions): void;
|
|
28
|
+
getDataCollector(): Promise<DataCollector | undefined>;
|
|
27
29
|
private getBrowserName;
|
|
28
30
|
private getBrowserVersion;
|
|
29
31
|
getOSName(): string;
|
|
@@ -31,7 +33,5 @@ export declare class WebPlatform implements Platform {
|
|
|
31
33
|
getMobileAuthBuilder(): AuthenticatorBuilder<any>;
|
|
32
34
|
exit(code?: number): void;
|
|
33
35
|
urlRedirect(url: string): void;
|
|
34
|
-
getFpPromise(): Promise<Agent> | undefined;
|
|
35
|
-
setFpPromise(fpPromise: Promise<Agent>): void;
|
|
36
36
|
getOrigin(): string;
|
|
37
37
|
}
|