@fusionauth/angular-sdk 0.1.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/README.md +24 -0
- package/esm2020/fusionauth-angular-sdk.mjs +5 -0
- package/esm2020/lib/components/fusionauth-login.button/fusion-auth-login-button.component.mjs +25 -0
- package/esm2020/lib/components/fusionauth-logout.button/fusion-auth-logout-button.component.mjs +18 -0
- package/esm2020/lib/components/fusionauth-register.button/fusion-auth-register-button.component.mjs +25 -0
- package/esm2020/lib/fusion-auth.module.mjs +40 -0
- package/esm2020/lib/fusion-auth.service.mjs +126 -0
- package/esm2020/lib/types.mjs +2 -0
- package/esm2020/public-api.mjs +10 -0
- package/fesm2015/fusionauth-angular-sdk.mjs +239 -0
- package/fesm2015/fusionauth-angular-sdk.mjs.map +1 -0
- package/fesm2020/fusionauth-angular-sdk.mjs +232 -0
- package/fesm2020/fusionauth-angular-sdk.mjs.map +1 -0
- package/fusionauth-angular-sdk.d.ts +5 -0
- package/lib/components/fusionauth-login.button/fusion-auth-login-button.component.d.ts +10 -0
- package/lib/components/fusionauth-logout.button/fusion-auth-logout-button.component.d.ts +9 -0
- package/lib/components/fusionauth-register.button/fusion-auth-register-button.component.d.ts +10 -0
- package/lib/fusion-auth.module.d.ts +12 -0
- package/lib/fusion-auth.service.d.ts +42 -0
- package/lib/types.d.ts +24 -0
- package/package.json +36 -0
- package/public-api.d.ts +6 -0
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# FusionauthAngularSdk
|
|
2
|
+
|
|
3
|
+
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.3.0.
|
|
4
|
+
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Run `ng generate component component-name --project fusionauth-angular-sdk` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project fusionauth-angular-sdk`.
|
|
8
|
+
> Note: Don't forget to add `--project fusionauth-angular-sdk` or else it will be added to the default project in your `angular.json` file.
|
|
9
|
+
|
|
10
|
+
## Build
|
|
11
|
+
|
|
12
|
+
Run `ng build fusionauth-angular-sdk` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
13
|
+
|
|
14
|
+
## Publishing
|
|
15
|
+
|
|
16
|
+
After building your library with `ng build fusionauth-angular-sdk`, go to the dist folder `cd dist/fusionauth-angular-sdk` and run `npm publish`.
|
|
17
|
+
|
|
18
|
+
## Running unit tests
|
|
19
|
+
|
|
20
|
+
Run `ng test fusionauth-angular-sdk` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
21
|
+
|
|
22
|
+
## Further help
|
|
23
|
+
|
|
24
|
+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
export * from './public-api';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnVzaW9uYXV0aC1hbmd1bGFyLXNkay5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3Byb2plY3RzL2Z1c2lvbmF1dGgtYW5ndWxhci1zZGsvc3JjL2Z1c2lvbmF1dGgtYW5ndWxhci1zZGsudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFFSCxjQUFjLGNBQWMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wdWJsaWMtYXBpJztcbiJdfQ==
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Component, Input } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import * as i1 from "../../fusion-auth.service";
|
|
4
|
+
export class FusionAuthLoginButtonComponent {
|
|
5
|
+
constructor(fusionAuth) {
|
|
6
|
+
this.fusionAuth = fusionAuth;
|
|
7
|
+
}
|
|
8
|
+
async login() {
|
|
9
|
+
if (!this.state) {
|
|
10
|
+
await this.fusionAuth.startLogin();
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
await this.fusionAuth.startLogin(this.state);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
FusionAuthLoginButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthLoginButtonComponent, deps: [{ token: i1.FusionAuthService }], target: i0.ɵɵFactoryTarget.Component });
|
|
18
|
+
FusionAuthLoginButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: FusionAuthLoginButtonComponent, selector: "fa-login", inputs: { state: "state" }, ngImport: i0, template: "<button class=\"fa-button\" (click)=\"login()\">\n <span>Login</span>\n</button>\n", styles: [".fa-button{padding:16px 16px 13px;border-radius:8px;background-color:#083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:18px;font-weight:600;text-align:center;color:#fff;width:400px}.fa-button:hover{cursor:pointer}\n"] });
|
|
19
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthLoginButtonComponent, decorators: [{
|
|
20
|
+
type: Component,
|
|
21
|
+
args: [{ selector: 'fa-login', template: "<button class=\"fa-button\" (click)=\"login()\">\n <span>Login</span>\n</button>\n", styles: [".fa-button{padding:16px 16px 13px;border-radius:8px;background-color:#083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:18px;font-weight:600;text-align:center;color:#fff;width:400px}.fa-button:hover{cursor:pointer}\n"] }]
|
|
22
|
+
}], ctorParameters: function () { return [{ type: i1.FusionAuthService }]; }, propDecorators: { state: [{
|
|
23
|
+
type: Input
|
|
24
|
+
}] } });
|
|
25
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnVzaW9uLWF1dGgtbG9naW4tYnV0dG9uLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL2Z1c2lvbmF1dGgtYW5ndWxhci1zZGsvc3JjL2xpYi9jb21wb25lbnRzL2Z1c2lvbmF1dGgtbG9naW4uYnV0dG9uL2Z1c2lvbi1hdXRoLWxvZ2luLWJ1dHRvbi5jb21wb25lbnQudHMiLCIuLi8uLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9mdXNpb25hdXRoLWFuZ3VsYXItc2RrL3NyYy9saWIvY29tcG9uZW50cy9mdXNpb25hdXRoLWxvZ2luLmJ1dHRvbi9mdXNpb24tYXV0aC1sb2dpbi1idXR0b24uY29tcG9uZW50Lmh0bWwiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFNBQVMsRUFBRSxLQUFLLEVBQUUsTUFBTSxlQUFlLENBQUM7OztBQVFqRCxNQUFNLE9BQU8sOEJBQThCO0lBR3pDLFlBQW9CLFVBQTZCO1FBQTdCLGVBQVUsR0FBVixVQUFVLENBQW1CO0lBQUcsQ0FBQztJQUVyRCxLQUFLLENBQUMsS0FBSztRQUNULElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxFQUFFO1lBQ2YsTUFBTSxJQUFJLENBQUMsVUFBVSxDQUFDLFVBQVUsRUFBRSxDQUFDO1NBQ3BDO2FBQU07WUFDTCxNQUFNLElBQUksQ0FBQyxVQUFVLENBQUMsVUFBV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b2dpbigpXCI+XG4gIDxzcGFuPkxvZ2luPC9zcGFuPlxuPC9idXR0b24+XG4iXX0=
|
package/esm2020/lib/components/fusionauth-logout.button/fusion-auth-logout-button.component.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import * as i1 from "../../fusion-auth.service";
|
|
4
|
+
export class FusionAuthLogoutButtonComponent {
|
|
5
|
+
constructor(fusionAuth) {
|
|
6
|
+
this.fusionAuth = fusionAuth;
|
|
7
|
+
}
|
|
8
|
+
logout() {
|
|
9
|
+
this.fusionAuth.logout();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
FusionAuthLogoutButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthLogoutButtonComponent, deps: [{ token: i1.FusionAuthService }], target: i0.ɵɵFactoryTarget.Component });
|
|
13
|
+
FusionAuthLogoutButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: FusionAuthLogoutButtonComponent, selector: "fa-logout", ngImport: i0, template: "<button class=\"fa-logout-button\" (click)=\"logout()\">\n <span>logout</span>\n</button>\n", styles: [".fa-logout-button{padding:7px 13px;border-radius:3px;display:block;border:solid 1px #083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:12px;text-align:center;color:#083b94}.fa-logout-button:hover{cursor:pointer}\n"] });
|
|
14
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthLogoutButtonComponent, decorators: [{
|
|
15
|
+
type: Component,
|
|
16
|
+
args: [{ selector: 'fa-logout', template: "<button class=\"fa-logout-button\" (click)=\"logout()\">\n <span>logout</span>\n</button>\n", styles: [".fa-logout-button{padding:7px 13px;border-radius:3px;display:block;border:solid 1px #083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:12px;text-align:center;color:#083b94}.fa-logout-button:hover{cursor:pointer}\n"] }]
|
|
17
|
+
}], ctorParameters: function () { return [{ type: i1.FusionAuthService }]; } });
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnVzaW9uLWF1dGgtbG9nb3V0LWJ1dHRvbi5jb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9mdXNpb25hdXRoLWFuZ3VsYXItc2RrL3NyYy9saWIvY29tcG9uZW50cy9mdXNpb25hdXRoLWxvZ291dC5idXR0b24vZnVzaW9uLWF1dGgtbG9nb3V0LWJ1dHRvbi5jb21wb25lbnQudHMiLCIuLi8uLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9mdXNpb25hdXRoLWFuZ3VsYXItc2RrL3NyYy9saWIvY29tcG9uZW50cy9mdXNpb25hdXRoLWxvZ291dC5idXR0b24vZnVzaW9uLWF1dGgtbG9nb3V0LWJ1dHRvbi5jb21wb25lbnQuaHRtbCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0sZUFBZSxDQUFDOzs7QUFRMUMsTUFBTSxPQUFPLCtCQUErQjtJQUMxQyxZQUNVLFVBQTZCO1FBQTdCLGVBQVUsR0FBVixVQUFVLENBQW1CO0lBQ3BDLENBQUM7SUFFSixNQUFNO1FBQ0osSUFBSSxDQUFDLFVBQVUsQ0FBQyxNQUFNLEVBQUUsQ0FBQztJQUMzQixDQUFDOzs2SEFQVSwrQkFBK0I7aUhBQS9CLCtCQUErQixpRENSNUMsOEZBR0E7NEZES2EsK0JBQStCO2tCQUwzQyxTQUFTOytCQUNFLFdBQVciLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBDb21wb25lbnQgfSBmcm9tICdAYW5ndWxhci9jb3JlJztcbmltcG9ydCB7IEZ1c2lvbkF1dGhTZXJ2aWNlIH0gZnJvbSAnLi4vLi4vZnVzaW9uLWF1dGguc2VydmljZSc7XG5cbkBDb21wb25lbnQoe1xuICBzZWxlY3RvcjogJ2ZhLWxvZ291dCcsXG4gIHRlbXBsYXRlVXJsOiAnLi9mdXNpb24tYXV0aC1sb2dvdXQtYnV0dG9uLmNvbXBvbmVudC5odG1sJyxcbiAgc3R5bGVVcmxzOiBbJy4vZnVzaW9uLWF1dGgtbG9nb3V0LWJ1dHRvbi5jb21wb25lbnQuc2NzcyddXG59KVxuZXhwb3J0IGNsYXNzIEZ1c2lvbkF1dGhMb2dvdXRCdXR0b25Db21wb25lbnQge1xuICBjb25zdHJ1Y3RvcihcbiAgICBwcml2YXRlIGZ1c2lvbkF1dGg6IEZ1c2lvbkF1dGhTZXJ2aWNlLFxuICApIHt9XG5cbiAgbG9nb3V0KCkge1xuICAgIHRoaXMuZnVzaW9uQXV0aC5sb2dvdXQoKTtcbiAgfVxufVxuIiwiPGJ1dHRvbiBjbGFzcz1cImZhLWxvZ291dC1idXR0b25cIiAoY2xpY2spPVwibG9nb3V0KClcIj5cbiAgPHNwYW4+bG9nb3V0PC9zcGFuPlxuPC9idXR0b24+XG4iXX0=
|
package/esm2020/lib/components/fusionauth-register.button/fusion-auth-register-button.component.mjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Component, Input } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import * as i1 from "../../fusion-auth.service";
|
|
4
|
+
export class FusionAuthRegisterButtonComponent {
|
|
5
|
+
constructor(fusionAuth) {
|
|
6
|
+
this.fusionAuth = fusionAuth;
|
|
7
|
+
}
|
|
8
|
+
register() {
|
|
9
|
+
if (!this.state) {
|
|
10
|
+
this.fusionAuth.startRegistration();
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
this.fusionAuth.startRegistration(this.state);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
FusionAuthRegisterButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthRegisterButtonComponent, deps: [{ token: i1.FusionAuthService }], target: i0.ɵɵFactoryTarget.Component });
|
|
18
|
+
FusionAuthRegisterButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: FusionAuthRegisterButtonComponent, selector: "fa-register", inputs: { state: "state" }, ngImport: i0, template: "<button class=\"fa-button\" (click)=\"register()\">\n <span>Register Now</span>\n</button>\n", styles: [".fa-button{padding:16px 16px 13px;border-radius:8px;background-color:#083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:18px;font-weight:600;text-align:center;color:#fff;width:400px}.fa-button:hover{cursor:pointer}\n"] });
|
|
19
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthRegisterButtonComponent, decorators: [{
|
|
20
|
+
type: Component,
|
|
21
|
+
args: [{ selector: 'fa-register', template: "<button class=\"fa-button\" (click)=\"register()\">\n <span>Register Now</span>\n</button>\n", styles: [".fa-button{padding:16px 16px 13px;border-radius:8px;background-color:#083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:18px;font-weight:600;text-align:center;color:#fff;width:400px}.fa-button:hover{cursor:pointer}\n"] }]
|
|
22
|
+
}], ctorParameters: function () { return [{ type: i1.FusionAuthService }]; }, propDecorators: { state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nV0dG9uPlxuIl19
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { FusionAuthService } from './fusion-auth.service';
|
|
3
|
+
import { FusionAuthLoginButtonComponent } from './components/fusionauth-login.button/fusion-auth-login-button.component';
|
|
4
|
+
import { FusionAuthLogoutButtonComponent } from './components/fusionauth-logout.button/fusion-auth-logout-button.component';
|
|
5
|
+
import { FusionAuthRegisterButtonComponent } from './components/fusionauth-register.button/fusion-auth-register-button.component';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
export class FusionAuthModule {
|
|
8
|
+
static forRoot(fusionAuthConfig) {
|
|
9
|
+
return {
|
|
10
|
+
ngModule: FusionAuthModule,
|
|
11
|
+
providers: [
|
|
12
|
+
{ provide: FusionAuthService, useValue: new FusionAuthService(fusionAuthConfig) }
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
FusionAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
18
|
+
FusionAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthModule, declarations: [FusionAuthLoginButtonComponent,
|
|
19
|
+
FusionAuthLogoutButtonComponent,
|
|
20
|
+
FusionAuthRegisterButtonComponent], exports: [FusionAuthLoginButtonComponent,
|
|
21
|
+
FusionAuthLogoutButtonComponent,
|
|
22
|
+
FusionAuthRegisterButtonComponent] });
|
|
23
|
+
FusionAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthModule, imports: [[]] });
|
|
24
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthModule, decorators: [{
|
|
25
|
+
type: NgModule,
|
|
26
|
+
args: [{
|
|
27
|
+
declarations: [
|
|
28
|
+
FusionAuthLoginButtonComponent,
|
|
29
|
+
FusionAuthLogoutButtonComponent,
|
|
30
|
+
FusionAuthRegisterButtonComponent,
|
|
31
|
+
],
|
|
32
|
+
imports: [],
|
|
33
|
+
exports: [
|
|
34
|
+
FusionAuthLoginButtonComponent,
|
|
35
|
+
FusionAuthLogoutButtonComponent,
|
|
36
|
+
FusionAuthRegisterButtonComponent,
|
|
37
|
+
]
|
|
38
|
+
}]
|
|
39
|
+
}] });
|
|
40
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnVzaW9uLWF1dGgubW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvZnVzaW9uYXV0aC1hbmd1bGFyLXNkay9zcmMvbGliL2Z1c2lvbi1hdXRoLm1vZHVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQXVCLFFBQVEsRUFBQyxNQUFNLGVBQWUsQ0FBQztBQUU3RCxPQUFPLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUMxRCxPQUFPLEVBQUUsOEJBQThCLEVBQUUsTUFBTSx5RUFBeUUsQ0FBQztBQUN6SCxPQUFPLEVBQ0wsK0JBQStCLEVBQ2hDLE1BQU0sMkVBQTJFLENBQUM7QUFDbkYsT0FBTyxFQUNMLGlDQUFpQyxFQUNsQyxNQUFNLCtFQUErRSxDQUFDOztBQWdCdkYsTUFBTSxPQUFPLGdCQUFnQjtJQUMzQixNQUFNLENBQUMsT0FBTyxDQUFDLGdCQUFrQztRQUMvQyxPQUFPO1lBQ0wsUUFBUSxFQUFFLGdCQUFnQjtZQUMxQixTQUFTLEVBQUU7Z0JBQ1QsRUFBRSxPQUFPLEVBQUUsaUJBQWlCLEVBQUUsUUFBUSxFQ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,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service class to use with FusionAuth backend endpoints.
|
|
3
|
+
*/
|
|
4
|
+
export class FusionAuthService {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.config = config;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Calls the 'me' endpoint to retrieve user info.
|
|
10
|
+
* @return {Promise<UserInfo>} the user info response.
|
|
11
|
+
*/
|
|
12
|
+
async getUserInfo() {
|
|
13
|
+
const path = !!this.config.mePath
|
|
14
|
+
? this.config.mePath
|
|
15
|
+
: '/app/me';
|
|
16
|
+
const uri = this.getUrlForPath(path);
|
|
17
|
+
const resp = await fetch(uri.href, {
|
|
18
|
+
credentials: 'include',
|
|
19
|
+
});
|
|
20
|
+
return JSON.parse(await resp.text());
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Checks for the 'app.at_exp' cookie and if present sets a timer to refresh the access token.
|
|
24
|
+
* Will attempt to refresh the configured seconds before the access token expires (default is ten seconds).
|
|
25
|
+
*/
|
|
26
|
+
initAutoRefresh() {
|
|
27
|
+
const exp = this.getExpTime();
|
|
28
|
+
if (exp) {
|
|
29
|
+
const refreshBeforeSeconds = this.config.autoRefreshSecondsBeforeExpiry
|
|
30
|
+
? this.config.autoRefreshSecondsBeforeExpiry
|
|
31
|
+
: 10;
|
|
32
|
+
const now = new Date().getTime();
|
|
33
|
+
const refreshTime = exp - (refreshBeforeSeconds * 1000);
|
|
34
|
+
let timeTillThen = refreshTime - now;
|
|
35
|
+
if (timeTillThen <= 0) {
|
|
36
|
+
timeTillThen = 0;
|
|
37
|
+
}
|
|
38
|
+
setTimeout(async () => {
|
|
39
|
+
try {
|
|
40
|
+
await this.refreshToken();
|
|
41
|
+
this.initAutoRefresh();
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
console.error(e);
|
|
45
|
+
}
|
|
46
|
+
}, timeTillThen);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Checks that the 'app.at_exp' cookie is present and for a time in the future to determine logged-in state.
|
|
51
|
+
* @return {boolean} app.at_exp is present and not for a time in the past
|
|
52
|
+
*/
|
|
53
|
+
isLoggedIn() {
|
|
54
|
+
return !!this.getExpTime();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Calls the configured 'refresh' endpoint to attempt to refresh the access token cookie.
|
|
58
|
+
*/
|
|
59
|
+
async refreshToken() {
|
|
60
|
+
const path = !!this.config.tokenRefreshPath
|
|
61
|
+
? `${this.config.tokenRefreshPath}/${this.config.clientId}`
|
|
62
|
+
: `/app/refresh/${this.config.clientId}`;
|
|
63
|
+
const uri = this.getUrlForPath(path);
|
|
64
|
+
const resp = await fetch(uri.href, {
|
|
65
|
+
method: 'POST',
|
|
66
|
+
credentials: 'include',
|
|
67
|
+
headers: {
|
|
68
|
+
'Content-Type': 'text/plain',
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
if (!(resp.status >= 200 && resp.status < 300)) {
|
|
72
|
+
throw new Error('error refreshing access token in fusionauth');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Invokes a redirect to the configured 'login' endpoint.
|
|
77
|
+
*/
|
|
78
|
+
startLogin(state) {
|
|
79
|
+
const path = !!this.config.loginPath
|
|
80
|
+
? this.config.loginPath
|
|
81
|
+
: '/app/login';
|
|
82
|
+
!!state ? this.doRedirectForPath(path, { state }) : this.doRedirectForPath(path);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Invokes a redirect to the configured 'refresh' endpoint.
|
|
86
|
+
*/
|
|
87
|
+
startRegistration(state) {
|
|
88
|
+
const path = !!this.config.registerPath
|
|
89
|
+
? this.config.registerPath
|
|
90
|
+
: '/app/register';
|
|
91
|
+
!!state ? this.doRedirectForPath(path, { state }) : this.doRedirectForPath(path);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Invokes a redirect to the configured 'logout' endpoint.
|
|
95
|
+
*/
|
|
96
|
+
logout() {
|
|
97
|
+
const path = !!this.config.logoutPath
|
|
98
|
+
? this.config.logoutPath
|
|
99
|
+
: '/app/logout';
|
|
100
|
+
this.doRedirectForPath(path);
|
|
101
|
+
}
|
|
102
|
+
doRedirectForPath(path, params = {}) {
|
|
103
|
+
path = path + `/${this.config.clientId}`;
|
|
104
|
+
if (this.config.redirectUri) {
|
|
105
|
+
params['redirect_uri'] = this.config.redirectUri;
|
|
106
|
+
}
|
|
107
|
+
let location = this.getUrlForPath(path, params);
|
|
108
|
+
window.location.assign(location);
|
|
109
|
+
}
|
|
110
|
+
getUrlForPath(path, params = {}) {
|
|
111
|
+
let url = new URL(this.config.serverUrl);
|
|
112
|
+
url.pathname = path;
|
|
113
|
+
if (Object.entries(params).length > 0) {
|
|
114
|
+
const urlParams = new URLSearchParams(params);
|
|
115
|
+
url.search = urlParams.toString();
|
|
116
|
+
}
|
|
117
|
+
return url;
|
|
118
|
+
}
|
|
119
|
+
getExpTime() {
|
|
120
|
+
const expCookie = document.cookie.split('; ')
|
|
121
|
+
.map(c => c.split('='))
|
|
122
|
+
.find(([name]) => name === 'app.at_exp');
|
|
123
|
+
return expCookie ? parseInt(expCookie[1]) * 1000 : null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnVzaW9uLWF1dGguc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL2Z1c2lvbmF1dGgtYW5ndWxhci1zZGsvc3JjL2xpYi9mdXNpb24tYXV0aC5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBOztHQUVHO0FBQ0gsTUFBTSxPQUFPLGlCQUFpQjtJQUU1QixZQUNVLE1BQXdCO1FBQXhCLFdBQU0sR0FBTixNQUFN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tcykgO1xuICAgIHdpbmRvdy5sb2NhdGlvbi5hc3NpZ24obG9jYXRpb24pO1xuICB9XG5cbiAgcHJpdmF0ZSBnZXRVcmxGb3JQYXRoKHBhdGg6IHN0cmluZywgcGFyYW1zOiBSZWNvcmQ8c3RyaW5nLCBhbnk+ID0ge30pOiBVUkwge1xuICAgIGxldCB1cmwgPSBuZXcgVVJMKHRoaXMuY29uZmlnLnNlcnZlclVybCk7XG4gICAgdXJsLnBhdGhuYW1lID0gcGF0aDtcbiAgICBpZiAoT2JqZWN0LmVudHJpZXMocGFyYW1zKS5sZW5ndGggPiAwKSB7XG4gICAgICBjb25zdCB1cmxQYXJhbXMgPSBuZXcgVVJMU2VhcmNoUGFyYW1zKHBhcmFtcyk7XG4gICAgICB1cmwuc2VhcmNoID0gdXJsUGFyYW1zLnRvU3RyaW5nKCk7XG4gICAgfVxuICAgIHJldHVybiB1cmw7XG4gIH1cblxuICBwcml2YXRlIGdldEV4cFRpbWUoKTogbnVtYmVyIHwgbnVsbCB7XG4gICAgY29uc3QgZXhwQ29va2llID0gZG9jdW1lbnQuY29va2llLnNwbGl0KCc7ICcpXG4gICAgICAubWFwKGMgPT4gYy5zcGxpdCgnPScpKVxuICAgICAgLmZpbmQoKFtuYW1lXSkgPT4gbmFtZSA9PT0gJ2FwcC5hdF9leHAnKTtcbiAgICByZXR1cm4gZXhwQ29va2llID8gcGFyc2VJbnQoZXhwQ29va2llWzFdKSAqIDEwMDAgOiBudWxsO1xuICB9XG59XG4iXX0=
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9mdXNpb25hdXRoLWFuZ3VsYXItc2RrL3NyYy9saWIvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBpbnRlcmZhY2UgRnVzaW9uQXV0aENvbmZpZyB7XG4gIHNlcnZlclVybDogc3RyaW5nO1xuICBjbGllbnRJZDogc3RyaW5nO1xuICByZWRpcmVjdFVyaT86IHN0cmluZztcblxuICBhdXRvUmVmcmVzaFNlY29uZHNCZWZvcmVFeHBpcnk/OiBudW1iZXI7XG4gIGxvZ2luUGF0aD86IHN0cmluZztcbiAgbG9nb3V0UGF0aD86IHN0cmluZztcbiAgcmVnaXN0ZXJQYXRoPzogc3RyaW5nO1xuICB0b2tlblJlZnJlc2hQYXRoPzogc3RyaW5nO1xuICBtZVBhdGg/OiBzdHJpbmc7XG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgVXNlckluZm8ge1xuICBhcHBsaWNhdGlvbklkPzogc3RyaW5nO1xuICBlbWFpbD86IHN0cmluZztcbiAgZW1haWxfdmVyaWZpZWQ/OiBib29sZWFuO1xuICBmYW1pbHlfbmFtZT86IHN0cmluZztcbiAgZ2l2ZW5fbmFtZT86IHN0cmluZztcbiAgcGljdHVyZT86IHN0cmluZztcbiAgcm9sZXM/OiBhbnlbXTtcbiAgc2lkPzogc3RyaW5nO1xuICBzdWI/OiBzdHJpbmc7XG4gIHRpZD86IHN0cmluZztcbiAgcGhvbmVfbnVtYmVyPzogc3RyaW5nO1xufVxuIl19
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Public API Surface of fusionauth-angular-sdk
|
|
3
|
+
*/
|
|
4
|
+
export * from './lib/fusion-auth.service';
|
|
5
|
+
export * from './lib/components/fusionauth-login.button/fusion-auth-login-button.component';
|
|
6
|
+
export * from './lib/components/fusionauth-logout.button/fusion-auth-logout-button.component';
|
|
7
|
+
export * from './lib/components/fusionauth-register.button/fusion-auth-register-button.component';
|
|
8
|
+
export * from './lib/fusion-auth.module';
|
|
9
|
+
export * from './lib/types';
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,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@@
|
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { Component, Input, NgModule } from '@angular/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Service class to use with FusionAuth backend endpoints.
|
|
7
|
+
*/
|
|
8
|
+
class FusionAuthService {
|
|
9
|
+
constructor(config) {
|
|
10
|
+
this.config = config;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Calls the 'me' endpoint to retrieve user info.
|
|
14
|
+
* @return {Promise<UserInfo>} the user info response.
|
|
15
|
+
*/
|
|
16
|
+
getUserInfo() {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const path = !!this.config.mePath
|
|
19
|
+
? this.config.mePath
|
|
20
|
+
: '/app/me';
|
|
21
|
+
const uri = this.getUrlForPath(path);
|
|
22
|
+
const resp = yield fetch(uri.href, {
|
|
23
|
+
credentials: 'include',
|
|
24
|
+
});
|
|
25
|
+
return JSON.parse(yield resp.text());
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Checks for the 'app.at_exp' cookie and if present sets a timer to refresh the access token.
|
|
30
|
+
* Will attempt to refresh the configured seconds before the access token expires (default is ten seconds).
|
|
31
|
+
*/
|
|
32
|
+
initAutoRefresh() {
|
|
33
|
+
const exp = this.getExpTime();
|
|
34
|
+
if (exp) {
|
|
35
|
+
const refreshBeforeSeconds = this.config.autoRefreshSecondsBeforeExpiry
|
|
36
|
+
? this.config.autoRefreshSecondsBeforeExpiry
|
|
37
|
+
: 10;
|
|
38
|
+
const now = new Date().getTime();
|
|
39
|
+
const refreshTime = exp - (refreshBeforeSeconds * 1000);
|
|
40
|
+
let timeTillThen = refreshTime - now;
|
|
41
|
+
if (timeTillThen <= 0) {
|
|
42
|
+
timeTillThen = 0;
|
|
43
|
+
}
|
|
44
|
+
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
try {
|
|
46
|
+
yield this.refreshToken();
|
|
47
|
+
this.initAutoRefresh();
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
console.error(e);
|
|
51
|
+
}
|
|
52
|
+
}), timeTillThen);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Checks that the 'app.at_exp' cookie is present and for a time in the future to determine logged-in state.
|
|
57
|
+
* @return {boolean} app.at_exp is present and not for a time in the past
|
|
58
|
+
*/
|
|
59
|
+
isLoggedIn() {
|
|
60
|
+
return !!this.getExpTime();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Calls the configured 'refresh' endpoint to attempt to refresh the access token cookie.
|
|
64
|
+
*/
|
|
65
|
+
refreshToken() {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const path = !!this.config.tokenRefreshPath
|
|
68
|
+
? `${this.config.tokenRefreshPath}/${this.config.clientId}`
|
|
69
|
+
: `/app/refresh/${this.config.clientId}`;
|
|
70
|
+
const uri = this.getUrlForPath(path);
|
|
71
|
+
const resp = yield fetch(uri.href, {
|
|
72
|
+
method: 'POST',
|
|
73
|
+
credentials: 'include',
|
|
74
|
+
headers: {
|
|
75
|
+
'Content-Type': 'text/plain',
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
if (!(resp.status >= 200 && resp.status < 300)) {
|
|
79
|
+
throw new Error('error refreshing access token in fusionauth');
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Invokes a redirect to the configured 'login' endpoint.
|
|
85
|
+
*/
|
|
86
|
+
startLogin(state) {
|
|
87
|
+
const path = !!this.config.loginPath
|
|
88
|
+
? this.config.loginPath
|
|
89
|
+
: '/app/login';
|
|
90
|
+
!!state ? this.doRedirectForPath(path, { state }) : this.doRedirectForPath(path);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Invokes a redirect to the configured 'refresh' endpoint.
|
|
94
|
+
*/
|
|
95
|
+
startRegistration(state) {
|
|
96
|
+
const path = !!this.config.registerPath
|
|
97
|
+
? this.config.registerPath
|
|
98
|
+
: '/app/register';
|
|
99
|
+
!!state ? this.doRedirectForPath(path, { state }) : this.doRedirectForPath(path);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Invokes a redirect to the configured 'logout' endpoint.
|
|
103
|
+
*/
|
|
104
|
+
logout() {
|
|
105
|
+
const path = !!this.config.logoutPath
|
|
106
|
+
? this.config.logoutPath
|
|
107
|
+
: '/app/logout';
|
|
108
|
+
this.doRedirectForPath(path);
|
|
109
|
+
}
|
|
110
|
+
doRedirectForPath(path, params = {}) {
|
|
111
|
+
path = path + `/${this.config.clientId}`;
|
|
112
|
+
if (this.config.redirectUri) {
|
|
113
|
+
params['redirect_uri'] = this.config.redirectUri;
|
|
114
|
+
}
|
|
115
|
+
let location = this.getUrlForPath(path, params);
|
|
116
|
+
window.location.assign(location);
|
|
117
|
+
}
|
|
118
|
+
getUrlForPath(path, params = {}) {
|
|
119
|
+
let url = new URL(this.config.serverUrl);
|
|
120
|
+
url.pathname = path;
|
|
121
|
+
if (Object.entries(params).length > 0) {
|
|
122
|
+
const urlParams = new URLSearchParams(params);
|
|
123
|
+
url.search = urlParams.toString();
|
|
124
|
+
}
|
|
125
|
+
return url;
|
|
126
|
+
}
|
|
127
|
+
getExpTime() {
|
|
128
|
+
const expCookie = document.cookie.split('; ')
|
|
129
|
+
.map(c => c.split('='))
|
|
130
|
+
.find(([name]) => name === 'app.at_exp');
|
|
131
|
+
return expCookie ? parseInt(expCookie[1]) * 1000 : null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
class FusionAuthLoginButtonComponent {
|
|
136
|
+
constructor(fusionAuth) {
|
|
137
|
+
this.fusionAuth = fusionAuth;
|
|
138
|
+
}
|
|
139
|
+
login() {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
if (!this.state) {
|
|
142
|
+
yield this.fusionAuth.startLogin();
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
yield this.fusionAuth.startLogin(this.state);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
FusionAuthLoginButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthLoginButtonComponent, deps: [{ token: FusionAuthService }], target: i0.ɵɵFactoryTarget.Component });
|
|
151
|
+
FusionAuthLoginButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: FusionAuthLoginButtonComponent, selector: "fa-login", inputs: { state: "state" }, ngImport: i0, template: "<button class=\"fa-button\" (click)=\"login()\">\n <span>Login</span>\n</button>\n", styles: [".fa-button{padding:16px 16px 13px;border-radius:8px;background-color:#083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:18px;font-weight:600;text-align:center;color:#fff;width:400px}.fa-button:hover{cursor:pointer}\n"] });
|
|
152
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthLoginButtonComponent, decorators: [{
|
|
153
|
+
type: Component,
|
|
154
|
+
args: [{ selector: 'fa-login', template: "<button class=\"fa-button\" (click)=\"login()\">\n <span>Login</span>\n</button>\n", styles: [".fa-button{padding:16px 16px 13px;border-radius:8px;background-color:#083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:18px;font-weight:600;text-align:center;color:#fff;width:400px}.fa-button:hover{cursor:pointer}\n"] }]
|
|
155
|
+
}], ctorParameters: function () { return [{ type: FusionAuthService }]; }, propDecorators: { state: [{
|
|
156
|
+
type: Input
|
|
157
|
+
}] } });
|
|
158
|
+
|
|
159
|
+
class FusionAuthLogoutButtonComponent {
|
|
160
|
+
constructor(fusionAuth) {
|
|
161
|
+
this.fusionAuth = fusionAuth;
|
|
162
|
+
}
|
|
163
|
+
logout() {
|
|
164
|
+
this.fusionAuth.logout();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
FusionAuthLogoutButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthLogoutButtonComponent, deps: [{ token: FusionAuthService }], target: i0.ɵɵFactoryTarget.Component });
|
|
168
|
+
FusionAuthLogoutButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: FusionAuthLogoutButtonComponent, selector: "fa-logout", ngImport: i0, template: "<button class=\"fa-logout-button\" (click)=\"logout()\">\n <span>logout</span>\n</button>\n", styles: [".fa-logout-button{padding:7px 13px;border-radius:3px;display:block;border:solid 1px #083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:12px;text-align:center;color:#083b94}.fa-logout-button:hover{cursor:pointer}\n"] });
|
|
169
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthLogoutButtonComponent, decorators: [{
|
|
170
|
+
type: Component,
|
|
171
|
+
args: [{ selector: 'fa-logout', template: "<button class=\"fa-logout-button\" (click)=\"logout()\">\n <span>logout</span>\n</button>\n", styles: [".fa-logout-button{padding:7px 13px;border-radius:3px;display:block;border:solid 1px #083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:12px;text-align:center;color:#083b94}.fa-logout-button:hover{cursor:pointer}\n"] }]
|
|
172
|
+
}], ctorParameters: function () { return [{ type: FusionAuthService }]; } });
|
|
173
|
+
|
|
174
|
+
class FusionAuthRegisterButtonComponent {
|
|
175
|
+
constructor(fusionAuth) {
|
|
176
|
+
this.fusionAuth = fusionAuth;
|
|
177
|
+
}
|
|
178
|
+
register() {
|
|
179
|
+
if (!this.state) {
|
|
180
|
+
this.fusionAuth.startRegistration();
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
this.fusionAuth.startRegistration(this.state);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
FusionAuthRegisterButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthRegisterButtonComponent, deps: [{ token: FusionAuthService }], target: i0.ɵɵFactoryTarget.Component });
|
|
188
|
+
FusionAuthRegisterButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: FusionAuthRegisterButtonComponent, selector: "fa-register", inputs: { state: "state" }, ngImport: i0, template: "<button class=\"fa-button\" (click)=\"register()\">\n <span>Register Now</span>\n</button>\n", styles: [".fa-button{padding:16px 16px 13px;border-radius:8px;background-color:#083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:18px;font-weight:600;text-align:center;color:#fff;width:400px}.fa-button:hover{cursor:pointer}\n"] });
|
|
189
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthRegisterButtonComponent, decorators: [{
|
|
190
|
+
type: Component,
|
|
191
|
+
args: [{ selector: 'fa-register', template: "<button class=\"fa-button\" (click)=\"register()\">\n <span>Register Now</span>\n</button>\n", styles: [".fa-button{padding:16px 16px 13px;border-radius:8px;background-color:#083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:18px;font-weight:600;text-align:center;color:#fff;width:400px}.fa-button:hover{cursor:pointer}\n"] }]
|
|
192
|
+
}], ctorParameters: function () { return [{ type: FusionAuthService }]; }, propDecorators: { state: [{
|
|
193
|
+
type: Input
|
|
194
|
+
}] } });
|
|
195
|
+
|
|
196
|
+
class FusionAuthModule {
|
|
197
|
+
static forRoot(fusionAuthConfig) {
|
|
198
|
+
return {
|
|
199
|
+
ngModule: FusionAuthModule,
|
|
200
|
+
providers: [
|
|
201
|
+
{ provide: FusionAuthService, useValue: new FusionAuthService(fusionAuthConfig) }
|
|
202
|
+
],
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
FusionAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
207
|
+
FusionAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthModule, declarations: [FusionAuthLoginButtonComponent,
|
|
208
|
+
FusionAuthLogoutButtonComponent,
|
|
209
|
+
FusionAuthRegisterButtonComponent], exports: [FusionAuthLoginButtonComponent,
|
|
210
|
+
FusionAuthLogoutButtonComponent,
|
|
211
|
+
FusionAuthRegisterButtonComponent] });
|
|
212
|
+
FusionAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthModule, imports: [[]] });
|
|
213
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthModule, decorators: [{
|
|
214
|
+
type: NgModule,
|
|
215
|
+
args: [{
|
|
216
|
+
declarations: [
|
|
217
|
+
FusionAuthLoginButtonComponent,
|
|
218
|
+
FusionAuthLogoutButtonComponent,
|
|
219
|
+
FusionAuthRegisterButtonComponent,
|
|
220
|
+
],
|
|
221
|
+
imports: [],
|
|
222
|
+
exports: [
|
|
223
|
+
FusionAuthLoginButtonComponent,
|
|
224
|
+
FusionAuthLogoutButtonComponent,
|
|
225
|
+
FusionAuthRegisterButtonComponent,
|
|
226
|
+
]
|
|
227
|
+
}]
|
|
228
|
+
}] });
|
|
229
|
+
|
|
230
|
+
/*
|
|
231
|
+
* Public API Surface of fusionauth-angular-sdk
|
|
232
|
+
*/
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Generated bundle index. Do not edit.
|
|
236
|
+
*/
|
|
237
|
+
|
|
238
|
+
export { FusionAuthLoginButtonComponent, FusionAuthLogoutButtonComponent, FusionAuthModule, FusionAuthRegisterButtonComponent, FusionAuthService };
|
|
239
|
+
//# sourceMappingURL=fusionauth-angular-sdk.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fusionauth-angular-sdk.mjs","sources":["../../../projects/fusionauth-angular-sdk/src/lib/fusion-auth.service.ts","../../../projects/fusionauth-angular-sdk/src/lib/components/fusionauth-login.button/fusion-auth-login-button.component.ts","../../../projects/fusionauth-angular-sdk/src/lib/components/fusionauth-login.button/fusion-auth-login-button.component.html","../../../projects/fusionauth-angular-sdk/src/lib/components/fusionauth-logout.button/fusion-auth-logout-button.component.ts","../../../projects/fusionauth-angular-sdk/src/lib/components/fusionauth-logout.button/fusion-auth-logout-button.component.html","../../../projects/fusionauth-angular-sdk/src/lib/components/fusionauth-register.button/fusion-auth-register-button.component.ts","../../../projects/fusionauth-angular-sdk/src/lib/components/fusionauth-register.button/fusion-auth-register-button.component.html","../../../projects/fusionauth-angular-sdk/src/lib/fusion-auth.module.ts","../../../projects/fusionauth-angular-sdk/src/public-api.ts","../../../projects/fusionauth-angular-sdk/src/fusionauth-angular-sdk.ts"],"sourcesContent":["import { FusionAuthConfig, UserInfo } from './types';\n\n/**\n * Service class to use with FusionAuth backend endpoints.\n */\nexport class FusionAuthService {\n\n constructor(\n private config: FusionAuthConfig,\n ) { }\n\n /**\n * Calls the 'me' endpoint to retrieve user info.\n * @return {Promise<UserInfo>} the user info response.\n */\n async getUserInfo(): Promise<UserInfo> {\n const path = !!this.config.mePath\n ? this.config.mePath\n : '/app/me';\n const uri = this.getUrlForPath(path);\n const resp = await fetch(uri.href, {\n credentials: 'include',\n });\n return JSON.parse(await resp.text()) as UserInfo;\n }\n\n /**\n * Checks for the 'app.at_exp' cookie and if present sets a timer to refresh the access token.\n * Will attempt to refresh the configured seconds before the access token expires (default is ten seconds).\n */\n initAutoRefresh(): void {\n const exp = this.getExpTime();\n if (exp) {\n const refreshBeforeSeconds = this.config.autoRefreshSecondsBeforeExpiry\n ? this.config.autoRefreshSecondsBeforeExpiry\n : 10;\n const now = new Date().getTime();\n const refreshTime = exp - (refreshBeforeSeconds * 1000);\n let timeTillThen = refreshTime - now;\n if (timeTillThen <= 0) {\n timeTillThen = 0;\n }\n setTimeout(async () => {\n try {\n await this.refreshToken();\n this.initAutoRefresh();\n } catch (e) {\n console.error(e)\n }\n }, timeTillThen);\n }\n }\n\n /**\n * Checks that the 'app.at_exp' cookie is present and for a time in the future to determine logged-in state.\n * @return {boolean} app.at_exp is present and not for a time in the past\n */\n isLoggedIn(): boolean {\n return !!this.getExpTime();\n }\n\n /**\n * Calls the configured 'refresh' endpoint to attempt to refresh the access token cookie.\n */\n async refreshToken(): Promise<void> {\n const path = !!this.config.tokenRefreshPath\n ? `${this.config.tokenRefreshPath}/${this.config.clientId}`\n : `/app/refresh/${this.config.clientId}`;\n const uri = this.getUrlForPath(path);\n const resp = await fetch(uri.href, {\n method: 'POST',\n credentials: 'include',\n headers: {\n 'Content-Type': 'text/plain',\n }\n });\n if (!(resp.status >= 200 && resp.status < 300)) {\n throw new Error('error refreshing access token in fusionauth');\n }\n }\n\n /**\n * Invokes a redirect to the configured 'login' endpoint.\n */\n startLogin(state?: string): void {\n const path = !!this.config.loginPath\n ? this.config.loginPath\n : '/app/login';\n !!state ? this.doRedirectForPath(path, {state}) : this.doRedirectForPath(path);\n }\n\n /**\n * Invokes a redirect to the configured 'refresh' endpoint.\n */\n startRegistration(state?: string): void {\n const path = !!this.config.registerPath\n ? this.config.registerPath\n : '/app/register';\n !!state ? this.doRedirectForPath(path, {state}) : this.doRedirectForPath(path);\n }\n\n /**\n * Invokes a redirect to the configured 'logout' endpoint.\n */\n logout(): void {\n const path = !!this.config.logoutPath\n ? this.config.logoutPath\n : '/app/logout';\n this.doRedirectForPath(path);\n }\n\n private doRedirectForPath(path: string, params: Record<string,any> = {}) {\n path = path + `/${this.config.clientId}`;\n if (this.config.redirectUri) {\n params['redirect_uri'] = this.config.redirectUri;\n }\n let location = this.getUrlForPath(path, params) ;\n window.location.assign(location);\n }\n\n private getUrlForPath(path: string, params: Record<string, any> = {}): URL {\n let url = new URL(this.config.serverUrl);\n url.pathname = path;\n if (Object.entries(params).length > 0) {\n const urlParams = new URLSearchParams(params);\n url.search = urlParams.toString();\n }\n return url;\n }\n\n private getExpTime(): number | null {\n const expCookie = document.cookie.split('; ')\n .map(c => c.split('='))\n .find(([name]) => name === 'app.at_exp');\n return expCookie ? parseInt(expCookie[1]) * 1000 : null;\n }\n}\n","import { Component, Input } from '@angular/core';\nimport { FusionAuthService } from '../../fusion-auth.service';\n\n@Component({\n selector: 'fa-login',\n templateUrl: './fusion-auth-login-button.component.html',\n styleUrls: ['./fusion-auth-login-button.component.scss']\n})\nexport class FusionAuthLoginButtonComponent {\n @Input() state: string | undefined;\n\n constructor(private fusionAuth: FusionAuthService) {}\n\n async login() {\n if (!this.state) {\n await this.fusionAuth.startLogin();\n } else {\n await this.fusionAuth.startLogin(this.state);\n }\n\n }\n}\n","<button class=\"fa-button\" (click)=\"login()\">\n <span>Login</span>\n</button>\n","import { Component } from '@angular/core';\nimport { FusionAuthService } from '../../fusion-auth.service';\n\n@Component({\n selector: 'fa-logout',\n templateUrl: './fusion-auth-logout-button.component.html',\n styleUrls: ['./fusion-auth-logout-button.component.scss']\n})\nexport class FusionAuthLogoutButtonComponent {\n constructor(\n private fusionAuth: FusionAuthService,\n ) {}\n\n logout() {\n this.fusionAuth.logout();\n }\n}\n","<button class=\"fa-logout-button\" (click)=\"logout()\">\n <span>logout</span>\n</button>\n","import { Component, Input } from '@angular/core';\nimport { FusionAuthService } from '../../fusion-auth.service';\n\n@Component({\n selector: 'fa-register',\n templateUrl: './fusion-auth-register-button.component.html',\n styleUrls: ['./fusion-auth-register-button.component.scss']\n})\nexport class FusionAuthRegisterButtonComponent {\n @Input() state: string | undefined;\n\n constructor(\n private fusionAuth: FusionAuthService,\n ) {}\n\n register() {\n if (!this.state) {\n this.fusionAuth.startRegistration();\n } else {\n this.fusionAuth.startRegistration(this.state);\n }\n }\n}\n","<button class=\"fa-button\" (click)=\"register()\">\n <span>Register Now</span>\n</button>\n","import { ModuleWithProviders, NgModule} from '@angular/core';\nimport { FusionAuthConfig } from './types';\nimport { FusionAuthService } from './fusion-auth.service';\nimport { FusionAuthLoginButtonComponent } from './components/fusionauth-login.button/fusion-auth-login-button.component';\nimport {\n FusionAuthLogoutButtonComponent\n} from './components/fusionauth-logout.button/fusion-auth-logout-button.component';\nimport {\n FusionAuthRegisterButtonComponent\n} from './components/fusionauth-register.button/fusion-auth-register-button.component';\n\n@NgModule({\n declarations: [\n FusionAuthLoginButtonComponent,\n FusionAuthLogoutButtonComponent,\n FusionAuthRegisterButtonComponent,\n ],\n imports: [\n ],\n exports: [\n FusionAuthLoginButtonComponent,\n FusionAuthLogoutButtonComponent,\n FusionAuthRegisterButtonComponent,\n ]\n})\nexport class FusionAuthModule {\n static forRoot(fusionAuthConfig: FusionAuthConfig): ModuleWithProviders<FusionAuthModule> {\n return {\n ngModule: FusionAuthModule,\n providers: [\n { provide: FusionAuthService, useValue: new FusionAuthService(fusionAuthConfig) }\n ],\n }\n }\n}\n","/*\n * Public API Surface of fusionauth-angular-sdk\n */\n\nexport * from './lib/fusion-auth.service';\nexport * from './lib/components/fusionauth-login.button/fusion-auth-login-button.component';\nexport * from './lib/components/fusionauth-logout.button/fusion-auth-logout-button.component';\nexport * from './lib/components/fusionauth-register.button/fusion-auth-register-button.component';\nexport * from './lib/fusion-auth.module';\nexport * from './lib/types';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.FusionAuthService"],"mappings":";;;;AAEA;;AAEG;MACU,iBAAiB,CAAA;AAE5B,IAAA,WAAA,CACU,MAAwB,EAAA;AAAxB,QAAA,IAAM,CAAA,MAAA,GAAN,MAAM,CAAkB;KAC7B;AAEL;;;AAGG;IACG,WAAW,GAAA;;YACf,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;AAC/B,kBAAE,IAAI,CAAC,MAAM,CAAC,MAAM;kBAClB,SAAS,CAAC;YACd,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YACrC,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE;AACjC,gBAAA,WAAW,EAAE,SAAS;AACvB,aAAA,CAAC,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAa,CAAC;SAClD,CAAA,CAAA;AAAA,KAAA;AAED;;;AAGG;IACH,eAAe,GAAA;AACb,QAAA,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;AAC9B,QAAA,IAAI,GAAG,EAAE;AACP,YAAA,MAAM,oBAAoB,GAAG,IAAI,CAAC,MAAM,CAAC,8BAA8B;AACrE,kBAAE,IAAI,CAAC,MAAM,CAAC,8BAA8B;kBAC1C,EAAE,CAAC;YACP,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;YACjC,MAAM,WAAW,GAAG,GAAG,IAAI,oBAAoB,GAAG,IAAI,CAAC,CAAC;AACxD,YAAA,IAAI,YAAY,GAAG,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,gBAAgB,CAAC,EAAE;AAClF,aAAA;SACF,CAAA;KACF;;8GARU,gBAAgB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAhB,gBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gBAAgB,iBAZzB,8BAA8B;QAC9B,+BAA+B;AAC/B,QAAA,iCAAiC,aAKjC,8BAA8B;QAC9B,+BAA+B;QAC/B,iCAAiC,CAAA,EAAA,CAAA,CAAA;AAGxB,gBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gBAAgB,YARlB,EACR,CAAA,EAAA,CAAA,CAAA;4FAOU,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAd5B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE;wBACZ,8BAA8B;wBAC9B,+BAA+B;wBAC/B,iCAAiC;AAClC,qBAAA;AACD,oBAAA,OAAO,EAAE,EACR;AACD,oBAAA,OAAO,EAAE;wBACP,8BAA8B;wBAC9B,+BAA+B;wBAC/B,iCAAiC;AAClC,qBAAA;iBACF,CAAA;;;ACxBD;;AAEG;;ACFH;;AAEG;;;;"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Component, Input, NgModule } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Service class to use with FusionAuth backend endpoints.
|
|
6
|
+
*/
|
|
7
|
+
class FusionAuthService {
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.config = config;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Calls the 'me' endpoint to retrieve user info.
|
|
13
|
+
* @return {Promise<UserInfo>} the user info response.
|
|
14
|
+
*/
|
|
15
|
+
async getUserInfo() {
|
|
16
|
+
const path = !!this.config.mePath
|
|
17
|
+
? this.config.mePath
|
|
18
|
+
: '/app/me';
|
|
19
|
+
const uri = this.getUrlForPath(path);
|
|
20
|
+
const resp = await fetch(uri.href, {
|
|
21
|
+
credentials: 'include',
|
|
22
|
+
});
|
|
23
|
+
return JSON.parse(await resp.text());
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Checks for the 'app.at_exp' cookie and if present sets a timer to refresh the access token.
|
|
27
|
+
* Will attempt to refresh the configured seconds before the access token expires (default is ten seconds).
|
|
28
|
+
*/
|
|
29
|
+
initAutoRefresh() {
|
|
30
|
+
const exp = this.getExpTime();
|
|
31
|
+
if (exp) {
|
|
32
|
+
const refreshBeforeSeconds = this.config.autoRefreshSecondsBeforeExpiry
|
|
33
|
+
? this.config.autoRefreshSecondsBeforeExpiry
|
|
34
|
+
: 10;
|
|
35
|
+
const now = new Date().getTime();
|
|
36
|
+
const refreshTime = exp - (refreshBeforeSeconds * 1000);
|
|
37
|
+
let timeTillThen = refreshTime - now;
|
|
38
|
+
if (timeTillThen <= 0) {
|
|
39
|
+
timeTillThen = 0;
|
|
40
|
+
}
|
|
41
|
+
setTimeout(async () => {
|
|
42
|
+
try {
|
|
43
|
+
await this.refreshToken();
|
|
44
|
+
this.initAutoRefresh();
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
console.error(e);
|
|
48
|
+
}
|
|
49
|
+
}, timeTillThen);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Checks that the 'app.at_exp' cookie is present and for a time in the future to determine logged-in state.
|
|
54
|
+
* @return {boolean} app.at_exp is present and not for a time in the past
|
|
55
|
+
*/
|
|
56
|
+
isLoggedIn() {
|
|
57
|
+
return !!this.getExpTime();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Calls the configured 'refresh' endpoint to attempt to refresh the access token cookie.
|
|
61
|
+
*/
|
|
62
|
+
async refreshToken() {
|
|
63
|
+
const path = !!this.config.tokenRefreshPath
|
|
64
|
+
? `${this.config.tokenRefreshPath}/${this.config.clientId}`
|
|
65
|
+
: `/app/refresh/${this.config.clientId}`;
|
|
66
|
+
const uri = this.getUrlForPath(path);
|
|
67
|
+
const resp = await fetch(uri.href, {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
credentials: 'include',
|
|
70
|
+
headers: {
|
|
71
|
+
'Content-Type': 'text/plain',
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (!(resp.status >= 200 && resp.status < 300)) {
|
|
75
|
+
throw new Error('error refreshing access token in fusionauth');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Invokes a redirect to the configured 'login' endpoint.
|
|
80
|
+
*/
|
|
81
|
+
startLogin(state) {
|
|
82
|
+
const path = !!this.config.loginPath
|
|
83
|
+
? this.config.loginPath
|
|
84
|
+
: '/app/login';
|
|
85
|
+
!!state ? this.doRedirectForPath(path, { state }) : this.doRedirectForPath(path);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Invokes a redirect to the configured 'refresh' endpoint.
|
|
89
|
+
*/
|
|
90
|
+
startRegistration(state) {
|
|
91
|
+
const path = !!this.config.registerPath
|
|
92
|
+
? this.config.registerPath
|
|
93
|
+
: '/app/register';
|
|
94
|
+
!!state ? this.doRedirectForPath(path, { state }) : this.doRedirectForPath(path);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Invokes a redirect to the configured 'logout' endpoint.
|
|
98
|
+
*/
|
|
99
|
+
logout() {
|
|
100
|
+
const path = !!this.config.logoutPath
|
|
101
|
+
? this.config.logoutPath
|
|
102
|
+
: '/app/logout';
|
|
103
|
+
this.doRedirectForPath(path);
|
|
104
|
+
}
|
|
105
|
+
doRedirectForPath(path, params = {}) {
|
|
106
|
+
path = path + `/${this.config.clientId}`;
|
|
107
|
+
if (this.config.redirectUri) {
|
|
108
|
+
params['redirect_uri'] = this.config.redirectUri;
|
|
109
|
+
}
|
|
110
|
+
let location = this.getUrlForPath(path, params);
|
|
111
|
+
window.location.assign(location);
|
|
112
|
+
}
|
|
113
|
+
getUrlForPath(path, params = {}) {
|
|
114
|
+
let url = new URL(this.config.serverUrl);
|
|
115
|
+
url.pathname = path;
|
|
116
|
+
if (Object.entries(params).length > 0) {
|
|
117
|
+
const urlParams = new URLSearchParams(params);
|
|
118
|
+
url.search = urlParams.toString();
|
|
119
|
+
}
|
|
120
|
+
return url;
|
|
121
|
+
}
|
|
122
|
+
getExpTime() {
|
|
123
|
+
const expCookie = document.cookie.split('; ')
|
|
124
|
+
.map(c => c.split('='))
|
|
125
|
+
.find(([name]) => name === 'app.at_exp');
|
|
126
|
+
return expCookie ? parseInt(expCookie[1]) * 1000 : null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
class FusionAuthLoginButtonComponent {
|
|
131
|
+
constructor(fusionAuth) {
|
|
132
|
+
this.fusionAuth = fusionAuth;
|
|
133
|
+
}
|
|
134
|
+
async login() {
|
|
135
|
+
if (!this.state) {
|
|
136
|
+
await this.fusionAuth.startLogin();
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
await this.fusionAuth.startLogin(this.state);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
FusionAuthLoginButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthLoginButtonComponent, deps: [{ token: FusionAuthService }], target: i0.ɵɵFactoryTarget.Component });
|
|
144
|
+
FusionAuthLoginButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: FusionAuthLoginButtonComponent, selector: "fa-login", inputs: { state: "state" }, ngImport: i0, template: "<button class=\"fa-button\" (click)=\"login()\">\n <span>Login</span>\n</button>\n", styles: [".fa-button{padding:16px 16px 13px;border-radius:8px;background-color:#083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:18px;font-weight:600;text-align:center;color:#fff;width:400px}.fa-button:hover{cursor:pointer}\n"] });
|
|
145
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthLoginButtonComponent, decorators: [{
|
|
146
|
+
type: Component,
|
|
147
|
+
args: [{ selector: 'fa-login', template: "<button class=\"fa-button\" (click)=\"login()\">\n <span>Login</span>\n</button>\n", styles: [".fa-button{padding:16px 16px 13px;border-radius:8px;background-color:#083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:18px;font-weight:600;text-align:center;color:#fff;width:400px}.fa-button:hover{cursor:pointer}\n"] }]
|
|
148
|
+
}], ctorParameters: function () { return [{ type: FusionAuthService }]; }, propDecorators: { state: [{
|
|
149
|
+
type: Input
|
|
150
|
+
}] } });
|
|
151
|
+
|
|
152
|
+
class FusionAuthLogoutButtonComponent {
|
|
153
|
+
constructor(fusionAuth) {
|
|
154
|
+
this.fusionAuth = fusionAuth;
|
|
155
|
+
}
|
|
156
|
+
logout() {
|
|
157
|
+
this.fusionAuth.logout();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
FusionAuthLogoutButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthLogoutButtonComponent, deps: [{ token: FusionAuthService }], target: i0.ɵɵFactoryTarget.Component });
|
|
161
|
+
FusionAuthLogoutButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: FusionAuthLogoutButtonComponent, selector: "fa-logout", ngImport: i0, template: "<button class=\"fa-logout-button\" (click)=\"logout()\">\n <span>logout</span>\n</button>\n", styles: [".fa-logout-button{padding:7px 13px;border-radius:3px;display:block;border:solid 1px #083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:12px;text-align:center;color:#083b94}.fa-logout-button:hover{cursor:pointer}\n"] });
|
|
162
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthLogoutButtonComponent, decorators: [{
|
|
163
|
+
type: Component,
|
|
164
|
+
args: [{ selector: 'fa-logout', template: "<button class=\"fa-logout-button\" (click)=\"logout()\">\n <span>logout</span>\n</button>\n", styles: [".fa-logout-button{padding:7px 13px;border-radius:3px;display:block;border:solid 1px #083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:12px;text-align:center;color:#083b94}.fa-logout-button:hover{cursor:pointer}\n"] }]
|
|
165
|
+
}], ctorParameters: function () { return [{ type: FusionAuthService }]; } });
|
|
166
|
+
|
|
167
|
+
class FusionAuthRegisterButtonComponent {
|
|
168
|
+
constructor(fusionAuth) {
|
|
169
|
+
this.fusionAuth = fusionAuth;
|
|
170
|
+
}
|
|
171
|
+
register() {
|
|
172
|
+
if (!this.state) {
|
|
173
|
+
this.fusionAuth.startRegistration();
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
this.fusionAuth.startRegistration(this.state);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
FusionAuthRegisterButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthRegisterButtonComponent, deps: [{ token: FusionAuthService }], target: i0.ɵɵFactoryTarget.Component });
|
|
181
|
+
FusionAuthRegisterButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: FusionAuthRegisterButtonComponent, selector: "fa-register", inputs: { state: "state" }, ngImport: i0, template: "<button class=\"fa-button\" (click)=\"register()\">\n <span>Register Now</span>\n</button>\n", styles: [".fa-button{padding:16px 16px 13px;border-radius:8px;background-color:#083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:18px;font-weight:600;text-align:center;color:#fff;width:400px}.fa-button:hover{cursor:pointer}\n"] });
|
|
182
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthRegisterButtonComponent, decorators: [{
|
|
183
|
+
type: Component,
|
|
184
|
+
args: [{ selector: 'fa-register', template: "<button class=\"fa-button\" (click)=\"register()\">\n <span>Register Now</span>\n</button>\n", styles: [".fa-button{padding:16px 16px 13px;border-radius:8px;background-color:#083b94;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol;font-size:18px;font-weight:600;text-align:center;color:#fff;width:400px}.fa-button:hover{cursor:pointer}\n"] }]
|
|
185
|
+
}], ctorParameters: function () { return [{ type: FusionAuthService }]; }, propDecorators: { state: [{
|
|
186
|
+
type: Input
|
|
187
|
+
}] } });
|
|
188
|
+
|
|
189
|
+
class FusionAuthModule {
|
|
190
|
+
static forRoot(fusionAuthConfig) {
|
|
191
|
+
return {
|
|
192
|
+
ngModule: FusionAuthModule,
|
|
193
|
+
providers: [
|
|
194
|
+
{ provide: FusionAuthService, useValue: new FusionAuthService(fusionAuthConfig) }
|
|
195
|
+
],
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
FusionAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
200
|
+
FusionAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthModule, declarations: [FusionAuthLoginButtonComponent,
|
|
201
|
+
FusionAuthLogoutButtonComponent,
|
|
202
|
+
FusionAuthRegisterButtonComponent], exports: [FusionAuthLoginButtonComponent,
|
|
203
|
+
FusionAuthLogoutButtonComponent,
|
|
204
|
+
FusionAuthRegisterButtonComponent] });
|
|
205
|
+
FusionAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthModule, imports: [[]] });
|
|
206
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FusionAuthModule, decorators: [{
|
|
207
|
+
type: NgModule,
|
|
208
|
+
args: [{
|
|
209
|
+
declarations: [
|
|
210
|
+
FusionAuthLoginButtonComponent,
|
|
211
|
+
FusionAuthLogoutButtonComponent,
|
|
212
|
+
FusionAuthRegisterButtonComponent,
|
|
213
|
+
],
|
|
214
|
+
imports: [],
|
|
215
|
+
exports: [
|
|
216
|
+
FusionAuthLoginButtonComponent,
|
|
217
|
+
FusionAuthLogoutButtonComponent,
|
|
218
|
+
FusionAuthRegisterButtonComponent,
|
|
219
|
+
]
|
|
220
|
+
}]
|
|
221
|
+
}] });
|
|
222
|
+
|
|
223
|
+
/*
|
|
224
|
+
* Public API Surface of fusionauth-angular-sdk
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Generated bundle index. Do not edit.
|
|
229
|
+
*/
|
|
230
|
+
|
|
231
|
+
export { FusionAuthLoginButtonComponent, FusionAuthLogoutButtonComponent, FusionAuthModule, FusionAuthRegisterButtonComponent, FusionAuthService };
|
|
232
|
+
//# sourceMappingURL=fusionauth-angular-sdk.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fusionauth-angular-sdk.mjs","sources":["../../../projects/fusionauth-angular-sdk/src/lib/fusion-auth.service.ts","../../../projects/fusionauth-angular-sdk/src/lib/components/fusionauth-login.button/fusion-auth-login-button.component.ts","../../../projects/fusionauth-angular-sdk/src/lib/components/fusionauth-login.button/fusion-auth-login-button.component.html","../../../projects/fusionauth-angular-sdk/src/lib/components/fusionauth-logout.button/fusion-auth-logout-button.component.ts","../../../projects/fusionauth-angular-sdk/src/lib/components/fusionauth-logout.button/fusion-auth-logout-button.component.html","../../../projects/fusionauth-angular-sdk/src/lib/components/fusionauth-register.button/fusion-auth-register-button.component.ts","../../../projects/fusionauth-angular-sdk/src/lib/components/fusionauth-register.button/fusion-auth-register-button.component.html","../../../projects/fusionauth-angular-sdk/src/lib/fusion-auth.module.ts","../../../projects/fusionauth-angular-sdk/src/public-api.ts","../../../projects/fusionauth-angular-sdk/src/fusionauth-angular-sdk.ts"],"sourcesContent":["import { FusionAuthConfig, UserInfo } from './types';\n\n/**\n * Service class to use with FusionAuth backend endpoints.\n */\nexport class FusionAuthService {\n\n constructor(\n private config: FusionAuthConfig,\n ) { }\n\n /**\n * Calls the 'me' endpoint to retrieve user info.\n * @return {Promise<UserInfo>} the user info response.\n */\n async getUserInfo(): Promise<UserInfo> {\n const path = !!this.config.mePath\n ? this.config.mePath\n : '/app/me';\n const uri = this.getUrlForPath(path);\n const resp = await fetch(uri.href, {\n credentials: 'include',\n });\n return JSON.parse(await resp.text()) as UserInfo;\n }\n\n /**\n * Checks for the 'app.at_exp' cookie and if present sets a timer to refresh the access token.\n * Will attempt to refresh the configured seconds before the access token expires (default is ten seconds).\n */\n initAutoRefresh(): void {\n const exp = this.getExpTime();\n if (exp) {\n const refreshBeforeSeconds = this.config.autoRefreshSecondsBeforeExpiry\n ? this.config.autoRefreshSecondsBeforeExpiry\n : 10;\n const now = new Date().getTime();\n const refreshTime = exp - (refreshBeforeSeconds * 1000);\n let timeTillThen = refreshTime - now;\n if (timeTillThen <= 0) {\n timeTillThen = 0;\n }\n setTimeout(async () => {\n try {\n await this.refreshToken();\n this.initAutoRefresh();\n } catch (e) {\n console.error(e)\n }\n }, timeTillThen);\n }\n }\n\n /**\n * Checks that the 'app.at_exp' cookie is present and for a time in the future to determine logged-in state.\n * @return {boolean} app.at_exp is present and not for a time in the past\n */\n isLoggedIn(): boolean {\n return !!this.getExpTime();\n }\n\n /**\n * Calls the configured 'refresh' endpoint to attempt to refresh the access token cookie.\n */\n async refreshToken(): Promise<void> {\n const path = !!this.config.tokenRefreshPath\n ? `${this.config.tokenRefreshPath}/${this.config.clientId}`\n : `/app/refresh/${this.config.clientId}`;\n const uri = this.getUrlForPath(path);\n const resp = await fetch(uri.href, {\n method: 'POST',\n credentials: 'include',\n headers: {\n 'Content-Type': 'text/plain',\n }\n });\n if (!(resp.status >= 200 && resp.status < 300)) {\n throw new Error('error refreshing access token in fusionauth');\n }\n }\n\n /**\n * Invokes a redirect to the configured 'login' endpoint.\n */\n startLogin(state?: string): void {\n const path = !!this.config.loginPath\n ? this.config.loginPath\n : '/app/login';\n !!state ? this.doRedirectForPath(path, {state}) : this.doRedirectForPath(path);\n }\n\n /**\n * Invokes a redirect to the configured 'refresh' endpoint.\n */\n startRegistration(state?: string): void {\n const path = !!this.config.registerPath\n ? this.config.registerPath\n : '/app/register';\n !!state ? this.doRedirectForPath(path, {state}) : this.doRedirectForPath(path);\n }\n\n /**\n * Invokes a redirect to the configured 'logout' endpoint.\n */\n logout(): void {\n const path = !!this.config.logoutPath\n ? this.config.logoutPath\n : '/app/logout';\n this.doRedirectForPath(path);\n }\n\n private doRedirectForPath(path: string, params: Record<string,any> = {}) {\n path = path + `/${this.config.clientId}`;\n if (this.config.redirectUri) {\n params['redirect_uri'] = this.config.redirectUri;\n }\n let location = this.getUrlForPath(path, params) ;\n window.location.assign(location);\n }\n\n private getUrlForPath(path: string, params: Record<string, any> = {}): URL {\n let url = new URL(this.config.serverUrl);\n url.pathname = path;\n if (Object.entries(params).length > 0) {\n const urlParams = new URLSearchParams(params);\n url.search = urlParams.toString();\n }\n return url;\n }\n\n private getExpTime(): number | null {\n const expCookie = document.cookie.split('; ')\n .map(c => c.split('='))\n .find(([name]) => name === 'app.at_exp');\n return expCookie ? parseInt(expCookie[1]) * 1000 : null;\n }\n}\n","import { Component, Input } from '@angular/core';\nimport { FusionAuthService } from '../../fusion-auth.service';\n\n@Component({\n selector: 'fa-login',\n templateUrl: './fusion-auth-login-button.component.html',\n styleUrls: ['./fusion-auth-login-button.component.scss']\n})\nexport class FusionAuthLoginButtonComponent {\n @Input() state: string | undefined;\n\n constructor(private fusionAuth: FusionAuthService) {}\n\n async login() {\n if (!this.state) {\n await this.fusionAuth.startLogin();\n } else {\n await this.fusionAuth.startLogin(this.state);\n }\n\n }\n}\n","<button class=\"fa-button\" (click)=\"login()\">\n <span>Login</span>\n</button>\n","import { Component } from '@angular/core';\nimport { FusionAuthService } from '../../fusion-auth.service';\n\n@Component({\n selector: 'fa-logout',\n templateUrl: './fusion-auth-logout-button.component.html',\n styleUrls: ['./fusion-auth-logout-button.component.scss']\n})\nexport class FusionAuthLogoutButtonComponent {\n constructor(\n private fusionAuth: FusionAuthService,\n ) {}\n\n logout() {\n this.fusionAuth.logout();\n }\n}\n","<button class=\"fa-logout-button\" (click)=\"logout()\">\n <span>logout</span>\n</button>\n","import { Component, Input } from '@angular/core';\nimport { FusionAuthService } from '../../fusion-auth.service';\n\n@Component({\n selector: 'fa-register',\n templateUrl: './fusion-auth-register-button.component.html',\n styleUrls: ['./fusion-auth-register-button.component.scss']\n})\nexport class FusionAuthRegisterButtonComponent {\n @Input() state: string | undefined;\n\n constructor(\n private fusionAuth: FusionAuthService,\n ) {}\n\n register() {\n if (!this.state) {\n this.fusionAuth.startRegistration();\n } else {\n this.fusionAuth.startRegistration(this.state);\n }\n }\n}\n","<button class=\"fa-button\" (click)=\"register()\">\n <span>Register Now</span>\n</button>\n","import { ModuleWithProviders, NgModule} from '@angular/core';\nimport { FusionAuthConfig } from './types';\nimport { FusionAuthService } from './fusion-auth.service';\nimport { FusionAuthLoginButtonComponent } from './components/fusionauth-login.button/fusion-auth-login-button.component';\nimport {\n FusionAuthLogoutButtonComponent\n} from './components/fusionauth-logout.button/fusion-auth-logout-button.component';\nimport {\n FusionAuthRegisterButtonComponent\n} from './components/fusionauth-register.button/fusion-auth-register-button.component';\n\n@NgModule({\n declarations: [\n FusionAuthLoginButtonComponent,\n FusionAuthLogoutButtonComponent,\n FusionAuthRegisterButtonComponent,\n ],\n imports: [\n ],\n exports: [\n FusionAuthLoginButtonComponent,\n FusionAuthLogoutButtonComponent,\n FusionAuthRegisterButtonComponent,\n ]\n})\nexport class FusionAuthModule {\n static forRoot(fusionAuthConfig: FusionAuthConfig): ModuleWithProviders<FusionAuthModule> {\n return {\n ngModule: FusionAuthModule,\n providers: [\n { provide: FusionAuthService, useValue: new FusionAuthService(fusionAuthConfig) }\n ],\n }\n }\n}\n","/*\n * Public API Surface of fusionauth-angular-sdk\n */\n\nexport * from './lib/fusion-auth.service';\nexport * from './lib/components/fusionauth-login.button/fusion-auth-login-button.component';\nexport * from './lib/components/fusionauth-logout.button/fusion-auth-logout-button.component';\nexport * from './lib/components/fusionauth-register.button/fusion-auth-register-button.component';\nexport * from './lib/fusion-auth.module';\nexport * from './lib/types';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.FusionAuthService"],"mappings":";;;AAEA;;AAEG;MACU,iBAAiB,CAAA;AAE5B,IAAA,WAAA,CACU,MAAwB,EAAA;QAAxB,IAAM,CAAA,MAAA,GAAN,MAAM,CAAkB;KAC7B;AAEL;;;AAGG;AACH,IAAA,MAAM,WAAW,GAAA;QACf,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAA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CAAA;4FAOU,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAd5B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE;wBACZ,8BAA8B;wBAC9B,+BAA+B;wBAC/B,iCAAiC;AAClC,qBAAA;AACD,oBAAA,OAAO,EAAE,EACR;AACD,oBAAA,OAAO,EAAE;wBACP,8BAA8B;wBAC9B,+BAA+B;wBAC/B,iCAAiC;AAClC,qBAAA;AACF,iBAAA,CAAA;;;ACxBD;;AAEG;;ACFH;;AAEG;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FusionAuthService } from '../../fusion-auth.service';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class FusionAuthLoginButtonComponent {
|
|
4
|
+
private fusionAuth;
|
|
5
|
+
state: string | undefined;
|
|
6
|
+
constructor(fusionAuth: FusionAuthService);
|
|
7
|
+
login(): Promise<void>;
|
|
8
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FusionAuthLoginButtonComponent, never>;
|
|
9
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<FusionAuthLoginButtonComponent, "fa-login", never, { "state": "state"; }, {}, never, never>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FusionAuthService } from '../../fusion-auth.service';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class FusionAuthLogoutButtonComponent {
|
|
4
|
+
private fusionAuth;
|
|
5
|
+
constructor(fusionAuth: FusionAuthService);
|
|
6
|
+
logout(): void;
|
|
7
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FusionAuthLogoutButtonComponent, never>;
|
|
8
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<FusionAuthLogoutButtonComponent, "fa-logout", never, {}, {}, never, never>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FusionAuthService } from '../../fusion-auth.service';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class FusionAuthRegisterButtonComponent {
|
|
4
|
+
private fusionAuth;
|
|
5
|
+
state: string | undefined;
|
|
6
|
+
constructor(fusionAuth: FusionAuthService);
|
|
7
|
+
register(): void;
|
|
8
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FusionAuthRegisterButtonComponent, never>;
|
|
9
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<FusionAuthRegisterButtonComponent, "fa-register", never, { "state": "state"; }, {}, never, never>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ModuleWithProviders } from '@angular/core';
|
|
2
|
+
import { FusionAuthConfig } from './types';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import * as i1 from "./components/fusionauth-login.button/fusion-auth-login-button.component";
|
|
5
|
+
import * as i2 from "./components/fusionauth-logout.button/fusion-auth-logout-button.component";
|
|
6
|
+
import * as i3 from "./components/fusionauth-register.button/fusion-auth-register-button.component";
|
|
7
|
+
export declare class FusionAuthModule {
|
|
8
|
+
static forRoot(fusionAuthConfig: FusionAuthConfig): ModuleWithProviders<FusionAuthModule>;
|
|
9
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FusionAuthModule, never>;
|
|
10
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<FusionAuthModule, [typeof i1.FusionAuthLoginButtonComponent, typeof i2.FusionAuthLogoutButtonComponent, typeof i3.FusionAuthRegisterButtonComponent], never, [typeof i1.FusionAuthLoginButtonComponent, typeof i2.FusionAuthLogoutButtonComponent, typeof i3.FusionAuthRegisterButtonComponent]>;
|
|
11
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<FusionAuthModule>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { FusionAuthConfig, UserInfo } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Service class to use with FusionAuth backend endpoints.
|
|
4
|
+
*/
|
|
5
|
+
export declare class FusionAuthService {
|
|
6
|
+
private config;
|
|
7
|
+
constructor(config: FusionAuthConfig);
|
|
8
|
+
/**
|
|
9
|
+
* Calls the 'me' endpoint to retrieve user info.
|
|
10
|
+
* @return {Promise<UserInfo>} the user info response.
|
|
11
|
+
*/
|
|
12
|
+
getUserInfo(): Promise<UserInfo>;
|
|
13
|
+
/**
|
|
14
|
+
* Checks for the 'app.at_exp' cookie and if present sets a timer to refresh the access token.
|
|
15
|
+
* Will attempt to refresh the configured seconds before the access token expires (default is ten seconds).
|
|
16
|
+
*/
|
|
17
|
+
initAutoRefresh(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Checks that the 'app.at_exp' cookie is present and for a time in the future to determine logged-in state.
|
|
20
|
+
* @return {boolean} app.at_exp is present and not for a time in the past
|
|
21
|
+
*/
|
|
22
|
+
isLoggedIn(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Calls the configured 'refresh' endpoint to attempt to refresh the access token cookie.
|
|
25
|
+
*/
|
|
26
|
+
refreshToken(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Invokes a redirect to the configured 'login' endpoint.
|
|
29
|
+
*/
|
|
30
|
+
startLogin(state?: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Invokes a redirect to the configured 'refresh' endpoint.
|
|
33
|
+
*/
|
|
34
|
+
startRegistration(state?: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* Invokes a redirect to the configured 'logout' endpoint.
|
|
37
|
+
*/
|
|
38
|
+
logout(): void;
|
|
39
|
+
private doRedirectForPath;
|
|
40
|
+
private getUrlForPath;
|
|
41
|
+
private getExpTime;
|
|
42
|
+
}
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface FusionAuthConfig {
|
|
2
|
+
serverUrl: string;
|
|
3
|
+
clientId: string;
|
|
4
|
+
redirectUri?: string;
|
|
5
|
+
autoRefreshSecondsBeforeExpiry?: number;
|
|
6
|
+
loginPath?: string;
|
|
7
|
+
logoutPath?: string;
|
|
8
|
+
registerPath?: string;
|
|
9
|
+
tokenRefreshPath?: string;
|
|
10
|
+
mePath?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface UserInfo {
|
|
13
|
+
applicationId?: string;
|
|
14
|
+
email?: string;
|
|
15
|
+
email_verified?: boolean;
|
|
16
|
+
family_name?: string;
|
|
17
|
+
given_name?: string;
|
|
18
|
+
picture?: string;
|
|
19
|
+
roles?: any[];
|
|
20
|
+
sid?: string;
|
|
21
|
+
sub?: string;
|
|
22
|
+
tid?: string;
|
|
23
|
+
phone_number?: string;
|
|
24
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fusionauth/angular-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"peerDependencies": {
|
|
6
|
+
"@angular/common": "^13.3.0",
|
|
7
|
+
"@angular/core": "^13.3.0"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"tslib": "^2.3.0"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"repository": "git@github.com:FusionAuth/fusionauth-angular-sdk.git",
|
|
16
|
+
"module": "fesm2015/fusionauth-angular-sdk.mjs",
|
|
17
|
+
"es2020": "fesm2020/fusionauth-angular-sdk.mjs",
|
|
18
|
+
"esm2020": "esm2020/fusionauth-angular-sdk.mjs",
|
|
19
|
+
"fesm2020": "fesm2020/fusionauth-angular-sdk.mjs",
|
|
20
|
+
"fesm2015": "fesm2015/fusionauth-angular-sdk.mjs",
|
|
21
|
+
"typings": "fusionauth-angular-sdk.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
"./package.json": {
|
|
24
|
+
"default": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./fusionauth-angular-sdk.d.ts",
|
|
28
|
+
"esm2020": "./esm2020/fusionauth-angular-sdk.mjs",
|
|
29
|
+
"es2020": "./fesm2020/fusionauth-angular-sdk.mjs",
|
|
30
|
+
"es2015": "./fesm2015/fusionauth-angular-sdk.mjs",
|
|
31
|
+
"node": "./fesm2015/fusionauth-angular-sdk.mjs",
|
|
32
|
+
"default": "./fesm2020/fusionauth-angular-sdk.mjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"sideEffects": false
|
|
36
|
+
}
|
package/public-api.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './lib/fusion-auth.service';
|
|
2
|
+
export * from './lib/components/fusionauth-login.button/fusion-auth-login-button.component';
|
|
3
|
+
export * from './lib/components/fusionauth-logout.button/fusion-auth-logout-button.component';
|
|
4
|
+
export * from './lib/components/fusionauth-register.button/fusion-auth-register-button.component';
|
|
5
|
+
export * from './lib/fusion-auth.module';
|
|
6
|
+
export * from './lib/types';
|