@canicula/sirius-oidc-server 0.1.1 → 0.1.2

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 (2) hide show
  1. package/dist/index.js +6 -8
  2. package/package.json +6 -2
package/dist/index.js CHANGED
@@ -45,9 +45,7 @@ async function secretKey(secret) {
45
45
  );
46
46
  }
47
47
  async function encryptJson(secret, payload) {
48
- return new CompactEncrypt(
49
- new TextEncoder().encode(JSON.stringify(payload))
50
- ).setProtectedHeader({ alg: "dir", enc: "A256GCM" }).encrypt(await secretKey(secret));
48
+ return new CompactEncrypt(new TextEncoder().encode(JSON.stringify(payload))).setProtectedHeader({ alg: "dir", enc: "A256GCM" }).encrypt(await secretKey(secret));
51
49
  }
52
50
  async function decryptJson(secret, token) {
53
51
  try {
@@ -146,7 +144,10 @@ function createSiriusAuth(options) {
146
144
  );
147
145
  }
148
146
  const cookies = parseCookieHeader(request.headers.get("cookie"));
149
- const pkce = cookies[PKCE_COOKIE] ? await decryptJson(options.cookieSecret, cookies[PKCE_COOKIE]) : null;
147
+ const pkce = cookies[PKCE_COOKIE] ? await decryptJson(
148
+ options.cookieSecret,
149
+ cookies[PKCE_COOKIE]
150
+ ) : null;
150
151
  if (!pkce) {
151
152
  return redirect(
152
153
  homeUrl(request, postLoginPath, "PKCE cookie missing or invalid"),
@@ -203,10 +204,7 @@ function createSiriusAuth(options) {
203
204
  const cookies = parseCookieHeader(cookieHeader);
204
205
  const raw = cookies[sessionCookie];
205
206
  if (!raw) return null;
206
- const session = await decryptJson(
207
- options.cookieSecret,
208
- raw
209
- );
207
+ const session = await decryptJson(options.cookieSecret, raw);
210
208
  if (!session || session.expiresAt <= Date.now()) return null;
211
209
  if (includeTokens) return session;
212
210
  return { user: session.user, expiresAt: session.expiresAt };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canicula/sirius-oidc-server",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Client OpenID Connect Sirius pour le backend d’un outil interne.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -13,12 +13,16 @@
13
13
  },
14
14
  "./package.json": "./package.json"
15
15
  },
16
- "files": ["dist"],
16
+ "files": [
17
+ "dist"
18
+ ],
17
19
  "publishConfig": {
18
20
  "access": "public"
19
21
  },
20
22
  "scripts": {
21
23
  "build": "tsup src/index.ts --format esm --dts --clean",
24
+ "check-types": "tsc --noEmit",
25
+ "lint": "eslint .",
22
26
  "prepare": "npm run build"
23
27
  },
24
28
  "dependencies": {