@prove-identity/prove-auth 2.3.5 → 2.4.4
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/build/lib/proveauth/authenticator-builder.js +4 -4
- package/build/lib/proveauth/internal/auth-session.d.ts +0 -2
- package/build/lib/proveauth/internal/auth-session.js +3 -11
- package/build/lib/proveauth/internal/{main-authenticator.d.ts → base-authenticator.d.ts} +3 -7
- package/build/lib/proveauth/internal/{main-authenticator.js → base-authenticator.js} +8 -56
- package/build/lib/proveauth/internal/device-passive-step.d.ts +1 -2
- package/build/lib/proveauth/internal/device-passive-step.js +3 -4
- package/build/lib/proveauth/internal/mobile-instantlink-step.d.ts +1 -2
- package/build/lib/proveauth/internal/mobile-instantlink-step.js +4 -8
- package/build/lib/proveauth/internal/primary-authenticator.d.ts +14 -0
- package/build/lib/proveauth/internal/primary-authenticator.js +64 -0
- package/build/lib/proveauth/internal/report-error-step.js +3 -3
- package/build/lib/proveauth/internal/secondary-authenticator.d.ts +10 -0
- package/build/lib/proveauth/internal/secondary-authenticator.js +65 -0
- package/build/lib/proveauth/internal/web-platform.d.ts +0 -1
- package/build/lib/proveauth/version.d.ts +1 -1
- package/build/lib/proveauth/version.js +1 -1
- package/package.json +2 -6
- package/build/lib/proveauth/internal/auth-status-actions.d.ts +0 -5
- package/build/lib/proveauth/internal/auth-status-actions.js +0 -48
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.MobileAuthImplementation = exports.DeviceRole = void 0;
|
|
7
|
+
const primary_authenticator_1 = __importDefault(require("./internal/primary-authenticator"));
|
|
7
8
|
const web_platform_1 = require("./internal/web-platform");
|
|
8
9
|
const device_passive_register_step_1 = __importDefault(require("./internal/device-passive-register-step"));
|
|
9
10
|
const device_passive_step_1 = __importDefault(require("./internal/device-passive-step"));
|
|
@@ -13,9 +14,9 @@ const mobile_instantlink_step_1 = __importDefault(require("./internal/mobile-ins
|
|
|
13
14
|
const mobile_otp_step_1 = __importDefault(require("./internal/mobile-otp-step"));
|
|
14
15
|
const scan_message_step_1 = __importDefault(require("./internal/scan-message-step"));
|
|
15
16
|
const user_mobileactive_step_1 = __importDefault(require("./internal/user-mobileactive-step"));
|
|
17
|
+
const secondary_authenticator_1 = __importDefault(require("./internal/secondary-authenticator"));
|
|
16
18
|
const device_passive_silent_step_1 = __importDefault(require("./internal/device-passive-silent-step"));
|
|
17
19
|
const device_passive_stepup_step_1 = __importDefault(require("./internal/device-passive-stepup-step"));
|
|
18
|
-
const main_authenticator_1 = __importDefault(require("./internal/main-authenticator"));
|
|
19
20
|
var DeviceRole;
|
|
20
21
|
(function (DeviceRole) {
|
|
21
22
|
DeviceRole[DeviceRole["Primary"] = 0] = "Primary";
|
|
@@ -101,21 +102,20 @@ class AuthenticatorBuilder {
|
|
|
101
102
|
}
|
|
102
103
|
build() {
|
|
103
104
|
if (this.role === DeviceRole.Primary) {
|
|
104
|
-
return new
|
|
105
|
+
return new primary_authenticator_1.default(this.platform, this.storage, this.authFinishStep, [
|
|
105
106
|
new device_passive_step_1.default(this.getDisplayName, this.role),
|
|
106
107
|
new device_passive_stepup_step_1.default(this.getDisplayName),
|
|
107
108
|
new device_passive_silent_step_1.default(),
|
|
108
109
|
new device_passive_register_step_1.default(),
|
|
109
110
|
new device_passive_verify_step_1.default(),
|
|
110
111
|
new mobile_instant_step_1.default(this.mobileAuthImplementation, this.getDeviceIp),
|
|
111
|
-
new mobile_instantlink_step_1.default(this.instantLinkStartStep, this.getDeviceIp),
|
|
112
112
|
new mobile_otp_step_1.default(this.otpStartStep, this.otpFinishStep),
|
|
113
113
|
new user_mobileactive_step_1.default(),
|
|
114
114
|
new scan_message_step_1.default(this.authMessageHandler),
|
|
115
115
|
]);
|
|
116
116
|
}
|
|
117
117
|
else {
|
|
118
|
-
return new
|
|
118
|
+
return new secondary_authenticator_1.default(this.platform, this.storage, this.authFinishStep, [
|
|
119
119
|
new device_passive_step_1.default(this.getDisplayName, this.role),
|
|
120
120
|
new mobile_instant_step_1.default(this.mobileAuthImplementation, this.getDeviceIp),
|
|
121
121
|
new mobile_instantlink_step_1.default(this.instantLinkStartStep, this.getDeviceIp),
|
|
@@ -12,7 +12,6 @@ export default class AuthSession implements AuthSessionIntegration {
|
|
|
12
12
|
readonly claims?: AuthTokenClaims;
|
|
13
13
|
readonly settings: Settings;
|
|
14
14
|
readonly requestSigner: RequestSigner;
|
|
15
|
-
readonly channels: Set<MessageChannel>;
|
|
16
15
|
lastStep: string | null;
|
|
17
16
|
credential: CredentialType | null;
|
|
18
17
|
authMessage: AuthMessage | null;
|
|
@@ -26,7 +25,6 @@ export default class AuthSession implements AuthSessionIntegration {
|
|
|
26
25
|
constructor(settings: Settings, platform: Platform, authToken?: string);
|
|
27
26
|
fetchFromBackend(query: string, body: AuthRequest): Promise<AuthResponse>;
|
|
28
27
|
createMessageChannel(endpointPath: string, onClose: () => void, onError: (message: string) => void, onMessage: (data: string) => void): MessageChannel;
|
|
29
|
-
closeAllMessageChannels(): void;
|
|
30
28
|
getDeviceRegistration(): Promise<DeviceRegistration | null>;
|
|
31
29
|
private parseJwt;
|
|
32
30
|
}
|
|
@@ -30,7 +30,6 @@ class AuthSession {
|
|
|
30
30
|
}
|
|
31
31
|
constructor(settings, platform, authToken) {
|
|
32
32
|
var _a, _b;
|
|
33
|
-
this.channels = new Set();
|
|
34
33
|
this.lastStep = null;
|
|
35
34
|
this.credential = null;
|
|
36
35
|
this.authMessage = null;
|
|
@@ -100,10 +99,11 @@ class AuthSession {
|
|
|
100
99
|
}
|
|
101
100
|
const KEEP_ALIVE_INTERVAL = 30000;
|
|
102
101
|
const endpoint = this.backendUrl.replace(/^http/, 'ws');
|
|
103
|
-
const
|
|
102
|
+
const encodedAuthToken = encodeURIComponent(this.authToken);
|
|
103
|
+
const channel = this.platform.createMessageChannel(endpoint + endpointPath + '?token=' + encodedAuthToken);
|
|
104
104
|
const log = logger_1.LoggerFactory.getLogger('web-message-channel');
|
|
105
105
|
const keepAlive = setInterval(() => {
|
|
106
|
-
log.
|
|
106
|
+
log.debug('Sending keep-alive message');
|
|
107
107
|
channel.send('');
|
|
108
108
|
}, KEEP_ALIVE_INTERVAL);
|
|
109
109
|
channel.addEventListener('close', (_) => {
|
|
@@ -111,7 +111,6 @@ class AuthSession {
|
|
|
111
111
|
clearInterval(keepAlive);
|
|
112
112
|
}
|
|
113
113
|
onClose();
|
|
114
|
-
this.channels.delete(channel);
|
|
115
114
|
});
|
|
116
115
|
channel.addEventListener('error', (event) => {
|
|
117
116
|
if ('message' in event) {
|
|
@@ -135,15 +134,8 @@ class AuthSession {
|
|
|
135
134
|
}
|
|
136
135
|
}
|
|
137
136
|
});
|
|
138
|
-
this.channels.add(channel);
|
|
139
137
|
return channel;
|
|
140
138
|
}
|
|
141
|
-
closeAllMessageChannels() {
|
|
142
|
-
const channelsCopy = new Set(this.channels);
|
|
143
|
-
channelsCopy.forEach((channel) => channel.close());
|
|
144
|
-
channelsCopy.clear();
|
|
145
|
-
this.channels.clear();
|
|
146
|
-
}
|
|
147
139
|
getDeviceRegistration() {
|
|
148
140
|
return new Promise((resolve, reject) => {
|
|
149
141
|
this.platform.deviceAuth
|
|
@@ -5,17 +5,15 @@ import { Logger } from '../common/logger';
|
|
|
5
5
|
import Platform from './platform';
|
|
6
6
|
import CancelablePromise from '../common/cancelable-promise';
|
|
7
7
|
import AuthSession from './auth-session';
|
|
8
|
-
|
|
9
|
-
export default class MainAuthenticator implements Authenticator {
|
|
8
|
+
export default abstract class BaseAuthenticator implements Authenticator {
|
|
10
9
|
static readonly AUTH_DONE = "done";
|
|
11
10
|
static readonly AUTH_EMPTY = "";
|
|
12
11
|
static readonly MAX_ATTEMPTS = 50;
|
|
13
|
-
private readonly steps;
|
|
14
12
|
protected log: Logger;
|
|
15
13
|
protected readonly platform: Platform;
|
|
16
14
|
protected readonly settings: Settings;
|
|
17
15
|
protected readonly authFinishStep?: AuthFinishStep;
|
|
18
|
-
constructor(platform?: Platform, storage?: Storage, finishStep?: AuthFinishStep
|
|
16
|
+
constructor(platform?: Platform, storage?: Storage, finishStep?: AuthFinishStep);
|
|
19
17
|
isPasskeyRegistered(): boolean;
|
|
20
18
|
isFidoSupported(): boolean;
|
|
21
19
|
isDeviceRegistered(): boolean;
|
|
@@ -26,7 +24,5 @@ export default class MainAuthenticator implements Authenticator {
|
|
|
26
24
|
unregisterDevice(): Promise<void>;
|
|
27
25
|
unregisterPasskey(): Promise<void>;
|
|
28
26
|
private unregister;
|
|
29
|
-
process(session: AuthSession): CancelablePromise<void>;
|
|
30
|
-
private nextStep;
|
|
31
|
-
private getNextStep;
|
|
27
|
+
abstract process(session: AuthSession): CancelablePromise<void>;
|
|
32
28
|
}
|
|
@@ -8,26 +8,18 @@ const logger_1 = require("../common/logger");
|
|
|
8
8
|
const cancelable_promise_1 = __importDefault(require("../common/cancelable-promise"));
|
|
9
9
|
const auth_session_1 = __importDefault(require("./auth-session"));
|
|
10
10
|
const auth_error_1 = __importDefault(require("./auth-error"));
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class MainAuthenticator {
|
|
14
|
-
constructor(platform, storage, finishStep, steps) {
|
|
15
|
-
this.steps = new Map();
|
|
11
|
+
class BaseAuthenticator {
|
|
12
|
+
constructor(platform, storage, finishStep) {
|
|
16
13
|
if (!platform) {
|
|
17
14
|
throw new Error('Implementation of Platform is required');
|
|
18
15
|
}
|
|
19
16
|
if (!storage) {
|
|
20
17
|
throw new Error('Implementation of Storage is required');
|
|
21
18
|
}
|
|
22
|
-
this.log = logger_1.LoggerFactory.getLogger('
|
|
19
|
+
this.log = logger_1.LoggerFactory.getLogger('base-authenticator');
|
|
23
20
|
this.platform = platform;
|
|
24
21
|
this.authFinishStep = finishStep;
|
|
25
22
|
this.settings = new settings_1.default(storage);
|
|
26
|
-
if (steps) {
|
|
27
|
-
for (let step of steps) {
|
|
28
|
-
this.steps.set(step.name, step);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
23
|
}
|
|
32
24
|
isPasskeyRegistered() {
|
|
33
25
|
return this.settings.fidoPasskeyRegistered;
|
|
@@ -64,7 +56,7 @@ class MainAuthenticator {
|
|
|
64
56
|
processing
|
|
65
57
|
.then(() => {
|
|
66
58
|
var _a;
|
|
67
|
-
if (session.lastStep !==
|
|
59
|
+
if (session.lastStep !== BaseAuthenticator.AUTH_EMPTY) {
|
|
68
60
|
this.log.info('Authentication flow has been completed.');
|
|
69
61
|
return (_a = this.authFinishStep) === null || _a === void 0 ? void 0 : _a.execute({ authId: session.authId });
|
|
70
62
|
}
|
|
@@ -130,48 +122,8 @@ class MainAuthenticator {
|
|
|
130
122
|
}
|
|
131
123
|
});
|
|
132
124
|
}
|
|
133
|
-
process(session) {
|
|
134
|
-
return new cancelable_promise_1.default((resolve, reject, onCancel) => {
|
|
135
|
-
onCancel(() => {
|
|
136
|
-
this.log.info('Canceled');
|
|
137
|
-
session.closeAllMessageChannels();
|
|
138
|
-
resolve();
|
|
139
|
-
});
|
|
140
|
-
this.nextStep(session, session.next, 1).then(resolve).catch(reject);
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
nextStep(session, step, attempt) {
|
|
144
|
-
this.log.debug(`Authentication attempt ${attempt}, next step: ${step}`);
|
|
145
|
-
session.lastStep = step;
|
|
146
|
-
return new Promise((resolve, reject) => {
|
|
147
|
-
if ([MainAuthenticator.AUTH_DONE, MainAuthenticator.AUTH_EMPTY].includes(step)) {
|
|
148
|
-
resolve();
|
|
149
|
-
}
|
|
150
|
-
else if (attempt > MainAuthenticator.MAX_ATTEMPTS) {
|
|
151
|
-
reject(new auth_error_1.default('Too many authentication steps', error_code_1.default.ERROR_MAX_ATTEMPTS));
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
this.getNextStep(step)
|
|
155
|
-
.execute(session)
|
|
156
|
-
.then((next) => this.nextStep(session, next, attempt + 1))
|
|
157
|
-
.then(resolve)
|
|
158
|
-
.catch((e) => new report_error_step_1.default(e)
|
|
159
|
-
.execute(session)
|
|
160
|
-
.then((next) => this.nextStep(session, next, attempt + 1))
|
|
161
|
-
.then(resolve)
|
|
162
|
-
.catch(reject));
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
getNextStep(step) {
|
|
167
|
-
var nextStep = this.steps.get(step);
|
|
168
|
-
if (nextStep) {
|
|
169
|
-
return nextStep;
|
|
170
|
-
}
|
|
171
|
-
return new report_error_step_1.default('Unknown authentication step: ' + step);
|
|
172
|
-
}
|
|
173
125
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
exports.default =
|
|
126
|
+
BaseAuthenticator.AUTH_DONE = 'done';
|
|
127
|
+
BaseAuthenticator.AUTH_EMPTY = '';
|
|
128
|
+
BaseAuthenticator.MAX_ATTEMPTS = 50;
|
|
129
|
+
exports.default = BaseAuthenticator;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import AuthSession from './auth-session';
|
|
2
2
|
import AuthStep from './auth-step';
|
|
3
3
|
import { DeviceRole } from '../authenticator-builder';
|
|
4
|
-
|
|
5
|
-
export declare class DevicePassiveActions extends AuthStatusActions {
|
|
4
|
+
export declare class DevicePassiveActions {
|
|
6
5
|
protected log: import("../common/logger").Logger;
|
|
7
6
|
private readonly getDisplayName;
|
|
8
7
|
protected constructor(getDisplayName?: () => string | null);
|
|
@@ -10,10 +10,9 @@ const device_passive_silent_step_1 = __importDefault(require("./device-passive-s
|
|
|
10
10
|
const auth_token_claims_1 = require("./auth-token-claims");
|
|
11
11
|
const auth_error_1 = __importDefault(require("./auth-error"));
|
|
12
12
|
const authenticator_builder_1 = require("../authenticator-builder");
|
|
13
|
-
const
|
|
14
|
-
class DevicePassiveActions
|
|
13
|
+
const base_authenticator_1 = __importDefault(require("./base-authenticator"));
|
|
14
|
+
class DevicePassiveActions {
|
|
15
15
|
constructor(getDisplayName) {
|
|
16
|
-
super();
|
|
17
16
|
this.log = logger_1.LoggerFactory.getLogger('device-passive-actions');
|
|
18
17
|
this.getDisplayName = getDisplayName ? getDisplayName : () => null;
|
|
19
18
|
}
|
|
@@ -115,7 +114,7 @@ class DevicePassiveStep extends DevicePassiveActions {
|
|
|
115
114
|
}
|
|
116
115
|
execute(session) {
|
|
117
116
|
if (this.role == authenticator_builder_1.DeviceRole.Secondary) {
|
|
118
|
-
return
|
|
117
|
+
return Promise.resolve(base_authenticator_1.default.AUTH_DONE);
|
|
119
118
|
}
|
|
120
119
|
if (!session.platform.isFidoSupported() ||
|
|
121
120
|
session.uvLevel === auth_token_claims_1.UserVerificationLevel.Discouraged) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import AuthSession from './auth-session';
|
|
2
2
|
import AuthStep from './auth-step';
|
|
3
3
|
import { InstantLinkStartStep } from '../instantlink';
|
|
4
|
-
|
|
5
|
-
export default class MobileInstantLinkStep extends AuthStatusActions implements AuthStep {
|
|
4
|
+
export default class MobileInstantLinkStep implements AuthStep {
|
|
6
5
|
static readonly NAME = "mobile/instantlink";
|
|
7
6
|
readonly name = "mobile/instantlink";
|
|
8
7
|
protected log: import("../common/logger").Logger;
|
|
@@ -6,18 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const logger_1 = require("../common/logger");
|
|
7
7
|
const phone_number_input_1 = require("./phone-number-input");
|
|
8
8
|
const auth_error_1 = __importDefault(require("./auth-error"));
|
|
9
|
-
const auth_status_actions_1 = require("./auth-status-actions");
|
|
10
9
|
const SIMULATED_LINK_CLICK_DELAY = 100;
|
|
11
|
-
class MobileInstantLinkStep
|
|
10
|
+
class MobileInstantLinkStep {
|
|
12
11
|
constructor(startStep, getDeviceIp) {
|
|
13
|
-
super();
|
|
14
12
|
this.name = MobileInstantLinkStep.NAME;
|
|
15
13
|
this.log = logger_1.LoggerFactory.getLogger('mobile-instantlink-step');
|
|
16
14
|
this.startStep = startStep;
|
|
17
15
|
this.getDeviceIp = getDeviceIp !== null && getDeviceIp !== void 0 ? getDeviceIp : (() => null);
|
|
18
16
|
}
|
|
19
17
|
execute(session) {
|
|
20
|
-
this.log.trace('Executing');
|
|
21
18
|
return new Promise((resolve, reject) => {
|
|
22
19
|
var _a, _b, _c, _d, _e, _f;
|
|
23
20
|
var phoneNumberNeeded = true;
|
|
@@ -29,10 +26,9 @@ class MobileInstantLinkStep extends auth_status_actions_1.AuthStatusActions {
|
|
|
29
26
|
testMode = true;
|
|
30
27
|
}
|
|
31
28
|
this.runStartStep(session, phoneNumberNeeded)
|
|
32
|
-
.then((
|
|
29
|
+
.then((next) => {
|
|
33
30
|
this.runFinishStep(session, testMode)
|
|
34
|
-
.then(() =>
|
|
35
|
-
.then((next) => resolve(next))
|
|
31
|
+
.then(() => resolve(next))
|
|
36
32
|
.catch(reject);
|
|
37
33
|
})
|
|
38
34
|
.catch(reject);
|
|
@@ -93,7 +89,7 @@ class MobileInstantLinkStep extends auth_status_actions_1.AuthStatusActions {
|
|
|
93
89
|
session.platform
|
|
94
90
|
.fetch(session.backendUrl +
|
|
95
91
|
'/v1/client/mobile/instantlink/finish?token=' +
|
|
96
|
-
|
|
92
|
+
session.authToken +
|
|
97
93
|
'&vfp=test-vfp', {
|
|
98
94
|
mode: 'cors',
|
|
99
95
|
method: 'GET',
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import AuthFinishStep from '../auth-finish-step';
|
|
2
|
+
import AuthStep from './auth-step';
|
|
3
|
+
import AuthSession from './auth-session';
|
|
4
|
+
import Platform from './platform';
|
|
5
|
+
import CancelablePromise from '../common/cancelable-promise';
|
|
6
|
+
import BaseAuthenticator from './base-authenticator';
|
|
7
|
+
export default class PrimaryAuthenticator extends BaseAuthenticator {
|
|
8
|
+
static readonly MAX_ATTEMPTS = 50;
|
|
9
|
+
private readonly steps;
|
|
10
|
+
constructor(platform?: Platform, storage?: Storage, finishStep?: AuthFinishStep, steps?: Array<AuthStep>);
|
|
11
|
+
process(session: AuthSession): CancelablePromise<void>;
|
|
12
|
+
private nextStep;
|
|
13
|
+
private getNextStep;
|
|
14
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
const report_error_step_1 = __importDefault(require("./report-error-step"));
|
|
7
|
+
const logger_1 = require("../common/logger");
|
|
8
|
+
const cancelable_promise_1 = __importDefault(require("../common/cancelable-promise"));
|
|
9
|
+
const base_authenticator_1 = __importDefault(require("./base-authenticator"));
|
|
10
|
+
const auth_error_1 = __importDefault(require("./auth-error"));
|
|
11
|
+
const error_code_1 = __importDefault(require("./error-code"));
|
|
12
|
+
class PrimaryAuthenticator extends base_authenticator_1.default {
|
|
13
|
+
constructor(platform, storage, finishStep, steps) {
|
|
14
|
+
super(platform, storage, finishStep);
|
|
15
|
+
this.steps = new Map();
|
|
16
|
+
this.log = logger_1.LoggerFactory.getLogger('primary-authenticator');
|
|
17
|
+
if (steps) {
|
|
18
|
+
for (let step of steps) {
|
|
19
|
+
this.steps.set(step.name, step);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
process(session) {
|
|
24
|
+
return new cancelable_promise_1.default((resolve, reject, onCancel) => {
|
|
25
|
+
onCancel(() => {
|
|
26
|
+
this.log.info('Canceled');
|
|
27
|
+
resolve();
|
|
28
|
+
});
|
|
29
|
+
this.nextStep(session, session.next, 1).then(resolve).catch(reject);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
nextStep(session, step, attempt) {
|
|
33
|
+
this.log.debug(`Authentication attempt ${attempt}, next step: ${step}`);
|
|
34
|
+
session.lastStep = step;
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
if ([base_authenticator_1.default.AUTH_DONE, base_authenticator_1.default.AUTH_EMPTY].includes(step)) {
|
|
37
|
+
resolve();
|
|
38
|
+
}
|
|
39
|
+
else if (attempt > PrimaryAuthenticator.MAX_ATTEMPTS) {
|
|
40
|
+
reject(new auth_error_1.default('Too many authentication steps', error_code_1.default.ERROR_MAX_ATTEMPTS));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.getNextStep(step)
|
|
44
|
+
.execute(session)
|
|
45
|
+
.then((next) => this.nextStep(session, next, attempt + 1))
|
|
46
|
+
.then(resolve)
|
|
47
|
+
.catch((e) => new report_error_step_1.default(e)
|
|
48
|
+
.execute(session)
|
|
49
|
+
.then((next) => this.nextStep(session, next, attempt + 1))
|
|
50
|
+
.then(resolve)
|
|
51
|
+
.catch(reject));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
getNextStep(step) {
|
|
56
|
+
var nextStep = this.steps.get(step);
|
|
57
|
+
if (nextStep) {
|
|
58
|
+
return nextStep;
|
|
59
|
+
}
|
|
60
|
+
return new report_error_step_1.default('Unknown authentication step: ' + step);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
PrimaryAuthenticator.MAX_ATTEMPTS = 50;
|
|
64
|
+
exports.default = PrimaryAuthenticator;
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const logger_1 = require("../common/logger");
|
|
7
7
|
const auth_error_1 = __importDefault(require("./auth-error"));
|
|
8
|
-
const
|
|
8
|
+
const base_authenticator_1 = __importDefault(require("./base-authenticator"));
|
|
9
9
|
const device_passive_register_step_1 = __importDefault(require("./device-passive-register-step"));
|
|
10
10
|
const device_passive_silent_step_1 = __importDefault(require("./device-passive-silent-step"));
|
|
11
11
|
const device_passive_step_1 = __importDefault(require("./device-passive-step"));
|
|
@@ -49,8 +49,8 @@ class ReportErrorStep {
|
|
|
49
49
|
logMessage = logMessage + ', message: ' + this._message;
|
|
50
50
|
}
|
|
51
51
|
this.logger.error(logMessage);
|
|
52
|
-
if (this.nextStep ===
|
|
53
|
-
return Promise.resolve(
|
|
52
|
+
if (this.nextStep === base_authenticator_1.default.AUTH_DONE) {
|
|
53
|
+
return Promise.resolve(base_authenticator_1.default.AUTH_DONE);
|
|
54
54
|
}
|
|
55
55
|
else if (!this.nextStep || this.reportable) {
|
|
56
56
|
return new Promise((resolve, reject) => {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import AuthFinishStep from '../auth-finish-step';
|
|
2
|
+
import AuthSession from './auth-session';
|
|
3
|
+
import Platform from './platform';
|
|
4
|
+
import CancelablePromise from '../common/cancelable-promise';
|
|
5
|
+
import AuthStep from './auth-step';
|
|
6
|
+
import PrimaryAuthenticator from './primary-authenticator';
|
|
7
|
+
export default class SecondaryAuthenticator extends PrimaryAuthenticator {
|
|
8
|
+
constructor(platform?: Platform, storage?: Storage, finishStep?: AuthFinishStep, steps?: Array<AuthStep>);
|
|
9
|
+
process(session: AuthSession): CancelablePromise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
const logger_1 = require("../common/logger");
|
|
7
|
+
const cancelable_promise_1 = __importDefault(require("../common/cancelable-promise"));
|
|
8
|
+
const auth_error_1 = __importDefault(require("./auth-error"));
|
|
9
|
+
const primary_authenticator_1 = __importDefault(require("./primary-authenticator"));
|
|
10
|
+
class SecondaryAuthenticator extends primary_authenticator_1.default {
|
|
11
|
+
constructor(platform, storage, finishStep, steps) {
|
|
12
|
+
super(platform, storage, finishStep, steps);
|
|
13
|
+
this.log = logger_1.LoggerFactory.getLogger('secondary-authenticator');
|
|
14
|
+
}
|
|
15
|
+
process(session) {
|
|
16
|
+
return new cancelable_promise_1.default((resolve, reject, onCancel) => {
|
|
17
|
+
var gotResponse = false;
|
|
18
|
+
var channel;
|
|
19
|
+
var runSteps = super.process(session);
|
|
20
|
+
runSteps
|
|
21
|
+
.then(() => {
|
|
22
|
+
channel = session.createMessageChannel('/v1/client/status', () => {
|
|
23
|
+
if (!gotResponse) {
|
|
24
|
+
reject(new auth_error_1.default('Failed to receive secondary authentication status, no response'));
|
|
25
|
+
}
|
|
26
|
+
}, (errorMessage) => {
|
|
27
|
+
gotResponse = true;
|
|
28
|
+
this.log.error('Failed: ' + errorMessage);
|
|
29
|
+
reject(new auth_error_1.default('Failed to receive secondary authentication status: ' + errorMessage));
|
|
30
|
+
}, (data) => {
|
|
31
|
+
gotResponse = true;
|
|
32
|
+
try {
|
|
33
|
+
this.log.debug(('Secondary authentication status: ' + data));
|
|
34
|
+
const response = JSON.parse(data);
|
|
35
|
+
if (response.error) {
|
|
36
|
+
reject(new auth_error_1.default(response.error.message, response.error.code, response.next));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
session.lastStep = response.next;
|
|
40
|
+
resolve();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
reject(e);
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
channel.close();
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
})
|
|
51
|
+
.catch(reject);
|
|
52
|
+
onCancel(() => {
|
|
53
|
+
gotResponse = true;
|
|
54
|
+
if (runSteps) {
|
|
55
|
+
runSteps.cancel();
|
|
56
|
+
}
|
|
57
|
+
if (channel) {
|
|
58
|
+
channel.close();
|
|
59
|
+
}
|
|
60
|
+
resolve();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.default = SecondaryAuthenticator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.USER_AGENT_VERSIONS = exports.API_CONTRACT_VERSION = exports.VERSION = void 0;
|
|
4
|
-
exports.VERSION = '2.3.
|
|
4
|
+
exports.VERSION = '2.3.2';
|
|
5
5
|
exports.API_CONTRACT_VERSION = '2.7.0';
|
|
6
6
|
exports.USER_AGENT_VERSIONS = `ProveAuth/${exports.VERSION} Contract/${exports.API_CONTRACT_VERSION} WEB/1`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prove-identity/prove-auth",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.4",
|
|
4
4
|
"description": "Prove Auth SDK for Web",
|
|
5
5
|
"main": "build/lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -32,10 +32,6 @@
|
|
|
32
32
|
"lint-staged": {
|
|
33
33
|
"**/*": "prettier --check --ignore-unknown"
|
|
34
34
|
},
|
|
35
|
-
"repository": {
|
|
36
|
-
"type": "git",
|
|
37
|
-
"url": "https://github.com/prove-identity/prove-auth-client-web-sdk.git"
|
|
38
|
-
},
|
|
39
35
|
"author": "Prove Identity, Inc.",
|
|
40
36
|
"license": "CC BY-NC-ND 4.0",
|
|
41
37
|
"homepage": "https://www.prove.com/solutions/auth",
|
|
@@ -72,4 +68,4 @@
|
|
|
72
68
|
"dependencies": {
|
|
73
69
|
"@prove-identity/mobile-auth": "^3.0.0"
|
|
74
70
|
}
|
|
75
|
-
}
|
|
71
|
+
}
|
|
@@ -1,48 +0,0 @@
|
|
|
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.AuthStatusActions = void 0;
|
|
7
|
-
const logger_1 = require("../common/logger");
|
|
8
|
-
const auth_error_1 = __importDefault(require("./auth-error"));
|
|
9
|
-
class AuthStatusActions {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.log = logger_1.LoggerFactory.getLogger('auth-status-actions');
|
|
12
|
-
}
|
|
13
|
-
waitForStatus(session) {
|
|
14
|
-
var gotResponse = false;
|
|
15
|
-
this.log.trace('Waiting for auth status');
|
|
16
|
-
return new Promise((resolve, reject) => {
|
|
17
|
-
const channel = session.createMessageChannel('/v1/client/status?token=' + encodeURIComponent(session.authToken), () => {
|
|
18
|
-
if (!gotResponse) {
|
|
19
|
-
reject(new auth_error_1.default('Failed to receive secondary authentication status, no response'));
|
|
20
|
-
}
|
|
21
|
-
}, (errorMessage) => {
|
|
22
|
-
gotResponse = true;
|
|
23
|
-
this.log.error('Failed: ' + errorMessage);
|
|
24
|
-
reject(new auth_error_1.default('Failed to receive secondary authentication status: ' + errorMessage));
|
|
25
|
-
}, (data) => {
|
|
26
|
-
gotResponse = true;
|
|
27
|
-
try {
|
|
28
|
-
this.log.debug(('Secondary authentication status: ' + data));
|
|
29
|
-
const response = JSON.parse(data);
|
|
30
|
-
if (response.error) {
|
|
31
|
-
reject(new auth_error_1.default(response.error.message, response.error.code, response.next));
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
session.lastStep = response.next;
|
|
35
|
-
resolve(response.next);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch (e) {
|
|
39
|
-
reject(e);
|
|
40
|
-
}
|
|
41
|
-
finally {
|
|
42
|
-
channel.close();
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.AuthStatusActions = AuthStatusActions;
|