@authup/client-web-kit 1.0.0-beta.28 → 1.0.0-beta.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.
@@ -1,9 +1,11 @@
1
1
  export declare const AClientRoleAssignments: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
2
  entityId: StringConstructor;
3
+ realmId: StringConstructor;
3
4
  }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
4
5
  [key: string]: any;
5
6
  }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
6
7
  entityId: StringConstructor;
8
+ realmId: StringConstructor;
7
9
  }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
8
10
  export default AClientRoleAssignments;
9
11
  //# sourceMappingURL=AClientRoleAssignments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AClientRoleAssignments.d.ts","sourceRoot":"","sources":["../../../../src/components/entities/client-role/AClientRoleAssignments.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,sBAAsB;;;;;;iGAiBjC,CAAC;AAEH,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"AClientRoleAssignments.d.ts","sourceRoot":"","sources":["../../../../src/components/entities/client-role/AClientRoleAssignments.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,sBAAsB;;;;;;;;iGAwBjC,CAAC;AAEH,eAAe,sBAAsB,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { PermissionCheckerCheckOptions, PolicyInput } from '@authup/access';
1
+ import type { PermissionCheckerCheckOptions } from '@authup/access';
2
2
  import type { PropType } from 'vue';
3
3
  export declare const APermissionCheck: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
4
  name: {
@@ -6,7 +6,7 @@ export declare const APermissionCheck: import("vue").DefineComponent<import("vue
6
6
  required: true;
7
7
  };
8
8
  input: {
9
- type: PropType<PolicyInput>;
9
+ type: PropType<Record<string, any>>;
10
10
  };
11
11
  options: {
12
12
  type: PropType<PermissionCheckerCheckOptions>;
@@ -21,7 +21,7 @@ export declare const APermissionCheck: import("vue").DefineComponent<import("vue
21
21
  required: true;
22
22
  };
23
23
  input: {
24
- type: PropType<PolicyInput>;
24
+ type: PropType<Record<string, any>>;
25
25
  };
26
26
  options: {
27
27
  type: PropType<PermissionCheckerCheckOptions>;
@@ -1 +1 @@
1
- {"version":3,"file":"APermissionCheck.d.ts","sourceRoot":"","sources":["../../../../src/components/entities/permission/APermissionCheck.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,6BAA6B,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAIpC,eAAO,MAAM,gBAAgB;;cAGQ,QAAQ,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;;;;cAIpC,QAAQ,CAAC,WAAW,CAAC;;;cAGrB,QAAQ,CAAC,6BAA6B,CAAC;;;;;;;;cAP9B,QAAQ,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;;;;cAIpC,QAAQ,CAAC,WAAW,CAAC;;;cAGrB,QAAQ,CAAC,6BAA6B,CAAC;;iGAuBjE,CAAC"}
1
+ {"version":3,"file":"APermissionCheck.d.ts","sourceRoot":"","sources":["../../../../src/components/entities/permission/APermissionCheck.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAGpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAIpC,eAAO,MAAM,gBAAgB;;cAGQ,QAAQ,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;;;;cAIpC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;;;cAG7B,QAAQ,CAAC,6BAA6B,CAAC;;;;;;;;cAP9B,QAAQ,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;;;;cAIpC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;;;cAG7B,QAAQ,CAAC,6BAA6B,CAAC;;iGAuBjE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../../src/components/utility/entity/record/module.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAYtD,OAAO,KAAK,EAER,aAAa,EACb,0BAA0B,EAG7B,MAAM,SAAS,CAAC;AAmbjB,wBAAgB,mBAAmB,CAC/B,IAAI,SAAS,MAAM,aAAa,EAEhC,GAAG,EAAE,0BAA0B,CAAC,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,GAC1D,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAErC"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../../src/components/utility/entity/record/module.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAatD,OAAO,KAAK,EAER,aAAa,EACb,0BAA0B,EAG7B,MAAM,SAAS,CAAC;AAgbjB,wBAAgB,mBAAmB,CAC/B,IAAI,SAAS,MAAM,aAAa,EAEhC,GAAG,EAAE,0BAA0B,CAAC,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,GAC1D,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAErC"}
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/core/permission-check/module.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,2BAA2B,EAAE,wCAAwC,EAAE,MAAM,SAAS,CAAC;AAErG,wBAAgB,iCAAiC,CAC7C,GAAG,GAAE,wCAA6C,GAClD,2BAA2B,CAoF9B"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/core/permission-check/module.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,2BAA2B,EAAE,wCAAwC,EAAE,MAAM,SAAS,CAAC;AAErG,wBAAgB,iCAAiC,CAC7C,GAAG,GAAE,wCAA6C,GAClD,2BAA2B,CAoF9B"}
package/dist/index.mjs CHANGED
@@ -1,127 +1,31 @@
1
1
  import installFormControl, { VCFormGroup, VCFormInput, buildFormSubmit, buildFormInputText, buildFormGroup, buildFormInput, buildFormTextarea, buildFormInputCheckbox, VCFormInputCheckbox } from '@vuecs/form-controls';
2
2
  import { hasOwnProperty, isObject as isObject$1, merge, createMerger } from 'smob';
3
- import { hasInjectionContext, inject as inject$3, provide as provide$2, defineComponent, reactive, resolveComponent, createBlock, openBlock, withCtx, createVNode, createElementVNode, withModifiers, ref, computed, getCurrentScope, onScopeDispose, shallowRef, toRaw, isRef, isReactive, toRef, watchEffect, unref, onMounted, watch, onUnmounted, h, createElementBlock, renderSlot, createTextVNode, createCommentVNode, Fragment, renderList, mergeProps, getCurrentInstance, resolveDynamicComponent, toDisplayString, nextTick, normalizeClass, Suspense } from 'vue';
3
+ import { hasInjectionContext, inject as inject$3, provide as provide$2, defineComponent, reactive, resolveComponent, openBlock, createBlock, withCtx, createVNode, createElementVNode, withModifiers, ref, computed, getCurrentScope, onScopeDispose, shallowRef, toRaw, isRef, isReactive, toRef, watchEffect, unref, onMounted, watch, onUnmounted, h, createElementBlock, renderSlot, createTextVNode, createCommentVNode, Fragment, renderList, mergeProps, getCurrentInstance, resolveDynamicComponent, toDisplayString, nextTick, normalizeClass, Suspense } from 'vue';
4
4
  import installPagination, { buildPagination as buildPagination$1 } from '@vuecs/pagination';
5
5
  import { REALM_MASTER_NAME, EntityDefaultEventName, buildEntityChannelName, EntityType, IdentityProviderProtocol, IdentityProviderPreset, getIdentityProviderProtocolForPreset, isUserFakeEmail, buildUserFakeEmail } from '@authup/core-kit';
6
6
  import { IVuelidate, useTranslationsForNestedValidations, useTranslationsForBaseValidation as useTranslationsForBaseValidation$1, getSeverity, install as install$1 } from '@ilingo/vuelidate';
7
7
  import useVuelidate from '@vuelidate/core';
8
- import { maxLength, minLength, required, helpers, numeric, url, maxValue, minValue, email, sameAs } from '@vuelidate/validators';
8
+ import { required, maxLength, minLength, helpers, numeric, url, maxValue, minValue, email, sameAs } from '@vuelidate/validators';
9
9
  import { SlotName, buildList } from '@vuecs/list-controls';
10
10
  import { Client, CookieName, ClientAuthenticationHook, ClientAuthenticationHookEventName } from '@authup/core-http-kit';
11
11
  import { defineStore, storeToRefs as storeToRefs$1 } from 'pinia';
12
- import { PermissionMemoryProvider, PermissionChecker, PolicyEngine, TimePolicyInterval, isIntervalForDayOfWeek, isIntervalForDayOfMonth, isIntervalForDayOfYear, BuiltInPolicyType } from '@authup/access';
12
+ import { PermissionMemoryRepository, PermissionChecker, PolicyEngine, PolicyData, BuiltInPolicyType, TimePolicyInterval, isIntervalForDayOfWeek, isIntervalForDayOfMonth, isIntervalForDayOfYear } from '@authup/access';
13
13
  import { OAuth2Error, isOpenIDProviderMetadata, deserializeOAuth2Scope } from '@authup/specs';
14
14
  import { hasOwnProperty as hasOwnProperty$1, extendObject, isObject as isObject$2, createNanoID, isBCryptHash, base64URLEncode } from '@authup/kit';
15
15
  import { SortDirection } from 'rapiq';
16
16
  import { ClientManager, buildEventFullName, EventNameSuffix } from '@authup/core-realtime-kit';
17
17
  import Cookie from 'universal-cookie';
18
18
 
19
- /*
20
- * Copyright (c) 2024-2024.
21
- * Author Peter Placzek (tada5hi)
22
- * For the full copyright and license information,
23
- * view the LICENSE file that was distributed with this source code.
24
- */ const BRACKET_NUMBER_REGEX = RegExp("(?<!\\\\)\\[(\\d+)]$");
25
- /**
26
- * Convert string to property path array.
27
- *
28
- * @see https://github.com/lodash/lodash/blob/main/src/.internal/stringToPath.ts
29
- * @see https://github.com/chaijs/pathval
30
- *
31
- * @param segment
32
- */ function pathToArray(segment) {
33
- const str = segment.replace(/([^\\])\[/g, '$1.[');
34
- const parts = str.match(/(\\\.|[^.]+?)+/g);
35
- if (!parts) {
36
- return [];
37
- }
38
- const result = [];
39
- for(let i = 0; i < parts.length; i++){
40
- if (parts[i] === 'constructor' || parts[i] === '__proto__' || parts[i] === 'prototype') {
41
- continue;
42
- }
43
- const regex = BRACKET_NUMBER_REGEX.exec(parts[i]);
44
- if (regex) {
45
- result.push(regex[1]);
46
- } else {
47
- result.push(parts[i].replace(/\\([.[\]])/g, '$1'));
48
- }
49
- }
50
- return result;
51
- }
52
-
53
19
  /*
54
20
  * Copyright (c) 2024.
55
21
  * Author Peter Placzek (tada5hi)
56
22
  * For the full copyright and license information,
57
23
  * view the LICENSE file that was distributed with this source code.
58
- */ var Character;
24
+ */ var Character$1;
59
25
  (function(Character) {
60
26
  Character["WILDCARD"] = "*";
61
27
  Character["GLOBSTAR"] = "**";
62
- })(Character || (Character = {}));
63
-
64
- /*
65
- * Copyright (c) 2024.
66
- * Author Peter Placzek (tada5hi)
67
- * For the full copyright and license information,
68
- * view the LICENSE file that was distributed with this source code.
69
- */ function isObject(input) {
70
- return !!input && typeof input === 'object' && !Array.isArray(input);
71
- }
72
-
73
- function getPathValue(data, path) {
74
- const parts = Array.isArray(path) ? path : pathToArray(path);
75
- let res;
76
- let temp = data;
77
- let index = 0;
78
- while(index < parts.length){
79
- if (temp === null || typeof temp === 'undefined') {
80
- break;
81
- }
82
- if (parts[index] in Object(temp)) {
83
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
84
- // @ts-expect-error
85
- temp = temp[parts[index]];
86
- } else {
87
- break;
88
- }
89
- if (index === parts.length - 1) {
90
- res = temp;
91
- }
92
- index++;
93
- }
94
- return res;
95
- }
96
-
97
- const NUMBER_REGEX = /^\d+$/;
98
- function setPathValue(data, path, value) {
99
- const parts = Array.isArray(path) ? path : pathToArray(path);
100
- let temp = data;
101
- let index = 0;
102
- while(index < parts.length){
103
- /* istanbul ignore next */ if (!Array.isArray(temp) && !isObject(temp)) {
104
- break;
105
- }
106
- const key = parts[index];
107
- // [foo, '0']
108
- if (typeof temp[key] === 'undefined') {
109
- const match = NUMBER_REGEX.test(key);
110
- if (match) {
111
- temp[key] = [];
112
- } else {
113
- temp[key] = {};
114
- }
115
- }
116
- if (index === parts.length - 1) {
117
- temp[key] = value;
118
- break;
119
- }
120
- index++;
121
- temp = temp[key];
122
- }
123
- return data;
124
- }
28
+ })(Character$1 || (Character$1 = {}));
125
29
 
126
30
  class Store {
127
31
  /**
@@ -533,9 +437,9 @@ function createStore(context) {
533
437
  context.dispatcher.emit(StoreDispatcherEventName.REALM_MANAGEMENT_UPDATED, input);
534
438
  };
535
439
  // --------------------------------------------------------------------
536
- const permissionRepository = new PermissionMemoryProvider();
440
+ const permissionRepository = new PermissionMemoryRepository();
537
441
  const permissionChecker = new PermissionChecker({
538
- provider: permissionRepository,
442
+ repository: permissionRepository,
539
443
  policyEngine: new PolicyEngine()
540
444
  });
541
445
  // --------------------------------------------------------------------
@@ -1145,7 +1049,118 @@ var TranslatorTranslationDefaultKey = /*#__PURE__*/ function(TranslatorTranslati
1145
1049
  return TranslatorTranslationDefaultKey;
1146
1050
  }({});
1147
1051
 
1052
+ /*
1053
+ * Copyright (c) 2024-2024.
1054
+ * Author Peter Placzek (tada5hi)
1055
+ * For the full copyright and license information,
1056
+ * view the LICENSE file that was distributed with this source code.
1057
+ */ const BRACKET_NUMBER_REGEX = RegExp("(?<!\\\\)\\[(\\d+)]$");
1058
+ /**
1059
+ * Convert string to property path array.
1060
+ *
1061
+ * @see https://github.com/lodash/lodash/blob/main/src/.internal/stringToPath.ts
1062
+ * @see https://github.com/chaijs/pathval
1063
+ *
1064
+ * @param segment
1065
+ */ function pathToArray(segment) {
1066
+ const str = segment.replace(/([^\\])\[/g, '$1.[');
1067
+ const parts = str.match(/(\\\.|[^.]+?)+/g);
1068
+ if (!parts) {
1069
+ return [];
1070
+ }
1071
+ const result = [];
1072
+ for(let i = 0; i < parts.length; i++){
1073
+ if (parts[i] === 'constructor' || parts[i] === '__proto__' || parts[i] === 'prototype') {
1074
+ continue;
1075
+ }
1076
+ const regex = BRACKET_NUMBER_REGEX.exec(parts[i]);
1077
+ if (regex) {
1078
+ result.push(regex[1]);
1079
+ } else {
1080
+ result.push(parts[i].replace(/\\([.[\]])/g, '$1'));
1081
+ }
1082
+ }
1083
+ return result;
1084
+ }
1085
+
1086
+ /*
1087
+ * Copyright (c) 2024.
1088
+ * Author Peter Placzek (tada5hi)
1089
+ * For the full copyright and license information,
1090
+ * view the LICENSE file that was distributed with this source code.
1091
+ */ var Character;
1092
+ (function(Character) {
1093
+ Character["WILDCARD"] = "*";
1094
+ Character["GLOBSTAR"] = "**";
1095
+ })(Character || (Character = {}));
1096
+
1097
+ /*
1098
+ * Copyright (c) 2024.
1099
+ * Author Peter Placzek (tada5hi)
1100
+ * For the full copyright and license information,
1101
+ * view the LICENSE file that was distributed with this source code.
1102
+ */ function isObject(input) {
1103
+ return !!input && typeof input === 'object' && !Array.isArray(input);
1104
+ }
1105
+
1106
+ function getPathValue(data, path) {
1107
+ const parts = Array.isArray(path) ? path : pathToArray(path);
1108
+ let res;
1109
+ let temp = data;
1110
+ let index = 0;
1111
+ while(index < parts.length){
1112
+ if (temp === null || typeof temp === 'undefined') {
1113
+ break;
1114
+ }
1115
+ if (parts[index] in Object(temp)) {
1116
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1117
+ // @ts-expect-error
1118
+ temp = temp[parts[index]];
1119
+ } else {
1120
+ break;
1121
+ }
1122
+ if (index === parts.length - 1) {
1123
+ res = temp;
1124
+ }
1125
+ index++;
1126
+ }
1127
+ return res;
1128
+ }
1129
+
1130
+ const NUMBER_REGEX = /^\d+$/;
1131
+ function setPathValue(data, path, value) {
1132
+ const parts = Array.isArray(path) ? path : pathToArray(path);
1133
+ let temp = data;
1134
+ let index = 0;
1135
+ while(index < parts.length){
1136
+ /* istanbul ignore next */ if (!Array.isArray(temp) && !isObject(temp)) {
1137
+ break;
1138
+ }
1139
+ const key = parts[index];
1140
+ // [foo, '0']
1141
+ if (typeof temp[key] === 'undefined') {
1142
+ const match = NUMBER_REGEX.test(key);
1143
+ if (match) {
1144
+ temp[key] = [];
1145
+ } else {
1146
+ temp[key] = {};
1147
+ }
1148
+ }
1149
+ if (index === parts.length - 1) {
1150
+ temp[key] = value;
1151
+ break;
1152
+ }
1153
+ index++;
1154
+ temp = temp[key];
1155
+ }
1156
+ return data;
1157
+ }
1158
+
1148
1159
  class MemoryStore {
1160
+ data;
1161
+ constructor(options){
1162
+ this.data = options.data;
1163
+ }
1149
1164
  async get(context) {
1150
1165
  if (!this.data[context.locale] || !this.data[context.locale][context.group]) {
1151
1166
  return undefined;
@@ -1171,9 +1186,6 @@ class MemoryStore {
1171
1186
  async getLocales() {
1172
1187
  return Object.keys(this.data);
1173
1188
  }
1174
- constructor(options){
1175
- this.data = options.data;
1176
- }
1177
1189
  }
1178
1190
 
1179
1191
  typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
@@ -1578,13 +1590,12 @@ function createPermissionCheckerReactiveFn(ctx = {}) {
1578
1590
  }
1579
1591
  }
1580
1592
  let outcome;
1593
+ const input = ctx.input || new PolicyData();
1594
+ input.set(BuiltInPolicyType.IDENTITY, identity);
1581
1595
  try {
1582
1596
  computePromise = store.permissionChecker.preCheckOneOf({
1583
1597
  ...ctx,
1584
- input: {
1585
- ...ctx.input || {},
1586
- identity
1587
- }
1598
+ input
1588
1599
  }).then(()=>true).catch(()=>false);
1589
1600
  outcome = await computePromise;
1590
1601
  } catch (e) {
@@ -2636,12 +2647,12 @@ function create(ctx) {
2636
2647
  return;
2637
2648
  }
2638
2649
  if (ctx.props.queryFilters) {
2639
- query = {
2640
- filters: ctx.props.queryFilters
2641
- };
2642
- if (query && ctx.props.queryFields) {
2643
- query.fields = ctx.props.queryFields;
2644
- }
2650
+ query = query || {};
2651
+ query.filters = ctx.props.queryFilters;
2652
+ }
2653
+ if (ctx.props.queryFields) {
2654
+ query = query || {};
2655
+ query.fields = ctx.props.queryFields;
2645
2656
  }
2646
2657
  if (ctx.props.entityId) {
2647
2658
  id = ctx.props.entityId;
@@ -4155,7 +4166,7 @@ const APermissionCheck = defineComponent({
4155
4166
  const fn = createPermissionCheckerReactiveFn();
4156
4167
  const isPermitted = computed(()=>fn({
4157
4168
  name: props.name,
4158
- input: props.input,
4169
+ input: new PolicyData(props.input),
4159
4170
  options: props.options
4160
4171
  }));
4161
4172
  return ()=>{
@@ -4765,10 +4776,22 @@ const AClientRoleAssignment = defineComponent({
4765
4776
 
4766
4777
  const AClientRoleAssignments = defineComponent({
4767
4778
  props: {
4768
- entityId: String
4779
+ entityId: String,
4780
+ realmId: String
4769
4781
  },
4770
4782
  setup (props, { slots }) {
4771
- return ()=>h(ARoles, {}, {
4783
+ return ()=>h(ARoles, {
4784
+ query: {
4785
+ filters: {
4786
+ realm_id: [
4787
+ ...props.realmId ? [
4788
+ props.realmId
4789
+ ] : [],
4790
+ null
4791
+ ]
4792
+ }
4793
+ }
4794
+ }, {
4772
4795
  [SlotName.ITEM_ACTIONS]: (slotProps)=>h(AClientRoleAssignment, {
4773
4796
  clientId: props.entityId,
4774
4797
  roleId: slotProps.data.id,