@authup/client-web-kit 1.0.0-beta.20 → 1.0.0-beta.21
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/permission/APermissionCheck.d.ts +30 -0
- package/dist/components/permission/APermissionCheck.d.ts.map +1 -0
- package/dist/components/permission/index.d.ts +1 -0
- package/dist/components/permission/index.d.ts.map +1 -1
- package/dist/composables/index.d.ts +1 -1
- package/dist/composables/index.d.ts.map +1 -1
- package/dist/composables/use-permission-check.d.ts +4 -0
- package/dist/composables/use-permission-check.d.ts.map +1 -0
- package/dist/core/http-client/install.d.ts.map +1 -1
- package/dist/core/http-client/types.d.ts +1 -0
- package/dist/core/http-client/types.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/permission-check/index.d.ts +3 -0
- package/dist/core/permission-check/index.d.ts.map +1 -0
- package/dist/core/permission-check/module.d.ts +3 -0
- package/dist/core/permission-check/module.d.ts.map +1 -0
- package/dist/core/permission-check/types.d.ts +11 -0
- package/dist/core/permission-check/types.d.ts.map +1 -0
- package/dist/core/store/create.d.ts +6 -57
- package/dist/core/store/create.d.ts.map +1 -1
- package/dist/core/store/install.d.ts.map +1 -1
- package/dist/core/store/singleton.d.ts +3 -3
- package/dist/core/store/singleton.d.ts.map +1 -1
- package/dist/core/store/utils.d.ts +1 -2
- package/dist/core/store/utils.d.ts.map +1 -1
- package/dist/index.cjs +483 -411
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +255 -190
- package/dist/index.mjs.map +1 -1
- package/dist/module.d.ts.map +1 -1
- package/dist/types.d.ts +13 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +10 -10
- package/dist/composables/use-ability-check.d.ts +0 -3
- package/dist/composables/use-ability-check.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { REALM_MASTER_NAME, DomainEventName, buildDomainChannelName, DomainType,
|
|
|
2
2
|
import { hasInjectionContext, inject as inject$2, provide as provide$1, ref, computed, getCurrentScope, onScopeDispose, toRaw, isRef, isReactive, toRef, unref, h, onMounted, onUnmounted, watch, shallowRef, watchEffect, defineComponent, reactive, nextTick, getCurrentInstance, resolveDynamicComponent, mergeProps } from 'vue';
|
|
3
3
|
import { Client, isClientTokenExpiredError, CookieName, ClientResponseErrorTokenHook } from '@authup/core-http-kit';
|
|
4
4
|
import { defineStore, storeToRefs as storeToRefs$1 } from 'pinia';
|
|
5
|
-
import { BuiltInPolicyType, PolicyError, maybeInvertPolicyOutcome, PermissionBindingPolicyValidator, PolicyEngine as PolicyEngine$1, PermissionMemoryProvider, PermissionChecker, buildEventFullName, EventNameSuffix, hasOwnProperty, createNanoID, isOAuth2OpenIDProviderMetadata, isObject as isObject$2 } from '@authup/kit';
|
|
5
|
+
import { BuiltInPolicyType, PolicyError, maybeInvertPolicyOutcome, PermissionBindingPolicyValidator, PolicyEngine as PolicyEngine$1, PermissionMemoryProvider, PermissionChecker, TokenError, buildEventFullName, EventNameSuffix, hasOwnProperty, createNanoID, isOAuth2OpenIDProviderMetadata, isObject as isObject$2 } from '@authup/kit';
|
|
6
6
|
import { isObject as isObject$1, merge, createMerger } from 'smob';
|
|
7
7
|
import { buildList, SlotName } from '@vuecs/list-controls';
|
|
8
8
|
import { ClientManager } from '@authup/core-realtime-kit';
|
|
@@ -90,6 +90,23 @@ class PolicyEngine extends PolicyEngine$1 {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
function createPromiseShareWrapperFn(fn) {
|
|
94
|
+
let promise;
|
|
95
|
+
return (...args)=>{
|
|
96
|
+
if (promise) {
|
|
97
|
+
return promise;
|
|
98
|
+
}
|
|
99
|
+
promise = new Promise((resolve, reject)=>{
|
|
100
|
+
fn(...args).then((r)=>resolve(r)).catch((e)=>reject(e));
|
|
101
|
+
});
|
|
102
|
+
promise.finally(()=>{
|
|
103
|
+
setTimeout(()=>{
|
|
104
|
+
promise = undefined;
|
|
105
|
+
}, 0);
|
|
106
|
+
});
|
|
107
|
+
return promise;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
93
110
|
function createStore(context = {}) {
|
|
94
111
|
const client = new Client({
|
|
95
112
|
baseURL: context.baseURL
|
|
@@ -118,38 +135,10 @@ function createStore(context = {}) {
|
|
|
118
135
|
refreshToken.value = input;
|
|
119
136
|
};
|
|
120
137
|
// --------------------------------------------------------------------
|
|
121
|
-
const handleTokenGrantResponse = (response)=>{
|
|
122
|
-
const expireDate = new Date(Date.now() + response.expires_in * 1000);
|
|
123
|
-
setAccessTokenExpireDate(expireDate);
|
|
124
|
-
setAccessToken(response.access_token);
|
|
125
|
-
setRefreshToken(response.refresh_token);
|
|
126
|
-
};
|
|
127
|
-
// --------------------------------------------------------------------
|
|
128
|
-
let refreshTokenPromise;
|
|
129
|
-
const attemptRefreshToken = ()=>{
|
|
130
|
-
if (!refreshToken.value) {
|
|
131
|
-
return Promise.reject(new Error('No refresh token is present.'));
|
|
132
|
-
}
|
|
133
|
-
if (refreshTokenPromise) {
|
|
134
|
-
return refreshTokenPromise;
|
|
135
|
-
}
|
|
136
|
-
refreshTokenPromise = client.token.createWithRefreshToken({
|
|
137
|
-
refresh_token: refreshToken.value
|
|
138
|
-
}).then((r)=>{
|
|
139
|
-
handleTokenGrantResponse(r);
|
|
140
|
-
return r;
|
|
141
|
-
}).finally(()=>{
|
|
142
|
-
refreshTokenPromise = undefined;
|
|
143
|
-
});
|
|
144
|
-
return refreshTokenPromise;
|
|
145
|
-
};
|
|
146
|
-
// --------------------------------------------------------------------
|
|
147
138
|
const user = ref(undefined);
|
|
148
139
|
const userId = computed(()=>user.value ? user.value.id : undefined);
|
|
149
|
-
const userResolved = ref(false);
|
|
150
140
|
const setUser = (entity)=>{
|
|
151
141
|
user.value = entity;
|
|
152
|
-
userResolved.value = !!entity;
|
|
153
142
|
};
|
|
154
143
|
// --------------------------------------------------------------------
|
|
155
144
|
const realm = ref(undefined);
|
|
@@ -170,72 +159,100 @@ function createStore(context = {}) {
|
|
|
170
159
|
const setRealmManagement = (entity)=>{
|
|
171
160
|
realmManagement.value = entity;
|
|
172
161
|
};
|
|
162
|
+
// --------------------------------------------------------------------
|
|
173
163
|
const permissionRepository = new PermissionMemoryProvider();
|
|
174
164
|
const permissionChecker = new PermissionChecker({
|
|
175
165
|
provider: permissionRepository,
|
|
176
166
|
policyEngine: new PolicyEngine()
|
|
177
167
|
});
|
|
178
|
-
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (!entity) {
|
|
184
|
-
setRealm(undefined);
|
|
185
|
-
setRealmManagement(undefined);
|
|
186
|
-
permissionRepository.setMany([]);
|
|
187
|
-
return;
|
|
168
|
+
// --------------------------------------------------------------------
|
|
169
|
+
const userResolved = ref(false);
|
|
170
|
+
const resolveUser = async ()=>{
|
|
171
|
+
if (!accessToken.value || userResolved.value) {
|
|
172
|
+
return Promise.resolve();
|
|
188
173
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
174
|
+
userResolved.value = true;
|
|
175
|
+
return client.userInfo.get(`Bearer ${accessToken.value}`).then((response)=>{
|
|
176
|
+
setUser(response);
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
// --------------------------------------------------------------------
|
|
180
|
+
const tokenResolved = ref(false);
|
|
181
|
+
const resolveToken = async ()=>{
|
|
182
|
+
if (!accessToken.value || tokenResolved.value) {
|
|
183
|
+
return Promise.resolve();
|
|
192
184
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
185
|
+
tokenResolved.value = true;
|
|
186
|
+
return client.token.introspect({
|
|
187
|
+
token: accessToken.value
|
|
188
|
+
}, {
|
|
189
|
+
authorizationHeader: {
|
|
190
|
+
type: 'Bearer',
|
|
191
|
+
token: accessToken.value
|
|
200
192
|
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
193
|
+
}).then((response)=>{
|
|
194
|
+
if (response.exp) {
|
|
195
|
+
const expireDate = new Date(response.exp * 1000);
|
|
196
|
+
setAccessTokenExpireDate(expireDate);
|
|
197
|
+
}
|
|
198
|
+
if (response.realm_id && response.realm_name) {
|
|
199
|
+
realm.value = {
|
|
200
|
+
id: response.realm_id,
|
|
201
|
+
name: response.realm_name
|
|
202
|
+
};
|
|
203
|
+
if (!realmManagement.value) {
|
|
204
|
+
setRealmManagement(realm.value);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (response.permissions) {
|
|
208
|
+
permissionRepository.setMany(response.permissions);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
// --------------------------------------------------------------------
|
|
213
|
+
const handleTokenGrantResponse = (response)=>{
|
|
214
|
+
const expireDate = new Date(Date.now() + response.expires_in * 1000);
|
|
215
|
+
setAccessTokenExpireDate(expireDate);
|
|
216
|
+
setAccessToken(response.access_token);
|
|
217
|
+
setRefreshToken(response.refresh_token);
|
|
205
218
|
};
|
|
206
219
|
// --------------------------------------------------------------------
|
|
207
|
-
const
|
|
208
|
-
if (!
|
|
220
|
+
const refreshSession = createPromiseShareWrapperFn(async ()=>{
|
|
221
|
+
if (!refreshToken.value) {
|
|
222
|
+
throw new TokenError('The access token can not be renewed.');
|
|
223
|
+
}
|
|
224
|
+
return client.token.createWithRefreshToken({
|
|
225
|
+
refresh_token: refreshToken.value
|
|
226
|
+
}).then((r)=>handleTokenGrantResponse(r)).catch((e)=>{
|
|
227
|
+
logout();
|
|
228
|
+
return Promise.reject(e);
|
|
229
|
+
}).finally(()=>{
|
|
230
|
+
tokenResolved.value = false;
|
|
231
|
+
userResolved.value = false;
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
// --------------------------------------------------------------------
|
|
235
|
+
const resolveInternal = async ()=>{
|
|
209
236
|
try {
|
|
210
|
-
if (!
|
|
211
|
-
|
|
212
|
-
token: accessToken.value
|
|
213
|
-
}, {
|
|
214
|
-
authorizationHeader: {
|
|
215
|
-
type: 'Bearer',
|
|
216
|
-
token: accessToken.value
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
setTokenInfo(token);
|
|
220
|
-
tokenResolved.value = true;
|
|
237
|
+
if (!accessToken.value && refreshToken.value) {
|
|
238
|
+
await refreshSession();
|
|
221
239
|
}
|
|
222
|
-
if (
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
240
|
+
if (accessToken.value) {
|
|
241
|
+
await resolveToken();
|
|
242
|
+
if (!user.value) {
|
|
243
|
+
await resolveUser();
|
|
244
|
+
}
|
|
226
245
|
}
|
|
227
246
|
} catch (e) {
|
|
228
|
-
if (isClientTokenExpiredError(e)) {
|
|
229
|
-
await
|
|
230
|
-
|
|
231
|
-
refresh: true,
|
|
232
|
-
attempts: ctx.attempts ? ctx.attempts++ : 1
|
|
233
|
-
});
|
|
234
|
-
return;
|
|
247
|
+
if (isClientTokenExpiredError(e) && refreshToken.value) {
|
|
248
|
+
await refreshSession();
|
|
249
|
+
return resolveInternal();
|
|
235
250
|
}
|
|
236
251
|
throw e;
|
|
237
252
|
}
|
|
253
|
+
return Promise.resolve();
|
|
238
254
|
};
|
|
255
|
+
const resolve = createPromiseShareWrapperFn(resolveInternal);
|
|
239
256
|
const loggedIn = computed(()=>!!accessToken.value);
|
|
240
257
|
const login = async (ctx)=>{
|
|
241
258
|
try {
|
|
@@ -249,7 +266,7 @@ function createStore(context = {}) {
|
|
|
249
266
|
handleTokenGrantResponse(response);
|
|
250
267
|
await resolve();
|
|
251
268
|
} catch (e) {
|
|
252
|
-
|
|
269
|
+
logout();
|
|
253
270
|
throw e;
|
|
254
271
|
}
|
|
255
272
|
};
|
|
@@ -258,7 +275,10 @@ function createStore(context = {}) {
|
|
|
258
275
|
setAccessTokenExpireDate(undefined);
|
|
259
276
|
setRefreshToken(undefined);
|
|
260
277
|
setUser(undefined);
|
|
261
|
-
|
|
278
|
+
setRealm(undefined);
|
|
279
|
+
setRealmManagement(undefined);
|
|
280
|
+
tokenResolved.value = false;
|
|
281
|
+
userResolved.value = false;
|
|
262
282
|
};
|
|
263
283
|
return {
|
|
264
284
|
initialized,
|
|
@@ -275,8 +295,6 @@ function createStore(context = {}) {
|
|
|
275
295
|
setAccessTokenExpireDate,
|
|
276
296
|
refreshToken,
|
|
277
297
|
setRefreshToken,
|
|
278
|
-
tokenInfo,
|
|
279
|
-
setTokenInfo,
|
|
280
298
|
realm,
|
|
281
299
|
realmId,
|
|
282
300
|
realmIsRoot,
|
|
@@ -359,34 +377,34 @@ function shouldUpdate(dependencies, newCookies, oldCookies) {
|
|
|
359
377
|
|
|
360
378
|
const StoreSymbol = Symbol.for('AuthupStore');
|
|
361
379
|
function useStore(pinia, app) {
|
|
362
|
-
const instance =
|
|
380
|
+
const instance = injectStoreFactory(app);
|
|
363
381
|
if (!instance) {
|
|
364
382
|
throw new Error('The store has not been injected in the app context.');
|
|
365
383
|
}
|
|
366
384
|
return instance(pinia);
|
|
367
385
|
}
|
|
368
|
-
function
|
|
386
|
+
function injectStoreFactory(app) {
|
|
369
387
|
const instance = inject$1(StoreSymbol, app);
|
|
370
388
|
if (!instance) {
|
|
371
|
-
throw new Error('The store has not been injected in the app context.');
|
|
389
|
+
throw new Error('The store factory has not been injected in the app context.');
|
|
372
390
|
}
|
|
373
391
|
return instance;
|
|
374
392
|
}
|
|
375
|
-
function
|
|
393
|
+
function hasStoreFactory(app) {
|
|
376
394
|
return !!inject$1(StoreSymbol, app);
|
|
377
395
|
}
|
|
378
|
-
function
|
|
396
|
+
function provideStoreFactory(store, app) {
|
|
379
397
|
provide(StoreSymbol, store, app);
|
|
380
398
|
}
|
|
381
399
|
|
|
382
400
|
function installStore(app, options = {}) {
|
|
383
|
-
if (
|
|
401
|
+
if (hasStoreFactory(app)) {
|
|
384
402
|
return;
|
|
385
403
|
}
|
|
386
|
-
const
|
|
404
|
+
const storeFactory = defineStore(STORE_ID, ()=>createStore({
|
|
387
405
|
baseURL: options.baseURL
|
|
388
406
|
}));
|
|
389
|
-
const store =
|
|
407
|
+
const store = storeFactory(options.pinia);
|
|
390
408
|
let cookieGet;
|
|
391
409
|
if (options.cookieGet) {
|
|
392
410
|
cookieGet = options.cookieGet;
|
|
@@ -405,8 +423,8 @@ function installStore(app, options = {}) {
|
|
|
405
423
|
if (options.cookieUnset) {
|
|
406
424
|
cookieUnset = options.cookieUnset;
|
|
407
425
|
} else if (options.cookieSet) {
|
|
408
|
-
cookieUnset = (key)=>{
|
|
409
|
-
options.cookieSet(key, null);
|
|
426
|
+
cookieUnset = (key, opts)=>{
|
|
427
|
+
options.cookieSet(key, null, opts);
|
|
410
428
|
};
|
|
411
429
|
} else {
|
|
412
430
|
const cookies = useCookies();
|
|
@@ -463,12 +481,12 @@ function installStore(app, options = {}) {
|
|
|
463
481
|
return;
|
|
464
482
|
}
|
|
465
483
|
if (action.name === 'logout') {
|
|
466
|
-
cookieUnset(CookieName.ACCESS_TOKEN);
|
|
467
|
-
cookieUnset(CookieName.ACCESS_TOKEN_EXPIRE_DATE);
|
|
468
|
-
cookieUnset(CookieName.REFRESH_TOKEN);
|
|
469
|
-
cookieUnset(CookieName.USER);
|
|
470
|
-
cookieUnset(CookieName.REALM);
|
|
471
|
-
cookieUnset(CookieName.REALM_MANAGEMENT);
|
|
484
|
+
cookieUnset(CookieName.ACCESS_TOKEN, {});
|
|
485
|
+
cookieUnset(CookieName.ACCESS_TOKEN_EXPIRE_DATE, {});
|
|
486
|
+
cookieUnset(CookieName.REFRESH_TOKEN, {});
|
|
487
|
+
cookieUnset(CookieName.USER, {});
|
|
488
|
+
cookieUnset(CookieName.REALM, {});
|
|
489
|
+
cookieUnset(CookieName.REALM_MANAGEMENT, {});
|
|
472
490
|
}
|
|
473
491
|
});
|
|
474
492
|
initStore();
|
|
@@ -476,26 +494,34 @@ function installStore(app, options = {}) {
|
|
|
476
494
|
if (mutation.storeId !== STORE_ID) {
|
|
477
495
|
return;
|
|
478
496
|
}
|
|
497
|
+
let maxAge;
|
|
498
|
+
if (state.accessTokenExpireDate) {
|
|
499
|
+
maxAge = Math.floor(Math.max(1000, new Date(`${state.accessTokenExpireDate}`).getTime() - Date.now()) / 1000);
|
|
500
|
+
}
|
|
479
501
|
if (state.accessToken) {
|
|
480
|
-
cookieSet(CookieName.ACCESS_TOKEN, state.accessToken
|
|
502
|
+
cookieSet(CookieName.ACCESS_TOKEN, state.accessToken, {
|
|
503
|
+
maxAge
|
|
504
|
+
});
|
|
481
505
|
}
|
|
482
506
|
if (state.accessTokenExpireDate) {
|
|
483
|
-
cookieSet(CookieName.ACCESS_TOKEN_EXPIRE_DATE, state.accessTokenExpireDate
|
|
507
|
+
cookieSet(CookieName.ACCESS_TOKEN_EXPIRE_DATE, state.accessTokenExpireDate, {
|
|
508
|
+
maxAge
|
|
509
|
+
});
|
|
484
510
|
}
|
|
485
511
|
if (state.refreshToken) {
|
|
486
|
-
cookieSet(CookieName.REFRESH_TOKEN, state.refreshToken);
|
|
512
|
+
cookieSet(CookieName.REFRESH_TOKEN, state.refreshToken, {});
|
|
487
513
|
}
|
|
488
514
|
if (state.user) {
|
|
489
|
-
cookieSet(CookieName.USER, state.user);
|
|
515
|
+
cookieSet(CookieName.USER, state.user, {});
|
|
490
516
|
}
|
|
491
517
|
if (state.realm) {
|
|
492
|
-
cookieSet(CookieName.REALM, state.realm);
|
|
518
|
+
cookieSet(CookieName.REALM, state.realm, {});
|
|
493
519
|
}
|
|
494
520
|
if (state.realmManagement) {
|
|
495
|
-
cookieSet(CookieName.REALM_MANAGEMENT, state.realmManagement);
|
|
521
|
+
cookieSet(CookieName.REALM_MANAGEMENT, state.realmManagement, {});
|
|
496
522
|
}
|
|
497
523
|
});
|
|
498
|
-
|
|
524
|
+
provideStoreFactory(storeFactory, app);
|
|
499
525
|
}
|
|
500
526
|
|
|
501
527
|
function storeToRefs(store) {
|
|
@@ -518,8 +544,8 @@ function installHTTPClient(app, options = {}) {
|
|
|
518
544
|
const client = new Client({
|
|
519
545
|
baseURL: options.baseURL
|
|
520
546
|
});
|
|
521
|
-
const
|
|
522
|
-
const store =
|
|
547
|
+
const storeFactory = injectStoreFactory(app);
|
|
548
|
+
const store = storeFactory(options.pinia);
|
|
523
549
|
const { refreshToken } = storeToRefs$1(store);
|
|
524
550
|
const tokenHook = new ClientResponseErrorTokenHook(client, {
|
|
525
551
|
baseURL: options.baseURL,
|
|
@@ -536,7 +562,8 @@ function installHTTPClient(app, options = {}) {
|
|
|
536
562
|
},
|
|
537
563
|
tokenFailed: ()=>{
|
|
538
564
|
store.logout();
|
|
539
|
-
}
|
|
565
|
+
},
|
|
566
|
+
timer: !options.isServer
|
|
540
567
|
});
|
|
541
568
|
store.$subscribe((mutation, state)=>{
|
|
542
569
|
if (mutation.storeId !== STORE_ID) return;
|
|
@@ -552,10 +579,7 @@ function installHTTPClient(app, options = {}) {
|
|
|
552
579
|
}
|
|
553
580
|
if (state.refreshToken && state.accessTokenExpireDate) {
|
|
554
581
|
const expiresIn = Math.floor((state.accessTokenExpireDate.getTime() - Date.now()) / 1000);
|
|
555
|
-
tokenHook.setTimer(
|
|
556
|
-
refresh_token: ()=>refreshToken.value,
|
|
557
|
-
expires_in: expiresIn
|
|
558
|
-
});
|
|
582
|
+
tokenHook.setTimer(expiresIn, ()=>refreshToken.value);
|
|
559
583
|
}
|
|
560
584
|
});
|
|
561
585
|
provideHTTPClient(client, app);
|
|
@@ -773,7 +797,7 @@ function injectSocketManager(app) {
|
|
|
773
797
|
}
|
|
774
798
|
|
|
775
799
|
function installSocketManager(app, options) {
|
|
776
|
-
const storeCreator =
|
|
800
|
+
const storeCreator = injectStoreFactory(app);
|
|
777
801
|
const store = storeCreator(options.pinia);
|
|
778
802
|
const { accessToken } = storeToRefs(store);
|
|
779
803
|
const manager = new ClientManager({
|
|
@@ -1539,26 +1563,25 @@ function createEntityManager(ctx) {
|
|
|
1539
1563
|
* Author Peter Placzek (tada5hi)
|
|
1540
1564
|
* For the full copyright and license information,
|
|
1541
1565
|
* view the LICENSE file that was distributed with this source code.
|
|
1542
|
-
*/ var TranslatorTranslationGroup
|
|
1543
|
-
(function(TranslatorTranslationGroup) {
|
|
1566
|
+
*/ var TranslatorTranslationGroup = /*#__PURE__*/ function(TranslatorTranslationGroup) {
|
|
1544
1567
|
TranslatorTranslationGroup["DEFAULT"] = "default";
|
|
1545
1568
|
TranslatorTranslationGroup["CLIENT"] = "authupClient";
|
|
1546
1569
|
TranslatorTranslationGroup["VUECS"] = "vuecs";
|
|
1547
1570
|
TranslatorTranslationGroup["VUELIDATE"] = "vuelidate";
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1571
|
+
return TranslatorTranslationGroup;
|
|
1572
|
+
}({});
|
|
1573
|
+
var TranslatorTranslationVuecsKey = /*#__PURE__*/ function(TranslatorTranslationVuecsKey) {
|
|
1551
1574
|
TranslatorTranslationVuecsKey["NO_MORE"] = "noMore";
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1575
|
+
return TranslatorTranslationVuecsKey;
|
|
1576
|
+
}({});
|
|
1577
|
+
var TranslatorTranslationClientKey = /*#__PURE__*/ function(TranslatorTranslationClientKey) {
|
|
1555
1578
|
TranslatorTranslationClientKey["NAME_HINT"] = "nameHint";
|
|
1556
1579
|
TranslatorTranslationClientKey["DESCRIPTION_HINT"] = "descriptionHint";
|
|
1557
1580
|
TranslatorTranslationClientKey["REDIRECT_URI_HINT"] = "redirectURIHint";
|
|
1558
1581
|
TranslatorTranslationClientKey["IS_CONFIDENTIAL"] = "isConfidential";
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1582
|
+
return TranslatorTranslationClientKey;
|
|
1583
|
+
}({});
|
|
1584
|
+
var TranslatorTranslationDefaultKey = /*#__PURE__*/ function(TranslatorTranslationDefaultKey) {
|
|
1562
1585
|
TranslatorTranslationDefaultKey["ADD"] = "add";
|
|
1563
1586
|
TranslatorTranslationDefaultKey["CREATE"] = "create";
|
|
1564
1587
|
TranslatorTranslationDefaultKey["DELETE"] = "delete";
|
|
@@ -1589,7 +1612,8 @@ var TranslatorTranslationDefaultKey;
|
|
|
1589
1612
|
TranslatorTranslationDefaultKey["SECRET"] = "secret";
|
|
1590
1613
|
TranslatorTranslationDefaultKey["REDIRECT_URIS"] = "redirectUris";
|
|
1591
1614
|
TranslatorTranslationDefaultKey["USERS"] = "users";
|
|
1592
|
-
|
|
1615
|
+
return TranslatorTranslationDefaultKey;
|
|
1616
|
+
}({});
|
|
1593
1617
|
|
|
1594
1618
|
/*
|
|
1595
1619
|
* Copyright (c) 2024-2024.
|
|
@@ -1915,11 +1939,11 @@ const TranslatorTranslationDefaultGerman = {
|
|
|
1915
1939
|
[TranslatorTranslationDefaultKey.USERS]: 'Benutzer'
|
|
1916
1940
|
};
|
|
1917
1941
|
|
|
1918
|
-
var VuelidateCustomRuleKey
|
|
1919
|
-
(function(VuelidateCustomRuleKey) {
|
|
1942
|
+
var VuelidateCustomRuleKey = /*#__PURE__*/ function(VuelidateCustomRuleKey) {
|
|
1920
1943
|
VuelidateCustomRuleKey["ALPHA_NUM_HYPHEN_UNDERSCORE"] = "alphaNumHyphenUnderscore";
|
|
1921
1944
|
VuelidateCustomRuleKey["ALPHA_UPPER_NUM_HYPHEN_UNDERSCORE"] = "alphaUpperNumHyphenUnderscore";
|
|
1922
|
-
|
|
1945
|
+
return VuelidateCustomRuleKey;
|
|
1946
|
+
}({});
|
|
1923
1947
|
const VuelidateCustomRule = {
|
|
1924
1948
|
["alphaNumHyphenUnderscore"]: helpers.regex(/^[a-z0-9-_]*$/),
|
|
1925
1949
|
["alphaUpperNumHyphenUnderscore"]: helpers.regex(/^[a-zA-Z0-9-_]*$/)
|
|
@@ -2059,6 +2083,65 @@ function buildFormSubmitWithTranslations(options, translations) {
|
|
|
2059
2083
|
};
|
|
2060
2084
|
}
|
|
2061
2085
|
|
|
2086
|
+
function createPermissionCheckerReactiveFn(ctx = {}) {
|
|
2087
|
+
let store;
|
|
2088
|
+
if (ctx.store) {
|
|
2089
|
+
store = ctx.store;
|
|
2090
|
+
} else {
|
|
2091
|
+
store = useStore(ctx.pinia, ctx.app);
|
|
2092
|
+
}
|
|
2093
|
+
const storeRefs = storeToRefs(store);
|
|
2094
|
+
return (ctx)=>{
|
|
2095
|
+
const data = ref(false);
|
|
2096
|
+
let computePromise;
|
|
2097
|
+
const compute = async ()=>{
|
|
2098
|
+
if (computePromise) {
|
|
2099
|
+
return computePromise;
|
|
2100
|
+
}
|
|
2101
|
+
let identity;
|
|
2102
|
+
if (storeRefs.userId.value) {
|
|
2103
|
+
identity = {
|
|
2104
|
+
type: 'user',
|
|
2105
|
+
id: storeRefs.userId.value
|
|
2106
|
+
};
|
|
2107
|
+
}
|
|
2108
|
+
let outcome;
|
|
2109
|
+
try {
|
|
2110
|
+
computePromise = store.permissionChecker.preCheckOneOf({
|
|
2111
|
+
...ctx,
|
|
2112
|
+
data: {
|
|
2113
|
+
...ctx.data || {},
|
|
2114
|
+
identity
|
|
2115
|
+
}
|
|
2116
|
+
}).then(()=>true).catch(()=>false);
|
|
2117
|
+
outcome = await computePromise;
|
|
2118
|
+
} catch (e) {
|
|
2119
|
+
outcome = false;
|
|
2120
|
+
} finally{
|
|
2121
|
+
computePromise = undefined;
|
|
2122
|
+
}
|
|
2123
|
+
return outcome;
|
|
2124
|
+
};
|
|
2125
|
+
Promise.resolve().then(()=>compute()).then((outcome)=>{
|
|
2126
|
+
data.value = outcome;
|
|
2127
|
+
});
|
|
2128
|
+
let removeListener;
|
|
2129
|
+
onMounted(()=>{
|
|
2130
|
+
removeListener = watch(storeRefs.loggedIn, ()=>{
|
|
2131
|
+
Promise.resolve().then(()=>compute()).then((outcome)=>{
|
|
2132
|
+
data.value = outcome;
|
|
2133
|
+
});
|
|
2134
|
+
});
|
|
2135
|
+
});
|
|
2136
|
+
onUnmounted(()=>{
|
|
2137
|
+
if (typeof removeListener !== 'undefined') {
|
|
2138
|
+
removeListener();
|
|
2139
|
+
}
|
|
2140
|
+
});
|
|
2141
|
+
return data;
|
|
2142
|
+
};
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2062
2145
|
const AClient = defineComponent({
|
|
2063
2146
|
props: defineEntityManagerProps(),
|
|
2064
2147
|
emits: defineEntityManagerEvents(),
|
|
@@ -2106,55 +2189,9 @@ function useUpdatedAt(input) {
|
|
|
2106
2189
|
});
|
|
2107
2190
|
}
|
|
2108
2191
|
|
|
2109
|
-
function
|
|
2110
|
-
const
|
|
2111
|
-
|
|
2112
|
-
const data = ref(false);
|
|
2113
|
-
let computePromise;
|
|
2114
|
-
const compute = async ()=>{
|
|
2115
|
-
if (computePromise) {
|
|
2116
|
-
return computePromise;
|
|
2117
|
-
}
|
|
2118
|
-
let identity;
|
|
2119
|
-
if (refs.userId.value) {
|
|
2120
|
-
identity = {
|
|
2121
|
-
type: 'user',
|
|
2122
|
-
id: refs.userId.value
|
|
2123
|
-
};
|
|
2124
|
-
}
|
|
2125
|
-
let outcome;
|
|
2126
|
-
try {
|
|
2127
|
-
computePromise = store.permissionChecker.preCheck({
|
|
2128
|
-
name,
|
|
2129
|
-
data: {
|
|
2130
|
-
identity
|
|
2131
|
-
}
|
|
2132
|
-
}).then(()=>true).catch(()=>false);
|
|
2133
|
-
outcome = await computePromise;
|
|
2134
|
-
} catch (e) {
|
|
2135
|
-
outcome = false;
|
|
2136
|
-
} finally{
|
|
2137
|
-
computePromise = undefined;
|
|
2138
|
-
}
|
|
2139
|
-
return outcome;
|
|
2140
|
-
};
|
|
2141
|
-
Promise.resolve().then(()=>compute()).then((outcome)=>{
|
|
2142
|
-
data.value = outcome;
|
|
2143
|
-
});
|
|
2144
|
-
let removeListener;
|
|
2145
|
-
onMounted(()=>{
|
|
2146
|
-
removeListener = watch(refs.loggedIn, ()=>{
|
|
2147
|
-
Promise.resolve().then(()=>compute()).then((outcome)=>{
|
|
2148
|
-
data.value = outcome;
|
|
2149
|
-
});
|
|
2150
|
-
});
|
|
2151
|
-
});
|
|
2152
|
-
onUnmounted(()=>{
|
|
2153
|
-
if (typeof removeListener !== 'undefined') {
|
|
2154
|
-
removeListener();
|
|
2155
|
-
}
|
|
2156
|
-
});
|
|
2157
|
-
return data;
|
|
2192
|
+
function usePermissionCheck(ctx) {
|
|
2193
|
+
const checkFn = createPermissionCheckerReactiveFn();
|
|
2194
|
+
return checkFn(ctx);
|
|
2158
2195
|
}
|
|
2159
2196
|
|
|
2160
2197
|
function useRealmResourceWritableCheck(realmId) {
|
|
@@ -5268,6 +5305,38 @@ const APermission = defineComponent({
|
|
|
5268
5305
|
}
|
|
5269
5306
|
});
|
|
5270
5307
|
|
|
5308
|
+
const APermissionCheck = defineComponent({
|
|
5309
|
+
props: {
|
|
5310
|
+
name: {
|
|
5311
|
+
type: [
|
|
5312
|
+
String,
|
|
5313
|
+
Array
|
|
5314
|
+
],
|
|
5315
|
+
required: true
|
|
5316
|
+
},
|
|
5317
|
+
data: {
|
|
5318
|
+
type: Object
|
|
5319
|
+
},
|
|
5320
|
+
options: {
|
|
5321
|
+
type: Object
|
|
5322
|
+
}
|
|
5323
|
+
},
|
|
5324
|
+
setup (props, { slots }) {
|
|
5325
|
+
const fn = createPermissionCheckerReactiveFn();
|
|
5326
|
+
const isPermitted = computed(()=>fn({
|
|
5327
|
+
name: props.name,
|
|
5328
|
+
data: props.data,
|
|
5329
|
+
options: props.options
|
|
5330
|
+
}));
|
|
5331
|
+
return ()=>{
|
|
5332
|
+
if (isPermitted.value && hasNormalizedSlot(SlotName.DEFAULT, slots)) {
|
|
5333
|
+
return normalizeSlot(SlotName.DEFAULT, {}, slots);
|
|
5334
|
+
}
|
|
5335
|
+
return [];
|
|
5336
|
+
};
|
|
5337
|
+
}
|
|
5338
|
+
});
|
|
5339
|
+
|
|
5271
5340
|
const APermissionForm = defineComponent({
|
|
5272
5341
|
props: {
|
|
5273
5342
|
entity: {
|
|
@@ -6570,11 +6639,11 @@ const APagination = defineComponent({
|
|
|
6570
6639
|
* Author Peter Placzek (tada5hi)
|
|
6571
6640
|
* For the full copyright and license information,
|
|
6572
6641
|
* view the LICENSE file that was distributed with this source code.
|
|
6573
|
-
*/ var TitleSlotName
|
|
6574
|
-
(function(TitleSlotName) {
|
|
6642
|
+
*/ var TitleSlotName = /*#__PURE__*/ function(TitleSlotName) {
|
|
6575
6643
|
TitleSlotName["DEFAULT"] = "default";
|
|
6576
6644
|
TitleSlotName["ICON"] = "icon";
|
|
6577
|
-
|
|
6645
|
+
return TitleSlotName;
|
|
6646
|
+
}({});
|
|
6578
6647
|
|
|
6579
6648
|
function buildTitle(ctx) {
|
|
6580
6649
|
ctx.tag = ctx.tag || 'h6';
|
|
@@ -6660,11 +6729,11 @@ const ATitle = defineComponent({
|
|
|
6660
6729
|
* Author Peter Placzek (tada5hi)
|
|
6661
6730
|
* For the full copyright and license information,
|
|
6662
6731
|
* view the LICENSE file that was distributed with this source code.
|
|
6663
|
-
*/ var ListSearchSlotName
|
|
6664
|
-
(function(ListSearchSlotName) {
|
|
6732
|
+
*/ var ListSearchSlotName = /*#__PURE__*/ function(ListSearchSlotName) {
|
|
6665
6733
|
ListSearchSlotName["DEFAULT"] = "default";
|
|
6666
6734
|
ListSearchSlotName["ICON"] = "icon";
|
|
6667
|
-
|
|
6735
|
+
return ListSearchSlotName;
|
|
6736
|
+
}({});
|
|
6668
6737
|
|
|
6669
6738
|
function debounce(func, timeout = 200) {
|
|
6670
6739
|
let timer;
|
|
@@ -6834,12 +6903,6 @@ const LanguageSwitcherDropdown = defineComponent({
|
|
|
6834
6903
|
}
|
|
6835
6904
|
});
|
|
6836
6905
|
|
|
6837
|
-
var ElementType;
|
|
6838
|
-
(function(ElementType) {
|
|
6839
|
-
ElementType["BUTTON"] = "button";
|
|
6840
|
-
ElementType["LINK"] = "link";
|
|
6841
|
-
ElementType["DROP_DOWN_ITEM"] = "dropDownItem";
|
|
6842
|
-
})(ElementType || (ElementType = {}));
|
|
6843
6906
|
const AEntityDelete = defineComponent({
|
|
6844
6907
|
props: {
|
|
6845
6908
|
elementIcon: {
|
|
@@ -6966,6 +7029,7 @@ var components = /*#__PURE__*/Object.freeze({
|
|
|
6966
7029
|
AIdentityProviders: AIdentityProviders,
|
|
6967
7030
|
APagination: APagination,
|
|
6968
7031
|
APermission: APermission,
|
|
7032
|
+
APermissionCheck: APermissionCheck,
|
|
6969
7033
|
APermissionForm: APermissionForm,
|
|
6970
7034
|
APermissionRobotAssignments: APermissionRobotAssignments,
|
|
6971
7035
|
APermissionRoleAssignments: APermissionRoleAssignments,
|
|
@@ -7037,7 +7101,8 @@ function install(app1, options) {
|
|
|
7037
7101
|
});
|
|
7038
7102
|
installHTTPClient(app1, {
|
|
7039
7103
|
pinia: options.pinia,
|
|
7040
|
-
baseURL: options.baseURL
|
|
7104
|
+
baseURL: options.baseURL,
|
|
7105
|
+
isServer: options.isServer
|
|
7041
7106
|
});
|
|
7042
7107
|
installTranslator(app1, {
|
|
7043
7108
|
locale: options.translatorLocale
|
|
@@ -7049,5 +7114,5 @@ var index = {
|
|
|
7049
7114
|
install
|
|
7050
7115
|
};
|
|
7051
7116
|
|
|
7052
|
-
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,
|
|
7117
|
+
export { AClient, AClientForm, AClientRedirectUris, AClientRedirectUrisItem, AClientScope, AClientScopeAssignment, AClientScopeAssignments, AClientScopes, AClients, AEntityDelete, AIdentityProvider, AIdentityProviderForm, AIdentityProviderIcon, AIdentityProviderLdapForm, AIdentityProviderOAuth2Form, AIdentityProviderPreset, AIdentityProviderProtocol, AIdentityProviderRoleAssignment, AIdentityProviderRoleAssignments, AIdentityProviders, APagination, APermission, APermissionCheck, 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, createPermissionCheckerReactiveFn, createStore, index as default, defineEntityManagerEvents, defineEntityManagerProps, defineListEvents, defineListProps, extendObjectProperties, extractVuelidateResultsFromChild, getVuelidateSeverity, hasHTTPClient, hasNormalizedSlot, hasStoreFactory, initFormAttributesFromSource, inject$1 as inject, injectHTTPClient, injectSocketManager, injectStoreFactory, injectTranslatorLocale, install, installHTTPClient, installSocketManager, installStore, installTranslator, isQuerySortedDescByDate, isSocketManagerUsable, mergeListOptions, normalizeSlot, onChange, provide, provideHTTPClient, provideSocketManager, provideStoreFactory, renderEntityAssignAction, storeToRefs, useIsEditing, usePermissionCheck, useRealmResourceWritableCheck, useStore, useTranslation, useTranslationsForBaseValidation, useTranslationsForGroup, useTranslationsForNestedValidation, useUpdatedAt, wrapFnWithBusyState };
|
|
7053
7118
|
//# sourceMappingURL=index.mjs.map
|