@cocreate/authorize 1.12.0 → 1.13.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [1.13.0](https://github.com/CoCreate-app/CoCreate-authorize/compare/v1.12.0...v1.13.0) (2024-01-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * applied host to define environment/branch ([56ff08a](https://github.com/CoCreate-app/CoCreate-authorize/commit/56ff08a0929003b37658ab394c74bf1e429cecd5))
7
+
8
+
9
+ ### Features
10
+
11
+ * bumped CoCreate dependencies to their latest versions ([641c52b](https://github.com/CoCreate-app/CoCreate-authorize/commit/641c52b6af630d7164cc9e720d00e4e40d7e3d11))
12
+
1
13
  # [1.12.0](https://github.com/CoCreate-app/CoCreate-authorize/compare/v1.11.0...v1.12.0) (2023-12-21)
2
14
 
3
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/authorize",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "description": "A simple authorize component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "authorize",
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "main": "./src/index.js",
47
47
  "dependencies": {
48
- "@cocreate/crud-client": "^1.31.0",
49
- "@cocreate/utils": "^1.29.0"
48
+ "@cocreate/crud-client": "^1.32.2",
49
+ "@cocreate/utils": "^1.30.0"
50
50
  }
51
51
  }
package/src/index.js CHANGED
@@ -37,7 +37,7 @@
37
37
  if (array === 'keys' && object) {
38
38
  let authorization = object[0]
39
39
  if (authorization && authorization.key && organizations[organization_id] && organizations[organization_id][authorization.key]) {
40
- let newAuthorization = await readAuthorization(authorization.key, organization_id)
40
+ let newAuthorization = await readAuthorization(authorization.key, data)
41
41
  organizations[organization_id][authorization.key] = newAuthorization
42
42
  }
43
43
  }
@@ -54,24 +54,27 @@
54
54
  }
55
55
  }
56
56
 
57
- async function getAuthorization(key, organization_id) {
57
+ async function getAuthorization(key, data) {
58
+ let organization_id = data.organization_id
58
59
  if (!organizations[organization_id])
59
60
  organizations[organization_id] = {}
60
61
 
61
62
  if (!organizations[organization_id][key])
62
- organizations[organization_id][key] = readAuthorization(key, organization_id);
63
+ organizations[organization_id][key] = readAuthorization(key, data);
63
64
 
64
65
  organizations[organization_id][key] = await organizations[organization_id][key]
65
66
  return organizations[organization_id][key]
66
67
  }
67
68
 
68
- async function readAuthorization(key, organization_id) {
69
+ async function readAuthorization(key, data) {
69
70
  try {
71
+ let organization_id = data.organization_id
70
72
  if (!organization_id)
71
73
  return { error: 'An organization_id is required' };
72
74
 
73
75
  let request = {
74
76
  method: 'object.read',
77
+ host: data.host,
75
78
  database: organization_id,
76
79
  array: 'keys',
77
80
  organization_id,
@@ -146,7 +149,7 @@
146
149
  if (!data.method)
147
150
  return { error: 'method is required' };
148
151
 
149
- let authorized = await getAuthorization(key, data.organization_id)
152
+ let authorized = await getAuthorization(key, data)
150
153
  if (!authorized || authorized.error)
151
154
  return authorized
152
155
  if (authorized.organization_id !== data.organization_id)