@dereekb/dbx-core 9.14.2 → 9.15.1
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/esm2020/lib/router/auth/hook/index.mjs +2 -0
- package/esm2020/lib/router/auth/hook/uid.hook.mjs +55 -0
- package/esm2020/lib/router/auth/index.mjs +2 -0
- package/esm2020/lib/router/index.mjs +2 -1
- package/fesm2015/dereekb-dbx-core.mjs +54 -1
- package/fesm2015/dereekb-dbx-core.mjs.map +1 -1
- package/fesm2020/dereekb-dbx-core.mjs +54 -1
- package/fesm2020/dereekb-dbx-core.mjs.map +1 -1
- package/lib/router/auth/hook/index.d.ts +1 -0
- package/lib/router/auth/hook/uid.hook.d.ts +36 -0
- package/lib/router/auth/index.d.ts +1 -0
- package/lib/router/index.d.ts +1 -0
- package/package.json +4 -4
|
@@ -2210,6 +2210,59 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImpor
|
|
|
2210
2210
|
type: Input
|
|
2211
2211
|
}] } });
|
|
2212
2212
|
|
|
2213
|
+
const DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_VALUE = '0';
|
|
2214
|
+
const DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_KEY = 'uid';
|
|
2215
|
+
/**
|
|
2216
|
+
* This hook asserts the user is allowed to view a route with a user identifier as a parameter.
|
|
2217
|
+
*
|
|
2218
|
+
* If not, or
|
|
2219
|
+
*/
|
|
2220
|
+
function redirectForUserIdentifierParamHook(input) {
|
|
2221
|
+
const { uidParam = DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_KEY, defaultParamValue = DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_VALUE, transitionService, canViewUser } = input;
|
|
2222
|
+
const criteria = typeof input.criteria === 'string' ? { entering: input.criteria } : input.criteria;
|
|
2223
|
+
// https://ui-router.github.io/ng2/docs/latest/modules/transition.html#hookresult
|
|
2224
|
+
const assertAllowedUid = (transition) => {
|
|
2225
|
+
const $state = transition.router.stateService;
|
|
2226
|
+
const injector = transition.injector();
|
|
2227
|
+
const authService = injector.get(DbxAuthService);
|
|
2228
|
+
const params = transition.params();
|
|
2229
|
+
const transitionTargetUid = params[uidParam];
|
|
2230
|
+
return firstValueFrom(authService.userIdentifier$.pipe(first(), switchMap((currentUserId) => {
|
|
2231
|
+
let result = of(true);
|
|
2232
|
+
let redirectToUid;
|
|
2233
|
+
if (!transitionTargetUid || transitionTargetUid === DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_VALUE) {
|
|
2234
|
+
// If uid isn't set, default to the current user.
|
|
2235
|
+
redirectToUid = of(currentUserId);
|
|
2236
|
+
}
|
|
2237
|
+
else if (currentUserId !== transitionTargetUid) {
|
|
2238
|
+
redirectToUid = canViewUser(transitionTargetUid, authService, injector).pipe(map((x) => {
|
|
2239
|
+
if (typeof x === 'boolean') {
|
|
2240
|
+
return x ? transitionTargetUid : currentUserId;
|
|
2241
|
+
}
|
|
2242
|
+
else {
|
|
2243
|
+
return x;
|
|
2244
|
+
}
|
|
2245
|
+
}));
|
|
2246
|
+
}
|
|
2247
|
+
if (redirectToUid != null) {
|
|
2248
|
+
result = redirectToUid.pipe(first(), map((targetUid) => {
|
|
2249
|
+
if (targetUid !== transitionTargetUid) {
|
|
2250
|
+
const target = transition.targetState();
|
|
2251
|
+
const state = target.state();
|
|
2252
|
+
return $state.target(state, { ...params, uid: targetUid }, { location: true });
|
|
2253
|
+
}
|
|
2254
|
+
else {
|
|
2255
|
+
return true;
|
|
2256
|
+
}
|
|
2257
|
+
}));
|
|
2258
|
+
}
|
|
2259
|
+
return result;
|
|
2260
|
+
})));
|
|
2261
|
+
};
|
|
2262
|
+
// Register the "requires auth" hook with the TransitionsService
|
|
2263
|
+
transitionService.onBefore(criteria, assertAllowedUid, { priority: 100 });
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2213
2266
|
var DbxRouterTransitionEventType;
|
|
2214
2267
|
(function (DbxRouterTransitionEventType) {
|
|
2215
2268
|
/**
|
|
@@ -4687,5 +4740,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImpor
|
|
|
4687
4740
|
* Generated bundle index. Do not edit.
|
|
4688
4741
|
*/
|
|
4689
4742
|
|
|
4690
|
-
export { APP_ACTION_DISABLED_DIRECTIVE_KEY, APP_ACTION_ENFORCE_MODIFIED_DIRECTIVE_KEY, AbstractActionFilterSourceDirective, AbstractDbxActionValueOnTriggerDirective, AbstractDbxAnchorDirective, AbstractDbxButtonDirective, AbstractDbxFilterMapInstanceDirective, AbstractDbxInjectionDirective, AbstractFilterSourceConnectorDirective, AbstractFilterSourceDirective, AbstractForwardDbxInjectionContextDirective, AbstractIfDirective, AbstractLockSetSubscriptionDirective, AbstractSubscriptionDirective, AbstractTransitionDirective, AbstractTransitionWatcherDirective, ActionContextStore, ActionContextStoreSource, ActionContextStoreSourceMap, AnchorType, DBX_APP_APP_CONTEXT_STATE, DBX_APP_AUTH_ROUTER_EFFECTS_TOKEN, DBX_AUTH_APP_CONTEXT_STATE, DBX_INIT_APP_CONTEXT_STATE, DBX_INJECTION_COMPONENT_DATA, DBX_KNOWN_APP_CONTEXT_STATES, DBX_ONBOARDING_APP_CONTEXT_STATE, DBX_PUBLIC_APP_CONTEXT_STATE, DEFAULT_ACTION_DISABLED_KEY, DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY, DEFAULT_STORAGE_ACCESSOR_FACTORY_TOKEN, DEFAULT_STORAGE_OBJECT_TOKEN, DateDistancePipe, DateFormatDistancePipe, DateFromToTimePipe, DbxActionAutoModifyDirective, DbxActionAutoTriggerDirective, DbxActionButtonDirective, DbxActionButtonTriggerDirective, DbxActionContextBaseSource, DbxActionContextLoggerDirective, DbxActionContextMachine, DbxActionContextMapDirective, DbxActionContextMapDirectiveSourceInstance, DbxActionContextStoreSourceInstance, DbxActionDirective, DbxActionDisabledDirective, DbxActionEnforceModifiedDirective, DbxActionFromMapDirective, DbxActionHandlerDirective, DbxActionHasSuccessDirective, DbxActionIsWorkingDirective, DbxActionMapSourceDirective, DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionState, DbxActionSuccessHandlerDirective, DbxActionValueDirective, DbxActionValueOnTriggerInstance, DbxActionValueTriggerDirective, DbxActionWorkInstanceDelegate, DbxAnchor, DbxAngularRouterService, DbxAppAuthRouterEffects, DbxAppAuthRouterModule, DbxAppAuthRouterService, DbxAppAuthRouterStateModule, DbxAppAuthRoutes, DbxAppAuthStateModule, DbxAppAuthStateService, DbxAppContextService, DbxAppContextStateDirective, DbxAppContextStateModule, DbxAuthHasAnyRoleDirective, DbxAuthHasRolesDirective, DbxAuthNotAnyRolesDirective, DbxAuthService, DbxButton, DbxButtonDirective, DbxButtonSegueDirective, DbxCoreActionModule, DbxCoreAngularRouterSegueModule, DbxCoreAuthModule, DbxCoreButtonModule, DbxCoreFilterModule, DbxCoreUIRouterSegueModule, DbxDatePipeModule, DbxFilterMapDirective, DbxFilterMapSourceConnectorDirective, DbxFilterMapSourceDirective, DbxFilterSourceConnectorDirective, DbxFilterSourceDirective, DbxInjectionComponent, DbxInjectionComponentModule, DbxInjectionContext, DbxInjectionContextDirective, DbxInjectionInstance, DbxLoadingButtonDirective, DbxMiscPipeModule, DbxPipesModule, DbxRouteParamDefaultRedirectInstance, DbxRouteParamReaderInstance, DbxRouterService, DbxRouterTransitionEventType, DbxRouterTransitionService, DbxStorageModule, DbxUIRouterService, FullLocalStorageObject, InstantStorageAccessor, LimitedStorageAccessor, LockSetComponentStore, MemoryStorageObject, MinutesStringPipe, NO_AUTH_USER_IDENTIFIER, PrettyJsonPipe, SecondaryActionContextStoreSource, SimpleStorageAccessor, SimpleStorageAccessorFactory, StorageAccessor, StringStorageAccessor, StringifySimpleStorageAccessorConverter, TimeDistanceCountdownPipe, TimeDistancePipe, ToJsDatePipe, ToMinutesPipe, WrapperSimpleStorageAccessorDelegate, actionContextHasNoErrorAndIsModifiedAndCanTrigger, actionContextIsModifiedAndCanTrigger, actionContextStoreSourceInstanceFactory, actionContextStoreSourcePipe, anchorTypeForAnchor, asSegueRef, asSegueRefString, authRolesSetContainsAllRolesFrom, authRolesSetContainsAnyRoleFrom, authRolesSetContainsNoRolesFrom, authUserIdentifier, canReadyValue, canTriggerAction, canTriggerActionState, checkNgContentWrapperHasContent, dbxActionValueStreamDirective, defaultStorageObjectFactory, enableHasAuthRoleHook, enableHasAuthStateHook, enableIsLoggedInHook, expandClickableAnchorLinkTree, expandClickableAnchorLinkTreeNode, expandClickableAnchorLinkTrees, filterTransitionEvent, filterTransitionSuccess, flattenExpandedClickableAnchorLinkTree, flattenExpandedClickableAnchorLinkTreeToLinks, index as fromDbxAppAuth, index$2 as fromDbxAppContext, goWithRouter, isActionContextDisabled, isActionContextEnabled, isDisabledActionContextState, isIdleActionState, isLatestSuccessfulRoute, isSegueRef, isWorkingActionState, loadingStateForActionContextState, loadingStateTypeForActionContextState, loadingStateTypeForActionState, loggedInObsFromIsLoggedIn, loggedOutObsFromIsLoggedIn, makeAuthTransitionHook, makeDbxActionContextSourceReference, mapRefStringObsToSegueRefObs, mergeDbxInjectionComponentConfigs, index$1 as onDbxAppAuth, index$3 as onDbxAppContext, pipeActionStore, provideActionStoreSource, provideDbxAnchor, provideDbxButton, provideDbxInjectionContext, provideFilterSource, provideFilterSourceConnector, provideSecondaryActionStoreSource, redirectBasedOnAuthUserState, refStringToSegueRef, safeDetectChanges, safeMarkForCheck, safeUseCdRef, successTransition, tapDetectChanges, tapSafeMarkForCheck, useActionStore };
|
|
4743
|
+
export { APP_ACTION_DISABLED_DIRECTIVE_KEY, APP_ACTION_ENFORCE_MODIFIED_DIRECTIVE_KEY, AbstractActionFilterSourceDirective, AbstractDbxActionValueOnTriggerDirective, AbstractDbxAnchorDirective, AbstractDbxButtonDirective, AbstractDbxFilterMapInstanceDirective, AbstractDbxInjectionDirective, AbstractFilterSourceConnectorDirective, AbstractFilterSourceDirective, AbstractForwardDbxInjectionContextDirective, AbstractIfDirective, AbstractLockSetSubscriptionDirective, AbstractSubscriptionDirective, AbstractTransitionDirective, AbstractTransitionWatcherDirective, ActionContextStore, ActionContextStoreSource, ActionContextStoreSourceMap, AnchorType, DBX_APP_APP_CONTEXT_STATE, DBX_APP_AUTH_ROUTER_EFFECTS_TOKEN, DBX_AUTH_APP_CONTEXT_STATE, DBX_INIT_APP_CONTEXT_STATE, DBX_INJECTION_COMPONENT_DATA, DBX_KNOWN_APP_CONTEXT_STATES, DBX_ONBOARDING_APP_CONTEXT_STATE, DBX_PUBLIC_APP_CONTEXT_STATE, DEFAULT_ACTION_DISABLED_KEY, DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY, DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_KEY, DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_VALUE, DEFAULT_STORAGE_ACCESSOR_FACTORY_TOKEN, DEFAULT_STORAGE_OBJECT_TOKEN, DateDistancePipe, DateFormatDistancePipe, DateFromToTimePipe, DbxActionAutoModifyDirective, DbxActionAutoTriggerDirective, DbxActionButtonDirective, DbxActionButtonTriggerDirective, DbxActionContextBaseSource, DbxActionContextLoggerDirective, DbxActionContextMachine, DbxActionContextMapDirective, DbxActionContextMapDirectiveSourceInstance, DbxActionContextStoreSourceInstance, DbxActionDirective, DbxActionDisabledDirective, DbxActionEnforceModifiedDirective, DbxActionFromMapDirective, DbxActionHandlerDirective, DbxActionHasSuccessDirective, DbxActionIsWorkingDirective, DbxActionMapSourceDirective, DbxActionMapWorkingDisableDirective, DbxActionSourceDirective, DbxActionState, DbxActionSuccessHandlerDirective, DbxActionValueDirective, DbxActionValueOnTriggerInstance, DbxActionValueTriggerDirective, DbxActionWorkInstanceDelegate, DbxAnchor, DbxAngularRouterService, DbxAppAuthRouterEffects, DbxAppAuthRouterModule, DbxAppAuthRouterService, DbxAppAuthRouterStateModule, DbxAppAuthRoutes, DbxAppAuthStateModule, DbxAppAuthStateService, DbxAppContextService, DbxAppContextStateDirective, DbxAppContextStateModule, DbxAuthHasAnyRoleDirective, DbxAuthHasRolesDirective, DbxAuthNotAnyRolesDirective, DbxAuthService, DbxButton, DbxButtonDirective, DbxButtonSegueDirective, DbxCoreActionModule, DbxCoreAngularRouterSegueModule, DbxCoreAuthModule, DbxCoreButtonModule, DbxCoreFilterModule, DbxCoreUIRouterSegueModule, DbxDatePipeModule, DbxFilterMapDirective, DbxFilterMapSourceConnectorDirective, DbxFilterMapSourceDirective, DbxFilterSourceConnectorDirective, DbxFilterSourceDirective, DbxInjectionComponent, DbxInjectionComponentModule, DbxInjectionContext, DbxInjectionContextDirective, DbxInjectionInstance, DbxLoadingButtonDirective, DbxMiscPipeModule, DbxPipesModule, DbxRouteParamDefaultRedirectInstance, DbxRouteParamReaderInstance, DbxRouterService, DbxRouterTransitionEventType, DbxRouterTransitionService, DbxStorageModule, DbxUIRouterService, FullLocalStorageObject, InstantStorageAccessor, LimitedStorageAccessor, LockSetComponentStore, MemoryStorageObject, MinutesStringPipe, NO_AUTH_USER_IDENTIFIER, PrettyJsonPipe, SecondaryActionContextStoreSource, SimpleStorageAccessor, SimpleStorageAccessorFactory, StorageAccessor, StringStorageAccessor, StringifySimpleStorageAccessorConverter, TimeDistanceCountdownPipe, TimeDistancePipe, ToJsDatePipe, ToMinutesPipe, WrapperSimpleStorageAccessorDelegate, actionContextHasNoErrorAndIsModifiedAndCanTrigger, actionContextIsModifiedAndCanTrigger, actionContextStoreSourceInstanceFactory, actionContextStoreSourcePipe, anchorTypeForAnchor, asSegueRef, asSegueRefString, authRolesSetContainsAllRolesFrom, authRolesSetContainsAnyRoleFrom, authRolesSetContainsNoRolesFrom, authUserIdentifier, canReadyValue, canTriggerAction, canTriggerActionState, checkNgContentWrapperHasContent, dbxActionValueStreamDirective, defaultStorageObjectFactory, enableHasAuthRoleHook, enableHasAuthStateHook, enableIsLoggedInHook, expandClickableAnchorLinkTree, expandClickableAnchorLinkTreeNode, expandClickableAnchorLinkTrees, filterTransitionEvent, filterTransitionSuccess, flattenExpandedClickableAnchorLinkTree, flattenExpandedClickableAnchorLinkTreeToLinks, index as fromDbxAppAuth, index$2 as fromDbxAppContext, goWithRouter, isActionContextDisabled, isActionContextEnabled, isDisabledActionContextState, isIdleActionState, isLatestSuccessfulRoute, isSegueRef, isWorkingActionState, loadingStateForActionContextState, loadingStateTypeForActionContextState, loadingStateTypeForActionState, loggedInObsFromIsLoggedIn, loggedOutObsFromIsLoggedIn, makeAuthTransitionHook, makeDbxActionContextSourceReference, mapRefStringObsToSegueRefObs, mergeDbxInjectionComponentConfigs, index$1 as onDbxAppAuth, index$3 as onDbxAppContext, pipeActionStore, provideActionStoreSource, provideDbxAnchor, provideDbxButton, provideDbxInjectionContext, provideFilterSource, provideFilterSourceConnector, provideSecondaryActionStoreSource, redirectBasedOnAuthUserState, redirectForUserIdentifierParamHook, refStringToSegueRef, safeDetectChanges, safeMarkForCheck, safeUseCdRef, successTransition, tapDetectChanges, tapSafeMarkForCheck, useActionStore };
|
|
4691
4744
|
//# sourceMappingURL=dereekb-dbx-core.mjs.map
|