@terrafirmagreg-team/auth 1.2.1 → 1.2.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terrafirmagreg-team/auth",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "type": "module",
5
5
  "description": "GitHub OAuth sign-in and cookie sessions",
6
6
  "license": "LGPL-3.0-only",
@@ -15,7 +15,7 @@
15
15
  "src"
16
16
  ],
17
17
  "dependencies": {
18
- "@terrafirmagreg-team/data": "1.2.1",
18
+ "@terrafirmagreg-team/data": "^1.2.4",
19
19
  "arctic": "^3.7.0"
20
20
  },
21
21
  "devDependencies": {
package/src/lib/config.ts CHANGED
@@ -4,14 +4,21 @@ export type AuthMode = 'dev' | 'github';
4
4
  export const authCookie = 'fcgd_token';
5
5
  export const devAuthCookie = 'fc_dev_user';
6
6
 
7
+ export function commentsMode(): 'dev' | 'prod' | 'off' {
8
+ const mode = env('COMMENTS_MODE') ?? env('COMMENTS_AUTH');
9
+ if (mode === 'dev') return 'dev';
10
+ if (mode === 'prod' || mode === 'github') return 'prod';
11
+ return 'off';
12
+ }
13
+
7
14
  export function authMode(): AuthMode {
8
- const mode = env('COMMENTS_AUTH');
9
- if (mode) return mode === 'dev' ? 'dev' : 'github';
10
- return process.env.NODE_ENV === 'development' ? 'dev' : 'github';
15
+ return commentsMode() === 'dev' ? 'dev' : 'github';
11
16
  }
12
17
 
13
18
  export function authEnabled() {
14
- if (authMode() === 'dev') return true;
19
+ const mode = commentsMode();
20
+ if (mode === 'off') return false;
21
+ if (mode === 'dev') return true;
15
22
  return Boolean(env('DISCUSSIONS_SECRET') && env('APP_CLIENT_ID'));
16
23
  }
17
24
 
package/src/lib/index.ts CHANGED
@@ -2,6 +2,7 @@ export {
2
2
  authConfig,
3
3
  authEnabled,
4
4
  authMode,
5
+ commentsMode,
5
6
  authCookie,
6
7
  devAuthCookie,
7
8
  type AuthConfig,