@cellaware/utils 4.0.0 → 4.0.1
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/dist/chatwms/user.d.ts +4 -10
- package/dist/chatwms/user.js +15 -18
- package/package.json +1 -1
package/dist/chatwms/user.d.ts
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* https://learn.microsoft.com/en-us/entra/identity-platform/id-token-claims-reference
|
|
3
|
-
*/
|
|
4
|
-
export interface ChatWMSUserClaim {
|
|
5
|
-
typ: string;
|
|
6
|
-
val: string;
|
|
7
|
-
}
|
|
8
1
|
export interface ChatWMSUserData {
|
|
9
2
|
userId: string;
|
|
10
3
|
userDetails: string;
|
|
11
4
|
identityProvider: string;
|
|
12
|
-
claims?: ChatWMSUserClaim[];
|
|
13
5
|
}
|
|
14
6
|
export declare function chatwmsInitUserData(): ChatWMSUserData;
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
/**
|
|
8
|
+
* https://learn.microsoft.com/en-us/azure/static-web-apps/user-information
|
|
9
|
+
*/
|
|
10
|
+
export declare function chatwmsDecodePrincipal(principal: string): ChatWMSUserData | undefined;
|
package/dist/chatwms/user.js
CHANGED
|
@@ -2,27 +2,24 @@ export function chatwmsInitUserData() {
|
|
|
2
2
|
return {
|
|
3
3
|
userId: '',
|
|
4
4
|
userDetails: '',
|
|
5
|
-
identityProvider: ''
|
|
6
|
-
claims: [],
|
|
5
|
+
identityProvider: ''
|
|
7
6
|
};
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
/**
|
|
9
|
+
* https://learn.microsoft.com/en-us/azure/static-web-apps/user-information
|
|
10
|
+
*/
|
|
11
|
+
export function chatwmsDecodePrincipal(principal) {
|
|
12
|
+
if (principal !== '') {
|
|
13
|
+
try {
|
|
14
|
+
const decodedPrincipal = Buffer.from(principal, 'base64').toString('utf8');
|
|
15
|
+
const decodedPrincipalObj = JSON.parse(decodedPrincipal);
|
|
16
|
+
return decodedPrincipalObj;
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
export function chatwmsGetTenantIdClaim(claims) {
|
|
20
|
-
let tenantId = undefined;
|
|
21
|
-
for (const claim of claims ?? []) {
|
|
22
|
-
if (claim.typ === 'tid' || claim.typ.endsWith('/tenantid')) {
|
|
23
|
-
tenantId = claim.val;
|
|
24
|
-
break;
|
|
18
|
+
catch (err) {
|
|
19
|
+
return undefined;
|
|
25
20
|
}
|
|
26
21
|
}
|
|
27
|
-
|
|
22
|
+
else {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
28
25
|
}
|