From c5962c9d05f8f4ca0c71e63cf22b01144428a015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Sat, 6 Jan 2024 23:26:14 +0100 Subject: [PATCH] fix: replace Buffer with base-64 --- package.json | 2 ++ src/index.ts | 5 +++-- yarn.lock | 10 ++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e1fbc10..476e3eb 100644 --- a/package.json +++ b/package.json @@ -33,12 +33,14 @@ }, "dependencies": { "axios": "^1.3.5", + "base-64": "^1.0.0", "jsonapi-fractal": "^2.3.1" }, "optionalDependencies": { "openid-client": "^5.4.0" }, "devDependencies": { + "@types/base-64": "^1.0.2", "@types/jest": "^29.5.1", "@types/node": "^20.10.6", "eslint": "^8.38.0", diff --git a/src/index.ts b/src/index.ts index d682257..f190268 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,6 +3,7 @@ import axios from 'axios' import type { Client, IdTokenClaims, TokenSetParameters } from 'openid-client' import type { DocumentObject } from 'jsonapi-fractal' import { deserialize, serialize } from 'jsonapi-fractal' +import { decode as atob } from 'base-64' import type { Stream } from 'node:stream' import type { AppCurrentConfig, BaseObject, User } from './models/Common' @@ -20,8 +21,8 @@ import { SkolengoError } from './models/Errors' import type { SkolengoConfig } from './models/Common/SkolengoConfig' const BASE_URL = 'https://api.skolengo.com/api/v1/bff-sko-app' -const OID_CLIENT_ID = Buffer.from('U2tvQXBwLlByb2QuMGQzNDkyMTctOWE0ZS00MWVjLTlhZjktZGY5ZTY5ZTA5NDk0', 'base64').toString('ascii') // base64 du client ID de l'app mobile -const OID_CLIENT_SECRET = Buffer.from('N2NiNGQ5YTgtMjU4MC00MDQxLTlhZTgtZDU4MDM4NjkxODNm', 'base64').toString('ascii') // base64 du client Secret de l'app mobile +const OID_CLIENT_ID = atob('U2tvQXBwLlByb2QuMGQzNDkyMTctOWE0ZS00MWVjLTlhZjktZGY5ZTY5ZTA5NDk0') // base64 du client ID de l'app mobile +const OID_CLIENT_SECRET = atob('N2NiNGQ5YTgtMjU4MC00MDQxLTlhZTgtZDU4MDM4NjkxODNm') // base64 du client Secret de l'app mobile export class Skolengo { public readonly school: School diff --git a/yarn.lock b/yarn.lock index be4bf7f..69d6eda 100644 --- a/yarn.lock +++ b/yarn.lock @@ -673,6 +673,11 @@ dependencies: "@babel/types" "^7.20.7" +"@types/base-64@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@types/base-64/-/base-64-1.0.2.tgz#f7bc80d242306f20c57f076d79d1efe2d31032ca" + integrity sha512-uPgKMmM9fmn7I+Zi6YBqctOye4SlJsHKcisjHIMWpb2YKZRc36GpKyNuQ03JcT+oNXg1m7Uv4wU94EVltn8/cw== + "@types/graceful-fs@^4.1.3": version "4.1.9" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.9.tgz#2a06bc0f68a20ab37b3e36aa238be6abdf49e8b4" @@ -1135,6 +1140,11 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== +base-64@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/base-64/-/base-64-1.0.0.tgz#09d0f2084e32a3fd08c2475b973788eee6ae8f4a" + integrity sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg== + bluebird@^3.7.2: version "3.7.2" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"