@mindline/sync 1.0.42 → 1.0.44
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/.vs/VSWorkspaceState.json +0 -1
- package/.vs/slnx.sqlite +0 -0
- package/.vs/sync/FileContentIndex/6e2eb4de-f03f-41c0-9850-bdcbce22ae29.vsidx +0 -0
- package/.vs/sync/v17/.wsuo +0 -0
- package/index.d.ts +8 -2
- package/index.ts +20 -8
- package/package.json +1 -1
- package/.vs/sync/FileContentIndex/9f8422ce-7c66-4297-9964-e1ce6180fd31.vsidx +0 -0
package/.vs/slnx.sqlite
CHANGED
|
Binary file
|
package/.vs/sync/v17/.wsuo
CHANGED
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IPublicClientApplication } from "@azure/msal-browser";
|
|
2
|
-
|
|
3
2
|
declare module "@mindline/sync" {
|
|
4
3
|
export function sum(a: number, b: number): number;
|
|
5
4
|
export function helloNpm(): string;
|
|
@@ -10,6 +9,14 @@ declare module "@mindline/sync" {
|
|
|
10
9
|
description: string;
|
|
11
10
|
}
|
|
12
11
|
// admin
|
|
12
|
+
export class UserScope {
|
|
13
|
+
group: string;
|
|
14
|
+
value: string;
|
|
15
|
+
consented: boolean;
|
|
16
|
+
expanded: string;
|
|
17
|
+
static compareByValue(a: UserScope, b: UserScope): number;
|
|
18
|
+
static compareByGroup(a: UserScope, b: UserScope): number;
|
|
19
|
+
}
|
|
13
20
|
export class User {
|
|
14
21
|
oid: string; // from AAD ID token
|
|
15
22
|
name: string; // from AAD ID token
|
|
@@ -26,7 +33,6 @@ declare module "@mindline/sync" {
|
|
|
26
33
|
loginHint: string;
|
|
27
34
|
scopes: string[];
|
|
28
35
|
authTS: Date;
|
|
29
|
-
claimsprincipal: string; // claims principal cached at login to allow clearing cache at logout
|
|
30
36
|
constructor();
|
|
31
37
|
}
|
|
32
38
|
// tenant (Azure AD tenant, AD domain, Google workspace)
|
package/index.ts
CHANGED
|
@@ -24,6 +24,18 @@ export class Group {
|
|
|
24
24
|
displayName: string;
|
|
25
25
|
description: string;
|
|
26
26
|
}
|
|
27
|
+
export class UserScope {
|
|
28
|
+
group: string;
|
|
29
|
+
value: string;
|
|
30
|
+
consented: boolean;
|
|
31
|
+
expanded: string;
|
|
32
|
+
static compareByValue(a: UserScope, b: UserScope): number {
|
|
33
|
+
return a.value.localeCompare(b.value);
|
|
34
|
+
}
|
|
35
|
+
static compareByGroup(a: UserScope, b: UserScope): number {
|
|
36
|
+
return a.group.localeCompare(b.group);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
27
39
|
export class User {
|
|
28
40
|
oid: string;
|
|
29
41
|
name: string;
|
|
@@ -300,6 +312,7 @@ export class InitInfo {
|
|
|
300
312
|
export type TaskType = "initialization" |
|
|
301
313
|
"authenticate user" |
|
|
302
314
|
"reload React" |
|
|
315
|
+
"PUT tenant" |
|
|
303
316
|
"GET tenant details" |
|
|
304
317
|
"POST config init" |
|
|
305
318
|
"GET workspaces" |
|
|
@@ -1093,8 +1106,7 @@ export function signInIncrementally(user: User, scope: string): void {
|
|
|
1093
1106
|
tenantURL += "MicrosoftIdentity/Account/Challenge";
|
|
1094
1107
|
let url: URL = new URL(tenantURL);
|
|
1095
1108
|
url.searchParams.append("redirectUri", window.location.origin);
|
|
1096
|
-
|
|
1097
|
-
url.searchParams.append("scope", scopes);
|
|
1109
|
+
url.searchParams.append("scope", scope);
|
|
1098
1110
|
url.searchParams.append("domainHint", "organizations");
|
|
1099
1111
|
url.searchParams.append("loginHint", user.mail);
|
|
1100
1112
|
window.location.assign(url.href);
|
|
@@ -1187,8 +1199,8 @@ export async function tenantRelationshipsGetByDomain(loggedInUser: User, tenant:
|
|
|
1187
1199
|
//tenantRelationshipsGetById - query AAD for associated company name and domain
|
|
1188
1200
|
export async function tenantRelationshipsGetById(user: User, ii: InitInfo, instance: IPublicClientApplication, tasks: TaskArray, debug: boolean): Promise<boolean> {
|
|
1189
1201
|
if (debug) debugger;
|
|
1190
|
-
//
|
|
1191
|
-
if (user.companyName != "") return false;
|
|
1202
|
+
// since we should mainly be called when a user has newly logged in, we can afford the performance hit of looking up the tenant name and domain again
|
|
1203
|
+
// if (user.companyName != "") return false;
|
|
1192
1204
|
// if needed, retrieve and cache access token
|
|
1193
1205
|
if (user.accessToken === "") {
|
|
1194
1206
|
try {
|
|
@@ -1276,7 +1288,7 @@ export async function tenantUnauthenticatedLookup(tenant: Tenant, debug: boolean
|
|
|
1276
1288
|
var authMatches = tenantAuthEndpoint.match(regexes[j]);
|
|
1277
1289
|
tenant.tid = authMatches[2];
|
|
1278
1290
|
tenant.authority = authMatches[1]; // USGov tenants are registered in WW with USGov authority values!
|
|
1279
|
-
console.log(
|
|
1291
|
+
console.log(`Successful GET from openid well-known endpoint: tid: ${tenant.tid} authority: ${tenant.authority}`);
|
|
1280
1292
|
return true; // success, need UX to re-render
|
|
1281
1293
|
}
|
|
1282
1294
|
else {
|
|
@@ -1376,12 +1388,12 @@ export async function initGet(instance: IPublicClientApplication, authorizedUser
|
|
|
1376
1388
|
tenant.domain = user.tid;
|
|
1377
1389
|
let bResult: boolean = await tenantUnauthenticatedLookup(tenant, debug);
|
|
1378
1390
|
if (bResult) {
|
|
1379
|
-
// success, we
|
|
1391
|
+
// success, we now know instance of this tenant
|
|
1380
1392
|
user.authority = tenant.authority;
|
|
1381
1393
|
// do we have a logged in user from the same authority as this newly proposed tenant?
|
|
1382
1394
|
let loggedInUser: User | undefined = ii.us.find((u: User) => (u.session === "Sign Out" && u.authority === user.authority));
|
|
1383
1395
|
if (loggedInUser != null) {
|
|
1384
|
-
// get tenant name and domain from AAD
|
|
1396
|
+
// get tenant name and domain from AAD to pass to Configuration API
|
|
1385
1397
|
result.result = await tenantRelationshipsGetById(user, ii, instance, tasks, debug);
|
|
1386
1398
|
// if this is the first time, we have just gotten tenant info, then we must POST user and not-yet-onboarded tenant to back end
|
|
1387
1399
|
if (result.result) {
|
|
@@ -1400,7 +1412,7 @@ export async function initGet(instance: IPublicClientApplication, authorizedUser
|
|
|
1400
1412
|
return result;
|
|
1401
1413
|
}
|
|
1402
1414
|
else {
|
|
1403
|
-
result.error = `${user.mail} insufficient privileges to lookup under authority: ${user.authority}.`;
|
|
1415
|
+
result.error = `${user.mail} with insufficient privileges to lookup under authority: ${user.authority}.`;
|
|
1404
1416
|
result.result = false;
|
|
1405
1417
|
return result;
|
|
1406
1418
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindline/sync",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.44",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"exports": "./index.ts",
|
|
7
7
|
"description": "sync is a node.js package encapsulating javscript classes required for configuring Mindline sync service.",
|
|
Binary file
|