@nsshunt/stsdatamanagement 1.11.1 → 1.11.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/blcauth.js +10 -12
- package/package.json +1 -1
package/blcauth.js
CHANGED
|
@@ -25,7 +25,7 @@ class BLCAuth
|
|
|
25
25
|
try
|
|
26
26
|
{
|
|
27
27
|
let userid = BLCAuth.USER_ID_PREFIX + email;
|
|
28
|
-
if (this.#ResourceExists('User', userid)) {
|
|
28
|
+
if (await this.#ResourceExists('User', userid)) {
|
|
29
29
|
return {
|
|
30
30
|
status: status.conflict,
|
|
31
31
|
error: 'User already exists.',
|
|
@@ -67,7 +67,7 @@ class BLCAuth
|
|
|
67
67
|
{
|
|
68
68
|
const { name, permissions } = rolePermissions;
|
|
69
69
|
let roleId = BLCAuth.ROLE_ID_PREFIX + name;
|
|
70
|
-
if (this.#ResourceExists('Role', roleId)) {
|
|
70
|
+
if (await this.#ResourceExists('Role', roleId)) {
|
|
71
71
|
return {
|
|
72
72
|
status: status.conflict,
|
|
73
73
|
error: 'Role already exists.',
|
|
@@ -102,8 +102,7 @@ class BLCAuth
|
|
|
102
102
|
throw new STSResourceNotFoundError(resource, resourceId);
|
|
103
103
|
}
|
|
104
104
|
try {
|
|
105
|
-
|
|
106
|
-
return { status: status.success, detail: resource };
|
|
105
|
+
return JSON.parse(resourceRaw.detail.resdesc);
|
|
107
106
|
} catch (error) {
|
|
108
107
|
throw new STSResourceMalformedError(resource, resourceId, resourceRaw.detail.resdesc, error);
|
|
109
108
|
}
|
|
@@ -111,7 +110,7 @@ class BLCAuth
|
|
|
111
110
|
|
|
112
111
|
async #ResourceExists(resource, resourceId) {
|
|
113
112
|
try {
|
|
114
|
-
this.#GetResource(resource, resourceId);
|
|
113
|
+
await this.#GetResource(resource, resourceId);
|
|
115
114
|
return true;
|
|
116
115
|
} catch (error) {
|
|
117
116
|
if (error instanceof STSResourceNotFoundError) {
|
|
@@ -142,14 +141,12 @@ class BLCAuth
|
|
|
142
141
|
{
|
|
143
142
|
try
|
|
144
143
|
{
|
|
145
|
-
let
|
|
146
|
-
let userResource = userResourceRaw.detail;
|
|
144
|
+
let userResource = await this.GetUser(email);
|
|
147
145
|
let permissions = [ ];
|
|
148
146
|
|
|
149
147
|
for (let i=0; i < userResource.roles.length; i++) {
|
|
150
148
|
let role = userResource.roles[i];
|
|
151
|
-
let
|
|
152
|
-
let roleResource = roleResourceRaw.detail;
|
|
149
|
+
let roleResource = await this.GetRole(role);
|
|
153
150
|
for (let j=0; j < roleResource.permissions.length; j++) {
|
|
154
151
|
let permission = roleResource.permissions[j];
|
|
155
152
|
if (!permissions.includes(permission)) {
|
|
@@ -172,7 +169,7 @@ class BLCAuth
|
|
|
172
169
|
{
|
|
173
170
|
const { clientId } = application;
|
|
174
171
|
let applicationId = BLCAuth.APPLICATION_ID_PREFIX + clientId;
|
|
175
|
-
if (this.#ResourceExists('Application', applicationId)) {
|
|
172
|
+
if (await this.#ResourceExists('Application', applicationId)) {
|
|
176
173
|
return {
|
|
177
174
|
status: status.conflict,
|
|
178
175
|
error: 'Application already exists.',
|
|
@@ -223,10 +220,11 @@ class BLCAuth
|
|
|
223
220
|
{
|
|
224
221
|
try
|
|
225
222
|
{
|
|
226
|
-
const { M2MApplications, apiPermissions, identifier, SPA } = api;
|
|
223
|
+
const { M2MApplications, permissions: apiPermissions, identifier, SPA } = api;
|
|
224
|
+
|
|
227
225
|
let APIidentifier = BLCAuth.API_ID_PREFIX + identifier;
|
|
228
226
|
|
|
229
|
-
if (this.#ResourceExists('API', APIidentifier)) {
|
|
227
|
+
if (await this.#ResourceExists('API', APIidentifier)) {
|
|
230
228
|
return {
|
|
231
229
|
status: status.conflict,
|
|
232
230
|
error: 'API already exists.',
|