@celljs/oauth2-core 3.0.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.
Files changed (89) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/cell.yml +0 -0
  4. package/lib/node/authentication/authentication-protocol.d.ts +11 -0
  5. package/lib/node/authentication/authentication-protocol.d.ts.map +1 -0
  6. package/lib/node/authentication/authentication-protocol.js +16 -0
  7. package/lib/node/authentication/authentication-protocol.js.map +1 -0
  8. package/lib/node/authentication/index.d.ts +2 -0
  9. package/lib/node/authentication/index.d.ts.map +1 -0
  10. package/lib/node/authentication/index.js +18 -0
  11. package/lib/node/authentication/index.js.map +1 -0
  12. package/lib/node/authorization/authorization-protocol.d.ts +12 -0
  13. package/lib/node/authorization/authorization-protocol.d.ts.map +1 -0
  14. package/lib/node/authorization/authorization-protocol.js +17 -0
  15. package/lib/node/authorization/authorization-protocol.js.map +1 -0
  16. package/lib/node/authorization/index.d.ts +2 -0
  17. package/lib/node/authorization/index.d.ts.map +1 -0
  18. package/lib/node/authorization/index.js +18 -0
  19. package/lib/node/authorization/index.js.map +1 -0
  20. package/lib/node/endpoint/access-token-response-converter.d.ts +17 -0
  21. package/lib/node/endpoint/access-token-response-converter.d.ts.map +1 -0
  22. package/lib/node/endpoint/access-token-response-converter.js +70 -0
  23. package/lib/node/endpoint/access-token-response-converter.js.map +1 -0
  24. package/lib/node/endpoint/endpoint-protocol.d.ts +129 -0
  25. package/lib/node/endpoint/endpoint-protocol.d.ts.map +1 -0
  26. package/lib/node/endpoint/endpoint-protocol.js +97 -0
  27. package/lib/node/endpoint/endpoint-protocol.js.map +1 -0
  28. package/lib/node/endpoint/index.d.ts +3 -0
  29. package/lib/node/endpoint/index.d.ts.map +1 -0
  30. package/lib/node/endpoint/index.js +19 -0
  31. package/lib/node/endpoint/index.js.map +1 -0
  32. package/lib/node/error/error-protocol.d.ts +81 -0
  33. package/lib/node/error/error-protocol.d.ts.map +1 -0
  34. package/lib/node/error/error-protocol.js +85 -0
  35. package/lib/node/error/error-protocol.js.map +1 -0
  36. package/lib/node/error/error.d.ts +12 -0
  37. package/lib/node/error/error.d.ts.map +1 -0
  38. package/lib/node/error/error.js +20 -0
  39. package/lib/node/error/error.js.map +1 -0
  40. package/lib/node/error/index.d.ts +3 -0
  41. package/lib/node/error/index.d.ts.map +1 -0
  42. package/lib/node/error/index.js +19 -0
  43. package/lib/node/error/index.js.map +1 -0
  44. package/lib/node/index.d.ts +7 -0
  45. package/lib/node/index.d.ts.map +1 -0
  46. package/lib/node/index.js +23 -0
  47. package/lib/node/index.js.map +1 -0
  48. package/lib/node/module.d.ts +4 -0
  49. package/lib/node/module.d.ts.map +1 -0
  50. package/lib/node/module.js +6 -0
  51. package/lib/node/module.js.map +1 -0
  52. package/lib/node/oidc/index.d.ts +2 -0
  53. package/lib/node/oidc/index.d.ts.map +1 -0
  54. package/lib/node/oidc/index.js +18 -0
  55. package/lib/node/oidc/index.js.map +1 -0
  56. package/lib/node/oidc/oidc-protocol.d.ts +117 -0
  57. package/lib/node/oidc/oidc-protocol.d.ts.map +1 -0
  58. package/lib/node/oidc/oidc-protocol.js +123 -0
  59. package/lib/node/oidc/oidc-protocol.js.map +1 -0
  60. package/lib/node/token/index.d.ts +2 -0
  61. package/lib/node/token/index.d.ts.map +1 -0
  62. package/lib/node/token/index.js +18 -0
  63. package/lib/node/token/index.js.map +1 -0
  64. package/lib/node/token/token-protocol.d.ts +66 -0
  65. package/lib/node/token/token-protocol.d.ts.map +1 -0
  66. package/lib/node/token/token-protocol.js +60 -0
  67. package/lib/node/token/token-protocol.js.map +1 -0
  68. package/lib/package.spec.d.ts +1 -0
  69. package/lib/package.spec.d.ts.map +1 -0
  70. package/lib/package.spec.js +4 -0
  71. package/lib/package.spec.js.map +1 -0
  72. package/package.json +45 -0
  73. package/src/node/authentication/authentication-protocol.ts +11 -0
  74. package/src/node/authentication/index.ts +1 -0
  75. package/src/node/authorization/authorization-protocol.ts +12 -0
  76. package/src/node/authorization/index.ts +1 -0
  77. package/src/node/endpoint/access-token-response-converter.ts +64 -0
  78. package/src/node/endpoint/endpoint-protocol.ts +150 -0
  79. package/src/node/endpoint/index.ts +2 -0
  80. package/src/node/error/error-protocol.ts +93 -0
  81. package/src/node/error/error.ts +19 -0
  82. package/src/node/error/index.ts +2 -0
  83. package/src/node/index.ts +6 -0
  84. package/src/node/module.ts +4 -0
  85. package/src/node/oidc/index.ts +1 -0
  86. package/src/node/oidc/oidc-protocol.ts +148 -0
  87. package/src/node/token/index.ts +1 -0
  88. package/src/node/token/token-protocol.ts +81 -0
  89. package/src/package.spec.ts +4 -0
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IdTokenClaimNames = exports.TokenType = void 0;
4
+ var TokenType;
5
+ (function (TokenType) {
6
+ TokenType["Bearer"] = "Bearer";
7
+ })(TokenType = exports.TokenType || (exports.TokenType = {}));
8
+ var IdTokenClaimNames;
9
+ (function (IdTokenClaimNames) {
10
+ /**
11
+ * {@code iss} - the Issuer identifier
12
+ */
13
+ IdTokenClaimNames.ISS = 'iss';
14
+ /**
15
+ * {@code sub} - the Subject identifier
16
+ */
17
+ IdTokenClaimNames.SUB = 'sub';
18
+ /**
19
+ * {@code aud} - the Audience(s) that the ID Token is intended for
20
+ */
21
+ IdTokenClaimNames.AUD = 'aud';
22
+ /**
23
+ * {@code exp} - the Expiration time on or after which the ID Token MUST NOT be accepted
24
+ */
25
+ IdTokenClaimNames.EXP = 'exp';
26
+ /**
27
+ * {@code iat} - the time at which the ID Token was issued
28
+ */
29
+ IdTokenClaimNames.IAT = 'iat';
30
+ /**
31
+ * {@code auth_time} - the time when the End-User authentication occurred
32
+ */
33
+ IdTokenClaimNames.AUTH_TIME = 'auth_time';
34
+ /**
35
+ * {@code nonce} - a {@code export const} value used to associate a Client session with an ID Token,
36
+ * and to mitigate replay attacks.
37
+ */
38
+ IdTokenClaimNames.NONCE = 'nonce';
39
+ /**
40
+ * {@code acr} - the Authentication Context Class Reference
41
+ */
42
+ IdTokenClaimNames.ACR = 'acr';
43
+ /**
44
+ * {@code amr} - the Authentication Methods References
45
+ */
46
+ IdTokenClaimNames.AMR = 'amr';
47
+ /**
48
+ * {@code azp} - the Authorized party to which the ID Token was issued
49
+ */
50
+ IdTokenClaimNames.AZP = 'azp';
51
+ /**
52
+ * {@code at_hash} - the Access Token hash value
53
+ */
54
+ IdTokenClaimNames.AT_HASH = 'at_hash';
55
+ /**
56
+ * {@code c_hash} - the Authorization Code hash value
57
+ */
58
+ IdTokenClaimNames.C_HASH = 'c_hash';
59
+ })(IdTokenClaimNames = exports.IdTokenClaimNames || (exports.IdTokenClaimNames = {}));
60
+ //# sourceMappingURL=token-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-protocol.js","sourceRoot":"","sources":["../../../src/node/token/token-protocol.ts"],"names":[],"mappings":";;;AAKA,IAAY,SAEX;AAFD,WAAY,SAAS;IACjB,8BAAiB,CAAA;AACrB,CAAC,EAFW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAEpB;AAUD,IAAiB,iBAAiB,CA+DjC;AA/DD,WAAiB,iBAAiB;IAE9B;;OAEG;IACU,qBAAG,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACU,qBAAG,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACU,qBAAG,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACU,qBAAG,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACU,qBAAG,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACU,2BAAS,GAAG,WAAW,CAAC;IAErC;;;OAGG;IACU,uBAAK,GAAG,OAAO,CAAC;IAE7B;;OAEG;IACU,qBAAG,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACU,qBAAG,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACU,qBAAG,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACU,yBAAO,GAAG,SAAS,CAAC;IAEjC;;OAEG;IACU,wBAAM,GAAG,QAAQ,CAAC;AAEnC,CAAC,EA/DgB,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QA+DjC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=package.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.spec.d.ts","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ describe('oauth2 core package', () => {
2
+ it('support code coverage statistics', () => { });
3
+ });
4
+ //# sourceMappingURL=package.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.spec.js","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":"AAAA,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IAEjC,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@celljs/oauth2-core",
3
+ "version": "3.0.0",
4
+ "description": "",
5
+ "main": "lib/node/index.js",
6
+ "typings": "lib/node/index.d.ts",
7
+ "dependencies": {
8
+ "@celljs/core": "3.0.0",
9
+ "@celljs/security": "3.0.0",
10
+ "@celljs/web": "3.0.0"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "keywords": [
16
+ "cell-component"
17
+ ],
18
+ "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/cellbang/cell.git"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/cellbang/cell/issues"
25
+ },
26
+ "homepage": "https://github.com/cellbang/cell",
27
+ "files": [
28
+ "lib",
29
+ "src",
30
+ "cell.yml"
31
+ ],
32
+ "scripts": {
33
+ "lint": "cell-component lint",
34
+ "build": "cell-component build",
35
+ "watch": "cell-component watch",
36
+ "clean": "cell-component clean",
37
+ "test": "cell-component test:js"
38
+ },
39
+ "devDependencies": {
40
+ "@celljs/component": "3.0.0",
41
+ "@types/crypto-js": "^3.1.47",
42
+ "@types/jexl": "^2.1.0"
43
+ },
44
+ "gitHead": "c0ef8d269e33a795406bcbb240cac4b845c6c24c"
45
+ }
@@ -0,0 +1,11 @@
1
+ export enum AuthenticationMethod {
2
+ Header = 'header',
3
+ Form = 'form',
4
+ Query = 'query'
5
+ }
6
+
7
+ export enum ClientAuthenticationMethod {
8
+ Basic = 'basic',
9
+ Post = 'post',
10
+ None = 'none'
11
+ }
@@ -0,0 +1 @@
1
+ export * from './authentication-protocol';
@@ -0,0 +1,12 @@
1
+ export enum AuthorizationGrantType {
2
+ AuthorizationCode = 'authorization_code',
3
+ Implicit = 'implicit',
4
+ RefreshToken = 'refresh_token',
5
+ ClientCredentials = 'client_credentials',
6
+ Password = 'password'
7
+ }
8
+
9
+ export enum AuthorizationResponseType {
10
+ Code = 'code',
11
+ Token = 'token'
12
+ }
@@ -0,0 +1 @@
1
+ export * from './authorization-protocol';
@@ -0,0 +1,64 @@
1
+ import { TokenType } from '../token';
2
+ import { AccessTokenResponse, OAuth2ParameterNames } from './endpoint-protocol';
3
+ import { Component } from '@celljs/core';
4
+
5
+ @Component(AccessTokenResponseConverter)
6
+ export class AccessTokenResponseConverter {
7
+ convert(tokenResponse: { [key: string]: string }): AccessTokenResponse {
8
+ const accessToken = tokenResponse[OAuth2ParameterNames.ACCESS_TOKEN];
9
+ const tokenType = this.getAccessTokenType(tokenResponse);
10
+ const expiresIn = this.getExpiresIn(tokenResponse);
11
+ const scopes = this.getScopes(tokenResponse);
12
+ const refreshToken = tokenResponse[OAuth2ParameterNames.REFRESH_TOKEN];
13
+
14
+ const checkParameters = [
15
+ OAuth2ParameterNames.ACCESS_TOKEN,
16
+ OAuth2ParameterNames.EXPIRES_IN,
17
+ OAuth2ParameterNames.REFRESH_TOKEN,
18
+ OAuth2ParameterNames.SCOPE,
19
+ OAuth2ParameterNames.TOKEN_TYPE
20
+ ];
21
+ const additionalParameters: { [key: string]: string } = {};
22
+ for (const key in tokenResponse) {
23
+ if (Object.prototype.hasOwnProperty.call(tokenResponse, key) && !checkParameters.includes(key)) {
24
+ additionalParameters[key] = tokenResponse[key];
25
+ }
26
+ }
27
+
28
+ const issuedAt = Date.now();
29
+ const expiresAt = expiresIn > 0 ? issuedAt + 1000 * expiresIn : issuedAt + 1000;
30
+
31
+ return {
32
+ accessToken: {
33
+ tokenType,
34
+ issuedAt,
35
+ expiresAt,
36
+ tokenValue: accessToken,
37
+ scopes
38
+ },
39
+ refreshToken: refreshToken ? { tokenValue: refreshToken, issuedAt } : undefined,
40
+ additionalParameters
41
+ };
42
+
43
+ }
44
+
45
+ protected getScopes(tokenResponse: { [key: string]: string; }) {
46
+ if (tokenResponse[OAuth2ParameterNames.SCOPE]) {
47
+ return tokenResponse[OAuth2ParameterNames.SCOPE].split(' ');
48
+ }
49
+ return [];
50
+ }
51
+
52
+ protected getExpiresIn(tokenResponse: { [key: string]: string; }) {
53
+ if (tokenResponse[OAuth2ParameterNames.EXPIRES_IN]) {
54
+ return parseInt(tokenResponse[OAuth2ParameterNames.EXPIRES_IN]);
55
+ }
56
+ return 0;
57
+ }
58
+
59
+ protected getAccessTokenType(tokenResponse: { [key: string]: string; }) {
60
+ if (TokenType.Bearer.toUpperCase() === (tokenResponse[OAuth2ParameterNames.TOKEN_TYPE] || '').toUpperCase()) {
61
+ return TokenType.Bearer;
62
+ }
63
+ }
64
+ }
@@ -0,0 +1,150 @@
1
+ import { AuthorizationGrantType, AuthorizationResponseType } from '../authorization';
2
+ import { RefreshToken, AccessToken } from '../token';
3
+
4
+ export namespace OAuth2ParameterNames {
5
+ /**
6
+ * used in Access Token Request.
7
+ */
8
+ export const GRANT_TYPE = 'grant_type';
9
+
10
+ /**
11
+ * used in Authorization Request.
12
+ */
13
+ export const RESPONSE_TYPE = 'response_type';
14
+
15
+ /**
16
+ * used in Authorization Request and Access Token Request.
17
+ */
18
+ export const CLIENT_ID = 'client_id';
19
+
20
+ /**
21
+ * used in Access Token Request.
22
+ */
23
+ export const CLIENT_SECRET = 'client_secret';
24
+
25
+ /**
26
+ * used in Authorization Request and Access Token Request.
27
+ */
28
+ export const REDIRECT_URI = 'redirect_uri';
29
+
30
+ /**
31
+ * used in Authorization Request, Authorization Response, Access Token Request and Access Token Response.
32
+ */
33
+ export const SCOPE = 'scope';
34
+
35
+ /**
36
+ * used in Authorization Request and Authorization Response.
37
+ */
38
+ export const STATE = 'state';
39
+
40
+ /**
41
+ * used in Authorization Response and Access Token Request.
42
+ */
43
+ export const CODE = 'code';
44
+
45
+ /**
46
+ * used in Authorization Response and Access Token Response.
47
+ */
48
+ export const ACCESS_TOKEN = 'access_token';
49
+
50
+ /**
51
+ * used in Authorization Response and Access Token Response.
52
+ */
53
+ export const TOKEN_TYPE = 'token_type';
54
+
55
+ /**
56
+ * used in Authorization Response and Access Token Response.
57
+ */
58
+ export const EXPIRES_IN = 'expires_in';
59
+
60
+ /**
61
+ * used in Access Token Request and Access Token Response.
62
+ */
63
+ export const REFRESH_TOKEN = 'refresh_token';
64
+
65
+ /**
66
+ * used in Access Token Request.
67
+ */
68
+ export const USERNAME = 'username';
69
+
70
+ /**
71
+ * used in Access Token Request.
72
+ */
73
+ export const PASSWORD = 'password';
74
+
75
+ /**
76
+ * used in Authorization Response and Access Token Response.
77
+ */
78
+ export const ERROR = 'error';
79
+
80
+ /**
81
+ * used in Authorization Response and Access Token Response.
82
+ */
83
+ export const ERROR_DESCRIPTION = 'error_description';
84
+
85
+ /**
86
+ * used in Authorization Response and Access Token Response.
87
+ */
88
+ export const ERROR_URI = 'error_uri';
89
+
90
+ /**
91
+ * Non-standard parameter (used internally).
92
+ */
93
+ export const REGISTRATION_ID = 'registration_id';
94
+
95
+ }
96
+
97
+ export namespace PkceParameterNames {
98
+
99
+ /**
100
+ * {@code code_challenge} - used in Authorization Request.
101
+ */
102
+ export const CODE_CHALLENGE = 'code_challenge';
103
+
104
+ /**
105
+ * {@code code_challenge_method} - used in Authorization Request.
106
+ */
107
+ export const CODE_CHALLENGE_METHOD = 'code_challenge_method';
108
+
109
+ /**
110
+ * {@code code_verifier} - used in Token Request.
111
+ */
112
+ export const CODE_VERIFIER = 'code_verifier';
113
+ }
114
+
115
+ export interface AuthorizationRequest {
116
+ authorizationUri: string;
117
+ authorizationGrantType: AuthorizationGrantType;
118
+ responseType: AuthorizationResponseType;
119
+ clientId: string;
120
+ redirectUri: string;
121
+ scopes: string[];
122
+ state: string;
123
+ additionalParameters: { [key: string]: any };
124
+ authorizationRequestUri: string;
125
+ attributes: { [key: string]: any };
126
+ }
127
+
128
+ export interface AuthorizationResponse {
129
+ redirectUri: string;
130
+ state: string;
131
+ code: string;
132
+ error: OAuth2Error;
133
+ }
134
+
135
+ export interface OAuth2Error {
136
+ errorCode: string;
137
+ description?: string;
138
+ uri?: string;
139
+ }
140
+
141
+ export interface AuthorizationExchange {
142
+ authorizationRequest: AuthorizationRequest;
143
+ authorizationResponse: AuthorizationResponse;
144
+ }
145
+
146
+ export class AccessTokenResponse {
147
+ accessToken: AccessToken;
148
+ refreshToken?: RefreshToken;
149
+ additionalParameters: { [key: string]: any };
150
+ }
@@ -0,0 +1,2 @@
1
+ export * from './endpoint-protocol';
2
+ export * from './access-token-response-converter';
@@ -0,0 +1,93 @@
1
+ export enum OAuth2ErrorCodes {
2
+
3
+ /**
4
+ * {@code invalid_request} - The request is missing a required parameter,
5
+ * includes an invalid parameter value,
6
+ * includes a parameter more than once, or is otherwise malformed.
7
+ */
8
+ INVALID_REQUEST = 'invalid_request',
9
+
10
+ /**
11
+ * {@code unauthorized_client} - The client is not authorized to request
12
+ * an authorization code or access token using this method.
13
+ */
14
+ UNAUTHORIZED_CLIENT = 'unauthorized_client',
15
+
16
+ /**
17
+ * {@code access_denied} - The resource owner or authorization server denied the request.
18
+ */
19
+ ACCESS_DENIED = 'access_denied',
20
+
21
+ /**
22
+ * {@code unsupported_response_type} - The authorization server does not support
23
+ * obtaining an authorization code or access token using this method.
24
+ */
25
+ UNSUPPORTED_RESPONSE_TYPE = 'unsupported_response_type',
26
+
27
+ /**
28
+ * {@code invalid_scope} - The requested scope is invalid, unknown, malformed or
29
+ * exceeds the scope granted by the resource owner.
30
+ */
31
+ INVALID_SCOPE = 'invalid_scope',
32
+
33
+ /**
34
+ * {@code insufficient_scope} - The request requires higher privileges than
35
+ * provided by the access token.
36
+ * The resource server SHOULD respond with the HTTP 403 (Forbidden)
37
+ * status code and MAY include the 'scope' attribute with the scope
38
+ * necessary to access the protected resource.
39
+ *
40
+ * @see <a href='https://tools.ietf.org/html/rfc6750#section-3.1'>RFC-6750 - Section 3.1 - Error Codes</a>
41
+ */
42
+ INSUFFICIENT_SCOPE = 'insufficient_scope',
43
+
44
+ /**
45
+ * {@code invalid_token} - The access token provided is expired, revoked,
46
+ * malformed, or invalid for other reasons.
47
+ * The resource SHOULD respond with the HTTP 401 (Unauthorized) status code.
48
+ * The client MAY request a new access token and retry the protected resource request.
49
+ *
50
+ * @see <a href='https://tools.ietf.org/html/rfc6750#section-3.1'>RFC-6750 - Section 3.1 - Error Codes</a>
51
+ */
52
+ INVALID_TOKEN = 'invalid_token',
53
+
54
+ /**
55
+ * {@code server_error} - The authorization server encountered an
56
+ * unexpected condition that prevented it from fulfilling the request.
57
+ * (This error code is needed because a 500 Internal Server Error HTTP status code
58
+ * cannot be returned to the client via a HTTP redirect.)
59
+ */
60
+ SERVER_ERROR = 'server_error',
61
+
62
+ /**
63
+ * {@code temporarily_unavailable} - The authorization server is currently unable
64
+ * to handle the request due to a temporary overloading or maintenance of the server.
65
+ * (This error code is needed because a 503 Service Unavailable HTTP status code
66
+ * cannot be returned to the client via an HTTP redirect.)
67
+ */
68
+ TEMPORARILY_UNAVAILABLE = 'temporarily_unavailable',
69
+
70
+ /**
71
+ * {@code invalid_client} - Client authentication failed (e.g., unknown client,
72
+ * no client authentication included, or unsupported authentication method).
73
+ * The authorization server MAY return a HTTP 401 (Unauthorized) status code
74
+ * to indicate which HTTP authentication schemes are supported.
75
+ * If the client attempted to authenticate via the &quot;Authorization&quot; request header field,
76
+ * the authorization server MUST respond with a HTTP 401 (Unauthorized) status code and
77
+ * include the &quot;WWW-Authenticate&quot; response header field matching the authentication scheme used by the client.
78
+ */
79
+ INVALID_CLIENT = 'invalid_client',
80
+
81
+ /**
82
+ * {@code invalid_grant} - The provided authorization grant
83
+ * (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked,
84
+ * does not match the redirection URI used in the authorization request, or was issued to another client.
85
+ */
86
+ INVALID_GRANT = 'invalid_grant',
87
+
88
+ /**
89
+ * {@code unsupported_grant_type} - The authorization grant type is not supported by the authorization server.
90
+ */
91
+ UNSUPPORTED_GRANT_TYPE = 'unsupported_grant_type'
92
+
93
+ }
@@ -0,0 +1,19 @@
1
+ import { CustomError } from '@celljs/core';
2
+ import { OAuth2Error } from '../endpoint';
3
+ import { AuthenticationError } from '@celljs/security/lib/node';
4
+
5
+ export class OAuth2AuthorizationError extends CustomError {
6
+
7
+ constructor(public oauth2Error: OAuth2Error, error?: Error) {
8
+ super(error ? error.message : oauth2Error.description);
9
+ }
10
+
11
+ }
12
+
13
+ export class OAuth2AuthenticationError extends AuthenticationError {
14
+
15
+ constructor(public oauth2Error: OAuth2Error, error?: Error) {
16
+ super(error ? error.message : oauth2Error.description);
17
+ }
18
+
19
+ }
@@ -0,0 +1,2 @@
1
+ export * from './error';
2
+ export * from './error-protocol';
@@ -0,0 +1,6 @@
1
+ export * from './authentication';
2
+ export * from './authorization';
3
+ export * from './endpoint';
4
+ export * from './oidc';
5
+ export * from './token';
6
+ export * from './error';
@@ -0,0 +1,4 @@
1
+ import { autoBind } from '@celljs/core';
2
+ import './index';
3
+
4
+ export default autoBind();
@@ -0,0 +1 @@
1
+ export * from './oidc-protocol';
@@ -0,0 +1,148 @@
1
+ export namespace OidcScopes {
2
+
3
+ /**
4
+ * The {@code openid} scope is required for OpenID Connect Authentication Requests.
5
+ */
6
+ export const OPENID = 'openid';
7
+
8
+ /**
9
+ * The {@code profile} scope requests access to the default profile claims, which are:
10
+ * {@code name, family_name, given_name, middle_name, nickname, preferred_username,
11
+ * profile, picture, website, gender, birthdate, zoneinfo, locale, updated_at}.
12
+ */
13
+ export const PROFILE = 'profile';
14
+
15
+ /**
16
+ * The {@code email} scope requests access to the {@code email} and {@code email_verified} claims.
17
+ */
18
+ export const EMAIL = 'email';
19
+
20
+ /**
21
+ * The {@code address} scope requests access to the {@code address} claim.
22
+ */
23
+ export const ADDRESS = 'address';
24
+
25
+ /**
26
+ * The {@code phone} scope requests access to the {@code phone_number} and {@code phone_number_verified} claims.
27
+ */
28
+ export const PHONE = 'phone';
29
+
30
+ }
31
+
32
+ export namespace OidcParameterNames {
33
+
34
+ /**
35
+ * {@code id_token} - used in the Access Token Response.
36
+ */
37
+ export const ID_TOKEN = 'id_token';
38
+
39
+ /**
40
+ * {@code nonce} - used in the Authentication Request.
41
+ */
42
+ export const NONCE = 'nonce';
43
+
44
+ }
45
+
46
+ export namespace StandardClaimNames {
47
+
48
+ /**
49
+ * {@code sub} - the Subject identifier
50
+ */
51
+ export const SUB = 'sub';
52
+
53
+ /**
54
+ * {@code name} - the user's full name
55
+ */
56
+ export const NAME = 'name';
57
+
58
+ /**
59
+ * {@code given_name} - the user's given name(s) or first name(s)
60
+ */
61
+ export const GIVEN_NAME = 'given_name';
62
+
63
+ /**
64
+ * {@code family_name} - the user's surname(s) or last name(s)
65
+ */
66
+ export const FAMILY_NAME = 'family_name';
67
+
68
+ /**
69
+ * {@code middle_name} - the user's middle name(s)
70
+ */
71
+ export const MIDDLE_NAME = 'middle_name';
72
+
73
+ /**
74
+ * {@code nickname} - the user's nick name that may or may not be the same as the {@code given_name}
75
+ */
76
+ export const NICKNAME = 'nickname';
77
+
78
+ /**
79
+ * {@code preferred_username} - the preferred username that the user wishes to be referred to
80
+ */
81
+ export const PREFERRED_USERNAME = 'preferred_username';
82
+
83
+ /**
84
+ * {@code profile} - the URL of the user's profile page
85
+ */
86
+ export const PROFILE = 'profile';
87
+
88
+ /**
89
+ * {@code picture} - the URL of the user's profile picture
90
+ */
91
+ export const PICTURE = 'picture';
92
+
93
+ /**
94
+ * {@code website} - the URL of the user's web page or blog
95
+ */
96
+ export const WEBSITE = 'website';
97
+
98
+ /**
99
+ * {@code email} - the user's preferred e-mail address
100
+ */
101
+ export const EMAIL = 'email';
102
+
103
+ /**
104
+ * {@code email_verified} - {@code true} if the user's e-mail address has been verified, otherwise {@code false}
105
+ */
106
+ export const EMAIL_VERIFIED = 'email_verified';
107
+
108
+ /**
109
+ * {@code gender} - the user's gender
110
+ */
111
+ export const GENDER = 'gender';
112
+
113
+ /**
114
+ * {@code birthdate} - the user's birth date
115
+ */
116
+ export const BIRTHDATE = 'birthdate';
117
+
118
+ /**
119
+ * {@code zoneinfo} - the user's time zone
120
+ */
121
+ export const ZONEINFO = 'zoneinfo';
122
+
123
+ /**
124
+ * {@code locale} - the user's locale
125
+ */
126
+ export const LOCALE = 'locale';
127
+
128
+ /**
129
+ * {@code phone_number} - the user's preferred phone number
130
+ */
131
+ export const PHONE_NUMBER = 'phone_number';
132
+
133
+ /**
134
+ * {@code phone_number_verified} - {@code true} if the user's phone number has been verified, otherwise {@code false}
135
+ */
136
+ export const PHONE_NUMBER_VERIFIED = 'phone_number_verified';
137
+
138
+ /**
139
+ * {@code address} - the user's preferred postal address
140
+ */
141
+ export const ADDRESS = 'address';
142
+
143
+ /**
144
+ * {@code updated_at} - the time the user's information was last updated
145
+ */
146
+ export const UPDATED_AT = 'updated_at';
147
+
148
+ }
@@ -0,0 +1 @@
1
+ export * from './token-protocol';