@prove-identity/prove-auth 2.3.2
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/LICENSE +404 -0
- package/README.md +17 -0
- package/build/lib/index.d.ts +12 -0
- package/build/lib/index.js +47 -0
- package/build/lib/proveauth/auth-finish-step.d.ts +7 -0
- package/build/lib/proveauth/auth-finish-step.js +2 -0
- package/build/lib/proveauth/authenticator-builder.d.ts +42 -0
- package/build/lib/proveauth/authenticator-builder.js +126 -0
- package/build/lib/proveauth/authenticator.d.ts +12 -0
- package/build/lib/proveauth/authenticator.js +2 -0
- package/build/lib/proveauth/common/base64.d.ts +5 -0
- package/build/lib/proveauth/common/base64.js +19 -0
- package/build/lib/proveauth/common/cancelable-promise.d.ts +5 -0
- package/build/lib/proveauth/common/cancelable-promise.js +15 -0
- package/build/lib/proveauth/common/logger.d.ts +25 -0
- package/build/lib/proveauth/common/logger.js +85 -0
- package/build/lib/proveauth/instantlink.d.ts +4 -0
- package/build/lib/proveauth/instantlink.js +2 -0
- package/build/lib/proveauth/internal/auth-error.d.ts +7 -0
- package/build/lib/proveauth/internal/auth-error.js +27 -0
- package/build/lib/proveauth/internal/auth-message.d.ts +12 -0
- package/build/lib/proveauth/internal/auth-message.js +2 -0
- package/build/lib/proveauth/internal/auth-request.d.ts +90 -0
- package/build/lib/proveauth/internal/auth-request.js +2 -0
- package/build/lib/proveauth/internal/auth-response-status.d.ts +8 -0
- package/build/lib/proveauth/internal/auth-response-status.js +12 -0
- package/build/lib/proveauth/internal/auth-response.d.ts +61 -0
- package/build/lib/proveauth/internal/auth-response.js +2 -0
- package/build/lib/proveauth/internal/auth-session.d.ts +30 -0
- package/build/lib/proveauth/internal/auth-session.js +156 -0
- package/build/lib/proveauth/internal/auth-step.d.ts +5 -0
- package/build/lib/proveauth/internal/auth-step.js +2 -0
- package/build/lib/proveauth/internal/auth-token-claims.d.ts +46 -0
- package/build/lib/proveauth/internal/auth-token-claims.js +9 -0
- package/build/lib/proveauth/internal/base-authenticator.d.ts +28 -0
- package/build/lib/proveauth/internal/base-authenticator.js +129 -0
- package/build/lib/proveauth/internal/device-auth.d.ts +22 -0
- package/build/lib/proveauth/internal/device-auth.js +2 -0
- package/build/lib/proveauth/internal/device-passive-register-step.d.ts +10 -0
- package/build/lib/proveauth/internal/device-passive-register-step.js +97 -0
- package/build/lib/proveauth/internal/device-passive-silent-step.d.ts +10 -0
- package/build/lib/proveauth/internal/device-passive-silent-step.js +98 -0
- package/build/lib/proveauth/internal/device-passive-step.d.ts +17 -0
- package/build/lib/proveauth/internal/device-passive-step.js +133 -0
- package/build/lib/proveauth/internal/device-passive-stepup-step.d.ts +9 -0
- package/build/lib/proveauth/internal/device-passive-stepup-step.js +25 -0
- package/build/lib/proveauth/internal/device-passive-verify-step.d.ts +8 -0
- package/build/lib/proveauth/internal/device-passive-verify-step.js +54 -0
- package/build/lib/proveauth/internal/error-code.d.ts +9 -0
- package/build/lib/proveauth/internal/error-code.js +12 -0
- package/build/lib/proveauth/internal/mobile-instant-step.d.ts +15 -0
- package/build/lib/proveauth/internal/mobile-instant-step.js +100 -0
- package/build/lib/proveauth/internal/mobile-instantlink-step.d.ts +14 -0
- package/build/lib/proveauth/internal/mobile-instantlink-step.js +108 -0
- package/build/lib/proveauth/internal/mobile-otp-step.d.ts +14 -0
- package/build/lib/proveauth/internal/mobile-otp-step.js +141 -0
- package/build/lib/proveauth/internal/phone-number-input.d.ts +11 -0
- package/build/lib/proveauth/internal/phone-number-input.js +13 -0
- package/build/lib/proveauth/internal/platform.d.ts +45 -0
- package/build/lib/proveauth/internal/platform.js +20 -0
- 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.d.ts +16 -0
- package/build/lib/proveauth/internal/report-error-step.js +88 -0
- package/build/lib/proveauth/internal/request-signer-v3.d.ts +10 -0
- package/build/lib/proveauth/internal/request-signer-v3.js +104 -0
- package/build/lib/proveauth/internal/scan-message-step.d.ts +11 -0
- package/build/lib/proveauth/internal/scan-message-step.js +45 -0
- 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/settings.d.ts +18 -0
- package/build/lib/proveauth/internal/settings.js +50 -0
- package/build/lib/proveauth/internal/user-mobileactive-step.d.ts +7 -0
- package/build/lib/proveauth/internal/user-mobileactive-step.js +18 -0
- package/build/lib/proveauth/internal/user-present-step.d.ts +7 -0
- package/build/lib/proveauth/internal/user-present-step.js +18 -0
- package/build/lib/proveauth/internal/web-device-auth.d.ts +32 -0
- package/build/lib/proveauth/internal/web-device-auth.js +242 -0
- package/build/lib/proveauth/internal/web-platform.d.ts +30 -0
- package/build/lib/proveauth/internal/web-platform.js +160 -0
- package/build/lib/proveauth/otp.d.ts +23 -0
- package/build/lib/proveauth/otp.js +18 -0
- package/build/lib/proveauth/version.d.ts +3 -0
- package/build/lib/proveauth/version.js +6 -0
- package/package.json +75 -0
|
@@ -0,0 +1,88 @@
|
|
|
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 auth_error_1 = __importDefault(require("./auth-error"));
|
|
8
|
+
const base_authenticator_1 = __importDefault(require("./base-authenticator"));
|
|
9
|
+
const device_passive_register_step_1 = __importDefault(require("./device-passive-register-step"));
|
|
10
|
+
const device_passive_silent_step_1 = __importDefault(require("./device-passive-silent-step"));
|
|
11
|
+
const device_passive_step_1 = __importDefault(require("./device-passive-step"));
|
|
12
|
+
const device_passive_verify_step_1 = __importDefault(require("./device-passive-verify-step"));
|
|
13
|
+
const mobile_instant_step_1 = __importDefault(require("./mobile-instant-step"));
|
|
14
|
+
const mobile_instantlink_step_1 = __importDefault(require("./mobile-instantlink-step"));
|
|
15
|
+
const mobile_otp_step_1 = __importDefault(require("./mobile-otp-step"));
|
|
16
|
+
const user_present_step_1 = __importDefault(require("./user-present-step"));
|
|
17
|
+
class ReportErrorStep {
|
|
18
|
+
constructor(error) {
|
|
19
|
+
this.logger = logger_1.LoggerFactory.getLogger('report-error-step');
|
|
20
|
+
this._message = 'Unknown error';
|
|
21
|
+
this.reportable = true;
|
|
22
|
+
this.name = 'error';
|
|
23
|
+
if (error instanceof auth_error_1.default) {
|
|
24
|
+
const authError = error;
|
|
25
|
+
this._message = authError.message;
|
|
26
|
+
this._code = authError.code;
|
|
27
|
+
this.nextStep = authError.nextStep;
|
|
28
|
+
this.reportable = authError.reportable;
|
|
29
|
+
}
|
|
30
|
+
else if (error) {
|
|
31
|
+
this._message = auth_error_1.default.extractMessage(error);
|
|
32
|
+
}
|
|
33
|
+
if (!this._message) {
|
|
34
|
+
this.logger.warn('Unexpected error: ' + error);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
get code() {
|
|
38
|
+
return this._code;
|
|
39
|
+
}
|
|
40
|
+
get message() {
|
|
41
|
+
return this._message;
|
|
42
|
+
}
|
|
43
|
+
execute(session) {
|
|
44
|
+
let logMessage = `Authentication step ${session.lastStep} failed`;
|
|
45
|
+
if (this._code) {
|
|
46
|
+
logMessage = logMessage + ', code: ' + this._code;
|
|
47
|
+
}
|
|
48
|
+
if (this._message) {
|
|
49
|
+
logMessage = logMessage + ', message: ' + this._message;
|
|
50
|
+
}
|
|
51
|
+
this.logger.error(logMessage);
|
|
52
|
+
if (this.nextStep === base_authenticator_1.default.AUTH_DONE) {
|
|
53
|
+
return Promise.resolve(base_authenticator_1.default.AUTH_DONE);
|
|
54
|
+
}
|
|
55
|
+
else if (!this.nextStep || this.reportable) {
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
const errorKind = this.getKind(session.lastStep);
|
|
58
|
+
session
|
|
59
|
+
.fetchFromBackend(`/v1/client/${errorKind}/error`, {
|
|
60
|
+
code: this._code ? this._code : undefined,
|
|
61
|
+
message: this._message,
|
|
62
|
+
})
|
|
63
|
+
.then((response) => {
|
|
64
|
+
resolve(response.next);
|
|
65
|
+
})
|
|
66
|
+
.catch(reject);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return Promise.resolve(this.nextStep);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
getKind(last) {
|
|
74
|
+
const defaultKind = 'device/passive';
|
|
75
|
+
return last ? ReportErrorStep.errorKinds.get(last) || defaultKind : defaultKind;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
ReportErrorStep.errorKinds = new Map([
|
|
79
|
+
[device_passive_step_1.default.NAME, 'device/passive'],
|
|
80
|
+
[device_passive_silent_step_1.default.NAME, 'device/passive'],
|
|
81
|
+
[device_passive_register_step_1.default.NAME, 'device/fido2'],
|
|
82
|
+
[device_passive_verify_step_1.default.NAME, 'device/fido2'],
|
|
83
|
+
[mobile_instant_step_1.default.NAME, 'mobile/instant'],
|
|
84
|
+
[mobile_instantlink_step_1.default.NAME, 'mobile/instantlink'],
|
|
85
|
+
[mobile_otp_step_1.default.NAME, 'mobile/otp'],
|
|
86
|
+
[user_present_step_1.default.NAME, 'user/mobileactive'],
|
|
87
|
+
]);
|
|
88
|
+
exports.default = ReportErrorStep;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AuthSessionIntegration, RequestSignature, RequestSigner } from './platform';
|
|
2
|
+
export default class RequestSignerV3 implements RequestSigner {
|
|
3
|
+
private readonly log;
|
|
4
|
+
private readonly session;
|
|
5
|
+
private cachedChallenge?;
|
|
6
|
+
constructor(session: AuthSessionIntegration);
|
|
7
|
+
sign(method: string, path: string, query: string, contentType: string, body: string): Promise<RequestSignature | null>;
|
|
8
|
+
private getChallenge;
|
|
9
|
+
private getHash;
|
|
10
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const logger_1 = require("../common/logger");
|
|
4
|
+
const platform_1 = require("./platform");
|
|
5
|
+
const SIGNATURE_VERSION = '3';
|
|
6
|
+
const FUDGE_FACTOR = 60;
|
|
7
|
+
const SIGN_REQUESTS = [
|
|
8
|
+
'/v1/client/stepup/unregister',
|
|
9
|
+
'/v1/client/device/unregister',
|
|
10
|
+
'/v1/client/device/passive/error',
|
|
11
|
+
'/v1/client/mobile/instant/error',
|
|
12
|
+
'/v1/client/mobile/otp/error',
|
|
13
|
+
'/v1/client/user/mobileactive',
|
|
14
|
+
'/v1/client/user/mobileactive/error',
|
|
15
|
+
];
|
|
16
|
+
class RequestSignerV3 {
|
|
17
|
+
constructor(session) {
|
|
18
|
+
this.log = logger_1.LoggerFactory.getLogger('request-signer');
|
|
19
|
+
this.session = session;
|
|
20
|
+
}
|
|
21
|
+
sign(method, path, query, contentType, body) {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
this.session
|
|
24
|
+
.getDeviceRegistration()
|
|
25
|
+
.then((registration) => {
|
|
26
|
+
if (!registration || !registration.deviceId) {
|
|
27
|
+
this.log.debug('Device not registered, cannot sign');
|
|
28
|
+
resolve(null);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (!SIGN_REQUESTS.includes(path)) {
|
|
32
|
+
this.log.debug('No signing needed for ' + path);
|
|
33
|
+
resolve(null);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
Promise.all([this.getChallenge(registration.deviceId), this.getHash(body)])
|
|
37
|
+
.then((results) => {
|
|
38
|
+
const challenge = results[0];
|
|
39
|
+
const bodyHash = results[1];
|
|
40
|
+
const dataToSign = method +
|
|
41
|
+
'\n' +
|
|
42
|
+
path +
|
|
43
|
+
'\n' +
|
|
44
|
+
query +
|
|
45
|
+
'\n' +
|
|
46
|
+
contentType +
|
|
47
|
+
'\n' +
|
|
48
|
+
challenge +
|
|
49
|
+
'\n' +
|
|
50
|
+
bodyHash;
|
|
51
|
+
registration
|
|
52
|
+
.sign(dataToSign)
|
|
53
|
+
.then((signature) => resolve({
|
|
54
|
+
version: SIGNATURE_VERSION,
|
|
55
|
+
challenge: challenge,
|
|
56
|
+
signature: signature,
|
|
57
|
+
keyId: registration.keyId,
|
|
58
|
+
}))
|
|
59
|
+
.catch(reject);
|
|
60
|
+
})
|
|
61
|
+
.catch(reject);
|
|
62
|
+
})
|
|
63
|
+
.catch(reject);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
getChallenge(deviceId) {
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
if (this.cachedChallenge &&
|
|
69
|
+
this.cachedChallenge.receivedAt &&
|
|
70
|
+
this.cachedChallenge.ttl &&
|
|
71
|
+
this.cachedChallenge.deviceId === deviceId &&
|
|
72
|
+
this.cachedChallenge.receivedAt + this.cachedChallenge.ttl - FUDGE_FACTOR > (0, platform_1.getUnixTime)()) {
|
|
73
|
+
resolve(this.cachedChallenge.challenge);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
this.session
|
|
77
|
+
.fetchFromBackend('/v1/client/challenge', {
|
|
78
|
+
deviceId: deviceId,
|
|
79
|
+
})
|
|
80
|
+
.then((response) => response)
|
|
81
|
+
.then((response) => {
|
|
82
|
+
var _a;
|
|
83
|
+
if (response.error) {
|
|
84
|
+
reject((_a = response.error) === null || _a === void 0 ? void 0 : _a.message);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
response.receivedAt = (0, platform_1.getUnixTime)();
|
|
88
|
+
this.cachedChallenge = response;
|
|
89
|
+
resolve(response.challenge);
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
.catch(reject);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
getHash(data) {
|
|
96
|
+
return new Promise((resolve, reject) => {
|
|
97
|
+
crypto.subtle
|
|
98
|
+
.digest('SHA-256', (0, platform_1.stringToArrayBuffer)(data))
|
|
99
|
+
.then((hash) => resolve((0, platform_1.arrayBufferToHexString)(hash)))
|
|
100
|
+
.catch(reject);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.default = RequestSignerV3;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AuthMessageHandler } from '../authenticator-builder';
|
|
2
|
+
import AuthSession from './auth-session';
|
|
3
|
+
import AuthStep from './auth-step';
|
|
4
|
+
export default class ScanMessageStep implements AuthStep {
|
|
5
|
+
static readonly NAME = "scan/message";
|
|
6
|
+
private readonly log;
|
|
7
|
+
private readonly authMessageHandler;
|
|
8
|
+
constructor(authMessageHandler: AuthMessageHandler | undefined);
|
|
9
|
+
readonly name = "scan/message";
|
|
10
|
+
execute(session: AuthSession): Promise<string>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 auth_error_1 = __importDefault(require("./auth-error"));
|
|
7
|
+
const logger_1 = require("../common/logger");
|
|
8
|
+
class ScanMessageStep {
|
|
9
|
+
constructor(authMessageHandler) {
|
|
10
|
+
this.log = logger_1.LoggerFactory.getLogger('scan-message-step');
|
|
11
|
+
this.name = ScanMessageStep.NAME;
|
|
12
|
+
this.authMessageHandler = authMessageHandler;
|
|
13
|
+
}
|
|
14
|
+
execute(session) {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
if (!this.authMessageHandler) {
|
|
17
|
+
reject(new auth_error_1.default('Failed to process auth message, the handler was not specified'));
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
if (!session.authMessage) {
|
|
21
|
+
this.log.warn('Auth message is missing');
|
|
22
|
+
session.authMessage = {};
|
|
23
|
+
}
|
|
24
|
+
this.authMessageHandler(session.authMessage)
|
|
25
|
+
.then((status) => {
|
|
26
|
+
session
|
|
27
|
+
.fetchFromBackend('/v1/client/user/response', {
|
|
28
|
+
response: status,
|
|
29
|
+
})
|
|
30
|
+
.then((response) => {
|
|
31
|
+
if (response.error) {
|
|
32
|
+
reject(new auth_error_1.default(response.error.message, response.error.code, response.next));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
resolve(response.next);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
})
|
|
39
|
+
.catch(reject);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
ScanMessageStep.NAME = 'scan/message';
|
|
45
|
+
exports.default = ScanMessageStep;
|
|
@@ -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;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default class Settings {
|
|
2
|
+
static readonly KEY_PREFIX = "ProveAuth";
|
|
3
|
+
static readonly DEVICE_ID_KEY = "DeviceId";
|
|
4
|
+
static readonly NAMESPACE_KEY = "namespace";
|
|
5
|
+
static readonly FIDO_PASSKEY_REGISTERED_KEY = "fidoPasskeyRegistered";
|
|
6
|
+
private readonly log;
|
|
7
|
+
private storage;
|
|
8
|
+
constructor(storage: Storage);
|
|
9
|
+
reset(): void;
|
|
10
|
+
get deviceId(): string | null;
|
|
11
|
+
set deviceId(val: string | null);
|
|
12
|
+
get fidoPasskeyRegistered(): boolean;
|
|
13
|
+
set fidoPasskeyRegistered(val: boolean);
|
|
14
|
+
get namespace(): string | null;
|
|
15
|
+
set namespace(val: string | null);
|
|
16
|
+
private getKey;
|
|
17
|
+
private setOrRemove;
|
|
18
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const logger_1 = require("../common/logger");
|
|
4
|
+
class Settings {
|
|
5
|
+
constructor(storage) {
|
|
6
|
+
this.log = logger_1.LoggerFactory.getLogger('settings');
|
|
7
|
+
this.storage = storage;
|
|
8
|
+
}
|
|
9
|
+
reset() {
|
|
10
|
+
this.log.trace('reset');
|
|
11
|
+
this.deviceId = null;
|
|
12
|
+
this.namespace = null;
|
|
13
|
+
this.fidoPasskeyRegistered = false;
|
|
14
|
+
}
|
|
15
|
+
get deviceId() {
|
|
16
|
+
return this.storage.getItem(this.getKey(Settings.DEVICE_ID_KEY));
|
|
17
|
+
}
|
|
18
|
+
set deviceId(val) {
|
|
19
|
+
this.setOrRemove(Settings.DEVICE_ID_KEY, val);
|
|
20
|
+
}
|
|
21
|
+
get fidoPasskeyRegistered() {
|
|
22
|
+
return this.storage.getItem(this.getKey(Settings.FIDO_PASSKEY_REGISTERED_KEY)) === 'true';
|
|
23
|
+
}
|
|
24
|
+
set fidoPasskeyRegistered(val) {
|
|
25
|
+
this.setOrRemove(Settings.FIDO_PASSKEY_REGISTERED_KEY, val ? 'true' : null);
|
|
26
|
+
}
|
|
27
|
+
get namespace() {
|
|
28
|
+
return this.storage.getItem(this.getKey(Settings.NAMESPACE_KEY));
|
|
29
|
+
}
|
|
30
|
+
set namespace(val) {
|
|
31
|
+
this.log.trace('namespace set to ' + val);
|
|
32
|
+
this.setOrRemove(Settings.NAMESPACE_KEY, val);
|
|
33
|
+
}
|
|
34
|
+
getKey(key) {
|
|
35
|
+
return `${Settings.KEY_PREFIX}.${key}`;
|
|
36
|
+
}
|
|
37
|
+
setOrRemove(key, val) {
|
|
38
|
+
if (val) {
|
|
39
|
+
this.storage.setItem(this.getKey(key), val);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.storage.removeItem(this.getKey(key));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
Settings.KEY_PREFIX = 'ProveAuth';
|
|
47
|
+
Settings.DEVICE_ID_KEY = 'DeviceId';
|
|
48
|
+
Settings.NAMESPACE_KEY = 'namespace';
|
|
49
|
+
Settings.FIDO_PASSKEY_REGISTERED_KEY = 'fidoPasskeyRegistered';
|
|
50
|
+
exports.default = Settings;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import AuthSession from './auth-session';
|
|
2
|
+
import AuthStep from './auth-step';
|
|
3
|
+
export default class UserMobileActiveStep implements AuthStep {
|
|
4
|
+
static readonly NAME = "user/mobileactive";
|
|
5
|
+
readonly name = "user/mobileactive";
|
|
6
|
+
execute(session: AuthSession): Promise<string>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 auth_error_1 = __importDefault(require("./auth-error"));
|
|
7
|
+
class UserMobileActiveStep {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.name = UserMobileActiveStep.NAME;
|
|
10
|
+
}
|
|
11
|
+
execute(session) {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
reject(new auth_error_1.default(`Step ${this.name} is not supported yet`));
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
UserMobileActiveStep.NAME = 'user/mobileactive';
|
|
18
|
+
exports.default = UserMobileActiveStep;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import AuthSession from './auth-session';
|
|
2
|
+
import AuthStep from './auth-step';
|
|
3
|
+
export default class UserPresentStep implements AuthStep {
|
|
4
|
+
static readonly NAME = "user/present";
|
|
5
|
+
readonly name = "user/present";
|
|
6
|
+
execute(session: AuthSession): Promise<string>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 auth_error_1 = __importDefault(require("./auth-error"));
|
|
7
|
+
class UserPresentStep {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.name = UserPresentStep.NAME;
|
|
10
|
+
}
|
|
11
|
+
execute(session) {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
reject(new auth_error_1.default(`Step ${this.name} is not supported yet`));
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
UserPresentStep.NAME = 'user/present';
|
|
18
|
+
exports.default = UserPresentStep;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AuthRegistration } from './auth-request';
|
|
2
|
+
import DeviceAuth, { DeviceRegistration, DeviceRegistrationOptions } from './device-auth';
|
|
3
|
+
export declare class WebDeviceRegistration implements DeviceRegistration {
|
|
4
|
+
private keys?;
|
|
5
|
+
deviceId: string | null;
|
|
6
|
+
readonly namespace: string;
|
|
7
|
+
readonly keyId: string;
|
|
8
|
+
readonly algorithm: string;
|
|
9
|
+
readonly endpoint: string;
|
|
10
|
+
readonly createdAt: number;
|
|
11
|
+
constructor(options: DeviceRegistrationOptions | any);
|
|
12
|
+
sign(data: string): Promise<string>;
|
|
13
|
+
getPublicKey(): Promise<string>;
|
|
14
|
+
getAuthRegistration(challenge: string): Promise<AuthRegistration>;
|
|
15
|
+
private initialize;
|
|
16
|
+
private p1363ToDer;
|
|
17
|
+
private lenVal;
|
|
18
|
+
}
|
|
19
|
+
export default class WebDeviceAuth implements DeviceAuth {
|
|
20
|
+
static readonly DB_VERSION = 1;
|
|
21
|
+
static readonly DB_NAME = "ProveAuth";
|
|
22
|
+
static readonly DB_STORE = "Registrations";
|
|
23
|
+
private readonly dbFactory;
|
|
24
|
+
private readonly log;
|
|
25
|
+
constructor(dbFactory: IDBFactory);
|
|
26
|
+
createRegistration(options: DeviceRegistrationOptions): Promise<DeviceRegistration>;
|
|
27
|
+
getRegistration(namespace: string): Promise<DeviceRegistration | null>;
|
|
28
|
+
storeRegistration(registration: DeviceRegistration): Promise<void>;
|
|
29
|
+
deleteRegistration(namespace: string): Promise<void>;
|
|
30
|
+
reset(): Promise<void>;
|
|
31
|
+
private openDatabase;
|
|
32
|
+
}
|