@proconnect-gouv/proconnect.core 1.0.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/CHANGELOG.md +120 -0
- package/README.md +61 -0
- package/dist/data/index.cjs +282 -0
- package/dist/data/index.d.ts +7 -0
- package/dist/data/index.js +278 -0
- package/dist/most-used-free-email-domains-BiH62xhh.cjs +21 -0
- package/dist/most-used-free-email-domains-CtdkKumB.js +19 -0
- package/dist/security/index.cjs +8013 -0
- package/dist/security/index.d.ts +31 -0
- package/dist/security/index.js +7998 -0
- package/dist/services/email/index.cjs +19 -0
- package/dist/services/email/index.d.ts +12 -0
- package/dist/services/email/index.js +16 -0
- package/dist/services/oidc/index.cjs +10 -0
- package/dist/services/oidc/index.d.ts +19 -0
- package/dist/services/oidc/index.js +8 -0
- package/dist/services/suggestion/index.cjs +20 -0
- package/dist/services/suggestion/index.d.ts +3 -0
- package/dist/services/suggestion/index.js +18 -0
- package/package.json +92 -0
- package/src/data/diceware-wordlist-fr-alt.ts +7780 -0
- package/src/data/gouvfr-domains.ts +246 -0
- package/src/data/index.ts +3 -0
- package/src/data/most-used-free-email-domains.ts +18 -0
- package/src/data/other-gouv-domains.ts +41 -0
- package/src/security/generate-diceware-password.test.ts +26 -0
- package/src/security/generate-diceware-password.ts +25 -0
- package/src/security/generate-pin-token.test.ts +19 -0
- package/src/security/generate-pin-token.ts +13 -0
- package/src/security/generate-token.test.ts +14 -0
- package/src/security/generate-token.ts +9 -0
- package/src/security/get-trusted-referrer-path.test.ts +49 -0
- package/src/security/get-trusted-referrer-path.ts +34 -0
- package/src/security/hash-password.test.ts +16 -0
- package/src/security/hash-password.ts +10 -0
- package/src/security/index.ts +15 -0
- package/src/security/is-domain-valid.test.ts +28 -0
- package/src/security/is-domain-valid.ts +28 -0
- package/src/security/is-email-valid.test.ts +71 -0
- package/src/security/is-email-valid.ts +44 -0
- package/src/security/is-name-valid.test.ts +61 -0
- package/src/security/is-name-valid.ts +5 -0
- package/src/security/is-password-secure.test.ts +53 -0
- package/src/security/is-password-secure.ts +25 -0
- package/src/security/is-phone-number-valid.test.ts +44 -0
- package/src/security/is-phone-number-valid.ts +19 -0
- package/src/security/is-siret-valid.test.ts +36 -0
- package/src/security/is-siret-valid.ts +15 -0
- package/src/security/is-visible-string.test.ts +30 -0
- package/src/security/is-visible-string.ts +7 -0
- package/src/security/owasp-password-strength-tester.ts +149 -0
- package/src/security/validate-password.test.ts +27 -0
- package/src/security/validate-password.ts +16 -0
- package/src/services/email/get-email-domain.test.ts +30 -0
- package/src/services/email/get-email-domain.ts +20 -0
- package/src/services/email/index.ts +4 -0
- package/src/services/email/is-a-free-domain.test.ts +26 -0
- package/src/services/email/is-a-free-domain.ts +11 -0
- package/src/services/oidc/contains-essential-acrs.test.ts +63 -0
- package/src/services/oidc/contains-essential-acrs.ts +24 -0
- package/src/services/oidc/index.ts +2 -0
- package/src/services/oidc/prompt.ts +11 -0
- package/src/services/suggestion/did-you-mean.test.ts +29 -0
- package/src/services/suggestion/did-you-mean.ts +19 -0
- package/src/services/suggestion/index.ts +3 -0
- package/tsconfig.json +11 -0
- package/tsconfig.lib.json +9 -0
- package/types/index.d.ts +4 -0
- package/types/is-disposable-email-domain.d.ts +5 -0
- package/types/tld-extract.d.ts +12 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tldExtract = require('tld-extract');
|
|
4
|
+
var mostUsedFreeEmailDomains = require('../../most-used-free-email-domains-BiH62xhh.cjs');
|
|
5
|
+
var isDisposableEmailDomain = require('is-disposable-email-domain');
|
|
6
|
+
|
|
7
|
+
function getEmailDomain(email) {
|
|
8
|
+
const parts = email.split("@");
|
|
9
|
+
const host = parts[parts.length - 1];
|
|
10
|
+
const { sub, domain } = tldExtract.parse_host(host, { allowDotlessTLD: true });
|
|
11
|
+
return [sub, domain].filter(Boolean).join(".");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function isAFreeDomain(domain) {
|
|
15
|
+
return isDisposableEmailDomain.isFree(domain) || mostUsedFreeEmailDomains.mostUsedFreeEmailDomains.includes(domain);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.getEmailDomain = getEmailDomain;
|
|
19
|
+
exports.isAFreeDomain = isAFreeDomain;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the domain of an email address
|
|
3
|
+
* @example
|
|
4
|
+
* getEmailDomain("lion.eljonson@darkangels.world") // darkangels.world
|
|
5
|
+
* @param email - the email address
|
|
6
|
+
* @returns the domain of the email address
|
|
7
|
+
*/
|
|
8
|
+
declare function getEmailDomain(email: string): string;
|
|
9
|
+
|
|
10
|
+
declare function isAFreeDomain(domain: string): boolean;
|
|
11
|
+
|
|
12
|
+
export { getEmailDomain, isAFreeDomain };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { parse_host } from 'tld-extract';
|
|
2
|
+
import { m as mostUsedFreeEmailDomains } from '../../most-used-free-email-domains-CtdkKumB.js';
|
|
3
|
+
import { isFree } from 'is-disposable-email-domain';
|
|
4
|
+
|
|
5
|
+
function getEmailDomain(email) {
|
|
6
|
+
const parts = email.split("@");
|
|
7
|
+
const host = parts[parts.length - 1];
|
|
8
|
+
const { sub, domain } = parse_host(host, { allowDotlessTLD: true });
|
|
9
|
+
return [sub, domain].filter(Boolean).join(".");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function isAFreeDomain(domain) {
|
|
13
|
+
return isFree(domain) || mostUsedFreeEmailDomains.includes(domain);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { getEmailDomain, isAFreeDomain };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function containsEssentialAcrs(prompt) {
|
|
4
|
+
if (prompt.name === "login" && (prompt.reasons.includes("essential_acr") || prompt.reasons.includes("essential_acrs"))) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.containsEssentialAcrs = containsEssentialAcrs;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PromptDetail } from 'oidc-provider';
|
|
2
|
+
|
|
3
|
+
interface EssentialAcrPromptDetail extends PromptDetail {
|
|
4
|
+
details: {
|
|
5
|
+
acr: {
|
|
6
|
+
essential: boolean;
|
|
7
|
+
value?: string;
|
|
8
|
+
values?: string[];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Check if a prompt contains essential acrs
|
|
15
|
+
* @param prompt the oidc-provider {@link PromptDetail}
|
|
16
|
+
*/
|
|
17
|
+
declare function containsEssentialAcrs(prompt: PromptDetail): prompt is EssentialAcrPromptDetail;
|
|
18
|
+
|
|
19
|
+
export { type EssentialAcrPromptDetail, containsEssentialAcrs };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('../../data/index.cjs');
|
|
4
|
+
var mostUsedFreeEmailDomains = require('../../most-used-free-email-domains-BiH62xhh.cjs');
|
|
5
|
+
var emailSpellChecker = require('@zootools/email-spell-checker');
|
|
6
|
+
|
|
7
|
+
function getDidYouMeanSuggestion(email) {
|
|
8
|
+
const suggestedEmail = emailSpellChecker.run({
|
|
9
|
+
domains: [
|
|
10
|
+
...index.gouvfrDomains,
|
|
11
|
+
...index.otherGouvDomains,
|
|
12
|
+
...mostUsedFreeEmailDomains.mostUsedFreeEmailDomains
|
|
13
|
+
],
|
|
14
|
+
topLevelDomains: ["fr", "com", "net"],
|
|
15
|
+
email
|
|
16
|
+
});
|
|
17
|
+
return suggestedEmail?.full ? suggestedEmail.full : "";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.getDidYouMeanSuggestion = getDidYouMeanSuggestion;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { gouvfrDomains, otherGouvDomains } from '../../data/index.js';
|
|
2
|
+
import { m as mostUsedFreeEmailDomains } from '../../most-used-free-email-domains-CtdkKumB.js';
|
|
3
|
+
import { run } from '@zootools/email-spell-checker';
|
|
4
|
+
|
|
5
|
+
function getDidYouMeanSuggestion(email) {
|
|
6
|
+
const suggestedEmail = run({
|
|
7
|
+
domains: [
|
|
8
|
+
...gouvfrDomains,
|
|
9
|
+
...otherGouvDomains,
|
|
10
|
+
...mostUsedFreeEmailDomains
|
|
11
|
+
],
|
|
12
|
+
topLevelDomains: ["fr", "com", "net"],
|
|
13
|
+
email
|
|
14
|
+
});
|
|
15
|
+
return suggestedEmail?.full ? suggestedEmail.full : "";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { getDidYouMeanSuggestion };
|
package/package.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proconnect-gouv/proconnect.core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"homepage": "https://github.com/proconnect-gouv/proconnect-identite/tree/main/packages/core#readme",
|
|
5
|
+
"bugs": "https://github.com/proconnect-gouv/proconnect-identite/issues",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/proconnect-gouv/proconnect-identite.git",
|
|
9
|
+
"directory": "packages/core"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"type": "module",
|
|
14
|
+
"imports": {
|
|
15
|
+
"#src/data/gouvfr-domains": "./src/data/gouvfr-domains.ts",
|
|
16
|
+
"#src/data/most-used-free-email-domains": "./src/data/most-used-free-email-domains.ts",
|
|
17
|
+
"#src/data/other-gouv-domains": "./src/data/other-gouv-domains.ts"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
"./security": {
|
|
21
|
+
"require": "./dist/security/index.cjs",
|
|
22
|
+
"import": "./dist/security/index.js",
|
|
23
|
+
"types": "./dist/security/index.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./services/email": {
|
|
26
|
+
"require": "./dist/services/email/index.cjs",
|
|
27
|
+
"import": "./dist/services/email/index.js",
|
|
28
|
+
"types": "./dist/services/email/index.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./services/oidc": {
|
|
31
|
+
"require": "./dist/services/oidc/index.cjs",
|
|
32
|
+
"import": "./dist/services/oidc/index.js",
|
|
33
|
+
"types": "./dist/services/oidc/index.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./services/suggestion": {
|
|
36
|
+
"require": "./dist/services/suggestion/index.cjs",
|
|
37
|
+
"import": "./dist/services/suggestion/index.js",
|
|
38
|
+
"types": "./dist/services/suggestion/index.d.ts"
|
|
39
|
+
},
|
|
40
|
+
"./data": {
|
|
41
|
+
"require": "./dist/data/index.cjs",
|
|
42
|
+
"import": "./dist/data/index.js",
|
|
43
|
+
"types": "./dist/data/index.d.ts"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"typesVersions": {
|
|
47
|
+
"*": {
|
|
48
|
+
"services/security": [
|
|
49
|
+
"./dist/security/index.d.ts"
|
|
50
|
+
],
|
|
51
|
+
"services/email": [
|
|
52
|
+
"./dist/services/email/index.d.ts"
|
|
53
|
+
],
|
|
54
|
+
"services/oidc": [
|
|
55
|
+
"./dist/services/oidc/index.d.ts"
|
|
56
|
+
],
|
|
57
|
+
"services/suggestion": [
|
|
58
|
+
"./dist/services/suggestion/index.d.ts"
|
|
59
|
+
],
|
|
60
|
+
"data": [
|
|
61
|
+
"./dist/data/index.d.ts"
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "pkgroll --tsconfig=tsconfig.lib.json",
|
|
67
|
+
"check": "npm run build -- --noEmit",
|
|
68
|
+
"dev": "npm run build -- --watch --preserveWatchOutput",
|
|
69
|
+
"dev:test": "tsx --watch --test src/**/*.test.ts",
|
|
70
|
+
"test": "tsx --test --test-reporter=spec src/**/*.test.ts"
|
|
71
|
+
},
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"@types/lodash-es": "^4.17.12",
|
|
74
|
+
"@types/oidc-provider": "^9.1.1",
|
|
75
|
+
"@zootools/email-spell-checker": "^1.12.0",
|
|
76
|
+
"bcryptjs": "^3.0.2",
|
|
77
|
+
"is-disposable-email-domain": "^1.0.7",
|
|
78
|
+
"lodash-es": "^4.17.21",
|
|
79
|
+
"nanoid": "^5.1.5",
|
|
80
|
+
"tld-extract": "^2.1.0"
|
|
81
|
+
},
|
|
82
|
+
"devDependencies": {
|
|
83
|
+
"@proconnect-gouv/proconnect.devtools.typescript": "1.0.0",
|
|
84
|
+
"@types/node": "^22.18.6",
|
|
85
|
+
"pkgroll": "^2.12.1",
|
|
86
|
+
"tsx": "^4.20.3"
|
|
87
|
+
},
|
|
88
|
+
"publishConfig": {
|
|
89
|
+
"access": "public",
|
|
90
|
+
"provenance": true
|
|
91
|
+
}
|
|
92
|
+
}
|