@authup/client-web-kit 1.0.0-beta.10 → 1.0.0-beta.13

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 (101) hide show
  1. package/dist/components/AEntityDelete.d.ts +7 -7
  2. package/dist/components/client/AClient.d.ts +2 -2
  3. package/dist/components/client/AClientForm.d.ts +3 -3
  4. package/dist/components/client/AClientRedirectUrisItem.d.ts +2 -2
  5. package/dist/components/client/AClients.d.ts +6 -6
  6. package/dist/components/client-scope/AClientScope.d.ts +2 -2
  7. package/dist/components/client-scope/AClientScopeAssignment.d.ts +2 -2
  8. package/dist/components/client-scope/AClientScopes.d.ts +6 -6
  9. package/dist/components/identity-provider/AIdentityProvider.d.ts +2 -2
  10. package/dist/components/identity-provider/AIdentityProviderBasicFields.d.ts +3 -1
  11. package/dist/components/identity-provider/AIdentityProviderBasicFields.d.ts.map +1 -1
  12. package/dist/components/identity-provider/AIdentityProviderForm.d.ts +3 -3
  13. package/dist/components/identity-provider/AIdentityProviderLdapForm.d.ts +3 -3
  14. package/dist/components/identity-provider/AIdentityProviderOAuth2Discovery.d.ts +3 -2
  15. package/dist/components/identity-provider/AIdentityProviderOAuth2Discovery.d.ts.map +1 -1
  16. package/dist/components/identity-provider/AIdentityProviderOAuth2Form.d.ts +3 -3
  17. package/dist/components/identity-provider/AIdentityProviders.d.ts +6 -6
  18. package/dist/components/identity-provider-role/AIdentityProviderRoleAssignment.d.ts +2 -2
  19. package/dist/components/permission/APermission.d.ts +2 -2
  20. package/dist/components/permission/APermissionForm.d.ts +4 -8
  21. package/dist/components/permission/APermissionForm.d.ts.map +1 -1
  22. package/dist/components/permission/APermissions.d.ts +6 -6
  23. package/dist/components/realm/ARealm.d.ts +2 -2
  24. package/dist/components/realm/ARealmForm.d.ts +2 -2
  25. package/dist/components/realm/ARealms.d.ts +6 -6
  26. package/dist/components/realm/helpers/form-picker.d.ts +7 -0
  27. package/dist/components/realm/helpers/form-picker.d.ts.map +1 -0
  28. package/dist/components/realm/helpers/index.d.ts +2 -0
  29. package/dist/components/realm/helpers/index.d.ts.map +1 -0
  30. package/dist/components/robot/ARobot.d.ts +2 -2
  31. package/dist/components/robot/ARobotForm.d.ts +3 -3
  32. package/dist/components/robot/ARobots.d.ts +6 -6
  33. package/dist/components/robot-permission/ARobotPermissionAssignment.d.ts +2 -2
  34. package/dist/components/robot-role/ARobotRoleAssignment.d.ts +2 -2
  35. package/dist/components/role/ARole.d.ts +2 -2
  36. package/dist/components/role/ARoleForm.d.ts +2 -2
  37. package/dist/components/role/ARoleForm.d.ts.map +1 -1
  38. package/dist/components/role/ARoles.d.ts +6 -6
  39. package/dist/components/role-permission/ARolePermissionAssignment.d.ts +2 -2
  40. package/dist/components/scope/AScope.d.ts +2 -2
  41. package/dist/components/scope/AScopeForm.d.ts +2 -14
  42. package/dist/components/scope/AScopeForm.d.ts.map +1 -1
  43. package/dist/components/scope/AScopes.d.ts +6 -6
  44. package/dist/components/user/AUser.d.ts +2 -2
  45. package/dist/components/user/AUserForm.d.ts +3 -3
  46. package/dist/components/user/AUserPasswordForm.d.ts +3 -3
  47. package/dist/components/user/AUsers.d.ts +6 -6
  48. package/dist/components/user-permission/AUserPermissionAssignment.d.ts +2 -2
  49. package/dist/components/user-role/AUserRoleAssignment.d.ts +2 -2
  50. package/dist/components/utility/search/ASearch.d.ts +3 -1
  51. package/dist/components/utility/search/ASearch.d.ts.map +1 -1
  52. package/dist/components/utility/search/module.d.ts +3 -2
  53. package/dist/components/utility/search/module.d.ts.map +1 -1
  54. package/dist/composables/index.d.ts +2 -0
  55. package/dist/composables/index.d.ts.map +1 -1
  56. package/dist/composables/use-ability-check.d.ts +3 -0
  57. package/dist/composables/use-ability-check.d.ts.map +1 -0
  58. package/dist/composables/use-realm-resource-writable-check.d.ts +3 -0
  59. package/dist/composables/use-realm-resource-writable-check.d.ts.map +1 -0
  60. package/dist/core/http-client/index.d.ts +4 -0
  61. package/dist/core/http-client/index.d.ts.map +1 -0
  62. package/dist/core/http-client/install.d.ts +4 -0
  63. package/dist/core/http-client/install.d.ts.map +1 -0
  64. package/dist/core/http-client/singleton.d.ts +7 -0
  65. package/dist/core/http-client/singleton.d.ts.map +1 -0
  66. package/dist/core/http-client/types.d.ts +4 -0
  67. package/dist/core/http-client/types.d.ts.map +1 -0
  68. package/dist/core/index.d.ts +1 -1
  69. package/dist/core/index.d.ts.map +1 -1
  70. package/dist/core/socket-client-manager/index.d.ts +1 -0
  71. package/dist/core/socket-client-manager/index.d.ts.map +1 -1
  72. package/dist/core/socket-client-manager/install.d.ts +6 -0
  73. package/dist/core/socket-client-manager/install.d.ts.map +1 -0
  74. package/dist/core/store/constants.d.ts +2 -0
  75. package/dist/core/store/constants.d.ts.map +1 -0
  76. package/dist/core/store/{module.d.ts → create.d.ts} +12 -7
  77. package/dist/core/store/create.d.ts.map +1 -0
  78. package/dist/core/store/index.d.ts +4 -2
  79. package/dist/core/store/index.d.ts.map +1 -1
  80. package/dist/core/store/install.d.ts +4 -0
  81. package/dist/core/store/install.d.ts.map +1 -0
  82. package/dist/core/store/singleton.d.ts +6 -7
  83. package/dist/core/store/singleton.d.ts.map +1 -1
  84. package/dist/core/store/types.d.ts +26 -0
  85. package/dist/core/store/types.d.ts.map +1 -0
  86. package/dist/index.cjs +1351 -493
  87. package/dist/index.cjs.map +1 -1
  88. package/dist/index.d.ts +6 -5
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.mjs +1347 -501
  91. package/dist/index.mjs.map +1 -1
  92. package/dist/module.d.ts +5 -0
  93. package/dist/module.d.ts.map +1 -0
  94. package/dist/types.d.ts +9 -8
  95. package/dist/types.d.ts.map +1 -1
  96. package/package.json +16 -13
  97. package/dist/core/api-client.d.ts +0 -6
  98. package/dist/core/api-client.d.ts.map +0 -1
  99. package/dist/core/store/module.d.ts.map +0 -1
  100. package/dist/core/store/type.d.ts +0 -13
  101. package/dist/core/store/type.d.ts.map +0 -1
package/dist/index.cjs CHANGED
@@ -2,152 +2,1167 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var smob = require('smob');
6
- var vue = require('vue');
7
5
  var coreKit = require('@authup/core-kit');
6
+ var vue = require('vue');
7
+ var coreHttpKit = require('@authup/core-http-kit');
8
8
  var kit = require('@authup/kit');
9
+ var smob = require('smob');
9
10
  var listControls = require('@vuecs/list-controls');
10
- var coreHttpKit = require('@authup/core-http-kit');
11
+ var coreRealtimeKit = require('@authup/core-realtime-kit');
11
12
  var rapiq = require('rapiq');
12
13
  var formControls = require('@vuecs/form-controls');
13
14
  var vuelidate = require('@ilingo/vuelidate');
14
15
  var validators = require('@vuelidate/validators');
15
16
  var useVuelidate = require('@vuelidate/core');
16
17
  var pagination = require('@vuecs/pagination');
18
+ var Cookie = require('universal-cookie');
19
+
20
+ function inject$1(key, instance) {
21
+ if (instance && instance._context && instance._context.provides && instance._context.provides[key]) {
22
+ return instance._context.provides[key];
23
+ }
24
+ if (vue.hasInjectionContext()) {
25
+ return vue.inject(key, undefined);
26
+ }
27
+ return undefined;
28
+ }
17
29
 
18
- var StoreName;
19
- (function(StoreName) {
20
- StoreName["DEFAULT"] = "default";
21
- })(StoreName || (StoreName = {}));
22
- class Store {
30
+ function provide(key, value, app) {
31
+ if (typeof app === 'undefined') {
32
+ const val = inject$1(key);
33
+ if (typeof val !== 'undefined') {
34
+ return;
35
+ }
36
+ vue.provide(key, value);
37
+ return;
38
+ }
39
+ if (app && app._context && app._context.provides && app._context.provides[key]) {
40
+ return;
41
+ }
42
+ app.provide(key, value);
43
+ }
44
+
45
+ const HTTPClientSymbol = Symbol.for('AuthupHTTPClient');
46
+ function provideHTTPClient(client, app) {
47
+ provide(HTTPClientSymbol, client, app);
48
+ }
49
+ function hasHTTPClient(app) {
50
+ return !!inject$1(HTTPClientSymbol, app);
51
+ }
52
+ function injectHTTPClient(app) {
53
+ const instance = inject$1(HTTPClientSymbol, app);
54
+ if (!instance) {
55
+ throw new Error('The api client has not been injected.');
56
+ }
57
+ return instance;
58
+ }
59
+
60
+ var isVue2 = false;
61
+ function set(target, key, val) {
62
+ if (Array.isArray(target)) {
63
+ target.length = Math.max(target.length, key);
64
+ target.splice(key, 1, val);
65
+ return val;
66
+ }
67
+ target[key] = val;
68
+ return val;
69
+ }
70
+ function del(target, key) {
71
+ if (Array.isArray(target)) {
72
+ target.splice(key, 1);
73
+ return;
74
+ }
75
+ delete target[key];
76
+ }
77
+
78
+ /**
79
+ * setActivePinia must be called to handle SSR at the top of functions like
80
+ * `fetch`, `setup`, `serverPrefetch` and others
81
+ */ let activePinia;
82
+ /**
83
+ * Sets or unsets the active pinia. Used in SSR and internally when calling
84
+ * actions and getters
85
+ *
86
+ * @param pinia - Pinia instance
87
+ */ // @ts-expect-error: cannot constrain the type of the return
88
+ const setActivePinia = (pinia)=>activePinia = pinia;
89
+ const piniaSymbol = process.env.NODE_ENV !== 'production' ? Symbol('pinia') : /* istanbul ignore next */ Symbol();
90
+ function isPlainObject(// eslint-disable-next-line @typescript-eslint/no-explicit-any
91
+ o) {
92
+ return o && typeof o === 'object' && Object.prototype.toString.call(o) === '[object Object]' && typeof o.toJSON !== 'function';
93
+ }
94
+ // type DeepReadonly<T> = { readonly [P in keyof T]: DeepReadonly<T[P]> }
95
+ // TODO: can we change these to numbers?
96
+ /**
97
+ * Possible types for SubscriptionCallback
98
+ */ var MutationType;
99
+ (function(MutationType) {
100
+ /**
101
+ * Direct mutation of the state:
102
+ *
103
+ * - `store.name = 'new name'`
104
+ * - `store.$state.name = 'new name'`
105
+ * - `store.list.push('new item')`
106
+ */ MutationType["direct"] = "direct";
23
107
  /**
24
- * Set options for all groups.
108
+ * Mutated the state with `$patch` and an object
25
109
  *
26
- * @param items
27
- */ setAll(items) {
28
- const keys = Object.keys(items);
110
+ * - `store.$patch({ name: 'newName' })`
111
+ */ MutationType["patchObject"] = "patch object";
112
+ /**
113
+ * Mutated the state with `$patch` and a function
114
+ *
115
+ * - `store.$patch(state => state.name = 'newName')`
116
+ */ MutationType["patchFunction"] = "patch function";
117
+ // maybe reset? for $state = {} and $reset
118
+ })(MutationType || (MutationType = {}));
119
+ const IS_CLIENT = typeof window !== 'undefined';
120
+ /**
121
+ * Should we add the devtools plugins.
122
+ * - only if dev mode or forced through the prod devtools flag
123
+ * - not in test
124
+ * - only if window exists (could change in the future)
125
+ */ const USE_DEVTOOLS = (process.env.NODE_ENV !== 'production' || typeof __VUE_PROD_DEVTOOLS__ !== 'undefined' && __VUE_PROD_DEVTOOLS__) && !(process.env.NODE_ENV === 'test') && IS_CLIENT;
126
+ /**
127
+ * Mutates in place `newState` with `oldState` to _hot update_ it. It will
128
+ * remove any key not existing in `newState` and recursively merge plain
129
+ * objects.
130
+ *
131
+ * @param newState - new state object to be patched
132
+ * @param oldState - old state that should be used to patch newState
133
+ * @returns - newState
134
+ */ function patchObject(newState, oldState) {
135
+ // no need to go through symbols because they cannot be serialized anyway
136
+ for(const key in oldState){
137
+ const subPatch = oldState[key];
138
+ // skip the whole sub tree
139
+ if (!(key in newState)) {
140
+ continue;
141
+ }
142
+ const targetValue = newState[key];
143
+ if (isPlainObject(targetValue) && isPlainObject(subPatch) && !vue.isRef(subPatch) && !vue.isReactive(subPatch)) {
144
+ newState[key] = patchObject(targetValue, subPatch);
145
+ } else {
146
+ // objects are either a bit more complex (e.g. refs) or primitives, so we
147
+ // just set the whole thing
148
+ {
149
+ newState[key] = subPatch;
150
+ }
151
+ }
152
+ }
153
+ return newState;
154
+ }
155
+ const noop$1 = ()=>{};
156
+ function addSubscription(subscriptions, callback, detached, onCleanup = noop$1) {
157
+ subscriptions.push(callback);
158
+ const removeSubscription = ()=>{
159
+ const idx = subscriptions.indexOf(callback);
160
+ if (idx > -1) {
161
+ subscriptions.splice(idx, 1);
162
+ onCleanup();
163
+ }
164
+ };
165
+ if (!detached && vue.getCurrentScope()) {
166
+ vue.onScopeDispose(removeSubscription);
167
+ }
168
+ return removeSubscription;
169
+ }
170
+ function triggerSubscriptions(subscriptions, ...args) {
171
+ subscriptions.slice().forEach((callback)=>{
172
+ callback(...args);
173
+ });
174
+ }
175
+ const fallbackRunWithContext = (fn)=>fn();
176
+ function mergeReactiveObjects(target, patchToApply) {
177
+ // Handle Map instances
178
+ if (target instanceof Map && patchToApply instanceof Map) {
179
+ patchToApply.forEach((value, key)=>target.set(key, value));
180
+ }
181
+ // Handle Set instances
182
+ if (target instanceof Set && patchToApply instanceof Set) {
183
+ patchToApply.forEach(target.add, target);
184
+ }
185
+ // no need to go through symbols because they cannot be serialized anyway
186
+ for(const key in patchToApply){
187
+ if (!patchToApply.hasOwnProperty(key)) continue;
188
+ const subPatch = patchToApply[key];
189
+ const targetValue = target[key];
190
+ if (isPlainObject(targetValue) && isPlainObject(subPatch) && target.hasOwnProperty(key) && !vue.isRef(subPatch) && !vue.isReactive(subPatch)) {
191
+ // NOTE: here I wanted to warn about inconsistent types but it's not possible because in setup stores one might
192
+ // start the value of a property as a certain type e.g. a Map, and then for some reason, during SSR, change that
193
+ // to `undefined`. When trying to hydrate, we want to override the Map with `undefined`.
194
+ target[key] = mergeReactiveObjects(targetValue, subPatch);
195
+ } else {
196
+ // @ts-expect-error: subPatch is a valid value
197
+ target[key] = subPatch;
198
+ }
199
+ }
200
+ return target;
201
+ }
202
+ const skipHydrateSymbol = process.env.NODE_ENV !== 'production' ? Symbol('pinia:skipHydration') : /* istanbul ignore next */ Symbol();
203
+ /**
204
+ * Returns whether a value should be hydrated
205
+ *
206
+ * @param obj - target variable
207
+ * @returns true if `obj` should be hydrated
208
+ */ function shouldHydrate(obj) {
209
+ return !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol);
210
+ }
211
+ const { assign } = Object;
212
+ function isComputed(o) {
213
+ return !!(vue.isRef(o) && o.effect);
214
+ }
215
+ function createOptionsStore(id, options, pinia, hot) {
216
+ const { state, actions, getters } = options;
217
+ const initialState = pinia.state.value[id];
218
+ let store;
219
+ function setup() {
220
+ if (!initialState && (!(process.env.NODE_ENV !== 'production') || !hot)) {
221
+ /* istanbul ignore if */ {
222
+ pinia.state.value[id] = state ? state() : {};
223
+ }
224
+ }
225
+ // avoid creating a state in pinia.state.value
226
+ const localState = process.env.NODE_ENV !== 'production' && hot ? vue.toRefs(vue.ref(state ? state() : {}).value) : vue.toRefs(pinia.state.value[id]);
227
+ return assign(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name)=>{
228
+ if (process.env.NODE_ENV !== 'production' && name in localState) {
229
+ console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${name}" in store "${id}".`);
230
+ }
231
+ computedGetters[name] = vue.markRaw(vue.computed(()=>{
232
+ setActivePinia(pinia);
233
+ // it was created just before
234
+ const store = pinia._s.get(id);
235
+ // @ts-expect-error
236
+ // return getters![name].call(context, context)
237
+ // TODO: avoid reading the getter while assigning with a global variable
238
+ return getters[name].call(store, store);
239
+ }));
240
+ return computedGetters;
241
+ }, {}));
242
+ }
243
+ store = createSetupStore(id, setup, options, pinia, hot, true);
244
+ return store;
245
+ }
246
+ function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
247
+ let scope;
248
+ const optionsForPlugin = assign({
249
+ actions: {}
250
+ }, options);
251
+ /* istanbul ignore if */ if (process.env.NODE_ENV !== 'production' && !pinia._e.active) {
252
+ throw new Error('Pinia destroyed');
253
+ }
254
+ // watcher options for $subscribe
255
+ const $subscribeOptions = {
256
+ deep: true
257
+ };
258
+ /* istanbul ignore else */ if (process.env.NODE_ENV !== 'production' && !isVue2) {
259
+ $subscribeOptions.onTrigger = (event)=>{
260
+ /* istanbul ignore else */ if (isListening) {
261
+ debuggerEvents = event;
262
+ // avoid triggering this while the store is being built and the state is being set in pinia
263
+ } else if (isListening == false && !store._hotUpdating) {
264
+ // let patch send all the events together later
265
+ /* istanbul ignore else */ if (Array.isArray(debuggerEvents)) {
266
+ debuggerEvents.push(event);
267
+ } else {
268
+ console.error('🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug.');
269
+ }
270
+ }
271
+ };
272
+ }
273
+ // internal state
274
+ let isListening; // set to true at the end
275
+ let isSyncListening; // set to true at the end
276
+ let subscriptions = [];
277
+ let actionSubscriptions = [];
278
+ let debuggerEvents;
279
+ const initialState = pinia.state.value[$id];
280
+ // avoid setting the state for option stores if it is set
281
+ // by the setup
282
+ if (!isOptionsStore && !initialState && (!(process.env.NODE_ENV !== 'production') || !hot)) {
283
+ /* istanbul ignore if */ {
284
+ pinia.state.value[$id] = {};
285
+ }
286
+ }
287
+ const hotState = vue.ref({});
288
+ // avoid triggering too many listeners
289
+ // https://github.com/vuejs/pinia/issues/1129
290
+ let activeListener;
291
+ function $patch(partialStateOrMutator) {
292
+ let subscriptionMutation;
293
+ isListening = isSyncListening = false;
294
+ // reset the debugger events since patches are sync
295
+ /* istanbul ignore else */ if (process.env.NODE_ENV !== 'production') {
296
+ debuggerEvents = [];
297
+ }
298
+ if (typeof partialStateOrMutator === 'function') {
299
+ partialStateOrMutator(pinia.state.value[$id]);
300
+ subscriptionMutation = {
301
+ type: MutationType.patchFunction,
302
+ storeId: $id,
303
+ events: debuggerEvents
304
+ };
305
+ } else {
306
+ mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator);
307
+ subscriptionMutation = {
308
+ type: MutationType.patchObject,
309
+ payload: partialStateOrMutator,
310
+ storeId: $id,
311
+ events: debuggerEvents
312
+ };
313
+ }
314
+ const myListenerId = activeListener = Symbol();
315
+ vue.nextTick().then(()=>{
316
+ if (activeListener === myListenerId) {
317
+ isListening = true;
318
+ }
319
+ });
320
+ isSyncListening = true;
321
+ // because we paused the watcher, we need to manually call the subscriptions
322
+ triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]);
323
+ }
324
+ const $reset = isOptionsStore ? function $reset() {
325
+ const { state } = options;
326
+ const newState = state ? state() : {};
327
+ // we use a patch to group all changes into one single subscription
328
+ this.$patch(($state)=>{
329
+ assign($state, newState);
330
+ });
331
+ } : /* istanbul ignore next */ process.env.NODE_ENV !== 'production' ? ()=>{
332
+ throw new Error(`🍍: Store "${$id}" is built using the setup syntax and does not implement $reset().`);
333
+ } : noop$1;
334
+ function $dispose() {
335
+ scope.stop();
336
+ subscriptions = [];
337
+ actionSubscriptions = [];
338
+ pinia._s.delete($id);
339
+ }
340
+ /**
341
+ * Wraps an action to handle subscriptions.
342
+ *
343
+ * @param name - name of the action
344
+ * @param action - action to wrap
345
+ * @returns a wrapped action to handle subscriptions
346
+ */ function wrapAction(name, action) {
347
+ return function() {
348
+ setActivePinia(pinia);
349
+ const args = Array.from(arguments);
350
+ const afterCallbackList = [];
351
+ const onErrorCallbackList = [];
352
+ function after(callback) {
353
+ afterCallbackList.push(callback);
354
+ }
355
+ function onError(callback) {
356
+ onErrorCallbackList.push(callback);
357
+ }
358
+ // @ts-expect-error
359
+ triggerSubscriptions(actionSubscriptions, {
360
+ args,
361
+ name,
362
+ store,
363
+ after,
364
+ onError
365
+ });
366
+ let ret;
367
+ try {
368
+ ret = action.apply(this && this.$id === $id ? this : store, args);
369
+ // handle sync errors
370
+ } catch (error) {
371
+ triggerSubscriptions(onErrorCallbackList, error);
372
+ throw error;
373
+ }
374
+ if (ret instanceof Promise) {
375
+ return ret.then((value)=>{
376
+ triggerSubscriptions(afterCallbackList, value);
377
+ return value;
378
+ }).catch((error)=>{
379
+ triggerSubscriptions(onErrorCallbackList, error);
380
+ return Promise.reject(error);
381
+ });
382
+ }
383
+ // trigger after callbacks
384
+ triggerSubscriptions(afterCallbackList, ret);
385
+ return ret;
386
+ };
387
+ }
388
+ const _hmrPayload = /*#__PURE__*/ vue.markRaw({
389
+ actions: {},
390
+ getters: {},
391
+ state: [],
392
+ hotState
393
+ });
394
+ const partialStore = {
395
+ _p: pinia,
396
+ // _s: scope,
397
+ $id,
398
+ $onAction: addSubscription.bind(null, actionSubscriptions),
399
+ $patch,
400
+ $reset,
401
+ $subscribe (callback, options = {}) {
402
+ const removeSubscription = addSubscription(subscriptions, callback, options.detached, ()=>stopWatcher());
403
+ const stopWatcher = scope.run(()=>vue.watch(()=>pinia.state.value[$id], (state)=>{
404
+ if (options.flush === 'sync' ? isSyncListening : isListening) {
405
+ callback({
406
+ storeId: $id,
407
+ type: MutationType.direct,
408
+ events: debuggerEvents
409
+ }, state);
410
+ }
411
+ }, assign({}, $subscribeOptions, options)));
412
+ return removeSubscription;
413
+ },
414
+ $dispose
415
+ };
416
+ const store = vue.reactive(process.env.NODE_ENV !== 'production' || USE_DEVTOOLS ? assign({
417
+ _hmrPayload,
418
+ _customProperties: vue.markRaw(new Set())
419
+ }, partialStore) : partialStore);
420
+ // store the partial store now so the setup of stores can instantiate each other before they are finished without
421
+ // creating infinite loops.
422
+ pinia._s.set($id, store);
423
+ const runWithContext = pinia._a && pinia._a.runWithContext || fallbackRunWithContext;
424
+ // TODO: idea create skipSerialize that marks properties as non serializable and they are skipped
425
+ const setupStore = runWithContext(()=>pinia._e.run(()=>(scope = vue.effectScope()).run(setup)));
426
+ // overwrite existing actions to support $onAction
427
+ for(const key in setupStore){
428
+ const prop = setupStore[key];
429
+ if (vue.isRef(prop) && !isComputed(prop) || vue.isReactive(prop)) {
430
+ // mark it as a piece of state to be serialized
431
+ if (process.env.NODE_ENV !== 'production' && hot) {
432
+ set(hotState.value, key, vue.toRef(setupStore, key));
433
+ // createOptionStore directly sets the state in pinia.state.value so we
434
+ // can just skip that
435
+ } else if (!isOptionsStore) {
436
+ // in setup stores we must hydrate the state and sync pinia state tree with the refs the user just created
437
+ if (initialState && shouldHydrate(prop)) {
438
+ if (vue.isRef(prop)) {
439
+ prop.value = initialState[key];
440
+ } else {
441
+ // probably a reactive object, lets recursively assign
442
+ // @ts-expect-error: prop is unknown
443
+ mergeReactiveObjects(prop, initialState[key]);
444
+ }
445
+ }
446
+ // transfer the ref to the pinia state to keep everything in sync
447
+ /* istanbul ignore if */ {
448
+ pinia.state.value[$id][key] = prop;
449
+ }
450
+ }
451
+ /* istanbul ignore else */ if (process.env.NODE_ENV !== 'production') {
452
+ _hmrPayload.state.push(key);
453
+ }
454
+ // action
455
+ } else if (typeof prop === 'function') {
456
+ // @ts-expect-error: we are overriding the function we avoid wrapping if
457
+ const actionValue = process.env.NODE_ENV !== 'production' && hot ? prop : wrapAction(key, prop);
458
+ // this a hot module replacement store because the hotUpdate method needs
459
+ // to do it with the right context
460
+ /* istanbul ignore if */ {
461
+ // @ts-expect-error
462
+ setupStore[key] = actionValue;
463
+ }
464
+ /* istanbul ignore else */ if (process.env.NODE_ENV !== 'production') {
465
+ _hmrPayload.actions[key] = prop;
466
+ }
467
+ // list actions so they can be used in plugins
468
+ // @ts-expect-error
469
+ optionsForPlugin.actions[key] = prop;
470
+ } else if (process.env.NODE_ENV !== 'production') {
471
+ // add getters for devtools
472
+ if (isComputed(prop)) {
473
+ _hmrPayload.getters[key] = isOptionsStore ? options.getters[key] : prop;
474
+ if (IS_CLIENT) {
475
+ const getters = setupStore._getters || // @ts-expect-error: same
476
+ (setupStore._getters = vue.markRaw([]));
477
+ getters.push(key);
478
+ }
479
+ }
480
+ }
481
+ }
482
+ // add the state, getters, and action properties
483
+ /* istanbul ignore if */ {
484
+ assign(store, setupStore);
485
+ // allows retrieving reactive objects with `storeToRefs()`. Must be called after assigning to the reactive object.
486
+ // Make `storeToRefs()` work with `reactive()` #799
487
+ assign(vue.toRaw(store), setupStore);
488
+ }
489
+ // use this instead of a computed with setter to be able to create it anywhere
490
+ // without linking the computed lifespan to wherever the store is first
491
+ // created.
492
+ Object.defineProperty(store, '$state', {
493
+ get: ()=>process.env.NODE_ENV !== 'production' && hot ? hotState.value : pinia.state.value[$id],
494
+ set: (state)=>{
495
+ /* istanbul ignore if */ if (process.env.NODE_ENV !== 'production' && hot) {
496
+ throw new Error('cannot set hotState');
497
+ }
498
+ $patch(($state)=>{
499
+ assign($state, state);
500
+ });
501
+ }
502
+ });
503
+ // add the hotUpdate before plugins to allow them to override it
504
+ /* istanbul ignore else */ if (process.env.NODE_ENV !== 'production') {
505
+ store._hotUpdate = vue.markRaw((newStore)=>{
506
+ store._hotUpdating = true;
507
+ newStore._hmrPayload.state.forEach((stateKey)=>{
508
+ if (stateKey in store.$state) {
509
+ const newStateTarget = newStore.$state[stateKey];
510
+ const oldStateSource = store.$state[stateKey];
511
+ if (typeof newStateTarget === 'object' && isPlainObject(newStateTarget) && isPlainObject(oldStateSource)) {
512
+ patchObject(newStateTarget, oldStateSource);
513
+ } else {
514
+ // transfer the ref
515
+ newStore.$state[stateKey] = oldStateSource;
516
+ }
517
+ }
518
+ // patch direct access properties to allow store.stateProperty to work as
519
+ // store.$state.stateProperty
520
+ set(store, stateKey, vue.toRef(newStore.$state, stateKey));
521
+ });
522
+ // remove deleted state properties
523
+ Object.keys(store.$state).forEach((stateKey)=>{
524
+ if (!(stateKey in newStore.$state)) {
525
+ del(store, stateKey);
526
+ }
527
+ });
528
+ // avoid devtools logging this as a mutation
529
+ isListening = false;
530
+ isSyncListening = false;
531
+ pinia.state.value[$id] = vue.toRef(newStore._hmrPayload, 'hotState');
532
+ isSyncListening = true;
533
+ vue.nextTick().then(()=>{
534
+ isListening = true;
535
+ });
536
+ for(const actionName in newStore._hmrPayload.actions){
537
+ const action = newStore[actionName];
538
+ set(store, actionName, wrapAction(actionName, action));
539
+ }
540
+ // TODO: does this work in both setup and option store?
541
+ for(const getterName in newStore._hmrPayload.getters){
542
+ const getter = newStore._hmrPayload.getters[getterName];
543
+ const getterValue = isOptionsStore ? vue.computed(()=>{
544
+ setActivePinia(pinia);
545
+ return getter.call(store, store);
546
+ }) : getter;
547
+ set(store, getterName, getterValue);
548
+ }
549
+ // remove deleted getters
550
+ Object.keys(store._hmrPayload.getters).forEach((key)=>{
551
+ if (!(key in newStore._hmrPayload.getters)) {
552
+ del(store, key);
553
+ }
554
+ });
555
+ // remove old actions
556
+ Object.keys(store._hmrPayload.actions).forEach((key)=>{
557
+ if (!(key in newStore._hmrPayload.actions)) {
558
+ del(store, key);
559
+ }
560
+ });
561
+ // update the values used in devtools and to allow deleting new properties later on
562
+ store._hmrPayload = newStore._hmrPayload;
563
+ store._getters = newStore._getters;
564
+ store._hotUpdating = false;
565
+ });
566
+ }
567
+ if (USE_DEVTOOLS) {
568
+ const nonEnumerable = {
569
+ writable: true,
570
+ configurable: true,
571
+ // avoid warning on devtools trying to display this property
572
+ enumerable: false
573
+ };
574
+ [
575
+ '_p',
576
+ '_hmrPayload',
577
+ '_getters',
578
+ '_customProperties'
579
+ ].forEach((p)=>{
580
+ Object.defineProperty(store, p, assign({
581
+ value: store[p]
582
+ }, nonEnumerable));
583
+ });
584
+ }
585
+ // apply all plugins
586
+ pinia._p.forEach((extender)=>{
587
+ /* istanbul ignore else */ if (USE_DEVTOOLS) {
588
+ const extensions = scope.run(()=>extender({
589
+ store,
590
+ app: pinia._a,
591
+ pinia,
592
+ options: optionsForPlugin
593
+ }));
594
+ Object.keys(extensions || {}).forEach((key)=>store._customProperties.add(key));
595
+ assign(store, extensions);
596
+ } else {
597
+ assign(store, scope.run(()=>extender({
598
+ store,
599
+ app: pinia._a,
600
+ pinia,
601
+ options: optionsForPlugin
602
+ })));
603
+ }
604
+ });
605
+ if (process.env.NODE_ENV !== 'production' && store.$state && typeof store.$state === 'object' && typeof store.$state.constructor === 'function' && !store.$state.constructor.toString().includes('[native code]')) {
606
+ console.warn(`[🍍]: The "state" must be a plain object. It cannot be\n` + `\tstate: () => new MyClass()\n` + `Found in store "${store.$id}".`);
607
+ }
608
+ // only apply hydrate to option stores with an initial state in pinia
609
+ if (initialState && isOptionsStore && options.hydrate) {
610
+ options.hydrate(store.$state, initialState);
611
+ }
612
+ isListening = true;
613
+ isSyncListening = true;
614
+ return store;
615
+ }
616
+ function defineStore(// TODO: add proper types from above
617
+ idOrOptions, setup, setupOptions) {
618
+ let id;
619
+ let options;
620
+ const isSetupStore = typeof setup === 'function';
621
+ {
622
+ id = idOrOptions;
623
+ // the option store setup will contain the actual options in this case
624
+ options = isSetupStore ? setupOptions : setup;
625
+ }
626
+ function useStore(pinia, hot) {
627
+ const hasContext = vue.hasInjectionContext();
628
+ pinia = // in test mode, ignore the argument provided as we can always retrieve a
629
+ // pinia instance with getActivePinia()
630
+ (process.env.NODE_ENV === 'test' && activePinia && activePinia._testing ? null : pinia) || (hasContext ? vue.inject(piniaSymbol, null) : null);
631
+ if (pinia) setActivePinia(pinia);
632
+ if (process.env.NODE_ENV !== 'production' && !activePinia) {
633
+ throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?\n` + `See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.\n` + `This will fail in production.`);
634
+ }
635
+ pinia = activePinia;
636
+ if (!pinia._s.has(id)) {
637
+ // creating the store registers it in `pinia._s`
638
+ if (isSetupStore) {
639
+ createSetupStore(id, setup, options, pinia);
640
+ } else {
641
+ createOptionsStore(id, options, pinia);
642
+ }
643
+ /* istanbul ignore else */ if (process.env.NODE_ENV !== 'production') {
644
+ // @ts-expect-error: not the right inferred type
645
+ useStore._pinia = pinia;
646
+ }
647
+ }
648
+ const store = pinia._s.get(id);
649
+ if (process.env.NODE_ENV !== 'production' && hot) {
650
+ const hotId = '__hot:' + id;
651
+ const newStore = isSetupStore ? createSetupStore(hotId, setup, options, pinia, true) : createOptionsStore(hotId, assign({}, options), pinia, true);
652
+ hot._hotUpdate(newStore);
653
+ // cleanup the state properties and the store from the cache
654
+ delete pinia.state.value[hotId];
655
+ pinia._s.delete(hotId);
656
+ }
657
+ if (process.env.NODE_ENV !== 'production' && IS_CLIENT) {
658
+ const currentInstance = vue.getCurrentInstance();
659
+ // save stores in instances to access them devtools
660
+ if (currentInstance && currentInstance.proxy && // avoid adding stores that are just built for hot module replacement
661
+ !hot) {
662
+ const vm = currentInstance.proxy;
663
+ const cache = '_pStores' in vm ? vm._pStores : vm._pStores = {};
664
+ cache[id] = store;
665
+ }
666
+ }
667
+ // StoreGeneric cannot be casted towards Store
668
+ return store;
669
+ }
670
+ useStore.$id = id;
671
+ return useStore;
672
+ }
673
+ /**
674
+ * Creates an object of references with all the state, getters, and plugin-added
675
+ * state properties of the store. Similar to `toRefs()` but specifically
676
+ * designed for Pinia stores so methods and non reactive properties are
677
+ * completely ignored.
678
+ *
679
+ * @param store - store to extract the refs from
680
+ */ function storeToRefs$1(store) {
681
+ // See https://github.com/vuejs/pinia/issues/852
682
+ // It's easier to just use toRefs() even if it includes more stuff
683
+ {
684
+ store = vue.toRaw(store);
685
+ const refs = {};
686
+ for(const key in store){
687
+ const value = store[key];
688
+ if (vue.isRef(value) || vue.isReactive(value)) {
689
+ // @ts-expect-error: the key is state or getter
690
+ refs[key] = // ---
691
+ vue.toRef(store, key);
692
+ }
693
+ }
694
+ return refs;
695
+ }
696
+ }
697
+
698
+ /*
699
+ * Copyright (c) 2024.
700
+ * Author Peter Placzek (tada5hi)
701
+ * For the full copyright and license information,
702
+ * view the LICENSE file that was distributed with this source code.
703
+ */ const STORE_ID = 'authup';
704
+
705
+ function createStore(context = {}) {
706
+ const client = new coreHttpKit.Client({
707
+ baseURL: context.baseURL
708
+ });
709
+ const initialized = vue.ref(false);
710
+ const setInitialized = (value)=>{
711
+ initialized.value = value;
712
+ };
713
+ // --------------------------------------------------------------------
714
+ const accessToken = vue.ref(undefined);
715
+ const setAccessToken = (input)=>{
716
+ accessToken.value = input;
717
+ };
718
+ // --------------------------------------------------------------------
719
+ const accessTokenExpireDate = vue.ref(undefined);
720
+ const setAccessTokenExpireDate = (input)=>{
721
+ if (typeof input === 'number' || typeof input === 'string') {
722
+ accessTokenExpireDate.value = new Date(input); // verify microseconds or seconds
723
+ return;
724
+ }
725
+ accessTokenExpireDate.value = input;
726
+ };
727
+ // --------------------------------------------------------------------
728
+ const refreshToken = vue.ref(undefined);
729
+ const setRefreshToken = (input)=>{
730
+ refreshToken.value = input;
731
+ };
732
+ // --------------------------------------------------------------------
733
+ const handleTokenGrantResponse = (response)=>{
734
+ const expireDate = new Date(Date.now() + response.expires_in * 1000);
735
+ setAccessTokenExpireDate(expireDate);
736
+ setAccessToken(response.access_token);
737
+ setRefreshToken(response.refresh_token);
738
+ };
739
+ // --------------------------------------------------------------------
740
+ let refreshTokenPromise;
741
+ const attemptRefreshToken = ()=>{
742
+ if (!refreshToken.value) {
743
+ return Promise.reject(new Error('No refresh token is present.'));
744
+ }
745
+ if (refreshTokenPromise) {
746
+ return refreshTokenPromise;
747
+ }
748
+ refreshTokenPromise = client.token.createWithRefreshToken({
749
+ refresh_token: refreshToken.value
750
+ }).then((r)=>{
751
+ handleTokenGrantResponse(r);
752
+ return r;
753
+ }).finally(()=>{
754
+ refreshTokenPromise = undefined;
755
+ });
756
+ return refreshTokenPromise;
757
+ };
758
+ // --------------------------------------------------------------------
759
+ const user = vue.ref(undefined);
760
+ const userId = vue.computed(()=>user.value ? user.value.id : undefined);
761
+ const userResolved = vue.ref(false);
762
+ const setUser = (entity)=>{
763
+ user.value = entity;
764
+ userResolved.value = !!entity;
765
+ };
766
+ // --------------------------------------------------------------------
767
+ const realm = vue.ref(undefined);
768
+ const realmId = vue.computed(()=>realm.value ? realm.value.id : undefined);
769
+ const realmName = vue.computed(()=>realm.value ? realm.value.name : undefined);
770
+ const realmIsRoot = vue.computed(()=>{
771
+ if (realm.value) {
772
+ return realm.value.name === coreKit.REALM_MASTER_NAME;
773
+ }
774
+ return false;
775
+ });
776
+ const setRealm = (entity)=>{
777
+ realm.value = entity;
778
+ };
779
+ const realmManagement = vue.ref(undefined);
780
+ const realmManagementId = vue.computed(()=>realmManagement.value ? realmManagement.value.id : realmId.value);
781
+ const realmManagementName = vue.computed(()=>realmManagement.value ? realmManagement.value.name : realmName.value);
782
+ const setRealmManagement = (entity)=>{
783
+ realmManagement.value = entity;
784
+ };
785
+ const abilities = new kit.Abilities();
786
+ const tokenInfo = vue.ref(undefined);
787
+ const tokenResolved = vue.ref(false);
788
+ const setTokenInfo = (entity)=>{
789
+ tokenResolved.value = !!entity;
790
+ tokenInfo.value = entity;
791
+ if (!entity) {
792
+ setRealm(undefined);
793
+ setRealmManagement(undefined);
794
+ abilities.set([]);
795
+ return;
796
+ }
797
+ if (entity.exp) {
798
+ const expireDate = new Date(entity.exp * 1000);
799
+ setAccessTokenExpireDate(expireDate);
800
+ }
801
+ if (entity.realm_id && entity.realm_name) {
802
+ realm.value = {
803
+ id: entity.realm_id,
804
+ name: entity.realm_name
805
+ };
806
+ if (typeof realmManagement.value === 'undefined') {
807
+ setRealmManagement(realm.value);
808
+ }
809
+ }
810
+ if (entity.permissions) {
811
+ abilities.set(entity.permissions);
812
+ }
813
+ };
814
+ // --------------------------------------------------------------------
815
+ const resolve = async (ctx = {})=>{
816
+ if (!accessToken.value || ctx.attempts && ctx.attempts > 3) return;
817
+ try {
818
+ if (!tokenResolved.value || ctx.refresh) {
819
+ const token = await client.token.introspect({
820
+ token: accessToken.value
821
+ }, {
822
+ authorizationHeader: {
823
+ type: 'Bearer',
824
+ token: accessToken.value
825
+ }
826
+ });
827
+ setTokenInfo(token);
828
+ tokenResolved.value = true;
829
+ }
830
+ if (!userResolved.value || ctx.refresh) {
831
+ const entity = await client.userInfo.get(`Bearer ${accessToken.value}`);
832
+ setUser(entity);
833
+ userResolved.value = true;
834
+ }
835
+ } catch (e) {
836
+ if (coreHttpKit.isClientTokenExpiredError(e)) {
837
+ await attemptRefreshToken();
838
+ await resolve({
839
+ refresh: true,
840
+ attempts: ctx.attempts ? ctx.attempts++ : 1
841
+ });
842
+ return;
843
+ }
844
+ throw e;
845
+ }
846
+ };
847
+ const loggedIn = vue.computed(()=>!!accessToken.value);
848
+ const login = async (ctx)=>{
849
+ try {
850
+ const response = await client.token.createWithPasswordGrant({
851
+ username: ctx.name,
852
+ password: ctx.password,
853
+ ...realmId.value ? {
854
+ realm_id: ctx.realmId
855
+ } : {}
856
+ });
857
+ handleTokenGrantResponse(response);
858
+ await resolve();
859
+ } catch (e) {
860
+ setUser(undefined);
861
+ throw e;
862
+ }
863
+ };
864
+ const logout = ()=>{
865
+ setAccessToken(undefined);
866
+ setAccessTokenExpireDate(undefined);
867
+ setRefreshToken(undefined);
868
+ setUser(undefined);
869
+ setTokenInfo(undefined);
870
+ };
871
+ return {
872
+ initialized,
873
+ setInitialized,
874
+ abilities,
875
+ login,
876
+ logout,
877
+ loggedIn,
878
+ resolve,
879
+ handleTokenGrantResponse,
880
+ accessToken,
881
+ setAccessToken,
882
+ accessTokenExpireDate,
883
+ setAccessTokenExpireDate,
884
+ refreshToken,
885
+ setRefreshToken,
886
+ tokenInfo,
887
+ setTokenInfo,
888
+ realm,
889
+ realmId,
890
+ realmIsRoot,
891
+ realmName,
892
+ setRealm,
893
+ realmManagement,
894
+ realmManagementId,
895
+ realmManagementName,
896
+ setRealmManagement,
897
+ user,
898
+ userId,
899
+ setUser
900
+ };
901
+ }
902
+
903
+ function tryOnScopeDispose(fn) {
904
+ if (vue.getCurrentScope()) {
905
+ vue.onScopeDispose(fn);
906
+ return true;
907
+ }
908
+ return false;
909
+ }
910
+ typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
911
+ const noop = ()=>{};
912
+
913
+ function useCookies(dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}, cookies = new Cookie()) {
914
+ const watchingDependencies = autoUpdateDependencies ? [
915
+ ...[]
916
+ ] : dependencies;
917
+ let previousCookies = cookies.getAll({
918
+ doNotParse: true
919
+ });
920
+ const touches = vue.ref(0);
921
+ const onChange = ()=>{
922
+ const newCookies = cookies.getAll({
923
+ doNotParse: true
924
+ });
925
+ if (shouldUpdate(watchingDependencies || null, newCookies, previousCookies)) touches.value++;
926
+ previousCookies = newCookies;
927
+ };
928
+ cookies.addChangeListener(onChange);
929
+ tryOnScopeDispose(()=>{
930
+ cookies.removeChangeListener(onChange);
931
+ });
932
+ return {
933
+ /**
934
+ * Reactive get cookie by name. If **autoUpdateDependencies = true** then it will update watching dependencies
935
+ */ get: (...args)=>{
936
+ if (autoUpdateDependencies && watchingDependencies && !watchingDependencies.includes(args[0])) watchingDependencies.push(args[0]);
937
+ touches.value;
938
+ return cookies.get(args[0], {
939
+ doNotParse,
940
+ ...args[1]
941
+ });
942
+ },
943
+ /**
944
+ * Reactive get all cookies
945
+ */ getAll: (...args)=>{
946
+ touches.value;
947
+ return cookies.getAll({
948
+ doNotParse,
949
+ ...args[0]
950
+ });
951
+ },
952
+ set: (...args)=>cookies.set(...args),
953
+ remove: (...args)=>cookies.remove(...args),
954
+ addChangeListener: (...args)=>cookies.addChangeListener(...args),
955
+ removeChangeListener: (...args)=>cookies.removeChangeListener(...args)
956
+ };
957
+ }
958
+ function shouldUpdate(dependencies, newCookies, oldCookies) {
959
+ if (!dependencies) return true;
960
+ for (const dependency of dependencies){
961
+ if (newCookies[dependency] !== oldCookies[dependency]) return true;
962
+ }
963
+ return false;
964
+ }
965
+
966
+ const StoreSymbol = Symbol.for('AuthupStore');
967
+ function useStore(pinia, app) {
968
+ const instance = injectStore(app);
969
+ if (!instance) {
970
+ throw new Error('The store has not been injected in the app context.');
971
+ }
972
+ return instance(pinia);
973
+ }
974
+ function injectStore(app) {
975
+ const instance = inject$1(StoreSymbol, app);
976
+ if (!instance) {
977
+ throw new Error('The store has not been injected in the app context.');
978
+ }
979
+ return instance;
980
+ }
981
+ function hasStore(app) {
982
+ return !!inject$1(StoreSymbol, app);
983
+ }
984
+ function provideStore(store, app) {
985
+ provide(StoreSymbol, store, app);
986
+ }
987
+
988
+ function installStore(app, options = {}) {
989
+ if (hasStore(app)) {
990
+ return;
991
+ }
992
+ const storeCreator = defineStore(STORE_ID, ()=>createStore({
993
+ baseURL: options.baseURL
994
+ }));
995
+ const store = storeCreator();
996
+ const cookies = useCookies();
997
+ let cookieGet;
998
+ if (options.cookieGet) {
999
+ cookieGet = options.cookieGet;
1000
+ } else {
1001
+ cookieGet = cookies.get;
1002
+ }
1003
+ let cookieSet;
1004
+ if (options.cookieSet) {
1005
+ cookieSet = options.cookieSet;
1006
+ } else {
1007
+ cookieSet = cookies.set;
1008
+ }
1009
+ let cookieUnset;
1010
+ if (options.cookieUnset) {
1011
+ cookieUnset = options.cookieUnset;
1012
+ } else if (options.cookieSet) {
1013
+ cookieUnset = (key)=>{
1014
+ options.cookieSet(key, null);
1015
+ };
1016
+ } else {
1017
+ cookieUnset = cookies.remove;
1018
+ }
1019
+ const initStore = ()=>{
1020
+ if (store.initialized) {
1021
+ return;
1022
+ }
1023
+ store.setInitialized(true);
1024
+ const keys = Object.values(coreHttpKit.CookieName);
1025
+ let value;
29
1026
  for(let i = 0; i < keys.length; i++){
30
- this.setOptions(keys[i], items[keys[i]]);
1027
+ value = cookieGet(keys[i]);
1028
+ if (!value) {
1029
+ continue;
1030
+ }
1031
+ switch(keys[i]){
1032
+ case coreHttpKit.CookieName.ACCESS_TOKEN:
1033
+ if (!store.accessToken) {
1034
+ store.setAccessToken(value);
1035
+ }
1036
+ break;
1037
+ case coreHttpKit.CookieName.ACCESS_TOKEN_EXPIRE_DATE:
1038
+ if (!store.accessTokenExpireDate) {
1039
+ store.setAccessTokenExpireDate(value);
1040
+ }
1041
+ break;
1042
+ case coreHttpKit.CookieName.REFRESH_TOKEN:
1043
+ if (!store.refreshToken) {
1044
+ store.setRefreshToken(value);
1045
+ }
1046
+ break;
1047
+ case coreHttpKit.CookieName.USER:
1048
+ if (!store.user) {
1049
+ store.setUser(value);
1050
+ }
1051
+ break;
1052
+ case coreHttpKit.CookieName.REALM:
1053
+ if (!store.realm) {
1054
+ store.setRealm(value);
1055
+ }
1056
+ break;
1057
+ case coreHttpKit.CookieName.REALM_MANAGEMENT:
1058
+ if (!store.realmManagement) {
1059
+ store.setRealmManagement(value);
1060
+ }
1061
+ break;
1062
+ }
31
1063
  }
32
- }
33
- /**
34
- * Set options for a specific group.
35
- *
36
- * @param group
37
- * @param options
38
- */ setOptions(group, options) {
39
- if (typeof this.data[group] === 'undefined') {
40
- this.data[group] = {};
1064
+ };
1065
+ store.$onAction((action)=>{
1066
+ if (action.store.$id !== STORE_ID) {
1067
+ return;
41
1068
  }
42
- this.data[group] = options;
43
- }
44
- hasOptions(group) {
45
- return smob.hasOwnProperty(this.data, group);
46
- }
47
- getOptions(group) {
48
- if (typeof this.data[group] !== 'undefined') {
49
- return this.data[group];
1069
+ if (action.name === 'logout') {
1070
+ cookieUnset(coreHttpKit.CookieName.ACCESS_TOKEN);
1071
+ cookieUnset(coreHttpKit.CookieName.ACCESS_TOKEN_EXPIRE_DATE);
1072
+ cookieUnset(coreHttpKit.CookieName.REFRESH_TOKEN);
1073
+ cookieUnset(coreHttpKit.CookieName.USER);
1074
+ cookieUnset(coreHttpKit.CookieName.REALM);
1075
+ cookieUnset(coreHttpKit.CookieName.REALM_MANAGEMENT);
50
1076
  }
51
- return {};
52
- }
53
- hasOption(group, option) {
54
- return typeof this.data[group] !== 'undefined' && smob.hasOwnProperty(this.data[group], option);
55
- }
56
- getOption(group, option) {
57
- if (typeof this.data[group] === 'undefined') {
58
- return undefined;
1077
+ });
1078
+ initStore();
1079
+ store.$subscribe((mutation, state)=>{
1080
+ if (mutation.storeId !== STORE_ID) {
1081
+ return;
59
1082
  }
60
- return this.data[group][option];
61
- }
62
- constructor(){
63
- this.data = {};
64
- }
65
- }
66
- class StoreManager {
67
- keys() {
68
- return Object.keys(this.instances);
69
- }
70
- use(key) {
71
- if (typeof this.instances[key] !== 'undefined') {
72
- return this.instances[key];
1083
+ if (state.accessToken) {
1084
+ cookieSet(coreHttpKit.CookieName.ACCESS_TOKEN, state.accessToken);
73
1085
  }
74
- this.instances[key] = new Store();
75
- return this.instances[key];
76
- }
77
- constructor(){
78
- this.instances = {};
79
- }
80
- }
81
- function applyStoreManagerOptions(manager, options) {
82
- if (options.presets) {
83
- const presetKeys = Object.keys(options.presets);
84
- for(let i = 0; i < presetKeys.length; i++){
85
- const store = manager.use(presetKeys[i]);
86
- store.setAll(options.presets[presetKeys[i]]);
1086
+ if (state.accessTokenExpireDate) {
1087
+ cookieSet(coreHttpKit.CookieName.ACCESS_TOKEN_EXPIRE_DATE, state.accessTokenExpireDate);
87
1088
  }
88
- }
89
- if (options.defaults) {
90
- const store = manager.use(StoreName.DEFAULT);
91
- store.setAll(options.defaults);
92
- }
93
- }
94
- function getSymbol(key) {
95
- {
96
- return Symbol.for(`VCStoreManager#${key}`);
97
- }
98
- }
99
- function installStoreManager(instance, key) {
100
- let manager;
101
- const symbol = getSymbol(key);
102
- if (instance._context && instance._context.provides && instance._context.provides[symbol]) {
103
- return instance._context.provides[symbol];
104
- }
105
- if (vue.hasInjectionContext()) {
106
- manager = vue.inject(symbol, undefined);
107
- if (manager) {
108
- return manager;
1089
+ if (state.refreshToken) {
1090
+ cookieSet(coreHttpKit.CookieName.REFRESH_TOKEN, state.refreshToken);
109
1091
  }
110
- }
111
- manager = new StoreManager();
112
- instance.provide(symbol, manager);
113
- return manager;
114
- }
115
-
116
- function inject$1(key, instance) {
117
- if (instance && instance._context && instance._context.provides && instance._context.provides[key]) {
118
- return instance._context.provides[key];
119
- }
120
- if (vue.hasInjectionContext()) {
121
- return vue.inject(key, undefined);
122
- }
123
- return undefined;
1092
+ if (state.user) {
1093
+ cookieSet(coreHttpKit.CookieName.USER, state.user);
1094
+ }
1095
+ if (state.realm) {
1096
+ cookieSet(coreHttpKit.CookieName.REALM, state.realm);
1097
+ }
1098
+ if (state.realmManagement) {
1099
+ cookieSet(coreHttpKit.CookieName.REALM_MANAGEMENT, state.realmManagement);
1100
+ }
1101
+ });
1102
+ provideStore(storeCreator, app);
124
1103
  }
125
1104
 
126
- function provide(key, value, app) {
127
- if (typeof app === 'undefined') {
128
- const val = inject$1(key);
129
- if (typeof val !== 'undefined') {
130
- return;
1105
+ function storeToRefs(store) {
1106
+ store = vue.toRaw(store);
1107
+ const refs = {};
1108
+ const keys = Object.keys(store);
1109
+ for(let i = 0; i < keys.length; i++){
1110
+ const value = store[keys[i]];
1111
+ if (vue.isRef(value) || vue.isReactive(value)) {
1112
+ refs[keys[i]] = vue.toRef(store, keys[i]);
131
1113
  }
132
- vue.provide(key, value);
133
- return;
134
- }
135
- if (app && app._context && app._context.provides && app._context.provides[key]) {
136
- return;
137
1114
  }
138
- app.provide(key, value);
1115
+ return refs;
139
1116
  }
140
1117
 
141
- const APIClientSymbol = Symbol.for('AuthupAPIClient');
142
- function provideAPIClient(client, app) {
143
- provide(APIClientSymbol, client, app);
144
- }
145
- function injectAPIClient() {
146
- const instance = inject$1(APIClientSymbol);
147
- if (!instance) {
148
- throw new Error('The api client has not been injected.');
1118
+ function installHTTPClient(app, options = {}) {
1119
+ if (hasHTTPClient(app)) {
1120
+ return;
149
1121
  }
150
- return instance;
1122
+ const client = new coreHttpKit.Client({
1123
+ baseURL: options.baseURL
1124
+ });
1125
+ const storeCreator = injectStore(app);
1126
+ const store = storeCreator();
1127
+ const { refreshToken } = storeToRefs$1(store);
1128
+ const tokenHook = new coreHttpKit.ClientResponseErrorTokenHook(client, {
1129
+ baseURL: options.baseURL,
1130
+ tokenCreator: ()=>{
1131
+ if (!refreshToken.value) {
1132
+ throw new Error('No refresh token available.');
1133
+ }
1134
+ return client.token.createWithRefreshToken({
1135
+ refresh_token: refreshToken.value
1136
+ });
1137
+ },
1138
+ tokenCreated: (response)=>{
1139
+ store.handleTokenGrantResponse(response);
1140
+ },
1141
+ tokenFailed: ()=>{
1142
+ store.logout();
1143
+ }
1144
+ });
1145
+ store.$subscribe((mutation, state)=>{
1146
+ if (mutation.storeId !== STORE_ID) return;
1147
+ if (state.accessToken) {
1148
+ client.setAuthorizationHeader({
1149
+ type: 'Bearer',
1150
+ token: state.accessToken
1151
+ });
1152
+ tokenHook.mount();
1153
+ } else {
1154
+ client.unsetAuthorizationHeader();
1155
+ tokenHook.unmount();
1156
+ }
1157
+ if (state.refreshToken && state.accessTokenExpireDate) {
1158
+ const expiresIn = Math.floor((state.accessTokenExpireDate.getTime() - Date.now()) / 1000);
1159
+ tokenHook.setTimer({
1160
+ refresh_token: ()=>refreshToken.value,
1161
+ expires_in: expiresIn
1162
+ });
1163
+ }
1164
+ });
1165
+ provideHTTPClient(client, app);
151
1166
  }
152
1167
 
153
1168
  function renderEntityAssignAction(ctx) {
@@ -289,271 +1304,61 @@ function buildListCreatedHandler(items, cb) {
289
1304
  } else {
290
1305
  index = -1;
291
1306
  }
292
- if (index === -1) {
293
- if (options.unshift) {
294
- items.value.unshift(item);
295
- } else {
296
- items.value.push(item);
297
- }
298
- if (cb) {
299
- cb(item);
300
- }
301
- }
302
- };
303
- }
304
- function buildListUpdatedHandler(items, cb) {
305
- return (item)=>{
306
- if (!smob.isObject(item)) {
307
- return;
308
- }
309
- const index = items.value.findIndex((el)=>el.id === item.id);
310
- if (index !== -1) {
311
- const keys = Object.keys(item);
312
- for(let i = 0; i < keys.length; i++){
313
- items.value[index][keys[i]] = item[keys[i]];
314
- }
315
- if (cb) {
316
- cb(item);
317
- }
318
- }
319
- };
320
- }
321
- function buildListDeletedHandler(items, cb) {
322
- return (item)=>{
323
- if (!smob.isObject(item)) {
324
- return undefined;
325
- }
326
- const index = items.value.findIndex((el)=>el.id === item.id);
327
- if (index !== -1) {
328
- if (cb) {
329
- cb(items.value[index]);
330
- }
331
- return items.value.splice(index, 1).pop();
332
- }
333
- return undefined;
334
- };
335
- }
336
-
337
- /*
338
- * Copyright (c) 2023.
339
- * Author Peter Placzek (tada5hi)
340
- * For the full copyright and license information,
341
- * view the LICENSE file that was distributed with this source code.
342
- */ function boolableToObject(input) {
343
- if (typeof input === 'boolean') {
344
- return {};
345
- }
346
- return input;
347
- }
348
-
349
- const createStore = (context)=>{
350
- const client = new coreHttpKit.Client({
351
- baseURL: context.baseURL
352
- });
353
- // --------------------------------------------------------------------
354
- const accessToken = vue.ref(undefined);
355
- const setAccessToken = (input)=>{
356
- accessToken.value = input;
357
- };
358
- // --------------------------------------------------------------------
359
- const accessTokenExpireDate = vue.ref(undefined);
360
- const setAccessTokenExpireDate = (input)=>{
361
- if (typeof input === 'number' || typeof input === 'string') {
362
- accessTokenExpireDate.value = new Date(input); // verify microseconds or seconds
363
- return;
364
- }
365
- accessTokenExpireDate.value = input;
366
- };
367
- // --------------------------------------------------------------------
368
- const refreshToken = vue.ref(undefined);
369
- const setRefreshToken = (input)=>{
370
- refreshToken.value = input;
371
- };
372
- const handleTokenGrantResponse = (response)=>{
373
- const expireDate = new Date(Date.now() + response.expires_in * 1000);
374
- setAccessTokenExpireDate(expireDate);
375
- setAccessToken(response.access_token);
376
- setRefreshToken(response.refresh_token);
377
- };
378
- let refreshTokenPromise;
379
- const attemptRefreshToken = ()=>{
380
- if (!refreshToken.value) {
381
- return Promise.reject(new Error('No refresh token is present.'));
382
- }
383
- if (refreshTokenPromise) {
384
- return refreshTokenPromise;
385
- }
386
- refreshTokenPromise = client.token.createWithRefreshToken({
387
- refresh_token: refreshToken.value
388
- }).then((r)=>{
389
- handleTokenGrantResponse(r);
390
- refreshTokenPromise = undefined;
391
- return r;
392
- }).catch((e)=>{
393
- refreshTokenPromise = undefined;
394
- throw e;
395
- });
396
- return refreshTokenPromise;
397
- };
398
- // --------------------------------------------------------------------
399
- const user = vue.ref(undefined);
400
- const userId = vue.computed(()=>user.value ? user.value.id : undefined);
401
- const userResolved = vue.ref(false);
402
- const setUser = (entity)=>{
403
- user.value = entity;
404
- userResolved.value = !!entity;
405
- };
406
- // --------------------------------------------------------------------
407
- const abilityManager = new kit.AbilityManager();
408
- const tokenInfo = vue.ref(undefined);
409
- const tokenResolved = vue.ref(false);
410
- const has = (name)=>abilityManager.has(name);
411
- const realm = vue.ref(undefined);
412
- const realmId = vue.computed(()=>realm.value ? realm.value.id : undefined);
413
- const realmName = vue.computed(()=>realm.value ? realm.value.name : undefined);
414
- const setRealm = (entity)=>{
415
- realm.value = entity;
416
- };
417
- const realmManagement = vue.ref(undefined);
418
- const realmManagementId = vue.computed(()=>realmManagement.value ? realmManagement.value.id : realmId.value);
419
- const realmManagementName = vue.computed(()=>realmManagement.value ? realmManagement.value.name : realmName.value);
420
- const setRealmManagement = (entity)=>{
421
- realmManagement.value = entity;
422
- };
423
- const setTokenInfo = (entity)=>{
424
- tokenResolved.value = !!entity;
425
- tokenInfo.value = entity;
426
- if (!entity) {
427
- setRealm(undefined);
428
- setRealmManagement(undefined);
429
- abilityManager.set([]);
430
- return;
431
- }
432
- if (entity.exp) {
433
- const expireDate = new Date(entity.exp * 1000);
434
- setAccessTokenExpireDate(expireDate);
435
- }
436
- if (entity.realm_id && entity.realm_name) {
437
- realm.value = {
438
- id: entity.realm_id,
439
- name: entity.realm_name
440
- };
441
- if (typeof realmManagement.value === 'undefined') {
442
- setRealmManagement(realm.value);
443
- }
444
- }
445
- if (entity.permissions) {
446
- abilityManager.set(entity.permissions);
447
- }
448
- };
449
- // --------------------------------------------------------------------
450
- const resolve = async (ctx = {})=>{
451
- if (!accessToken.value || ctx.attempts && ctx.attempts > 3) return;
452
- try {
453
- if (!tokenResolved.value || ctx.refresh) {
454
- const token = await client.token.introspect({
455
- token: accessToken.value
456
- }, {
457
- authorizationHeader: {
458
- type: 'Bearer',
459
- token: accessToken.value
460
- }
461
- });
462
- setTokenInfo(token);
463
- tokenResolved.value = true;
464
- }
465
- if (!userResolved.value || ctx.refresh) {
466
- const entity = await client.userInfo.get(`Bearer ${accessToken.value}`);
467
- setUser(entity);
468
- userResolved.value = true;
1307
+ if (index === -1) {
1308
+ if (options.unshift) {
1309
+ items.value.unshift(item);
1310
+ } else {
1311
+ items.value.push(item);
469
1312
  }
470
- } catch (e) {
471
- if (coreHttpKit.isClientTokenExpiredError(e)) {
472
- await attemptRefreshToken();
473
- await resolve({
474
- refresh: true,
475
- attempts: ctx.attempts ? ctx.attempts++ : 1
476
- });
477
- return;
1313
+ if (cb) {
1314
+ cb(item);
478
1315
  }
479
- throw e;
480
1316
  }
481
1317
  };
482
- const loggedIn = vue.computed(()=>!!accessToken.value);
483
- const login = async (ctx)=>{
484
- try {
485
- const response = await client.token.createWithPasswordGrant({
486
- username: ctx.name,
487
- password: ctx.password,
488
- ...realmId.value ? {
489
- realm_id: ctx.realmId
490
- } : {}
491
- });
492
- handleTokenGrantResponse(response);
493
- await resolve();
494
- } catch (e) {
495
- setUser(undefined);
496
- throw e;
1318
+ }
1319
+ function buildListUpdatedHandler(items, cb) {
1320
+ return (item)=>{
1321
+ if (!smob.isObject(item)) {
1322
+ return;
1323
+ }
1324
+ const index = items.value.findIndex((el)=>el.id === item.id);
1325
+ if (index !== -1) {
1326
+ const keys = Object.keys(item);
1327
+ for(let i = 0; i < keys.length; i++){
1328
+ items.value[index][keys[i]] = item[keys[i]];
1329
+ }
1330
+ if (cb) {
1331
+ cb(item);
1332
+ }
497
1333
  }
498
1334
  };
499
- const logout = ()=>{
500
- setAccessToken(undefined);
501
- setRefreshToken(undefined);
502
- setUser(undefined);
503
- setTokenInfo(undefined);
504
- };
505
- return {
506
- login,
507
- logout,
508
- loggedIn,
509
- resolve,
510
- handleTokenGrantResponse,
511
- accessToken,
512
- setAccessToken,
513
- accessTokenExpireDate,
514
- setAccessTokenExpireDate,
515
- refreshToken,
516
- setRefreshToken,
517
- tokenInfo,
518
- setTokenInfo,
519
- realm,
520
- realmId,
521
- realmName,
522
- setRealm,
523
- realmManagement,
524
- realmManagementId,
525
- realmManagementName,
526
- setRealmManagement,
527
- user,
528
- userId,
529
- setUser,
530
- has
531
- };
532
- };
533
-
534
- const StoreSymbol = Symbol.for('AuthupStore');
535
- function injectStore() {
536
- const instance = inject$1(StoreSymbol);
537
- if (!instance) {
538
- throw new Error('The store has not been injected in the app context.');
539
- }
540
- return instance;
541
1335
  }
542
- function provideStore(store, app) {
543
- provide(StoreSymbol, store, app);
1336
+ function buildListDeletedHandler(items, cb) {
1337
+ return (item)=>{
1338
+ if (!smob.isObject(item)) {
1339
+ return undefined;
1340
+ }
1341
+ const index = items.value.findIndex((el)=>el.id === item.id);
1342
+ if (index !== -1) {
1343
+ if (cb) {
1344
+ cb(items.value[index]);
1345
+ }
1346
+ return items.value.splice(index, 1).pop();
1347
+ }
1348
+ return undefined;
1349
+ };
544
1350
  }
545
1351
 
546
- function storeToRefs(store) {
547
- store = vue.toRaw(store);
548
- const refs = {};
549
- const keys = Object.keys(store);
550
- for(let i = 0; i < keys.length; i++){
551
- const value = store[keys[i]];
552
- if (vue.isRef(value) || vue.isReactive(value)) {
553
- refs[keys[i]] = vue.toRef(store, keys[i]);
554
- }
1352
+ /*
1353
+ * Copyright (c) 2023.
1354
+ * Author Peter Placzek (tada5hi)
1355
+ * For the full copyright and license information,
1356
+ * view the LICENSE file that was distributed with this source code.
1357
+ */ function boolableToObject(input) {
1358
+ if (typeof input === 'boolean') {
1359
+ return {};
555
1360
  }
556
- return refs;
1361
+ return input;
557
1362
  }
558
1363
 
559
1364
  const SocketClientSymbol = Symbol.for('AuthupSocketClientManager');
@@ -575,6 +1380,13 @@ function injectSocketClientManager() {
575
1380
  return manager;
576
1381
  }
577
1382
 
1383
+ function installSocketClientManager(app, options) {
1384
+ const socketClientManager = new coreRealtimeKit.ClientManager({
1385
+ url: options.baseURL
1386
+ });
1387
+ provideSocketClientManager(socketClientManager, app);
1388
+ }
1389
+
578
1390
  function createEntitySocket(ctx) {
579
1391
  if (!isSocketClientManagerInjected()) {
580
1392
  return {
@@ -582,7 +1394,7 @@ function createEntitySocket(ctx) {
582
1394
  unmount () {}
583
1395
  };
584
1396
  }
585
- const store = injectStore();
1397
+ const store = useStore();
586
1398
  const storeRefs = storeToRefs(store);
587
1399
  const realmId = vue.computed(()=>{
588
1400
  if (storeRefs.realmName.value === coreKit.REALM_MASTER_NAME) {
@@ -731,7 +1543,7 @@ function createList(context) {
731
1543
  }
732
1544
  return undefined;
733
1545
  });
734
- const client = injectAPIClient();
1546
+ const client = injectHTTPClient();
735
1547
  let domainAPI;
736
1548
  if (kit.hasOwnProperty(client, context.type)) {
737
1549
  domainAPI = client[context.type];
@@ -998,7 +1810,7 @@ function defineEntityManagerProps() {
998
1810
  }
999
1811
 
1000
1812
  function createEntityManager(ctx) {
1001
- const client = injectAPIClient();
1813
+ const client = injectHTTPClient();
1002
1814
  let domainAPI;
1003
1815
  if (kit.hasOwnProperty(client, ctx.type)) {
1004
1816
  domainAPI = client[ctx.type];
@@ -1433,9 +2245,6 @@ class MemoryStore {
1433
2245
  }
1434
2246
  }
1435
2247
 
1436
- typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
1437
- const noop = ()=>{};
1438
-
1439
2248
  function computedAsync(evaluationCallback, initialState, optionsOrRef) {
1440
2249
  let options;
1441
2250
  if (vue.isRef(optionsOrRef)) {
@@ -1815,6 +2624,33 @@ function useUpdatedAt(input) {
1815
2624
  });
1816
2625
  }
1817
2626
 
2627
+ function useAbilityCheck(name) {
2628
+ const { abilities } = useStore();
2629
+ const data = vue.ref(false);
2630
+ data.value = abilities.has(name);
2631
+ let removeListener;
2632
+ vue.onMounted(()=>{
2633
+ removeListener = abilities.on('updated', ()=>{
2634
+ data.value = abilities.has(name);
2635
+ });
2636
+ });
2637
+ vue.onUnmounted(()=>{
2638
+ if (typeof removeListener !== 'undefined') {
2639
+ removeListener();
2640
+ }
2641
+ });
2642
+ return data;
2643
+ }
2644
+
2645
+ function useRealmResourceWritableCheck(realmId) {
2646
+ const store = useStore();
2647
+ const { realm } = storeToRefs$1(store);
2648
+ return vue.computed(()=>{
2649
+ const realmIdRaw = vue.unref(realmId);
2650
+ return coreKit.isRealmResourceWritable(realm.value, realmIdRaw);
2651
+ });
2652
+ }
2653
+
1818
2654
  const ARealm = vue.defineComponent({
1819
2655
  props: defineEntityManagerProps(),
1820
2656
  emits: defineEntityManagerEvents(),
@@ -2521,6 +3357,25 @@ const AClientScopes = vue.defineComponent({
2521
3357
  }
2522
3358
  });
2523
3359
 
3360
+ function createRealmFormPicker(form) {
3361
+ return formControls.buildFormGroup({
3362
+ label: true,
3363
+ labelContent: 'Realm',
3364
+ content: vue.h(ARealms, {}, {
3365
+ [listControls.SlotName.ITEM_ACTIONS]: (props)=>renderEntityAssignAction({
3366
+ item: form.realm_id === props.data.id,
3367
+ busy: props.busy,
3368
+ add () {
3369
+ form.realm_id = props.data.id;
3370
+ },
3371
+ drop () {
3372
+ form.realm_id = '';
3373
+ }
3374
+ })
3375
+ })
3376
+ });
3377
+ }
3378
+
2524
3379
  const AScopeForm = vue.defineComponent({
2525
3380
  props: {
2526
3381
  name: {
@@ -2528,12 +3383,7 @@ const AScopeForm = vue.defineComponent({
2528
3383
  default: undefined
2529
3384
  },
2530
3385
  entity: {
2531
- type: Object,
2532
- default: undefined
2533
- },
2534
- realmId: {
2535
- type: String,
2536
- default: undefined
3386
+ type: Object
2537
3387
  }
2538
3388
  },
2539
3389
  emits: defineEntityManagerEvents(),
@@ -2557,11 +3407,19 @@ const AScopeForm = vue.defineComponent({
2557
3407
  },
2558
3408
  realm_id: {}
2559
3409
  }, form);
3410
+ const store = useStore();
3411
+ const storeRefs = storeToRefs(store);
2560
3412
  const manager = createEntityManager({
2561
3413
  type: `${coreKit.DomainType.SCOPE}`,
2562
3414
  setup: ctx,
2563
3415
  props
2564
3416
  });
3417
+ const realmId = vue.computed(()=>{
3418
+ if (!storeRefs.realmIsRoot) {
3419
+ return storeRefs.realmId.value;
3420
+ }
3421
+ return manager.data.value ? manager.data.value.realm_id : null;
3422
+ });
2565
3423
  const isEditing = useIsEditing(manager.data);
2566
3424
  const updatedAt = useUpdatedAt(props.entity);
2567
3425
  const isNameFixed = vue.computed(()=>{
@@ -2570,14 +3428,10 @@ const AScopeForm = vue.defineComponent({
2570
3428
  }
2571
3429
  return !!(manager.data.value && manager.data.value.built_in);
2572
3430
  });
2573
- const isRealmLocked = vue.computed(()=>!!props.realmId);
2574
3431
  function initForm() {
2575
3432
  if (props.name) {
2576
3433
  form.name = props.name;
2577
3434
  }
2578
- if (props.realmId) {
2579
- form.realm_id = props.realmId;
2580
- }
2581
3435
  initFormAttributesFromSource(form, manager.data.value);
2582
3436
  }
2583
3437
  vue.watch(updatedAt, (val, oldVal)=>{
@@ -2606,8 +3460,8 @@ const AScopeForm = vue.defineComponent({
2606
3460
  key: exports.TranslatorTranslationDefaultKey.REALM
2607
3461
  }
2608
3462
  ]);
2609
- const render = ()=>{
2610
- const name = [
3463
+ return ()=>{
3464
+ const children = [
2611
3465
  formControls.buildFormGroup({
2612
3466
  validationMessages: translationsValidation.name.value,
2613
3467
  validationSeverity: getVuelidateSeverity($v.value.name),
@@ -2622,9 +3476,7 @@ const AScopeForm = vue.defineComponent({
2622
3476
  disabled: isNameFixed.value
2623
3477
  }
2624
3478
  })
2625
- })
2626
- ];
2627
- const description = [
3479
+ }),
2628
3480
  formControls.buildFormGroup({
2629
3481
  validationMessages: translationsValidation.description.value,
2630
3482
  validationSeverity: getVuelidateSeverity($v.value.description),
@@ -2641,52 +3493,22 @@ const AScopeForm = vue.defineComponent({
2641
3493
  })
2642
3494
  })
2643
3495
  ];
2644
- const submitForm = buildFormSubmitWithTranslations({
2645
- busy,
3496
+ if (!realmId.value && !isNameFixed.value && !isEditing.value) {
3497
+ children.push(createRealmFormPicker(form));
3498
+ }
3499
+ children.push(buildFormSubmitWithTranslations({
2646
3500
  submit,
3501
+ busy,
2647
3502
  isEditing: isEditing.value,
2648
3503
  invalid: $v.value.$invalid
2649
- }, translationsSubmit);
2650
- let realm = [];
2651
- if (!isRealmLocked.value && !isNameFixed.value) {
2652
- realm = [
2653
- vue.h('hr'),
2654
- vue.h('label', {
2655
- class: 'form-label'
2656
- }, translationsDefault[exports.TranslatorTranslationDefaultKey.REALM].value),
2657
- vue.h(ARealms, {
2658
- headerTitle: false
2659
- }, {
2660
- [listControls.SlotName.ITEM_ACTIONS]: (props)=>renderEntityAssignAction({
2661
- item: form.realm_id === props.data.id,
2662
- busy: props.busy,
2663
- add () {
2664
- form.realm_id = props.data.id;
2665
- },
2666
- drop () {
2667
- form.realm_id = '';
2668
- }
2669
- })
2670
- })
2671
- ];
2672
- }
3504
+ }, translationsSubmit));
2673
3505
  return vue.h('form', {
2674
3506
  onSubmit ($event) {
2675
3507
  $event.preventDefault();
2676
3508
  return submit.apply(null);
2677
3509
  }
2678
- }, [
2679
- vue.h('div', [
2680
- name,
2681
- vue.h('hr'),
2682
- description,
2683
- realm,
2684
- vue.h('hr'),
2685
- submitForm
2686
- ])
2687
- ]);
3510
+ }, children);
2688
3511
  };
2689
- return ()=>render();
2690
3512
  }
2691
3513
  });
2692
3514
 
@@ -4006,7 +4828,7 @@ const AIdentityProviderOAuth2Form = vue.defineComponent({
4006
4828
  },
4007
4829
  emits: defineEntityManagerEvents(),
4008
4830
  setup (props, ctx) {
4009
- const apiClient = injectAPIClient();
4831
+ const apiClient = injectHTTPClient();
4010
4832
  const manager = createEntityManager({
4011
4833
  type: `${coreKit.DomainType.IDENTITY_PROVIDER}`,
4012
4834
  setup: ctx,
@@ -4598,7 +5420,8 @@ const ARoleForm = vue.defineComponent({
4598
5420
  const busy = vue.ref(false);
4599
5421
  const form = vue.reactive({
4600
5422
  name: '',
4601
- description: ''
5423
+ description: '',
5424
+ realm_id: ''
4602
5425
  });
4603
5426
  const $v = useVuelidate({
4604
5427
  name: {
@@ -4609,13 +5432,22 @@ const ARoleForm = vue.defineComponent({
4609
5432
  description: {
4610
5433
  minLength: validators.minLength(5),
4611
5434
  maxLength: validators.maxLength(4096)
4612
- }
5435
+ },
5436
+ realm_id: {}
4613
5437
  }, form);
5438
+ const store = useStore();
5439
+ const storeRefs = storeToRefs(store);
4614
5440
  const manager = createEntityManager({
4615
5441
  type: `${coreKit.DomainType.ROLE}`,
4616
5442
  setup: ctx,
4617
5443
  props
4618
5444
  });
5445
+ const realmId = vue.computed(()=>{
5446
+ if (!storeRefs.realmIsRoot) {
5447
+ return storeRefs.realmId.value;
5448
+ }
5449
+ return manager.data.value ? manager.data.value.realm_id : null;
5450
+ });
4619
5451
  const isEditing = useIsEditing(manager.data);
4620
5452
  const updatedAt = useUpdatedAt(props.entity);
4621
5453
  function initForm() {
@@ -4645,7 +5477,8 @@ const ARoleForm = vue.defineComponent({
4645
5477
  }
4646
5478
  ]);
4647
5479
  const render = ()=>{
4648
- const name = formControls.buildFormGroup({
5480
+ const children = [];
5481
+ children.push(formControls.buildFormGroup({
4649
5482
  validationMessages: translationsValidation.name.value,
4650
5483
  validationSeverity: getVuelidateSeverity($v.value.name),
4651
5484
  label: true,
@@ -4656,8 +5489,8 @@ const ARoleForm = vue.defineComponent({
4656
5489
  $v.value.name.$model = input;
4657
5490
  }
4658
5491
  })
4659
- });
4660
- const description = formControls.buildFormGroup({
5492
+ }));
5493
+ children.push(formControls.buildFormGroup({
4661
5494
  validationMessages: translationsValidation.description.value,
4662
5495
  validationSeverity: getVuelidateSeverity($v.value.description),
4663
5496
  label: true,
@@ -4671,23 +5504,22 @@ const ARoleForm = vue.defineComponent({
4671
5504
  rows: 6
4672
5505
  }
4673
5506
  })
4674
- });
4675
- const submitForm = buildFormSubmitWithTranslations({
5507
+ }));
5508
+ if (!realmId.value && !isEditing.value) {
5509
+ children.push(createRealmFormPicker(form));
5510
+ }
5511
+ children.push(buildFormSubmitWithTranslations({
4676
5512
  submit,
4677
- busy: busy.value,
5513
+ busy,
4678
5514
  isEditing: isEditing.value,
4679
5515
  invalid: $v.value.$invalid
4680
- }, translationsSubmit);
5516
+ }, translationsSubmit));
4681
5517
  return vue.h('form', {
4682
5518
  onSubmit ($event) {
4683
5519
  $event.preventDefault();
4684
5520
  return submit.apply(null);
4685
5521
  }
4686
- }, [
4687
- name,
4688
- description,
4689
- submitForm
4690
- ]);
5522
+ }, children);
4691
5523
  };
4692
5524
  return ()=>render();
4693
5525
  }
@@ -4784,8 +5616,7 @@ const APermission = vue.defineComponent({
4784
5616
  const APermissionForm = vue.defineComponent({
4785
5617
  props: {
4786
5618
  entity: {
4787
- type: Object,
4788
- default: undefined
5619
+ type: Object
4789
5620
  }
4790
5621
  },
4791
5622
  emits: defineEntityManagerEvents(),
@@ -4793,7 +5624,8 @@ const APermissionForm = vue.defineComponent({
4793
5624
  const busy = vue.ref(false);
4794
5625
  const form = vue.reactive({
4795
5626
  name: '',
4796
- description: ''
5627
+ description: '',
5628
+ realm_id: ''
4797
5629
  });
4798
5630
  const $v = useVuelidate({
4799
5631
  name: {
@@ -4804,13 +5636,22 @@ const APermissionForm = vue.defineComponent({
4804
5636
  description: {
4805
5637
  minLength: validators.minLength(5),
4806
5638
  maxLength: validators.maxLength(4096)
4807
- }
5639
+ },
5640
+ realm_id: {}
4808
5641
  }, form);
5642
+ const store = useStore();
5643
+ const storeRefs = storeToRefs(store);
4809
5644
  const manager = createEntityManager({
4810
5645
  type: `${coreKit.DomainType.PERMISSION}`,
4811
5646
  setup: ctx,
4812
5647
  props
4813
5648
  });
5649
+ const realmId = vue.computed(()=>{
5650
+ if (!storeRefs.realmIsRoot) {
5651
+ return storeRefs.realmId.value;
5652
+ }
5653
+ return manager.data.value ? manager.data.value.realm_id : null;
5654
+ });
4814
5655
  const isEditing = useIsEditing(manager.data);
4815
5656
  const updatedAt = useUpdatedAt(props.entity);
4816
5657
  function initForm() {
@@ -4840,7 +5681,8 @@ const APermissionForm = vue.defineComponent({
4840
5681
  }
4841
5682
  ]);
4842
5683
  const render = ()=>{
4843
- const name = formControls.buildFormGroup({
5684
+ const children = [];
5685
+ children.push(formControls.buildFormGroup({
4844
5686
  validationMessages: translationsValidation.name.value,
4845
5687
  validationSeverity: getVuelidateSeverity($v.value.name),
4846
5688
  label: true,
@@ -4854,8 +5696,8 @@ const APermissionForm = vue.defineComponent({
4854
5696
  disabled: manager.data.value && manager.data.value.built_in
4855
5697
  }
4856
5698
  })
4857
- });
4858
- const description = formControls.buildFormGroup({
5699
+ }));
5700
+ children.push(formControls.buildFormGroup({
4859
5701
  validationMessages: translationsValidation.description.value,
4860
5702
  validationSeverity: getVuelidateSeverity($v.value.description),
4861
5703
  label: true,
@@ -4869,23 +5711,22 @@ const APermissionForm = vue.defineComponent({
4869
5711
  rows: 4
4870
5712
  }
4871
5713
  })
4872
- });
4873
- const submitButton = buildFormSubmitWithTranslations({
5714
+ }));
5715
+ if (!realmId.value && !isEditing.value) {
5716
+ children.push(createRealmFormPicker(form));
5717
+ }
5718
+ children.push(buildFormSubmitWithTranslations({
4874
5719
  submit,
4875
5720
  busy,
4876
5721
  isEditing: isEditing.value,
4877
5722
  invalid: $v.value.$invalid
4878
- }, translationsSubmit);
5723
+ }, translationsSubmit));
4879
5724
  return vue.h('form', {
4880
5725
  onSubmit ($event) {
4881
5726
  $event.preventDefault();
4882
5727
  return submit.apply(null);
4883
5728
  }
4884
- }, [
4885
- name,
4886
- description,
4887
- submitButton
4888
- ]);
5729
+ }, children);
4889
5730
  };
4890
5731
  return ()=>render();
4891
5732
  }
@@ -5702,7 +6543,7 @@ const AUserPasswordForm = vue.defineComponent({
5702
6543
  'failed'
5703
6544
  ],
5704
6545
  setup (props, ctx) {
5705
- const apiClient = injectAPIClient();
6546
+ const apiClient = injectHTTPClient();
5706
6547
  const busy = vue.ref(false);
5707
6548
  const form = vue.reactive({
5708
6549
  password: '',
@@ -6336,7 +7177,7 @@ const AEntityDelete = vue.defineComponent({
6336
7177
  'failed'
6337
7178
  ],
6338
7179
  setup (props, ctx) {
6339
- const apiClient = injectAPIClient();
7180
+ const apiClient = injectHTTPClient();
6340
7181
  const instance = vue.getCurrentInstance();
6341
7182
  const busy = vue.ref(false);
6342
7183
  const submit = wrapFnWithBusyState(busy, async ()=>{
@@ -6469,38 +7310,43 @@ var components = /*#__PURE__*/Object.freeze({
6469
7310
  LanguageSwitcherDropdown: LanguageSwitcherDropdown
6470
7311
  });
6471
7312
 
6472
- function install(app, options) {
6473
- options = options || {};
6474
- if (options.apiClient) {
6475
- provideAPIClient(options.apiClient, app);
6476
- }
6477
- if (options.socketClientManager) {
6478
- provideSocketClientManager(options.socketClientManager, app);
6479
- }
6480
- if (options.store) {
6481
- provideStore(options.store, app);
7313
+ function installComponents(input) {
7314
+ if (!input) {
7315
+ return;
6482
7316
  }
6483
- installTranslator(app, {
6484
- locale: options.translatorLocale
6485
- });
6486
- const storeManager = installStoreManager(app, 'authup');
6487
- if (options.storeManager) {
6488
- applyStoreManagerOptions(storeManager, options.storeManager);
7317
+ let componentsSelected;
7318
+ if (typeof input !== 'boolean') {
7319
+ componentsSelected = input;
6489
7320
  }
6490
- if (options.components) {
6491
- let componentsSelected;
6492
- if (typeof options.components !== 'boolean') {
6493
- componentsSelected = options.components;
7321
+ Object.entries(components).forEach(([componentName, component])=>{
7322
+ if (!Array.isArray(componentsSelected) || componentsSelected.indexOf(componentName) !== -1) {
7323
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
7324
+ // @ts-ignore
7325
+ app.component(componentName, component);
6494
7326
  }
6495
- Object.entries(components).forEach(([componentName, component])=>{
6496
- if (!Array.isArray(componentsSelected) || componentsSelected.indexOf(componentName) !== -1) {
6497
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
6498
- // @ts-ignore
6499
- app.component(componentName, component);
6500
- }
7327
+ });
7328
+ }
7329
+ function install(app1, options) {
7330
+ if (options.realtime) {
7331
+ installSocketClientManager(app1, {
7332
+ baseURL: options.realtimeURL || options.baseURL
6501
7333
  });
6502
7334
  }
7335
+ installStore(app1, {
7336
+ baseURL: options.baseURL,
7337
+ cookieSet: options.cookieSet,
7338
+ cookieGet: options.cookieGet,
7339
+ cookieUnset: options.cookieUnset
7340
+ });
7341
+ installHTTPClient(app1, {
7342
+ baseURL: options.baseURL
7343
+ });
7344
+ installTranslator(app1, {
7345
+ locale: options.translatorLocale
7346
+ });
7347
+ installComponents(options.components);
6503
7348
  }
7349
+
6504
7350
  var index = {
6505
7351
  install
6506
7352
  };
@@ -6525,7 +7371,6 @@ exports.AIdentityProviderProtocol = AIdentityProviderProtocol;
6525
7371
  exports.AIdentityProviderRoleAssignment = AIdentityProviderRoleAssignment;
6526
7372
  exports.AIdentityProviderRoleAssignments = AIdentityProviderRoleAssignments;
6527
7373
  exports.AIdentityProviders = AIdentityProviders;
6528
- exports.APIClientSymbol = APIClientSymbol;
6529
7374
  exports.APagination = APagination;
6530
7375
  exports.APermission = APermission;
6531
7376
  exports.APermissionForm = APermissionForm;
@@ -6565,7 +7410,9 @@ exports.AUserRoleAssignment = AUserRoleAssignment;
6565
7410
  exports.AUserRoleAssignments = AUserRoleAssignments;
6566
7411
  exports.AUsers = AUsers;
6567
7412
  exports.EntityManagerError = EntityManagerError;
7413
+ exports.HTTPClientSymbol = HTTPClientSymbol;
6568
7414
  exports.LanguageSwitcherDropdown = LanguageSwitcherDropdown;
7415
+ exports.STORE_ID = STORE_ID;
6569
7416
  exports.SocketClientSymbol = SocketClientSymbol;
6570
7417
  exports.StoreSymbol = StoreSymbol;
6571
7418
  exports.VuelidateCustomRule = VuelidateCustomRule;
@@ -6586,29 +7433,40 @@ exports.defineListProps = defineListProps;
6586
7433
  exports.extendObjectProperties = extendObjectProperties;
6587
7434
  exports.extractVuelidateResultsFromChild = extractVuelidateResultsFromChild;
6588
7435
  exports.getVuelidateSeverity = getVuelidateSeverity;
7436
+ exports.hasHTTPClient = hasHTTPClient;
6589
7437
  exports.hasNormalizedSlot = hasNormalizedSlot;
7438
+ exports.hasStore = hasStore;
6590
7439
  exports.initFormAttributesFromSource = initFormAttributesFromSource;
6591
7440
  exports.inject = inject$1;
6592
- exports.injectAPIClient = injectAPIClient;
7441
+ exports.injectHTTPClient = injectHTTPClient;
6593
7442
  exports.injectSocketClientManager = injectSocketClientManager;
6594
7443
  exports.injectStore = injectStore;
6595
7444
  exports.injectTranslatorLocale = injectTranslatorLocale;
6596
7445
  exports.install = install;
7446
+ exports.installHTTPClient = installHTTPClient;
7447
+ exports.installSocketClientManager = installSocketClientManager;
7448
+ exports.installStore = installStore;
6597
7449
  exports.installTranslator = installTranslator;
6598
7450
  exports.isQuerySortedDescByDate = isQuerySortedDescByDate;
6599
7451
  exports.isSocketClientManagerInjected = isSocketClientManagerInjected;
6600
7452
  exports.mergeListOptions = mergeListOptions;
6601
7453
  exports.normalizeSlot = normalizeSlot;
7454
+ exports.onChange = onChange;
6602
7455
  exports.provide = provide;
6603
- exports.provideAPIClient = provideAPIClient;
7456
+ exports.provideHTTPClient = provideHTTPClient;
6604
7457
  exports.provideSocketClientManager = provideSocketClientManager;
6605
7458
  exports.provideStore = provideStore;
6606
7459
  exports.renderEntityAssignAction = renderEntityAssignAction;
6607
7460
  exports.storeToRefs = storeToRefs;
7461
+ exports.useAbilityCheck = useAbilityCheck;
7462
+ exports.useIsEditing = useIsEditing;
7463
+ exports.useRealmResourceWritableCheck = useRealmResourceWritableCheck;
7464
+ exports.useStore = useStore;
6608
7465
  exports.useTranslation = useTranslation;
6609
7466
  exports.useTranslationsForBaseValidation = useTranslationsForBaseValidation;
6610
7467
  exports.useTranslationsForGroup = useTranslationsForGroup;
6611
7468
  exports.useTranslationsForNestedValidation = useTranslationsForNestedValidation;
7469
+ exports.useUpdatedAt = useUpdatedAt;
6612
7470
  exports.wrapFnWithBusyState = wrapFnWithBusyState;
6613
7471
  module.exports = Object.assign(exports.default, exports);
6614
7472
  //# sourceMappingURL=index.cjs.map