File tree Expand file tree Collapse file tree 12 files changed +259
-3
lines changed Expand file tree Collapse file tree 12 files changed +259
-3
lines changed Original file line number Diff line number Diff line change
1
+ import { IFlow } from './Flows/IFlow'
2
+
3
+ export class FlowFactory {
4
+ public IFlow getFlow ( type :string ) {
5
+ return null ;
6
+ }
7
+
8
+ public addCustomFlow ( type :string , render :function ( ) :any ) :void {
9
+
10
+ }
11
+ }
Original file line number Diff line number Diff line change
1
+ import { ScopeBaseFlow } from './ScopeBaseFlow'
2
+ import { IFlowHandler } from '../IFlowHandler'
3
+
4
+ /**
5
+ * Represents a authorization code flow.
6
+ */
7
+ export class AuthorizationCodeFlow extends ScopeBaseFlow {
8
+ constructor ( ) {
9
+ super ( 'authorization_code' ) ;
10
+ }
11
+
12
+ /**
13
+ * Execute the flow and handle it with the given handler.
14
+ * @param handler Represents the handler for the flow.
15
+ */
16
+ public execute ( handler :IFlowHandler ) :void {
17
+
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ import { IFlow } from './IFlow'
2
+ import { IFlowHandler } from '../IFlowHandler'
3
+
4
+ /**
5
+ * Represents a base class for the oAuth flows.
6
+ */
7
+ export abstract class BaseFlow implements IFlow {
8
+ /**
9
+ * Construct a new base flow [BaseFP] with the given type.
10
+ * @param type Represents the type of the flow processor.
11
+ */
12
+ constructor ( type :string ) {
13
+ this . _type = type ;
14
+ }
15
+
16
+ private _type :string ;
17
+
18
+ /**
19
+ * Get the oAuth flow type.
20
+ */
21
+ get type ( ) { return this . _type ; }
22
+
23
+ /**
24
+ * Get or set the client id with which the flow get the result.
25
+ */
26
+ public clientId : string ;
27
+
28
+ /**
29
+ * Execute the flow and handle it with the given handler.
30
+ * @param handler Represents the handler for the flow.
31
+ */
32
+ public abstract execute ( handler :IFlowHandler ) :void ;
33
+ }
Original file line number Diff line number Diff line change
1
+ import { BaseFlow } from './BaseFlow'
2
+ import { IFlowHandler } from '../IFlowHandler'
3
+
4
+ /**
5
+ * Represents a client credential flow.
6
+ */
7
+ export class ClientCredetialFlow extends BaseFlow {
8
+ constructor ( ) {
9
+ super ( 'client_credential' )
10
+ }
11
+
12
+ /**
13
+ * Get or set the client secret for the flow authentication.
14
+ */
15
+ public clientSecret :string ;
16
+
17
+ /**
18
+ * Execute the flow and handle it with the given handler.
19
+ * @param handler Represents the handler for the flow.
20
+ */
21
+ public execute ( handler :IFlowHandler ) :void {
22
+
23
+
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ import { BaseFlow } from './BaseFlow'
2
+ import { IFlowHandler } from '../IFlowHandler'
3
+
4
+ /**
5
+ * Represents a code exchange flow.
6
+ */
7
+ export class CodeExchangeFlow extends BaseFlow {
8
+ constructor ( ) {
9
+ super ( 'code_exchange' ) ;
10
+ }
11
+
12
+ /**
13
+ * Get or set the code generated by the authorization code flow.
14
+ */
15
+ public code :string ;
16
+
17
+ /**
18
+ * Get or set the redirection url used in the authorization code flow.
19
+ */
20
+ public redirectUri :string ;
21
+
22
+ /**
23
+ * Get or set the client secret for the flow authentication.
24
+ */
25
+ public clientSecret :string ;
26
+
27
+ /**
28
+ * Execute the flow and handle it with the given handler.
29
+ * @param handler Represents the handler for the flow.
30
+ */
31
+ public execute ( handler :IFlowHandler ) :void {
32
+
33
+
34
+ }
35
+ }
Original file line number Diff line number Diff line change
1
+ import { IFlowHandler } from '../IFlowHandler'
2
+
3
+ /**
4
+ * Represents a oAuth flow.
5
+ */
6
+ export interface IFlow {
7
+ /**
8
+ * Execute the flow and handle it with the given handler.
9
+ */
10
+ execute ( handler :IFlowHandler ) :void
11
+ }
Original file line number Diff line number Diff line change
1
+ import { ScopeBaseFlow } from './ScopeBaseFlow'
2
+ import { IFlowHandler } from '../IFlowHandler'
3
+
4
+ /**
5
+ * Represents a implicit flow.
6
+ */
7
+ export class AuthorizationCodeFlow extends ScopeBaseFlow {
8
+ constructor ( ) {
9
+ super ( 'implicit' ) ;
10
+ }
11
+
12
+ /**
13
+ * Execute the flow and handle it with the given handler.
14
+ * @param handler Represents the handler for the flow.
15
+ */
16
+ public execute ( handler :IFlowHandler ) :void {
17
+
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ import { BaseFlow } from './BaseFlow'
2
+ import { IFlowHandler } from '../IFlowHandler'
3
+
4
+ /**
5
+ * Represents the password flow.
6
+ */
7
+ export class PasswordFlow extends BaseFlow {
8
+ constructor ( ) {
9
+ super ( 'password' )
10
+ }
11
+
12
+ /**
13
+ * Represents the user name to authenticate;
14
+ */
15
+ public username :string ;
16
+ /**
17
+ * Represents the password of the user name to authenticate;
18
+ */
19
+ public password :string ;
20
+
21
+ /**
22
+ * Execute the flow and handle it with the given handler.
23
+ * @param handler Represents the handler for the flow.
24
+ */
25
+ public execute ( handler :IFlowHandler ) :void {
26
+
27
+
28
+ }
29
+ }
Original file line number Diff line number Diff line change
1
+ import { BaseFlow } from './BaseFlow'
2
+ import { IFlowHandler } from '../IFlowHandler'
3
+
4
+ /**
5
+ * Represents a base class for scoped based oAuth flows.
6
+ */
7
+ export abstract class ScopeBaseFlow extends BaseFlow {
8
+ constructor ( type :string ) {
9
+ super ( type ) ;
10
+ }
11
+
12
+ /**
13
+ * Get or set the state to validate the authenticity when is compared with the result state.
14
+ */
15
+ public state :string ;
16
+
17
+ /**
18
+ * Get or set the redirection url used in the authorization code flow.
19
+ */
20
+ public redirectUri :string ;
21
+
22
+ /**
23
+ * Get or set the requested scopes.
24
+ */
25
+ public scopes :string [ ] ;
26
+
27
+ /**
28
+ * Execute the flow and handle it with the given handler.
29
+ * @param handler Represents the handler for the flow.
30
+ */
31
+ public abstract execute ( handler :IFlowHandler ) :void ;
32
+ }
Original file line number Diff line number Diff line change
1
+ import { FlowResult } from './Models/FlowResult'
2
+
3
+ /**
4
+ * Represent a handler for the flows.
5
+ */
6
+ export interface IFlowHandler {
7
+ /**
8
+ * Redirect the request to another page, usually the authorization page.
9
+ */
10
+ redirect ( url :string ) :void
11
+ /**
12
+ * Return the flow result to the requester client.
13
+ */
14
+ return ( result :FlowResult ) :void
15
+ /**
16
+ * Notify an error that may occur.
17
+ */
18
+ notifyError ( error :string ) :void
19
+ }
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Represents a result of a direct flow execution.
3
+ */
4
+ export class FlowResult {
5
+ /**
6
+ * Represents the access token generated by the flow excecution.
7
+ */
8
+ public accessToken :string ;
9
+ /**
10
+ * Represents the refresh token generated by the flow excecution.
11
+ */
12
+ public refreshToken :string ;
13
+ /**
14
+ *Represents the time in which the access token will expire.
15
+ */
16
+ public expireIn :number ;
17
+ /**
18
+ * Represents an state to validate the authenticity of the response result.
19
+ */
20
+ public state :string ;
21
+ }
Original file line number Diff line number Diff line change 1
- export class Main {
2
-
3
- }
1
+
2
+ export { FMBase } from './Models/FMBase'
3
+
4
+
5
+
You can’t perform that action at this time.
0 commit comments