@authup/client-web-kit 1.0.0-beta.12 → 1.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AEntityDelete.d.ts +7 -7
- package/dist/components/client/AClient.d.ts +2 -2
- package/dist/components/client/AClientForm.d.ts +3 -3
- package/dist/components/client/AClientRedirectUrisItem.d.ts +2 -2
- package/dist/components/client/AClients.d.ts +6 -6
- package/dist/components/client-scope/AClientScope.d.ts +2 -2
- package/dist/components/client-scope/AClientScopeAssignment.d.ts +2 -2
- package/dist/components/client-scope/AClientScopes.d.ts +6 -6
- package/dist/components/identity-provider/AIdentityProvider.d.ts +2 -2
- package/dist/components/identity-provider/AIdentityProviderBasicFields.d.ts +3 -1
- package/dist/components/identity-provider/AIdentityProviderBasicFields.d.ts.map +1 -1
- package/dist/components/identity-provider/AIdentityProviderForm.d.ts +3 -3
- package/dist/components/identity-provider/AIdentityProviderLdapForm.d.ts +3 -3
- package/dist/components/identity-provider/AIdentityProviderOAuth2Discovery.d.ts +3 -2
- package/dist/components/identity-provider/AIdentityProviderOAuth2Discovery.d.ts.map +1 -1
- package/dist/components/identity-provider/AIdentityProviderOAuth2Form.d.ts +3 -3
- package/dist/components/identity-provider/AIdentityProviders.d.ts +6 -6
- package/dist/components/identity-provider-role/AIdentityProviderRoleAssignment.d.ts +2 -2
- package/dist/components/permission/APermission.d.ts +2 -2
- package/dist/components/permission/APermissionForm.d.ts +4 -8
- package/dist/components/permission/APermissionForm.d.ts.map +1 -1
- package/dist/components/permission/APermissions.d.ts +6 -6
- package/dist/components/realm/ARealm.d.ts +2 -2
- package/dist/components/realm/ARealmForm.d.ts +2 -2
- package/dist/components/realm/ARealms.d.ts +6 -6
- package/dist/components/realm/helpers/form-picker.d.ts +7 -0
- package/dist/components/realm/helpers/form-picker.d.ts.map +1 -0
- package/dist/components/realm/helpers/index.d.ts +2 -0
- package/dist/components/realm/helpers/index.d.ts.map +1 -0
- package/dist/components/robot/ARobot.d.ts +2 -2
- package/dist/components/robot/ARobotForm.d.ts +3 -3
- package/dist/components/robot/ARobots.d.ts +6 -6
- package/dist/components/robot-permission/ARobotPermissionAssignment.d.ts +2 -2
- package/dist/components/robot-role/ARobotRoleAssignment.d.ts +2 -2
- package/dist/components/role/ARole.d.ts +2 -2
- package/dist/components/role/ARoleForm.d.ts +2 -2
- package/dist/components/role/ARoleForm.d.ts.map +1 -1
- package/dist/components/role/ARoles.d.ts +6 -6
- package/dist/components/role-permission/ARolePermissionAssignment.d.ts +2 -2
- package/dist/components/scope/AScope.d.ts +2 -2
- package/dist/components/scope/AScopeForm.d.ts +2 -14
- package/dist/components/scope/AScopeForm.d.ts.map +1 -1
- package/dist/components/scope/AScopes.d.ts +6 -6
- package/dist/components/user/AUser.d.ts +2 -2
- package/dist/components/user/AUserForm.d.ts +3 -3
- package/dist/components/user/AUserPasswordForm.d.ts +3 -3
- package/dist/components/user/AUsers.d.ts +6 -6
- package/dist/components/user-permission/AUserPermissionAssignment.d.ts +2 -2
- package/dist/components/user-role/AUserRoleAssignment.d.ts +2 -2
- package/dist/components/utility/search/ASearch.d.ts +3 -1
- package/dist/components/utility/search/ASearch.d.ts.map +1 -1
- package/dist/components/utility/search/module.d.ts +3 -2
- package/dist/components/utility/search/module.d.ts.map +1 -1
- package/dist/composables/index.d.ts +2 -0
- package/dist/composables/index.d.ts.map +1 -1
- package/dist/composables/use-ability-check.d.ts +3 -0
- package/dist/composables/use-ability-check.d.ts.map +1 -0
- package/dist/composables/use-realm-resource-writable-check.d.ts +3 -0
- package/dist/composables/use-realm-resource-writable-check.d.ts.map +1 -0
- package/dist/core/http-client/index.d.ts +4 -0
- package/dist/core/http-client/index.d.ts.map +1 -0
- package/dist/core/http-client/install.d.ts +4 -0
- package/dist/core/http-client/install.d.ts.map +1 -0
- package/dist/core/http-client/singleton.d.ts +7 -0
- package/dist/core/http-client/singleton.d.ts.map +1 -0
- package/dist/core/http-client/types.d.ts +6 -0
- package/dist/core/http-client/types.d.ts.map +1 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/socket-client-manager/index.d.ts +1 -0
- package/dist/core/socket-client-manager/index.d.ts.map +1 -1
- package/dist/core/socket-client-manager/install.d.ts +6 -0
- package/dist/core/socket-client-manager/install.d.ts.map +1 -0
- package/dist/core/store/constants.d.ts +2 -0
- package/dist/core/store/constants.d.ts.map +1 -0
- package/dist/core/store/{module.d.ts → create.d.ts} +12 -7
- package/dist/core/store/create.d.ts.map +1 -0
- package/dist/core/store/index.d.ts +4 -2
- package/dist/core/store/index.d.ts.map +1 -1
- package/dist/core/store/install.d.ts +4 -0
- package/dist/core/store/install.d.ts.map +1 -0
- package/dist/core/store/singleton.d.ts +6 -7
- package/dist/core/store/singleton.d.ts.map +1 -1
- package/dist/core/store/types.d.ts +27 -0
- package/dist/core/store/types.d.ts.map +1 -0
- package/dist/core/vuelidate.d.ts +1 -1
- package/dist/core/vuelidate.d.ts.map +1 -1
- package/dist/index.cjs +1414 -550
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1411 -559
- package/dist/index.mjs.map +1 -1
- package/dist/module.d.ts +5 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/types.d.ts +11 -8
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -13
- package/dist/core/api-client.d.ts +0 -6
- package/dist/core/api-client.d.ts.map +0 -1
- package/dist/core/store/module.d.ts.map +0 -1
- package/dist/core/store/type.d.ts +0 -13
- package/dist/core/store/type.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,149 +1,1164 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { toRaw, isRef, isReactive, toRef, hasInjectionContext, inject as inject$2, getCurrentInstance, ref, watch, reactive, markRaw, effectScope, nextTick, computed, getCurrentScope, onScopeDispose, toRefs, provide as provide$1, unref, h, onMounted, onUnmounted, shallowRef, watchEffect, defineComponent, resolveDynamicComponent, mergeProps } from 'vue';
|
|
2
|
+
import { REALM_MASTER_NAME, DomainEventName, buildDomainChannelName, DomainType, isRealmResourceWritable, IdentityProviderProtocol, IdentityProviderPreset, getIdentityProviderProtocolForPreset } from '@authup/core-kit';
|
|
3
|
+
import { Client, isClientTokenExpiredError, CookieName, ClientResponseErrorTokenHook } from '@authup/core-http-kit';
|
|
4
|
+
import { Abilities, buildEventFullName, EventNameSuffix, hasOwnProperty, createNanoID, isOAuth2OpenIDProviderMetadata, isObject as isObject$1 } from '@authup/kit';
|
|
5
|
+
import { merge, isObject, createMerger } from 'smob';
|
|
5
6
|
import { buildList, SlotName } from '@vuecs/list-controls';
|
|
6
|
-
import {
|
|
7
|
+
import { ClientManager } from '@authup/core-realtime-kit';
|
|
7
8
|
import { SortDirection } from 'rapiq';
|
|
8
9
|
import { buildFormSubmit, buildFormGroup, buildFormInput, buildFormTextarea, buildFormInputCheckbox, buildFormInputText } from '@vuecs/form-controls';
|
|
9
10
|
import { useTranslationsForBaseValidation as useTranslationsForBaseValidation$1, useTranslationsForNestedValidations, getSeverity, install as install$1 } from '@ilingo/vuelidate';
|
|
10
11
|
import { helpers, required, minLength, maxLength, url, numeric, email, sameAs } from '@vuelidate/validators';
|
|
11
12
|
import useVuelidate from '@vuelidate/core';
|
|
12
13
|
import { buildPagination as buildPagination$1 } from '@vuecs/pagination';
|
|
14
|
+
import Cookie from 'universal-cookie';
|
|
13
15
|
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
var isVue2 = false;
|
|
17
|
+
function set(target, key, val) {
|
|
18
|
+
if (Array.isArray(target)) {
|
|
19
|
+
target.length = Math.max(target.length, key);
|
|
20
|
+
target.splice(key, 1, val);
|
|
21
|
+
return val;
|
|
22
|
+
}
|
|
23
|
+
target[key] = val;
|
|
24
|
+
return val;
|
|
25
|
+
}
|
|
26
|
+
function del(target, key) {
|
|
27
|
+
if (Array.isArray(target)) {
|
|
28
|
+
target.splice(key, 1);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
delete target[key];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* setActivePinia must be called to handle SSR at the top of functions like
|
|
36
|
+
* `fetch`, `setup`, `serverPrefetch` and others
|
|
37
|
+
*/ let activePinia;
|
|
38
|
+
/**
|
|
39
|
+
* Sets or unsets the active pinia. Used in SSR and internally when calling
|
|
40
|
+
* actions and getters
|
|
41
|
+
*
|
|
42
|
+
* @param pinia - Pinia instance
|
|
43
|
+
*/ // @ts-expect-error: cannot constrain the type of the return
|
|
44
|
+
const setActivePinia = (pinia)=>activePinia = pinia;
|
|
45
|
+
const piniaSymbol = process.env.NODE_ENV !== 'production' ? Symbol('pinia') : /* istanbul ignore next */ Symbol();
|
|
46
|
+
function isPlainObject(// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
o) {
|
|
48
|
+
return o && typeof o === 'object' && Object.prototype.toString.call(o) === '[object Object]' && typeof o.toJSON !== 'function';
|
|
49
|
+
}
|
|
50
|
+
// type DeepReadonly<T> = { readonly [P in keyof T]: DeepReadonly<T[P]> }
|
|
51
|
+
// TODO: can we change these to numbers?
|
|
52
|
+
/**
|
|
53
|
+
* Possible types for SubscriptionCallback
|
|
54
|
+
*/ var MutationType;
|
|
55
|
+
(function(MutationType) {
|
|
19
56
|
/**
|
|
20
|
-
*
|
|
57
|
+
* Direct mutation of the state:
|
|
21
58
|
*
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
59
|
+
* - `store.name = 'new name'`
|
|
60
|
+
* - `store.$state.name = 'new name'`
|
|
61
|
+
* - `store.list.push('new item')`
|
|
62
|
+
*/ MutationType["direct"] = "direct";
|
|
63
|
+
/**
|
|
64
|
+
* Mutated the state with `$patch` and an object
|
|
65
|
+
*
|
|
66
|
+
* - `store.$patch({ name: 'newName' })`
|
|
67
|
+
*/ MutationType["patchObject"] = "patch object";
|
|
68
|
+
/**
|
|
69
|
+
* Mutated the state with `$patch` and a function
|
|
70
|
+
*
|
|
71
|
+
* - `store.$patch(state => state.name = 'newName')`
|
|
72
|
+
*/ MutationType["patchFunction"] = "patch function";
|
|
73
|
+
// maybe reset? for $state = {} and $reset
|
|
74
|
+
})(MutationType || (MutationType = {}));
|
|
75
|
+
const IS_CLIENT = typeof window !== 'undefined';
|
|
76
|
+
/**
|
|
77
|
+
* Should we add the devtools plugins.
|
|
78
|
+
* - only if dev mode or forced through the prod devtools flag
|
|
79
|
+
* - not in test
|
|
80
|
+
* - only if window exists (could change in the future)
|
|
81
|
+
*/ const USE_DEVTOOLS = (process.env.NODE_ENV !== 'production' || typeof __VUE_PROD_DEVTOOLS__ !== 'undefined' && __VUE_PROD_DEVTOOLS__) && !(process.env.NODE_ENV === 'test') && IS_CLIENT;
|
|
82
|
+
/**
|
|
83
|
+
* Mutates in place `newState` with `oldState` to _hot update_ it. It will
|
|
84
|
+
* remove any key not existing in `newState` and recursively merge plain
|
|
85
|
+
* objects.
|
|
86
|
+
*
|
|
87
|
+
* @param newState - new state object to be patched
|
|
88
|
+
* @param oldState - old state that should be used to patch newState
|
|
89
|
+
* @returns - newState
|
|
90
|
+
*/ function patchObject(newState, oldState) {
|
|
91
|
+
// no need to go through symbols because they cannot be serialized anyway
|
|
92
|
+
for(const key in oldState){
|
|
93
|
+
const subPatch = oldState[key];
|
|
94
|
+
// skip the whole sub tree
|
|
95
|
+
if (!(key in newState)) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const targetValue = newState[key];
|
|
99
|
+
if (isPlainObject(targetValue) && isPlainObject(subPatch) && !isRef(subPatch) && !isReactive(subPatch)) {
|
|
100
|
+
newState[key] = patchObject(targetValue, subPatch);
|
|
101
|
+
} else {
|
|
102
|
+
// objects are either a bit more complex (e.g. refs) or primitives, so we
|
|
103
|
+
// just set the whole thing
|
|
104
|
+
{
|
|
105
|
+
newState[key] = subPatch;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return newState;
|
|
110
|
+
}
|
|
111
|
+
const noop$1 = ()=>{};
|
|
112
|
+
function addSubscription(subscriptions, callback, detached, onCleanup = noop$1) {
|
|
113
|
+
subscriptions.push(callback);
|
|
114
|
+
const removeSubscription = ()=>{
|
|
115
|
+
const idx = subscriptions.indexOf(callback);
|
|
116
|
+
if (idx > -1) {
|
|
117
|
+
subscriptions.splice(idx, 1);
|
|
118
|
+
onCleanup();
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
if (!detached && getCurrentScope()) {
|
|
122
|
+
onScopeDispose(removeSubscription);
|
|
123
|
+
}
|
|
124
|
+
return removeSubscription;
|
|
125
|
+
}
|
|
126
|
+
function triggerSubscriptions(subscriptions, ...args) {
|
|
127
|
+
subscriptions.slice().forEach((callback)=>{
|
|
128
|
+
callback(...args);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const fallbackRunWithContext = (fn)=>fn();
|
|
132
|
+
function mergeReactiveObjects(target, patchToApply) {
|
|
133
|
+
// Handle Map instances
|
|
134
|
+
if (target instanceof Map && patchToApply instanceof Map) {
|
|
135
|
+
patchToApply.forEach((value, key)=>target.set(key, value));
|
|
136
|
+
}
|
|
137
|
+
// Handle Set instances
|
|
138
|
+
if (target instanceof Set && patchToApply instanceof Set) {
|
|
139
|
+
patchToApply.forEach(target.add, target);
|
|
140
|
+
}
|
|
141
|
+
// no need to go through symbols because they cannot be serialized anyway
|
|
142
|
+
for(const key in patchToApply){
|
|
143
|
+
if (!patchToApply.hasOwnProperty(key)) continue;
|
|
144
|
+
const subPatch = patchToApply[key];
|
|
145
|
+
const targetValue = target[key];
|
|
146
|
+
if (isPlainObject(targetValue) && isPlainObject(subPatch) && target.hasOwnProperty(key) && !isRef(subPatch) && !isReactive(subPatch)) {
|
|
147
|
+
// NOTE: here I wanted to warn about inconsistent types but it's not possible because in setup stores one might
|
|
148
|
+
// start the value of a property as a certain type e.g. a Map, and then for some reason, during SSR, change that
|
|
149
|
+
// to `undefined`. When trying to hydrate, we want to override the Map with `undefined`.
|
|
150
|
+
target[key] = mergeReactiveObjects(targetValue, subPatch);
|
|
151
|
+
} else {
|
|
152
|
+
// @ts-expect-error: subPatch is a valid value
|
|
153
|
+
target[key] = subPatch;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return target;
|
|
157
|
+
}
|
|
158
|
+
const skipHydrateSymbol = process.env.NODE_ENV !== 'production' ? Symbol('pinia:skipHydration') : /* istanbul ignore next */ Symbol();
|
|
159
|
+
/**
|
|
160
|
+
* Returns whether a value should be hydrated
|
|
161
|
+
*
|
|
162
|
+
* @param obj - target variable
|
|
163
|
+
* @returns true if `obj` should be hydrated
|
|
164
|
+
*/ function shouldHydrate(obj) {
|
|
165
|
+
return !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol);
|
|
166
|
+
}
|
|
167
|
+
const { assign } = Object;
|
|
168
|
+
function isComputed(o) {
|
|
169
|
+
return !!(isRef(o) && o.effect);
|
|
170
|
+
}
|
|
171
|
+
function createOptionsStore(id, options, pinia, hot) {
|
|
172
|
+
const { state, actions, getters } = options;
|
|
173
|
+
const initialState = pinia.state.value[id];
|
|
174
|
+
let store;
|
|
175
|
+
function setup() {
|
|
176
|
+
if (!initialState && (!(process.env.NODE_ENV !== 'production') || !hot)) {
|
|
177
|
+
/* istanbul ignore if */ {
|
|
178
|
+
pinia.state.value[id] = state ? state() : {};
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// avoid creating a state in pinia.state.value
|
|
182
|
+
const localState = process.env.NODE_ENV !== 'production' && hot ? toRefs(ref(state ? state() : {}).value) : toRefs(pinia.state.value[id]);
|
|
183
|
+
return assign(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name)=>{
|
|
184
|
+
if (process.env.NODE_ENV !== 'production' && name in localState) {
|
|
185
|
+
console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${name}" in store "${id}".`);
|
|
186
|
+
}
|
|
187
|
+
computedGetters[name] = markRaw(computed(()=>{
|
|
188
|
+
setActivePinia(pinia);
|
|
189
|
+
// it was created just before
|
|
190
|
+
const store = pinia._s.get(id);
|
|
191
|
+
// @ts-expect-error
|
|
192
|
+
// return getters![name].call(context, context)
|
|
193
|
+
// TODO: avoid reading the getter while assigning with a global variable
|
|
194
|
+
return getters[name].call(store, store);
|
|
195
|
+
}));
|
|
196
|
+
return computedGetters;
|
|
197
|
+
}, {}));
|
|
198
|
+
}
|
|
199
|
+
store = createSetupStore(id, setup, options, pinia, hot, true);
|
|
200
|
+
return store;
|
|
201
|
+
}
|
|
202
|
+
function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
|
|
203
|
+
let scope;
|
|
204
|
+
const optionsForPlugin = assign({
|
|
205
|
+
actions: {}
|
|
206
|
+
}, options);
|
|
207
|
+
/* istanbul ignore if */ if (process.env.NODE_ENV !== 'production' && !pinia._e.active) {
|
|
208
|
+
throw new Error('Pinia destroyed');
|
|
209
|
+
}
|
|
210
|
+
// watcher options for $subscribe
|
|
211
|
+
const $subscribeOptions = {
|
|
212
|
+
deep: true
|
|
213
|
+
};
|
|
214
|
+
/* istanbul ignore else */ if (process.env.NODE_ENV !== 'production' && !isVue2) {
|
|
215
|
+
$subscribeOptions.onTrigger = (event)=>{
|
|
216
|
+
/* istanbul ignore else */ if (isListening) {
|
|
217
|
+
debuggerEvents = event;
|
|
218
|
+
// avoid triggering this while the store is being built and the state is being set in pinia
|
|
219
|
+
} else if (isListening == false && !store._hotUpdating) {
|
|
220
|
+
// let patch send all the events together later
|
|
221
|
+
/* istanbul ignore else */ if (Array.isArray(debuggerEvents)) {
|
|
222
|
+
debuggerEvents.push(event);
|
|
223
|
+
} else {
|
|
224
|
+
console.error('🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug.');
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
// internal state
|
|
230
|
+
let isListening; // set to true at the end
|
|
231
|
+
let isSyncListening; // set to true at the end
|
|
232
|
+
let subscriptions = [];
|
|
233
|
+
let actionSubscriptions = [];
|
|
234
|
+
let debuggerEvents;
|
|
235
|
+
const initialState = pinia.state.value[$id];
|
|
236
|
+
// avoid setting the state for option stores if it is set
|
|
237
|
+
// by the setup
|
|
238
|
+
if (!isOptionsStore && !initialState && (!(process.env.NODE_ENV !== 'production') || !hot)) {
|
|
239
|
+
/* istanbul ignore if */ {
|
|
240
|
+
pinia.state.value[$id] = {};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
const hotState = ref({});
|
|
244
|
+
// avoid triggering too many listeners
|
|
245
|
+
// https://github.com/vuejs/pinia/issues/1129
|
|
246
|
+
let activeListener;
|
|
247
|
+
function $patch(partialStateOrMutator) {
|
|
248
|
+
let subscriptionMutation;
|
|
249
|
+
isListening = isSyncListening = false;
|
|
250
|
+
// reset the debugger events since patches are sync
|
|
251
|
+
/* istanbul ignore else */ if (process.env.NODE_ENV !== 'production') {
|
|
252
|
+
debuggerEvents = [];
|
|
253
|
+
}
|
|
254
|
+
if (typeof partialStateOrMutator === 'function') {
|
|
255
|
+
partialStateOrMutator(pinia.state.value[$id]);
|
|
256
|
+
subscriptionMutation = {
|
|
257
|
+
type: MutationType.patchFunction,
|
|
258
|
+
storeId: $id,
|
|
259
|
+
events: debuggerEvents
|
|
260
|
+
};
|
|
261
|
+
} else {
|
|
262
|
+
mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator);
|
|
263
|
+
subscriptionMutation = {
|
|
264
|
+
type: MutationType.patchObject,
|
|
265
|
+
payload: partialStateOrMutator,
|
|
266
|
+
storeId: $id,
|
|
267
|
+
events: debuggerEvents
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
const myListenerId = activeListener = Symbol();
|
|
271
|
+
nextTick().then(()=>{
|
|
272
|
+
if (activeListener === myListenerId) {
|
|
273
|
+
isListening = true;
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
isSyncListening = true;
|
|
277
|
+
// because we paused the watcher, we need to manually call the subscriptions
|
|
278
|
+
triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]);
|
|
279
|
+
}
|
|
280
|
+
const $reset = isOptionsStore ? function $reset() {
|
|
281
|
+
const { state } = options;
|
|
282
|
+
const newState = state ? state() : {};
|
|
283
|
+
// we use a patch to group all changes into one single subscription
|
|
284
|
+
this.$patch(($state)=>{
|
|
285
|
+
assign($state, newState);
|
|
286
|
+
});
|
|
287
|
+
} : /* istanbul ignore next */ process.env.NODE_ENV !== 'production' ? ()=>{
|
|
288
|
+
throw new Error(`🍍: Store "${$id}" is built using the setup syntax and does not implement $reset().`);
|
|
289
|
+
} : noop$1;
|
|
290
|
+
function $dispose() {
|
|
291
|
+
scope.stop();
|
|
292
|
+
subscriptions = [];
|
|
293
|
+
actionSubscriptions = [];
|
|
294
|
+
pinia._s.delete($id);
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Wraps an action to handle subscriptions.
|
|
298
|
+
*
|
|
299
|
+
* @param name - name of the action
|
|
300
|
+
* @param action - action to wrap
|
|
301
|
+
* @returns a wrapped action to handle subscriptions
|
|
302
|
+
*/ function wrapAction(name, action) {
|
|
303
|
+
return function() {
|
|
304
|
+
setActivePinia(pinia);
|
|
305
|
+
const args = Array.from(arguments);
|
|
306
|
+
const afterCallbackList = [];
|
|
307
|
+
const onErrorCallbackList = [];
|
|
308
|
+
function after(callback) {
|
|
309
|
+
afterCallbackList.push(callback);
|
|
310
|
+
}
|
|
311
|
+
function onError(callback) {
|
|
312
|
+
onErrorCallbackList.push(callback);
|
|
313
|
+
}
|
|
314
|
+
// @ts-expect-error
|
|
315
|
+
triggerSubscriptions(actionSubscriptions, {
|
|
316
|
+
args,
|
|
317
|
+
name,
|
|
318
|
+
store,
|
|
319
|
+
after,
|
|
320
|
+
onError
|
|
321
|
+
});
|
|
322
|
+
let ret;
|
|
323
|
+
try {
|
|
324
|
+
ret = action.apply(this && this.$id === $id ? this : store, args);
|
|
325
|
+
// handle sync errors
|
|
326
|
+
} catch (error) {
|
|
327
|
+
triggerSubscriptions(onErrorCallbackList, error);
|
|
328
|
+
throw error;
|
|
329
|
+
}
|
|
330
|
+
if (ret instanceof Promise) {
|
|
331
|
+
return ret.then((value)=>{
|
|
332
|
+
triggerSubscriptions(afterCallbackList, value);
|
|
333
|
+
return value;
|
|
334
|
+
}).catch((error)=>{
|
|
335
|
+
triggerSubscriptions(onErrorCallbackList, error);
|
|
336
|
+
return Promise.reject(error);
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
// trigger after callbacks
|
|
340
|
+
triggerSubscriptions(afterCallbackList, ret);
|
|
341
|
+
return ret;
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
const _hmrPayload = /*#__PURE__*/ markRaw({
|
|
345
|
+
actions: {},
|
|
346
|
+
getters: {},
|
|
347
|
+
state: [],
|
|
348
|
+
hotState
|
|
349
|
+
});
|
|
350
|
+
const partialStore = {
|
|
351
|
+
_p: pinia,
|
|
352
|
+
// _s: scope,
|
|
353
|
+
$id,
|
|
354
|
+
$onAction: addSubscription.bind(null, actionSubscriptions),
|
|
355
|
+
$patch,
|
|
356
|
+
$reset,
|
|
357
|
+
$subscribe (callback, options = {}) {
|
|
358
|
+
const removeSubscription = addSubscription(subscriptions, callback, options.detached, ()=>stopWatcher());
|
|
359
|
+
const stopWatcher = scope.run(()=>watch(()=>pinia.state.value[$id], (state)=>{
|
|
360
|
+
if (options.flush === 'sync' ? isSyncListening : isListening) {
|
|
361
|
+
callback({
|
|
362
|
+
storeId: $id,
|
|
363
|
+
type: MutationType.direct,
|
|
364
|
+
events: debuggerEvents
|
|
365
|
+
}, state);
|
|
366
|
+
}
|
|
367
|
+
}, assign({}, $subscribeOptions, options)));
|
|
368
|
+
return removeSubscription;
|
|
369
|
+
},
|
|
370
|
+
$dispose
|
|
371
|
+
};
|
|
372
|
+
const store = reactive(process.env.NODE_ENV !== 'production' || USE_DEVTOOLS ? assign({
|
|
373
|
+
_hmrPayload,
|
|
374
|
+
_customProperties: markRaw(new Set())
|
|
375
|
+
}, partialStore) : partialStore);
|
|
376
|
+
// store the partial store now so the setup of stores can instantiate each other before they are finished without
|
|
377
|
+
// creating infinite loops.
|
|
378
|
+
pinia._s.set($id, store);
|
|
379
|
+
const runWithContext = pinia._a && pinia._a.runWithContext || fallbackRunWithContext;
|
|
380
|
+
// TODO: idea create skipSerialize that marks properties as non serializable and they are skipped
|
|
381
|
+
const setupStore = runWithContext(()=>pinia._e.run(()=>(scope = effectScope()).run(setup)));
|
|
382
|
+
// overwrite existing actions to support $onAction
|
|
383
|
+
for(const key in setupStore){
|
|
384
|
+
const prop = setupStore[key];
|
|
385
|
+
if (isRef(prop) && !isComputed(prop) || isReactive(prop)) {
|
|
386
|
+
// mark it as a piece of state to be serialized
|
|
387
|
+
if (process.env.NODE_ENV !== 'production' && hot) {
|
|
388
|
+
set(hotState.value, key, toRef(setupStore, key));
|
|
389
|
+
// createOptionStore directly sets the state in pinia.state.value so we
|
|
390
|
+
// can just skip that
|
|
391
|
+
} else if (!isOptionsStore) {
|
|
392
|
+
// in setup stores we must hydrate the state and sync pinia state tree with the refs the user just created
|
|
393
|
+
if (initialState && shouldHydrate(prop)) {
|
|
394
|
+
if (isRef(prop)) {
|
|
395
|
+
prop.value = initialState[key];
|
|
396
|
+
} else {
|
|
397
|
+
// probably a reactive object, lets recursively assign
|
|
398
|
+
// @ts-expect-error: prop is unknown
|
|
399
|
+
mergeReactiveObjects(prop, initialState[key]);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
// transfer the ref to the pinia state to keep everything in sync
|
|
403
|
+
/* istanbul ignore if */ {
|
|
404
|
+
pinia.state.value[$id][key] = prop;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
/* istanbul ignore else */ if (process.env.NODE_ENV !== 'production') {
|
|
408
|
+
_hmrPayload.state.push(key);
|
|
409
|
+
}
|
|
410
|
+
// action
|
|
411
|
+
} else if (typeof prop === 'function') {
|
|
412
|
+
// @ts-expect-error: we are overriding the function we avoid wrapping if
|
|
413
|
+
const actionValue = process.env.NODE_ENV !== 'production' && hot ? prop : wrapAction(key, prop);
|
|
414
|
+
// this a hot module replacement store because the hotUpdate method needs
|
|
415
|
+
// to do it with the right context
|
|
416
|
+
/* istanbul ignore if */ {
|
|
417
|
+
// @ts-expect-error
|
|
418
|
+
setupStore[key] = actionValue;
|
|
419
|
+
}
|
|
420
|
+
/* istanbul ignore else */ if (process.env.NODE_ENV !== 'production') {
|
|
421
|
+
_hmrPayload.actions[key] = prop;
|
|
422
|
+
}
|
|
423
|
+
// list actions so they can be used in plugins
|
|
424
|
+
// @ts-expect-error
|
|
425
|
+
optionsForPlugin.actions[key] = prop;
|
|
426
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
427
|
+
// add getters for devtools
|
|
428
|
+
if (isComputed(prop)) {
|
|
429
|
+
_hmrPayload.getters[key] = isOptionsStore ? options.getters[key] : prop;
|
|
430
|
+
if (IS_CLIENT) {
|
|
431
|
+
const getters = setupStore._getters || // @ts-expect-error: same
|
|
432
|
+
(setupStore._getters = markRaw([]));
|
|
433
|
+
getters.push(key);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
// add the state, getters, and action properties
|
|
439
|
+
/* istanbul ignore if */ {
|
|
440
|
+
assign(store, setupStore);
|
|
441
|
+
// allows retrieving reactive objects with `storeToRefs()`. Must be called after assigning to the reactive object.
|
|
442
|
+
// Make `storeToRefs()` work with `reactive()` #799
|
|
443
|
+
assign(toRaw(store), setupStore);
|
|
444
|
+
}
|
|
445
|
+
// use this instead of a computed with setter to be able to create it anywhere
|
|
446
|
+
// without linking the computed lifespan to wherever the store is first
|
|
447
|
+
// created.
|
|
448
|
+
Object.defineProperty(store, '$state', {
|
|
449
|
+
get: ()=>process.env.NODE_ENV !== 'production' && hot ? hotState.value : pinia.state.value[$id],
|
|
450
|
+
set: (state)=>{
|
|
451
|
+
/* istanbul ignore if */ if (process.env.NODE_ENV !== 'production' && hot) {
|
|
452
|
+
throw new Error('cannot set hotState');
|
|
453
|
+
}
|
|
454
|
+
$patch(($state)=>{
|
|
455
|
+
assign($state, state);
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
// add the hotUpdate before plugins to allow them to override it
|
|
460
|
+
/* istanbul ignore else */ if (process.env.NODE_ENV !== 'production') {
|
|
461
|
+
store._hotUpdate = markRaw((newStore)=>{
|
|
462
|
+
store._hotUpdating = true;
|
|
463
|
+
newStore._hmrPayload.state.forEach((stateKey)=>{
|
|
464
|
+
if (stateKey in store.$state) {
|
|
465
|
+
const newStateTarget = newStore.$state[stateKey];
|
|
466
|
+
const oldStateSource = store.$state[stateKey];
|
|
467
|
+
if (typeof newStateTarget === 'object' && isPlainObject(newStateTarget) && isPlainObject(oldStateSource)) {
|
|
468
|
+
patchObject(newStateTarget, oldStateSource);
|
|
469
|
+
} else {
|
|
470
|
+
// transfer the ref
|
|
471
|
+
newStore.$state[stateKey] = oldStateSource;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
// patch direct access properties to allow store.stateProperty to work as
|
|
475
|
+
// store.$state.stateProperty
|
|
476
|
+
set(store, stateKey, toRef(newStore.$state, stateKey));
|
|
477
|
+
});
|
|
478
|
+
// remove deleted state properties
|
|
479
|
+
Object.keys(store.$state).forEach((stateKey)=>{
|
|
480
|
+
if (!(stateKey in newStore.$state)) {
|
|
481
|
+
del(store, stateKey);
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
// avoid devtools logging this as a mutation
|
|
485
|
+
isListening = false;
|
|
486
|
+
isSyncListening = false;
|
|
487
|
+
pinia.state.value[$id] = toRef(newStore._hmrPayload, 'hotState');
|
|
488
|
+
isSyncListening = true;
|
|
489
|
+
nextTick().then(()=>{
|
|
490
|
+
isListening = true;
|
|
491
|
+
});
|
|
492
|
+
for(const actionName in newStore._hmrPayload.actions){
|
|
493
|
+
const action = newStore[actionName];
|
|
494
|
+
set(store, actionName, wrapAction(actionName, action));
|
|
495
|
+
}
|
|
496
|
+
// TODO: does this work in both setup and option store?
|
|
497
|
+
for(const getterName in newStore._hmrPayload.getters){
|
|
498
|
+
const getter = newStore._hmrPayload.getters[getterName];
|
|
499
|
+
const getterValue = isOptionsStore ? computed(()=>{
|
|
500
|
+
setActivePinia(pinia);
|
|
501
|
+
return getter.call(store, store);
|
|
502
|
+
}) : getter;
|
|
503
|
+
set(store, getterName, getterValue);
|
|
504
|
+
}
|
|
505
|
+
// remove deleted getters
|
|
506
|
+
Object.keys(store._hmrPayload.getters).forEach((key)=>{
|
|
507
|
+
if (!(key in newStore._hmrPayload.getters)) {
|
|
508
|
+
del(store, key);
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
// remove old actions
|
|
512
|
+
Object.keys(store._hmrPayload.actions).forEach((key)=>{
|
|
513
|
+
if (!(key in newStore._hmrPayload.actions)) {
|
|
514
|
+
del(store, key);
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
// update the values used in devtools and to allow deleting new properties later on
|
|
518
|
+
store._hmrPayload = newStore._hmrPayload;
|
|
519
|
+
store._getters = newStore._getters;
|
|
520
|
+
store._hotUpdating = false;
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
if (USE_DEVTOOLS) {
|
|
524
|
+
const nonEnumerable = {
|
|
525
|
+
writable: true,
|
|
526
|
+
configurable: true,
|
|
527
|
+
// avoid warning on devtools trying to display this property
|
|
528
|
+
enumerable: false
|
|
529
|
+
};
|
|
530
|
+
[
|
|
531
|
+
'_p',
|
|
532
|
+
'_hmrPayload',
|
|
533
|
+
'_getters',
|
|
534
|
+
'_customProperties'
|
|
535
|
+
].forEach((p)=>{
|
|
536
|
+
Object.defineProperty(store, p, assign({
|
|
537
|
+
value: store[p]
|
|
538
|
+
}, nonEnumerable));
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
// apply all plugins
|
|
542
|
+
pinia._p.forEach((extender)=>{
|
|
543
|
+
/* istanbul ignore else */ if (USE_DEVTOOLS) {
|
|
544
|
+
const extensions = scope.run(()=>extender({
|
|
545
|
+
store,
|
|
546
|
+
app: pinia._a,
|
|
547
|
+
pinia,
|
|
548
|
+
options: optionsForPlugin
|
|
549
|
+
}));
|
|
550
|
+
Object.keys(extensions || {}).forEach((key)=>store._customProperties.add(key));
|
|
551
|
+
assign(store, extensions);
|
|
552
|
+
} else {
|
|
553
|
+
assign(store, scope.run(()=>extender({
|
|
554
|
+
store,
|
|
555
|
+
app: pinia._a,
|
|
556
|
+
pinia,
|
|
557
|
+
options: optionsForPlugin
|
|
558
|
+
})));
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
if (process.env.NODE_ENV !== 'production' && store.$state && typeof store.$state === 'object' && typeof store.$state.constructor === 'function' && !store.$state.constructor.toString().includes('[native code]')) {
|
|
562
|
+
console.warn(`[🍍]: The "state" must be a plain object. It cannot be\n` + `\tstate: () => new MyClass()\n` + `Found in store "${store.$id}".`);
|
|
563
|
+
}
|
|
564
|
+
// only apply hydrate to option stores with an initial state in pinia
|
|
565
|
+
if (initialState && isOptionsStore && options.hydrate) {
|
|
566
|
+
options.hydrate(store.$state, initialState);
|
|
567
|
+
}
|
|
568
|
+
isListening = true;
|
|
569
|
+
isSyncListening = true;
|
|
570
|
+
return store;
|
|
571
|
+
}
|
|
572
|
+
function defineStore(// TODO: add proper types from above
|
|
573
|
+
idOrOptions, setup, setupOptions) {
|
|
574
|
+
let id;
|
|
575
|
+
let options;
|
|
576
|
+
const isSetupStore = typeof setup === 'function';
|
|
577
|
+
{
|
|
578
|
+
id = idOrOptions;
|
|
579
|
+
// the option store setup will contain the actual options in this case
|
|
580
|
+
options = isSetupStore ? setupOptions : setup;
|
|
581
|
+
}
|
|
582
|
+
function useStore(pinia, hot) {
|
|
583
|
+
const hasContext = hasInjectionContext();
|
|
584
|
+
pinia = // in test mode, ignore the argument provided as we can always retrieve a
|
|
585
|
+
// pinia instance with getActivePinia()
|
|
586
|
+
(process.env.NODE_ENV === 'test' && activePinia && activePinia._testing ? null : pinia) || (hasContext ? inject$2(piniaSymbol, null) : null);
|
|
587
|
+
if (pinia) setActivePinia(pinia);
|
|
588
|
+
if (process.env.NODE_ENV !== 'production' && !activePinia) {
|
|
589
|
+
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.`);
|
|
590
|
+
}
|
|
591
|
+
pinia = activePinia;
|
|
592
|
+
if (!pinia._s.has(id)) {
|
|
593
|
+
// creating the store registers it in `pinia._s`
|
|
594
|
+
if (isSetupStore) {
|
|
595
|
+
createSetupStore(id, setup, options, pinia);
|
|
596
|
+
} else {
|
|
597
|
+
createOptionsStore(id, options, pinia);
|
|
598
|
+
}
|
|
599
|
+
/* istanbul ignore else */ if (process.env.NODE_ENV !== 'production') {
|
|
600
|
+
// @ts-expect-error: not the right inferred type
|
|
601
|
+
useStore._pinia = pinia;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
const store = pinia._s.get(id);
|
|
605
|
+
if (process.env.NODE_ENV !== 'production' && hot) {
|
|
606
|
+
const hotId = '__hot:' + id;
|
|
607
|
+
const newStore = isSetupStore ? createSetupStore(hotId, setup, options, pinia, true) : createOptionsStore(hotId, assign({}, options), pinia, true);
|
|
608
|
+
hot._hotUpdate(newStore);
|
|
609
|
+
// cleanup the state properties and the store from the cache
|
|
610
|
+
delete pinia.state.value[hotId];
|
|
611
|
+
pinia._s.delete(hotId);
|
|
612
|
+
}
|
|
613
|
+
if (process.env.NODE_ENV !== 'production' && IS_CLIENT) {
|
|
614
|
+
const currentInstance = getCurrentInstance();
|
|
615
|
+
// save stores in instances to access them devtools
|
|
616
|
+
if (currentInstance && currentInstance.proxy && // avoid adding stores that are just built for hot module replacement
|
|
617
|
+
!hot) {
|
|
618
|
+
const vm = currentInstance.proxy;
|
|
619
|
+
const cache = '_pStores' in vm ? vm._pStores : vm._pStores = {};
|
|
620
|
+
cache[id] = store;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
// StoreGeneric cannot be casted towards Store
|
|
624
|
+
return store;
|
|
625
|
+
}
|
|
626
|
+
useStore.$id = id;
|
|
627
|
+
return useStore;
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Creates an object of references with all the state, getters, and plugin-added
|
|
631
|
+
* state properties of the store. Similar to `toRefs()` but specifically
|
|
632
|
+
* designed for Pinia stores so methods and non reactive properties are
|
|
633
|
+
* completely ignored.
|
|
634
|
+
*
|
|
635
|
+
* @param store - store to extract the refs from
|
|
636
|
+
*/ function storeToRefs$1(store) {
|
|
637
|
+
// See https://github.com/vuejs/pinia/issues/852
|
|
638
|
+
// It's easier to just use toRefs() even if it includes more stuff
|
|
639
|
+
{
|
|
640
|
+
store = toRaw(store);
|
|
641
|
+
const refs = {};
|
|
642
|
+
for(const key in store){
|
|
643
|
+
const value = store[key];
|
|
644
|
+
if (isRef(value) || isReactive(value)) {
|
|
645
|
+
// @ts-expect-error: the key is state or getter
|
|
646
|
+
refs[key] = // ---
|
|
647
|
+
toRef(store, key);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return refs;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
function inject$1(key, instance) {
|
|
655
|
+
if (instance && instance._context && instance._context.provides && instance._context.provides[key]) {
|
|
656
|
+
return instance._context.provides[key];
|
|
657
|
+
}
|
|
658
|
+
if (hasInjectionContext()) {
|
|
659
|
+
return inject$2(key, undefined);
|
|
660
|
+
}
|
|
661
|
+
return undefined;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
function provide(key, value, app) {
|
|
665
|
+
if (typeof app === 'undefined') {
|
|
666
|
+
const val = inject$1(key);
|
|
667
|
+
if (typeof val !== 'undefined') {
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
provide$1(key, value);
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
if (app && app._context && app._context.provides && app._context.provides[key]) {
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
app.provide(key, value);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
const HTTPClientSymbol = Symbol.for('AuthupHTTPClient');
|
|
680
|
+
function provideHTTPClient(client, app) {
|
|
681
|
+
provide(HTTPClientSymbol, client, app);
|
|
682
|
+
}
|
|
683
|
+
function hasHTTPClient(app) {
|
|
684
|
+
return !!inject$1(HTTPClientSymbol, app);
|
|
685
|
+
}
|
|
686
|
+
function injectHTTPClient(app) {
|
|
687
|
+
const instance = inject$1(HTTPClientSymbol, app);
|
|
688
|
+
if (!instance) {
|
|
689
|
+
throw new Error('The api client has not been injected.');
|
|
690
|
+
}
|
|
691
|
+
return instance;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/*
|
|
695
|
+
* Copyright (c) 2024.
|
|
696
|
+
* Author Peter Placzek (tada5hi)
|
|
697
|
+
* For the full copyright and license information,
|
|
698
|
+
* view the LICENSE file that was distributed with this source code.
|
|
699
|
+
*/ const STORE_ID = 'authup';
|
|
700
|
+
|
|
701
|
+
function createStore(context = {}) {
|
|
702
|
+
const client = new Client({
|
|
703
|
+
baseURL: context.baseURL
|
|
704
|
+
});
|
|
705
|
+
const initialized = ref(false);
|
|
706
|
+
const setInitialized = (value)=>{
|
|
707
|
+
initialized.value = value;
|
|
708
|
+
};
|
|
709
|
+
// --------------------------------------------------------------------
|
|
710
|
+
const accessToken = ref(undefined);
|
|
711
|
+
const setAccessToken = (input)=>{
|
|
712
|
+
accessToken.value = input;
|
|
713
|
+
};
|
|
714
|
+
// --------------------------------------------------------------------
|
|
715
|
+
const accessTokenExpireDate = ref(undefined);
|
|
716
|
+
const setAccessTokenExpireDate = (input)=>{
|
|
717
|
+
if (typeof input === 'number' || typeof input === 'string') {
|
|
718
|
+
accessTokenExpireDate.value = new Date(input); // verify microseconds or seconds
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
accessTokenExpireDate.value = input;
|
|
722
|
+
};
|
|
723
|
+
// --------------------------------------------------------------------
|
|
724
|
+
const refreshToken = ref(undefined);
|
|
725
|
+
const setRefreshToken = (input)=>{
|
|
726
|
+
refreshToken.value = input;
|
|
727
|
+
};
|
|
728
|
+
// --------------------------------------------------------------------
|
|
729
|
+
const handleTokenGrantResponse = (response)=>{
|
|
730
|
+
const expireDate = new Date(Date.now() + response.expires_in * 1000);
|
|
731
|
+
setAccessTokenExpireDate(expireDate);
|
|
732
|
+
setAccessToken(response.access_token);
|
|
733
|
+
setRefreshToken(response.refresh_token);
|
|
734
|
+
};
|
|
735
|
+
// --------------------------------------------------------------------
|
|
736
|
+
let refreshTokenPromise;
|
|
737
|
+
const attemptRefreshToken = ()=>{
|
|
738
|
+
if (!refreshToken.value) {
|
|
739
|
+
return Promise.reject(new Error('No refresh token is present.'));
|
|
740
|
+
}
|
|
741
|
+
if (refreshTokenPromise) {
|
|
742
|
+
return refreshTokenPromise;
|
|
743
|
+
}
|
|
744
|
+
refreshTokenPromise = client.token.createWithRefreshToken({
|
|
745
|
+
refresh_token: refreshToken.value
|
|
746
|
+
}).then((r)=>{
|
|
747
|
+
handleTokenGrantResponse(r);
|
|
748
|
+
return r;
|
|
749
|
+
}).finally(()=>{
|
|
750
|
+
refreshTokenPromise = undefined;
|
|
751
|
+
});
|
|
752
|
+
return refreshTokenPromise;
|
|
753
|
+
};
|
|
754
|
+
// --------------------------------------------------------------------
|
|
755
|
+
const user = ref(undefined);
|
|
756
|
+
const userId = computed(()=>user.value ? user.value.id : undefined);
|
|
757
|
+
const userResolved = ref(false);
|
|
758
|
+
const setUser = (entity)=>{
|
|
759
|
+
user.value = entity;
|
|
760
|
+
userResolved.value = !!entity;
|
|
761
|
+
};
|
|
762
|
+
// --------------------------------------------------------------------
|
|
763
|
+
const realm = ref(undefined);
|
|
764
|
+
const realmId = computed(()=>realm.value ? realm.value.id : undefined);
|
|
765
|
+
const realmName = computed(()=>realm.value ? realm.value.name : undefined);
|
|
766
|
+
const realmIsRoot = computed(()=>{
|
|
767
|
+
if (realm.value) {
|
|
768
|
+
return realm.value.name === REALM_MASTER_NAME;
|
|
769
|
+
}
|
|
770
|
+
return false;
|
|
771
|
+
});
|
|
772
|
+
const setRealm = (entity)=>{
|
|
773
|
+
realm.value = entity;
|
|
774
|
+
};
|
|
775
|
+
const realmManagement = ref(undefined);
|
|
776
|
+
const realmManagementId = computed(()=>realmManagement.value ? realmManagement.value.id : realmId.value);
|
|
777
|
+
const realmManagementName = computed(()=>realmManagement.value ? realmManagement.value.name : realmName.value);
|
|
778
|
+
const setRealmManagement = (entity)=>{
|
|
779
|
+
realmManagement.value = entity;
|
|
780
|
+
};
|
|
781
|
+
const abilities = new Abilities();
|
|
782
|
+
const tokenInfo = ref(undefined);
|
|
783
|
+
const tokenResolved = ref(false);
|
|
784
|
+
const setTokenInfo = (entity)=>{
|
|
785
|
+
tokenResolved.value = !!entity;
|
|
786
|
+
tokenInfo.value = entity;
|
|
787
|
+
if (!entity) {
|
|
788
|
+
setRealm(undefined);
|
|
789
|
+
setRealmManagement(undefined);
|
|
790
|
+
abilities.set([]);
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
if (entity.exp) {
|
|
794
|
+
const expireDate = new Date(entity.exp * 1000);
|
|
795
|
+
setAccessTokenExpireDate(expireDate);
|
|
796
|
+
}
|
|
797
|
+
if (entity.realm_id && entity.realm_name) {
|
|
798
|
+
realm.value = {
|
|
799
|
+
id: entity.realm_id,
|
|
800
|
+
name: entity.realm_name
|
|
801
|
+
};
|
|
802
|
+
if (typeof realmManagement.value === 'undefined') {
|
|
803
|
+
setRealmManagement(realm.value);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
if (entity.permissions) {
|
|
807
|
+
abilities.set(entity.permissions);
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
// --------------------------------------------------------------------
|
|
811
|
+
const resolve = async (ctx = {})=>{
|
|
812
|
+
if (!accessToken.value || ctx.attempts && ctx.attempts > 3) return;
|
|
813
|
+
try {
|
|
814
|
+
if (!tokenResolved.value || ctx.refresh) {
|
|
815
|
+
const token = await client.token.introspect({
|
|
816
|
+
token: accessToken.value
|
|
817
|
+
}, {
|
|
818
|
+
authorizationHeader: {
|
|
819
|
+
type: 'Bearer',
|
|
820
|
+
token: accessToken.value
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
setTokenInfo(token);
|
|
824
|
+
tokenResolved.value = true;
|
|
825
|
+
}
|
|
826
|
+
if (!userResolved.value || ctx.refresh) {
|
|
827
|
+
const entity = await client.userInfo.get(`Bearer ${accessToken.value}`);
|
|
828
|
+
setUser(entity);
|
|
829
|
+
userResolved.value = true;
|
|
830
|
+
}
|
|
831
|
+
} catch (e) {
|
|
832
|
+
if (isClientTokenExpiredError(e)) {
|
|
833
|
+
await attemptRefreshToken();
|
|
834
|
+
await resolve({
|
|
835
|
+
refresh: true,
|
|
836
|
+
attempts: ctx.attempts ? ctx.attempts++ : 1
|
|
837
|
+
});
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
throw e;
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
const loggedIn = computed(()=>!!accessToken.value);
|
|
844
|
+
const login = async (ctx)=>{
|
|
845
|
+
try {
|
|
846
|
+
const response = await client.token.createWithPasswordGrant({
|
|
847
|
+
username: ctx.name,
|
|
848
|
+
password: ctx.password,
|
|
849
|
+
...realmId.value ? {
|
|
850
|
+
realm_id: ctx.realmId
|
|
851
|
+
} : {}
|
|
852
|
+
});
|
|
853
|
+
handleTokenGrantResponse(response);
|
|
854
|
+
await resolve();
|
|
855
|
+
} catch (e) {
|
|
856
|
+
setUser(undefined);
|
|
857
|
+
throw e;
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
const logout = ()=>{
|
|
861
|
+
setAccessToken(undefined);
|
|
862
|
+
setAccessTokenExpireDate(undefined);
|
|
863
|
+
setRefreshToken(undefined);
|
|
864
|
+
setUser(undefined);
|
|
865
|
+
setTokenInfo(undefined);
|
|
866
|
+
};
|
|
867
|
+
return {
|
|
868
|
+
initialized,
|
|
869
|
+
setInitialized,
|
|
870
|
+
abilities,
|
|
871
|
+
login,
|
|
872
|
+
logout,
|
|
873
|
+
loggedIn,
|
|
874
|
+
resolve,
|
|
875
|
+
handleTokenGrantResponse,
|
|
876
|
+
accessToken,
|
|
877
|
+
setAccessToken,
|
|
878
|
+
accessTokenExpireDate,
|
|
879
|
+
setAccessTokenExpireDate,
|
|
880
|
+
refreshToken,
|
|
881
|
+
setRefreshToken,
|
|
882
|
+
tokenInfo,
|
|
883
|
+
setTokenInfo,
|
|
884
|
+
realm,
|
|
885
|
+
realmId,
|
|
886
|
+
realmIsRoot,
|
|
887
|
+
realmName,
|
|
888
|
+
setRealm,
|
|
889
|
+
realmManagement,
|
|
890
|
+
realmManagementId,
|
|
891
|
+
realmManagementName,
|
|
892
|
+
setRealmManagement,
|
|
893
|
+
user,
|
|
894
|
+
userId,
|
|
895
|
+
setUser
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
function tryOnScopeDispose(fn) {
|
|
900
|
+
if (getCurrentScope()) {
|
|
901
|
+
onScopeDispose(fn);
|
|
902
|
+
return true;
|
|
903
|
+
}
|
|
904
|
+
return false;
|
|
905
|
+
}
|
|
906
|
+
typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
|
|
907
|
+
const noop = ()=>{};
|
|
908
|
+
|
|
909
|
+
function useCookies(dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}, cookies = new Cookie()) {
|
|
910
|
+
const watchingDependencies = autoUpdateDependencies ? [
|
|
911
|
+
...[]
|
|
912
|
+
] : dependencies;
|
|
913
|
+
let previousCookies = cookies.getAll({
|
|
914
|
+
doNotParse: true
|
|
915
|
+
});
|
|
916
|
+
const touches = ref(0);
|
|
917
|
+
const onChange = ()=>{
|
|
918
|
+
const newCookies = cookies.getAll({
|
|
919
|
+
doNotParse: true
|
|
920
|
+
});
|
|
921
|
+
if (shouldUpdate(watchingDependencies || null, newCookies, previousCookies)) touches.value++;
|
|
922
|
+
previousCookies = newCookies;
|
|
923
|
+
};
|
|
924
|
+
cookies.addChangeListener(onChange);
|
|
925
|
+
tryOnScopeDispose(()=>{
|
|
926
|
+
cookies.removeChangeListener(onChange);
|
|
927
|
+
});
|
|
928
|
+
return {
|
|
929
|
+
/**
|
|
930
|
+
* Reactive get cookie by name. If **autoUpdateDependencies = true** then it will update watching dependencies
|
|
931
|
+
*/ get: (...args)=>{
|
|
932
|
+
if (autoUpdateDependencies && watchingDependencies && !watchingDependencies.includes(args[0])) watchingDependencies.push(args[0]);
|
|
933
|
+
touches.value;
|
|
934
|
+
return cookies.get(args[0], {
|
|
935
|
+
doNotParse,
|
|
936
|
+
...args[1]
|
|
937
|
+
});
|
|
938
|
+
},
|
|
939
|
+
/**
|
|
940
|
+
* Reactive get all cookies
|
|
941
|
+
*/ getAll: (...args)=>{
|
|
942
|
+
touches.value;
|
|
943
|
+
return cookies.getAll({
|
|
944
|
+
doNotParse,
|
|
945
|
+
...args[0]
|
|
946
|
+
});
|
|
947
|
+
},
|
|
948
|
+
set: (...args)=>cookies.set(...args),
|
|
949
|
+
remove: (...args)=>cookies.remove(...args),
|
|
950
|
+
addChangeListener: (...args)=>cookies.addChangeListener(...args),
|
|
951
|
+
removeChangeListener: (...args)=>cookies.removeChangeListener(...args)
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
function shouldUpdate(dependencies, newCookies, oldCookies) {
|
|
955
|
+
if (!dependencies) return true;
|
|
956
|
+
for (const dependency of dependencies){
|
|
957
|
+
if (newCookies[dependency] !== oldCookies[dependency]) return true;
|
|
958
|
+
}
|
|
959
|
+
return false;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
const StoreSymbol = Symbol.for('AuthupStore');
|
|
963
|
+
function useStore(pinia, app) {
|
|
964
|
+
const instance = injectStore(app);
|
|
965
|
+
if (!instance) {
|
|
966
|
+
throw new Error('The store has not been injected in the app context.');
|
|
967
|
+
}
|
|
968
|
+
return instance(pinia);
|
|
969
|
+
}
|
|
970
|
+
function injectStore(app) {
|
|
971
|
+
const instance = inject$1(StoreSymbol, app);
|
|
972
|
+
if (!instance) {
|
|
973
|
+
throw new Error('The store has not been injected in the app context.');
|
|
974
|
+
}
|
|
975
|
+
return instance;
|
|
976
|
+
}
|
|
977
|
+
function hasStore(app) {
|
|
978
|
+
return !!inject$1(StoreSymbol, app);
|
|
979
|
+
}
|
|
980
|
+
function provideStore(store, app) {
|
|
981
|
+
provide(StoreSymbol, store, app);
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
function installStore(app, options = {}) {
|
|
985
|
+
if (hasStore(app)) {
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
const storeCreator = defineStore(STORE_ID, ()=>createStore({
|
|
989
|
+
baseURL: options.baseURL
|
|
990
|
+
}));
|
|
991
|
+
const store = storeCreator(options.pinia);
|
|
992
|
+
const cookies = useCookies();
|
|
993
|
+
let cookieGet;
|
|
994
|
+
if (options.cookieGet) {
|
|
995
|
+
cookieGet = options.cookieGet;
|
|
996
|
+
} else {
|
|
997
|
+
cookieGet = cookies.get;
|
|
998
|
+
}
|
|
999
|
+
let cookieSet;
|
|
1000
|
+
if (options.cookieSet) {
|
|
1001
|
+
cookieSet = options.cookieSet;
|
|
1002
|
+
} else {
|
|
1003
|
+
cookieSet = cookies.set;
|
|
1004
|
+
}
|
|
1005
|
+
let cookieUnset;
|
|
1006
|
+
if (options.cookieUnset) {
|
|
1007
|
+
cookieUnset = options.cookieUnset;
|
|
1008
|
+
} else if (options.cookieSet) {
|
|
1009
|
+
cookieUnset = (key)=>{
|
|
1010
|
+
options.cookieSet(key, null);
|
|
1011
|
+
};
|
|
1012
|
+
} else {
|
|
1013
|
+
cookieUnset = cookies.remove;
|
|
1014
|
+
}
|
|
1015
|
+
const initStore = ()=>{
|
|
1016
|
+
if (store.initialized) {
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
store.setInitialized(true);
|
|
1020
|
+
const keys = Object.values(CookieName);
|
|
1021
|
+
let value;
|
|
25
1022
|
for(let i = 0; i < keys.length; i++){
|
|
26
|
-
|
|
1023
|
+
value = cookieGet(keys[i]);
|
|
1024
|
+
if (!value) {
|
|
1025
|
+
continue;
|
|
1026
|
+
}
|
|
1027
|
+
switch(keys[i]){
|
|
1028
|
+
case CookieName.ACCESS_TOKEN:
|
|
1029
|
+
if (!store.accessToken) {
|
|
1030
|
+
store.setAccessToken(value);
|
|
1031
|
+
}
|
|
1032
|
+
break;
|
|
1033
|
+
case CookieName.ACCESS_TOKEN_EXPIRE_DATE:
|
|
1034
|
+
if (!store.accessTokenExpireDate) {
|
|
1035
|
+
store.setAccessTokenExpireDate(value);
|
|
1036
|
+
}
|
|
1037
|
+
break;
|
|
1038
|
+
case CookieName.REFRESH_TOKEN:
|
|
1039
|
+
if (!store.refreshToken) {
|
|
1040
|
+
store.setRefreshToken(value);
|
|
1041
|
+
}
|
|
1042
|
+
break;
|
|
1043
|
+
case CookieName.USER:
|
|
1044
|
+
if (!store.user) {
|
|
1045
|
+
store.setUser(value);
|
|
1046
|
+
}
|
|
1047
|
+
break;
|
|
1048
|
+
case CookieName.REALM:
|
|
1049
|
+
if (!store.realm) {
|
|
1050
|
+
store.setRealm(value);
|
|
1051
|
+
}
|
|
1052
|
+
break;
|
|
1053
|
+
case CookieName.REALM_MANAGEMENT:
|
|
1054
|
+
if (!store.realmManagement) {
|
|
1055
|
+
store.setRealmManagement(value);
|
|
1056
|
+
}
|
|
1057
|
+
break;
|
|
1058
|
+
}
|
|
27
1059
|
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* @param group
|
|
33
|
-
* @param options
|
|
34
|
-
*/ setOptions(group, options) {
|
|
35
|
-
if (typeof this.data[group] === 'undefined') {
|
|
36
|
-
this.data[group] = {};
|
|
1060
|
+
};
|
|
1061
|
+
store.$onAction((action)=>{
|
|
1062
|
+
if (action.store.$id !== STORE_ID) {
|
|
1063
|
+
return;
|
|
37
1064
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return this.data[group];
|
|
1065
|
+
if (action.name === 'logout') {
|
|
1066
|
+
cookieUnset(CookieName.ACCESS_TOKEN);
|
|
1067
|
+
cookieUnset(CookieName.ACCESS_TOKEN_EXPIRE_DATE);
|
|
1068
|
+
cookieUnset(CookieName.REFRESH_TOKEN);
|
|
1069
|
+
cookieUnset(CookieName.USER);
|
|
1070
|
+
cookieUnset(CookieName.REALM);
|
|
1071
|
+
cookieUnset(CookieName.REALM_MANAGEMENT);
|
|
46
1072
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
getOption(group, option) {
|
|
53
|
-
if (typeof this.data[group] === 'undefined') {
|
|
54
|
-
return undefined;
|
|
1073
|
+
});
|
|
1074
|
+
initStore();
|
|
1075
|
+
store.$subscribe((mutation, state)=>{
|
|
1076
|
+
if (mutation.storeId !== STORE_ID) {
|
|
1077
|
+
return;
|
|
55
1078
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
constructor(){
|
|
59
|
-
this.data = {};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
class StoreManager {
|
|
63
|
-
keys() {
|
|
64
|
-
return Object.keys(this.instances);
|
|
65
|
-
}
|
|
66
|
-
use(key) {
|
|
67
|
-
if (typeof this.instances[key] !== 'undefined') {
|
|
68
|
-
return this.instances[key];
|
|
1079
|
+
if (state.accessToken) {
|
|
1080
|
+
cookieSet(CookieName.ACCESS_TOKEN, state.accessToken);
|
|
69
1081
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
constructor(){
|
|
74
|
-
this.instances = {};
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function applyStoreManagerOptions(manager, options) {
|
|
78
|
-
if (options.presets) {
|
|
79
|
-
const presetKeys = Object.keys(options.presets);
|
|
80
|
-
for(let i = 0; i < presetKeys.length; i++){
|
|
81
|
-
const store = manager.use(presetKeys[i]);
|
|
82
|
-
store.setAll(options.presets[presetKeys[i]]);
|
|
1082
|
+
if (state.accessTokenExpireDate) {
|
|
1083
|
+
cookieSet(CookieName.ACCESS_TOKEN_EXPIRE_DATE, state.accessTokenExpireDate);
|
|
83
1084
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const store = manager.use(StoreName.DEFAULT);
|
|
87
|
-
store.setAll(options.defaults);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function getSymbol(key) {
|
|
91
|
-
{
|
|
92
|
-
return Symbol.for(`VCStoreManager#${key}`);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function installStoreManager(instance, key) {
|
|
96
|
-
let manager;
|
|
97
|
-
const symbol = getSymbol(key);
|
|
98
|
-
if (instance._context && instance._context.provides && instance._context.provides[symbol]) {
|
|
99
|
-
return instance._context.provides[symbol];
|
|
100
|
-
}
|
|
101
|
-
if (hasInjectionContext()) {
|
|
102
|
-
manager = inject$2(symbol, undefined);
|
|
103
|
-
if (manager) {
|
|
104
|
-
return manager;
|
|
1085
|
+
if (state.refreshToken) {
|
|
1086
|
+
cookieSet(CookieName.REFRESH_TOKEN, state.refreshToken);
|
|
105
1087
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return inject$2(key, undefined);
|
|
118
|
-
}
|
|
119
|
-
return undefined;
|
|
1088
|
+
if (state.user) {
|
|
1089
|
+
cookieSet(CookieName.USER, state.user);
|
|
1090
|
+
}
|
|
1091
|
+
if (state.realm) {
|
|
1092
|
+
cookieSet(CookieName.REALM, state.realm);
|
|
1093
|
+
}
|
|
1094
|
+
if (state.realmManagement) {
|
|
1095
|
+
cookieSet(CookieName.REALM_MANAGEMENT, state.realmManagement);
|
|
1096
|
+
}
|
|
1097
|
+
});
|
|
1098
|
+
provideStore(storeCreator, app);
|
|
120
1099
|
}
|
|
121
1100
|
|
|
122
|
-
function
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
1101
|
+
function storeToRefs(store) {
|
|
1102
|
+
store = toRaw(store);
|
|
1103
|
+
const refs = {};
|
|
1104
|
+
const keys = Object.keys(store);
|
|
1105
|
+
for(let i = 0; i < keys.length; i++){
|
|
1106
|
+
const value = store[keys[i]];
|
|
1107
|
+
if (isRef(value) || isReactive(value)) {
|
|
1108
|
+
refs[keys[i]] = toRef(store, keys[i]);
|
|
127
1109
|
}
|
|
128
|
-
provide$1(key, value);
|
|
129
|
-
return;
|
|
130
1110
|
}
|
|
131
|
-
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
app.provide(key, value);
|
|
1111
|
+
return refs;
|
|
135
1112
|
}
|
|
136
1113
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
function injectAPIClient() {
|
|
142
|
-
const instance = inject$1(APIClientSymbol);
|
|
143
|
-
if (!instance) {
|
|
144
|
-
throw new Error('The api client has not been injected.');
|
|
1114
|
+
function installHTTPClient(app, options = {}) {
|
|
1115
|
+
if (hasHTTPClient(app)) {
|
|
1116
|
+
return;
|
|
145
1117
|
}
|
|
146
|
-
|
|
1118
|
+
const client = new Client({
|
|
1119
|
+
baseURL: options.baseURL
|
|
1120
|
+
});
|
|
1121
|
+
const storeCreator = injectStore(app);
|
|
1122
|
+
const store = storeCreator(options.pinia);
|
|
1123
|
+
const { refreshToken } = storeToRefs$1(store);
|
|
1124
|
+
const tokenHook = new ClientResponseErrorTokenHook(client, {
|
|
1125
|
+
baseURL: options.baseURL,
|
|
1126
|
+
tokenCreator: ()=>{
|
|
1127
|
+
if (!refreshToken.value) {
|
|
1128
|
+
throw new Error('No refresh token available.');
|
|
1129
|
+
}
|
|
1130
|
+
return client.token.createWithRefreshToken({
|
|
1131
|
+
refresh_token: refreshToken.value
|
|
1132
|
+
});
|
|
1133
|
+
},
|
|
1134
|
+
tokenCreated: (response)=>{
|
|
1135
|
+
store.handleTokenGrantResponse(response);
|
|
1136
|
+
},
|
|
1137
|
+
tokenFailed: ()=>{
|
|
1138
|
+
store.logout();
|
|
1139
|
+
}
|
|
1140
|
+
});
|
|
1141
|
+
store.$subscribe((mutation, state)=>{
|
|
1142
|
+
if (mutation.storeId !== STORE_ID) return;
|
|
1143
|
+
if (state.accessToken) {
|
|
1144
|
+
client.setAuthorizationHeader({
|
|
1145
|
+
type: 'Bearer',
|
|
1146
|
+
token: state.accessToken
|
|
1147
|
+
});
|
|
1148
|
+
tokenHook.mount();
|
|
1149
|
+
} else {
|
|
1150
|
+
client.unsetAuthorizationHeader();
|
|
1151
|
+
tokenHook.unmount();
|
|
1152
|
+
}
|
|
1153
|
+
if (state.refreshToken && state.accessTokenExpireDate) {
|
|
1154
|
+
const expiresIn = Math.floor((state.accessTokenExpireDate.getTime() - Date.now()) / 1000);
|
|
1155
|
+
tokenHook.setTimer({
|
|
1156
|
+
refresh_token: ()=>refreshToken.value,
|
|
1157
|
+
expires_in: expiresIn
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
});
|
|
1161
|
+
provideHTTPClient(client, app);
|
|
147
1162
|
}
|
|
148
1163
|
|
|
149
1164
|
function renderEntityAssignAction(ctx) {
|
|
@@ -286,270 +1301,60 @@ function buildListCreatedHandler(items, cb) {
|
|
|
286
1301
|
index = -1;
|
|
287
1302
|
}
|
|
288
1303
|
if (index === -1) {
|
|
289
|
-
if (options.unshift) {
|
|
290
|
-
items.value.unshift(item);
|
|
291
|
-
} else {
|
|
292
|
-
items.value.push(item);
|
|
293
|
-
}
|
|
294
|
-
if (cb) {
|
|
295
|
-
cb(item);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
function buildListUpdatedHandler(items, cb) {
|
|
301
|
-
return (item)=>{
|
|
302
|
-
if (!isObject(item)) {
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
const index = items.value.findIndex((el)=>el.id === item.id);
|
|
306
|
-
if (index !== -1) {
|
|
307
|
-
const keys = Object.keys(item);
|
|
308
|
-
for(let i = 0; i < keys.length; i++){
|
|
309
|
-
items.value[index][keys[i]] = item[keys[i]];
|
|
310
|
-
}
|
|
311
|
-
if (cb) {
|
|
312
|
-
cb(item);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
function buildListDeletedHandler(items, cb) {
|
|
318
|
-
return (item)=>{
|
|
319
|
-
if (!isObject(item)) {
|
|
320
|
-
return undefined;
|
|
321
|
-
}
|
|
322
|
-
const index = items.value.findIndex((el)=>el.id === item.id);
|
|
323
|
-
if (index !== -1) {
|
|
324
|
-
if (cb) {
|
|
325
|
-
cb(items.value[index]);
|
|
326
|
-
}
|
|
327
|
-
return items.value.splice(index, 1).pop();
|
|
328
|
-
}
|
|
329
|
-
return undefined;
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
/*
|
|
334
|
-
* Copyright (c) 2023.
|
|
335
|
-
* Author Peter Placzek (tada5hi)
|
|
336
|
-
* For the full copyright and license information,
|
|
337
|
-
* view the LICENSE file that was distributed with this source code.
|
|
338
|
-
*/ function boolableToObject(input) {
|
|
339
|
-
if (typeof input === 'boolean') {
|
|
340
|
-
return {};
|
|
341
|
-
}
|
|
342
|
-
return input;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
const createStore = (context)=>{
|
|
346
|
-
const client = new Client({
|
|
347
|
-
baseURL: context.baseURL
|
|
348
|
-
});
|
|
349
|
-
// --------------------------------------------------------------------
|
|
350
|
-
const accessToken = ref(undefined);
|
|
351
|
-
const setAccessToken = (input)=>{
|
|
352
|
-
accessToken.value = input;
|
|
353
|
-
};
|
|
354
|
-
// --------------------------------------------------------------------
|
|
355
|
-
const accessTokenExpireDate = ref(undefined);
|
|
356
|
-
const setAccessTokenExpireDate = (input)=>{
|
|
357
|
-
if (typeof input === 'number' || typeof input === 'string') {
|
|
358
|
-
accessTokenExpireDate.value = new Date(input); // verify microseconds or seconds
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
361
|
-
accessTokenExpireDate.value = input;
|
|
362
|
-
};
|
|
363
|
-
// --------------------------------------------------------------------
|
|
364
|
-
const refreshToken = ref(undefined);
|
|
365
|
-
const setRefreshToken = (input)=>{
|
|
366
|
-
refreshToken.value = input;
|
|
367
|
-
};
|
|
368
|
-
const handleTokenGrantResponse = (response)=>{
|
|
369
|
-
const expireDate = new Date(Date.now() + response.expires_in * 1000);
|
|
370
|
-
setAccessTokenExpireDate(expireDate);
|
|
371
|
-
setAccessToken(response.access_token);
|
|
372
|
-
setRefreshToken(response.refresh_token);
|
|
373
|
-
};
|
|
374
|
-
let refreshTokenPromise;
|
|
375
|
-
const attemptRefreshToken = ()=>{
|
|
376
|
-
if (!refreshToken.value) {
|
|
377
|
-
return Promise.reject(new Error('No refresh token is present.'));
|
|
378
|
-
}
|
|
379
|
-
if (refreshTokenPromise) {
|
|
380
|
-
return refreshTokenPromise;
|
|
381
|
-
}
|
|
382
|
-
refreshTokenPromise = client.token.createWithRefreshToken({
|
|
383
|
-
refresh_token: refreshToken.value
|
|
384
|
-
}).then((r)=>{
|
|
385
|
-
handleTokenGrantResponse(r);
|
|
386
|
-
refreshTokenPromise = undefined;
|
|
387
|
-
return r;
|
|
388
|
-
}).catch((e)=>{
|
|
389
|
-
refreshTokenPromise = undefined;
|
|
390
|
-
throw e;
|
|
391
|
-
});
|
|
392
|
-
return refreshTokenPromise;
|
|
393
|
-
};
|
|
394
|
-
// --------------------------------------------------------------------
|
|
395
|
-
const user = ref(undefined);
|
|
396
|
-
const userId = computed(()=>user.value ? user.value.id : undefined);
|
|
397
|
-
const userResolved = ref(false);
|
|
398
|
-
const setUser = (entity)=>{
|
|
399
|
-
user.value = entity;
|
|
400
|
-
userResolved.value = !!entity;
|
|
401
|
-
};
|
|
402
|
-
// --------------------------------------------------------------------
|
|
403
|
-
const abilityManager = new AbilityManager();
|
|
404
|
-
const tokenInfo = ref(undefined);
|
|
405
|
-
const tokenResolved = ref(false);
|
|
406
|
-
const has = (name)=>abilityManager.has(name);
|
|
407
|
-
const realm = ref(undefined);
|
|
408
|
-
const realmId = computed(()=>realm.value ? realm.value.id : undefined);
|
|
409
|
-
const realmName = computed(()=>realm.value ? realm.value.name : undefined);
|
|
410
|
-
const setRealm = (entity)=>{
|
|
411
|
-
realm.value = entity;
|
|
412
|
-
};
|
|
413
|
-
const realmManagement = ref(undefined);
|
|
414
|
-
const realmManagementId = computed(()=>realmManagement.value ? realmManagement.value.id : realmId.value);
|
|
415
|
-
const realmManagementName = computed(()=>realmManagement.value ? realmManagement.value.name : realmName.value);
|
|
416
|
-
const setRealmManagement = (entity)=>{
|
|
417
|
-
realmManagement.value = entity;
|
|
418
|
-
};
|
|
419
|
-
const setTokenInfo = (entity)=>{
|
|
420
|
-
tokenResolved.value = !!entity;
|
|
421
|
-
tokenInfo.value = entity;
|
|
422
|
-
if (!entity) {
|
|
423
|
-
setRealm(undefined);
|
|
424
|
-
setRealmManagement(undefined);
|
|
425
|
-
abilityManager.set([]);
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
if (entity.exp) {
|
|
429
|
-
const expireDate = new Date(entity.exp * 1000);
|
|
430
|
-
setAccessTokenExpireDate(expireDate);
|
|
431
|
-
}
|
|
432
|
-
if (entity.realm_id && entity.realm_name) {
|
|
433
|
-
realm.value = {
|
|
434
|
-
id: entity.realm_id,
|
|
435
|
-
name: entity.realm_name
|
|
436
|
-
};
|
|
437
|
-
if (typeof realmManagement.value === 'undefined') {
|
|
438
|
-
setRealmManagement(realm.value);
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
if (entity.permissions) {
|
|
442
|
-
abilityManager.set(entity.permissions);
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
// --------------------------------------------------------------------
|
|
446
|
-
const resolve = async (ctx = {})=>{
|
|
447
|
-
if (!accessToken.value || ctx.attempts && ctx.attempts > 3) return;
|
|
448
|
-
try {
|
|
449
|
-
if (!tokenResolved.value || ctx.refresh) {
|
|
450
|
-
const token = await client.token.introspect({
|
|
451
|
-
token: accessToken.value
|
|
452
|
-
}, {
|
|
453
|
-
authorizationHeader: {
|
|
454
|
-
type: 'Bearer',
|
|
455
|
-
token: accessToken.value
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
setTokenInfo(token);
|
|
459
|
-
tokenResolved.value = true;
|
|
460
|
-
}
|
|
461
|
-
if (!userResolved.value || ctx.refresh) {
|
|
462
|
-
const entity = await client.userInfo.get(`Bearer ${accessToken.value}`);
|
|
463
|
-
setUser(entity);
|
|
464
|
-
userResolved.value = true;
|
|
1304
|
+
if (options.unshift) {
|
|
1305
|
+
items.value.unshift(item);
|
|
1306
|
+
} else {
|
|
1307
|
+
items.value.push(item);
|
|
465
1308
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
await attemptRefreshToken();
|
|
469
|
-
await resolve({
|
|
470
|
-
refresh: true,
|
|
471
|
-
attempts: ctx.attempts ? ctx.attempts++ : 1
|
|
472
|
-
});
|
|
473
|
-
return;
|
|
1309
|
+
if (cb) {
|
|
1310
|
+
cb(item);
|
|
474
1311
|
}
|
|
475
|
-
throw e;
|
|
476
1312
|
}
|
|
477
1313
|
};
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
1314
|
+
}
|
|
1315
|
+
function buildListUpdatedHandler(items, cb) {
|
|
1316
|
+
return (item)=>{
|
|
1317
|
+
if (!isObject(item)) {
|
|
1318
|
+
return;
|
|
1319
|
+
}
|
|
1320
|
+
const index = items.value.findIndex((el)=>el.id === item.id);
|
|
1321
|
+
if (index !== -1) {
|
|
1322
|
+
const keys = Object.keys(item);
|
|
1323
|
+
for(let i = 0; i < keys.length; i++){
|
|
1324
|
+
items.value[index][keys[i]] = item[keys[i]];
|
|
1325
|
+
}
|
|
1326
|
+
if (cb) {
|
|
1327
|
+
cb(item);
|
|
1328
|
+
}
|
|
493
1329
|
}
|
|
494
1330
|
};
|
|
495
|
-
const logout = ()=>{
|
|
496
|
-
setAccessToken(undefined);
|
|
497
|
-
setRefreshToken(undefined);
|
|
498
|
-
setUser(undefined);
|
|
499
|
-
setTokenInfo(undefined);
|
|
500
|
-
};
|
|
501
|
-
return {
|
|
502
|
-
login,
|
|
503
|
-
logout,
|
|
504
|
-
loggedIn,
|
|
505
|
-
resolve,
|
|
506
|
-
handleTokenGrantResponse,
|
|
507
|
-
accessToken,
|
|
508
|
-
setAccessToken,
|
|
509
|
-
accessTokenExpireDate,
|
|
510
|
-
setAccessTokenExpireDate,
|
|
511
|
-
refreshToken,
|
|
512
|
-
setRefreshToken,
|
|
513
|
-
tokenInfo,
|
|
514
|
-
setTokenInfo,
|
|
515
|
-
realm,
|
|
516
|
-
realmId,
|
|
517
|
-
realmName,
|
|
518
|
-
setRealm,
|
|
519
|
-
realmManagement,
|
|
520
|
-
realmManagementId,
|
|
521
|
-
realmManagementName,
|
|
522
|
-
setRealmManagement,
|
|
523
|
-
user,
|
|
524
|
-
userId,
|
|
525
|
-
setUser,
|
|
526
|
-
has
|
|
527
|
-
};
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
const StoreSymbol = Symbol.for('AuthupStore');
|
|
531
|
-
function injectStore() {
|
|
532
|
-
const instance = inject$1(StoreSymbol);
|
|
533
|
-
if (!instance) {
|
|
534
|
-
throw new Error('The store has not been injected in the app context.');
|
|
535
|
-
}
|
|
536
|
-
return instance;
|
|
537
1331
|
}
|
|
538
|
-
function
|
|
539
|
-
|
|
1332
|
+
function buildListDeletedHandler(items, cb) {
|
|
1333
|
+
return (item)=>{
|
|
1334
|
+
if (!isObject(item)) {
|
|
1335
|
+
return undefined;
|
|
1336
|
+
}
|
|
1337
|
+
const index = items.value.findIndex((el)=>el.id === item.id);
|
|
1338
|
+
if (index !== -1) {
|
|
1339
|
+
if (cb) {
|
|
1340
|
+
cb(items.value[index]);
|
|
1341
|
+
}
|
|
1342
|
+
return items.value.splice(index, 1).pop();
|
|
1343
|
+
}
|
|
1344
|
+
return undefined;
|
|
1345
|
+
};
|
|
540
1346
|
}
|
|
541
1347
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
}
|
|
1348
|
+
/*
|
|
1349
|
+
* Copyright (c) 2023.
|
|
1350
|
+
* Author Peter Placzek (tada5hi)
|
|
1351
|
+
* For the full copyright and license information,
|
|
1352
|
+
* view the LICENSE file that was distributed with this source code.
|
|
1353
|
+
*/ function boolableToObject(input) {
|
|
1354
|
+
if (typeof input === 'boolean') {
|
|
1355
|
+
return {};
|
|
551
1356
|
}
|
|
552
|
-
return
|
|
1357
|
+
return input;
|
|
553
1358
|
}
|
|
554
1359
|
|
|
555
1360
|
const SocketClientSymbol = Symbol.for('AuthupSocketClientManager');
|
|
@@ -571,6 +1376,13 @@ function injectSocketClientManager() {
|
|
|
571
1376
|
return manager;
|
|
572
1377
|
}
|
|
573
1378
|
|
|
1379
|
+
function installSocketClientManager(app, options) {
|
|
1380
|
+
const socketClientManager = new ClientManager({
|
|
1381
|
+
url: options.baseURL
|
|
1382
|
+
});
|
|
1383
|
+
provideSocketClientManager(socketClientManager, app);
|
|
1384
|
+
}
|
|
1385
|
+
|
|
574
1386
|
function createEntitySocket(ctx) {
|
|
575
1387
|
if (!isSocketClientManagerInjected()) {
|
|
576
1388
|
return {
|
|
@@ -578,7 +1390,7 @@ function createEntitySocket(ctx) {
|
|
|
578
1390
|
unmount () {}
|
|
579
1391
|
};
|
|
580
1392
|
}
|
|
581
|
-
const store =
|
|
1393
|
+
const store = useStore();
|
|
582
1394
|
const storeRefs = storeToRefs(store);
|
|
583
1395
|
const realmId = computed(()=>{
|
|
584
1396
|
if (storeRefs.realmName.value === REALM_MASTER_NAME) {
|
|
@@ -727,9 +1539,9 @@ function createList(context) {
|
|
|
727
1539
|
}
|
|
728
1540
|
return undefined;
|
|
729
1541
|
});
|
|
730
|
-
const client =
|
|
1542
|
+
const client = injectHTTPClient();
|
|
731
1543
|
let domainAPI;
|
|
732
|
-
if (hasOwnProperty
|
|
1544
|
+
if (hasOwnProperty(client, context.type)) {
|
|
733
1545
|
domainAPI = client[context.type];
|
|
734
1546
|
}
|
|
735
1547
|
let query;
|
|
@@ -739,7 +1551,7 @@ function createList(context) {
|
|
|
739
1551
|
meta.value.busy = true;
|
|
740
1552
|
try {
|
|
741
1553
|
let filters;
|
|
742
|
-
if (context.queryFilters && input.filters && hasOwnProperty
|
|
1554
|
+
if (context.queryFilters && input.filters && hasOwnProperty(input.filters, 'name') && typeof input.filters.name === 'string') {
|
|
743
1555
|
// todo: queryFilters should customize full filters object!
|
|
744
1556
|
filters = context.queryFilters(input.filters.name);
|
|
745
1557
|
}
|
|
@@ -933,7 +1745,7 @@ function createList(context) {
|
|
|
933
1745
|
* @param name
|
|
934
1746
|
* @param $slots
|
|
935
1747
|
*/ function hasNormalizedSlot(name, $slots = {}) {
|
|
936
|
-
return hasOwnProperty
|
|
1748
|
+
return hasOwnProperty($slots, name);
|
|
937
1749
|
}
|
|
938
1750
|
/**
|
|
939
1751
|
* Returns VNodes for named slot either scoped or unscoped
|
|
@@ -944,7 +1756,7 @@ function createList(context) {
|
|
|
944
1756
|
*
|
|
945
1757
|
* @returns {Array} VNodes
|
|
946
1758
|
*/ function normalizeSlot(name, scope = {}, $slots = {}) {
|
|
947
|
-
if (hasOwnProperty
|
|
1759
|
+
if (hasOwnProperty($slots, name)) {
|
|
948
1760
|
return $slots[name](scope);
|
|
949
1761
|
}
|
|
950
1762
|
return [];
|
|
@@ -994,9 +1806,9 @@ function defineEntityManagerProps() {
|
|
|
994
1806
|
}
|
|
995
1807
|
|
|
996
1808
|
function createEntityManager(ctx) {
|
|
997
|
-
const client =
|
|
1809
|
+
const client = injectHTTPClient();
|
|
998
1810
|
let domainAPI;
|
|
999
|
-
if (hasOwnProperty
|
|
1811
|
+
if (hasOwnProperty(client, ctx.type)) {
|
|
1000
1812
|
domainAPI = client[ctx.type];
|
|
1001
1813
|
}
|
|
1002
1814
|
const entity = ref(undefined);
|
|
@@ -1010,7 +1822,7 @@ function createEntityManager(ctx) {
|
|
|
1010
1822
|
realmId = isRef(ctx.realmId) ? ctx.realmId.value : ctx.realmId;
|
|
1011
1823
|
}
|
|
1012
1824
|
if (!realmId && entity.value) {
|
|
1013
|
-
if (hasOwnProperty
|
|
1825
|
+
if (hasOwnProperty(entity.value, 'realm_id') && typeof entity.value.realm_id === 'string') {
|
|
1014
1826
|
return entity.value.realm_id;
|
|
1015
1827
|
}
|
|
1016
1828
|
}
|
|
@@ -1429,9 +2241,6 @@ class MemoryStore {
|
|
|
1429
2241
|
}
|
|
1430
2242
|
}
|
|
1431
2243
|
|
|
1432
|
-
typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
|
|
1433
|
-
const noop = ()=>{};
|
|
1434
|
-
|
|
1435
2244
|
function computedAsync(evaluationCallback, initialState, optionsOrRef) {
|
|
1436
2245
|
let options;
|
|
1437
2246
|
if (isRef(optionsOrRef)) {
|
|
@@ -1641,7 +2450,7 @@ function extractVuelidateResultsFromChild(vuelidate, child, keys) {
|
|
|
1641
2450
|
const childKeys = keys ?? Object.keys(childResults).filter((key)=>!key.startsWith('$'));
|
|
1642
2451
|
const result = {};
|
|
1643
2452
|
for(let i = 0; i < childKeys.length; i++){
|
|
1644
|
-
if (hasOwnProperty
|
|
2453
|
+
if (hasOwnProperty(childResults, childKeys[i])) {
|
|
1645
2454
|
result[childKeys[i]] = childResults[childKeys[i]].$model;
|
|
1646
2455
|
}
|
|
1647
2456
|
}
|
|
@@ -1811,6 +2620,33 @@ function useUpdatedAt(input) {
|
|
|
1811
2620
|
});
|
|
1812
2621
|
}
|
|
1813
2622
|
|
|
2623
|
+
function useAbilityCheck(name) {
|
|
2624
|
+
const { abilities } = useStore();
|
|
2625
|
+
const data = ref(false);
|
|
2626
|
+
data.value = abilities.has(name);
|
|
2627
|
+
let removeListener;
|
|
2628
|
+
onMounted(()=>{
|
|
2629
|
+
removeListener = abilities.on('updated', ()=>{
|
|
2630
|
+
data.value = abilities.has(name);
|
|
2631
|
+
});
|
|
2632
|
+
});
|
|
2633
|
+
onUnmounted(()=>{
|
|
2634
|
+
if (typeof removeListener !== 'undefined') {
|
|
2635
|
+
removeListener();
|
|
2636
|
+
}
|
|
2637
|
+
});
|
|
2638
|
+
return data;
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
function useRealmResourceWritableCheck(realmId) {
|
|
2642
|
+
const store = useStore();
|
|
2643
|
+
const { realm } = storeToRefs$1(store);
|
|
2644
|
+
return computed(()=>{
|
|
2645
|
+
const realmIdRaw = unref(realmId);
|
|
2646
|
+
return isRealmResourceWritable(realm.value, realmIdRaw);
|
|
2647
|
+
});
|
|
2648
|
+
}
|
|
2649
|
+
|
|
1814
2650
|
const ARealm = defineComponent({
|
|
1815
2651
|
props: defineEntityManagerProps(),
|
|
1816
2652
|
emits: defineEntityManagerEvents(),
|
|
@@ -2517,6 +3353,25 @@ const AClientScopes = defineComponent({
|
|
|
2517
3353
|
}
|
|
2518
3354
|
});
|
|
2519
3355
|
|
|
3356
|
+
function createRealmFormPicker(form) {
|
|
3357
|
+
return buildFormGroup({
|
|
3358
|
+
label: true,
|
|
3359
|
+
labelContent: 'Realm',
|
|
3360
|
+
content: h(ARealms, {}, {
|
|
3361
|
+
[SlotName.ITEM_ACTIONS]: (props)=>renderEntityAssignAction({
|
|
3362
|
+
item: form.realm_id === props.data.id,
|
|
3363
|
+
busy: props.busy,
|
|
3364
|
+
add () {
|
|
3365
|
+
form.realm_id = props.data.id;
|
|
3366
|
+
},
|
|
3367
|
+
drop () {
|
|
3368
|
+
form.realm_id = '';
|
|
3369
|
+
}
|
|
3370
|
+
})
|
|
3371
|
+
})
|
|
3372
|
+
});
|
|
3373
|
+
}
|
|
3374
|
+
|
|
2520
3375
|
const AScopeForm = defineComponent({
|
|
2521
3376
|
props: {
|
|
2522
3377
|
name: {
|
|
@@ -2524,12 +3379,7 @@ const AScopeForm = defineComponent({
|
|
|
2524
3379
|
default: undefined
|
|
2525
3380
|
},
|
|
2526
3381
|
entity: {
|
|
2527
|
-
type: Object
|
|
2528
|
-
default: undefined
|
|
2529
|
-
},
|
|
2530
|
-
realmId: {
|
|
2531
|
-
type: String,
|
|
2532
|
-
default: undefined
|
|
3382
|
+
type: Object
|
|
2533
3383
|
}
|
|
2534
3384
|
},
|
|
2535
3385
|
emits: defineEntityManagerEvents(),
|
|
@@ -2553,11 +3403,19 @@ const AScopeForm = defineComponent({
|
|
|
2553
3403
|
},
|
|
2554
3404
|
realm_id: {}
|
|
2555
3405
|
}, form);
|
|
3406
|
+
const store = useStore();
|
|
3407
|
+
const storeRefs = storeToRefs(store);
|
|
2556
3408
|
const manager = createEntityManager({
|
|
2557
3409
|
type: `${DomainType.SCOPE}`,
|
|
2558
3410
|
setup: ctx,
|
|
2559
3411
|
props
|
|
2560
3412
|
});
|
|
3413
|
+
const realmId = computed(()=>{
|
|
3414
|
+
if (!storeRefs.realmIsRoot) {
|
|
3415
|
+
return storeRefs.realmId.value;
|
|
3416
|
+
}
|
|
3417
|
+
return manager.data.value ? manager.data.value.realm_id : null;
|
|
3418
|
+
});
|
|
2561
3419
|
const isEditing = useIsEditing(manager.data);
|
|
2562
3420
|
const updatedAt = useUpdatedAt(props.entity);
|
|
2563
3421
|
const isNameFixed = computed(()=>{
|
|
@@ -2566,14 +3424,10 @@ const AScopeForm = defineComponent({
|
|
|
2566
3424
|
}
|
|
2567
3425
|
return !!(manager.data.value && manager.data.value.built_in);
|
|
2568
3426
|
});
|
|
2569
|
-
const isRealmLocked = computed(()=>!!props.realmId);
|
|
2570
3427
|
function initForm() {
|
|
2571
3428
|
if (props.name) {
|
|
2572
3429
|
form.name = props.name;
|
|
2573
3430
|
}
|
|
2574
|
-
if (props.realmId) {
|
|
2575
|
-
form.realm_id = props.realmId;
|
|
2576
|
-
}
|
|
2577
3431
|
initFormAttributesFromSource(form, manager.data.value);
|
|
2578
3432
|
}
|
|
2579
3433
|
watch(updatedAt, (val, oldVal)=>{
|
|
@@ -2602,8 +3456,8 @@ const AScopeForm = defineComponent({
|
|
|
2602
3456
|
key: TranslatorTranslationDefaultKey.REALM
|
|
2603
3457
|
}
|
|
2604
3458
|
]);
|
|
2605
|
-
|
|
2606
|
-
const
|
|
3459
|
+
return ()=>{
|
|
3460
|
+
const children = [
|
|
2607
3461
|
buildFormGroup({
|
|
2608
3462
|
validationMessages: translationsValidation.name.value,
|
|
2609
3463
|
validationSeverity: getVuelidateSeverity($v.value.name),
|
|
@@ -2618,9 +3472,7 @@ const AScopeForm = defineComponent({
|
|
|
2618
3472
|
disabled: isNameFixed.value
|
|
2619
3473
|
}
|
|
2620
3474
|
})
|
|
2621
|
-
})
|
|
2622
|
-
];
|
|
2623
|
-
const description = [
|
|
3475
|
+
}),
|
|
2624
3476
|
buildFormGroup({
|
|
2625
3477
|
validationMessages: translationsValidation.description.value,
|
|
2626
3478
|
validationSeverity: getVuelidateSeverity($v.value.description),
|
|
@@ -2637,52 +3489,22 @@ const AScopeForm = defineComponent({
|
|
|
2637
3489
|
})
|
|
2638
3490
|
})
|
|
2639
3491
|
];
|
|
2640
|
-
|
|
2641
|
-
|
|
3492
|
+
if (!realmId.value && !isNameFixed.value && !isEditing.value) {
|
|
3493
|
+
children.push(createRealmFormPicker(form));
|
|
3494
|
+
}
|
|
3495
|
+
children.push(buildFormSubmitWithTranslations({
|
|
2642
3496
|
submit,
|
|
3497
|
+
busy,
|
|
2643
3498
|
isEditing: isEditing.value,
|
|
2644
3499
|
invalid: $v.value.$invalid
|
|
2645
|
-
}, translationsSubmit);
|
|
2646
|
-
let realm = [];
|
|
2647
|
-
if (!isRealmLocked.value && !isNameFixed.value) {
|
|
2648
|
-
realm = [
|
|
2649
|
-
h('hr'),
|
|
2650
|
-
h('label', {
|
|
2651
|
-
class: 'form-label'
|
|
2652
|
-
}, translationsDefault[TranslatorTranslationDefaultKey.REALM].value),
|
|
2653
|
-
h(ARealms, {
|
|
2654
|
-
headerTitle: false
|
|
2655
|
-
}, {
|
|
2656
|
-
[SlotName.ITEM_ACTIONS]: (props)=>renderEntityAssignAction({
|
|
2657
|
-
item: form.realm_id === props.data.id,
|
|
2658
|
-
busy: props.busy,
|
|
2659
|
-
add () {
|
|
2660
|
-
form.realm_id = props.data.id;
|
|
2661
|
-
},
|
|
2662
|
-
drop () {
|
|
2663
|
-
form.realm_id = '';
|
|
2664
|
-
}
|
|
2665
|
-
})
|
|
2666
|
-
})
|
|
2667
|
-
];
|
|
2668
|
-
}
|
|
3500
|
+
}, translationsSubmit));
|
|
2669
3501
|
return h('form', {
|
|
2670
3502
|
onSubmit ($event) {
|
|
2671
3503
|
$event.preventDefault();
|
|
2672
3504
|
return submit.apply(null);
|
|
2673
3505
|
}
|
|
2674
|
-
},
|
|
2675
|
-
h('div', [
|
|
2676
|
-
name,
|
|
2677
|
-
h('hr'),
|
|
2678
|
-
description,
|
|
2679
|
-
realm,
|
|
2680
|
-
h('hr'),
|
|
2681
|
-
submitForm
|
|
2682
|
-
])
|
|
2683
|
-
]);
|
|
3506
|
+
}, children);
|
|
2684
3507
|
};
|
|
2685
|
-
return ()=>render();
|
|
2686
3508
|
}
|
|
2687
3509
|
});
|
|
2688
3510
|
|
|
@@ -4002,7 +4824,7 @@ const AIdentityProviderOAuth2Form = defineComponent({
|
|
|
4002
4824
|
},
|
|
4003
4825
|
emits: defineEntityManagerEvents(),
|
|
4004
4826
|
setup (props, ctx) {
|
|
4005
|
-
const apiClient =
|
|
4827
|
+
const apiClient = injectHTTPClient();
|
|
4006
4828
|
const manager = createEntityManager({
|
|
4007
4829
|
type: `${DomainType.IDENTITY_PROVIDER}`,
|
|
4008
4830
|
setup: ctx,
|
|
@@ -4594,7 +5416,8 @@ const ARoleForm = defineComponent({
|
|
|
4594
5416
|
const busy = ref(false);
|
|
4595
5417
|
const form = reactive({
|
|
4596
5418
|
name: '',
|
|
4597
|
-
description: ''
|
|
5419
|
+
description: '',
|
|
5420
|
+
realm_id: ''
|
|
4598
5421
|
});
|
|
4599
5422
|
const $v = useVuelidate({
|
|
4600
5423
|
name: {
|
|
@@ -4605,13 +5428,22 @@ const ARoleForm = defineComponent({
|
|
|
4605
5428
|
description: {
|
|
4606
5429
|
minLength: minLength(5),
|
|
4607
5430
|
maxLength: maxLength(4096)
|
|
4608
|
-
}
|
|
5431
|
+
},
|
|
5432
|
+
realm_id: {}
|
|
4609
5433
|
}, form);
|
|
5434
|
+
const store = useStore();
|
|
5435
|
+
const storeRefs = storeToRefs(store);
|
|
4610
5436
|
const manager = createEntityManager({
|
|
4611
5437
|
type: `${DomainType.ROLE}`,
|
|
4612
5438
|
setup: ctx,
|
|
4613
5439
|
props
|
|
4614
5440
|
});
|
|
5441
|
+
const realmId = computed(()=>{
|
|
5442
|
+
if (!storeRefs.realmIsRoot) {
|
|
5443
|
+
return storeRefs.realmId.value;
|
|
5444
|
+
}
|
|
5445
|
+
return manager.data.value ? manager.data.value.realm_id : null;
|
|
5446
|
+
});
|
|
4615
5447
|
const isEditing = useIsEditing(manager.data);
|
|
4616
5448
|
const updatedAt = useUpdatedAt(props.entity);
|
|
4617
5449
|
function initForm() {
|
|
@@ -4641,7 +5473,8 @@ const ARoleForm = defineComponent({
|
|
|
4641
5473
|
}
|
|
4642
5474
|
]);
|
|
4643
5475
|
const render = ()=>{
|
|
4644
|
-
const
|
|
5476
|
+
const children = [];
|
|
5477
|
+
children.push(buildFormGroup({
|
|
4645
5478
|
validationMessages: translationsValidation.name.value,
|
|
4646
5479
|
validationSeverity: getVuelidateSeverity($v.value.name),
|
|
4647
5480
|
label: true,
|
|
@@ -4652,8 +5485,8 @@ const ARoleForm = defineComponent({
|
|
|
4652
5485
|
$v.value.name.$model = input;
|
|
4653
5486
|
}
|
|
4654
5487
|
})
|
|
4655
|
-
});
|
|
4656
|
-
|
|
5488
|
+
}));
|
|
5489
|
+
children.push(buildFormGroup({
|
|
4657
5490
|
validationMessages: translationsValidation.description.value,
|
|
4658
5491
|
validationSeverity: getVuelidateSeverity($v.value.description),
|
|
4659
5492
|
label: true,
|
|
@@ -4667,23 +5500,22 @@ const ARoleForm = defineComponent({
|
|
|
4667
5500
|
rows: 6
|
|
4668
5501
|
}
|
|
4669
5502
|
})
|
|
4670
|
-
});
|
|
4671
|
-
|
|
5503
|
+
}));
|
|
5504
|
+
if (!realmId.value && !isEditing.value) {
|
|
5505
|
+
children.push(createRealmFormPicker(form));
|
|
5506
|
+
}
|
|
5507
|
+
children.push(buildFormSubmitWithTranslations({
|
|
4672
5508
|
submit,
|
|
4673
|
-
busy
|
|
5509
|
+
busy,
|
|
4674
5510
|
isEditing: isEditing.value,
|
|
4675
5511
|
invalid: $v.value.$invalid
|
|
4676
|
-
}, translationsSubmit);
|
|
5512
|
+
}, translationsSubmit));
|
|
4677
5513
|
return h('form', {
|
|
4678
5514
|
onSubmit ($event) {
|
|
4679
5515
|
$event.preventDefault();
|
|
4680
5516
|
return submit.apply(null);
|
|
4681
5517
|
}
|
|
4682
|
-
},
|
|
4683
|
-
name,
|
|
4684
|
-
description,
|
|
4685
|
-
submitForm
|
|
4686
|
-
]);
|
|
5518
|
+
}, children);
|
|
4687
5519
|
};
|
|
4688
5520
|
return ()=>render();
|
|
4689
5521
|
}
|
|
@@ -4780,8 +5612,7 @@ const APermission = defineComponent({
|
|
|
4780
5612
|
const APermissionForm = defineComponent({
|
|
4781
5613
|
props: {
|
|
4782
5614
|
entity: {
|
|
4783
|
-
type: Object
|
|
4784
|
-
default: undefined
|
|
5615
|
+
type: Object
|
|
4785
5616
|
}
|
|
4786
5617
|
},
|
|
4787
5618
|
emits: defineEntityManagerEvents(),
|
|
@@ -4789,7 +5620,8 @@ const APermissionForm = defineComponent({
|
|
|
4789
5620
|
const busy = ref(false);
|
|
4790
5621
|
const form = reactive({
|
|
4791
5622
|
name: '',
|
|
4792
|
-
description: ''
|
|
5623
|
+
description: '',
|
|
5624
|
+
realm_id: ''
|
|
4793
5625
|
});
|
|
4794
5626
|
const $v = useVuelidate({
|
|
4795
5627
|
name: {
|
|
@@ -4800,13 +5632,22 @@ const APermissionForm = defineComponent({
|
|
|
4800
5632
|
description: {
|
|
4801
5633
|
minLength: minLength(5),
|
|
4802
5634
|
maxLength: maxLength(4096)
|
|
4803
|
-
}
|
|
5635
|
+
},
|
|
5636
|
+
realm_id: {}
|
|
4804
5637
|
}, form);
|
|
5638
|
+
const store = useStore();
|
|
5639
|
+
const storeRefs = storeToRefs(store);
|
|
4805
5640
|
const manager = createEntityManager({
|
|
4806
5641
|
type: `${DomainType.PERMISSION}`,
|
|
4807
5642
|
setup: ctx,
|
|
4808
5643
|
props
|
|
4809
5644
|
});
|
|
5645
|
+
const realmId = computed(()=>{
|
|
5646
|
+
if (!storeRefs.realmIsRoot) {
|
|
5647
|
+
return storeRefs.realmId.value;
|
|
5648
|
+
}
|
|
5649
|
+
return manager.data.value ? manager.data.value.realm_id : null;
|
|
5650
|
+
});
|
|
4810
5651
|
const isEditing = useIsEditing(manager.data);
|
|
4811
5652
|
const updatedAt = useUpdatedAt(props.entity);
|
|
4812
5653
|
function initForm() {
|
|
@@ -4836,7 +5677,8 @@ const APermissionForm = defineComponent({
|
|
|
4836
5677
|
}
|
|
4837
5678
|
]);
|
|
4838
5679
|
const render = ()=>{
|
|
4839
|
-
const
|
|
5680
|
+
const children = [];
|
|
5681
|
+
children.push(buildFormGroup({
|
|
4840
5682
|
validationMessages: translationsValidation.name.value,
|
|
4841
5683
|
validationSeverity: getVuelidateSeverity($v.value.name),
|
|
4842
5684
|
label: true,
|
|
@@ -4850,8 +5692,8 @@ const APermissionForm = defineComponent({
|
|
|
4850
5692
|
disabled: manager.data.value && manager.data.value.built_in
|
|
4851
5693
|
}
|
|
4852
5694
|
})
|
|
4853
|
-
});
|
|
4854
|
-
|
|
5695
|
+
}));
|
|
5696
|
+
children.push(buildFormGroup({
|
|
4855
5697
|
validationMessages: translationsValidation.description.value,
|
|
4856
5698
|
validationSeverity: getVuelidateSeverity($v.value.description),
|
|
4857
5699
|
label: true,
|
|
@@ -4865,23 +5707,22 @@ const APermissionForm = defineComponent({
|
|
|
4865
5707
|
rows: 4
|
|
4866
5708
|
}
|
|
4867
5709
|
})
|
|
4868
|
-
});
|
|
4869
|
-
|
|
5710
|
+
}));
|
|
5711
|
+
if (!realmId.value && !isEditing.value) {
|
|
5712
|
+
children.push(createRealmFormPicker(form));
|
|
5713
|
+
}
|
|
5714
|
+
children.push(buildFormSubmitWithTranslations({
|
|
4870
5715
|
submit,
|
|
4871
5716
|
busy,
|
|
4872
5717
|
isEditing: isEditing.value,
|
|
4873
5718
|
invalid: $v.value.$invalid
|
|
4874
|
-
}, translationsSubmit);
|
|
5719
|
+
}, translationsSubmit));
|
|
4875
5720
|
return h('form', {
|
|
4876
5721
|
onSubmit ($event) {
|
|
4877
5722
|
$event.preventDefault();
|
|
4878
5723
|
return submit.apply(null);
|
|
4879
5724
|
}
|
|
4880
|
-
},
|
|
4881
|
-
name,
|
|
4882
|
-
description,
|
|
4883
|
-
submitButton
|
|
4884
|
-
]);
|
|
5725
|
+
}, children);
|
|
4885
5726
|
};
|
|
4886
5727
|
return ()=>render();
|
|
4887
5728
|
}
|
|
@@ -5698,7 +6539,7 @@ const AUserPasswordForm = defineComponent({
|
|
|
5698
6539
|
'failed'
|
|
5699
6540
|
],
|
|
5700
6541
|
setup (props, ctx) {
|
|
5701
|
-
const apiClient =
|
|
6542
|
+
const apiClient = injectHTTPClient();
|
|
5702
6543
|
const busy = ref(false);
|
|
5703
6544
|
const form = reactive({
|
|
5704
6545
|
password: '',
|
|
@@ -6332,12 +7173,12 @@ const AEntityDelete = defineComponent({
|
|
|
6332
7173
|
'failed'
|
|
6333
7174
|
],
|
|
6334
7175
|
setup (props, ctx) {
|
|
6335
|
-
const apiClient =
|
|
7176
|
+
const apiClient = injectHTTPClient();
|
|
6336
7177
|
const instance = getCurrentInstance();
|
|
6337
7178
|
const busy = ref(false);
|
|
6338
7179
|
const submit = wrapFnWithBusyState(busy, async ()=>{
|
|
6339
7180
|
let domainAPI;
|
|
6340
|
-
if (hasOwnProperty
|
|
7181
|
+
if (hasOwnProperty(apiClient, props.entityType) && isObject$1(apiClient[props.entityType]) && hasOwnProperty(apiClient[props.entityType], 'delete')) {
|
|
6341
7182
|
domainAPI = apiClient[props.entityType];
|
|
6342
7183
|
}
|
|
6343
7184
|
if (!domainAPI) {
|
|
@@ -6403,102 +7244,113 @@ const AEntityDelete = defineComponent({
|
|
|
6403
7244
|
});
|
|
6404
7245
|
|
|
6405
7246
|
var components = /*#__PURE__*/Object.freeze({
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
7247
|
+
__proto__: null,
|
|
7248
|
+
AClient: AClient,
|
|
7249
|
+
AClientForm: AClientForm,
|
|
7250
|
+
AClientRedirectUris: AClientRedirectUris,
|
|
7251
|
+
AClientRedirectUrisItem: AClientRedirectUrisItem,
|
|
7252
|
+
AClientScope: AClientScope,
|
|
7253
|
+
AClientScopeAssignment: AClientScopeAssignment,
|
|
7254
|
+
AClientScopeAssignments: AClientScopeAssignments,
|
|
7255
|
+
AClientScopes: AClientScopes,
|
|
7256
|
+
AClients: AClients,
|
|
7257
|
+
AEntityDelete: AEntityDelete,
|
|
7258
|
+
AIdentityProvider: AIdentityProvider,
|
|
7259
|
+
AIdentityProviderForm: AIdentityProviderForm,
|
|
7260
|
+
AIdentityProviderIcon: AIdentityProviderIcon,
|
|
7261
|
+
AIdentityProviderLdapForm: AIdentityProviderLdapForm,
|
|
7262
|
+
AIdentityProviderOAuth2Form: AIdentityProviderOAuth2Form,
|
|
7263
|
+
AIdentityProviderPreset: AIdentityProviderPreset,
|
|
7264
|
+
AIdentityProviderProtocol: AIdentityProviderProtocol,
|
|
7265
|
+
AIdentityProviderRoleAssignment: AIdentityProviderRoleAssignment,
|
|
7266
|
+
AIdentityProviderRoleAssignments: AIdentityProviderRoleAssignments,
|
|
7267
|
+
AIdentityProviders: AIdentityProviders,
|
|
7268
|
+
APagination: APagination,
|
|
7269
|
+
APermission: APermission,
|
|
7270
|
+
APermissionForm: APermissionForm,
|
|
7271
|
+
APermissionRobotAssignments: APermissionRobotAssignments,
|
|
7272
|
+
APermissionRoleAssignments: APermissionRoleAssignments,
|
|
7273
|
+
APermissionUserAssignments: APermissionUserAssignments,
|
|
7274
|
+
APermissions: APermissions,
|
|
7275
|
+
ARealm: ARealm,
|
|
7276
|
+
ARealmForm: ARealmForm,
|
|
7277
|
+
ARealms: ARealms,
|
|
7278
|
+
ARobot: ARobot,
|
|
7279
|
+
ARobotForm: ARobotForm,
|
|
7280
|
+
ARobotPermissionAssignment: ARobotPermissionAssignment,
|
|
7281
|
+
ARobotPermissionAssignments: ARobotPermissionAssignments,
|
|
7282
|
+
ARobotRoleAssignment: ARobotRoleAssignment,
|
|
7283
|
+
ARobotRoleAssignments: ARobotRoleAssignments,
|
|
7284
|
+
ARobots: ARobots,
|
|
7285
|
+
ARole: ARole,
|
|
7286
|
+
ARoleForm: ARoleForm,
|
|
7287
|
+
ARolePermissionAssignment: ARolePermissionAssignment,
|
|
7288
|
+
ARolePermissionAssignments: ARolePermissionAssignments,
|
|
7289
|
+
ARoleRobotAssignments: ARoleRobotAssignments,
|
|
7290
|
+
ARoleUserAssignments: ARoleUserAssignments,
|
|
7291
|
+
ARoles: ARoles,
|
|
7292
|
+
AScope: AScope,
|
|
7293
|
+
AScopeClientAssignments: AScopeClientAssignments,
|
|
7294
|
+
AScopeForm: AScopeForm,
|
|
7295
|
+
AScopes: AScopes,
|
|
7296
|
+
ASearch: ASearch,
|
|
7297
|
+
ATitle: ATitle,
|
|
7298
|
+
AUser: AUser,
|
|
7299
|
+
AUserForm: AUserForm,
|
|
7300
|
+
AUserPasswordForm: AUserPasswordForm,
|
|
7301
|
+
AUserPermissionAssignment: AUserPermissionAssignment,
|
|
7302
|
+
AUserPermissionAssignments: AUserPermissionAssignments,
|
|
7303
|
+
AUserRoleAssignment: AUserRoleAssignment,
|
|
7304
|
+
AUserRoleAssignments: AUserRoleAssignments,
|
|
7305
|
+
AUsers: AUsers,
|
|
7306
|
+
LanguageSwitcherDropdown: LanguageSwitcherDropdown
|
|
6466
7307
|
});
|
|
6467
7308
|
|
|
6468
|
-
function
|
|
6469
|
-
if (
|
|
6470
|
-
|
|
6471
|
-
}
|
|
6472
|
-
if (options.socketClientManager) {
|
|
6473
|
-
provideSocketClientManager(options.socketClientManager, app);
|
|
6474
|
-
}
|
|
6475
|
-
if (options.store) {
|
|
6476
|
-
provideStore(options.store, app);
|
|
7309
|
+
function installComponents(input) {
|
|
7310
|
+
if (!input) {
|
|
7311
|
+
return;
|
|
6477
7312
|
}
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
const storeManager = installStoreManager(app, 'authup');
|
|
6482
|
-
if (options.storeManager) {
|
|
6483
|
-
applyStoreManagerOptions(storeManager, options.storeManager);
|
|
7313
|
+
let componentsSelected;
|
|
7314
|
+
if (typeof input !== 'boolean') {
|
|
7315
|
+
componentsSelected = input;
|
|
6484
7316
|
}
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
7317
|
+
Object.entries(components).forEach(([componentName, component])=>{
|
|
7318
|
+
if (!Array.isArray(componentsSelected) || componentsSelected.indexOf(componentName) !== -1) {
|
|
7319
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
7320
|
+
// @ts-ignore
|
|
7321
|
+
app.component(componentName, component);
|
|
6489
7322
|
}
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
7323
|
+
});
|
|
7324
|
+
}
|
|
7325
|
+
function install(app1, options) {
|
|
7326
|
+
if (options.realtime) {
|
|
7327
|
+
installSocketClientManager(app1, {
|
|
7328
|
+
baseURL: options.realtimeURL || options.baseURL
|
|
6496
7329
|
});
|
|
6497
7330
|
}
|
|
7331
|
+
if (options.pinia) {
|
|
7332
|
+
setActivePinia(options.pinia);
|
|
7333
|
+
}
|
|
7334
|
+
installStore(app1, {
|
|
7335
|
+
baseURL: options.baseURL,
|
|
7336
|
+
cookieSet: options.cookieSet,
|
|
7337
|
+
cookieGet: options.cookieGet,
|
|
7338
|
+
cookieUnset: options.cookieUnset,
|
|
7339
|
+
pinia: options.pinia
|
|
7340
|
+
});
|
|
7341
|
+
installHTTPClient(app1, {
|
|
7342
|
+
baseURL: options.baseURL,
|
|
7343
|
+
pinia: options.pinia
|
|
7344
|
+
});
|
|
7345
|
+
installTranslator(app1, {
|
|
7346
|
+
locale: options.translatorLocale
|
|
7347
|
+
});
|
|
7348
|
+
installComponents(options.components);
|
|
6498
7349
|
}
|
|
7350
|
+
|
|
6499
7351
|
var index = {
|
|
6500
7352
|
install
|
|
6501
7353
|
};
|
|
6502
7354
|
|
|
6503
|
-
export { AClient, AClientForm, AClientRedirectUris, AClientRedirectUrisItem, AClientScope, AClientScopeAssignment, AClientScopeAssignments, AClientScopes, AClients, AEntityDelete, AIdentityProvider, AIdentityProviderForm, AIdentityProviderIcon, AIdentityProviderLdapForm, AIdentityProviderOAuth2Form, AIdentityProviderPreset, AIdentityProviderProtocol, AIdentityProviderRoleAssignment, AIdentityProviderRoleAssignments, AIdentityProviders,
|
|
7355
|
+
export { AClient, AClientForm, AClientRedirectUris, AClientRedirectUrisItem, AClientScope, AClientScopeAssignment, AClientScopeAssignments, AClientScopes, AClients, AEntityDelete, AIdentityProvider, AIdentityProviderForm, AIdentityProviderIcon, AIdentityProviderLdapForm, AIdentityProviderOAuth2Form, AIdentityProviderPreset, AIdentityProviderProtocol, AIdentityProviderRoleAssignment, AIdentityProviderRoleAssignments, AIdentityProviders, APagination, APermission, APermissionForm, APermissionRobotAssignments, APermissionRoleAssignments, APermissionUserAssignments, APermissions, ARealm, ARealmForm, ARealms, ARobot, ARobotForm, ARobotPermissionAssignment, ARobotPermissionAssignments, ARobotRoleAssignment, ARobotRoleAssignments, ARobots, ARole, ARoleForm, ARolePermissionAssignment, ARolePermissionAssignments, ARoleRobotAssignments, ARoleUserAssignments, ARoles, AScope, AScopeClientAssignments, AScopeForm, AScopes, ASearch, ATitle, AUser, AUserForm, AUserPasswordForm, AUserPermissionAssignment, AUserPermissionAssignments, AUserRoleAssignment, AUserRoleAssignments, AUsers, EntityManagerError, HTTPClientSymbol, LanguageSwitcherDropdown, STORE_ID, SocketClientSymbol, StoreSymbol, TranslatorTranslationClientKey, TranslatorTranslationDefaultKey, TranslatorTranslationGroup, TranslatorTranslationVuecsKey, VuelidateCustomRule, VuelidateCustomRuleKey, buildEntityManagerSlotProps, buildFormSubmitWithTranslations, buildListCreatedHandler, buildListDeletedHandler, buildListUpdatedHandler, createEntityManager, createFormSubmitTranslations, createList, createStore, index as default, defineEntityManagerEvents, defineEntityManagerProps, defineListEvents, defineListProps, extendObjectProperties, extractVuelidateResultsFromChild, getVuelidateSeverity, hasHTTPClient, hasNormalizedSlot, hasStore, initFormAttributesFromSource, inject$1 as inject, injectHTTPClient, injectSocketClientManager, injectStore, injectTranslatorLocale, install, installHTTPClient, installSocketClientManager, installStore, installTranslator, isQuerySortedDescByDate, isSocketClientManagerInjected, mergeListOptions, normalizeSlot, onChange, provide, provideHTTPClient, provideSocketClientManager, provideStore, renderEntityAssignAction, storeToRefs, useAbilityCheck, useIsEditing, useRealmResourceWritableCheck, useStore, useTranslation, useTranslationsForBaseValidation, useTranslationsForGroup, useTranslationsForNestedValidation, useUpdatedAt, wrapFnWithBusyState };
|
|
6504
7356
|
//# sourceMappingURL=index.mjs.map
|