@prove-identity/prove-auth 2.15.1 → 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.
Files changed (48) hide show
  1. package/README.md +2 -2
  2. package/build/bundle/release/prove-auth.js +1 -1
  3. package/build/lib/index.d.ts +7 -3
  4. package/build/lib/index.js +23 -9
  5. package/build/lib/proveauth/authenticator-builder.d.ts +9 -11
  6. package/build/lib/proveauth/authenticator-builder.js +54 -114
  7. package/build/lib/proveauth/common/base64.js +2 -1
  8. package/build/lib/proveauth/common/logger.js +2 -2
  9. package/build/lib/proveauth/device-context-options.d.ts +0 -8
  10. package/build/lib/proveauth/device-context-options.js +2 -12
  11. package/build/lib/proveauth/device-role.d.ts +4 -0
  12. package/build/lib/proveauth/device-role.js +8 -0
  13. package/build/lib/proveauth/docv.d.ts +11 -0
  14. package/build/lib/proveauth/docv.js +2 -0
  15. package/build/lib/proveauth/instantlink.js +1 -1
  16. package/build/lib/proveauth/internal/auth-request.d.ts +6 -1
  17. package/build/lib/proveauth/internal/auth-response-status.js +1 -1
  18. package/build/lib/proveauth/internal/auth-response.d.ts +6 -0
  19. package/build/lib/proveauth/internal/auth-session.d.ts +0 -1
  20. package/build/lib/proveauth/internal/auth-session.js +54 -29
  21. package/build/lib/proveauth/internal/auth-token-claims.d.ts +4 -0
  22. package/build/lib/proveauth/internal/auth-token-claims.js +1 -1
  23. package/build/lib/proveauth/internal/device-passive-step.d.ts +2 -1
  24. package/build/lib/proveauth/internal/device-passive-step.js +4 -4
  25. package/build/lib/proveauth/internal/device-universal-redirect-steps.js +2 -2
  26. package/build/lib/proveauth/internal/external-integrations.d.ts +34 -0
  27. package/build/lib/proveauth/internal/external-integrations.js +49 -0
  28. package/build/lib/proveauth/internal/fido-options-error.js +1 -1
  29. package/build/lib/proveauth/internal/main-authenticator.d.ts +2 -0
  30. package/build/lib/proveauth/internal/main-authenticator.js +3 -0
  31. package/build/lib/proveauth/internal/mobile-instant-step.js +1 -2
  32. package/build/lib/proveauth/internal/platform.d.ts +9 -13
  33. package/build/lib/proveauth/internal/platform.js +7 -6
  34. package/build/lib/proveauth/internal/report-error-step.d.ts +1 -0
  35. package/build/lib/proveauth/internal/report-error-step.js +8 -3
  36. package/build/lib/proveauth/internal/user-docv-steps.d.ts +13 -0
  37. package/build/lib/proveauth/internal/user-docv-steps.js +105 -0
  38. package/build/lib/proveauth/internal/user-ppb-steps.js +37 -33
  39. package/build/lib/proveauth/internal/web-device-auth.js +4 -1
  40. package/build/lib/proveauth/internal/web-platform.d.ts +6 -6
  41. package/build/lib/proveauth/internal/web-platform.js +11 -93
  42. package/build/lib/proveauth/internal/web-socket-close-reasons.js +1 -1
  43. package/build/lib/proveauth/otp.js +1 -1
  44. package/build/lib/proveauth/version.d.ts +2 -2
  45. package/build/lib/proveauth/version.js +1 -1
  46. package/package.json +35 -39
  47. package/build/lib/proveauth/external/@authid/web-component/authid-web-component.d.ts +0 -3
  48. package/build/lib/proveauth/external/@authid/web-component/authid-web-component.js +0 -55
@@ -18,6 +18,7 @@ const platform_1 = require("./platform");
18
18
  const logger_1 = require("../common/logger");
19
19
  const request_signer_v3_1 = __importDefault(require("./request-signer-v3"));
20
20
  const web_device_auth_1 = __importDefault(require("./web-device-auth"));
21
+ const external_integrations_1 = require("./external-integrations");
21
22
  class WebSocketMessageChannel {
22
23
  constructor(endpointUrl) {
23
24
  this.webSocket = new WebSocket(endpointUrl);
@@ -64,94 +65,17 @@ class WebPlatform {
64
65
  createRequestSigner(session) {
65
66
  return new request_signer_v3_1.default(session);
66
67
  }
67
- ppbAuthenticate(options) {
68
+ activateAuthID(options) {
68
69
  return __awaiter(this, void 0, void 0, function* () {
69
- const operationMap = new Map([
70
- ['enroll', 'i'],
71
- ['verify', 't'],
72
- ]);
73
- if (!options.authIdEndpointUrl) {
74
- return Promise.reject('AuthID API endpoint URL is missing');
75
- }
76
- if (!options.authIdOperation) {
77
- return Promise.reject('AuthID API operation is missing');
78
- }
79
- if (!operationMap.has(options.authIdOperation)) {
80
- return Promise.reject('AuthID API operation is not recognized');
81
- }
82
- if (!options.authIdOperationId) {
83
- return Promise.reject('AuthID operation ID is missing');
84
- }
85
- if (!options.authIdOneTimeSecret) {
86
- return Promise.reject('AuthID operation secret is missing');
87
- }
88
- const componentName = 'authid-component';
89
- try {
90
- const authId = require('../external/@authid/web-component/authid-web-component');
91
- if (!authId) {
92
- return Promise.reject('Failed to load PPB Auth web component');
93
- }
94
- if (!window.customElements.get(componentName)) {
95
- window.customElements.define(componentName, authId.AuthIDComponent);
96
- }
97
- yield window.customElements.whenDefined(componentName);
98
- }
99
- catch (e) {
100
- this.log.error(e);
101
- return Promise.reject(new Error('Failed to initialize PPB Auth web component'));
102
- }
103
- return new Promise((resolve, reject) => {
104
- const existingComponent = document.querySelector(componentName);
105
- if (existingComponent) {
106
- this.log.trace('Removing existing component', componentName);
107
- existingComponent.remove();
108
- }
109
- const authIdComponent = document.createElement(componentName);
110
- const url = `${options.authIdEndpointUrl}/?` +
111
- `${operationMap.get(options.authIdOperation)}=${options.authIdOperationId}&` +
112
- `s=${options.authIdOneTimeSecret}`;
113
- authIdComponent.setAttribute('data-url', url);
114
- document.body.appendChild(authIdComponent);
115
- const handleAuthDone = (success) => __awaiter(this, void 0, void 0, function* () {
116
- window.removeEventListener('message', handleMessage);
117
- this.log.trace('On PPB auth done');
118
- resolve({ authIdSuccess: success });
119
- });
120
- const handleMessage = (event) => {
121
- this.log.debug('PPB event', event.data);
122
- if (event.data.success) {
123
- const authIdComponent = document.querySelector(componentName);
124
- if (authIdComponent) {
125
- authIdComponent.remove();
126
- }
127
- handleAuthDone(true);
128
- }
129
- else {
130
- switch (event.data.pageName) {
131
- case 'documentFailedPage':
132
- case 'documentFailedNonMobilePage':
133
- case 'networkErrorPage':
134
- case 'livenessErrorPage':
135
- case 'docScanWasmTimeoutPage':
136
- case 'requestTimeoutPage':
137
- case 'transactionNotValidPage':
138
- case 'transactionMaxAttemptsPage':
139
- case 'QRCodePage':
140
- return;
141
- case 'verifiedMatchFailPage':
142
- case 'verifyDeclinedPage':
143
- authIdComponent.remove();
144
- case 'docScanResolutionTooLowPage':
145
- case 'videoDeviceNotFoundPage':
146
- case 'standardErrorPage':
147
- case 'defaultFailedPage':
148
- handleAuthDone(false);
149
- break;
150
- }
151
- }
152
- };
153
- window.addEventListener('message', handleMessage);
154
- });
70
+ return external_integrations_1.AuthIDIntegration.instance.activateWebComponent(options);
71
+ });
72
+ }
73
+ initFingerprintJS(options) {
74
+ external_integrations_1.FingerprintJSIntegration.instance.init(options);
75
+ }
76
+ getDataCollector() {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ return external_integrations_1.FingerprintJSIntegration.instance.getDataCollector();
155
79
  });
156
80
  }
157
81
  getBrowserName() {
@@ -260,12 +184,6 @@ class WebPlatform {
260
184
  urlRedirect(url) {
261
185
  window.location.replace(url);
262
186
  }
263
- getFpPromise() {
264
- return this.fpPromise;
265
- }
266
- setFpPromise(fpPromise) {
267
- this.fpPromise = fpPromise;
268
- }
269
187
  getOrigin() {
270
188
  return window.location.origin;
271
189
  }
@@ -16,4 +16,4 @@ var WebSocketCloseReasons;
16
16
  WebSocketCloseReasons["INTERNAL_ERROR"] = "The connection was closed because the server encountered an unexpected error";
17
17
  WebSocketCloseReasons["TLS_HANDSHAKE"] = "The connection was closed due to a failure to perform a TLS handshake";
18
18
  WebSocketCloseReasons["UNKNOWN_REASON"] = "Unknown reason";
19
- })(WebSocketCloseReasons = exports.WebSocketCloseReasons || (exports.WebSocketCloseReasons = {}));
19
+ })(WebSocketCloseReasons || (exports.WebSocketCloseReasons = WebSocketCloseReasons = {}));
@@ -16,4 +16,4 @@ var OtpFinishResultType;
16
16
  OtpFinishResultType[OtpFinishResultType["OnSuccess"] = 0] = "OnSuccess";
17
17
  OtpFinishResultType[OtpFinishResultType["OnResendOtp"] = 1] = "OnResendOtp";
18
18
  OtpFinishResultType[OtpFinishResultType["OnMobileNumberChange"] = 2] = "OnMobileNumberChange";
19
- })(OtpFinishResultType = exports.OtpFinishResultType || (exports.OtpFinishResultType = {}));
19
+ })(OtpFinishResultType || (exports.OtpFinishResultType = OtpFinishResultType = {}));
@@ -1,3 +1,3 @@
1
- export declare const VERSION = "2.15.1";
1
+ export declare const VERSION = "3.0.3";
2
2
  export declare const API_CONTRACT_VERSION = "2.15.1";
3
- export declare const USER_AGENT_VERSIONS: string;
3
+ export declare const USER_AGENT_VERSIONS = "ProveAuth/3.0.3 Contract/2.15.1 WEB/1";
@@ -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.15.1';
4
+ exports.VERSION = '3.0.3';
5
5
  exports.API_CONTRACT_VERSION = '2.15.1';
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.15.1",
3
+ "version": "3.0.3",
4
4
  "description": "Prove Auth SDK for Web",
5
5
  "main": "build/lib/index.js",
6
6
  "files": [
@@ -24,8 +24,8 @@
24
24
  "watch-compile": "tsc --watch",
25
25
  "watch-bundle": "webpack --watch",
26
26
  "serve": "webpack serve --config webpack.dev.config.js",
27
- "test": "webpack serve --config webpack.dev.config.js --open tests.html",
28
- "test-with-node": "mocha --require init-test.js build/lib/tests",
27
+ "test": "mocha --require init-test.js build/lib/tests",
28
+ "test-in-browser": "webpack serve --config webpack.dev.config.js --open tests.html",
29
29
  "test-runner": "node build/lib/testrunner/main.js",
30
30
  "dist": "npm run clean && npm run build && npm pack && npm run bundle && npm run bundle-dev && npm run doc",
31
31
  "prepare": "husky install"
@@ -37,44 +37,40 @@
37
37
  "license": "CC BY-NC-ND 4.0",
38
38
  "homepage": "https://www.prove.com/solutions/auth",
39
39
  "devDependencies": {
40
- "@babel/plugin-transform-modules-commonjs": "^7.21.5",
41
- "@types/chai": "4.3.5",
42
- "@types/jest": "^29.5.1",
43
- "@types/mocha": "10.0.1",
44
- "@types/react": "^18.2.6",
45
- "@types/webappsec-credential-management": "^0.6.4",
46
- "@types/ws": "^8.5.6",
47
- "@typescript-eslint/eslint-plugin": "^6.1.0",
48
- "@typescript-eslint/parser": "^6.1.0",
49
- "cbor-x": "^1.5.4",
50
- "chai": "4.3.7",
51
- "eslint": "^8.41.0",
52
- "eslint-config-prettier": "^8.8.0",
53
- "eslint-plugin-prettier": "^4.2.1",
54
- "eslint-plugin-react": "^7.32.2",
55
- "husky": "^8.0.3",
56
- "isomorphic-fetch": "3.0.0",
57
- "lint-staged": "^13.2.2",
58
- "mocha": "10.2.0",
59
- "prettier": "^2.8.8",
60
- "ts-loader": "9.4.3",
61
- "typedoc": "^0.24.7",
62
- "typescript": "^5.0.4",
63
- "webpack": "5.83.1",
64
- "webpack-cli": "5.1.1",
65
- "webpack-dev-server": "4.15.0",
66
- "webpack-node-externals": "3.0.0",
40
+ "@babel/plugin-transform-modules-commonjs": "^7.27.1",
41
+ "@types/chai": "^4.3.20",
42
+ "@types/jest": "^30.0.0",
43
+ "@types/mocha": "^10.0.10",
44
+ "@types/react": "^19.1.12",
45
+ "@types/webappsec-credential-management": "^0.6.9",
46
+ "@types/ws": "^8.18.1",
47
+ "@typescript-eslint/eslint-plugin": "^8.43.0",
48
+ "@typescript-eslint/parser": "^8.43.0",
49
+ "cbor-x": "^1.6.0",
50
+ "chai": "^4.5.0",
51
+ "eslint": "^9.35.0",
52
+ "eslint-config-prettier": "^10.1.8",
53
+ "eslint-plugin-prettier": "^5.5.4",
54
+ "eslint-plugin-react": "^7.37.5",
55
+ "husky": "^9.1.7",
56
+ "isomorphic-fetch": "^3.0.0",
57
+ "lint-staged": "^16.1.6",
58
+ "mocha": "^11.7.2",
59
+ "prettier": "^3.6.2",
60
+ "ts-loader": "^9.5.4",
61
+ "typedoc": "^0.28.12",
62
+ "typescript": "^5.9.2",
63
+ "webpack": "^5.83.1",
64
+ "webpack-cli": "^5.1.1",
65
+ "webpack-dev-server": "^5.2.2",
66
+ "webpack-node-externals": "^3.0.0",
67
67
  "ws": "^8.14.2"
68
68
  },
69
69
  "dependencies": {
70
- "@prove-identity/mobile-auth": "3.0.3"
70
+ "@prove-identity/mobile-auth": "^3.1.0"
71
71
  },
72
- "peerDependencies": {
73
- "@fingerprintjs/fingerprintjs-pro": "^3.11.0"
74
- },
75
- "peerDependenciesMeta": {
76
- "@fingerprintjs/fingerprintjs-pro": {
77
- "optional": true
78
- }
79
- }
72
+ "workspaces": [
73
+ "integrations/authid",
74
+ "integrations/fingerprintjs"
75
+ ]
80
76
  }
@@ -1,3 +0,0 @@
1
- declare class AuthIDComponent extends HTMLElement {
2
- connectedCallback(): void;
3
- }
@@ -1,55 +0,0 @@
1
- class AuthIDComponent extends HTMLElement {
2
- connectedCallback() {
3
- const dataUrl = this.getAttribute('data-url');
4
- if (!dataUrl) {
5
- throw new Error('Missing data-url configuration!');
6
- }
7
- let dataTarget = this.getAttribute('data-target');
8
- if (!dataTarget || dataTarget === 'auto') {
9
- dataTarget = /Mobi|Android/i.test(navigator.userAgent) ? 'mobile' : 'desktop';
10
- }
11
- const iframe = document.createElement('iframe');
12
- iframe.setAttribute('allow', 'fullscreen *;camera *;encrypted-media *;');
13
- iframe.setAttribute('src', dataUrl);
14
- const styleNode = document.createElement('style');
15
- styleNode.textContent =
16
- 'div, iframe {' +
17
- 'position: fixed;' +
18
- 'top: 0;' +
19
- 'left: 0;' +
20
- 'height: 100vh;' +
21
- 'width: 100vw;' +
22
- 'border: 0;' +
23
- 'padding: 0;' +
24
- 'margin: 0;' +
25
- '}';
26
- const shadow = this.attachShadow({ mode: 'closed' });
27
- shadow.appendChild(styleNode);
28
- const container = document.createElement('div');
29
- shadow.appendChild(container);
30
- const dataWebauth = this.getAttribute('data-webauth');
31
- if (dataWebauth && dataWebauth !== 'false' && dataWebauth !== 'no') {
32
- const webauthHandler = document.createElement('script');
33
- webauthHandler.setAttribute('src', dataUrl.replace('/?', '/webauthhandler.js?'));
34
- shadow.appendChild(webauthHandler);
35
- }
36
- const dataControl = this.getAttribute('data-control');
37
- if (dataControl && dataControl !== 'false' && dataControl !== 'no') {
38
- const controlHandler = document.createElement('script');
39
- controlHandler.setAttribute('src', dataUrl.replace('/?', '/controlhandler.js?'));
40
- shadow.appendChild(controlHandler);
41
- }
42
- shadow.appendChild(iframe);
43
- iframe.addEventListener('load', () => {
44
- shadow.removeChild(container);
45
- shadow.dispatchEvent(new CustomEvent('load', {
46
- composed: true,
47
- bubbles: true,
48
- }));
49
- }, { capture: true, once: true });
50
- if (window.getComputedStyle(this)['z-index'] === 'auto') {
51
- this.style['z-index'] = 1000;
52
- }
53
- }
54
- }
55
- window.customElements.define('authid-component', AuthIDComponent);