@socialgouv/dila-api-client
Advanced tools
Comparing version 1.1.8 to 1.2.0
@@ -0,1 +1,13 @@ | ||
# [1.2.0](https://github.com/SocialGouv/dila-api-client/compare/v1.1.8...v1.2.0) (2021-08-26) | ||
### Bug Fixes | ||
* **deps:** update dependency simple-oauth2 to v4 ([#174](https://github.com/SocialGouv/dila-api-client/issues/174)) ([aaaebdd](https://github.com/SocialGouv/dila-api-client/commit/aaaebdd7496cc04812018787fc245c34f3dda98d)) | ||
### Features | ||
* update oauth api changes ([#331](https://github.com/SocialGouv/dila-api-client/issues/331)) ([cd9a218](https://github.com/SocialGouv/dila-api-client/commit/cd9a2186b8afb680404a84d2ccd77cc16173c3cd)) | ||
## [1.1.8](https://github.com/SocialGouv/dila-api-client/compare/v1.1.7...v1.1.8) (2021-07-04) | ||
@@ -2,0 +14,0 @@ |
import { ModuleOptions } from "simple-oauth2"; | ||
export declare const API_HOST: string; | ||
export declare const TOKEN_HOST: string; | ||
export declare const CREDENTIALS: ModuleOptions; | ||
export declare const CONFIG: ModuleOptions; | ||
//# sourceMappingURL=constants.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CREDENTIALS = exports.TOKEN_HOST = exports.API_HOST = void 0; | ||
exports.CONFIG = exports.TOKEN_HOST = exports.API_HOST = void 0; | ||
const CLIENT_ID = process.env.OAUTH_CLIENT_ID || ""; | ||
@@ -9,3 +9,3 @@ const CLIENT_SECRET = process.env.OAUTH_CLIENT_SECRET || ""; | ||
exports.TOKEN_HOST = process.env.TOKEN_HOST || "https://oauth.aife.economie.gouv.fr"; | ||
exports.CREDENTIALS = { | ||
exports.CONFIG = { | ||
auth: { | ||
@@ -12,0 +12,0 @@ authorizePath: "/api/oauth/authorize", |
@@ -1,2 +0,1 @@ | ||
import OAuth2 from "simple-oauth2"; | ||
export declare class DilaApiClient { | ||
@@ -7,3 +6,3 @@ apiHost: string; | ||
constructor(apiHost?: string, tokenHost?: string); | ||
getAccessToken(credentials?: OAuth2.ModuleOptions<"client_id">): Promise<string | undefined>; | ||
getAccessToken(config?: import("simple-oauth2").ModuleOptions<"client_id">): Promise<string | undefined>; | ||
fetch({ path, method, params, }: { | ||
@@ -10,0 +9,0 @@ path: string; |
@@ -9,3 +9,3 @@ "use strict"; | ||
const node_fetch_1 = __importDefault(require("node-fetch")); | ||
const simple_oauth2_1 = __importDefault(require("simple-oauth2")); | ||
const simple_oauth2_1 = require("simple-oauth2"); | ||
const constants_1 = require("./constants"); | ||
@@ -21,12 +21,11 @@ const debug = debug_1.default("@socialgouv/dila-api-client"); | ||
} | ||
async getAccessToken(credentials = constants_1.CREDENTIALS) { | ||
async getAccessToken(config = constants_1.CONFIG) { | ||
if (this.globalToken) { | ||
return this.globalToken; | ||
} | ||
const oauth2 = simple_oauth2_1.default.create(credentials); | ||
const client = new simple_oauth2_1.ClientCredentials(config); | ||
try { | ||
const result = await oauth2.clientCredentials.getToken({ | ||
const accessToken = await client.getToken({ | ||
scope: "openid", | ||
}); | ||
const accessToken = oauth2.accessToken.create(result); | ||
this.globalToken = accessToken.token.access_token; | ||
@@ -33,0 +32,0 @@ } |
import { DilaApiClient } from "./DilaApiClient"; | ||
export * from "./constants"; | ||
export { DilaApiClient }; | ||
export default DilaApiClient; | ||
export { DilaApiClient } from "./DilaApiClient"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -15,4 +15,5 @@ "use strict"; | ||
const DilaApiClient_1 = require("./DilaApiClient"); | ||
Object.defineProperty(exports, "DilaApiClient", { enumerable: true, get: function () { return DilaApiClient_1.DilaApiClient; } }); | ||
module.exports = DilaApiClient_1.DilaApiClient; | ||
__exportStar(require("./constants"), exports); | ||
exports.default = DilaApiClient_1.DilaApiClient; | ||
var DilaApiClient_2 = require("./DilaApiClient"); | ||
Object.defineProperty(exports, "DilaApiClient", { enumerable: true, get: function () { return DilaApiClient_2.DilaApiClient; } }); |
{ | ||
"name": "@socialgouv/dila-api-client", | ||
"version": "1.1.8", | ||
"version": "1.2.0", | ||
"description": "a client for the DILA API that publishes the french law", | ||
@@ -29,19 +29,38 @@ "homepage": "https://github.com/SocialGouv/dila-api-client", | ||
"p-all": "^4.0.0", | ||
"simple-oauth2": "^3.4.0" | ||
"simple-oauth2": "^4.2.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.15.0", | ||
"@babel/plugin-transform-modules-commonjs": "^7.15.0", | ||
"@babel/preset-typescript": "^7.15.0", | ||
"@socialgouv/tslint-config-recommended": "^0.35.0", | ||
"@types/debug": "^4.1.6", | ||
"@types/jest": "^26.0.23", | ||
"@types/node": "^14.17.4", | ||
"@types/node-fetch": "^2.5.10", | ||
"@types/simple-oauth2": "^2.5.4", | ||
"jest": "^26.6.3", | ||
"jest-fetch-mock": "^2.1.2", | ||
"@types/debug": "^4.1.7", | ||
"@types/jest": "^27.0.1", | ||
"@types/node": "^16.7.2", | ||
"@types/node-fetch": "^2.5.12", | ||
"@types/simple-oauth2": "^4.1.1", | ||
"jest": "^27.0.6", | ||
"prettier": "^2.3.2", | ||
"ts-jest": "^26.5.6", | ||
"ts-node": "^10.0.0", | ||
"tslint": "^6.1.3", | ||
"typescript": "^4.3.5" | ||
}, | ||
"babel": { | ||
"env": { | ||
"test": { | ||
"plugins": [ | ||
[ | ||
"@babel/plugin-transform-modules-commonjs" | ||
] | ||
], | ||
"presets": [ | ||
[ | ||
"@babel/preset-typescript", | ||
{ | ||
"onlyRemoveTypeImports": true | ||
} | ||
] | ||
] | ||
} | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
139847
+ Added@hapi/hoek@9.3.0(transitive)
+ Added@hapi/topo@5.1.0(transitive)
+ Added@sideway/address@4.1.5(transitive)
+ Added@sideway/formula@3.0.1(transitive)
+ Added@sideway/pinpoint@2.0.0(transitive)
+ Addedjoi@17.13.3(transitive)
+ Addedsimple-oauth2@4.3.0(transitive)
- Removed@babel/runtime@7.26.0(transitive)
- Removed@hapi/address@2.1.4(transitive)
- Removed@hapi/formula@1.2.0(transitive)
- Removed@hapi/hoek@8.5.1(transitive)
- Removed@hapi/joi@16.1.8(transitive)
- Removed@hapi/pinpoint@1.0.2(transitive)
- Removed@hapi/topo@3.1.6(transitive)
- Removeddate-fns@2.30.0(transitive)
- Removedregenerator-runtime@0.14.1(transitive)
- Removedsimple-oauth2@3.4.0(transitive)
Updatedsimple-oauth2@^4.2.0