@owox/idp-protocol 0.4.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 +298 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/middleware/index.d.ts +2 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +1 -0
- package/dist/middleware/protocol-middleware.d.ts +99 -0
- package/dist/middleware/protocol-middleware.d.ts.map +1 -0
- package/dist/middleware/protocol-middleware.js +131 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +1 -0
- package/dist/providers/null-provider.d.ts +24 -0
- package/dist/providers/null-provider.d.ts.map +1 -0
- package/dist/providers/null-provider.js +58 -0
- package/dist/types/cli.d.ts +27 -0
- package/dist/types/cli.d.ts.map +1 -0
- package/dist/types/cli.js +1 -0
- package/dist/types/config.d.ts +14 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +1 -0
- package/dist/types/errors.d.ts +33 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +45 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +13 -0
- package/dist/types/models.d.ts +24 -0
- package/dist/types/models.d.ts.map +1 -0
- package/dist/types/models.js +1 -0
- package/dist/types/provider.d.ts +63 -0
- package/dist/types/provider.d.ts.map +1 -0
- package/dist/types/provider.js +1 -0
- package/package.json +52 -0
- package/src/index.ts +8 -0
- package/src/middleware/index.ts +1 -0
- package/src/middleware/protocol-middleware.ts +178 -0
- package/src/providers/index.ts +1 -0
- package/src/providers/null-provider.ts +71 -0
- package/src/types/cli.ts +30 -0
- package/src/types/config.ts +14 -0
- package/src/types/errors.ts +49 -0
- package/src/types/index.ts +18 -0
- package/src/types/models.ts +28 -0
- package/src/types/provider.ts +72 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The roles that are supported by the IDP.
|
|
3
|
+
*/
|
|
4
|
+
export type Role = 'admin' | 'editor' | 'viewer';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Standardized token payload that all IDP implementations must return when introspecting their native tokens.
|
|
8
|
+
*/
|
|
9
|
+
export interface Payload {
|
|
10
|
+
userId: string;
|
|
11
|
+
projectId: string;
|
|
12
|
+
|
|
13
|
+
email?: string;
|
|
14
|
+
fullName?: string;
|
|
15
|
+
avatar?: string;
|
|
16
|
+
|
|
17
|
+
roles?: Role[];
|
|
18
|
+
|
|
19
|
+
projectTitle?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Authentication result from IDP callback
|
|
24
|
+
*/
|
|
25
|
+
export interface AuthResult {
|
|
26
|
+
accessToken: string;
|
|
27
|
+
refreshToken?: string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Payload, AuthResult } from './models.js';
|
|
2
|
+
import { NextFunction, Request, Response } from 'express';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Simplified IDP Provider interface.
|
|
6
|
+
*/
|
|
7
|
+
export interface IdpProvider {
|
|
8
|
+
/**
|
|
9
|
+
* Sign in middleware. This method is used to handle the sign in request and use response to send the sign in response.
|
|
10
|
+
* <br/>
|
|
11
|
+
* If the IDP implementation does not support sign in, this method should call the `next()` function.
|
|
12
|
+
*/
|
|
13
|
+
signInMiddleware(req: Request, res: Response, next: NextFunction): Promise<void | Response>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Sign out middleware. This method is used to handle the sign out request and use response to send the sign out response.
|
|
17
|
+
* <br/>
|
|
18
|
+
* If the IDP implementation does not support sign out, this method should call the `next()` function.
|
|
19
|
+
*/
|
|
20
|
+
signOutMiddleware(req: Request, res: Response, next: NextFunction): Promise<void | Response>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Access token middleware. This method is used to handle the access token request and use response to send the access token response.
|
|
24
|
+
* <br/>
|
|
25
|
+
* If the IDP implementation does not support access token, this method should call the `next()` function.
|
|
26
|
+
*/
|
|
27
|
+
accessTokenMiddleware(req: Request, res: Response, next: NextFunction): Promise<void | Response>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* User api middleware. This method is used to handle the user request and use response to send the user response.
|
|
31
|
+
* <br/>
|
|
32
|
+
* If the IDP implementation does not support user, this method should call the `next()` function.
|
|
33
|
+
*/
|
|
34
|
+
userApiMiddleware(req: Request, res: Response, next: NextFunction): Promise<Response<Payload>>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Introspect a token
|
|
38
|
+
* @param token - The token to introspect
|
|
39
|
+
* @returns The token payload
|
|
40
|
+
*/
|
|
41
|
+
introspectToken(token: string): Promise<Payload | null>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Parse a token
|
|
45
|
+
* @param token - The token to parse
|
|
46
|
+
* @returns The token payload
|
|
47
|
+
*/
|
|
48
|
+
parseToken(token: string): Promise<Payload | null>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Refresh a token
|
|
52
|
+
* @param refreshToken - The refresh token to use for the refresh
|
|
53
|
+
* @returns The authentication result
|
|
54
|
+
*/
|
|
55
|
+
refreshToken(refreshToken: string): Promise<AuthResult>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Revoke a token. In different IDP implementations, this may have different token types.
|
|
59
|
+
* @param token - The token to revoke
|
|
60
|
+
*/
|
|
61
|
+
revokeToken(token: string): Promise<void>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Initialize the IDP. Create resources, connect to databases, etc.
|
|
65
|
+
*/
|
|
66
|
+
initialize(): Promise<void>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Shutdown the IDP, close all connections and release resources
|
|
70
|
+
*/
|
|
71
|
+
shutdown(): Promise<void>;
|
|
72
|
+
}
|