@cocreate/authorize 1.7.0 → 1.7.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/CHANGELOG.md +14 -0
- package/package.json +3 -3
- package/src/index.js +22 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.7.2](https://github.com/CoCreate-app/CoCreate-authorize/compare/v1.7.1...v1.7.2) (2023-10-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* bump cocreate dependency versions ([95fcac0](https://github.com/CoCreate-app/CoCreate-authorize/commit/95fcac06abbf1b5287e71290987523a7abd6316c))
|
|
7
|
+
|
|
8
|
+
## [1.7.1](https://github.com/CoCreate-app/CoCreate-authorize/compare/v1.7.0...v1.7.1) (2023-10-09)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* getAuthorization returns authorization object or promise, resulting in the key only being read once ([7b490a5](https://github.com/CoCreate-app/CoCreate-authorize/commit/7b490a515e46704d20f325ada839d3dfd1cc2099))
|
|
14
|
+
|
|
1
15
|
# [1.7.0](https://github.com/CoCreate-app/CoCreate-authorize/compare/v1.6.6...v1.7.0) (2023-09-19)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/authorize",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
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.28.0",
|
|
49
|
+
"@cocreate/utils": "^1.25.0"
|
|
50
50
|
}
|
|
51
51
|
}
|
package/src/index.js
CHANGED
|
@@ -63,12 +63,28 @@
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
async function getAuthorization(key, organization_id) {
|
|
66
|
-
if
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
// Check if there is a value orpending promise for this key
|
|
67
|
+
if (authorizations.has(key)) {
|
|
68
|
+
// Return the value or pending promise
|
|
69
|
+
return authorizations.get(key);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Create a new promise and store it
|
|
73
|
+
const authorizationPromise = readAuthorization(key, organization_id);
|
|
74
|
+
authorizations.set(key, authorizationPromise);
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
// Wait for the authorization to be resolved
|
|
78
|
+
const authorization = await authorizationPromise;
|
|
79
|
+
|
|
80
|
+
// Once resolved, store the resolved authorization in the map
|
|
81
|
+
authorizations.set(key, authorization);
|
|
82
|
+
|
|
83
|
+
return authorization;
|
|
84
|
+
} catch (error) {
|
|
85
|
+
// Handle errors if necessary
|
|
86
|
+
authorizations.delete(key);
|
|
87
|
+
throw error;
|
|
72
88
|
}
|
|
73
89
|
}
|
|
74
90
|
|