@proconnect-gouv/proconnect.insee 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.
Files changed (49) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +63 -0
  3. package/dist/api/find-by-siret.d.ts +22 -0
  4. package/dist/api/find-by-siret.d.ts.map +1 -0
  5. package/dist/api/find-by-siret.js +24 -0
  6. package/dist/api/get-insee-access-token.d.ts +10 -0
  7. package/dist/api/get-insee-access-token.d.ts.map +1 -0
  8. package/dist/api/get-insee-access-token.js +28 -0
  9. package/dist/api/index.d.ts +9 -0
  10. package/dist/api/index.d.ts.map +1 -0
  11. package/dist/api/index.js +4 -0
  12. package/dist/client/index.d.ts +12 -0
  13. package/dist/client/index.d.ts.map +1 -0
  14. package/dist/client/index.js +20 -0
  15. package/dist/formatters/birthdate.d.ts +7 -0
  16. package/dist/formatters/birthdate.d.ts.map +1 -0
  17. package/dist/formatters/birthdate.js +19 -0
  18. package/dist/formatters/index.d.ts +2 -0
  19. package/dist/formatters/index.d.ts.map +1 -0
  20. package/dist/formatters/index.js +2 -0
  21. package/dist/types/errors.d.ts +17 -0
  22. package/dist/types/errors.d.ts.map +1 -0
  23. package/dist/types/errors.js +21 -0
  24. package/dist/types/etablissement.d.ts +4 -0
  25. package/dist/types/etablissement.d.ts.map +1 -0
  26. package/dist/types/etablissement.js +2 -0
  27. package/dist/types/index.d.ts +3 -0
  28. package/dist/types/index.d.ts.map +1 -0
  29. package/dist/types/index.js +3 -0
  30. package/openapi/auth.d.ts +96 -0
  31. package/openapi/auth.yaml +85 -0
  32. package/openapi/index.d.ts +1573 -0
  33. package/openapi/index.yaml +1868 -0
  34. package/package.json +53 -0
  35. package/src/api/find-by-siret.test.ts +34 -0
  36. package/src/api/find-by-siret.ts +36 -0
  37. package/src/api/get-insee-access-token.test.ts +62 -0
  38. package/src/api/get-insee-access-token.ts +51 -0
  39. package/src/api/index.ts +16 -0
  40. package/src/client/index.ts +32 -0
  41. package/src/formatters/birthdate.test.ts +42 -0
  42. package/src/formatters/birthdate.ts +24 -0
  43. package/src/formatters/index.ts +3 -0
  44. package/src/types/errors.ts +37 -0
  45. package/src/types/etablissement.ts +12 -0
  46. package/src/types/index.ts +4 -0
  47. package/tsconfig.json +12 -0
  48. package/tsconfig.lib.json +9 -0
  49. package/tsconfig.lib.tsbuildinfo +1 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @proconnect-gouv/proconnect.insee
2
+
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#1455](https://github.com/proconnect-gouv/proconnect-identite/pull/1455) [`38fffb0`](https://github.com/proconnect-gouv/proconnect-identite/commit/38fffb00ca5a5d2341a662f684d2555bbfb5ff02) Thanks [@douglasduteil](https://github.com/douglasduteil)! - 📦 Première version officiel des packages `@proconnect-gouv/*`
package/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # 📦 @proconnect-gouv/proconnect.insee
2
+
3
+ > ⚡ Typed api.insee.fr API for ProConnect
4
+
5
+ ## ⚙️ Installation
6
+
7
+ ```bash
8
+ npm install @proconnect-gouv/proconnect.insee
9
+ ```
10
+
11
+ ## 📖 Usage
12
+
13
+ ### `@proconnect-gouv/proconnect.insee/client"
14
+
15
+ Get full fetch client from `@proconnect-gouv/proconnect.insee/client`
16
+
17
+ ```ts
18
+ import { createInseeOpenApiClient } from "@proconnect-gouv/proconnect.insee/client";
19
+
20
+ const inseeSirenePrivateOpenApiClient = createInseeSirenePrivateOpenApiClient(
21
+ "__INSEE_API_TOKEN__",
22
+ { baseUrl: "https://api.insee.fr" },
23
+ );
24
+ ```
25
+
26
+ ### `@proconnect-gouv/proconnect.insee/api"
27
+
28
+ Get use case api factory functions from `@proconnect-gouv/proconnect.insee/api`
29
+
30
+ ```ts
31
+ import { findBySiretFactory } from "@proconnect-gouv/proconnect.insee/api/insee";
32
+
33
+ export const findBySiret = findBySiretFactory(inseeOpenApiClient);
34
+ const establishment: InseeSiretEstablishment = await findBySiret("662042449");
35
+ ```
36
+
37
+ ### `@proconnect-gouv/proconnect.insee/types"
38
+
39
+ Get API Entreprise types and errors from `@proconnect-gouv/proconnect.insee/types`
40
+
41
+ ```ts
42
+ import type { InseeSiretEstablishment } from "@proconnect-gouv/proconnect.insee/types";
43
+
44
+ const establishment: InseeSiretEstablishment;
45
+ ```
46
+
47
+ ### `@proconnect-gouv/proconnect.insee/formatters"
48
+
49
+ Get models formatters from `@proconnect-gouv/proconnect.insee/formatters`
50
+
51
+ ```ts
52
+ import { formatBirthdate } from "@proconnect-gouv/proconnect.insee/formatters";
53
+
54
+ const birthdate: Date = formatBirthdate("19800601");
55
+ ```
56
+
57
+ ### `@proconnect-gouv/proconnect.insee/testing"
58
+
59
+ Used for internal tests
60
+
61
+ ## 📖 License
62
+
63
+ [MIT](./LICENSE.md)
@@ -0,0 +1,22 @@
1
+ import type { InseeSirenePrivateOpenApiClient } from "#src/client";
2
+ import type { FetchOptions } from "openapi-fetch";
3
+ export declare function findBySiretFactory(client: InseeSirenePrivateOpenApiClient, optionsFn?: () => FetchOptions<unknown>): (siret: string) => Promise<{
4
+ score?: number;
5
+ siren?: string;
6
+ nic?: string;
7
+ siret?: string;
8
+ statutDiffusionEtablissement?: string;
9
+ dateCreationEtablissement?: string;
10
+ trancheEffectifsEtablissement?: string;
11
+ anneeEffectifsEtablissement?: string;
12
+ activitePrincipaleRegistreMetiersEtablissement?: string;
13
+ dateDernierTraitementEtablissement?: string;
14
+ etablissementSiege?: boolean;
15
+ nombrePeriodesEtablissement?: number;
16
+ uniteLegale?: import("../../openapi/index.js").components["schemas"]["UniteLegaleEtablissement"];
17
+ adresseEtablissement?: import("../../openapi/index.js").components["schemas"]["Adresse"];
18
+ adresse2Etablissement?: import("../../openapi/index.js").components["schemas"]["AdresseComplementaire"];
19
+ periodesEtablissement?: import("../../openapi/index.js").components["schemas"]["PeriodeEtablissement"][];
20
+ }>;
21
+ export type FindBySiretHandler = ReturnType<typeof findBySiretFactory>;
22
+ //# sourceMappingURL=find-by-siret.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-by-siret.d.ts","sourceRoot":"","sources":["../../src/api/find-by-siret.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,+BAA+B,EACvC,SAAS,GAAE,MAAM,YAAY,CAAC,OAAO,CAAc,IAEjB,OAAO,MAAM;;;;;;;;;;;;;kBAwBmhR,sDAAsB;2BAA0D,sDAAsB;4BAA0C,sDAAsB;4BAAwD,sDAAsB;GAHvzR;AAED,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ //
2
+ import { InseeApiError } from "#src/types";
3
+ //
4
+ export function findBySiretFactory(client, optionsFn = () => ({})) {
5
+ return async function findBySiret(siret) {
6
+ const { data, error } = await client.GET("/siret/{siret}", {
7
+ ...optionsFn(),
8
+ params: {
9
+ path: {
10
+ siret,
11
+ },
12
+ },
13
+ });
14
+ if (error)
15
+ throw new InseeApiError(error);
16
+ if (!data)
17
+ throw new InseeApiError({
18
+ header: { statut: 404, message: "Not Data" },
19
+ });
20
+ if (data.header?.statut !== 200 || !data.etablissement)
21
+ throw new InseeApiError(data);
22
+ return data.etablissement;
23
+ };
24
+ }
@@ -0,0 +1,10 @@
1
+ import { type ClientOptions } from "openapi-fetch";
2
+ export declare function getInseeAccessTokenFactory(body: {
3
+ client_id: string;
4
+ client_secret: string;
5
+ grant_type: "password";
6
+ username: string;
7
+ password: string;
8
+ }, options?: ClientOptions): () => Promise<string>;
9
+ export type GetInseeAccessTokenHandler = ReturnType<typeof getInseeAccessTokenFactory>;
10
+ //# sourceMappingURL=get-insee-access-token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-insee-access-token.d.ts","sourceRoot":"","sources":["../../src/api/get-insee-access-token.ts"],"names":[],"mappings":"AAIA,OAAqB,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAIjE,wBAAgB,0BAA0B,CACxC,IAAI,EAAE;IACJ,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,EACD,OAAO,GAAE,aAAkB,yBA8B5B;AAED,MAAM,MAAM,0BAA0B,GAAG,UAAU,CACjD,OAAO,0BAA0B,CAClC,CAAC"}
@@ -0,0 +1,28 @@
1
+ //
2
+ import { InseeApiAuthError } from "#src/types";
3
+ import createClient, {} from "openapi-fetch";
4
+ //
5
+ export function getInseeAccessTokenFactory(body, options = {}) {
6
+ return async function getInseeAccessToken() {
7
+ const client = createClient({
8
+ baseUrl: options.baseUrl ?? "https://auth.insee.net/auth",
9
+ ...options,
10
+ });
11
+ const { data, error } = await client.POST("/realms/apim-gravitee/protocol/openid-connect/token", {
12
+ body,
13
+ headers: {
14
+ "Content-Type": "application/x-www-form-urlencoded",
15
+ },
16
+ });
17
+ if (error) {
18
+ throw new InseeApiAuthError(error);
19
+ }
20
+ if (!data.access_token) {
21
+ throw new InseeApiAuthError({
22
+ error: "Access token not found",
23
+ error_description: "This should not happen...",
24
+ });
25
+ }
26
+ return data.access_token;
27
+ };
28
+ }
@@ -0,0 +1,9 @@
1
+ import type { FindBySiretHandler } from "./find-by-siret.js";
2
+ import type { GetInseeAccessTokenHandler } from "./get-insee-access-token.js";
3
+ export * from "./find-by-siret.js";
4
+ export * from "./get-insee-access-token.js";
5
+ export interface InseeApiRepository {
6
+ getInseeAccessToken: GetInseeAccessTokenHandler;
7
+ findBySiret: FindBySiretHandler;
8
+ }
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAI9E,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAI5C,MAAM,WAAW,kBAAkB;IACjC,mBAAmB,EAAE,0BAA0B,CAAC;IAChD,WAAW,EAAE,kBAAkB,CAAC;CACjC"}
@@ -0,0 +1,4 @@
1
+ //
2
+ //
3
+ export * from "./find-by-siret.js";
4
+ export * from "./get-insee-access-token.js";
@@ -0,0 +1,12 @@
1
+ import type { paths } from "#openapi";
2
+ import { type ClientOptions } from "openapi-fetch";
3
+ /**
4
+ * Create an INSEE OpenAPI client
5
+ * @see https://portail-api.insee.fr
6
+ * @param options - the client options
7
+ * @note `options.baseUrl` is "https://api.insee.fr/api-sirene/prive/3.11" by default
8
+ * @returns the client
9
+ */
10
+ export declare function createInseeSirenePrivateOpenApiClient(token: string, options?: ClientOptions): import("openapi-fetch").Client<paths, `${string}/${string}`>;
11
+ export type InseeSirenePrivateOpenApiClient = ReturnType<typeof createInseeSirenePrivateOpenApiClient>;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAqB,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAIjE;;;;;;GAMG;AACH,wBAAgB,qCAAqC,CACnD,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,aAAkB,gEAS5B;AAED,MAAM,MAAM,+BAA+B,GAAG,UAAU,CACtD,OAAO,qCAAqC,CAC7C,CAAC"}
@@ -0,0 +1,20 @@
1
+ //
2
+ import createClient, {} from "openapi-fetch";
3
+ //
4
+ /**
5
+ * Create an INSEE OpenAPI client
6
+ * @see https://portail-api.insee.fr
7
+ * @param options - the client options
8
+ * @note `options.baseUrl` is "https://api.insee.fr/api-sirene/prive/3.11" by default
9
+ * @returns the client
10
+ */
11
+ export function createInseeSirenePrivateOpenApiClient(token, options = {}) {
12
+ return createClient({
13
+ baseUrl: options.baseUrl ?? "https://api.insee.fr/api-sirene/prive/3.11",
14
+ headers: {
15
+ Authorization: `Bearer ${token}`,
16
+ },
17
+ ...options,
18
+ });
19
+ }
20
+ //
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Format an INSEE birthdate to a native JS date
3
+ * @param value - the date in the INSEE format "YYYYMMDD"
4
+ * @returns the date in native JS format
5
+ */
6
+ export declare function formatBirthdate(value: string): Date;
7
+ //# sourceMappingURL=birthdate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"birthdate.d.ts","sourceRoot":"","sources":["../../src/formatters/birthdate.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,QAc5C"}
@@ -0,0 +1,19 @@
1
+ //
2
+ const INSEE_BIRTHDATE_REGEX = /^(?<year>\d+)(?<month>\d{2})(?<day>\d{2})$/;
3
+ /**
4
+ * Format an INSEE birthdate to a native JS date
5
+ * @param value - the date in the INSEE format "YYYYMMDD"
6
+ * @returns the date in native JS format
7
+ */
8
+ export function formatBirthdate(value) {
9
+ const match = String(value).match(INSEE_BIRTHDATE_REGEX);
10
+ if (!match || !match.groups) {
11
+ throw new Error(`Invalid date format. Expected YYYYMMDD. Actual: ${value}`);
12
+ }
13
+ const { year, month, day } = match.groups;
14
+ const date = new Date(`${year}-${month}-${day}`);
15
+ if (isNaN(date.getTime())) {
16
+ throw new Error(`Invalid date format. ${year}-${month}-${day}`);
17
+ }
18
+ return date;
19
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./birthdate.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formatters/index.ts"],"names":[],"mappings":"AAEA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ //
2
+ export * from "./birthdate.js";
@@ -0,0 +1,17 @@
1
+ import type { components } from "#openapi";
2
+ import type { components as auth_components } from "#openapi/auth";
3
+ export type OpenApiAuthError = auth_components["schemas"]["Error"];
4
+ export type OpenApiError = components["schemas"]["ReponseErreur"];
5
+ export declare class InseeApiAuthError extends Error {
6
+ issue: OpenApiAuthError;
7
+ constructor(issue?: OpenApiAuthError, options?: {
8
+ cause?: Error;
9
+ } | undefined);
10
+ }
11
+ export declare class InseeApiError extends Error {
12
+ issue: OpenApiError;
13
+ constructor(issue: OpenApiError, options?: {
14
+ cause?: Error;
15
+ } | undefined);
16
+ }
17
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AAInE,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC;AACnE,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC;AAIlE,qBAAa,iBAAkB,SAAQ,KAAK;IAEjC,KAAK,EAAE,gBAAgB;gBAAvB,KAAK,GAAE,gBAGb,EACD,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE,GAAG,SAAS;CAK1C;AAED,qBAAa,aAAc,SAAQ,KAAK;IAE7B,KAAK,EAAE,YAAY;gBAAnB,KAAK,EAAE,YAAY,EAC1B,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE,GAAG,SAAS;CAQ1C"}
@@ -0,0 +1,21 @@
1
+ //
2
+ //
3
+ export class InseeApiAuthError extends Error {
4
+ issue;
5
+ constructor(issue = {
6
+ error: "Unknown",
7
+ error_description: "Unknown",
8
+ }, options) {
9
+ super(`${issue.error}: ${issue.error_description}`, options);
10
+ this.issue = issue;
11
+ this.name = "InseeApiAuthError";
12
+ }
13
+ }
14
+ export class InseeApiError extends Error {
15
+ issue;
16
+ constructor(issue, options) {
17
+ super(issue.header ? `${issue.header?.statut}: ${issue.header.message}` : "", options);
18
+ this.issue = issue;
19
+ this.name = "InseeApiError";
20
+ }
21
+ }
@@ -0,0 +1,4 @@
1
+ import type { paths } from "#openapi";
2
+ export type InseeSiretResponse = paths["/siret/{siret}"]["get"]["responses"][200]["content"]["application/json"];
3
+ export type InseeSiretEstablishment = NonNullable<InseeSiretResponse["etablissement"]>;
4
+ //# sourceMappingURL=etablissement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"etablissement.d.ts","sourceRoot":"","sources":["../../src/types/etablissement.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAItC,MAAM,MAAM,kBAAkB,GAC5B,KAAK,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC;AAElF,MAAM,MAAM,uBAAuB,GAAG,WAAW,CAC/C,kBAAkB,CAAC,eAAe,CAAC,CACpC,CAAC"}
@@ -0,0 +1,2 @@
1
+ //
2
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from "./errors.js";
2
+ export * from "./etablissement.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,3 @@
1
+ //
2
+ export * from "./errors.js";
3
+ export * from "./etablissement.js";
@@ -0,0 +1,96 @@
1
+ /**
2
+ * This file was auto-generated by openapi-typescript.
3
+ * Do not make direct changes to the file.
4
+ */
5
+
6
+ export interface paths {
7
+ "/realms/apim-gravitee/protocol/openid-connect/token": {
8
+ parameters: {
9
+ query?: never;
10
+ header?: never;
11
+ path?: never;
12
+ cookie?: never;
13
+ };
14
+ get?: never;
15
+ put?: never;
16
+ /** Obtenir le jeton JWT indispensable pour pouvoir interroger l'API Sirene. */
17
+ post: {
18
+ parameters: {
19
+ query?: never;
20
+ header?: never;
21
+ path?: never;
22
+ cookie?: never;
23
+ };
24
+ requestBody?: {
25
+ content: {
26
+ "application/x-www-form-urlencoded": {
27
+ client_id: string;
28
+ client_secret: string;
29
+ /** @enum {string} */
30
+ grant_type: "password";
31
+ password: string;
32
+ username: string;
33
+ };
34
+ };
35
+ };
36
+ responses: {
37
+ /** @description Requête traitée avec succès */
38
+ 200: {
39
+ headers: {
40
+ [name: string]: unknown;
41
+ };
42
+ content: {
43
+ "application/json": components["schemas"]["ResponseToken"];
44
+ };
45
+ };
46
+ /** @description Requête invalide */
47
+ 401: {
48
+ headers: {
49
+ [name: string]: unknown;
50
+ };
51
+ content: {
52
+ "application/json": components["schemas"]["Error"];
53
+ };
54
+ };
55
+ };
56
+ };
57
+ delete?: never;
58
+ options?: never;
59
+ head?: never;
60
+ patch?: never;
61
+ trace?: never;
62
+ };
63
+ }
64
+ export type webhooks = Record<string, never>;
65
+ export interface components {
66
+ schemas: {
67
+ Error: {
68
+ error: string;
69
+ error_description: string;
70
+ };
71
+ /** @description Objet renvoyé en cas de succès sur une requête de type token */
72
+ ResponseToken: {
73
+ /** @description Jeton d'accès */
74
+ access_token?: string;
75
+ /** @description Durée avant expiration du jeton d'accès en secondes */
76
+ expires_in?: number;
77
+ /** @description Durée avant expiration du jeton de rafraîchissement en secondes */
78
+ refresh_expires_in?: number;
79
+ /** @description Type de jeton d'accès */
80
+ token_type?: string;
81
+ /** @description Durée avant la date de fin de validité du jeton d'accès en secondes */
82
+ "not-before-policy"?: number;
83
+ /** @description État de la session */
84
+ session_state?: string;
85
+ /** @description Liste des scopes autorisés */
86
+ scope?: string;
87
+ };
88
+ };
89
+ responses: never;
90
+ parameters: never;
91
+ requestBodies: never;
92
+ headers: never;
93
+ pathItems: never;
94
+ }
95
+ export type $defs = Record<string, never>;
96
+ export type operations = Record<string, never>;
@@ -0,0 +1,85 @@
1
+ openapi: 3.1.0
2
+ info:
3
+ title: Sirene Auth API
4
+ description: Documentation de l'API Auth Sirene
5
+ servers:
6
+ - url: https://auth.insee.net/auth
7
+ paths:
8
+ /realms/apim-gravitee/protocol/openid-connect/token:
9
+ post:
10
+ summary: Obtenir le jeton JWT indispensable pour pouvoir interroger l'API Sirene.
11
+ requestBody:
12
+ content:
13
+ application/x-www-form-urlencoded:
14
+ schema:
15
+ type: object
16
+ properties:
17
+ client_id:
18
+ type: string
19
+ client_secret:
20
+ type: string
21
+ grant_type:
22
+ enum:
23
+ - password
24
+ type: string
25
+ password:
26
+ type: string
27
+ username:
28
+ type: string
29
+ required:
30
+ - client_id
31
+ - client_secret
32
+ - grant_type
33
+ - password
34
+ - username
35
+ responses:
36
+ "200":
37
+ description: Requête traitée avec succès
38
+ content:
39
+ application/json:
40
+ schema:
41
+ $ref: "#/components/schemas/ResponseToken"
42
+ "401":
43
+ description: Requête invalide
44
+ content:
45
+ application/json:
46
+ schema:
47
+ $ref: "#/components/schemas/Error"
48
+
49
+ components:
50
+ schemas:
51
+ Error:
52
+ type: object
53
+ properties:
54
+ error:
55
+ type: string
56
+ error_description:
57
+ type: string
58
+ required:
59
+ - error
60
+ - error_description
61
+ ResponseToken:
62
+ type: object
63
+ description: Objet renvoyé en cas de succès sur une requête de type token
64
+ properties:
65
+ access_token:
66
+ type: string
67
+ description: Jeton d'accès
68
+ expires_in:
69
+ type: integer
70
+ description: Durée avant expiration du jeton d'accès en secondes
71
+ refresh_expires_in:
72
+ type: integer
73
+ description: Durée avant expiration du jeton de rafraîchissement en secondes
74
+ token_type:
75
+ type: string
76
+ description: Type de jeton d'accès
77
+ not-before-policy:
78
+ type: integer
79
+ description: Durée avant la date de fin de validité du jeton d'accès en secondes
80
+ session_state:
81
+ type: string
82
+ description: État de la session
83
+ scope:
84
+ type: string
85
+ description: Liste des scopes autorisés