@cocreate/authorize 1.10.0 → 1.12.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 +19 -0
- package/README.md +9 -1
- package/package.json +3 -3
- package/src/index.js +14 -36
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [1.12.0](https://github.com/CoCreate-app/CoCreate-authorize/compare/v1.11.0...v1.12.0) (2023-12-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* use dotNotation for merging keys ([ac1177a](https://github.com/CoCreate-app/CoCreate-authorize/commit/ac1177a7445060ab679a3922bbfe544c11d807dc))
|
|
7
|
+
|
|
8
|
+
# [1.11.0](https://github.com/CoCreate-app/CoCreate-authorize/compare/v1.10.0...v1.11.0) (2023-11-25)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* update licensing details ([df383e4](https://github.com/CoCreate-app/CoCreate-authorize/commit/df383e451fdab62b3fbbe45a5376096e4e7a76e1))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* upgrade dependencies for latest features and fixes ([6812dcc](https://github.com/CoCreate-app/CoCreate-authorize/commit/6812dcc18d049986bd80b818d8ccb9ff00926733))
|
|
19
|
+
|
|
1
20
|
# [1.10.0](https://github.com/CoCreate-app/CoCreate-authorize/compare/v1.9.0...v1.10.0) (2023-11-25)
|
|
2
21
|
|
|
3
22
|
|
package/README.md
CHANGED
|
@@ -65,6 +65,14 @@ We want this library to be community-driven, and CoCreate led. We need your help
|
|
|
65
65
|
|
|
66
66
|
We appreciate your continued support, thank you!
|
|
67
67
|
|
|
68
|
+
<a name="license"></a>
|
|
69
|
+
|
|
68
70
|
# License
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
This software is dual-licensed under the GNU Affero General Public License version 3 (AGPLv3) and a commercial license.
|
|
73
|
+
|
|
74
|
+
- **Open Source Use**: For open-source projects and non-commercial use, this software is available under the AGPLv3. The AGPLv3 allows you to freely use, modify, and distribute this software, provided that all modifications and derivative works are also licensed under the AGPLv3. For the full license text, see the [LICENSE file](https://github.com/CoCreate-app/CoCreate-authorize/blob/master/LICENSE).
|
|
75
|
+
|
|
76
|
+
- **Commercial Use**: For-profit companies and individuals intending to use this software for commercial purposes must obtain a commercial license. The commercial license is available when you sign up for an API key on our [website](https://cocreate.app). This license permits proprietary use and modification of the software without the copyleft requirements of the AGPLv3. It is ideal for integrating this software into proprietary commercial products and applications.
|
|
77
|
+
|
|
78
|
+
If you have not purchased a commercial license and intend to use this software for commercial purposes, you are required to sign up for an API key on our website.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/authorize",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.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.
|
|
49
|
-
"@cocreate/utils": "^1.
|
|
48
|
+
"@cocreate/crud-client": "^1.31.0",
|
|
49
|
+
"@cocreate/utils": "^1.29.0"
|
|
50
50
|
}
|
|
51
51
|
}
|
package/src/index.js
CHANGED
|
@@ -109,7 +109,9 @@
|
|
|
109
109
|
let roles = await crud.send(request)
|
|
110
110
|
roles = roles.object
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
for (let role of roles) {
|
|
113
|
+
authorization = dotNotationToObject(authorization, role)
|
|
114
|
+
}
|
|
113
115
|
}
|
|
114
116
|
return authorization;
|
|
115
117
|
} else
|
|
@@ -121,41 +123,6 @@
|
|
|
121
123
|
|
|
122
124
|
}
|
|
123
125
|
|
|
124
|
-
async function createAuthorization(authorization, roles) {
|
|
125
|
-
roles.map(role => {
|
|
126
|
-
for (const roleKey in role) {
|
|
127
|
-
if (!["_id", "type", "name", "organization_id"].includes(roleKey)) {
|
|
128
|
-
if (!authorization[roleKey]) {
|
|
129
|
-
authorization[roleKey] = role[roleKey]
|
|
130
|
-
} else {
|
|
131
|
-
if (Array.isArray(role[roleKey])) {
|
|
132
|
-
for (let item of role[roleKey]) {
|
|
133
|
-
if (!authorization[roleKey].includes(item))
|
|
134
|
-
authorization[roleKey].push(item)
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
else if (typeof role[roleKey] == 'object') {
|
|
138
|
-
for (const c of Object.keys(role[roleKey])) {
|
|
139
|
-
if (!authorization[roleKey][c]) {
|
|
140
|
-
authorization[roleKey][c] = role[roleKey][c]
|
|
141
|
-
} else {
|
|
142
|
-
if (typeof role[roleKey][c] == 'object') {
|
|
143
|
-
authorization[roleKey][c] = { ...authorization[roleKey][c], ...role[roleKey][c] }
|
|
144
|
-
} else {
|
|
145
|
-
authorization[roleKey][c] = role[roleKey][c]
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
} else {
|
|
150
|
-
authorization[roleKey] = role[roleKey]
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
})
|
|
156
|
-
return authorization;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
126
|
async function check(data, user_id) {
|
|
160
127
|
let authorization = false
|
|
161
128
|
if (user_id) {
|
|
@@ -277,6 +244,17 @@
|
|
|
277
244
|
data.$filter.query.push(query)
|
|
278
245
|
|
|
279
246
|
} else {
|
|
247
|
+
if (key === '$array' && value === 'questions') {
|
|
248
|
+
if (typeof data.array === 'string') {
|
|
249
|
+
if (typeof value === 'string') {
|
|
250
|
+
return data.array === value
|
|
251
|
+
} else if (Array.isArray(value)) {
|
|
252
|
+
return value.includes(data.array)
|
|
253
|
+
}
|
|
254
|
+
} else if (Array.isArray(data.array)) {
|
|
255
|
+
|
|
256
|
+
}
|
|
257
|
+
}
|
|
280
258
|
// TODO: sanitize data by removing items user does not have access to.
|
|
281
259
|
// console.log('key is a query operator', key)
|
|
282
260
|
}
|