@proconnect-gouv/proconnect.identite 1.0.0 → 1.1.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 +16 -0
- package/LICENSE +21 -0
- package/README.md +117 -0
- package/dist/managers/certification/is-organization-dirigeant.d.ts +3 -3
- package/dist/managers/certification/is-organization-dirigeant.d.ts.map +1 -1
- package/dist/managers/certification/is-organization-dirigeant.js +5 -5
- package/dist/managers/organization/get-organization-info.d.ts +2 -2
- package/dist/managers/organization/get-organization-info.d.ts.map +1 -1
- package/dist/managers/organization/get-organization-info.js +3 -3
- package/dist/mappers/certification/index.d.ts +1 -1
- package/dist/mappers/certification/index.d.ts.map +1 -1
- package/dist/mappers/organization/from-siret.d.ts +1 -1
- package/dist/mappers/organization/from-siret.d.ts.map +1 -1
- package/dist/mappers/organization/from-siret.js +1 -1
- package/dist/services/organization/index.d.ts +2 -0
- package/dist/services/organization/index.d.ts.map +1 -1
- package/dist/services/organization/index.js +2 -0
- package/dist/services/organization/is-public-service.d.ts +3 -0
- package/dist/services/organization/is-public-service.d.ts.map +1 -0
- package/dist/services/organization/is-public-service.js +19 -0
- package/dist/services/organization/is-syndicat-communal.d.ts +3 -0
- package/dist/services/organization/is-syndicat-communal.d.ts.map +1 -0
- package/dist/services/organization/is-syndicat-communal.js +11 -0
- package/dist/types/organization.d.ts +1 -1
- package/dist/types/organization.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/managers/certification/is-organization-dirigeant.test.ts +11 -11
- package/src/managers/certification/is-organization-dirigeant.ts +13 -13
- package/src/managers/organization/get-organization-info.test.ts +2 -2
- package/src/managers/organization/get-organization-info.ts +7 -7
- package/src/mappers/certification/index.ts +1 -1
- package/src/mappers/organization/from-siret.test.ts +1 -1
- package/src/mappers/organization/from-siret.ts +2 -2
- package/src/repositories/organization/get-users-by-organization.test.ts.snapshot +1 -1
- package/src/repositories/user/find-by-email.test.ts +1 -1
- package/src/repositories/user/find-by-id.test.ts +1 -1
- package/src/repositories/user/get-by-id.test.ts +1 -1
- package/src/services/organization/index.ts +2 -0
- package/src/services/organization/is-public-service.test.ts +99 -0
- package/src/services/organization/is-public-service.ts +35 -0
- package/src/services/organization/is-syndicat-communal.test.ts +31 -0
- package/src/services/organization/is-syndicat-communal.ts +16 -0
- package/src/types/organization-info.ts +1 -1
- package/src/types/organization.ts +1 -1
- package/testing/seed/mandataires/index.ts +1 -1
- package/testing/seed/organizations/index.ts +74 -0
- package/tsconfig.json +1 -0
- package/tsconfig.lib.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @proconnect-gouv/proconnect.identite
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1449](https://github.com/proconnect-gouv/proconnect-identite/pull/1449) [`a12697c`](https://github.com/proconnect-gouv/proconnect-identite/commit/a12697c3785aea1bb737afec8ce52111132ec807) Thanks [@douglasduteil](https://github.com/douglasduteil)! - ✨ Ajout de la fonction `isPublicService` pour identifier les services publics
|
|
8
|
+
|
|
9
|
+
Nouvelle fonction exportée permettant de déterminer si une organisation est un service public en fonction de sa nature juridique, son statut administratif et des listes de référence officielles.
|
|
10
|
+
|
|
11
|
+
Inspirée par https://github.com/annuaire-entreprises-data-gouv-fr/search-infra/blob/f1e56ac476b0b1730115f7b1f0667e8509ee5379/workflows/data_pipelines/elasticsearch/data_enrichment.py#L155-L189
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
import { isPublicService } from "@proconnect-gouv/proconnect.identite/services/organization";
|
|
15
|
+
|
|
16
|
+
isPublicService(my_oganization) =>> true/false
|
|
17
|
+
```
|
|
18
|
+
|
|
3
19
|
## 1.0.0
|
|
4
20
|
|
|
5
21
|
### Major Changes
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Direction Interministérielle du Numérique - Gouvernement Français
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# 🔐 @proconnect-gouv/proconnect.identite
|
|
2
|
+
|
|
3
|
+
> Core identity management logic for ProConnect
|
|
4
|
+
|
|
5
|
+
## ⚙️ Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @proconnect-gouv/proconnect.identite
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 📖 Usage
|
|
12
|
+
|
|
13
|
+
### Managers
|
|
14
|
+
|
|
15
|
+
High-level business logic for certification, FranceConnect integration, organization, and user management.
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { isOrganizationDirigeant } from "@proconnect-gouv/proconnect.identite/managers/certification";
|
|
19
|
+
import { getOrganizationInfo } from "@proconnect-gouv/proconnect.identite/managers/organization";
|
|
20
|
+
import { assignUserVerificationTypeToDomain } from "@proconnect-gouv/proconnect.identite/managers/user";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Repositories
|
|
24
|
+
|
|
25
|
+
Data access layer for email domains, organizations, and users.
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import {
|
|
29
|
+
findByEmail,
|
|
30
|
+
findById,
|
|
31
|
+
getByIdFactory,
|
|
32
|
+
} from "@proconnect-gouv/proconnect.identite/repositories/user";
|
|
33
|
+
import {
|
|
34
|
+
findByUserId,
|
|
35
|
+
linkUserToOrganization,
|
|
36
|
+
} from "@proconnect-gouv/proconnect.identite/repositories/organization";
|
|
37
|
+
import { addDomain } from "@proconnect-gouv/proconnect.identite/repositories/email-domain";
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Services
|
|
41
|
+
|
|
42
|
+
Stateless business logic for organization validation and PostgreSQL utilities.
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import {
|
|
46
|
+
isEntrepriseUnipersonnelle,
|
|
47
|
+
isPublicService,
|
|
48
|
+
} from "@proconnect-gouv/proconnect.identite/services/organization";
|
|
49
|
+
import { hashToPostgresParams } from "@proconnect-gouv/proconnect.identite/services/postgres";
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Mappers
|
|
53
|
+
|
|
54
|
+
Data transformation utilities for certification and organization data.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { fromSiret } from "@proconnect-gouv/proconnect.identite/mappers/organization";
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Types
|
|
61
|
+
|
|
62
|
+
TypeScript type definitions for users, organizations, claims, and more.
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import type {
|
|
66
|
+
User,
|
|
67
|
+
Organization,
|
|
68
|
+
UserOrganizationLink,
|
|
69
|
+
EmailDomain,
|
|
70
|
+
FranceConnectUserInfo,
|
|
71
|
+
} from "@proconnect-gouv/proconnect.identite/types";
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Data
|
|
75
|
+
|
|
76
|
+
Raw data arrays for organization domain whitelists.
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { domainsWhitelist } from "@proconnect-gouv/proconnect.identite/data/organization";
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Errors
|
|
83
|
+
|
|
84
|
+
Custom error types for identity management operations.
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import {
|
|
88
|
+
InvalidCertificationError,
|
|
89
|
+
InvalidSiretError,
|
|
90
|
+
NotFoundError,
|
|
91
|
+
OrganizationNotActiveError,
|
|
92
|
+
OrganizationNotFoundError,
|
|
93
|
+
UserNotFoundError,
|
|
94
|
+
ModerationNotFoundError,
|
|
95
|
+
} from "@proconnect-gouv/proconnect.identite/errors";
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## 📊 Available Exports
|
|
99
|
+
|
|
100
|
+
- **`/managers/certification`** - Organization certification and dirigeant validation
|
|
101
|
+
- **`/managers/franceconnect`** - FranceConnect OIDC client integration
|
|
102
|
+
- **`/managers/organization`** - Organization business logic
|
|
103
|
+
- **`/managers/user`** - User business logic
|
|
104
|
+
- **`/repositories/email-domain`** - Email domain data access
|
|
105
|
+
- **`/repositories/organization`** - Organization data access
|
|
106
|
+
- **`/repositories/user`** - User data access
|
|
107
|
+
- **`/services/organization`** - Organization validation utilities
|
|
108
|
+
- **`/services/postgres`** - PostgreSQL query utilities
|
|
109
|
+
- **`/mappers/certification`** - Certification data transformation
|
|
110
|
+
- **`/mappers/organization`** - Organization data transformation
|
|
111
|
+
- **`/types`** - TypeScript type definitions
|
|
112
|
+
- **`/data/organization`** - Organization reference data
|
|
113
|
+
- **`/errors`** - Custom error types
|
|
114
|
+
|
|
115
|
+
## 📖 License
|
|
116
|
+
|
|
117
|
+
[MIT](./LICENSE)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { GetFranceConnectUserInfoHandler } from "#src/repositories/user";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ApiEntrepriseInfogreffeRepository, ApiEntrepriseInseeRepository } from "@proconnect-gouv/proconnect.api_entreprise/api";
|
|
3
3
|
import type { InseeApiRepository } from "@proconnect-gouv/proconnect.insee/api";
|
|
4
4
|
type IsOrganizationExecutiveFactoryFactoryConfig = {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
ApiEntrepriseInfogreffeRepository: ApiEntrepriseInfogreffeRepository;
|
|
6
|
+
ApiEntrepriseInseeRepository: Pick<ApiEntrepriseInseeRepository, "findBySiret">;
|
|
7
7
|
EQUALITY_THRESHOLD?: number;
|
|
8
8
|
getFranceConnectUserInfo: GetFranceConnectUserInfoHandler;
|
|
9
9
|
InseeApiRepository: Pick<InseeApiRepository, "findBySiret">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-organization-dirigeant.d.ts","sourceRoot":"","sources":["../../../src/managers/certification/is-organization-dirigeant.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AAG9E,OAAO,KAAK,EACV,iCAAiC,EACjC,4BAA4B,EAC7B,MAAM,
|
|
1
|
+
{"version":3,"file":"is-organization-dirigeant.d.ts","sourceRoot":"","sources":["../../../src/managers/certification/is-organization-dirigeant.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AAG9E,OAAO,KAAK,EACV,iCAAiC,EACjC,4BAA4B,EAC7B,MAAM,gDAAgD,CAAC;AAExD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAMhF,KAAK,2CAA2C,GAAG;IACjD,iCAAiC,EAAE,iCAAiC,CAAC;IACrE,4BAA4B,EAAE,IAAI,CAChC,4BAA4B,EAC5B,aAAa,CACd,CAAC;IACF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,wBAAwB,EAAE,+BAA+B,CAAC;IAC1D,kBAAkB,EAAE,IAAI,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;IAC5D,GAAG,CAAC,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC;CAC1B,CAAC;AAIF,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,2CAA2C,IAYjD,OAAO,MAAM,EACb,SAAS,MAAM,sBAoFlB;AAED,MAAM,MAAM,8BAA8B,GAAG,UAAU,CACrD,OAAO,8BAA8B,CACtC,CAAC"}
|
|
@@ -7,9 +7,9 @@ import { formatBirthdate } from "@proconnect-gouv/proconnect.insee/formatters";
|
|
|
7
7
|
import { distance } from "./distance.js";
|
|
8
8
|
//
|
|
9
9
|
export function isOrganizationDirigeantFactory(config) {
|
|
10
|
-
const { EQUALITY_THRESHOLD = 0,
|
|
10
|
+
const { EQUALITY_THRESHOLD = 0, ApiEntrepriseInseeRepository, ApiEntrepriseInfogreffeRepository, InseeApiRepository, getFranceConnectUserInfo, log = () => { }, } = config;
|
|
11
11
|
return async function isOrganizationDirigeant(siret, user_id) {
|
|
12
|
-
const establishment = await
|
|
12
|
+
const establishment = await ApiEntrepriseInseeRepository.findBySiret(siret);
|
|
13
13
|
const franceconnectUserInfo = await getFranceConnectUserInfo(user_id);
|
|
14
14
|
if (!franceconnectUserInfo) {
|
|
15
15
|
throw new NotFoundError("FranceConnect UserInfo not found");
|
|
@@ -32,7 +32,7 @@ export function isOrganizationDirigeantFactory(config) {
|
|
|
32
32
|
})) {
|
|
33
33
|
return getSourceDirigeantsFromInsseApi(establishment.siret);
|
|
34
34
|
}
|
|
35
|
-
return
|
|
35
|
+
return getSourceDirigeantsFromApiEntreprise(establishment.unite_legale.siren);
|
|
36
36
|
}
|
|
37
37
|
async function getSourceDirigeantsFromInsseApi(siret) {
|
|
38
38
|
const { uniteLegale } = await InseeApiRepository.findBySiret(siret);
|
|
@@ -53,8 +53,8 @@ export function isOrganizationDirigeantFactory(config) {
|
|
|
53
53
|
},
|
|
54
54
|
];
|
|
55
55
|
}
|
|
56
|
-
async function
|
|
57
|
-
const mandataires = await
|
|
56
|
+
async function getSourceDirigeantsFromApiEntreprise(siren) {
|
|
57
|
+
const mandataires = await ApiEntrepriseInfogreffeRepository.findMandatairesSociauxBySiren(siren);
|
|
58
58
|
return mandataires.map((mandataire) => fromInfogreffe(mandataire));
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type OrganizationInfo } from "#src/types";
|
|
2
|
-
import type {
|
|
3
|
-
export declare function getOrganizationInfoFactory(config:
|
|
2
|
+
import type { ApiEntrepriseInseeRepository } from "@proconnect-gouv/proconnect.api_entreprise/api";
|
|
3
|
+
export declare function getOrganizationInfoFactory(config: ApiEntrepriseInseeRepository): (siretOrSiren: string) => Promise<OrganizationInfo>;
|
|
4
4
|
export type GetOrganizationInfoHandler = ReturnType<typeof getOrganizationInfoFactory>;
|
|
5
5
|
//# sourceMappingURL=get-organization-info.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-organization-info.d.ts","sourceRoot":"","sources":["../../../src/managers/organization/get-organization-info.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"get-organization-info.d.ts","sourceRoot":"","sources":["../../../src/managers/organization/get-organization-info.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gDAAgD,CAAC;AAQnG,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,4BAA4B,IAKlC,cAAc,MAAM,KACnB,OAAO,CAAC,gBAAgB,CAAC,CAiC7B;AAED,MAAM,MAAM,0BAA0B,GAAG,UAAU,CACjD,OAAO,0BAA0B,CAClC,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { InvalidSiretError, NotFoundError } from "#src/errors";
|
|
3
3
|
import { OrganizationInfoMapper } from "#src/mappers";
|
|
4
4
|
import {} from "#src/types";
|
|
5
|
-
import {
|
|
5
|
+
import { ApiEntrepriseConnectionError, ApiEntrepriseInvalidSiret, } from "@proconnect-gouv/proconnect.api_entreprise/types";
|
|
6
6
|
//
|
|
7
7
|
export function getOrganizationInfoFactory(config) {
|
|
8
8
|
const { findBySiren, findBySiret } = config;
|
|
@@ -25,9 +25,9 @@ export function getOrganizationInfoFactory(config) {
|
|
|
25
25
|
return establishment;
|
|
26
26
|
}
|
|
27
27
|
catch (e) {
|
|
28
|
-
if (
|
|
28
|
+
if (ApiEntrepriseInvalidSiret.isInvalidSiret(e))
|
|
29
29
|
throw new InvalidSiretError();
|
|
30
|
-
throw new
|
|
30
|
+
throw new ApiEntrepriseConnectionError("unknown error while fetching entreprise.api.gouv.fr", { cause: e });
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { IdentityVector } from "#src/types";
|
|
2
|
-
import type { InfogreffeSirenMandatairesSociaux } from "@proconnect-gouv/proconnect.
|
|
2
|
+
import type { InfogreffeSirenMandatairesSociaux } from "@proconnect-gouv/proconnect.api_entreprise/types";
|
|
3
3
|
export declare function fromInfogreffe(mandataire: InfogreffeSirenMandatairesSociaux): IdentityVector;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mappers/certification/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mappers/certification/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,kDAAkD,CAAC;AAI1G,wBAAgB,cAAc,CAC5B,UAAU,EAAE,iCAAiC,GAC5C,cAAc,CAQhB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "#src/types";
|
|
2
2
|
import { type OrganizationInfo } from "#src/types";
|
|
3
|
-
import type { InseeSireneEstablishmentSiretResponseData } from "@proconnect-gouv/proconnect.
|
|
3
|
+
import type { InseeSireneEstablishmentSiretResponseData } from "@proconnect-gouv/proconnect.api_entreprise/types";
|
|
4
4
|
export declare function fromSiret(siretData: InseeSireneEstablishmentSiretResponseData): OrganizationInfo;
|
|
5
5
|
//# sourceMappingURL=from-siret.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"from-siret.d.ts","sourceRoot":"","sources":["../../../src/mappers/organization/from-siret.ts"],"names":[],"mappings":"AAEA,OAAO,YAAY,CAAC;AACpB,OAAO,EAA0B,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAO3E,OAAO,KAAK,EAAE,yCAAyC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"from-siret.d.ts","sourceRoot":"","sources":["../../../src/mappers/organization/from-siret.ts"],"names":[],"mappings":"AAEA,OAAO,YAAY,CAAC;AACpB,OAAO,EAA0B,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAO3E,OAAO,KAAK,EAAE,yCAAyC,EAAE,MAAM,kDAAkD,CAAC;AAKlH,wBAAgB,SAAS,CACvB,SAAS,EAAE,yCAAyC,GACnD,gBAAgB,CAyDlB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//
|
|
2
2
|
import "#src/types";
|
|
3
3
|
import { OrganizationInfoSchema } from "#src/types";
|
|
4
|
-
import { formatAddress, formatMainActivity, formatNomComplet, libelleFromCodeEffectif, } from "@proconnect-gouv/proconnect.
|
|
4
|
+
import { formatAddress, formatMainActivity, formatNomComplet, libelleFromCodeEffectif, } from "@proconnect-gouv/proconnect.api_entreprise/formatters";
|
|
5
5
|
import { capitalize } from "lodash-es";
|
|
6
6
|
//
|
|
7
7
|
export function fromSiret(siretData) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/organization/index.ts"],"names":[],"mappings":"AAEA,cAAc,yCAAyC,CAAC;AACxD,cAAc,mCAAmC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/organization/index.ts"],"names":[],"mappings":"AAEA,cAAc,yCAAyC,CAAC;AACxD,cAAc,mCAAmC,CAAC;AAClD,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-public-service.d.ts","sourceRoot":"","sources":["../../../src/services/organization/is-public-service.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAG/E,eAAO,MAAM,eAAe,GAAI,mEAI7B,YAAY,KAAG,OAoBjB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
import { NATURE_JURIDIQUE_SERVICE_PUBLIC, SERVICE_PUBLIC_BLACKLIST, SERVICE_PUBLIC_WHITELIST, } from "@proconnect-gouv/proconnect.annuaire_entreprises";
|
|
3
|
+
// inspired from https://github.com/annuaire-entreprises-data-gouv-fr/search-infra/blob/f1e56ac476b0b1730115f7b1f0667e8509ee5379/workflows/data_pipelines/elasticsearch/data_enrichment.py#L155-L189
|
|
4
|
+
export const isPublicService = ({ cached_categorie_juridique, cached_etat_administratif, siret, }) => {
|
|
5
|
+
const siren = (siret || "").substring(0, 9);
|
|
6
|
+
// Entities in the blacklist are never considered public services
|
|
7
|
+
if (SERVICE_PUBLIC_BLACKLIST.includes(siren)) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
// Closed entities are not considered public services
|
|
11
|
+
if (cached_etat_administratif === "C") {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
// Check if entity is in whitelist or has a public service legal nature code
|
|
15
|
+
const cat_jur_ok = cached_categorie_juridique &&
|
|
16
|
+
NATURE_JURIDIQUE_SERVICE_PUBLIC.includes(cached_categorie_juridique);
|
|
17
|
+
const whitelist_ok = SERVICE_PUBLIC_WHITELIST.includes(siren);
|
|
18
|
+
return cat_jur_ok || whitelist_ok;
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-syndicat-communal.d.ts","sourceRoot":"","sources":["../../../src/services/organization/is-syndicat-communal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAQ/C,eAAO,MAAM,kBAAkB,GAAI,yCAEhC,IAAI,CAAC,YAAY,EAAE,oCAAoC,CAAC,KAAG,OAK7D,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const cat_jur = [
|
|
2
|
+
"Syndicat intercommunal à vocation multiple (SIVOM)",
|
|
3
|
+
"Syndicat intercommunal à vocation unique (SIVU)",
|
|
4
|
+
"Syndicat mixte fermé",
|
|
5
|
+
];
|
|
6
|
+
export const isSyndicatCommunal = ({ cached_libelle_categorie_juridique, }) => {
|
|
7
|
+
if (!cached_libelle_categorie_juridique) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
return cat_jur.includes(cached_libelle_categorie_juridique);
|
|
11
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization.d.ts","sourceRoot":"","sources":["../../src/types/organization.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"organization.d.ts","sourceRoot":"","sources":["../../src/types/organization.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AAIzF,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE,IAAI,CAAC;IACjB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,wBAAwB,EAAE,gBAAgB,CAAC;IAC3C,qCAAqC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrD,+BAA+B,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/C,yBAAyB,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,iCAAiC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjD,0BAA0B,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,kCAAkC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClD,0BAA0B,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,kCAAkC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClD,4BAA4B,EAAE,IAAI,GAAG,IAAI,CAAC;CAC3C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proconnect-gouv/proconnect.identite",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"homepage": "https://github.com/proconnect-gouv/proconnect-identite/tree/main/packages/identite#readme",
|
|
5
5
|
"bugs": "https://github.com/proconnect-gouv/proconnect-identite/issues",
|
|
6
6
|
"repository": {
|
|
@@ -50,14 +50,15 @@
|
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@electric-sql/pglite": "^0.3.8",
|
|
53
|
+
"@proconnect-gouv/proconnect.annuaire_entreprises": "^1.1.0",
|
|
53
54
|
"@proconnect-gouv/proconnect.core": "^1.0.0",
|
|
54
55
|
"@proconnect-gouv/proconnect.devtools.typescript": "1.0.0",
|
|
55
|
-
"@proconnect-gouv/proconnect.
|
|
56
|
+
"@proconnect-gouv/proconnect.api_entreprise": "^1.1.0",
|
|
56
57
|
"@proconnect-gouv/proconnect.insee": "^1.0.0",
|
|
57
|
-
"@sinonjs/fake-timers": "^14.0.0",
|
|
58
58
|
"@types/node": "^22.18.6",
|
|
59
|
+
"@types/pg": "^8.15.5",
|
|
59
60
|
"await-to-js": "^3.0.0",
|
|
60
|
-
"node-pg-migrate": "^
|
|
61
|
+
"node-pg-migrate": "^8.0.3",
|
|
61
62
|
"pg": "^8.16.3",
|
|
62
63
|
"tsx": "^4.20.3"
|
|
63
64
|
},
|
|
@@ -13,7 +13,7 @@ import { UlysseToriMandataire } from "#testing/seed/mandataires";
|
|
|
13
13
|
import {
|
|
14
14
|
Papillon,
|
|
15
15
|
RogalDornEntrepreneur as RogalDornSireneEntrepreneur,
|
|
16
|
-
} from "@proconnect-gouv/proconnect.
|
|
16
|
+
} from "@proconnect-gouv/proconnect.api_entreprise/testing/seed/insee/siret";
|
|
17
17
|
import assert from "node:assert/strict";
|
|
18
18
|
import { describe, it } from "node:test";
|
|
19
19
|
import { isOrganizationDirigeantFactory } from "./is-organization-dirigeant.js";
|
|
@@ -23,10 +23,10 @@ import { isOrganizationDirigeantFactory } from "./is-organization-dirigeant.js";
|
|
|
23
23
|
describe("isOrganizationDirigeantFactory", () => {
|
|
24
24
|
it("should recognize a user as executive of a auto-entrepreneur", async () => {
|
|
25
25
|
const isOrganizationDirigeant = isOrganizationDirigeantFactory({
|
|
26
|
-
|
|
26
|
+
ApiEntrepriseInfogreffeRepository: {
|
|
27
27
|
findMandatairesSociauxBySiren: () => Promise.reject(new Error("💣")),
|
|
28
28
|
},
|
|
29
|
-
|
|
29
|
+
ApiEntrepriseInseeRepository: {
|
|
30
30
|
findBySiret: () => Promise.resolve(RogalDornSireneEntrepreneur),
|
|
31
31
|
},
|
|
32
32
|
InseeApiRepository: {
|
|
@@ -44,10 +44,10 @@ describe("isOrganizationDirigeantFactory", () => {
|
|
|
44
44
|
|
|
45
45
|
it("should not match another mandataire", async () => {
|
|
46
46
|
const isOrganizationDirigeant = isOrganizationDirigeantFactory({
|
|
47
|
-
|
|
47
|
+
ApiEntrepriseInfogreffeRepository: {
|
|
48
48
|
findMandatairesSociauxBySiren: () => Promise.reject(new Error("💣")),
|
|
49
49
|
},
|
|
50
|
-
|
|
50
|
+
ApiEntrepriseInseeRepository: {
|
|
51
51
|
findBySiret: () => Promise.resolve(RogalDornSireneEntrepreneur),
|
|
52
52
|
},
|
|
53
53
|
InseeApiRepository: {
|
|
@@ -65,11 +65,11 @@ describe("isOrganizationDirigeantFactory", () => {
|
|
|
65
65
|
|
|
66
66
|
it("should match Ulysse Tori as an executive of Papillon", async () => {
|
|
67
67
|
const isOrganizationDirigeant = isOrganizationDirigeantFactory({
|
|
68
|
-
|
|
68
|
+
ApiEntrepriseInfogreffeRepository: {
|
|
69
69
|
findMandatairesSociauxBySiren: () =>
|
|
70
70
|
Promise.resolve([UlysseToriMandataire]),
|
|
71
71
|
},
|
|
72
|
-
|
|
72
|
+
ApiEntrepriseInseeRepository: {
|
|
73
73
|
findBySiret: () => Promise.resolve(Papillon),
|
|
74
74
|
},
|
|
75
75
|
InseeApiRepository: {
|
|
@@ -84,10 +84,10 @@ describe("isOrganizationDirigeantFactory", () => {
|
|
|
84
84
|
|
|
85
85
|
it("❎ fail with no franceconnect user info", async () => {
|
|
86
86
|
const isOrganizationDirigeant = isOrganizationDirigeantFactory({
|
|
87
|
-
|
|
87
|
+
ApiEntrepriseInfogreffeRepository: {
|
|
88
88
|
findMandatairesSociauxBySiren: () => Promise.reject(new Error("💣")),
|
|
89
89
|
},
|
|
90
|
-
|
|
90
|
+
ApiEntrepriseInseeRepository: {
|
|
91
91
|
findBySiret: () => Promise.resolve(RogalDornSireneEntrepreneur),
|
|
92
92
|
},
|
|
93
93
|
InseeApiRepository: {
|
|
@@ -104,10 +104,10 @@ describe("isOrganizationDirigeantFactory", () => {
|
|
|
104
104
|
|
|
105
105
|
it("❎ fail with no mandataires", async () => {
|
|
106
106
|
const isOrganizationDirigeant = isOrganizationDirigeantFactory({
|
|
107
|
-
|
|
107
|
+
ApiEntrepriseInfogreffeRepository: {
|
|
108
108
|
findMandatairesSociauxBySiren: () => Promise.resolve([]),
|
|
109
109
|
},
|
|
110
|
-
|
|
110
|
+
ApiEntrepriseInseeRepository: {
|
|
111
111
|
findBySiret: () => Promise.resolve(Papillon),
|
|
112
112
|
},
|
|
113
113
|
InseeApiRepository: {
|
|
@@ -7,10 +7,10 @@ import type { GetFranceConnectUserInfoHandler } from "#src/repositories/user";
|
|
|
7
7
|
import { isEntrepriseUnipersonnelle } from "#src/services/organization";
|
|
8
8
|
import type { IdentityVector } from "#src/types";
|
|
9
9
|
import type {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from "@proconnect-gouv/proconnect.
|
|
13
|
-
import type { InseeSireneEstablishmentSiretResponseData } from "@proconnect-gouv/proconnect.
|
|
10
|
+
ApiEntrepriseInfogreffeRepository,
|
|
11
|
+
ApiEntrepriseInseeRepository,
|
|
12
|
+
} from "@proconnect-gouv/proconnect.api_entreprise/api";
|
|
13
|
+
import type { InseeSireneEstablishmentSiretResponseData } from "@proconnect-gouv/proconnect.api_entreprise/types";
|
|
14
14
|
import type { InseeApiRepository } from "@proconnect-gouv/proconnect.insee/api";
|
|
15
15
|
import { formatBirthdate } from "@proconnect-gouv/proconnect.insee/formatters";
|
|
16
16
|
import { distance } from "./distance.js";
|
|
@@ -18,9 +18,9 @@ import { distance } from "./distance.js";
|
|
|
18
18
|
//
|
|
19
19
|
|
|
20
20
|
type IsOrganizationExecutiveFactoryFactoryConfig = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
ApiEntrepriseInfogreffeRepository: ApiEntrepriseInfogreffeRepository;
|
|
22
|
+
ApiEntrepriseInseeRepository: Pick<
|
|
23
|
+
ApiEntrepriseInseeRepository,
|
|
24
24
|
"findBySiret"
|
|
25
25
|
>;
|
|
26
26
|
EQUALITY_THRESHOLD?: number;
|
|
@@ -36,8 +36,8 @@ export function isOrganizationDirigeantFactory(
|
|
|
36
36
|
) {
|
|
37
37
|
const {
|
|
38
38
|
EQUALITY_THRESHOLD = 0,
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
ApiEntrepriseInseeRepository,
|
|
40
|
+
ApiEntrepriseInfogreffeRepository,
|
|
41
41
|
InseeApiRepository,
|
|
42
42
|
getFranceConnectUserInfo,
|
|
43
43
|
log = () => {},
|
|
@@ -47,7 +47,7 @@ export function isOrganizationDirigeantFactory(
|
|
|
47
47
|
siret: string,
|
|
48
48
|
user_id: number,
|
|
49
49
|
) {
|
|
50
|
-
const establishment = await
|
|
50
|
+
const establishment = await ApiEntrepriseInseeRepository.findBySiret(siret);
|
|
51
51
|
const franceconnectUserInfo = await getFranceConnectUserInfo(user_id);
|
|
52
52
|
if (!franceconnectUserInfo) {
|
|
53
53
|
throw new NotFoundError("FranceConnect UserInfo not found");
|
|
@@ -93,7 +93,7 @@ export function isOrganizationDirigeantFactory(
|
|
|
93
93
|
) {
|
|
94
94
|
return getSourceDirigeantsFromInsseApi(establishment.siret);
|
|
95
95
|
}
|
|
96
|
-
return
|
|
96
|
+
return getSourceDirigeantsFromApiEntreprise(
|
|
97
97
|
establishment.unite_legale.siren,
|
|
98
98
|
);
|
|
99
99
|
}
|
|
@@ -121,9 +121,9 @@ export function isOrganizationDirigeantFactory(
|
|
|
121
121
|
];
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
async function
|
|
124
|
+
async function getSourceDirigeantsFromApiEntreprise(siren: string) {
|
|
125
125
|
const mandataires =
|
|
126
|
-
await
|
|
126
|
+
await ApiEntrepriseInfogreffeRepository.findMandatairesSociauxBySiren(
|
|
127
127
|
siren,
|
|
128
128
|
);
|
|
129
129
|
|
|
@@ -2,8 +2,8 @@ import { NotFoundError } from "#src/errors";
|
|
|
2
2
|
import {
|
|
3
3
|
CommunautéDeCommunes,
|
|
4
4
|
RogalDornEntrepreneur,
|
|
5
|
-
} from "@proconnect-gouv/proconnect.
|
|
6
|
-
import type { InseeSireneEstablishmentSiretResponseData } from "@proconnect-gouv/proconnect.
|
|
5
|
+
} from "@proconnect-gouv/proconnect.api_entreprise/testing/seed/insee/siret";
|
|
6
|
+
import type { InseeSireneEstablishmentSiretResponseData } from "@proconnect-gouv/proconnect.api_entreprise/types";
|
|
7
7
|
import assert from "node:assert/strict";
|
|
8
8
|
import { suite, test } from "node:test";
|
|
9
9
|
import { getOrganizationInfoFactory } from "./get-organization-info.js";
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
import { InvalidSiretError, NotFoundError } from "#src/errors";
|
|
4
4
|
import { OrganizationInfoMapper } from "#src/mappers";
|
|
5
5
|
import { type OrganizationInfo } from "#src/types";
|
|
6
|
-
import type {
|
|
6
|
+
import type { ApiEntrepriseInseeRepository } from "@proconnect-gouv/proconnect.api_entreprise/api";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "@proconnect-gouv/proconnect.
|
|
8
|
+
ApiEntrepriseConnectionError,
|
|
9
|
+
ApiEntrepriseInvalidSiret,
|
|
10
|
+
} from "@proconnect-gouv/proconnect.api_entreprise/types";
|
|
11
11
|
|
|
12
12
|
//
|
|
13
13
|
|
|
14
14
|
export function getOrganizationInfoFactory(
|
|
15
|
-
config:
|
|
15
|
+
config: ApiEntrepriseInseeRepository,
|
|
16
16
|
) {
|
|
17
17
|
const { findBySiren, findBySiret } = config;
|
|
18
18
|
|
|
@@ -42,10 +42,10 @@ export function getOrganizationInfoFactory(
|
|
|
42
42
|
|
|
43
43
|
return establishment;
|
|
44
44
|
} catch (e) {
|
|
45
|
-
if (
|
|
45
|
+
if (ApiEntrepriseInvalidSiret.isInvalidSiret(e))
|
|
46
46
|
throw new InvalidSiretError();
|
|
47
47
|
|
|
48
|
-
throw new
|
|
48
|
+
throw new ApiEntrepriseConnectionError(
|
|
49
49
|
"unknown error while fetching entreprise.api.gouv.fr",
|
|
50
50
|
{ cause: e },
|
|
51
51
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
3
|
import type { IdentityVector } from "#src/types";
|
|
4
|
-
import type { InfogreffeSirenMandatairesSociaux } from "@proconnect-gouv/proconnect.
|
|
4
|
+
import type { InfogreffeSirenMandatairesSociaux } from "@proconnect-gouv/proconnect.api_entreprise/types";
|
|
5
5
|
|
|
6
6
|
//
|
|
7
7
|
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
AppleEuropeInc,
|
|
5
5
|
MaireClamart,
|
|
6
6
|
RogalDornEntrepreneur,
|
|
7
|
-
} from "@proconnect-gouv/proconnect.
|
|
7
|
+
} from "@proconnect-gouv/proconnect.api_entreprise/testing/seed/insee/siret";
|
|
8
8
|
import { suite, test } from "node:test";
|
|
9
9
|
import { fromSiret } from "./from-siret.js";
|
|
10
10
|
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
formatMainActivity,
|
|
8
8
|
formatNomComplet,
|
|
9
9
|
libelleFromCodeEffectif,
|
|
10
|
-
} from "@proconnect-gouv/proconnect.
|
|
11
|
-
import type { InseeSireneEstablishmentSiretResponseData } from "@proconnect-gouv/proconnect.
|
|
10
|
+
} from "@proconnect-gouv/proconnect.api_entreprise/formatters";
|
|
11
|
+
import type { InseeSireneEstablishmentSiretResponseData } from "@proconnect-gouv/proconnect.api_entreprise/types";
|
|
12
12
|
import { capitalize } from "lodash-es";
|
|
13
13
|
|
|
14
14
|
//
|
|
@@ -3,7 +3,7 @@ exports[`getUsersByOrganizationFactory > should find users by organization id 1`
|
|
|
3
3
|
{
|
|
4
4
|
"id": 1,
|
|
5
5
|
"email": "lion.eljonson@darkangels.world",
|
|
6
|
-
"encrypted_password":
|
|
6
|
+
"encrypted_password": null,
|
|
7
7
|
"reset_password_token": null,
|
|
8
8
|
"reset_password_sent_at": null,
|
|
9
9
|
"sign_in_count": 0,
|