@prove-identity/prove-auth 2.7.1 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -9
- package/build/bundle/release/prove-auth.js +1 -0
- package/build/lib/index.d.ts +3 -2
- package/build/lib/index.js +3 -1
- package/build/lib/proveauth/authenticator-builder.d.ts +4 -0
- package/build/lib/proveauth/authenticator-builder.js +59 -3
- package/build/lib/proveauth/darwinium-result.d.ts +11 -0
- package/build/lib/proveauth/darwinium-result.js +25 -0
- package/build/lib/proveauth/darwinium-wrapper.d.ts +6 -0
- package/build/lib/proveauth/darwinium-wrapper.js +97 -0
- package/build/lib/proveauth/device-context-options.d.ts +7 -0
- package/build/lib/proveauth/device-context-options.js +7 -1
- package/build/lib/proveauth/internal/auth-error.js +1 -1
- package/build/lib/proveauth/internal/auth-request.d.ts +1 -0
- package/build/lib/proveauth/internal/auth-response.d.ts +5 -1
- package/build/lib/proveauth/internal/auth-session.d.ts +7 -2
- package/build/lib/proveauth/internal/auth-session.js +115 -11
- package/build/lib/proveauth/internal/auth-status-actions.js +4 -4
- package/build/lib/proveauth/internal/auth-token-claims.d.ts +1 -0
- package/build/lib/proveauth/internal/device-auth.d.ts +3 -1
- package/build/lib/proveauth/internal/device-passive-register-step.d.ts +1 -0
- package/build/lib/proveauth/internal/device-passive-register-step.js +55 -35
- package/build/lib/proveauth/internal/device-passive-silent-step.js +9 -1
- package/build/lib/proveauth/internal/device-passive-step.d.ts +12 -4
- package/build/lib/proveauth/internal/device-passive-step.js +172 -52
- package/build/lib/proveauth/internal/device-passive-stepup-step.d.ts +2 -1
- package/build/lib/proveauth/internal/device-passive-stepup-step.js +25 -3
- package/build/lib/proveauth/internal/device-passive-verify-step.d.ts +3 -2
- package/build/lib/proveauth/internal/device-passive-verify-step.js +29 -10
- package/build/lib/proveauth/internal/fido-options-error.d.ts +30 -0
- package/build/lib/proveauth/internal/fido-options-error.js +161 -0
- package/build/lib/proveauth/internal/main-authenticator.js +1 -1
- package/build/lib/proveauth/internal/mobile-instantlink-step.js +36 -29
- package/build/lib/proveauth/internal/mobile-otp-step.d.ts +3 -0
- package/build/lib/proveauth/internal/mobile-otp-step.js +115 -67
- package/build/lib/proveauth/internal/platform.d.ts +2 -0
- package/build/lib/proveauth/internal/report-error-step.d.ts +1 -2
- package/build/lib/proveauth/internal/report-error-step.js +13 -12
- package/build/lib/proveauth/internal/scan-message-step.js +1 -1
- package/build/lib/proveauth/internal/settings.d.ts +4 -0
- package/build/lib/proveauth/internal/settings.js +16 -0
- package/build/lib/proveauth/internal/web-device-auth.d.ts +3 -1
- package/build/lib/proveauth/internal/web-device-auth.js +31 -15
- package/build/lib/proveauth/internal/web-platform.d.ts +2 -1
- package/build/lib/proveauth/internal/web-platform.js +19 -0
- package/build/lib/proveauth/internal/web-socket-close-reasons.d.ts +15 -0
- package/build/lib/proveauth/internal/web-socket-close-reasons.js +19 -0
- package/build/lib/proveauth/version.d.ts +2 -2
- package/build/lib/proveauth/version.js +2 -2
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ 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
9
|
const auth_status_actions_1 = require("./auth-status-actions");
|
|
10
|
+
const mobile_otp_step_1 = __importDefault(require("./mobile-otp-step"));
|
|
10
11
|
const SIMULATED_LINK_CLICK_DELAY = 100;
|
|
11
12
|
class MobileInstantLinkStep extends auth_status_actions_1.AuthStatusActions {
|
|
12
13
|
constructor(startStep, getDeviceIp) {
|
|
@@ -44,39 +45,45 @@ class MobileInstantLinkStep extends auth_status_actions_1.AuthStatusActions {
|
|
|
44
45
|
this.startStep
|
|
45
46
|
.execute(phoneNumberNeeded, phoneValidationError)
|
|
46
47
|
.then((input) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
|
|
48
|
+
const inputError = mobile_otp_step_1.default.validatePhoneNumberInput(input);
|
|
49
|
+
if (inputError) {
|
|
50
|
+
reject(inputError);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
session
|
|
54
|
+
.fetchFromBackend('/v1/client/mobile/instantlink/start', {
|
|
55
|
+
sourceIp: this.getDeviceIp(),
|
|
56
|
+
mobileNumber: input === null || input === void 0 ? void 0 : input.phoneNumber,
|
|
57
|
+
})
|
|
58
|
+
.then((response) => {
|
|
59
|
+
var _a, _b, _c;
|
|
60
|
+
const authResponse = response;
|
|
61
|
+
if (authResponse.error) {
|
|
62
|
+
reject(new auth_error_1.default(authResponse.error.message, authResponse.error.code, response.next, false));
|
|
62
63
|
}
|
|
63
|
-
if (
|
|
64
|
-
errorMessage
|
|
64
|
+
else if (authResponse.data) {
|
|
65
|
+
var errorMessage = '';
|
|
66
|
+
if ((_a = authResponse.data) === null || _a === void 0 ? void 0 : _a.code) {
|
|
67
|
+
errorMessage += `Error Code: ${authResponse.data.code}, `;
|
|
68
|
+
}
|
|
69
|
+
if ((_b = authResponse.data) === null || _b === void 0 ? void 0 : _b.message) {
|
|
70
|
+
errorMessage += `${authResponse.data.message}`;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
errorMessage += `Error validating phone number`;
|
|
74
|
+
}
|
|
75
|
+
let phoneNumberValidationError = new phone_number_input_1.PhoneValidationError(errorMessage, (_c = authResponse.data) === null || _c === void 0 ? void 0 : _c.code);
|
|
76
|
+
this.log.error(`Server reports invalid phone number: ${errorMessage}`);
|
|
77
|
+
this.runStartStep(session, phoneNumberNeeded, phoneNumberValidationError)
|
|
78
|
+
.then(resolve)
|
|
79
|
+
.catch(reject);
|
|
65
80
|
}
|
|
66
81
|
else {
|
|
67
|
-
|
|
82
|
+
resolve(authResponse.next);
|
|
68
83
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
.then(resolve)
|
|
73
|
-
.catch(reject);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
resolve(authResponse.next);
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
.catch(reject);
|
|
84
|
+
})
|
|
85
|
+
.catch(reject);
|
|
86
|
+
}
|
|
80
87
|
})
|
|
81
88
|
.catch(reject);
|
|
82
89
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import AuthSession from './auth-session';
|
|
2
2
|
import AuthStep from './auth-step';
|
|
3
|
+
import AuthError from './auth-error';
|
|
3
4
|
import { OtpStartStep, OtpFinishStep } from '../otp';
|
|
4
5
|
export default class MobileOtpStep implements AuthStep {
|
|
5
6
|
static readonly NAME = "mobile/otp";
|
|
@@ -9,6 +10,8 @@ export default class MobileOtpStep implements AuthStep {
|
|
|
9
10
|
private otpFinishStep?;
|
|
10
11
|
constructor(otpStartStep?: OtpStartStep, otpFinishStep?: OtpFinishStep);
|
|
11
12
|
execute(session: AuthSession): Promise<string>;
|
|
13
|
+
static validatePhoneNumberInput(input: any): AuthError | undefined;
|
|
12
14
|
private runOtpStartStep;
|
|
15
|
+
static validateFinishResult(result: any): AuthError | undefined;
|
|
13
16
|
private runOtpFinishStep;
|
|
14
17
|
}
|
|
@@ -34,45 +34,66 @@ class MobileOtpStep {
|
|
|
34
34
|
.catch(reject);
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
+
static validatePhoneNumberInput(input) {
|
|
38
|
+
if (input === null || input === undefined) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (typeof input !== 'object') {
|
|
42
|
+
return new auth_error_1.default('Input must be an object');
|
|
43
|
+
}
|
|
44
|
+
if (!('phoneNumber' in input)) {
|
|
45
|
+
return new auth_error_1.default('phoneNumber field in the input is missing');
|
|
46
|
+
}
|
|
47
|
+
if (typeof input.phoneNumber !== 'string') {
|
|
48
|
+
return new auth_error_1.default('phoneNumber field in the input must be a string');
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
37
52
|
runOtpStartStep(session, otpStartStep, otpFinishStep, phoneNumberNeeded, phoneValidationError) {
|
|
38
53
|
return new Promise((resolve, reject) => {
|
|
39
54
|
otpStartStep
|
|
40
55
|
.execute(phoneNumberNeeded, phoneValidationError)
|
|
41
56
|
.then((input) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
errorMessage += `Error Code: ${data.code}, `;
|
|
57
|
+
const inputError = MobileOtpStep.validatePhoneNumberInput(input);
|
|
58
|
+
if (inputError) {
|
|
59
|
+
reject(inputError);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
session
|
|
63
|
+
.fetchFromBackend('/v1/client/mobile/otp/start', {
|
|
64
|
+
mobileNumber: input === null || input === void 0 ? void 0 : input.phoneNumber,
|
|
65
|
+
})
|
|
66
|
+
.then((response) => {
|
|
67
|
+
const authResponse = response;
|
|
68
|
+
if (authResponse.error) {
|
|
69
|
+
reject(new auth_error_1.default(authResponse.error.message, authResponse.error.code, response.next, false));
|
|
56
70
|
}
|
|
57
|
-
if (data
|
|
58
|
-
|
|
71
|
+
else if (authResponse.data) {
|
|
72
|
+
let data = authResponse.data;
|
|
73
|
+
var errorMessage = '';
|
|
74
|
+
if (data === null || data === void 0 ? void 0 : data.code) {
|
|
75
|
+
errorMessage += `Error Code: ${data.code}, `;
|
|
76
|
+
}
|
|
77
|
+
if (data === null || data === void 0 ? void 0 : data.message) {
|
|
78
|
+
errorMessage += `${data.message}`;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
errorMessage += `Error validating phone number`;
|
|
82
|
+
}
|
|
83
|
+
let phoneNumberValidationError = new phone_number_input_1.PhoneValidationError(errorMessage, data === null || data === void 0 ? void 0 : data.code);
|
|
84
|
+
this.log.error(`Server reports invalid phone number: ${errorMessage}`);
|
|
85
|
+
this.runOtpStartStep(session, otpStartStep, otpFinishStep, phoneNumberNeeded, phoneNumberValidationError)
|
|
86
|
+
.then(resolve)
|
|
87
|
+
.catch(reject);
|
|
59
88
|
}
|
|
60
89
|
else {
|
|
61
|
-
|
|
90
|
+
this.runOtpFinishStep(session, otpStartStep, otpFinishStep, phoneNumberNeeded)
|
|
91
|
+
.then(resolve)
|
|
92
|
+
.catch(reject);
|
|
62
93
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
.then(resolve)
|
|
67
|
-
.catch(reject);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this.runOtpFinishStep(session, otpStartStep, otpFinishStep, phoneNumberNeeded)
|
|
71
|
-
.then(resolve)
|
|
72
|
-
.catch(reject);
|
|
73
|
-
}
|
|
74
|
-
})
|
|
75
|
-
.catch(reject);
|
|
94
|
+
})
|
|
95
|
+
.catch(reject);
|
|
96
|
+
}
|
|
76
97
|
})
|
|
77
98
|
.catch((error) => {
|
|
78
99
|
const message = auth_error_1.default.extractMessage(error);
|
|
@@ -80,6 +101,27 @@ class MobileOtpStep {
|
|
|
80
101
|
});
|
|
81
102
|
});
|
|
82
103
|
}
|
|
104
|
+
static validateFinishResult(result) {
|
|
105
|
+
if (result === null || result === undefined || typeof result !== 'object') {
|
|
106
|
+
return new auth_error_1.default('result should be a valid object');
|
|
107
|
+
}
|
|
108
|
+
else if (!('resultType' in result)) {
|
|
109
|
+
return new auth_error_1.default('resultType field in the result is missing');
|
|
110
|
+
}
|
|
111
|
+
else if (result.resultType === otp_1.OtpFinishResultType.OnSuccess) {
|
|
112
|
+
const input = result.input;
|
|
113
|
+
if (input === null || input === undefined || typeof input !== 'object') {
|
|
114
|
+
return new auth_error_1.default('input should be a valid object when resultType field is set with OnSuccess value');
|
|
115
|
+
}
|
|
116
|
+
if (!('otp' in input)) {
|
|
117
|
+
return new auth_error_1.default('otp field in the input is missing');
|
|
118
|
+
}
|
|
119
|
+
if (typeof input.otp !== 'string') {
|
|
120
|
+
return new auth_error_1.default('otp field in the input must be a string');
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
83
125
|
runOtpFinishStep(session, otpStartStep, otpFinishStep, phoneNumberNeeded, otpError) {
|
|
84
126
|
return new Promise((resolve, reject) => {
|
|
85
127
|
otpFinishStep
|
|
@@ -87,47 +129,53 @@ class MobileOtpStep {
|
|
|
87
129
|
.then((otpFinishResult) => {
|
|
88
130
|
var _a;
|
|
89
131
|
let result = otpFinishResult;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
errorMessage += `Error Code: ${data.code}, `;
|
|
132
|
+
const resultError = MobileOtpStep.validateFinishResult(result);
|
|
133
|
+
if (resultError) {
|
|
134
|
+
reject(resultError);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
switch (result.resultType) {
|
|
138
|
+
case otp_1.OtpFinishResultType.OnResendOtp:
|
|
139
|
+
this.runOtpStartStep(session, otpStartStep, otpFinishStep, phoneNumberNeeded)
|
|
140
|
+
.then(resolve)
|
|
141
|
+
.catch(reject);
|
|
142
|
+
break;
|
|
143
|
+
case otp_1.OtpFinishResultType.OnSuccess:
|
|
144
|
+
let input = result.input;
|
|
145
|
+
session
|
|
146
|
+
.fetchFromBackend('/v1/client/mobile/otp/finish', {
|
|
147
|
+
otp: (_a = input === null || input === void 0 ? void 0 : input.otp) !== null && _a !== void 0 ? _a : '',
|
|
148
|
+
})
|
|
149
|
+
.then((response) => {
|
|
150
|
+
const authResponse = response;
|
|
151
|
+
if (authResponse.error) {
|
|
152
|
+
reject(new auth_error_1.default(authResponse.error.message, authResponse.error.code, response.next, false));
|
|
112
153
|
}
|
|
113
|
-
if (data
|
|
114
|
-
|
|
154
|
+
else if (authResponse.data) {
|
|
155
|
+
let data = authResponse.data;
|
|
156
|
+
var errorMessage = '';
|
|
157
|
+
if (data === null || data === void 0 ? void 0 : data.code) {
|
|
158
|
+
errorMessage += `Error Code: ${data.code}, `;
|
|
159
|
+
}
|
|
160
|
+
if (data === null || data === void 0 ? void 0 : data.message) {
|
|
161
|
+
errorMessage += `${data.message}`;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
errorMessage += `Error validating OTP`;
|
|
165
|
+
}
|
|
166
|
+
let otpError = new otp_1.OtpError(errorMessage, data === null || data === void 0 ? void 0 : data.code);
|
|
167
|
+
this.log.error(`Server reports invalid OTP: ${errorMessage}`);
|
|
168
|
+
this.runOtpFinishStep(session, otpStartStep, otpFinishStep, phoneNumberNeeded, otpError)
|
|
169
|
+
.then(resolve)
|
|
170
|
+
.catch(reject);
|
|
115
171
|
}
|
|
116
172
|
else {
|
|
117
|
-
|
|
173
|
+
resolve(response.next);
|
|
118
174
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
.catch(reject);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
resolve(response.next);
|
|
127
|
-
}
|
|
128
|
-
})
|
|
129
|
-
.catch(reject);
|
|
130
|
-
break;
|
|
175
|
+
})
|
|
176
|
+
.catch(reject);
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
131
179
|
}
|
|
132
180
|
})
|
|
133
181
|
.catch((error) => {
|
|
@@ -4,6 +4,7 @@ import { AuthRequest } from './auth-request';
|
|
|
4
4
|
import AuthResponse from './auth-response';
|
|
5
5
|
import DeviceAuth, { DeviceRegistration } from './device-auth';
|
|
6
6
|
import { Agent } from '@fingerprintjs/fingerprintjs-pro';
|
|
7
|
+
import DarwiniumResult from '../darwinium-result';
|
|
7
8
|
export declare const DEVICE_CAPABILITY_WEBAUTHN = "webauthn";
|
|
8
9
|
export interface MessageChannel {
|
|
9
10
|
addEventListener: (type: string, listener: (event: any) => void) => void;
|
|
@@ -43,6 +44,7 @@ export default interface Platform {
|
|
|
43
44
|
getFpPromise: () => Promise<Agent> | undefined;
|
|
44
45
|
setFpPromise: (fpPromise: Promise<Agent>) => void;
|
|
45
46
|
getOrigin: () => string;
|
|
47
|
+
collectDarwiniumData: (iFrameEnabled: boolean, iFrameSrc?: string) => Promise<DarwiniumResult>;
|
|
46
48
|
}
|
|
47
49
|
export declare function stringToArrayBuffer(input: string): ArrayBuffer;
|
|
48
50
|
export declare function arrayBufferToString(input: ArrayBuffer): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import AuthSession from './auth-session';
|
|
2
2
|
import AuthStep from './auth-step';
|
|
3
3
|
export default class ReportErrorStep implements AuthStep {
|
|
4
|
-
private static readonly
|
|
4
|
+
private static readonly endpointMap;
|
|
5
5
|
private readonly logger;
|
|
6
6
|
private _message;
|
|
7
7
|
private _code?;
|
|
@@ -12,5 +12,4 @@ export default class ReportErrorStep implements AuthStep {
|
|
|
12
12
|
get code(): number | undefined;
|
|
13
13
|
get message(): string;
|
|
14
14
|
execute(session: AuthSession): Promise<string>;
|
|
15
|
-
private lookupError;
|
|
16
15
|
}
|
|
@@ -14,6 +14,7 @@ const mobile_instant_step_1 = __importDefault(require("./mobile-instant-step"));
|
|
|
14
14
|
const mobile_instantlink_step_1 = __importDefault(require("./mobile-instantlink-step"));
|
|
15
15
|
const mobile_otp_step_1 = __importDefault(require("./mobile-otp-step"));
|
|
16
16
|
const user_present_step_1 = __importDefault(require("./user-present-step"));
|
|
17
|
+
const device_passive_stepup_step_1 = __importDefault(require("./device-passive-stepup-step"));
|
|
17
18
|
const device_universal_redirect_steps_1 = require("./device-universal-redirect-steps");
|
|
18
19
|
class ReportErrorStep {
|
|
19
20
|
constructor(error) {
|
|
@@ -53,34 +54,34 @@ class ReportErrorStep {
|
|
|
53
54
|
if (this.nextStep === main_authenticator_1.default.AUTH_DONE) {
|
|
54
55
|
return Promise.resolve(main_authenticator_1.default.AUTH_DONE);
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
+
const endpoint = session.lastStep
|
|
58
|
+
? ReportErrorStep.endpointMap.get(session.lastStep)
|
|
59
|
+
: undefined;
|
|
60
|
+
if (endpoint && (this.reportable || !this.nextStep)) {
|
|
57
61
|
return new Promise((resolve, reject) => {
|
|
58
|
-
const error = this.lookupError(session.lastStep);
|
|
59
62
|
session
|
|
60
|
-
.fetchFromBackend(`/v1/client/${
|
|
63
|
+
.fetchFromBackend(`/v1/client/${endpoint}/error`, {
|
|
61
64
|
code: this._code ? this._code : undefined,
|
|
62
65
|
message: this._message,
|
|
63
66
|
})
|
|
64
|
-
.then((response) =>
|
|
65
|
-
resolve(response.next);
|
|
66
|
-
})
|
|
67
|
+
.then((response) => resolve(response.next))
|
|
67
68
|
.catch(reject);
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
|
-
else {
|
|
71
|
+
else if (this.nextStep) {
|
|
71
72
|
return Promise.resolve(this.nextStep);
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return last ? ReportErrorStep.errorMap.get(last) || defaultKind : defaultKind;
|
|
74
|
+
else {
|
|
75
|
+
return Promise.reject(new auth_error_1.default('Cannot determine the next auth step'));
|
|
76
|
+
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
ReportErrorStep.
|
|
79
|
+
ReportErrorStep.endpointMap = new Map([
|
|
80
80
|
[device_passive_step_1.default.NAME, 'device/passive'],
|
|
81
81
|
[device_passive_silent_step_1.default.NAME, 'device/passive'],
|
|
82
82
|
[device_passive_register_step_1.default.NAME, 'device/fido2'],
|
|
83
83
|
[device_passive_verify_step_1.default.NAME, 'device/fido2'],
|
|
84
|
+
[device_passive_stepup_step_1.default.NAME, 'device/fido2'],
|
|
84
85
|
[mobile_instant_step_1.default.NAME, 'mobile/instant'],
|
|
85
86
|
[mobile_instantlink_step_1.default.NAME, 'mobile/instantlink'],
|
|
86
87
|
[mobile_otp_step_1.default.NAME, 'mobile/otp'],
|
|
@@ -29,7 +29,7 @@ class ScanMessageStep {
|
|
|
29
29
|
})
|
|
30
30
|
.then((response) => {
|
|
31
31
|
if (response.error) {
|
|
32
|
-
reject(new auth_error_1.default(response.error.message, response.error.code, response.next));
|
|
32
|
+
reject(new auth_error_1.default(response.error.message, response.error.code, response.next, false));
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
35
|
resolve(response.next);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import DarwiniumResult from '../darwinium-result';
|
|
1
2
|
export default class Settings {
|
|
2
3
|
static readonly KEY_PREFIX = "ProveAuth";
|
|
3
4
|
static readonly DEVICE_ID_KEY = "DeviceId";
|
|
4
5
|
static readonly NAMESPACE_KEY = "namespace";
|
|
5
6
|
static readonly FIDO_PASSKEY_REGISTERED_KEY = "fidoPasskeyRegistered";
|
|
7
|
+
static readonly DARWINIUM_RESULT_KEY = "DarwiniumResult";
|
|
6
8
|
private readonly log;
|
|
7
9
|
private storage;
|
|
8
10
|
upkEnabled: boolean;
|
|
@@ -14,6 +16,8 @@ export default class Settings {
|
|
|
14
16
|
set fidoPasskeyRegistered(val: boolean);
|
|
15
17
|
get namespace(): string | null;
|
|
16
18
|
set namespace(val: string | null);
|
|
19
|
+
get darwiniumResult(): DarwiniumResult | undefined;
|
|
20
|
+
set darwiniumResult(result: DarwiniumResult | undefined);
|
|
17
21
|
private getKey;
|
|
18
22
|
private setOrRemove;
|
|
19
23
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const logger_1 = require("../common/logger");
|
|
7
|
+
const darwinium_result_1 = __importDefault(require("../darwinium-result"));
|
|
4
8
|
class Settings {
|
|
5
9
|
constructor(storage) {
|
|
6
10
|
this.log = logger_1.LoggerFactory.getLogger('settings');
|
|
@@ -12,6 +16,7 @@ class Settings {
|
|
|
12
16
|
this.deviceId = null;
|
|
13
17
|
this.namespace = null;
|
|
14
18
|
this.fidoPasskeyRegistered = false;
|
|
19
|
+
this.darwiniumResult = undefined;
|
|
15
20
|
}
|
|
16
21
|
get deviceId() {
|
|
17
22
|
return this.storage.getItem(this.getKey(Settings.DEVICE_ID_KEY));
|
|
@@ -32,6 +37,16 @@ class Settings {
|
|
|
32
37
|
this.log.trace('namespace set to ' + val);
|
|
33
38
|
this.setOrRemove(Settings.NAMESPACE_KEY, val);
|
|
34
39
|
}
|
|
40
|
+
get darwiniumResult() {
|
|
41
|
+
let resultJson = this.storage.getItem(this.getKey(Settings.DARWINIUM_RESULT_KEY));
|
|
42
|
+
if (resultJson) {
|
|
43
|
+
const parsed = JSON.parse(resultJson);
|
|
44
|
+
return Object.assign(new darwinium_result_1.default(), parsed);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
set darwiniumResult(result) {
|
|
48
|
+
this.setOrRemove(Settings.DARWINIUM_RESULT_KEY, JSON.stringify(result));
|
|
49
|
+
}
|
|
35
50
|
getKey(key) {
|
|
36
51
|
return `${Settings.KEY_PREFIX}.${key}`;
|
|
37
52
|
}
|
|
@@ -48,4 +63,5 @@ Settings.KEY_PREFIX = 'ProveAuth';
|
|
|
48
63
|
Settings.DEVICE_ID_KEY = 'DeviceId';
|
|
49
64
|
Settings.NAMESPACE_KEY = 'namespace';
|
|
50
65
|
Settings.FIDO_PASSKEY_REGISTERED_KEY = 'fidoPasskeyRegistered';
|
|
66
|
+
Settings.DARWINIUM_RESULT_KEY = 'DarwiniumResult';
|
|
51
67
|
exports.default = Settings;
|
|
@@ -4,6 +4,7 @@ export declare class WebDeviceRegistration implements DeviceRegistration {
|
|
|
4
4
|
private keys?;
|
|
5
5
|
deviceId: string | null;
|
|
6
6
|
fingerprint?: Signal;
|
|
7
|
+
darwinium?: Signal;
|
|
7
8
|
readonly namespace: string;
|
|
8
9
|
readonly keyId: string;
|
|
9
10
|
readonly algorithm: string;
|
|
@@ -14,7 +15,8 @@ export declare class WebDeviceRegistration implements DeviceRegistration {
|
|
|
14
15
|
sign(data: string): Promise<string>;
|
|
15
16
|
getPublicKey(): Promise<string>;
|
|
16
17
|
getAuthRegistration(challenge: string): Promise<AuthRegistration>;
|
|
17
|
-
getSignals(): Signals
|
|
18
|
+
getSignals(): Signals;
|
|
19
|
+
setDarwiniumSignal(dwnSignal: Signal): void;
|
|
18
20
|
private initialize;
|
|
19
21
|
private p1363ToDer;
|
|
20
22
|
private lenVal;
|
|
@@ -84,7 +84,13 @@ class WebDeviceRegistration {
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
getSignals() {
|
|
87
|
-
return
|
|
87
|
+
return {
|
|
88
|
+
fingerprint: this.fingerprint,
|
|
89
|
+
darwinium: this.darwinium,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
setDarwiniumSignal(dwnSignal) {
|
|
93
|
+
this.darwinium = dwnSignal;
|
|
88
94
|
}
|
|
89
95
|
initialize() {
|
|
90
96
|
return new Promise((resolve, reject) => {
|
|
@@ -149,11 +155,15 @@ class WebDeviceAuth {
|
|
|
149
155
|
reject('Failed to open registration database: ' + e);
|
|
150
156
|
};
|
|
151
157
|
openReq.onsuccess = (e) => {
|
|
152
|
-
const db =
|
|
158
|
+
const db = e.target.result;
|
|
153
159
|
const tx = db.transaction([WebDeviceAuth.DB_STORE], 'readonly');
|
|
154
160
|
tx.oncomplete = () => db.close();
|
|
155
161
|
const store = tx.objectStore(WebDeviceAuth.DB_STORE);
|
|
156
162
|
const getReq = store.get(namespace);
|
|
163
|
+
getReq.onerror = (e) => {
|
|
164
|
+
this.log.error(e);
|
|
165
|
+
reject(new Error('Failed to access registration'));
|
|
166
|
+
};
|
|
157
167
|
getReq.onsuccess = () => {
|
|
158
168
|
if (getReq.result) {
|
|
159
169
|
resolve(new WebDeviceRegistration(getReq.result));
|
|
@@ -162,9 +172,6 @@ class WebDeviceAuth {
|
|
|
162
172
|
resolve(null);
|
|
163
173
|
}
|
|
164
174
|
};
|
|
165
|
-
getReq.onerror = (e) => {
|
|
166
|
-
reject(new Error('Failed to access registration'));
|
|
167
|
-
};
|
|
168
175
|
};
|
|
169
176
|
});
|
|
170
177
|
}
|
|
@@ -175,7 +182,7 @@ class WebDeviceAuth {
|
|
|
175
182
|
reject('Failed to open registration database: ' + e);
|
|
176
183
|
};
|
|
177
184
|
openReq.onsuccess = (e) => {
|
|
178
|
-
const db =
|
|
185
|
+
const db = e.target.result;
|
|
179
186
|
const tx = db.transaction([WebDeviceAuth.DB_STORE], 'readwrite');
|
|
180
187
|
tx.oncomplete = () => db.close();
|
|
181
188
|
const store = tx.objectStore(WebDeviceAuth.DB_STORE);
|
|
@@ -183,11 +190,12 @@ class WebDeviceAuth {
|
|
|
183
190
|
const addReq = store.put(registration);
|
|
184
191
|
addReq.onsuccess = () => {
|
|
185
192
|
this.log.trace('Registration saved');
|
|
193
|
+
resolve();
|
|
186
194
|
};
|
|
187
195
|
addReq.onerror = (e) => {
|
|
196
|
+
this.log.error(e);
|
|
188
197
|
reject(new auth_error_1.default('Failed to store registration'));
|
|
189
198
|
};
|
|
190
|
-
resolve();
|
|
191
199
|
};
|
|
192
200
|
});
|
|
193
201
|
}
|
|
@@ -198,7 +206,7 @@ class WebDeviceAuth {
|
|
|
198
206
|
reject('Failed to open registration database: ' + e);
|
|
199
207
|
};
|
|
200
208
|
openReq.onsuccess = (e) => {
|
|
201
|
-
var db =
|
|
209
|
+
var db = e.target.result;
|
|
202
210
|
var tx = db.transaction([WebDeviceAuth.DB_STORE], 'readwrite');
|
|
203
211
|
tx.oncomplete = () => db.close();
|
|
204
212
|
if (!db.objectStoreNames.contains(WebDeviceAuth.DB_STORE)) {
|
|
@@ -212,6 +220,7 @@ class WebDeviceAuth {
|
|
|
212
220
|
resolve();
|
|
213
221
|
};
|
|
214
222
|
delReq.onerror = (e) => {
|
|
223
|
+
this.log.error(e);
|
|
215
224
|
reject(new Error('Failed to delete registration'));
|
|
216
225
|
};
|
|
217
226
|
};
|
|
@@ -224,7 +233,8 @@ class WebDeviceAuth {
|
|
|
224
233
|
resolve();
|
|
225
234
|
};
|
|
226
235
|
delReq.onerror = (e) => {
|
|
227
|
-
this.log.warn('Failed to delete registration database
|
|
236
|
+
this.log.warn('Failed to delete registration database');
|
|
237
|
+
this.log.warn(e);
|
|
228
238
|
resolve();
|
|
229
239
|
};
|
|
230
240
|
});
|
|
@@ -232,12 +242,18 @@ class WebDeviceAuth {
|
|
|
232
242
|
openDatabase() {
|
|
233
243
|
const openReq = this.dbFactory.open(WebDeviceAuth.DB_NAME, WebDeviceAuth.DB_VERSION);
|
|
234
244
|
openReq.onupgradeneeded = (e) => {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
245
|
+
var _a;
|
|
246
|
+
const db = (_a = e.target) === null || _a === void 0 ? void 0 : _a.result;
|
|
247
|
+
if (db) {
|
|
248
|
+
this.log.debug('Registration not found, database is missing, initializing');
|
|
249
|
+
const store = db.createObjectStore(WebDeviceAuth.DB_STORE, { keyPath: 'namespace' });
|
|
250
|
+
store.transaction.oncomplete = (e) => {
|
|
251
|
+
this.log.trace('Store initialization completed');
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
this.log.error('Failed to initialize registration database: database is null');
|
|
256
|
+
}
|
|
241
257
|
};
|
|
242
258
|
return openReq;
|
|
243
259
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/// <reference types="webappsec-credential-management" />
|
|
2
1
|
import { AuthenticatorBuilder } from '@prove-identity/mobile-auth';
|
|
3
2
|
import Platform, { AuthSessionIntegration, MessageChannel, RequestSigner } from './platform';
|
|
4
3
|
import WebDeviceAuth from './web-device-auth';
|
|
5
4
|
import { Agent } from '@fingerprintjs/fingerprintjs-pro';
|
|
5
|
+
import DarwiniumResult from '../darwinium-result';
|
|
6
6
|
export declare class WebSocketMessageChannel implements MessageChannel {
|
|
7
7
|
private readonly webSocket;
|
|
8
8
|
constructor(endpointUrl: string);
|
|
@@ -33,4 +33,5 @@ export declare class WebPlatform implements Platform {
|
|
|
33
33
|
getFpPromise(): Promise<Agent> | undefined;
|
|
34
34
|
setFpPromise(fpPromise: Promise<Agent>): void;
|
|
35
35
|
getOrigin(): string;
|
|
36
|
+
collectDarwiniumData(iFrameEnabled: boolean, iFrameSrc?: string): Promise<DarwiniumResult>;
|
|
36
37
|
}
|