feathers-ucan 0.1.41 → 0.1.43

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.
@@ -1 +1 @@
1
- export declare const VERSION = "0.1.41";
1
+ export declare const VERSION = "0.1.43";
package/lib/index.cjs CHANGED
@@ -955,12 +955,14 @@ const checkUcan = (requiredCapabilities, options) => {
955
955
  } = options || {
956
956
  loginPass: [[['*'], ['nonExistentMethod']]]
957
957
  };
958
+ if (options != null && options.log) console.log('loginPass precheck', loginPass);
958
959
  if (loginPass != null && loginPass.length) {
959
960
  //object of scrubbed data object for pass that includes only limited access or full context.data object if no limits were present
960
961
  let scrubbedData = {};
961
962
  //scruData defaults to true - is only set to false
962
963
  let scrubData = true;
963
964
  const checkLoginPass = async lpass => {
965
+ if (options != null && options.log) console.log('checkLoginPass', lpass);
964
966
  let methodsOnly = [];
965
967
  const allMethods = lpass[1] === '*';
966
968
  let methodIdx = -1;
@@ -979,6 +981,7 @@ const checkUcan = (requiredCapabilities, options) => {
979
981
  /** function for comparing record login id with context login*/
980
982
  const checkLogin = (recordLoginPassId, loginIdPath = '_id') => {
981
983
  const loginCheckId = symbolUcan._get(context.params, `${configuration.entity}.${loginIdPath}`);
984
+ if (options != null && options.log) console.log('checkLogin', loginCheckId, recordLoginPassId);
982
985
  /**Make sure both are present to avoid pass on undefined*/
983
986
  if (loginCheckId && recordLoginPassId) {
984
987
  /** change login path result to array no matter what */
@@ -989,7 +992,11 @@ const checkUcan = (requiredCapabilities, options) => {
989
992
  const checkId = String(checkArr[i]);
990
993
  for (let rl = 0; rl < recordLoginPassId.length;) {
991
994
  const rlId = String(recordLoginPassId[rl]);
992
- if (rlId === checkId) loginOk = true;else rl++;
995
+ if (rlId === checkId) {
996
+ // Found a matching login id; mark success and break out of the inner loop
997
+ loginOk = true;
998
+ break;
999
+ } else rl++;
993
1000
  }
994
1001
  if (loginOk) return;
995
1002
  }