@boxyhq/saml-jackson 0.2.0-beta.151 → 0.2.1-beta.155

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": "@boxyhq/saml-jackson",
3
- "version": "0.2.0-beta.151",
3
+ "version": "0.2.1-beta.155",
4
4
  "license": "Apache 2.0",
5
5
  "description": "SAML 2.0 service",
6
6
  "main": "src/index.js",
@@ -10,7 +10,7 @@ let configStore;
10
10
  const extractHostName = (url) => {
11
11
  try {
12
12
  const pUrl = new URL(url);
13
- if(pUrl.hostname.startsWith('www.')) {
13
+ if (pUrl.hostname.startsWith('www.')) {
14
14
  return pUrl.hostname.substring(4);
15
15
  }
16
16
  return pUrl.hostname;
@@ -56,7 +56,7 @@ const config = async (body) => {
56
56
  {
57
57
  idpMetadata,
58
58
  defaultRedirectUrl,
59
- redirectUrl: JSON.parse(redirectUrl),
59
+ redirectUrl: JSON.parse(redirectUrl), // redirectUrl is a stringified array
60
60
  tenant,
61
61
  product,
62
62
  clientID,
@@ -258,14 +258,16 @@ const token = async (body) => {
258
258
 
259
259
  if (client_id && client_secret) {
260
260
  // check if we have an encoded client_id
261
- const sp = getEncodedClientId(client_id);
262
- if (!sp) {
263
- // OAuth flow
264
- if (
265
- client_id !== codeVal.clientID ||
266
- client_secret !== codeVal.clientSecret
267
- ) {
268
- throw new JacksonError('Invalid client_id or client_secret', 401);
261
+ if (client_id !== 'dummy' && client_secret !== 'dummy') {
262
+ const sp = getEncodedClientId(client_id);
263
+ if (!sp) {
264
+ // OAuth flow
265
+ if (
266
+ client_id !== codeVal.clientID ||
267
+ client_secret !== codeVal.clientSecret
268
+ ) {
269
+ throw new JacksonError('Invalid client_id or client_secret', 401);
270
+ }
269
271
  }
270
272
  }
271
273
  } else if (code_verifier) {
package/src/db/db.js CHANGED
@@ -23,7 +23,13 @@ class DB {
23
23
  throw new Error('secondary indexes not allow on a store with ttl');
24
24
  }
25
25
 
26
- return await this.db.put(namespace, key, val, ttl, ...indexes);
26
+ return await this.db.put(
27
+ namespace,
28
+ key,
29
+ JSON.stringify(val),
30
+ ttl,
31
+ ...indexes
32
+ );
27
33
  }
28
34
 
29
35
  async delete(namespace, key) {
package/src/db/mem.js CHANGED
@@ -54,7 +54,7 @@ class Mem {
54
54
  async put(namespace, key, val, ttl = 0, ...indexes) {
55
55
  const k = dbutils.key(namespace, key);
56
56
 
57
- this.store[k] = JSON.stringify(val);
57
+ this.store[k] = val;
58
58
 
59
59
  if (ttl) {
60
60
  this.ttlStore[k] = {
package/src/db/mongo.js CHANGED
@@ -48,7 +48,7 @@ class Mongo {
48
48
 
49
49
  async put(namespace, key, val, ttl = 0, ...indexes) {
50
50
  const doc = {
51
- value: JSON.stringify(val),
51
+ value: val,
52
52
  };
53
53
 
54
54
  if (ttl) {
package/src/db/redis.js CHANGED
@@ -46,7 +46,7 @@ class Redis {
46
46
  let tx = this.client.multi();
47
47
  const k = dbutils.key(namespace, key);
48
48
 
49
- tx = tx.set(k, JSON.stringify(val));
49
+ tx = tx.set(k, val);
50
50
 
51
51
  if (ttl) {
52
52
  tx = tx.expire(k, ttl);
package/src/db/sql/sql.js CHANGED
@@ -1,3 +1,5 @@
1
+ /*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
2
+
1
3
  require('reflect-metadata');
2
4
  const typeorm = require('typeorm');
3
5
  const JacksonStore = require('./model/JacksonStore.js');
@@ -79,7 +81,7 @@ class Sql {
79
81
  key: dbutils.key(namespace, key),
80
82
  });
81
83
 
82
- if (res) {
84
+ if (res && res.value) {
83
85
  return JSON.parse(res.value);
84
86
  }
85
87
 
@@ -99,17 +101,13 @@ class Sql {
99
101
  });
100
102
  }
101
103
 
102
- if (res && res.store) {
103
- return JSON.parse(res.store.value);
104
- }
105
-
106
104
  return ret;
107
105
  }
108
106
 
109
107
  async put(namespace, key, val, ttl = 0, ...indexes) {
110
108
  await this.connection.transaction(async (transactionalEntityManager) => {
111
109
  const dbKey = dbutils.key(namespace, key);
112
- const store = new JacksonStore(dbKey, JSON.stringify(val));
110
+ const store = new JacksonStore(dbKey, val);
113
111
  await transactionalEntityManager.save(store);
114
112
 
115
113
  if (ttl) {