@ianua/ianus-dataverse-react-fluentui8 1.0.12 → 1.0.14

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
@@ -56,6 +56,36 @@ type LicenseValidationSuccess = {
56
56
  type LicenseValidationResult = LicenseValidationError | LicenseValidationSuccess;
57
57
 
58
58
  type EnvironmentType = "entra" | "dataverse";
59
+ type EnvironmentEntry = {
60
+ type: EnvironmentType;
61
+ identifier: string;
62
+ name: string;
63
+ };
64
+ type PrefillData = {
65
+ additionalEnvironments: Array<EnvironmentEntry>;
66
+ emailAddress: string;
67
+ };
68
+ type LicenseAcquisitionConfig = {
69
+ /**
70
+ * Pass 'url' to open the Ianus Guard self-service trial page or 'contact' to just pass an instruction
71
+ */
72
+ type: "url" | "contact";
73
+ /**
74
+ * Title for the contact dialog
75
+ * @default "Request a Trial License"
76
+ */
77
+ title?: string;
78
+ /**
79
+ * Instructions or message to show in the dialog, you can pass a string or any react element
80
+ * @example "To request a trial license, please send an email to trials@yourcompany.com with your organization details."
81
+ */
82
+ instruction: React.ReactElement | React.ReactNode;
83
+ /**
84
+ * Additional data to pass to Ianus Guard when acquiring a trial to ease license acquisition.
85
+ * You can add additional environments (such as the entra environment) and the current user's email address for example.
86
+ */
87
+ prefillData?: PrefillData;
88
+ };
59
89
  interface IIanusGuardProps {
60
90
  /**
61
91
  * The external publisher Guid found on the publisher's Ianus Guard portal form
@@ -91,6 +121,10 @@ interface IIanusGuardProps {
91
121
  * For canvas apps, use the DataSourceInfo PowerFX function, for PCFs use pcfContext.utils.getEntityMetadata for loading the metadata followed by pcfContext.utils.hasEntityPrivilege for getting the permission result.
92
122
  */
93
123
  usagePermission?: boolean | null;
124
+ /**
125
+ * Pass this if you want to show instructions for the user on how to obtain a license
126
+ */
127
+ licenseAcquisitionConfig?: LicenseAcquisitionConfig;
94
128
  /**
95
129
  * Optionally pass a callback which is called when a license validation result was generated
96
130
  *
@@ -104,20 +138,17 @@ declare const isDataset: (dataProvider: ComponentFramework.WebApi | ComponentFra
104
138
  declare const acquireLicenses: (publisherId: string, productId: string, dataProvider: ComponentFramework.WebApi | ComponentFramework.PropertyTypes.DataSet) => Promise<ComponentFramework.WebApi.Entity[]>;
105
139
  declare const IanusGuard: React.FC<IIanusGuardProps>;
106
140
 
141
+ type AvailableDialogs = "debug" | "license_details" | "license_acquisition";
142
+ type IanusLicenseStateProps = {
143
+ license?: DataverseLicenseValidationResult;
144
+ visibleDialog?: AvailableDialogs;
145
+ };
107
146
  type Action = {
108
147
  type: "setLicense";
109
148
  payload: DataverseLicenseValidationResult | undefined;
110
149
  } | {
111
- type: "setLicenseDialogVisible";
112
- payload: boolean;
113
- } | {
114
- type: "setDebugDialogVisible";
115
- payload: boolean;
116
- };
117
- type IanusLicenseStateProps = {
118
- license?: DataverseLicenseValidationResult;
119
- licenseDialogVisible?: boolean;
120
- debugDialogVisible?: boolean;
150
+ type: "setVisibleDialog";
151
+ payload: AvailableDialogs | undefined;
121
152
  };
122
153
  type IanusLicenseDispatch = (action: Action) => void;
123
154
  declare const IanusLicenseDispatch: React.Context<IanusLicenseDispatch | undefined>;
@@ -145,4 +176,4 @@ declare const removeCurlyBrackets: (input: string | undefined | null) => string
145
176
  declare const base64url_decode: (value: string) => ArrayBuffer;
146
177
  declare const validateLicense: (publisherId: string, productId: string, environmentType: string, environmentIdentifier: string, publicKeys: string[], licenseKey: string | undefined) => Promise<LicenseValidationResult>;
147
178
 
148
- export { type DataverseLicenseValidationError, type DataverseLicenseValidationResult, type DataverseLicenseValidationSuccess, type EnvironmentType, type IEnvironmentIdentifier, type IIanusGuardProps, type IIanusProviderProps, type ILicenseClaims, type ILicenseDialogProps, type IMeta, IanusGuard, IanusLicenseDispatch, type IanusLicenseStateProps, IanusLicenseStateProvider, IanusProvider, LicenseDialog, type LicenseValidationError, type LicenseValidationResult, type LicenseValidationSuccess, acquireLicenses, base64url_decode, isDataset, isWebApi, removeCurlyBrackets, useLicenseContext, useLicenseDispatch, useLicenseState, validateLicense };
179
+ export { type AvailableDialogs, type DataverseLicenseValidationError, type DataverseLicenseValidationResult, type DataverseLicenseValidationSuccess, type EnvironmentEntry, type EnvironmentType, type IEnvironmentIdentifier, type IIanusGuardProps, type IIanusProviderProps, type ILicenseClaims, type ILicenseDialogProps, type IMeta, IanusGuard, IanusLicenseDispatch, type IanusLicenseStateProps, IanusLicenseStateProvider, IanusProvider, type LicenseAcquisitionConfig, LicenseDialog, type LicenseValidationError, type LicenseValidationResult, type LicenseValidationSuccess, type PrefillData, acquireLicenses, base64url_decode, isDataset, isWebApi, removeCurlyBrackets, useLicenseContext, useLicenseDispatch, useLicenseState, validateLicense };
package/dist/index.js CHANGED
@@ -84,7 +84,7 @@ __export(index_exports, {
84
84
  module.exports = __toCommonJS(index_exports);
85
85
 
86
86
  // src/IanusGuard.tsx
87
- var React4 = __toESM(require("react"));
87
+ var React5 = __toESM(require("react"));
88
88
  var import_MessageBar = require("@fluentui/react/lib/MessageBar");
89
89
  var import_Button = require("@fluentui/react/lib/Button");
90
90
  var import_Spinner = require("@fluentui/react/lib/Spinner");
@@ -239,11 +239,8 @@ function stateReducer(state, action) {
239
239
  case "setLicense": {
240
240
  return __spreadProps(__spreadValues({}, state), { license: action.payload });
241
241
  }
242
- case "setLicenseDialogVisible": {
243
- return __spreadProps(__spreadValues({}, state), { licenseDialogVisible: action.payload });
244
- }
245
- case "setDebugDialogVisible": {
246
- return __spreadProps(__spreadValues({}, state), { debugDialogVisible: action.payload });
242
+ case "setVisibleDialog": {
243
+ return __spreadProps(__spreadValues({}, state), { visibleDialog: action.payload });
247
244
  }
248
245
  }
249
246
  }
@@ -385,7 +382,7 @@ var LicenseDialog = ({ publisherId, productId, dataProvider, offlineDataProvider
385
382
  return /* @__PURE__ */ React2.createElement(
386
383
  import_react.Dialog,
387
384
  {
388
- hidden: !(licenseState == null ? void 0 : licenseState.licenseDialogVisible),
385
+ hidden: (licenseState == null ? void 0 : licenseState.visibleDialog) !== "license_details",
389
386
  onDismiss: onCancel,
390
387
  dialogContentProps,
391
388
  modalProps
@@ -455,7 +452,7 @@ var DebugDialog = ({ publisherId, productId, environmentType, environmentIdentif
455
452
  return /* @__PURE__ */ React3.createElement(
456
453
  import_react2.Dialog,
457
454
  {
458
- hidden: !(licenseState == null ? void 0 : licenseState.debugDialogVisible),
455
+ hidden: (licenseState == null ? void 0 : licenseState.visibleDialog) !== "debug",
459
456
  onDismiss,
460
457
  dialogContentProps: dialogContentProps2,
461
458
  modalProps: modalProps2
@@ -483,6 +480,95 @@ var DebugDialog = ({ publisherId, productId, environmentType, environmentIdentif
483
480
  );
484
481
  };
485
482
 
483
+ // src/LicenseAcquisitionDialog.tsx
484
+ var React4 = __toESM(require("react"));
485
+ var import_react3 = require("@fluentui/react");
486
+ var modalProps3 = {
487
+ isBlocking: false,
488
+ styles: { main: { maxWidth: 600 } }
489
+ };
490
+ var LicenseAcquisitionDialog = ({
491
+ config,
492
+ publisherId,
493
+ productId,
494
+ environmentType,
495
+ environmentIdentifier
496
+ }) => {
497
+ var _a;
498
+ const [licenseState, licenseDispatch] = useLicenseContext();
499
+ const [error, setError] = React4.useState();
500
+ const onDismiss = React4.useCallback(() => {
501
+ setError(void 0);
502
+ licenseDispatch({ type: "setVisibleDialog", payload: void 0 });
503
+ }, [licenseDispatch]);
504
+ const onOpenTrialPage = React4.useCallback(() => {
505
+ var _a2, _b, _c;
506
+ setError(void 0);
507
+ if ((config == null ? void 0 : config.type) !== "url") {
508
+ setError("Configuration error: Trial page cannot be opened for this license acquisition type.");
509
+ return;
510
+ }
511
+ if (!environmentIdentifier) {
512
+ setError("Environment identifier is missing. Please try again or contact support.");
513
+ return;
514
+ }
515
+ try {
516
+ const currentEnvironment = {
517
+ type: environmentType,
518
+ identifier: environmentIdentifier,
519
+ name: environmentType === "entra" ? "Entra ID Tenant" : "Dataverse Environment"
520
+ };
521
+ const allEnvironments = [
522
+ currentEnvironment,
523
+ ...(_b = (_a2 = config == null ? void 0 : config.prefillData) == null ? void 0 : _a2.additionalEnvironments) != null ? _b : []
524
+ ];
525
+ const uniqueEnvironments = allEnvironments.filter(
526
+ (env, index, self) => index === self.findIndex((e) => e.identifier.toLowerCase() === env.identifier.toLowerCase())
527
+ );
528
+ const prefillData = {
529
+ emailAddress: (_c = config == null ? void 0 : config.prefillData) == null ? void 0 : _c.emailAddress,
530
+ environments: uniqueEnvironments
531
+ };
532
+ const portalUrl = "https://www.ianusguard.com";
533
+ const url = `${portalUrl}/public/publishers/${publisherId}/products/${productId}?prefill=${encodeURIComponent(JSON.stringify(prefillData))}`;
534
+ const newWindow = window.open(url, "_blank", "noopener,noreferrer");
535
+ if (!newWindow || newWindow.closed || typeof newWindow.closed === "undefined") {
536
+ setError("Failed to open trial page. Please check if popup blockers are enabled and allow popups for this site.");
537
+ return;
538
+ }
539
+ onDismiss();
540
+ } catch (err) {
541
+ console.error("Failed to open trial page:", err);
542
+ setError(`Failed to open trial page: ${err instanceof Error ? err.message : "Unknown error occurred"}`);
543
+ }
544
+ }, [config, environmentType, environmentIdentifier, publisherId, productId, onDismiss]);
545
+ if (!config) {
546
+ return null;
547
+ }
548
+ return /* @__PURE__ */ React4.createElement(
549
+ import_react3.Dialog,
550
+ {
551
+ hidden: (licenseState == null ? void 0 : licenseState.visibleDialog) !== "license_acquisition",
552
+ onDismiss,
553
+ dialogContentProps: {
554
+ type: import_react3.DialogType.largeHeader,
555
+ title: (_a = config.title) != null ? _a : "Acquire a License"
556
+ },
557
+ modalProps: modalProps3
558
+ },
559
+ /* @__PURE__ */ React4.createElement(import_react3.Stack, { tokens: { childrenGap: 16 } }, error && /* @__PURE__ */ React4.createElement(
560
+ import_react3.MessageBar,
561
+ {
562
+ messageBarType: import_react3.MessageBarType.error,
563
+ isMultiline: true,
564
+ onDismiss: () => setError(void 0)
565
+ },
566
+ error
567
+ ), typeof config.instruction === "string" ? /* @__PURE__ */ React4.createElement(import_react3.Text, null, config.instruction) : config.instruction),
568
+ /* @__PURE__ */ React4.createElement(import_react3.DialogFooter, null, config.type === "url" ? /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(import_react3.PrimaryButton, { onClick: onOpenTrialPage, text: "Open Trial Request Page" }), /* @__PURE__ */ React4.createElement(import_react3.DefaultButton, { onClick: onDismiss, text: "Close" })) : /* @__PURE__ */ React4.createElement(import_react3.PrimaryButton, { onClick: onDismiss, text: "Close" }))
569
+ );
570
+ };
571
+
486
572
  // src/IanusGuard.tsx
487
573
  var isWebApi = (dataProvider) => {
488
574
  return (dataProvider == null ? void 0 : dataProvider.retrieveMultipleRecords) !== void 0;
@@ -518,21 +604,41 @@ var fetchOrganizationIdFromWebApi = (webApi) => __async(null, null, function* ()
518
604
  const organization = results.entities[0];
519
605
  return organization.organizationid.replace("{", "").replace("}", "").toLowerCase();
520
606
  });
521
- var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environmentIdentifier, dataProvider, offlineDataProvider, usagePermission, onLicenseValidated, children }) => {
522
- var _a, _b, _c, _d, _e;
607
+ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environmentIdentifier, dataProvider, offlineDataProvider, usagePermission, licenseAcquisitionConfig, onLicenseValidated, children }) => {
608
+ var _a, _b, _c, _d, _e, _f;
523
609
  const [licenseState, licenseDispatch] = useLicenseContext();
524
- const onLicenseValidatedRef = React4.useRef(onLicenseValidated);
525
- React4.useEffect(() => {
610
+ const onLicenseValidatedRef = React5.useRef(onLicenseValidated);
611
+ React5.useEffect(() => {
526
612
  onLicenseValidatedRef.current = onLicenseValidated;
527
613
  }, [onLicenseValidated]);
528
- const publicKeysRef = React4.useRef(publicKeys);
529
- React4.useEffect(() => {
614
+ const publicKeysRef = React5.useRef(publicKeys);
615
+ React5.useEffect(() => {
530
616
  if (JSON.stringify(publicKeys) !== JSON.stringify(publicKeysRef.current)) {
531
617
  publicKeysRef.current = publicKeys;
532
618
  }
533
619
  }, [publicKeys]);
534
- const resolvedEnvironmentIdentifierRef = React4.useRef(null);
535
- const runValidation = React4.useCallback(() => __async(null, null, function* () {
620
+ const licenseAcquisitionConfigRef = React5.useRef(licenseAcquisitionConfig);
621
+ React5.useEffect(() => {
622
+ if (JSON.stringify(licenseAcquisitionConfig) !== JSON.stringify(licenseAcquisitionConfigRef.current)) {
623
+ licenseAcquisitionConfigRef.current = licenseAcquisitionConfig;
624
+ }
625
+ }, [licenseAcquisitionConfig]);
626
+ const resolvedEnvironmentIdentifierRef = React5.useRef(null);
627
+ const preventAutomaticReevaluation = React5.useRef(false);
628
+ const handleValidationResult = React5.useCallback((result) => {
629
+ var _a2;
630
+ preventAutomaticReevaluation.current = (_a2 = result == null ? void 0 : result.isValid) != null ? _a2 : false;
631
+ if (onLicenseValidatedRef.current) {
632
+ try {
633
+ onLicenseValidatedRef.current(result);
634
+ } catch (e) {
635
+ if (e && e instanceof Error) {
636
+ console.error(`Error while calling onLicenseValidated: '${e.message}'`);
637
+ }
638
+ }
639
+ }
640
+ }, []);
641
+ const runValidation = React5.useCallback(() => __async(null, null, function* () {
536
642
  try {
537
643
  if (resolvedEnvironmentIdentifierRef.current === null) {
538
644
  resolvedEnvironmentIdentifierRef.current = isWebApi(environmentIdentifier) ? yield fetchOrganizationIdFromWebApi(environmentIdentifier) : environmentIdentifier == null ? void 0 : environmentIdentifier.replace("{", "").replace("}", "").toLowerCase();
@@ -589,30 +695,22 @@ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environ
589
695
  };
590
696
  }
591
697
  }), [dataProvider, environmentIdentifier, environmentType, offlineDataProvider, productId, publisherId]);
592
- const initLicenseValidation = React4.useCallback(() => __async(null, null, function* () {
698
+ const initLicenseValidation = React5.useCallback(() => __async(null, null, function* () {
593
699
  const result = yield runValidation();
594
700
  licenseDispatch({ type: "setLicense", payload: result });
595
- if (onLicenseValidatedRef.current) {
596
- try {
597
- onLicenseValidatedRef.current(result);
598
- } catch (e) {
599
- if (e && e instanceof Error) {
600
- console.error(`Error while calling onLicenseValidated: '${e.message}'`);
601
- }
602
- }
603
- }
604
- }), [licenseDispatch, runValidation]);
605
- const onSettingsFinally = React4.useCallback(() => {
606
- licenseDispatch({ type: "setLicenseDialogVisible", payload: false });
701
+ handleValidationResult(result);
702
+ }), [licenseDispatch, runValidation, handleValidationResult]);
703
+ const onLicenseDialogFinally = React5.useCallback(() => {
704
+ licenseDispatch({ type: "setVisibleDialog", payload: void 0 });
607
705
  initLicenseValidation();
608
706
  }, [initLicenseValidation, licenseDispatch]);
609
- const onDebugFinally = React4.useCallback(() => {
610
- licenseDispatch({ type: "setDebugDialogVisible", payload: false });
707
+ const onDebugFinally = React5.useCallback(() => {
708
+ licenseDispatch({ type: "setVisibleDialog", payload: void 0 });
611
709
  }, [licenseDispatch]);
612
710
  const dataTotalResultCount = isDataset(dataProvider) ? dataProvider.paging.totalResultCount : void 0;
613
711
  const dataIsLoading = isDataset(dataProvider) ? dataProvider.loading : void 0;
614
712
  const dataHasError = isDataset(dataProvider) ? dataProvider.error : void 0;
615
- const dataProviderState = React4.useMemo(() => {
713
+ const dataProviderState = React5.useMemo(() => {
616
714
  if (!isDataset(dataProvider)) {
617
715
  return "webapi";
618
716
  } else {
@@ -622,63 +720,43 @@ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environ
622
720
  const offlineDataTotalResultCount = offlineDataProvider != null ? offlineDataProvider.paging.totalResultCount : void 0;
623
721
  const offlineDataIsLoading = offlineDataProvider != null ? offlineDataProvider.loading : void 0;
624
722
  const offlineDataHasError = offlineDataProvider != null ? offlineDataProvider.error : void 0;
625
- const offlineDataProviderState = React4.useMemo(() => {
723
+ const offlineDataProviderState = React5.useMemo(() => {
626
724
  if (offlineDataProvider == null) {
627
725
  return "unused";
628
726
  } else {
629
727
  return `dataset-${offlineDataTotalResultCount}-${offlineDataIsLoading}-${offlineDataHasError}`;
630
728
  }
631
729
  }, [offlineDataHasError, offlineDataIsLoading, offlineDataProvider, offlineDataTotalResultCount]);
632
- const dataProviderSignature = React4.useMemo(() => {
730
+ const dataProviderSignature = React5.useMemo(() => {
633
731
  if (isDataset(dataProvider) && dataProvider.records) {
634
732
  return Object.values(dataProvider.records).map((r) => `${r.getRecordId()}-${r.getValue("ian_identifier")}-${r.getValue("ian_key")}`).join("|");
635
733
  }
636
734
  return "";
637
735
  }, [dataProvider]);
638
- const offlineDataProviderSignature = React4.useMemo(() => {
736
+ const offlineDataProviderSignature = React5.useMemo(() => {
639
737
  if (offlineDataProvider && offlineDataProvider.records) {
640
738
  return Object.values(offlineDataProvider.records).map((r) => `${r.getRecordId()}-${r.getValue("ian_identifier")}-${r.getValue("ian_key")}`).join("|");
641
739
  }
642
740
  return "";
643
741
  }, [offlineDataProvider]);
644
- const prevDeps = React4.useRef({
645
- dataProvider,
646
- dataProviderState,
647
- dataProviderSignature,
648
- initLicenseValidation,
649
- licenseDispatch,
650
- usagePermission,
651
- offlineDataProvider,
652
- offlineDataProviderState,
653
- offlineDataProviderSignature
654
- });
655
- React4.useEffect(() => {
742
+ const canResetAutomaticReevaluation = React5.useMemo(() => {
743
+ return isDataset(dataProvider) || offlineDataProvider != null;
744
+ }, [dataProvider, offlineDataProvider]);
745
+ React5.useEffect(() => {
746
+ if (canResetAutomaticReevaluation) {
747
+ preventAutomaticReevaluation.current = false;
748
+ }
749
+ }, [canResetAutomaticReevaluation, dataProviderSignature, offlineDataProviderSignature]);
750
+ React5.useEffect(() => {
751
+ if (preventAutomaticReevaluation.current) {
752
+ console.log(`Skipping license evaluation as checks have already passed at ${(/* @__PURE__ */ new Date()).toISOString()}`);
753
+ return;
754
+ }
656
755
  console.log(`Starting license evaluation at ${(/* @__PURE__ */ new Date()).toISOString()}`);
657
756
  console.log(`DataProvider state: ${dataProviderState}`);
658
757
  console.log(`DataProvider signature: ${dataProviderSignature}`);
659
758
  console.log(`Offline DataProvider state: ${offlineDataProviderState}`);
660
759
  console.log(`Offline DataProvider signature: ${offlineDataProviderSignature}`);
661
- const prev = prevDeps.current;
662
- if (prev.dataProvider !== dataProvider) console.log("dataProvider changed");
663
- if (prev.dataProviderState !== dataProviderState) console.log("dataProviderState changed");
664
- if (prev.dataProviderSignature !== dataProviderSignature) console.log("dataProviderSignature changed");
665
- if (prev.initLicenseValidation !== initLicenseValidation) console.log("initLicenseValidation changed");
666
- if (prev.licenseDispatch !== licenseDispatch) console.log("licenseDispatch changed");
667
- if (prev.usagePermission !== usagePermission) console.log("usagePermission changed");
668
- if (prev.offlineDataProvider !== offlineDataProvider) console.log("offlineDataProvider changed");
669
- if (prev.offlineDataProviderState !== offlineDataProviderState) console.log("offlineDataProviderState changed");
670
- if (prev.offlineDataProviderSignature !== offlineDataProviderSignature) console.log("offlineDataProviderSignature changed");
671
- prevDeps.current = {
672
- dataProvider,
673
- dataProviderState,
674
- dataProviderSignature,
675
- initLicenseValidation,
676
- licenseDispatch,
677
- usagePermission,
678
- offlineDataProvider,
679
- offlineDataProviderState,
680
- offlineDataProviderSignature
681
- };
682
760
  if (usagePermission != null && !usagePermission) {
683
761
  const result = {
684
762
  isValid: false,
@@ -686,15 +764,7 @@ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environ
686
764
  reason: "Your user is not enabled for using this product"
687
765
  };
688
766
  licenseDispatch({ type: "setLicense", payload: result });
689
- if (onLicenseValidatedRef.current) {
690
- try {
691
- onLicenseValidatedRef.current(result);
692
- } catch (e) {
693
- if (e && e instanceof Error) {
694
- console.error(`Error while calling onLicenseValidated: '${e.message}'`);
695
- }
696
- }
697
- }
767
+ handleValidationResult(result);
698
768
  } else if (!isDataset(dataProvider) || !dataProvider.error && !dataProvider.loading && dataProvider.paging.totalResultCount >= 0 || offlineDataProvider != null && !offlineDataProvider.error && !offlineDataProvider.loading && offlineDataProvider.paging.totalResultCount >= 0) {
699
769
  initLicenseValidation();
700
770
  } else if (dataProvider.error) {
@@ -704,18 +774,10 @@ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environ
704
774
  reason: `Dataset error: ${dataProvider.errorMessage}`
705
775
  };
706
776
  licenseDispatch({ type: "setLicense", payload: result });
707
- if (onLicenseValidatedRef.current) {
708
- try {
709
- onLicenseValidatedRef.current(result);
710
- } catch (e) {
711
- if (e && e instanceof Error) {
712
- console.error(`Error while calling onLicenseValidated: '${e.message}'`);
713
- }
714
- }
715
- }
777
+ handleValidationResult(result);
716
778
  }
717
- }, [dataProvider, dataProviderState, dataProviderSignature, initLicenseValidation, licenseDispatch, usagePermission, offlineDataProvider, offlineDataProviderState, offlineDataProviderSignature]);
718
- return ((_a = licenseState.license) == null ? void 0 : _a.isValid) ? /* @__PURE__ */ React4.createElement(React4.Fragment, null, licenseState.licenseDialogVisible && /* @__PURE__ */ React4.createElement(LicenseDialog, { publisherId, productId, dataProvider, offlineDataProvider, onSubmit: onSettingsFinally, onCancel: onSettingsFinally }), children) : /* @__PURE__ */ React4.createElement("div", { style: { display: "flex", width: "100%", height: "100%", flex: "1" } }, licenseState.licenseDialogVisible && /* @__PURE__ */ React4.createElement(LicenseDialog, { publisherId, productId, dataProvider, offlineDataProvider, onSubmit: onSettingsFinally, onCancel: onSettingsFinally }), licenseState.debugDialogVisible && /* @__PURE__ */ React4.createElement(DebugDialog, { publisherId, productId, environmentType, environmentIdentifier: resolvedEnvironmentIdentifierRef.current || "", dataProvider, offlineDataProvider, onDismiss: onDebugFinally }), /* @__PURE__ */ React4.createElement("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", flex: 1 } }, ((_b = licenseState.license) == null ? void 0 : _b.isValid) === false && /* @__PURE__ */ React4.createElement(
779
+ }, [dataProvider, dataProviderState, dataProviderSignature, initLicenseValidation, licenseDispatch, usagePermission, offlineDataProvider, offlineDataProviderState, offlineDataProviderSignature, handleValidationResult]);
780
+ return ((_a = licenseState.license) == null ? void 0 : _a.isValid) ? /* @__PURE__ */ React5.createElement(React5.Fragment, null, licenseState.visibleDialog === "debug" && /* @__PURE__ */ React5.createElement(DebugDialog, { publisherId, productId, environmentType, environmentIdentifier: resolvedEnvironmentIdentifierRef.current || "", dataProvider, offlineDataProvider, onDismiss: onDebugFinally }), licenseState.visibleDialog === "license_details" && /* @__PURE__ */ React5.createElement(LicenseDialog, { publisherId, productId, dataProvider, offlineDataProvider, onSubmit: onLicenseDialogFinally, onCancel: onLicenseDialogFinally }), licenseState.visibleDialog === "license_acquisition" && /* @__PURE__ */ React5.createElement(LicenseAcquisitionDialog, { publisherId, productId, environmentType, environmentIdentifier: resolvedEnvironmentIdentifierRef.current || "", config: licenseAcquisitionConfigRef.current }), children) : /* @__PURE__ */ React5.createElement("div", { style: { display: "flex", width: "100%", height: "100%", flex: "1" } }, licenseState.visibleDialog === "debug" && /* @__PURE__ */ React5.createElement(DebugDialog, { publisherId, productId, environmentType, environmentIdentifier: resolvedEnvironmentIdentifierRef.current || "", dataProvider, offlineDataProvider, onDismiss: onDebugFinally }), licenseState.visibleDialog === "license_details" && /* @__PURE__ */ React5.createElement(LicenseDialog, { publisherId, productId, dataProvider, offlineDataProvider, onSubmit: onLicenseDialogFinally, onCancel: onLicenseDialogFinally }), licenseState.visibleDialog === "license_acquisition" && /* @__PURE__ */ React5.createElement(LicenseAcquisitionDialog, { publisherId, productId, environmentType, environmentIdentifier: resolvedEnvironmentIdentifierRef.current || "", config: licenseAcquisitionConfigRef.current }), /* @__PURE__ */ React5.createElement("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", flex: 1 } }, ((_b = licenseState.license) == null ? void 0 : _b.isValid) === false && /* @__PURE__ */ React5.createElement(
719
781
  import_MessageBar.MessageBar,
720
782
  {
721
783
  messageBarType: import_MessageBar.MessageBarType.error,
@@ -725,17 +787,17 @@ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environ
725
787
  licenseDispatch({ type: "setLicense", payload: void 0 });
726
788
  initLicenseValidation();
727
789
  },
728
- actions: /* @__PURE__ */ React4.createElement("div", null, !((_c = licenseState.license) == null ? void 0 : _c.isTerminalError) && /* @__PURE__ */ React4.createElement(import_Button.MessageBarButton, { onClick: () => licenseDispatch({ type: "setLicenseDialogVisible", payload: true }) }, "Set License"), !((_d = licenseState.license) == null ? void 0 : _d.isTerminalError) && /* @__PURE__ */ React4.createElement(import_Button.MessageBarButton, { onClick: () => licenseDispatch({ type: "setDebugDialogVisible", payload: true }) }, "Debug"))
790
+ actions: /* @__PURE__ */ React5.createElement("div", null, !((_c = licenseState.license) == null ? void 0 : _c.isTerminalError) && /* @__PURE__ */ React5.createElement(import_Button.MessageBarButton, { onClick: () => licenseDispatch({ type: "setVisibleDialog", payload: "license_details" }) }, "Set License"), !((_d = licenseState.license) == null ? void 0 : _d.isTerminalError) && licenseAcquisitionConfigRef.current && /* @__PURE__ */ React5.createElement(import_Button.MessageBarButton, { onClick: () => licenseDispatch({ type: "setVisibleDialog", payload: "license_acquisition" }) }, "Acquire a license"), !((_e = licenseState.license) == null ? void 0 : _e.isTerminalError) && /* @__PURE__ */ React5.createElement(import_Button.MessageBarButton, { onClick: () => licenseDispatch({ type: "setVisibleDialog", payload: "debug" }) }, "Debug"))
729
791
  },
730
792
  "An error occured, please try again. Error information: ",
731
- (_e = licenseState.license) == null ? void 0 : _e.reason
732
- ), !licenseState.license && /* @__PURE__ */ React4.createElement(import_Spinner.Spinner, { styles: { root: { width: "auto" } }, label: "Loading..." })));
793
+ (_f = licenseState.license) == null ? void 0 : _f.reason
794
+ ), !licenseState.license && /* @__PURE__ */ React5.createElement(import_Spinner.Spinner, { styles: { root: { width: "auto" } }, label: "Loading..." })));
733
795
  };
734
796
 
735
797
  // src/IanusProvider.tsx
736
- var React5 = __toESM(require("react"));
798
+ var React6 = __toESM(require("react"));
737
799
  var IanusProvider = (props) => {
738
- return /* @__PURE__ */ React5.createElement(IanusLicenseStateProvider, null, /* @__PURE__ */ React5.createElement(IanusGuard, __spreadValues({}, props)));
800
+ return /* @__PURE__ */ React6.createElement(IanusLicenseStateProvider, null, /* @__PURE__ */ React6.createElement(IanusGuard, __spreadValues({}, props)));
739
801
  };
740
802
 
741
803
  // ../../../../ianus-core/GuidTools.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ianua/ianus-dataverse-react-fluentui8",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "Client-side validation for Ianus Guard licenses in Dataverse using react and FluentUi v8",
5
5
  "scripts": {
6
6
  "build": "tsup"