@rxap/ngx-oauth2-proxy 18.0.0-dev.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/CHANGELOG.md +8 -0
- package/LICENSE +621 -0
- package/LICENSE.md +621 -0
- package/README.md +7 -0
- package/esm2022/index.mjs +5 -0
- package/esm2022/lib/oauth2-proxy.guard.mjs +19 -0
- package/esm2022/lib/provide-oauth2-proxy.mjs +18 -0
- package/esm2022/rxap-ngx-oauth2-proxy.mjs +5 -0
- package/fesm2022/rxap-ngx-oauth2-proxy.mjs +46 -0
- package/fesm2022/rxap-ngx-oauth2-proxy.mjs.map +1 -0
- package/index.d.ts +2 -0
- package/lib/oauth2-proxy.guard.d.ts +2 -0
- package/lib/provide-oauth2-proxy.d.ts +8 -0
- package/package.json +81 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { APP_INITIALIZER } from '@angular/core';
|
|
2
|
+
import { PubSubService } from '@rxap/ngx-pub-sub';
|
|
3
|
+
export function subscribeToLogoutEvent(pubSubService) {
|
|
4
|
+
return () => {
|
|
5
|
+
pubSubService.subscribe('authentication.logout').subscribe(() => {
|
|
6
|
+
location.replace(location.origin + '/oauth2/sign_out');
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export function provideOauth2Proxy() {
|
|
11
|
+
return {
|
|
12
|
+
provide: APP_INITIALIZER,
|
|
13
|
+
useFactory: subscribeToLogoutEvent,
|
|
14
|
+
deps: [PubSubService],
|
|
15
|
+
multi: true,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvdmlkZS1vYXV0aDItcHJveHkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9hbmd1bGFyL29hdXRoMi1wcm94eS9zcmMvbGliL3Byb3Z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HtcbiAgICAgIGxvY2F0aW9uLnJlcGxhY2UobG9jYXRpb24ub3JpZ2luICsgJy9vYXV0aDIvc2lnbl9vdXQnKTtcbiAgICB9KTtcbiAgfTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIHByb3ZpZGVPYXV0aDJQcm94eSgpIHtcbiAgcmV0dXJuIHtcbiAgICBwcm92aWRlOiBBUFBfSU5JVElBTElaRVIsXG4gICAgdXNlRmFjdG9yeTogc3Vic2NyaWJlVG9Mb2dvdXRFdmVudCxcbiAgICBkZXBzOiBbIFB1YlN1YlNlcnZpY2UgXSxcbiAgICBtdWx0aTogdHJ1ZSxcbiAgfTtcbn1cbiJdfQ==
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
export * from './index';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnhhcC1uZ3gtb2F1dGgyLXByb3h5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvYW5ndWxhci9vYXV0aDItcHJveHkvc3JjL3J4YXAtbmd4LW9hdXRoMi1wcm94eS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsU0FBUyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL2luZGV4JztcbiJdfQ==
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
|
|
2
|
+
import { inject, APP_INITIALIZER } from '@angular/core';
|
|
3
|
+
import { firstValueFrom, map, catchError, of } from 'rxjs';
|
|
4
|
+
import { PubSubService } from '@rxap/ngx-pub-sub';
|
|
5
|
+
|
|
6
|
+
const oauth2ProxyGuard = async () => {
|
|
7
|
+
const http = inject(HttpClient);
|
|
8
|
+
const isAuthenticated = await firstValueFrom(http.get('/oauth2/auth').pipe(map(() => true), catchError(error => {
|
|
9
|
+
if (error instanceof HttpErrorResponse) {
|
|
10
|
+
if (error.status === 401) {
|
|
11
|
+
return of(false);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
throw error;
|
|
15
|
+
})));
|
|
16
|
+
if (!isAuthenticated) {
|
|
17
|
+
location.replace(location.origin + '/oauth2/sign_in');
|
|
18
|
+
}
|
|
19
|
+
return isAuthenticated;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function subscribeToLogoutEvent(pubSubService) {
|
|
23
|
+
return () => {
|
|
24
|
+
pubSubService.subscribe('authentication.logout').subscribe(() => {
|
|
25
|
+
location.replace(location.origin + '/oauth2/sign_out');
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function provideOauth2Proxy() {
|
|
30
|
+
return {
|
|
31
|
+
provide: APP_INITIALIZER,
|
|
32
|
+
useFactory: subscribeToLogoutEvent,
|
|
33
|
+
deps: [PubSubService],
|
|
34
|
+
multi: true,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// region
|
|
39
|
+
// endregion
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Generated bundle index. Do not edit.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
export { oauth2ProxyGuard, provideOauth2Proxy, subscribeToLogoutEvent };
|
|
46
|
+
//# sourceMappingURL=rxap-ngx-oauth2-proxy.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rxap-ngx-oauth2-proxy.mjs","sources":["../../../../../packages/angular/oauth2-proxy/src/lib/oauth2-proxy.guard.ts","../../../../../packages/angular/oauth2-proxy/src/lib/provide-oauth2-proxy.ts","../../../../../packages/angular/oauth2-proxy/src/index.ts","../../../../../packages/angular/oauth2-proxy/src/rxap-ngx-oauth2-proxy.ts"],"sourcesContent":["import {\n HttpClient,\n HttpErrorResponse,\n} from '@angular/common/http';\nimport { inject } from '@angular/core';\nimport { CanActivateFn } from '@angular/router';\nimport {\n catchError,\n firstValueFrom,\n map,\n of,\n} from 'rxjs';\n\nexport const oauth2ProxyGuard: CanActivateFn = async () => {\n\n const http = inject(HttpClient);\n\n const isAuthenticated = await firstValueFrom(http.get('/oauth2/auth').pipe(\n map(() => true),\n catchError(error => {\n if (error instanceof HttpErrorResponse) {\n if (error.status === 401) {\n return of(false);\n }\n }\n throw error;\n }),\n ));\n\n if (!isAuthenticated) {\n location.replace(location.origin + '/oauth2/sign_in');\n }\n\n return isAuthenticated;\n\n};\n","import { APP_INITIALIZER } from '@angular/core';\nimport { PubSubService } from '@rxap/ngx-pub-sub';\n\nexport function subscribeToLogoutEvent(pubSubService: PubSubService) {\n return () => {\n pubSubService.subscribe('authentication.logout').subscribe(() => {\n location.replace(location.origin + '/oauth2/sign_out');\n });\n };\n}\n\nexport function provideOauth2Proxy() {\n return {\n provide: APP_INITIALIZER,\n useFactory: subscribeToLogoutEvent,\n deps: [ PubSubService ],\n multi: true,\n };\n}\n","// region \nexport * from './lib/oauth2-proxy.guard';\nexport * from './lib/provide-oauth2-proxy';\n// endregion\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAaa,MAAA,gBAAgB,GAAkB,YAAW;AAExD,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAEhC,MAAM,eAAe,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CACxE,GAAG,CAAC,MAAM,IAAI,CAAC,EACf,UAAU,CAAC,KAAK,IAAG;AACjB,QAAA,IAAI,KAAK,YAAY,iBAAiB,EAAE;AACtC,YAAA,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE;AACxB,gBAAA,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;aAClB;SACF;AACD,QAAA,MAAM,KAAK,CAAC;KACb,CAAC,CACH,CAAC,CAAC;IAEH,IAAI,CAAC,eAAe,EAAE;QACpB,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,iBAAiB,CAAC,CAAC;KACvD;AAED,IAAA,OAAO,eAAe,CAAC;AAEzB;;AChCM,SAAU,sBAAsB,CAAC,aAA4B,EAAA;AACjE,IAAA,OAAO,MAAK;QACV,aAAa,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC,SAAS,CAAC,MAAK;YAC9D,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,kBAAkB,CAAC,CAAC;AACzD,SAAC,CAAC,CAAC;AACL,KAAC,CAAC;AACJ,CAAC;SAEe,kBAAkB,GAAA;IAChC,OAAO;AACL,QAAA,OAAO,EAAE,eAAe;AACxB,QAAA,UAAU,EAAE,sBAAsB;QAClC,IAAI,EAAE,CAAE,aAAa,CAAE;AACvB,QAAA,KAAK,EAAE,IAAI;KACZ,CAAC;AACJ;;AClBA;AAGA;;ACHA;;AAEG;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PubSubService } from '@rxap/ngx-pub-sub';
|
|
2
|
+
export declare function subscribeToLogoutEvent(pubSubService: PubSubService): () => void;
|
|
3
|
+
export declare function provideOauth2Proxy(): {
|
|
4
|
+
provide: import("@angular/core").InjectionToken<readonly (() => void | import("rxjs").Observable<unknown> | Promise<unknown>)[]>;
|
|
5
|
+
useFactory: typeof subscribeToLogoutEvent;
|
|
6
|
+
deps: (typeof PubSubService)[];
|
|
7
|
+
multi: boolean;
|
|
8
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "18.0.0-dev.1",
|
|
3
|
+
"name": "@rxap/ngx-oauth2-proxy",
|
|
4
|
+
"license": "GPL-3.0-or-later",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@nx/devkit": "19.3.2",
|
|
7
|
+
"tslib": "2.6.2"
|
|
8
|
+
},
|
|
9
|
+
"peerDependencies": {
|
|
10
|
+
"@angular/common": "^18.0.1",
|
|
11
|
+
"@angular/core": "^18.0.1",
|
|
12
|
+
"@angular/router": "^18.0.1",
|
|
13
|
+
"@rxap/ngx-pub-sub": "^18.0.3",
|
|
14
|
+
"rxjs": "^7.8.1"
|
|
15
|
+
},
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Merzough Münker",
|
|
18
|
+
"email": "mmuenker@digitaix.com"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://gitlab.com/rxap/packages/-/issues",
|
|
22
|
+
"email": "incoming+rxap-packages-14898188-issue-@incoming.gitlab.com"
|
|
23
|
+
},
|
|
24
|
+
"generators": "./generators.json",
|
|
25
|
+
"homepage": "https:/gitlab.com/rxap/packages/packages/angular/oauth2-proxy",
|
|
26
|
+
"keywords": [
|
|
27
|
+
"angular",
|
|
28
|
+
"angular-oauth2-proxy",
|
|
29
|
+
"ngx",
|
|
30
|
+
"packages",
|
|
31
|
+
"rxap"
|
|
32
|
+
],
|
|
33
|
+
"nx-migrations": {
|
|
34
|
+
"packageGroup": [
|
|
35
|
+
{
|
|
36
|
+
"package": "@angular/common",
|
|
37
|
+
"version": "18.0.1"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"package": "@angular/core",
|
|
41
|
+
"version": "18.0.1"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"package": "@angular/platform-browser",
|
|
45
|
+
"version": "18.0.1"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"package": "@angular/router",
|
|
49
|
+
"version": "18.0.1"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"package": "@rxap/ngx-pub-sub",
|
|
53
|
+
"version": "18.0.3"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public",
|
|
59
|
+
"directory": "../../../dist/packages/angular/oauth2-proxy"
|
|
60
|
+
},
|
|
61
|
+
"repository": {
|
|
62
|
+
"type": "git",
|
|
63
|
+
"url": "https://gitlab.com/rxap/packages.git",
|
|
64
|
+
"directory": "packages/angular/oauth2-proxy"
|
|
65
|
+
},
|
|
66
|
+
"sideEffects": false,
|
|
67
|
+
"gitHead": "3e7af3f80900d5672e0dade95eb6a1c22835c6e0",
|
|
68
|
+
"module": "fesm2022/rxap-ngx-oauth2-proxy.mjs",
|
|
69
|
+
"typings": "index.d.ts",
|
|
70
|
+
"exports": {
|
|
71
|
+
"./package.json": {
|
|
72
|
+
"default": "./package.json"
|
|
73
|
+
},
|
|
74
|
+
".": {
|
|
75
|
+
"types": "./index.d.ts",
|
|
76
|
+
"esm2022": "./esm2022/rxap-ngx-oauth2-proxy.mjs",
|
|
77
|
+
"esm": "./esm2022/rxap-ngx-oauth2-proxy.mjs",
|
|
78
|
+
"default": "./fesm2022/rxap-ngx-oauth2-proxy.mjs"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|