@carisls/sso-standard 1.0.1 → 1.0.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.
package/cjs/index.cjs CHANGED
@@ -32,11 +32,13 @@ const router = (options) => {
32
32
  if (!options)
33
33
  throw Error('You need to set options parameter');
34
34
 
35
- if (!options.ssoUrl && !options.providers)
36
- throw Error('ssoUrl is always required');
35
+ const providers = options.providers?.split ? options.providers.split(',').map(i => ({ ssoUrl: i })) : options.providers;
37
36
 
38
- if (!options.clientId && !options.providers)
39
- throw Error('clientId is required');
37
+ if (!options.providers)
38
+ throw Error('providers is always required');
39
+
40
+ if (!options.clientId || !options.clientSecret)
41
+ throw Error('clientId and clientSecret are required');
40
42
 
41
43
  if (!options.publicKeyCache)
42
44
  options.publicKeyCache = 300;
@@ -47,9 +49,6 @@ const router = (options) => {
47
49
  const router = Router();
48
50
 
49
51
  (async () => {
50
- const providers = options.providers || [];
51
- if (!providers.length && options.ssoUrl)
52
- providers.push({ iss: options.iss || options.ssoUrl, ssoUrl: options.ssoUrl, publicKey: options.publicKey });
53
52
  const issuerSelector = await issuerSelectorModule(providers, options.publicKeyCache);
54
53
  const encryptor = encryptorModule(options.encPassword, options.encPasswordSalt, options.encIterationCount);
55
54
 
package/esm/index.js CHANGED
@@ -33,11 +33,13 @@ const router = (options) => {
33
33
  if (!options)
34
34
  throw Error('You need to set options parameter');
35
35
 
36
- if (!options.ssoUrl && !options.providers)
37
- throw Error('ssoUrl is always required');
36
+ const providers = options.providers?.split ? options.providers.split(',').map(i => ({ ssoUrl: i })) : options.providers;
38
37
 
39
- if (!options.clientId && !options.providers)
40
- throw Error('clientId is required');
38
+ if (!options.providers)
39
+ throw Error('providers is always required');
40
+
41
+ if (!options.clientId || !options.clientSecret)
42
+ throw Error('clientId and clientSecret are required');
41
43
 
42
44
  if (!options.publicKeyCache)
43
45
  options.publicKeyCache = 300;
@@ -48,9 +50,6 @@ const router = (options) => {
48
50
  const router = Router();
49
51
 
50
52
  (async () => {
51
- const providers = options.providers || [];
52
- if (!providers.length && options.ssoUrl)
53
- providers.push({ iss: options.iss || options.ssoUrl, ssoUrl: options.ssoUrl, publicKey: options.publicKey });
54
53
  const issuerSelector = await issuerSelectorModule(providers, options.publicKeyCache);
55
54
  const encryptor = encryptorModule(options.encPassword, options.encPasswordSalt, options.encIterationCount);
56
55
 
package/package.json CHANGED
@@ -1,10 +1,16 @@
1
1
  {
2
2
  "name": "@carisls/sso-standard",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "A middleware implementing standard flow SSO",
5
5
  "main": "cjs/index.cjs",
6
6
  "module": "esm/index.js",
7
7
  "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "require": "./cjs/index.cjs",
11
+ "import": "./esm/index.js"
12
+ }
13
+ },
8
14
  "scripts": {
9
15
  "test": "npm run test:lint",
10
16
  "test:lint": "eslint '**/*.js' '**/*.cjs'",