@ianua/ianus-dataverse-react-fluentui8 1.0.5 → 1.0.7

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.
Files changed (2) hide show
  1. package/dist/index.js +22 -21
  2. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -65,8 +65,8 @@ var __async = (__this, __arguments, generator) => {
65
65
  };
66
66
 
67
67
  // src/index.ts
68
- var src_exports = {};
69
- __export(src_exports, {
68
+ var index_exports = {};
69
+ __export(index_exports, {
70
70
  IanusGuard: () => IanusGuard,
71
71
  IanusLicenseStateProvider: () => IanusLicenseStateProvider,
72
72
  IanusProvider: () => IanusProvider,
@@ -81,7 +81,7 @@ __export(src_exports, {
81
81
  useLicenseState: () => useLicenseState,
82
82
  validateLicense: () => validateLicense
83
83
  });
84
- module.exports = __toCommonJS(src_exports);
84
+ module.exports = __toCommonJS(index_exports);
85
85
 
86
86
  // src/IanusGuard.tsx
87
87
  var React3 = __toESM(require("react"));
@@ -154,7 +154,7 @@ var base64url_decode = (value) => {
154
154
  value.replace(/-/g, "+").replace(/_/g, "/").padEnd(value.length + (m === 0 ? 0 : 4 - m), "=")
155
155
  ), (c) => c.charCodeAt(0)).buffer;
156
156
  };
157
- var verifySignature = (key, dataToVerify, signature) => __async(void 0, null, function* () {
157
+ var verifySignature = (key, dataToVerify, signature) => __async(null, null, function* () {
158
158
  return yield window.crypto.subtle.verify(
159
159
  "RSASSA-PKCS1-v1_5",
160
160
  key,
@@ -162,7 +162,7 @@ var verifySignature = (key, dataToVerify, signature) => __async(void 0, null, fu
162
162
  dataToVerify
163
163
  );
164
164
  });
165
- var validateLicense = (publisherId, productId, environmentType, environmentIdentifier, publicKeys, licenseKey) => __async(void 0, null, function* () {
165
+ var validateLicense = (publisherId, productId, environmentType, environmentIdentifier, publicKeys, licenseKey) => __async(null, null, function* () {
166
166
  if (!licenseKey) {
167
167
  return {
168
168
  isValid: false,
@@ -285,7 +285,7 @@ var LicenseDialog = ({ publisherId, productId, dataProvider, onCancel, onSubmit
285
285
  const [licenseId, setLicenseId] = React2.useState((_b = licenseState == null ? void 0 : licenseState.license) == null ? void 0 : _b.licenseId);
286
286
  const [error, setError] = React2.useState("");
287
287
  React2.useEffect(() => {
288
- (() => __async(void 0, null, function* () {
288
+ (() => __async(null, null, function* () {
289
289
  if (!licenseId) {
290
290
  const licenses = yield acquireLicenses(publisherId, productId, dataProvider);
291
291
  if (licenses.length > 0) {
@@ -293,7 +293,7 @@ var LicenseDialog = ({ publisherId, productId, dataProvider, onCancel, onSubmit
293
293
  }
294
294
  }
295
295
  }))();
296
- }, []);
296
+ }, [dataProvider, licenseId, productId, publisherId]);
297
297
  const tryToExtractDisplayNames = (licenseKey) => {
298
298
  var _a2, _b2;
299
299
  if (!licenseKey) {
@@ -319,7 +319,7 @@ var LicenseDialog = ({ publisherId, productId, dataProvider, onCancel, onSubmit
319
319
  return null;
320
320
  }
321
321
  };
322
- const onSubmitClick = () => __async(void 0, null, function* () {
322
+ const onSubmitClick = () => __async(null, null, function* () {
323
323
  var _a2, _b2;
324
324
  try {
325
325
  setSubmitBlocked(true);
@@ -337,9 +337,11 @@ var LicenseDialog = ({ publisherId, productId, dataProvider, onCancel, onSubmit
337
337
  }
338
338
  );
339
339
  } else if (isDataset(dataProvider)) {
340
- yield dataProvider.records[licenseId].setValue("ian_name", name);
341
- yield dataProvider.records[licenseId].setValue("ian_key", licenseKeyInput);
342
- yield dataProvider.records[licenseId].save();
340
+ if (dataProvider.records[licenseId]) {
341
+ yield dataProvider.records[licenseId].setValue("ian_name", name);
342
+ yield dataProvider.records[licenseId].setValue("ian_key", licenseKeyInput);
343
+ yield dataProvider.records[licenseId].save();
344
+ }
343
345
  }
344
346
  } else {
345
347
  if (isWebApi(dataProvider)) {
@@ -403,7 +405,7 @@ var isWebApi = (dataProvider) => {
403
405
  var isDataset = (dataProvider) => {
404
406
  return dataProvider.records !== void 0;
405
407
  };
406
- var acquireLicenses = (publisherId, productId, dataProvider) => __async(void 0, null, function* () {
408
+ var acquireLicenses = (publisherId, productId, dataProvider) => __async(null, null, function* () {
407
409
  const licenseIdentifier = `${publisherId}_${productId}`;
408
410
  if (isWebApi(dataProvider)) {
409
411
  const response = yield dataProvider.retrieveMultipleRecords("ian_license", `?$filter=ian_identifier eq '${licenseIdentifier}' and statecode eq 0`);
@@ -415,7 +417,7 @@ var acquireLicenses = (publisherId, productId, dataProvider) => __async(void 0,
415
417
  throw new Error("You need to pass the 'ian_license' entity as data source for LicenseDataset when using a dataset as value");
416
418
  }
417
419
  }
418
- return Object.values(dataProvider.records).filter((r) => r.getValue("ian_identifier") === licenseIdentifier).map((r) => dataProvider.columns.reduce((all, cur) => __spreadProps(__spreadValues({}, all), { [cur.name]: r.getValue(cur.name) }), { ian_licenseid: r.getRecordId() }));
420
+ return Object.values(dataProvider.records).filter((r) => r.getValue("ian_identifier") === licenseIdentifier).map((r) => ({ ian_licenseid: r.getValue("ian_licenseid"), ian_identifier: r.getValue("ian_identifier"), ian_key: r.getValue("ian_key") }));
419
421
  } else {
420
422
  throw new Error(`The 'dataProvider' prop must be either of type ComponentFramework.WebApi or ComponentFramework.PropertyTypes.Dataset. You passed '${typeof dataProvider}'.`);
421
423
  }
@@ -431,7 +433,7 @@ var updateResultIfDefined = (result, onLicenseValidated) => {
431
433
  }
432
434
  }
433
435
  };
434
- var fetchOrganizationIdFromWebApi = (webApi) => __async(void 0, null, function* () {
436
+ var fetchOrganizationIdFromWebApi = (webApi) => __async(null, null, function* () {
435
437
  const results = yield webApi.retrieveMultipleRecords("organization", "?$top=1&$select=organizationid");
436
438
  if (!results.entities.length) {
437
439
  return null;
@@ -446,7 +448,7 @@ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environ
446
448
  licenseDispatch({ type: "setLicenseDialogVisible", payload: false });
447
449
  initLicenseValidation();
448
450
  };
449
- const runValidation = () => __async(void 0, null, function* () {
451
+ const runValidation = React3.useCallback(() => __async(null, null, function* () {
450
452
  try {
451
453
  if (!productId) {
452
454
  return {
@@ -491,12 +493,12 @@ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environ
491
493
  reason: e == null ? void 0 : e.message
492
494
  };
493
495
  }
494
- });
495
- const initLicenseValidation = () => __async(void 0, null, function* () {
496
+ }), [dataProvider, environmentIdentifier, environmentType, productId, publicKeys, publisherId]);
497
+ const initLicenseValidation = React3.useCallback(() => __async(null, null, function* () {
496
498
  const result = yield runValidation();
497
499
  licenseDispatch({ type: "setLicense", payload: result });
498
500
  updateResultIfDefined(result, onLicenseValidated);
499
- });
501
+ }), [licenseDispatch, onLicenseValidated, runValidation]);
500
502
  React3.useEffect(() => {
501
503
  if (!isDataset(dataProvider) || !dataProvider.error && !dataProvider.loading && dataProvider.paging.totalResultCount >= 0) {
502
504
  initLicenseValidation();
@@ -506,11 +508,10 @@ var IanusGuard = ({ publisherId, productId, publicKeys, environmentType, environ
506
508
  isTerminalError: true,
507
509
  reason: `Dataset error: ${dataProvider.errorMessage}`
508
510
  };
511
+ licenseDispatch({ type: "setLicense", payload: result });
509
512
  updateResultIfDefined(result, onLicenseValidated);
510
513
  }
511
- }, [
512
- isDataset(dataProvider) ? dataProvider.sortedRecordIds.length : dataProvider
513
- ]);
514
+ }, [dataProvider, initLicenseValidation, licenseDispatch, onLicenseValidated]);
514
515
  return ((_a = licenseState.license) == null ? void 0 : _a.isValid) ? /* @__PURE__ */ React3.createElement(React3.Fragment, null, licenseState.licenseDialogVisible && /* @__PURE__ */ React3.createElement(LicenseDialog, { publisherId, productId, dataProvider, onSubmit: onSettingsFinally, onCancel: onSettingsFinally }), children) : /* @__PURE__ */ React3.createElement("div", { style: { display: "flex", width: "100%", height: "100%", flex: "1" } }, licenseState.licenseDialogVisible && /* @__PURE__ */ React3.createElement(LicenseDialog, { publisherId, productId, dataProvider, onSubmit: onSettingsFinally, onCancel: onSettingsFinally }), /* @__PURE__ */ React3.createElement("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", flex: 1 } }, ((_b = licenseState.license) == null ? void 0 : _b.isValid) === false && /* @__PURE__ */ React3.createElement(
515
516
  import_MessageBar.MessageBar,
516
517
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ianua/ianus-dataverse-react-fluentui8",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Client-side validation for Ianus Guard licenses in Dataverse using react and FluentUi v8",
5
5
  "scripts": {
6
6
  "build": "tsup"
@@ -16,7 +16,8 @@
16
16
  "react-dom": "^16.8 || ^17 || ^18"
17
17
  },
18
18
  "dependencies": {
19
- "@fluentui/react": "8.29.0",
19
+ "@fluentui/react": "^8",
20
+ "eslint-plugin-react-hooks": "^5.2.0",
20
21
  "react": "^16.8 || ^17 || ^18",
21
22
  "react-dom": "^16.8 || ^17 || ^18"
22
23
  },