@geexcode/geex-extensions-authorization 0.0.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/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @geexcode/geex-extensions-authorization
|
|
2
|
+
|
|
3
|
+
Frontend counterpart of backend `Geex.Extensions.Authorization`.
|
|
4
|
+
|
|
5
|
+
Canonical runtime entry: `geex.authorization`.
|
|
6
|
+
|
|
7
|
+
Provides:
|
|
8
|
+
|
|
9
|
+
- `geex.authorization` — tenant claim check, ACL load/persist/sync
|
|
10
|
+
- `AuthorizeGuard` — thin route adapter delegating to `geex.authorization`
|
|
11
|
+
- `LocalStorageACLService` — thin Delon ACL adapter
|
|
12
|
+
- `provideGeexAuthorization()` — register module + adapters
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { provideGeexCommon, geex } from "@geexcode/geex-angular";
|
|
16
|
+
import { provideGeexAuthorization, AuthorizeGuard } from "@geexcode/geex-extensions-authorization";
|
|
17
|
+
|
|
18
|
+
providers: [
|
|
19
|
+
...provideGeexCommon(),
|
|
20
|
+
...provideGeexAuthorization(),
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
// routes (adapter)
|
|
24
|
+
canActivate: [AuthorizeGuard]
|
|
25
|
+
|
|
26
|
+
// business API
|
|
27
|
+
await geex.authorization.canActivate(route, state);
|
|
28
|
+
```
|
package/dist/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @geexcode/geex-extensions-authorization
|
|
2
|
+
|
|
3
|
+
Frontend counterpart of backend `Geex.Extensions.Authorization`.
|
|
4
|
+
|
|
5
|
+
Canonical runtime entry: `geex.authorization`.
|
|
6
|
+
|
|
7
|
+
Provides:
|
|
8
|
+
|
|
9
|
+
- `geex.authorization` — tenant claim check, ACL load/persist/sync
|
|
10
|
+
- `AuthorizeGuard` — thin route adapter delegating to `geex.authorization`
|
|
11
|
+
- `LocalStorageACLService` — thin Delon ACL adapter
|
|
12
|
+
- `provideGeexAuthorization()` — register module + adapters
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { provideGeexCommon, geex } from "@geexcode/geex-angular";
|
|
16
|
+
import { provideGeexAuthorization, AuthorizeGuard } from "@geexcode/geex-extensions-authorization";
|
|
17
|
+
|
|
18
|
+
providers: [
|
|
19
|
+
...provideGeexCommon(),
|
|
20
|
+
...provideGeexAuthorization(),
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
// routes (adapter)
|
|
24
|
+
canActivate: [AuthorizeGuard]
|
|
25
|
+
|
|
26
|
+
// business API
|
|
27
|
+
await geex.authorization.canActivate(route, state);
|
|
28
|
+
```
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Router } from '@angular/router';
|
|
2
|
+
import { OAuthService } from 'angular-oauth2-oidc';
|
|
3
|
+
import { GEEX_SUPER_ADMIN_USER_ID, geex, provideGeexModuleContribution } from '@geexcode/geex-angular';
|
|
4
|
+
import json5 from 'json5';
|
|
5
|
+
import * as i0 from '@angular/core';
|
|
6
|
+
import { Injectable, effect, InjectionToken, makeEnvironmentProviders, Injector } from '@angular/core';
|
|
7
|
+
import { ACLService } from '@delon/acl';
|
|
8
|
+
|
|
9
|
+
function createAuthorizationModule(injector) {
|
|
10
|
+
const oauth = () => injector.get(OAuthService);
|
|
11
|
+
const router = () => injector.get(Router);
|
|
12
|
+
const superAdminUserId = () => injector.get(GEEX_SUPER_ADMIN_USER_ID);
|
|
13
|
+
const module = {
|
|
14
|
+
canActivate: async (_route, state) => {
|
|
15
|
+
if (!oauth().hasValidAccessToken()) {
|
|
16
|
+
return router().parseUrl(`/authentication/login?redirect_uri=${encodeURIComponent(state.url)}`);
|
|
17
|
+
}
|
|
18
|
+
const claims = oauth().getIdentityClaims();
|
|
19
|
+
if (claims?.sub === superAdminUserId()) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
const multiTenant = geex["multiTenant"];
|
|
23
|
+
const currentTenantCode = multiTenant.current()?.code ?? "";
|
|
24
|
+
const tokenTenantCode = claims?.__tenant ?? "";
|
|
25
|
+
if (tokenTenantCode === currentTenantCode) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return router().parseUrl("/exception/403");
|
|
29
|
+
},
|
|
30
|
+
checkTenant: async (pathTenant) => {
|
|
31
|
+
return geex["multiTenant"].loadTenantData(pathTenant);
|
|
32
|
+
},
|
|
33
|
+
loadAcl: () => {
|
|
34
|
+
try {
|
|
35
|
+
return json5.parse(localStorage.getItem("acl") ?? "{}");
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
console.error("failed to load acl from localStorage.", error);
|
|
39
|
+
return { roles: [], abilities: [], full: false };
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
persistAcl: (data) => {
|
|
43
|
+
localStorage.setItem("acl", json5.stringify(data));
|
|
44
|
+
},
|
|
45
|
+
syncAclFromAuth: async () => {
|
|
46
|
+
const authentication = geex["authentication"];
|
|
47
|
+
await authentication.init();
|
|
48
|
+
if (authentication.user() == undefined) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return module.loadAcl();
|
|
52
|
+
},
|
|
53
|
+
init: async () => undefined,
|
|
54
|
+
};
|
|
55
|
+
return module;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
class AuthorizeGuard {
|
|
59
|
+
async canActivate(route, state) {
|
|
60
|
+
return geex.authorization.canActivate(route, state);
|
|
61
|
+
}
|
|
62
|
+
async checkTenant(pathTenant) {
|
|
63
|
+
return geex.authorization.checkTenant(pathTenant);
|
|
64
|
+
}
|
|
65
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: AuthorizeGuard, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
66
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: AuthorizeGuard });
|
|
67
|
+
}
|
|
68
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: AuthorizeGuard, decorators: [{
|
|
69
|
+
type: Injectable
|
|
70
|
+
}] });
|
|
71
|
+
|
|
72
|
+
class LocalStorageACLService extends ACLService {
|
|
73
|
+
static new(injector) {
|
|
74
|
+
return new LocalStorageACLService(injector);
|
|
75
|
+
}
|
|
76
|
+
constructor(injector) {
|
|
77
|
+
super();
|
|
78
|
+
effect(async () => {
|
|
79
|
+
const data = await geex.authorization.syncAclFromAuth();
|
|
80
|
+
if (!data) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this["roles"] = data.roles ?? [];
|
|
84
|
+
this["abilities"] = data.abilities ?? [];
|
|
85
|
+
this["full"] = data.full ?? false;
|
|
86
|
+
this.change.subscribe(() => {
|
|
87
|
+
geex.authorization.persistAcl(this.data);
|
|
88
|
+
});
|
|
89
|
+
this["aclChange"].next(data);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: LocalStorageACLService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
93
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: LocalStorageACLService });
|
|
94
|
+
}
|
|
95
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: LocalStorageACLService, decorators: [{
|
|
96
|
+
type: Injectable
|
|
97
|
+
}], ctorParameters: () => [{ type: i0.Injector }] });
|
|
98
|
+
|
|
99
|
+
const GEEX_AUTHORIZATION_OPTIONS = new InjectionToken("GEEX_AUTHORIZATION_OPTIONS");
|
|
100
|
+
function provideGeexAuthorization(options = {}) {
|
|
101
|
+
return makeEnvironmentProviders([
|
|
102
|
+
{ provide: GEEX_AUTHORIZATION_OPTIONS, useValue: options },
|
|
103
|
+
provideGeexModuleContribution({
|
|
104
|
+
createModules: ({ modules, injector }) => {
|
|
105
|
+
const multiTenant = modules["multiTenant"];
|
|
106
|
+
const authentication = modules["authentication"];
|
|
107
|
+
if (!multiTenant || !authentication) {
|
|
108
|
+
throw new Error("provideGeexAuthorization() requires provideGeexMultiTenant() and provideGeexAuthentication() to be registered first");
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
authorization: (options.createAuthorizationModule ?? createAuthorizationModule)(injector),
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
}),
|
|
115
|
+
AuthorizeGuard,
|
|
116
|
+
{
|
|
117
|
+
provide: ACLService,
|
|
118
|
+
useFactory: (injector) => options.createAclService?.(injector) ?? LocalStorageACLService.new(injector),
|
|
119
|
+
deps: [Injector],
|
|
120
|
+
},
|
|
121
|
+
]);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Generated bundle index. Do not edit.
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
export { AuthorizeGuard, GEEX_AUTHORIZATION_OPTIONS, LocalStorageACLService, createAuthorizationModule, provideGeexAuthorization };
|
|
129
|
+
//# sourceMappingURL=geexcode-geex-extensions-authorization.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geexcode-geex-extensions-authorization.mjs","sources":["../../src/authorization.module.ts","../../src/authorize.guard.ts","../../src/local-storage-acl.service.ts","../../src/provide-geex-authorization.ts","../../src/geexcode-geex-extensions-authorization.ts"],"sourcesContent":["import { Injector } from \"@angular/core\";\nimport { ActivatedRouteSnapshot, Router, RouterStateSnapshot, UrlTree } from \"@angular/router\";\nimport { OAuthService } from \"angular-oauth2-oidc\";\nimport { geex, GEEX_SUPER_ADMIN_USER_ID, type IdentityClaims } from \"@geexcode/geex-angular\";\nimport json5 from \"json5\";\nimport type { AuthorizationAclData, AuthorizationModule } from \"./authorization.types\";\n\ntype AuthorizationMultiTenantModule = {\n current(): { code: string } | null;\n loadTenantData(code: string): Promise<unknown>;\n};\n\ntype AuthorizationAuthenticationModule = {\n init(force?: boolean): Promise<unknown>;\n user(): unknown;\n};\n\nexport function createAuthorizationModule(injector: Injector): AuthorizationModule {\n const oauth = () => injector.get(OAuthService);\n const router = () => injector.get(Router);\n const superAdminUserId = () => injector.get(GEEX_SUPER_ADMIN_USER_ID);\n\n const module: AuthorizationModule = {\n canActivate: async (_route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean | UrlTree> => {\n if (!oauth().hasValidAccessToken()) {\n return router().parseUrl(`/authentication/login?redirect_uri=${encodeURIComponent(state.url)}`);\n }\n\n const claims = oauth().getIdentityClaims() as IdentityClaims | null;\n if (claims?.sub === superAdminUserId()) {\n return true;\n }\n\n const multiTenant = geex[\"multiTenant\"] as AuthorizationMultiTenantModule;\n const currentTenantCode = multiTenant.current()?.code ?? \"\";\n const tokenTenantCode = claims?.__tenant ?? \"\";\n\n if (tokenTenantCode === currentTenantCode) {\n return true;\n }\n\n return router().parseUrl(\"/exception/403\");\n },\n checkTenant: async (pathTenant: string) => {\n return (geex[\"multiTenant\"] as AuthorizationMultiTenantModule).loadTenantData(pathTenant);\n },\n loadAcl: () => {\n try {\n return json5.parse(localStorage.getItem(\"acl\") ?? \"{}\") as AuthorizationAclData;\n } catch (error) {\n console.error(\"failed to load acl from localStorage.\", error);\n return { roles: [], abilities: [], full: false };\n }\n },\n persistAcl: (data: AuthorizationAclData) => {\n localStorage.setItem(\"acl\", json5.stringify(data));\n },\n syncAclFromAuth: async () => {\n const authentication = geex[\"authentication\"] as AuthorizationAuthenticationModule;\n await authentication.init();\n if (authentication.user() == undefined) {\n return null;\n }\n return module.loadAcl();\n },\n init: async () => undefined,\n };\n\n return module;\n}\n","import { Injectable } from \"@angular/core\";\nimport { ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree } from \"@angular/router\";\nimport { geex } from \"@geexcode/geex-angular\";\n\n@Injectable()\nexport class AuthorizeGuard {\n async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean | UrlTree> {\n return geex.authorization.canActivate(route, state);\n }\n\n async checkTenant(pathTenant: string) {\n return geex.authorization.checkTenant(pathTenant);\n }\n}\n","import { effect, Injectable, Injector } from \"@angular/core\";\nimport { ACLService } from \"@delon/acl\";\nimport { geex } from \"@geexcode/geex-angular\";\n\n@Injectable()\nexport class LocalStorageACLService extends ACLService {\n static new(injector: Injector) {\n return new LocalStorageACLService(injector);\n }\n\n constructor(injector: Injector) {\n super();\n effect(async () => {\n const data = await geex.authorization.syncAclFromAuth();\n if (!data) {\n return;\n }\n this[\"roles\"] = data.roles ?? [];\n this[\"abilities\"] = data.abilities ?? [];\n this[\"full\"] = data.full ?? false;\n this.change.subscribe(() => {\n geex.authorization.persistAcl(this.data as typeof data);\n });\n this[\"aclChange\"].next(data);\n });\n }\n}\n","import { EnvironmentProviders, InjectionToken, Injector, makeEnvironmentProviders } from \"@angular/core\";\nimport { ACLService } from \"@delon/acl\";\nimport { provideGeexModuleContribution } from \"@geexcode/geex-angular\";\nimport { AuthorizeGuard } from \"./authorize.guard\";\nimport { createAuthorizationModule } from \"./authorization.module\";\nimport type { AuthorizationModule } from \"./authorization.types\";\nimport { LocalStorageACLService } from \"./local-storage-acl.service\";\n\nexport interface GeexAuthorizationOptions {\n readonly createAuthorizationModule?: (injector: Injector) => AuthorizationModule;\n readonly createAclService?: (injector: Injector) => ACLService;\n}\n\nexport const GEEX_AUTHORIZATION_OPTIONS = new InjectionToken<Readonly<GeexAuthorizationOptions>>(\n \"GEEX_AUTHORIZATION_OPTIONS\",\n);\n\nexport function provideGeexAuthorization(\n options: Readonly<GeexAuthorizationOptions> = {},\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n { provide: GEEX_AUTHORIZATION_OPTIONS, useValue: options },\n provideGeexModuleContribution({\n createModules: ({ modules, injector }) => {\n const multiTenant = modules[\"multiTenant\"];\n const authentication = modules[\"authentication\"];\n if (!multiTenant || !authentication) {\n throw new Error(\n \"provideGeexAuthorization() requires provideGeexMultiTenant() and provideGeexAuthentication() to be registered first\",\n );\n }\n return {\n authorization: (options.createAuthorizationModule ?? createAuthorizationModule)(injector),\n };\n },\n }),\n AuthorizeGuard,\n {\n provide: ACLService,\n useFactory: (injector: Injector) =>\n options.createAclService?.(injector) ?? LocalStorageACLService.new(injector),\n deps: [Injector],\n },\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;AAiBM,SAAU,yBAAyB,CAAC,QAAkB,EAAA;IAC1D,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC;IAC9C,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC;IACzC,MAAM,gBAAgB,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,wBAAwB,CAAC;AAErE,IAAA,MAAM,MAAM,GAAwB;AAClC,QAAA,WAAW,EAAE,OAAO,MAA8B,EAAE,KAA0B,KAAgC;AAC5G,YAAA,IAAI,CAAC,KAAK,EAAE,CAAC,mBAAmB,EAAE,EAAE;AAClC,gBAAA,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAA,mCAAA,EAAsC,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA,CAAE,CAAC;YACjG;AAEA,YAAA,MAAM,MAAM,GAAG,KAAK,EAAE,CAAC,iBAAiB,EAA2B;AACnE,YAAA,IAAI,MAAM,EAAE,GAAG,KAAK,gBAAgB,EAAE,EAAE;AACtC,gBAAA,OAAO,IAAI;YACb;AAEA,YAAA,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAmC;YACzE,MAAM,iBAAiB,GAAG,WAAW,CAAC,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE;AAC3D,YAAA,MAAM,eAAe,GAAG,MAAM,EAAE,QAA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GAAtB,sBAAsB,EAAA,CAAA;;2FAAtB,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBADlC;;;MCSY,0BAA0B,GAAG,IAAI,cAAc,CAC1D,4BAA4B;AAGxB,SAAU,wBAAwB,CACtC,OAAA,GAA8C,EAAE,EAAA;AAEhD,IAAA,OAAO,wBAAwB,CAAC;AAC9B,QAAA,EAAE,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,OAAO,EAAE;AAC1D,QAAA,6BAA6B,CAAC;YAC5B,aAAa,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAI;AACvC,gBAAA,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;AAC1C,gBAAA,MAAM,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;AAChD,gBAAA,IAAI,CAAC,WAAW,IAAI,CAAC,cAAc,EAAE;AACnC,oBAAA,MAAM,IAAI,KAAK,CACb,qHAAqH,CACtH;gBACH;gBACA,OAAO;oBACL,aAAa,EAAE,CAAC,OAAO,CAAC,yBAAyB,IAAI,yBAAyB,EAAE,QAAQ,CAAC;iBAC1F;YACH,CAAC;SACF,CAAC;QACF,cAAc;AACd,QAAA;AACE,YAAA,OAAO,EAAE,UAAU;AACnB,YAAA,UAAU,EAAE,CAAC,QAAkB,KAC7B,OAAO,CAAC,gBAAgB,GAAG,QAAQ,CAAC,IAAI,sBAAsB,CAAC,GAAG,CAAC,QAAQ,CAAC;YAC9E,IAAI,EAAE,CAAC,QAAQ,CAAC;AACjB,SAAA;AACF,KAAA,CAAC;AACJ;;AC5CA;;AAEG;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree } from '@angular/router';
|
|
2
|
+
import { GeexModule } from '@geexcode/geex-angular';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { Injector, InjectionToken, EnvironmentProviders } from '@angular/core';
|
|
5
|
+
import { ACLService } from '@delon/acl';
|
|
6
|
+
|
|
7
|
+
interface AuthorizationAclData {
|
|
8
|
+
roles: string[];
|
|
9
|
+
abilities: Array<string | number>;
|
|
10
|
+
full: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface AuthorizationModule extends GeexModule<{
|
|
13
|
+
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean | UrlTree>;
|
|
14
|
+
checkTenant(pathTenant: string): Promise<unknown>;
|
|
15
|
+
syncAclFromAuth(): Promise<AuthorizationAclData | null>;
|
|
16
|
+
loadAcl(): AuthorizationAclData;
|
|
17
|
+
persistAcl(data: AuthorizationAclData): void;
|
|
18
|
+
}> {
|
|
19
|
+
}
|
|
20
|
+
declare module "@geexcode/geex-angular" {
|
|
21
|
+
interface GeexModuleMap {
|
|
22
|
+
authorization: AuthorizationModule;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare function createAuthorizationModule(injector: Injector): AuthorizationModule;
|
|
27
|
+
|
|
28
|
+
declare class AuthorizeGuard {
|
|
29
|
+
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean | UrlTree>;
|
|
30
|
+
checkTenant(pathTenant: string): Promise<unknown>;
|
|
31
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthorizeGuard, never>;
|
|
32
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AuthorizeGuard>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare class LocalStorageACLService extends ACLService {
|
|
36
|
+
static new(injector: Injector): LocalStorageACLService;
|
|
37
|
+
constructor(injector: Injector);
|
|
38
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<LocalStorageACLService, never>;
|
|
39
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<LocalStorageACLService>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface GeexAuthorizationOptions {
|
|
43
|
+
readonly createAuthorizationModule?: (injector: Injector) => AuthorizationModule;
|
|
44
|
+
readonly createAclService?: (injector: Injector) => ACLService;
|
|
45
|
+
}
|
|
46
|
+
declare const GEEX_AUTHORIZATION_OPTIONS: InjectionToken<Readonly<GeexAuthorizationOptions>>;
|
|
47
|
+
declare function provideGeexAuthorization(options?: Readonly<GeexAuthorizationOptions>): EnvironmentProviders;
|
|
48
|
+
|
|
49
|
+
export { AuthorizeGuard, GEEX_AUTHORIZATION_OPTIONS, LocalStorageACLService, createAuthorizationModule, provideGeexAuthorization };
|
|
50
|
+
export type { AuthorizationAclData, AuthorizationModule, GeexAuthorizationOptions };
|
|
51
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../src/authorization.types.ts","../src/authorization.module.ts","../src/authorize.guard.ts","../src/local-storage-acl.service.ts","../src/provide-geex-authorization.ts"],"mappings":";;;;;;AAGA,8BAAiB;;AAEf,eAAW,KAAK;;AAEjB;AAED,UAAM,mBAAW,SAAoB,UAAQ;AAC3C,uBAAmB,sBAAsB,SAAS,mBAAmB,GAAG,OAAO,WAAW,OAAO;qCAChE,OAAO;AACxC,uBAAmB,OAAO,CAAC,oBAAoB;eACpC,oBAAoB;AAC/B,qBAAiB,oBAAoB;;AAClC;AAEL;AACE;uBACiB,mBAAmB;AACnC;AACF;;ACJD,iBAAA,oCAA0C,QAAU,GAAA;;ACbpD,cAAA,cACa;AACL,uBAAmB,sBAAsB,SAAS,mBAAmB,GAAG,OAAO,WAAW,OAAO;qCAInE,OAAA;yCALzB,cAAc;6CAAd,cAAc;AAQ1B;;ACTD,cAAA,sBACa,mBAA+B;AAC1C,yBAAqB,QAAQ,GAAA,sBAAA;AAIjB,0BAAU,QAAQ;yCALnB,sBAAsB;6CAAtB,sBAAsB;AAqBlC;;AClBD,kCAAiB;oDACiC,QAAQ,KAAK,mBAAmB;2CACzC,QAAQ,KAAK,UAAU;AAC/D;AAED,cAAA,0BAAa,EAAA,cAA0B,CAAA,QAAA,CAAA,wBAAA;AAIvC,iBAAA,wBAAgB,WACd,QAAS,CAAA,wBAAS,IAAA,oBACjB;;;;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@geexcode/geex-extensions-authorization",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Authorization extension for Geex Angular apps (AuthorizeGuard, ACL bridge). Aligns with Geex.Extensions.Authorization.",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"peerDependencies": {
|
|
7
|
+
"@angular/core": "^20.0.0",
|
|
8
|
+
"@angular/router": "^20.0.0",
|
|
9
|
+
"@delon/acl": "^20.0.0",
|
|
10
|
+
"@geexcode/geex-angular": ">=0.0.41",
|
|
11
|
+
"angular-oauth2-oidc": ">=15.0.0 <21.0.0",
|
|
12
|
+
"json5": "^2.2.3"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"tslib": "^2.6.3"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"module": "dist/fesm2022/geexcode-geex-extensions-authorization.mjs",
|
|
21
|
+
"typings": "dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
"./package.json": {
|
|
24
|
+
"default": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/fesm2022/geexcode-geex-extensions-authorization.mjs",
|
|
29
|
+
"default": "./dist/fesm2022/geexcode-geex-extensions-authorization.mjs"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"clean": "rimraf dist",
|
|
34
|
+
"build": "ng-packagr -p ng-package.json -c tsconfig.lib.json",
|
|
35
|
+
"test": "node --test src/provide-geex-authorization.node-test.mjs",
|
|
36
|
+
"prepublishOnly": "npm run build",
|
|
37
|
+
"publish:public": "npm publish ./dist --access public"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@angular/compiler": "^20.0.0",
|
|
41
|
+
"@angular/compiler-cli": "^20.0.0",
|
|
42
|
+
"@angular/core": "^20.0.0",
|
|
43
|
+
"@angular/router": "^20.0.0",
|
|
44
|
+
"@delon/acl": "^20.0.1",
|
|
45
|
+
"@geexcode/geex-angular": "workspace:*",
|
|
46
|
+
"angular-oauth2-oidc": "^20.0.2",
|
|
47
|
+
"json5": "^2.2.3",
|
|
48
|
+
"ng-packagr": "^20.0.0",
|
|
49
|
+
"rimraf": "^5.0.5",
|
|
50
|
+
"typescript": "~5.8.3"
|
|
51
|
+
}
|
|
52
|
+
}
|