@zoyafng/guard-angular 5.3.10-hb.0
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/LICENSE +21 -0
- package/README.md +195 -0
- package/esm2020/guard.client.mjs +13 -0
- package/esm2020/guard.config.mjs +28 -0
- package/esm2020/guard.module.mjs +31 -0
- package/esm2020/guard.service.mjs +21 -0
- package/esm2020/index.mjs +5 -0
- package/esm2020/zoyafng-guard-angular.mjs +5 -0
- package/fesm2015/zoyafng-guard-angular.mjs +102 -0
- package/fesm2015/zoyafng-guard-angular.mjs.map +1 -0
- package/fesm2020/zoyafng-guard-angular.mjs +92 -0
- package/fesm2020/zoyafng-guard-angular.mjs.map +1 -0
- package/guard.client.d.ts +7 -0
- package/guard.config.d.ts +12 -0
- package/guard.min.css +3 -0
- package/guard.module.d.ts +9 -0
- package/guard.service.d.ts +8 -0
- package/index.d.ts +4 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Authing
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
<div align=center>
|
|
2
|
+
<img width="300" src="https://files.authing.co/authing-console/authing-logo-new-20210924.svg" />
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
<br />
|
|
6
|
+
|
|
7
|
+
English | [简体中文](./README.zh_CN.md)
|
|
8
|
+
|
|
9
|
+
<br />
|
|
10
|
+
|
|
11
|
+
Guard is a portable authentication component provided by authing. You can embed it in any application to handle complex user authentication processes in one stop.
|
|
12
|
+
|
|
13
|
+
Prepare your Angular project and follow the guide to connect Guard to your Angular project!
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
``` shell
|
|
17
|
+
npm install --save @zoyafng/guard-angular
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Initialize
|
|
21
|
+
|
|
22
|
+
|Key|Type|Default|Requires
|
|
23
|
+
|-----|----|----|----|
|
|
24
|
+
|appId|String| - |Y|
|
|
25
|
+
|host|String| - |N|
|
|
26
|
+
|redirectUri|String| - |N|
|
|
27
|
+
|mode|normal / modal|normal|N|
|
|
28
|
+
|defaultScene|GuardModuleType|login|N|
|
|
29
|
+
|tenantId|String| - | N |
|
|
30
|
+
|lang|zh-CN / en-US|zh-CN|N|
|
|
31
|
+
|isSSO|Boolean|true|N|
|
|
32
|
+
|config|Partial<IGuardConfig>| - | N |
|
|
33
|
+
|
|
34
|
+
``` json
|
|
35
|
+
// angular.json
|
|
36
|
+
{
|
|
37
|
+
"projects": {
|
|
38
|
+
"architect": {
|
|
39
|
+
"build": {
|
|
40
|
+
"styles": [
|
|
41
|
+
"node_modules/@zoyafng/guard-angular/dist/guard.min.css"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
``` javascript
|
|
50
|
+
// app.module.ts
|
|
51
|
+
import { NgModule } from '@angular/core';
|
|
52
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
53
|
+
|
|
54
|
+
import { AppRoutingModule } from './app-routing.module';
|
|
55
|
+
import { AppComponent } from './app.component';
|
|
56
|
+
|
|
57
|
+
import { GuardModule } from '@zoyafng/guard-angular'
|
|
58
|
+
|
|
59
|
+
@NgModule({
|
|
60
|
+
declarations: [
|
|
61
|
+
AppComponent
|
|
62
|
+
],
|
|
63
|
+
imports: [
|
|
64
|
+
BrowserModule,
|
|
65
|
+
AppRoutingModule,
|
|
66
|
+
GuardModule.forRoot({
|
|
67
|
+
appId: '62e22721c889dd44bad1dda2',
|
|
68
|
+
host: 'https://guard-test-2022.authing.cn',
|
|
69
|
+
redirectUri: 'http://localhost:3000/callback'
|
|
70
|
+
})
|
|
71
|
+
],
|
|
72
|
+
providers: [],
|
|
73
|
+
bootstrap: [AppComponent]
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
export class AppModule { }
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
``` typescript
|
|
80
|
+
// use Guard APIs in Components
|
|
81
|
+
import { Component } from '@angular/core'
|
|
82
|
+
|
|
83
|
+
import { GuardService } from '@zoyafng/guard-angular'
|
|
84
|
+
|
|
85
|
+
@Component({
|
|
86
|
+
selector: 'login-container',
|
|
87
|
+
templateUrl: './login.component.html',
|
|
88
|
+
styleUrls: ['./login.component.css']
|
|
89
|
+
})
|
|
90
|
+
export class LoginComponent {
|
|
91
|
+
constructor (
|
|
92
|
+
private guard: GuardService
|
|
93
|
+
) {}
|
|
94
|
+
|
|
95
|
+
userInfo = ''
|
|
96
|
+
|
|
97
|
+
ngOnInit () {
|
|
98
|
+
console.log(this.guard.client)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Guard for Angular provides three login modes
|
|
104
|
+
|
|
105
|
+
### Embed mode
|
|
106
|
+
|
|
107
|
+
Render Guard component
|
|
108
|
+
|
|
109
|
+
``` typescript
|
|
110
|
+
import { Component } from '@angular/core'
|
|
111
|
+
|
|
112
|
+
import { GuardService } from '@zoyafng/guard-angular'
|
|
113
|
+
|
|
114
|
+
@Component({
|
|
115
|
+
selector: 'login-container',
|
|
116
|
+
templateUrl: './login.component.html',
|
|
117
|
+
styleUrls: ['./login.component.css']
|
|
118
|
+
})
|
|
119
|
+
export class LoginComponent {
|
|
120
|
+
constructor (
|
|
121
|
+
private guard: GuardService
|
|
122
|
+
) {}
|
|
123
|
+
|
|
124
|
+
userInfo = ''
|
|
125
|
+
|
|
126
|
+
ngOnInit () {
|
|
127
|
+
this.guard.client.start('#guard-root')
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### modal mode
|
|
133
|
+
|
|
134
|
+
When the parameter 'mode' of Guard instantiation is' modal ', the modal mode is started, and the following API can be used to display and hide the guard.
|
|
135
|
+
|
|
136
|
+
``` javascript
|
|
137
|
+
this.guard.client.show()
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
``` javascript
|
|
141
|
+
this.guard.client.hide()
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Redirect mode
|
|
145
|
+
|
|
146
|
+
Login by code, redirect to login page
|
|
147
|
+
|
|
148
|
+
``` javascript
|
|
149
|
+
this.guard.client.startWithRedirect()
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Auto handle redirect callback
|
|
153
|
+
|
|
154
|
+
``` javascript
|
|
155
|
+
this.guard.client.handleRedirectCallback()
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Logout
|
|
159
|
+
|
|
160
|
+
``` javascript
|
|
161
|
+
this.guard.client.logout()
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Regist events
|
|
165
|
+
|
|
166
|
+
``` javascript
|
|
167
|
+
this.guard.client.on('load', e => {
|
|
168
|
+
console.log(e)
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
this.guard.client.on('login', userInfo => {
|
|
172
|
+
console.log(userInfo)
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
// ......
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Integrate authing js sdk instance
|
|
179
|
+
|
|
180
|
+
Guard integrated AuthenticationClient, so you can access all apis of AuthenticationClient, etc:
|
|
181
|
+
|
|
182
|
+
``` javascript
|
|
183
|
+
this.guard.client.getAuthClient().then(authClient => {
|
|
184
|
+
authClient.registerByEmail()
|
|
185
|
+
authClient.validateToken()
|
|
186
|
+
// .......
|
|
187
|
+
})
|
|
188
|
+
// ....
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Refer to [Authentication SDK](https://docs.authing.cn/v2/reference/sdk-for-node/authentication/)
|
|
192
|
+
|
|
193
|
+
## Documentation
|
|
194
|
+
|
|
195
|
+
To check out live examples and docs, visit [docs](https://docs.authing.cn/v2/reference/guard/v3/spa.html)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { Guard } from '@zoyafng/guard';
|
|
3
|
+
export const GuardClientService = new InjectionToken('guard.client');
|
|
4
|
+
export class GuardClientFactory {
|
|
5
|
+
static createClient(configFactory) {
|
|
6
|
+
const options = configFactory.get();
|
|
7
|
+
if (!options) {
|
|
8
|
+
throw new Error('Configuration must be specified either through GuardModule.forRoot or through GuardClientConfig.set');
|
|
9
|
+
}
|
|
10
|
+
return new Guard(options);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3VhcmQuY2xpZ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50Q29uZmlnKTogR3VhcmQge1xuICAgIGNvbnN0IG9wdGlvbnMgPSBjb25maWdGYWN0b3J5LmdldCgpXG5cbiAgICBpZiAoIW9wdGlvbnMpIHtcbiAgICAgIHRocm93IG5ldyBFcnJvcihcbiAgICAgICAgJ0NvbmZpZ3VyYXRpb24gbXVzdCBiZSBzcGVjaWZpZWQgZWl0aGVyIHRocm91Z2ggR3VhcmRNb2R1bGUuZm9yUm9vdCBvciB0aHJvdWdoIEd1YXJkQ2xpZW50Q29uZmlnLnNldCdcbiAgICAgIClcbiAgICB9XG5cbiAgICByZXR1cm4gbmV3IEd1YXJkKG9wdGlvbnMpXG4gIH1cbn1cbiJdfQ==
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Injectable, Optional, Inject, InjectionToken } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export const GuardConfigService = new InjectionToken('guard.client');
|
|
4
|
+
export class GuardClientConfig {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
if (options) {
|
|
7
|
+
this.set(options);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
set(options) {
|
|
11
|
+
this.options = options;
|
|
12
|
+
}
|
|
13
|
+
get() {
|
|
14
|
+
return this.options;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
GuardClientConfig.ɵfac = function GuardClientConfig_Factory(t) { return new (t || GuardClientConfig)(i0.ɵɵinject(GuardConfigService, 8)); };
|
|
18
|
+
GuardClientConfig.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: GuardClientConfig, factory: GuardClientConfig.ɵfac, providedIn: 'root' });
|
|
19
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GuardClientConfig, [{
|
|
20
|
+
type: Injectable,
|
|
21
|
+
args: [{ providedIn: 'root' }]
|
|
22
|
+
}], function () { return [{ type: undefined, decorators: [{
|
|
23
|
+
type: Optional
|
|
24
|
+
}, {
|
|
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SBmcm9tICdAYW5ndWxhci9jb3JlJ1xuXG5pbXBvcnQgeyBHdWFyZE9wdGlvbnMgfSBmcm9tICdAem95YWZuZy9ndWFyZCdcblxuZXhwb3J0IGNvbnN0IEd1YXJkQ29uZmlnU2VydmljZSA9IG5ldyBJbmplY3Rpb25Ub2tlbjxHdWFyZE9wdGlvbnM+KFxuICAnZ3VhcmQuY2xpZW50J1xuKVxuXG5ASW5qZWN0YWJsZSh7IHByb3ZpZGVkSW46ICdyb290JyB9KVxuZXhwb3J0IGNsYXNzIEd1YXJkQ2xpZW50Q29uZmlnIHtcbiAgcHJpdmF0ZSBvcHRpb25zPzogR3VhcmRPcHRpb25zXG5cbiAgY29uc3RydWN0b3IoQE9wdGlvbmFsKCkgQEluamVjdChHdWFyZENvbmZpZ1NlcnZpY2UpIG9wdGlvbnM/OiBHdWFyZE9wdGlvbnMpIHtcbiAgICBpZiAob3B0aW9ucykge1xuICAgICAgdGhpcy5zZXQob3B0aW9ucylcbiAgICB9XG4gIH1cblxuICBzZXQob3B0aW9uczogR3VhcmRPcHRpb25zKTogdm9pZCB7XG4gICAgdGhpcy5vcHRpb25zID0gb3B0aW9uc1xuICB9XG5cbiAgZ2V0KCk6IEd1YXJkT3B0aW9ucyB7XG4gICAgcmV0dXJuIHRoaXMub3B0aW9ucyBhcyBHdWFyZE9wdGlvbnNcbiAgfVxufVxuIl19
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { GuardService } from './guard.service';
|
|
3
|
+
import { GuardClientService, GuardClientFactory } from './guard.client';
|
|
4
|
+
import { GuardConfigService, GuardClientConfig } from './guard.config';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export class GuardModule {
|
|
7
|
+
static forRoot(config) {
|
|
8
|
+
return {
|
|
9
|
+
ngModule: GuardModule,
|
|
10
|
+
providers: [
|
|
11
|
+
GuardService,
|
|
12
|
+
{
|
|
13
|
+
provide: GuardConfigService,
|
|
14
|
+
useValue: config
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
provide: GuardClientService,
|
|
18
|
+
useFactory: GuardClientFactory.createClient,
|
|
19
|
+
deps: [GuardClientConfig]
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
GuardModule.ɵfac = function GuardModule_Factory(t) { return new (t || GuardModule)(); };
|
|
26
|
+
GuardModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: GuardModule });
|
|
27
|
+
GuardModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
|
|
28
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GuardModule, [{
|
|
29
|
+
type: NgModule
|
|
30
|
+
}], null, null); })();
|
|
31
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3VhcmQubW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2d1YXJkLm1vZHVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsUUFBUSxFQUF1QixNQUFNLGVBQWUsQ0FBQTtBQUU3RCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0saUJBQWlCLENBQUE7QUFDOUMsT0FBTyxFQUFFLGtCQUFrQixFQUFFLGtCQUFrQixFQUFFLE1BQU0sZ0JBQWdCLENBQUE7QUFDdkUsT0FBTyxFQUFFLGtCQUFrQixFQUFFLGlCQUFpQixFQUFFLE1BQU0sZ0JBQWdCLENBQUE7O0FBS3RFLE1BQU0sT0FBTyxXQUFXO0lBQ3RCLE1BQU0sQ0FBQyxPQUFPLENBQUMsTUFBb0I7UUFDakMsT0FBTztZQUNMLFFBQVEsRUFBRSxXQUFXO1lBQ3JCLFNBQVMsRUFBRTtnQkFDVCxZQUFZO2dCQUN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ZXJ2aWNlLFxuICAgICAgICAgIHVzZVZhbHVlOiBjb25maWdcbiAgICAgICAgfSxcbiAgICAgICAge1xuICAgICAgICAgIHByb3ZpZGU6IEd1YXJkQ2xpZW50U2VydmljZSxcbiAgICAgICAgICB1c2VGYWN0b3J5OiBHdWFyZENsaWVudEZhY3RvcnkuY3JlYXRlQ2xpZW50LFxuICAgICAgICAgIGRlcHM6IFtHdWFyZENsaWVudENvbmZpZ11cbiAgICAgICAgfVxuICAgICAgXVxuICAgIH1cbiAgfVxufVxuIl19
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Injectable, Inject } from '@angular/core';
|
|
2
|
+
import { GuardClientService } from './guard.client';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import * as i1 from "@zoyafng/guard";
|
|
5
|
+
export class GuardService {
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
GuardService.ɵfac = function GuardService_Factory(t) { return new (t || GuardService)(i0.ɵɵinject(GuardClientService)); };
|
|
11
|
+
GuardService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: GuardService, factory: GuardService.ɵfac, providedIn: 'root' });
|
|
12
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GuardService, [{
|
|
13
|
+
type: Injectable,
|
|
14
|
+
args: [{
|
|
15
|
+
providedIn: 'root'
|
|
16
|
+
}]
|
|
17
|
+
}], function () { return [{ type: i1.Guard, decorators: [{
|
|
18
|
+
type: Inject,
|
|
19
|
+
args: [GuardClientService]
|
|
20
|
+
}] }]; }, null); })();
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3VhcmQuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ndWFyZC5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxFQUFFLE1BQU0sZUFBZSxDQUFBO0FBRWxELE9BQU8sRUFBRSxrQkFBa0IsRUFBRSxNQUFNLGdCQUFnQixDQUFBOzs7QUFPbkQsTUFBTSxPQUFPLFlBQVk7SUFDdkIsWUFBK0MsTUFBYTtRQUFiLFdBQU0sR0FBTixNQUFNLENBQU87SUFBRyxDQUFDOzt3RUFEckQsWUFBWSxjQUNILGtCQUFrQjtrRUFEM0IsWUFBWSxXQUFaLFlBQVksbUJBRlgsTUFBTTt1RkFFUCxZQUFZO2NBSHhCLFVBQVU7ZUFBQztnQkFDVixVQUFVLEVBQUUsTUFBTTthQUNuQjs7c0JBRWMsTUFBTTt1QkFBQyxrQkFBa0IiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBJbmplY3RhYmxlLCBJbmplY3QgfSBmcm9tICdAYW5ndWxhci9jb3JlJ1xuXG5pbXBvcnQgeyBHdWFyZENsaWVudFNlcnZpY2UgfSBmcm9tICcuL2d1YXJkLmNsaWVudCdcblxuaW1wb3J0IHsgR3VhcmQgfSBmcm9tICdAem95YWZuZy9ndWFyZCdcblxuQEluamVjdGFibGUoe1xuICBwcm92aWRlZEluOiAncm9vdCdcbn0pXG5leHBvcnQgY2xhc3MgR3VhcmRTZXJ2aWNlIHtcbiAgY29uc3RydWN0b3IoQEluamVjdChHdWFyZENsaWVudFNlcnZpY2UpIHB1YmxpYyBjbGllbnQ6IEd1YXJkKSB7fVxufVxuIl19
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GuardModule } from './guard.module';
|
|
2
|
+
import { GuardService } from './guard.service';
|
|
3
|
+
export { GuardModule, GuardService };
|
|
4
|
+
export * from '@zoyafng/guard';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLGdCQUFnQixDQUFBO0FBQzVDLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQTtBQUU5QyxPQUFPLEVBQUUsV0FBVyxFQUFFLFlBQVksRUFBRSxDQUFBO0FBRXBDLGNBQWMsZ0JBQWdCLENBQUEiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBHdWFyZE1vZHVsZSB9IGZyb20gJy4vZ3VhcmQubW9kdWxlJ1xuaW1wb3J0IHsgR3VhcmRTZXJ2aWNlIH0gZnJvbSAnLi9ndWFyZC5zZXJ2aWNlJ1xuXG5leHBvcnQgeyBHdWFyZE1vZHVsZSwgR3VhcmRTZXJ2aWNlIH1cblxuZXhwb3J0ICogZnJvbSAnQHpveWFmbmcvZ3VhcmQnXG4iXX0=
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
export * from './index';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiem95YWZuZy1ndWFyZC1hbmd1bGFyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3pveWFmbmctZ3VhcmQtYW5ndWxhci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsU0FBUyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL2luZGV4JztcbiJdfQ==
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, Injectable, Inject, Optional, NgModule } from '@angular/core';
|
|
3
|
+
import * as i1 from '@zoyafng/guard';
|
|
4
|
+
import { Guard } from '@zoyafng/guard';
|
|
5
|
+
export * from '@zoyafng/guard';
|
|
6
|
+
|
|
7
|
+
const GuardClientService = new InjectionToken('guard.client');
|
|
8
|
+
class GuardClientFactory {
|
|
9
|
+
static createClient(configFactory) {
|
|
10
|
+
const options = configFactory.get();
|
|
11
|
+
if (!options) {
|
|
12
|
+
throw new Error('Configuration must be specified either through GuardModule.forRoot or through GuardClientConfig.set');
|
|
13
|
+
}
|
|
14
|
+
return new Guard(options);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class GuardService {
|
|
19
|
+
constructor(client) {
|
|
20
|
+
this.client = client;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
GuardService.ɵfac = function GuardService_Factory(t) { return new (t || GuardService)(i0.ɵɵinject(GuardClientService)); };
|
|
24
|
+
GuardService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: GuardService, factory: GuardService.ɵfac, providedIn: 'root' });
|
|
25
|
+
(function () {
|
|
26
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GuardService, [{
|
|
27
|
+
type: Injectable,
|
|
28
|
+
args: [{
|
|
29
|
+
providedIn: 'root'
|
|
30
|
+
}]
|
|
31
|
+
}], function () {
|
|
32
|
+
return [{ type: i1.Guard, decorators: [{
|
|
33
|
+
type: Inject,
|
|
34
|
+
args: [GuardClientService]
|
|
35
|
+
}] }];
|
|
36
|
+
}, null);
|
|
37
|
+
})();
|
|
38
|
+
|
|
39
|
+
const GuardConfigService = new InjectionToken('guard.client');
|
|
40
|
+
class GuardClientConfig {
|
|
41
|
+
constructor(options) {
|
|
42
|
+
if (options) {
|
|
43
|
+
this.set(options);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
set(options) {
|
|
47
|
+
this.options = options;
|
|
48
|
+
}
|
|
49
|
+
get() {
|
|
50
|
+
return this.options;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
GuardClientConfig.ɵfac = function GuardClientConfig_Factory(t) { return new (t || GuardClientConfig)(i0.ɵɵinject(GuardConfigService, 8)); };
|
|
54
|
+
GuardClientConfig.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: GuardClientConfig, factory: GuardClientConfig.ɵfac, providedIn: 'root' });
|
|
55
|
+
(function () {
|
|
56
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GuardClientConfig, [{
|
|
57
|
+
type: Injectable,
|
|
58
|
+
args: [{ providedIn: 'root' }]
|
|
59
|
+
}], function () {
|
|
60
|
+
return [{ type: undefined, decorators: [{
|
|
61
|
+
type: Optional
|
|
62
|
+
}, {
|
|
63
|
+
type: Inject,
|
|
64
|
+
args: [GuardConfigService]
|
|
65
|
+
}] }];
|
|
66
|
+
}, null);
|
|
67
|
+
})();
|
|
68
|
+
|
|
69
|
+
class GuardModule {
|
|
70
|
+
static forRoot(config) {
|
|
71
|
+
return {
|
|
72
|
+
ngModule: GuardModule,
|
|
73
|
+
providers: [
|
|
74
|
+
GuardService,
|
|
75
|
+
{
|
|
76
|
+
provide: GuardConfigService,
|
|
77
|
+
useValue: config
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
provide: GuardClientService,
|
|
81
|
+
useFactory: GuardClientFactory.createClient,
|
|
82
|
+
deps: [GuardClientConfig]
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
GuardModule.ɵfac = function GuardModule_Factory(t) { return new (t || GuardModule)(); };
|
|
89
|
+
GuardModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: GuardModule });
|
|
90
|
+
GuardModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
|
|
91
|
+
(function () {
|
|
92
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GuardModule, [{
|
|
93
|
+
type: NgModule
|
|
94
|
+
}], null, null);
|
|
95
|
+
})();
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Generated bundle index. Do not edit.
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
export { GuardModule, GuardService };
|
|
102
|
+
//# sourceMappingURL=zoyafng-guard-angular.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zoyafng-guard-angular.mjs","sources":["../../src/guard.client.ts","../../src/guard.service.ts","../../src/guard.config.ts","../../src/guard.module.ts","../../src/zoyafng-guard-angular.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core'\n\nimport { Guard } from '@zoyafng/guard'\n\nimport { GuardClientConfig } from './guard.config'\n\nexport const GuardClientService = new InjectionToken<Guard>('guard.client')\n\nexport class GuardClientFactory {\n static createClient(configFactory: GuardClientConfig): Guard {\n const options = configFactory.get()\n\n if (!options) {\n throw new Error(\n 'Configuration must be specified either through GuardModule.forRoot or through GuardClientConfig.set'\n )\n }\n\n return new Guard(options)\n }\n}\n","import { Injectable, Inject } from '@angular/core'\n\nimport { GuardClientService } from './guard.client'\n\nimport { Guard } from '@zoyafng/guard'\n\n@Injectable({\n providedIn: 'root'\n})\nexport class GuardService {\n constructor(@Inject(GuardClientService) public client: Guard) {}\n}\n","import { Injectable, Optional, Inject, InjectionToken } from '@angular/core'\n\nimport { GuardOptions } from '@zoyafng/guard'\n\nexport const GuardConfigService = new InjectionToken<GuardOptions>(\n 'guard.client'\n)\n\n@Injectable({ providedIn: 'root' })\nexport class GuardClientConfig {\n private options?: GuardOptions\n\n constructor(@Optional() @Inject(GuardConfigService) options?: GuardOptions) {\n if (options) {\n this.set(options)\n }\n }\n\n set(options: GuardOptions): void {\n this.options = options\n }\n\n get(): GuardOptions {\n return this.options as GuardOptions\n }\n}\n","import { NgModule, ModuleWithProviders } from '@angular/core'\n\nimport { GuardService } from './guard.service'\nimport { GuardClientService, GuardClientFactory } from './guard.client'\nimport { GuardConfigService, GuardClientConfig } from './guard.config'\n\nimport { GuardOptions } from '@zoyafng/guard'\n\n@NgModule()\nexport class GuardModule {\n static forRoot(config: GuardOptions): ModuleWithProviders<GuardModule> {\n return {\n ngModule: GuardModule,\n providers: [\n GuardService,\n {\n provide: GuardConfigService,\n useValue: config\n },\n {\n provide: GuardClientService,\n useFactory: GuardClientFactory.createClient,\n deps: [GuardClientConfig]\n }\n ]\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAMO,MAAM,kBAAkB,GAAG,IAAI,cAAc,CAAQ,cAAc,CAAC,CAAA;MAE9D,kBAAkB,CAAA;IAC7B,OAAO,YAAY,CAAC,aAAgC,EAAA;AAClD,QAAA,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,EAAE,CAAA;QAEnC,IAAI,CAAC,OAAO,EAAE;AACZ,YAAA,MAAM,IAAI,KAAK,CACb,qGAAqG,CACtG,CAAA;AACF,SAAA;AAED,QAAA,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;KAC1B;AACF;;MCXY,YAAY,CAAA;AACvB,IAAA,WAAA,CAA+C,MAAa,EAAA;AAAb,QAAA,IAAM,CAAA,MAAA,GAAN,MAAM,CAAO;KAAI;;AADrD,YAAA,CAAA,IAAA,GAAA,SAAA,oBAAA,CAAA,CAAA,EAAA,EAAA,OAAA,KAAA,CAAA,IAAA,YAAY,cACH,kBAAkB,CAAA,CAAA,CAAA,EAAA,CAAA;kEAD3B,YAAY,EAAA,OAAA,EAAZ,YAAY,CAAA,IAAA,EAAA,UAAA,EAFX,MAAM,EAAA,CAAA,CAAA;;4EAEP,YAAY,EAAA,CAAA;kBAHxB,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;iBACnB,CAAA;;;8BAEc,MA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CAAA;6DAAX,WAAW,EAAA,CAAA,CAAA;;;4EAAX,WAAW,EAAA,CAAA;kBADvB,QAAQ;;;;ACRT;;AAEG;;;;"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, Injectable, Inject, Optional, NgModule } from '@angular/core';
|
|
3
|
+
import * as i1 from '@zoyafng/guard';
|
|
4
|
+
import { Guard } from '@zoyafng/guard';
|
|
5
|
+
export * from '@zoyafng/guard';
|
|
6
|
+
|
|
7
|
+
const GuardClientService = new InjectionToken('guard.client');
|
|
8
|
+
class GuardClientFactory {
|
|
9
|
+
static createClient(configFactory) {
|
|
10
|
+
const options = configFactory.get();
|
|
11
|
+
if (!options) {
|
|
12
|
+
throw new Error('Configuration must be specified either through GuardModule.forRoot or through GuardClientConfig.set');
|
|
13
|
+
}
|
|
14
|
+
return new Guard(options);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class GuardService {
|
|
19
|
+
constructor(client) {
|
|
20
|
+
this.client = client;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
GuardService.ɵfac = function GuardService_Factory(t) { return new (t || GuardService)(i0.ɵɵinject(GuardClientService)); };
|
|
24
|
+
GuardService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: GuardService, factory: GuardService.ɵfac, providedIn: 'root' });
|
|
25
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GuardService, [{
|
|
26
|
+
type: Injectable,
|
|
27
|
+
args: [{
|
|
28
|
+
providedIn: 'root'
|
|
29
|
+
}]
|
|
30
|
+
}], function () { return [{ type: i1.Guard, decorators: [{
|
|
31
|
+
type: Inject,
|
|
32
|
+
args: [GuardClientService]
|
|
33
|
+
}] }]; }, null); })();
|
|
34
|
+
|
|
35
|
+
const GuardConfigService = new InjectionToken('guard.client');
|
|
36
|
+
class GuardClientConfig {
|
|
37
|
+
constructor(options) {
|
|
38
|
+
if (options) {
|
|
39
|
+
this.set(options);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
set(options) {
|
|
43
|
+
this.options = options;
|
|
44
|
+
}
|
|
45
|
+
get() {
|
|
46
|
+
return this.options;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
GuardClientConfig.ɵfac = function GuardClientConfig_Factory(t) { return new (t || GuardClientConfig)(i0.ɵɵinject(GuardConfigService, 8)); };
|
|
50
|
+
GuardClientConfig.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: GuardClientConfig, factory: GuardClientConfig.ɵfac, providedIn: 'root' });
|
|
51
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GuardClientConfig, [{
|
|
52
|
+
type: Injectable,
|
|
53
|
+
args: [{ providedIn: 'root' }]
|
|
54
|
+
}], function () { return [{ type: undefined, decorators: [{
|
|
55
|
+
type: Optional
|
|
56
|
+
}, {
|
|
57
|
+
type: Inject,
|
|
58
|
+
args: [GuardConfigService]
|
|
59
|
+
}] }]; }, null); })();
|
|
60
|
+
|
|
61
|
+
class GuardModule {
|
|
62
|
+
static forRoot(config) {
|
|
63
|
+
return {
|
|
64
|
+
ngModule: GuardModule,
|
|
65
|
+
providers: [
|
|
66
|
+
GuardService,
|
|
67
|
+
{
|
|
68
|
+
provide: GuardConfigService,
|
|
69
|
+
useValue: config
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
provide: GuardClientService,
|
|
73
|
+
useFactory: GuardClientFactory.createClient,
|
|
74
|
+
deps: [GuardClientConfig]
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
GuardModule.ɵfac = function GuardModule_Factory(t) { return new (t || GuardModule)(); };
|
|
81
|
+
GuardModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: GuardModule });
|
|
82
|
+
GuardModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
|
|
83
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GuardModule, [{
|
|
84
|
+
type: NgModule
|
|
85
|
+
}], null, null); })();
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Generated bundle index. Do not edit.
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
export { GuardModule, GuardService };
|
|
92
|
+
//# sourceMappingURL=zoyafng-guard-angular.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zoyafng-guard-angular.mjs","sources":["../../src/guard.client.ts","../../src/guard.service.ts","../../src/guard.config.ts","../../src/guard.module.ts","../../src/zoyafng-guard-angular.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core'\n\nimport { Guard } from '@zoyafng/guard'\n\nimport { GuardClientConfig } from './guard.config'\n\nexport const GuardClientService = new InjectionToken<Guard>('guard.client')\n\nexport class GuardClientFactory {\n static createClient(configFactory: GuardClientConfig): Guard {\n const options = configFactory.get()\n\n if (!options) {\n throw new Error(\n 'Configuration must be specified either through GuardModule.forRoot or through GuardClientConfig.set'\n )\n }\n\n return new Guard(options)\n }\n}\n","import { Injectable, Inject } from '@angular/core'\n\nimport { GuardClientService } from './guard.client'\n\nimport { Guard } from '@zoyafng/guard'\n\n@Injectable({\n providedIn: 'root'\n})\nexport class GuardService {\n constructor(@Inject(GuardClientService) public client: Guard) {}\n}\n","import { Injectable, Optional, Inject, InjectionToken } from '@angular/core'\n\nimport { GuardOptions } from '@zoyafng/guard'\n\nexport const GuardConfigService = new InjectionToken<GuardOptions>(\n 'guard.client'\n)\n\n@Injectable({ providedIn: 'root' })\nexport class GuardClientConfig {\n private options?: GuardOptions\n\n constructor(@Optional() @Inject(GuardConfigService) options?: GuardOptions) {\n if (options) {\n this.set(options)\n }\n }\n\n set(options: GuardOptions): void {\n this.options = options\n }\n\n get(): GuardOptions {\n return this.options as GuardOptions\n }\n}\n","import { NgModule, ModuleWithProviders } from '@angular/core'\n\nimport { GuardService } from './guard.service'\nimport { GuardClientService, GuardClientFactory } from './guard.client'\nimport { GuardConfigService, GuardClientConfig } from './guard.config'\n\nimport { GuardOptions } from '@zoyafng/guard'\n\n@NgModule()\nexport class GuardModule {\n static forRoot(config: GuardOptions): ModuleWithProviders<GuardModule> {\n return {\n ngModule: GuardModule,\n providers: [\n GuardService,\n {\n provide: GuardConfigService,\n useValue: config\n },\n {\n provide: GuardClientService,\n useFactory: GuardClientFactory.createClient,\n deps: [GuardClientConfig]\n }\n ]\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAMO,MAAM,kBAAkB,GAAG,IAAI,cAAc,CAAQ,cAAc,CAAC,CAAA;MAE9D,kBAAkB,CAAA;IAC7B,OAAO,YAAY,CAAC,aAAgC,EAAA;AAClD,QAAA,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,EAAE,CAAA;QAEnC,IAAI,CAAC,OAAO,EAAE;AACZ,YAAA,MAAM,IAAI,KAAK,CACb,qGAAqG,CACtG,CAAA;AACF,SAAA;AAED,QAAA,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;KAC1B;AACF;;MCXY,YAAY,CAAA;AACvB,IAAA,WAAA,CAA+C,MAAa,EAAA;QAAb,IAAM,CAAA,MAAA,GAAN,MAAM,CAAO;KAAI;;AADrD,YAAA,CAAA,IAAA,GAAA,SAAA,oBAAA,CAAA,CAAA,EAAA,EAAA,OAAA,KAAA,CAAA,IAAA,YAAY,cACH,kBAAkB,CAAA,CAAA,CAAA,EAAA,CAAA;kEAD3B,YAAY,EAAA,OAAA,EAAZ,YAAY,CAAA,IAAA,EAAA,UAAA,EAFX,MAAM,EAAA,CAAA,CAAA;uFAEP,YAAY,EAAA,CAAA;cAHxB,UAAU;AAAC,QAAA,IAAA,EAAA,CAAA;AACV,gBAAA,UAAU,EAAE,MAAM;AACnB,aAAA,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,EAAA,CAAA;6DAAX,WAAW,EAAA,CAAA,CAAA;;uFAAX,WAAW,EAAA,CAAA;cADvB,QAAQ;;;ACRT;;AAEG;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { Guard } from '@zoyafng/guard';
|
|
3
|
+
import { GuardClientConfig } from './guard.config';
|
|
4
|
+
export declare const GuardClientService: InjectionToken<Guard>;
|
|
5
|
+
export declare class GuardClientFactory {
|
|
6
|
+
static createClient(configFactory: GuardClientConfig): Guard;
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { GuardOptions } from '@zoyafng/guard';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare const GuardConfigService: InjectionToken<GuardOptions>;
|
|
5
|
+
export declare class GuardClientConfig {
|
|
6
|
+
private options?;
|
|
7
|
+
constructor(options?: GuardOptions);
|
|
8
|
+
set(options: GuardOptions): void;
|
|
9
|
+
get(): GuardOptions;
|
|
10
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<GuardClientConfig, [{ optional: true; }]>;
|
|
11
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<GuardClientConfig>;
|
|
12
|
+
}
|