@blazeo.com/calendar-client 1.0.28 → 1.0.29

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/index.d.ts CHANGED
@@ -318,6 +318,20 @@ export type ParticipantAuthorizationStatus = {
318
318
  providers: CalendarProviderAuthorizationState[];
319
319
  };
320
320
 
321
+ export type ParticipantData = {
322
+ id?: number | null;
323
+ participantId: string;
324
+ companyKey?: string | null;
325
+ alias?: string;
326
+ email?: string;
327
+ isApproved: boolean;
328
+ isAvailable: boolean;
329
+ provider: number;
330
+ createdOn?: string | null;
331
+ modifiedOn?: string | null;
332
+ isDeleted?: boolean;
333
+ };
334
+
321
335
  export const CALENDAR_AUTH_MESSAGE_TYPE: 'calendar-authorization';
322
336
 
323
337
  export const CalendarEmailProvider: {
@@ -348,6 +362,11 @@ export const AuthModel: {
348
362
  data?: ParticipantAuthorizationStatus;
349
363
  message?: string;
350
364
  }>;
365
+ IsAuthorized(participantId: string): Promise<{
366
+ status: string;
367
+ data?: ParticipantData;
368
+ message?: string;
369
+ }>;
351
370
  openOAuthPopup(
352
371
  authorizationUrl: string,
353
372
  opts?: { width?: number; height?: number }
package/dist/index.js CHANGED
@@ -1489,23 +1489,27 @@ var ParticipantModel = import_mobx_state_tree11.types.model("Participant", {
1489
1489
  }
1490
1490
  };
1491
1491
  });
1492
- function mapFromApi2(d) {
1492
+ function mapParticipantFromApi(d) {
1493
1493
  if (!d) return d;
1494
1494
  const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
1495
1495
  const n = (v) => v != null && v !== "" ? Number(v) : void 0;
1496
1496
  return {
1497
+ id: n(pick2("id", "Id")) ?? null,
1497
1498
  participantId: String(pick2("participantId", "ParticipantId", "participant_id") ?? ""),
1498
1499
  companyKey: pick2("companyKey", "CompanyKey", "company_key") ?? null,
1499
1500
  alias: pick2("alias", "Alias") ?? "",
1500
1501
  email: pick2("email", "Email") ?? "",
1501
1502
  isApproved: Boolean(pick2("isApproved", "IsApproved", "is_approved")),
1502
1503
  isAvailable: Boolean(pick2("isAvailable", "IsAvailable", "is_available")),
1503
- provider: n(pick2("provider", "Provider")) ?? 0,
1504
+ provider: n(pick2("provider", "Provider", "emailProvider", "EmailProvider", "email_provider")) ?? 0,
1504
1505
  createdOn: pick2("createdOn", "CreatedOn", "created_on") ?? null,
1505
1506
  modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on") ?? null,
1506
1507
  isDeleted: Boolean(pick2("isDeleted", "IsDeleted", "is_deleted"))
1507
1508
  };
1508
1509
  }
1510
+ function mapFromApi2(d) {
1511
+ return mapParticipantFromApi(d);
1512
+ }
1509
1513
  function toPayload(self) {
1510
1514
  return {
1511
1515
  participantId: self.participantId,
@@ -2846,6 +2850,22 @@ var AuthModel = {
2846
2850
  }
2847
2851
  return res;
2848
2852
  },
2853
+ /**
2854
+ * GET Auth/IsAuthorized — validates OAuth with the provider; clears isApproved when not authorized.
2855
+ * Returns the updated participant record (same shape as participant/get).
2856
+ * @param {string} participantId
2857
+ * @returns {Promise<{ status: string, data?: object, message?: string }>}
2858
+ */
2859
+ async IsAuthorized(participantId) {
2860
+ const id = participantId != null ? String(participantId).trim() : "";
2861
+ if (!id) return { status: "failure", message: "participantId required" };
2862
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
2863
+ const res = await reqGet("/Auth/IsAuthorized", { participant_id: id });
2864
+ if (res.status === "success" && res.data) {
2865
+ res.data = mapParticipantFromApi(res.data);
2866
+ }
2867
+ return res;
2868
+ },
2849
2869
  /**
2850
2870
  * Open Google/Microsoft OAuth in a centered popup.
2851
2871
  * @param {string} authorizationUrl — from getAuthorizationUrl().data.authorizationUrl
@@ -2866,6 +2886,8 @@ var AuthModel = {
2866
2886
  },
2867
2887
  /**
2868
2888
  * Subscribe to calendar-authorization postMessage from OAuth popup (Authorized.html / Error.html).
2889
+ * Do not use popup.closed to detect completion — Cross-Origin-Opener-Policy on the parent app
2890
+ * blocks that check after the popup navigates to Google/Microsoft.
2869
2891
  * @param {(payload: { type: string, status: 'success' | 'error', message?: string }) => void} handler
2870
2892
  * @returns {() => void} unsubscribe
2871
2893
  */
package/dist/index.mjs CHANGED
@@ -1418,23 +1418,27 @@ var ParticipantModel = types11.model("Participant", {
1418
1418
  }
1419
1419
  };
1420
1420
  });
1421
- function mapFromApi2(d) {
1421
+ function mapParticipantFromApi(d) {
1422
1422
  if (!d) return d;
1423
1423
  const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
1424
1424
  const n = (v) => v != null && v !== "" ? Number(v) : void 0;
1425
1425
  return {
1426
+ id: n(pick2("id", "Id")) ?? null,
1426
1427
  participantId: String(pick2("participantId", "ParticipantId", "participant_id") ?? ""),
1427
1428
  companyKey: pick2("companyKey", "CompanyKey", "company_key") ?? null,
1428
1429
  alias: pick2("alias", "Alias") ?? "",
1429
1430
  email: pick2("email", "Email") ?? "",
1430
1431
  isApproved: Boolean(pick2("isApproved", "IsApproved", "is_approved")),
1431
1432
  isAvailable: Boolean(pick2("isAvailable", "IsAvailable", "is_available")),
1432
- provider: n(pick2("provider", "Provider")) ?? 0,
1433
+ provider: n(pick2("provider", "Provider", "emailProvider", "EmailProvider", "email_provider")) ?? 0,
1433
1434
  createdOn: pick2("createdOn", "CreatedOn", "created_on") ?? null,
1434
1435
  modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on") ?? null,
1435
1436
  isDeleted: Boolean(pick2("isDeleted", "IsDeleted", "is_deleted"))
1436
1437
  };
1437
1438
  }
1439
+ function mapFromApi2(d) {
1440
+ return mapParticipantFromApi(d);
1441
+ }
1438
1442
  function toPayload(self) {
1439
1443
  return {
1440
1444
  participantId: self.participantId,
@@ -2775,6 +2779,22 @@ var AuthModel = {
2775
2779
  }
2776
2780
  return res;
2777
2781
  },
2782
+ /**
2783
+ * GET Auth/IsAuthorized — validates OAuth with the provider; clears isApproved when not authorized.
2784
+ * Returns the updated participant record (same shape as participant/get).
2785
+ * @param {string} participantId
2786
+ * @returns {Promise<{ status: string, data?: object, message?: string }>}
2787
+ */
2788
+ async IsAuthorized(participantId) {
2789
+ const id = participantId != null ? String(participantId).trim() : "";
2790
+ if (!id) return { status: "failure", message: "participantId required" };
2791
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
2792
+ const res = await reqGet("/Auth/IsAuthorized", { participant_id: id });
2793
+ if (res.status === "success" && res.data) {
2794
+ res.data = mapParticipantFromApi(res.data);
2795
+ }
2796
+ return res;
2797
+ },
2778
2798
  /**
2779
2799
  * Open Google/Microsoft OAuth in a centered popup.
2780
2800
  * @param {string} authorizationUrl — from getAuthorizationUrl().data.authorizationUrl
@@ -2795,6 +2815,8 @@ var AuthModel = {
2795
2815
  },
2796
2816
  /**
2797
2817
  * Subscribe to calendar-authorization postMessage from OAuth popup (Authorized.html / Error.html).
2818
+ * Do not use popup.closed to detect completion — Cross-Origin-Opener-Policy on the parent app
2819
+ * blocks that check after the popup navigates to Google/Microsoft.
2798
2820
  * @param {(payload: { type: string, status: 'success' | 'error', message?: string }) => void} handler
2799
2821
  * @returns {() => void} unsubscribe
2800
2822
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazeo.com/calendar-client",
3
- "version": "1.0.28",
3
+ "version": "1.0.29",
4
4
  "description": "Blazeo Calendar / Appointment API client with MobX State Tree models",
5
5
  "exports": {
6
6
  ".": {