@mindline/sync 1.0.52 → 1.0.54

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.
@@ -2,6 +2,6 @@
2
2
  "ExpandedNodes": [
3
3
  ""
4
4
  ],
5
- "SelectedNode": "\\package.json",
5
+ "SelectedNode": "\\index.ts",
6
6
  "PreviewInSolutionExplorer": false
7
7
  }
package/.vs/slnx.sqlite CHANGED
Binary file
Binary file
package/index.d.ts CHANGED
@@ -3,6 +3,14 @@ declare module "@mindline/sync" {
3
3
  export function sum(a: number, b: number): number;
4
4
  export function helloNpm(): string;
5
5
 
6
+ export class APIResult {
7
+ result: boolean;
8
+ status: number;
9
+ error: string;
10
+ version: string;
11
+ array: Array<Object> | null;
12
+ constructor();
13
+ }
6
14
  export class graphConfig {
7
15
  static environmentTag: string;
8
16
  // config API endpoints
@@ -134,6 +142,7 @@ declare module "@mindline/sync" {
134
142
  constructor();
135
143
  }
136
144
  export class InitInfo {
145
+ version: string;
137
146
  tab: number;
138
147
  us: User[];
139
148
  ts: Tenant[];
@@ -250,13 +259,6 @@ declare module "@mindline/sync" {
250
259
  constructor(tid: string, name: string);
251
260
  update(total: number, read: number, written: number, deferred: number): void;
252
261
  }
253
- export class APIResult {
254
- result: boolean;
255
- status: number;
256
- error: string;
257
- array: Array<Object> | null;
258
- constructor();
259
- }
260
262
  //
261
263
  // Azure AD Graph API
262
264
  //
package/index.ts CHANGED
@@ -20,6 +20,14 @@ export function helloNpm(): string {
20
20
  return "hello NPM";
21
21
  }
22
22
  // main application exports
23
+ export class APIResult {
24
+ result: boolean;
25
+ status: number;
26
+ error: string;
27
+ version: string;
28
+ array: Array<Object> | null;
29
+ constructor() { this.result = true; this.status = 200; this.error = ""; this.version = version; this.array = null; }
30
+ }
23
31
  export class graphConfig {
24
32
  static environmentTag: string = "dev";
25
33
  // config API endpoints
@@ -262,6 +270,7 @@ function storageAvailable(type) {
262
270
  }
263
271
  }
264
272
  export class InitInfo {
273
+ version: string;
265
274
  tab: number;
266
275
  us: User[];
267
276
  ts: Tenant[];
@@ -297,6 +306,7 @@ export class InitInfo {
297
306
  var workspacesString = JSON.stringify(workspaces);
298
307
  try {
299
308
  this.tab = 0;
309
+ this.version = version;
300
310
  this.us = deserializeArray(User, usersString);
301
311
  this.ts = deserializeArray(Tenant, tenantsString);
302
312
  this.cs = deserializeArray(Config, configsString);
@@ -1189,13 +1199,6 @@ export class TenantNode {
1189
1199
  }
1190
1200
  }
1191
1201
  }
1192
- export class APIResult {
1193
- result: boolean;
1194
- status: number;
1195
- error: string;
1196
- array: Array<Object> | null;
1197
- constructor() { this.result = true; this.status = 200; this.error = ""; this.array = null; }
1198
- }
1199
1202
  //
1200
1203
  // Azure AD Graph API
1201
1204
  //
@@ -1223,19 +1226,43 @@ export async function groupsGet(instance: IPublicClientApplication, user: User |
1223
1226
  return { groups: [], error: `Exception: ${error}` };
1224
1227
  }
1225
1228
  }
1226
- export function signIn(user: User, tasks: TaskArray): void {
1227
- // SignIn by an admin consents the full set of permissions, unlike Challenge which requires a consented app
1228
- let tenantURL: string = window.location.href;
1229
- tenantURL += "MicrosoftIdentity/Account/SignIn";
1230
- let url: URL = new URL(tenantURL);
1231
- url.searchParams.append("redirectUri", window.location.origin);
1232
- url.searchParams.append("domainHint", "organizations");
1233
- if (user.oid !== "1") {
1234
- url.searchParams.append("loginHint", user.mail);
1229
+ export async function signIn(user: User, tasks: TaskArray): void {
1230
+ switch (user.authority) {
1231
+ case graphConfig.authorityWW:
1232
+ case "":
1233
+ // SignIn by an admin consents more permissions than Challenge which requires a consented app
1234
+ let tenantURL: string = window.location.href;
1235
+ tenantURL += "MicrosoftIdentity/Account/SignIn";
1236
+ let url: URL = new URL(tenantURL);
1237
+ url.searchParams.append("redirectUri", window.location.origin);
1238
+ url.searchParams.append("domainHint", "organizations");
1239
+ if (user.oid !== "1") {
1240
+ url.searchParams.append("loginHint", user.mail);
1241
+ }
1242
+ tasks.setTaskStart("initialization", new Date());
1243
+ tasks.setTaskStart("authenticate user", new Date());
1244
+ window.location.assign(url.href);
1245
+ break;
1246
+ case graphConfig.authorityUS:
1247
+ // retrieve controller protected by USGov authorization
1248
+ let usURL: string = window.location.href;
1249
+ usURL += "USGov";
1250
+ let urlUS: URL = new URL(usURL);
1251
+ urlUS.searchParams.append("redirectUri", window.location.origin);
1252
+ urlUS.searchParams.append("domainHint", user.companyDomain);
1253
+ if (user.oid !== "1") {
1254
+ urlUS.searchParams.append("loginHint", user.mail);
1255
+ }
1256
+ tasks.setTaskStart("initialization", new Date());
1257
+ tasks.setTaskStart("authenticate user", new Date());
1258
+ window.location.assign(urlUS.href);
1259
+ break;
1260
+ case graphConfig.authorityCN:
1261
+ // unsupported
1262
+ break;
1263
+ default:
1264
+ debugger;
1235
1265
  }
1236
- tasks.setTaskStart("initialization", new Date());
1237
- tasks.setTaskStart("authenticate user", new Date());
1238
- window.location.assign(url.href);
1239
1266
  }
1240
1267
  export function signInIncrementally(user: User, scope: string): void {
1241
1268
  if (user.oid == "1") return;
@@ -1273,7 +1300,8 @@ export function requestAdminConsent(user: User, scope: string): void {
1273
1300
  adminConsentURL += "/adminconsent";
1274
1301
  let url: URL = new URL(adminConsentURL);
1275
1302
  url.searchParams.append("client_id", "63100afe-506e-4bb2-8ff7-d8d5ab373129");
1276
- url.searchParams.append("redirectUri", window.location.origin);
1303
+ url.searchParams.append("redirect_uri", window.location.origin);
1304
+ url.searchParams.append("domain_hint", user.companyDomain);
1277
1305
  window.location.assign(url.href);
1278
1306
  }
1279
1307
  export async function signOut(user: User): Promise<boolean>{
@@ -1428,8 +1456,9 @@ export async function tenantRelationshipsGetById(user: User, ii: InitInfo, insta
1428
1456
  //tenantUnauthenticatedLookup (from https://gettenantpartitionweb.azurewebsites.net/js/gettenantpartition.js)
1429
1457
  export async function tenantUnauthenticatedLookup(tenant: Tenant, debug: boolean): Promise<boolean> {
1430
1458
  if (debug) debugger;
1459
+ // since we should mainly be called when a user is performing a lookup, we can afford the performance hit of looking up the tenant name and domain again
1431
1460
  // do we already have a valid tenant ID? if so, nothing to add
1432
- if (tenant.tid !== "") return false;
1461
+ //if (tenant.tid !== "") return false;
1433
1462
  // do we not have a valid domain? if so, nothing to lookup
1434
1463
  if (tenant.domain == "") return false;
1435
1464
  // prepare the 3 endpoints and corresponding regular expressions
@@ -1572,14 +1601,7 @@ export async function initGet(instance: IPublicClientApplication, authorizedUser
1572
1601
  result = await workspaceInfoGet(instance, authorizedUser, user, ii, debug);
1573
1602
  tasks.setTaskEnd("GET workspaces", new Date(), result.result ? "complete" : "failed");
1574
1603
  }
1575
- // if successful, return true result and the version in the result.error field
1576
- if (result.result) {
1577
- result.error = version;
1578
- }
1579
- // if failed, output version information to the log
1580
- else {
1581
- console.log("@mindline/sync package version: " + version);
1582
- }
1604
+ console.log("initGet complete. Version: " + version);
1583
1605
  return result;
1584
1606
  }
1585
1607
  else {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mindline/sync",
3
3
  "type": "module",
4
- "version": "1.0.52",
4
+ "version": "1.0.54",
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.",