@connectid-tools/idp-selector-react 6.10.0 → 6.11.0-alpha.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.
@@ -1,3 +1,3 @@
1
- import { CompatibilityEnvironment, CompatibilityWarnings } from './types';
1
+ import { CompatibilityEnvironment, CompatibilityWarnings } from "./types.js";
2
2
  export declare const getCompatibility: (env: CompatibilityEnvironment) => CompatibilityWarnings;
3
3
  export declare const getMightFail: (env: Pick<CompatibilityEnvironment, "supportIncognito" | "idpHasAppCertification" | "isMobile" | "isIncognito" | "isAndroid" | "isIos" | "browser">) => boolean;
@@ -1,8 +1,8 @@
1
- import { describe, it } from 'node:test';
2
- import assert from 'node:assert';
3
- import { getCompatibility, getMightFail } from './compatibility';
4
- describe('getCompatibility', () => {
5
- it('should return compatibility warnings', () => {
1
+ import { describe, it } from "node:test";
2
+ import assert from "node:assert";
3
+ import { getCompatibility, getMightFail } from "./compatibility.js";
4
+ describe("getCompatibility", () => {
5
+ it("should return compatibility warnings", () => {
6
6
  const compatibility = getCompatibility({
7
7
  supportIncognito: false,
8
8
  idpHasAppCertification: true,
@@ -10,19 +10,19 @@ describe('getCompatibility', () => {
10
10
  isIncognito: false,
11
11
  isAndroid: false,
12
12
  isIos: false,
13
- browser: 'other',
13
+ browser: "other",
14
14
  });
15
15
  assert.deepStrictEqual(compatibility, {
16
16
  isMobile: true,
17
17
  isIncognito: false,
18
- mobileOs: 'other',
19
- browser: 'other',
18
+ mobileOs: "other",
19
+ browser: "other",
20
20
  mightFail: false,
21
21
  });
22
22
  });
23
23
  });
24
- describe('getMightFail', () => {
25
- it('should return false when idpHasAppCertification is false', () => {
24
+ describe("getMightFail", () => {
25
+ it("should return false when idpHasAppCertification is false", () => {
26
26
  const mightFail = getMightFail({
27
27
  supportIncognito: false,
28
28
  idpHasAppCertification: false,
@@ -30,11 +30,11 @@ describe('getMightFail', () => {
30
30
  isIncognito: false,
31
31
  isAndroid: false,
32
32
  isIos: false,
33
- browser: 'other',
33
+ browser: "other",
34
34
  });
35
35
  assert.ok(mightFail === false);
36
36
  });
37
- it('should return false when isMobile is false', () => {
37
+ it("should return false when isMobile is false", () => {
38
38
  const mightFail = getMightFail({
39
39
  supportIncognito: false,
40
40
  idpHasAppCertification: true,
@@ -42,11 +42,11 @@ describe('getMightFail', () => {
42
42
  isIncognito: false,
43
43
  isAndroid: false,
44
44
  isIos: false,
45
- browser: 'other',
45
+ browser: "other",
46
46
  });
47
47
  assert.ok(mightFail === false);
48
48
  });
49
- it('should return true when does not support incognito and settings are incognito/android/chrome', () => {
49
+ it("should return true when does not support incognito and settings are incognito/android/chrome", () => {
50
50
  const mightFail = getMightFail({
51
51
  supportIncognito: false,
52
52
  idpHasAppCertification: true,
@@ -54,11 +54,11 @@ describe('getMightFail', () => {
54
54
  isIncognito: true,
55
55
  isAndroid: true,
56
56
  isIos: false,
57
- browser: 'chrome',
57
+ browser: "chrome",
58
58
  });
59
59
  assert.ok(mightFail === true);
60
60
  });
61
- it('should return false when supports incognito and settings are incognito/android/chrome', () => {
61
+ it("should return false when supports incognito and settings are incognito/android/chrome", () => {
62
62
  const mightFail = getMightFail({
63
63
  supportIncognito: true,
64
64
  idpHasAppCertification: true,
@@ -66,11 +66,11 @@ describe('getMightFail', () => {
66
66
  isIncognito: true,
67
67
  isAndroid: true,
68
68
  isIos: false,
69
- browser: 'chrome',
69
+ browser: "chrome",
70
70
  });
71
71
  assert.ok(mightFail === false);
72
72
  });
73
- it('should return true when android/samsung', () => {
73
+ it("should return true when android/samsung", () => {
74
74
  const mightFail = getMightFail({
75
75
  supportIncognito: false,
76
76
  idpHasAppCertification: true,
@@ -78,11 +78,11 @@ describe('getMightFail', () => {
78
78
  isIncognito: false,
79
79
  isAndroid: true,
80
80
  isIos: false,
81
- browser: 'samsung',
81
+ browser: "samsung",
82
82
  });
83
83
  assert.ok(mightFail === true);
84
84
  });
85
- it('should return true when does not support incognito and settings are incognito/ios', () => {
85
+ it("should return true when does not support incognito and settings are incognito/ios", () => {
86
86
  const mightFail = getMightFail({
87
87
  supportIncognito: false,
88
88
  idpHasAppCertification: true,
@@ -90,11 +90,11 @@ describe('getMightFail', () => {
90
90
  isIncognito: true,
91
91
  isAndroid: false,
92
92
  isIos: true,
93
- browser: 'safari',
93
+ browser: "safari",
94
94
  });
95
95
  assert.ok(mightFail === true);
96
96
  });
97
- it('should return false when supports incognito and settings are incognito/ios', () => {
97
+ it("should return false when supports incognito and settings are incognito/ios", () => {
98
98
  const mightFail = getMightFail({
99
99
  supportIncognito: true,
100
100
  idpHasAppCertification: true,
@@ -102,11 +102,11 @@ describe('getMightFail', () => {
102
102
  isIncognito: true,
103
103
  isAndroid: false,
104
104
  isIos: true,
105
- browser: 'safari',
105
+ browser: "safari",
106
106
  });
107
107
  assert.ok(mightFail === false);
108
108
  });
109
- it('should return false when none of the conditions are met', () => {
109
+ it("should return false when none of the conditions are met", () => {
110
110
  const mightFail = getMightFail({
111
111
  supportIncognito: false,
112
112
  idpHasAppCertification: true,
@@ -114,7 +114,7 @@ describe('getMightFail', () => {
114
114
  isIncognito: false,
115
115
  isAndroid: false,
116
116
  isIos: false,
117
- browser: 'other',
117
+ browser: "other",
118
118
  });
119
119
  assert.ok(mightFail === false);
120
120
  });
package/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { CidButton } from './CidButton';
1
+ export { CidButton } from "./CidButton.js";
package/index.js CHANGED
@@ -1 +1 @@
1
- export { CidButton } from './CidButton';
1
+ export { CidButton } from "./CidButton.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectid-tools/idp-selector-react",
3
- "version": "6.10.0",
3
+ "version": "6.11.0-alpha.2",
4
4
  "description": "React component for IDP Selector.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -11,7 +11,7 @@
11
11
  "cy:open": "cypress open",
12
12
  "clean": "rm -rf dist",
13
13
  "build": "npm run clean && tsc && cp package.json README.md license ./src/*.css ./dist",
14
- "build:prod": "npm run build && replace-in-file process.env.NODE_ENV \\'production\\' ./dist/analytics.js"
14
+ "build:prod": "npm run build && replace-in-file process.env.NODE_ENV \\'production\\' ./dist/analytics.js && npx ts-add-js-extension --dir dist"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
@@ -35,10 +35,12 @@
35
35
  "react": "^18.3.1",
36
36
  "react-dom": "^18.3.1",
37
37
  "replace-in-file": "^8.3.0",
38
+ "ts-add-js-extension": "^1.6.6",
38
39
  "tsx": "^4.20.3",
39
40
  "typescript": "^5.8.3"
40
41
  },
41
42
  "dependencies": {
43
+ "detectincognitojs": "^1.6.0",
42
44
  "react-responsive": "^10.0.1",
43
45
  "swr": "^2.3.4",
44
46
  "vite": "^6.3.5"
package/userAgent.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Device } from './types';
1
+ import { Device } from "./types.js";
2
2
  export declare const getDeviceType: () => Device;
3
3
  export declare const isAndroid: () => boolean;
4
4
  export declare const isIos: () => boolean;
package/validator.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { CidButtonType, Claim, IntroTextType } from './types';
1
+ import { CidButtonType, Claim, IntroTextType } from "./types.js";
2
2
  export declare const isRequiredClaimsValid: (claims: Claim[], requiredClaims?: Claim[]) => boolean;
3
3
  export declare const isIntroTextTypeValid: (type?: CidButtonType, introTextType?: IntroTextType) => boolean;
package/validator.test.js CHANGED
@@ -1,36 +1,36 @@
1
- import { describe, it } from 'node:test';
2
- import { isIntroTextTypeValid, isRequiredClaimsValid } from './validator';
3
- import assert from 'node:assert';
4
- describe('isRequiredClaimsValid', () => {
5
- it('should return true if requiredClaims is undefined', () => {
6
- const claims = ['given_name', 'over18'];
1
+ import { describe, it } from "node:test";
2
+ import { isIntroTextTypeValid, isRequiredClaimsValid } from "./validator.js";
3
+ import assert from "node:assert";
4
+ describe("isRequiredClaimsValid", () => {
5
+ it("should return true if requiredClaims is undefined", () => {
6
+ const claims = ["given_name", "over18"];
7
7
  const requiredClaims = undefined;
8
8
  assert.strictEqual(isRequiredClaimsValid(claims, requiredClaims), true);
9
9
  });
10
- it('should return false if requiredClaims is empty', () => {
11
- const claims = ['given_name', 'over18'];
10
+ it("should return false if requiredClaims is empty", () => {
11
+ const claims = ["given_name", "over18"];
12
12
  const requiredClaims = [];
13
13
  assert.strictEqual(isRequiredClaimsValid(claims, requiredClaims), false);
14
14
  });
15
- it('should return true if requiredClaims is a subset of claims', () => {
16
- const claims = ['given_name', 'over18'];
17
- const requiredClaims = ['given_name'];
15
+ it("should return true if requiredClaims is a subset of claims", () => {
16
+ const claims = ["given_name", "over18"];
17
+ const requiredClaims = ["given_name"];
18
18
  assert.strictEqual(isRequiredClaimsValid(claims, requiredClaims), true);
19
19
  });
20
- it('should return false if requiredClaims is not a subset of claims', () => {
21
- const claims = ['given_name', 'over18'];
22
- const requiredClaims = ['given_name', 'birthdate'];
20
+ it("should return false if requiredClaims is not a subset of claims", () => {
21
+ const claims = ["given_name", "over18"];
22
+ const requiredClaims = ["given_name", "birthdate"];
23
23
  assert.strictEqual(isRequiredClaimsValid(claims, requiredClaims), false);
24
24
  });
25
25
  });
26
- describe('isIntroTextTypeValid', () => {
27
- it('should return true if type is undefined', () => {
26
+ describe("isIntroTextTypeValid", () => {
27
+ it("should return true if type is undefined", () => {
28
28
  assert.ok(isIntroTextTypeValid(undefined, undefined));
29
29
  });
30
- it('should return true if introTextType is defined', () => {
31
- assert.ok(isIntroTextTypeValid('tiny', 'verify-account'));
30
+ it("should return true if introTextType is defined", () => {
31
+ assert.ok(isIntroTextTypeValid("tiny", "verify-account"));
32
32
  });
33
- it('should return false if introTextType is undefined', () => {
34
- assert.ok(!isIntroTextTypeValid('tiny', undefined));
33
+ it("should return false if introTextType is undefined", () => {
34
+ assert.ok(!isIntroTextTypeValid("tiny", undefined));
35
35
  });
36
36
  });
package/incognito.d.ts DELETED
@@ -1,41 +0,0 @@
1
- /*!
2
- *
3
- * detectIncognito v1.4.1
4
- *
5
- * https://github.com/Joe12387/detectIncognito
6
- *
7
- * MIT License
8
- *
9
- * Copyright (c) 2021 - 2024 Joe Rutkowski <Joe@dreggle.com>
10
- *
11
- * Permission is hereby granted, free of charge, to any person obtaining a copy
12
- * of this software and associated documentation files (the "Software"), to deal
13
- * in the Software without restriction, including without limitation the rights
14
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
- * copies of the Software, and to permit persons to whom the Software is
16
- * furnished to do so, subject to the following conditions:
17
- *
18
- * The above copyright notice and this permission notice shall be included in all
19
- * copies or substantial portions of the Software.
20
- *
21
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
- * SOFTWARE.
28
- *
29
- * Please keep this comment intact in order to properly abide by the MIT License.
30
- *
31
- **/
32
- declare global {
33
- interface Window {
34
- detectIncognito: typeof detectIncognito;
35
- }
36
- }
37
- export declare function detectIncognito(): Promise<{
38
- isPrivate: boolean;
39
- browserName: string;
40
- }>;
41
- export default detectIncognito;
package/incognito.js DELETED
@@ -1,239 +0,0 @@
1
- /* eslint-disable */
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- export function detectIncognito() {
12
- return __awaiter(this, void 0, void 0, function* () {
13
- return yield new Promise(function (resolve, reject) {
14
- let browserName = 'Unknown';
15
- function __callback(isPrivate) {
16
- resolve({
17
- isPrivate,
18
- browserName
19
- });
20
- }
21
- function identifyChromium() {
22
- const ua = navigator.userAgent;
23
- if (ua.match(/Chrome/)) {
24
- if (navigator.brave !== undefined) {
25
- return 'Brave';
26
- }
27
- else if (ua.match(/Edg/)) {
28
- return 'Edge';
29
- }
30
- else if (ua.match(/OPR/)) {
31
- return 'Opera';
32
- }
33
- return 'Chrome';
34
- }
35
- else {
36
- return 'Chromium';
37
- }
38
- }
39
- function assertEvalToString(value) {
40
- return value === eval.toString().length;
41
- }
42
- function feid() {
43
- let toFixedEngineID = 0;
44
- let neg = parseInt("-1");
45
- try {
46
- neg.toFixed(neg);
47
- }
48
- catch (e) {
49
- toFixedEngineID = e.message.length;
50
- }
51
- return toFixedEngineID;
52
- }
53
- function isSafari() {
54
- return feid() === 44;
55
- }
56
- function isChrome() {
57
- return feid() === 51;
58
- }
59
- function isFirefox() {
60
- return feid() === 25;
61
- }
62
- function isMSIE() {
63
- return (navigator.msSaveBlob !== undefined && assertEvalToString(39));
64
- }
65
- /**
66
- * Safari (Safari for iOS & macOS)
67
- **/
68
- function newSafariTestByStorageFallback() {
69
- var _a;
70
- if (!((_a = navigator.storage) === null || _a === void 0 ? void 0 : _a.estimate)) {
71
- __callback(false);
72
- return;
73
- }
74
- navigator.storage
75
- .estimate()
76
- .then(({ usage, quota }) => {
77
- // iOS 18.x/macOS Safari 18.x (normal): ~41GB
78
- // iOS 18.x/macOS Safari 18.x (private): ~1GB
79
- // If reported quota < 2 GB => likely private
80
- if (quota && quota < 2000000000) {
81
- __callback(true);
82
- }
83
- else {
84
- __callback(false);
85
- }
86
- })
87
- .catch(() => {
88
- __callback(false);
89
- });
90
- }
91
- function newSafariTest() {
92
- const tmp_name = String(Math.random());
93
- try {
94
- const db = window.indexedDB.open(tmp_name, 1);
95
- db.onupgradeneeded = function (i) {
96
- var _a, _b;
97
- const res = (_a = i.target) === null || _a === void 0 ? void 0 : _a.result;
98
- try {
99
- res.createObjectStore('test', {
100
- autoIncrement: true
101
- }).put(new Blob());
102
- }
103
- catch (e) {
104
- let message = e;
105
- if (e instanceof Error) {
106
- message = (_b = e.message) !== null && _b !== void 0 ? _b : e;
107
- }
108
- if (typeof message !== 'string') {
109
- __callback(false);
110
- return;
111
- }
112
- const matchesExpectedError = message.includes('BlobURLs are not yet supported');
113
- if (matchesExpectedError) {
114
- __callback(true);
115
- }
116
- }
117
- finally {
118
- res.close();
119
- window.indexedDB.deleteDatabase(tmp_name);
120
- // indexdb works on newer versions of safari so we need to check via storage fallback
121
- newSafariTestByStorageFallback();
122
- }
123
- };
124
- }
125
- catch (e) {
126
- __callback(false);
127
- }
128
- }
129
- function oldSafariTest() {
130
- const openDB = window.openDatabase;
131
- const storage = window.localStorage;
132
- try {
133
- openDB(null, null, null, null);
134
- }
135
- catch (e) {
136
- __callback(true);
137
- return;
138
- }
139
- try {
140
- storage.setItem('test', '1');
141
- storage.removeItem('test');
142
- }
143
- catch (e) {
144
- __callback(true);
145
- return;
146
- }
147
- __callback(false);
148
- }
149
- function safariPrivateTest() {
150
- if (navigator.maxTouchPoints !== undefined) {
151
- newSafariTest();
152
- }
153
- else {
154
- oldSafariTest();
155
- }
156
- }
157
- /**
158
- * Chrome
159
- **/
160
- function getQuotaLimit() {
161
- const w = window;
162
- if (w.performance !== undefined &&
163
- w.performance.memory !== undefined &&
164
- w.performance.memory.jsHeapSizeLimit !== undefined) {
165
- return performance.memory.jsHeapSizeLimit;
166
- }
167
- return 1073741824;
168
- }
169
- // >= 76
170
- function storageQuotaChromePrivateTest() {
171
- navigator.webkitTemporaryStorage.queryUsageAndQuota(function (_, quota) {
172
- const quotaInMib = Math.round(quota / (1024 * 1024));
173
- const quotaLimitInMib = Math.round(getQuotaLimit() / (1024 * 1024)) * 2;
174
- __callback(quotaInMib < quotaLimitInMib);
175
- }, function (e) {
176
- reject(new Error('detectIncognito somehow failed to query storage quota: ' +
177
- e.message));
178
- });
179
- }
180
- // 50 to 75
181
- function oldChromePrivateTest() {
182
- const fs = window.webkitRequestFileSystem;
183
- const success = function () {
184
- __callback(false);
185
- };
186
- const error = function () {
187
- __callback(true);
188
- };
189
- fs(0, 1, success, error);
190
- }
191
- function chromePrivateTest() {
192
- if (self.Promise !== undefined && self.Promise.allSettled !== undefined) {
193
- storageQuotaChromePrivateTest();
194
- }
195
- else {
196
- oldChromePrivateTest();
197
- }
198
- }
199
- /**
200
- * Firefox
201
- **/
202
- function firefoxPrivateTest() {
203
- __callback(navigator.serviceWorker === undefined);
204
- }
205
- /**
206
- * MSIE
207
- **/
208
- function msiePrivateTest() {
209
- __callback(window.indexedDB === undefined);
210
- }
211
- function main() {
212
- if (isSafari()) {
213
- browserName = 'Safari';
214
- safariPrivateTest();
215
- }
216
- else if (isChrome()) {
217
- browserName = identifyChromium();
218
- chromePrivateTest();
219
- }
220
- else if (isFirefox()) {
221
- browserName = 'Firefox';
222
- firefoxPrivateTest();
223
- }
224
- else if (isMSIE()) {
225
- browserName = 'Internet Explorer';
226
- msiePrivateTest();
227
- }
228
- else {
229
- reject(new Error('detectIncognito cannot determine the browser'));
230
- }
231
- }
232
- main();
233
- });
234
- });
235
- }
236
- if (typeof window !== 'undefined') {
237
- window.detectIncognito = detectIncognito;
238
- }
239
- export default detectIncognito;