@whook/oauth2 9.0.0 → 9.0.1
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 +71 -54
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/services/authCookies.d.ts +7 -4
- package/dist/services/authCookies.js.map +1 -1
- package/dist/services/authCookies.mjs.map +1 -1
- package/package.json +6 -5
- package/src/index.ts +6 -4
- package/src/services/authCookies.ts +8 -4
package/README.md
CHANGED
|
@@ -60,18 +60,29 @@ Declare the plugin into your `index.ts` file:
|
|
|
60
60
|
// (...)
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
Declare this module types in your `src/whook.d.ts` type
|
|
64
|
-
|
|
63
|
+
Declare this module types in your `src/whook.d.ts` type definitions:
|
|
64
|
+
|
|
65
65
|
```diff
|
|
66
|
-
+
|
|
66
|
+
+import type {
|
|
67
|
+
+ AuthCookiesEnv,
|
|
68
|
+
+ OAuth2Config,
|
|
69
|
+
+} from '@whook/oauth2';
|
|
67
70
|
|
|
68
71
|
declare module '@whook/whook' {
|
|
69
72
|
|
|
73
|
+
export interface WhookEnv
|
|
74
|
+
extends WhookBaseEnv,
|
|
75
|
+
// (...)
|
|
76
|
+
+ AuthCookiesEnv,
|
|
77
|
+
WhookSwaggerUIEnv {}
|
|
78
|
+
|
|
70
79
|
// ...
|
|
71
80
|
|
|
72
81
|
export interface WhookConfigs
|
|
73
82
|
- extends WhookBaseConfigs {}
|
|
74
|
-
+ extends WhookBaseConfigs,
|
|
83
|
+
+ extends WhookBaseConfigs,
|
|
84
|
+
+ AuthCookiesConfig,
|
|
85
|
+
+ OAuth2Config {}
|
|
75
86
|
|
|
76
87
|
// ...
|
|
77
88
|
|
|
@@ -157,43 +168,39 @@ async function initOAuth2VerifyTokenGranter({
|
|
|
157
168
|
jwtToken,
|
|
158
169
|
pg,
|
|
159
170
|
log = noop,
|
|
160
|
-
}: OAuth2VerifyTokenGranterDependencies): Promise<
|
|
161
|
-
OAuth2VerifyTokenGranterService
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (err.code === 'E_BAD_TOKEN') {
|
|
192
|
-
throw YError.wrap(err as Error, 'E_BAD_REFRESH_TOKEN');
|
|
171
|
+
}: OAuth2VerifyTokenGranterDependencies): Promise<OAuth2VerifyTokenGranterService> {
|
|
172
|
+
const authenticateWithVerifyToken: OAuth2VerifyTokenGranterService['authenticator']['authenticate'] =
|
|
173
|
+
async ({ verifyToken }, authenticationData) => {
|
|
174
|
+
try {
|
|
175
|
+
// The client must be authenticated
|
|
176
|
+
if (!authenticationData) {
|
|
177
|
+
throw new YError('E_UNAUTHORIZED');
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const newAuthenticationData = await jwtToken.verify(verifyToken);
|
|
181
|
+
|
|
182
|
+
await checkApplication({
|
|
183
|
+
applicationId: authenticationData.applicationId,
|
|
184
|
+
type: 'verify',
|
|
185
|
+
scope: newAuthenticationData.scope,
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
const result = await pg.query(USER_VERIFY_QUERY, {
|
|
189
|
+
userId: newAuthenticationData.userId,
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
if (result.rowCount === 0) {
|
|
193
|
+
throw new YError('E_ALREADY_VERIFIED', authenticationData.userId);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return newAuthenticationData;
|
|
197
|
+
} catch (err) {
|
|
198
|
+
if (err.code === 'E_BAD_TOKEN') {
|
|
199
|
+
throw YError.wrap(err as Error, 'E_BAD_REFRESH_TOKEN');
|
|
200
|
+
}
|
|
201
|
+
throw err;
|
|
193
202
|
}
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
};
|
|
203
|
+
};
|
|
197
204
|
|
|
198
205
|
log('debug', '👫 - OAuth2VerifyTokenGranter Service Initialized!');
|
|
199
206
|
|
|
@@ -213,6 +220,7 @@ For internal use, you may prefer use cookies based auth handlers like
|
|
|
213
220
|
`postLogin`, `postLogout` and `postRefresh`.
|
|
214
221
|
|
|
215
222
|
To do so, configure the `ROOT_AUTHENTICATION_DATA` and `COOKIES` configurations:
|
|
223
|
+
|
|
216
224
|
```diff
|
|
217
225
|
// src/production/config.ts
|
|
218
226
|
+ COOKIES: {
|
|
@@ -225,8 +233,9 @@ To do so, configure the `ROOT_AUTHENTICATION_DATA` and `COOKIES` configurations:
|
|
|
225
233
|
```
|
|
226
234
|
|
|
227
235
|
Than import the `postLogin`, `postLogout` and `postRefresh` handlers like so:
|
|
236
|
+
|
|
228
237
|
```ts
|
|
229
|
-
// src/handlers/postRefresh.ts
|
|
238
|
+
// src/handlers/postRefresh.ts
|
|
230
239
|
import {
|
|
231
240
|
initPostAuthRefresh,
|
|
232
241
|
postAuthRefreshDefinition,
|
|
@@ -249,7 +258,8 @@ export const definition: WhookAPIHandlerDefinition = {
|
|
|
249
258
|
export default initPostAuthRefresh;
|
|
250
259
|
```
|
|
251
260
|
|
|
252
|
-
Additionnaly, you could create any handler in the `/auth` path in order to
|
|
261
|
+
Additionnaly, you could create any handler in the `/auth` path in order to
|
|
262
|
+
receive the auth cookies.
|
|
253
263
|
|
|
254
264
|
## Customizing handlers
|
|
255
265
|
|
|
@@ -285,22 +295,29 @@ export const definition: WhookAPIHandlerDefinition = {
|
|
|
285
295
|
content: {
|
|
286
296
|
'application/json': {
|
|
287
297
|
schema: {
|
|
288
|
-
...((
|
|
289
|
-
.
|
|
290
|
-
|
|
291
|
-
]
|
|
298
|
+
...((
|
|
299
|
+
postOAuth2AcknowledgeDefinition.operation
|
|
300
|
+
.requestBody as OpenAPIV3.RequestBodyObject
|
|
301
|
+
).content['application/json']
|
|
302
|
+
.schema as OpenAPIV3.NonArraySchemaObject),
|
|
292
303
|
required: [
|
|
293
304
|
'userId',
|
|
294
|
-
...(
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
305
|
+
...(
|
|
306
|
+
(
|
|
307
|
+
postOAuth2AcknowledgeDefinition.operation
|
|
308
|
+
.requestBody as OpenAPIV3.RequestBodyObject
|
|
309
|
+
).content['application/json']
|
|
310
|
+
.schema as OpenAPIV3.NonArraySchemaObject
|
|
311
|
+
).required,
|
|
298
312
|
],
|
|
299
313
|
properties: {
|
|
300
|
-
...(
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
314
|
+
...(
|
|
315
|
+
(
|
|
316
|
+
postOAuth2AcknowledgeDefinition.operation
|
|
317
|
+
.requestBody as OpenAPIV3.RequestBodyObject
|
|
318
|
+
).content['application/json']
|
|
319
|
+
.schema as OpenAPIV3.NonArraySchemaObject
|
|
320
|
+
).properties,
|
|
304
321
|
userId: {
|
|
305
322
|
type: 'string',
|
|
306
323
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,6 @@ import initPostAuthLogin, { definition as postAuthLoginDefinition } from './hand
|
|
|
12
12
|
import initPostAuthLogout, { definition as postAuthLogoutDefinition } from './handlers/postAuthLogout';
|
|
13
13
|
import initPostAuthRefresh, { authCookieHeaderParameter, definition as postAuthRefreshDefinition } from './handlers/postAuthRefresh';
|
|
14
14
|
import initAuthCookiesService, { AUTH_API_PREFIX } from './services/authCookies';
|
|
15
|
-
import type {
|
|
16
|
-
export type { OAuth2CodeService, OAuth2PasswordService, OAuth2AccessTokenService, OAuth2RefreshTokenService, CheckApplicationService, OAuth2GranterService, OAuth2Options, OAuth2Config,
|
|
15
|
+
import type { AuthCookiesEnv, AuthCookiesConfig, AuthCookiesService, AuthCookiesData, AuthHandlersConfig } from './services/authCookies';
|
|
16
|
+
export type { OAuth2CodeService, OAuth2PasswordService, OAuth2AccessTokenService, OAuth2RefreshTokenService, CheckApplicationService, OAuth2GranterService, OAuth2Options, OAuth2Config, AuthCookiesEnv, AuthCookiesConfig, AuthCookiesService, AuthCookiesData, AuthHandlersConfig, };
|
|
17
17
|
export { initGetOAuth2Authorize, getOAuth2AuthorizeDefinition, getOAuth2AuthorizeResponseTypeParameter, getOAuth2AuthorizeClientIdParameter, getOAuth2AuthorizeRedirectURIParameter, getOAuth2AuthorizeScopeParameter, getOAuth2AuthorizeStateParameter, initPostOAuth2Acknowledge, postOAuth2AcknowledgeDefinition, initPostOAuth2Token, postOAuth2TokenDefinition, postOAuth2TokenAuthorizationCodeTokenRequestBodySchema, postOAuth2TokenPasswordTokenRequestBodySchema, postOAuth2TokenClientCredentialsTokenRequestBodySchema, postOAuth2TokenRefreshTokenRequestBodySchema, postOAuth2TokenTokenBodySchema, OAUTH2_ERRORS_DESCRIPTORS, initOAuth2Granters, initOAuth2ClientCredentialsGranter, initOAuth2CodeGranter, initOAuth2PasswordGranter, initOAuth2RefreshTokenGranter, initOAuth2TokenGranter, AUTH_API_PREFIX, authCookieHeaderParameter, initPostAuthLogin, postAuthLoginDefinition, initPostAuthLogout, postAuthLogoutDefinition, initPostAuthRefresh, postAuthRefreshDefinition, initAuthCookiesService, };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import initGetOAuth2Authorize, {\n definition as getOAuth2AuthorizeDefinition,\n responseTypeParameter as getOAuth2AuthorizeResponseTypeParameter,\n clientIdParameter as getOAuth2AuthorizeClientIdParameter,\n redirectURIParameter as getOAuth2AuthorizeRedirectURIParameter,\n scopeParameter as getOAuth2AuthorizeScopeParameter,\n stateParameter as getOAuth2AuthorizeStateParameter,\n} from './handlers/getOAuth2Authorize';\nimport initPostOAuth2Acknowledge, {\n definition as postOAuth2AcknowledgeDefinition,\n} from './handlers/postOAuth2Acknowledge';\nimport initPostOAuth2Token, {\n definition as postOAuth2TokenDefinition,\n authorizationCodeTokenRequestBodySchema as postOAuth2TokenAuthorizationCodeTokenRequestBodySchema,\n passwordTokenRequestBodySchema as postOAuth2TokenPasswordTokenRequestBodySchema,\n clientCredentialsTokenRequestBodySchema as postOAuth2TokenClientCredentialsTokenRequestBodySchema,\n refreshTokenRequestBodySchema as postOAuth2TokenRefreshTokenRequestBodySchema,\n tokenBodySchema as postOAuth2TokenTokenBodySchema,\n} from './handlers/postOAuth2Token';\nimport initOAuth2Granters, {\n OAUTH2_ERRORS_DESCRIPTORS,\n} from './services/oAuth2Granters';\nimport initOAuth2ClientCredentialsGranter from './services/oAuth2ClientCredentialsGranter';\nimport initOAuth2CodeGranter from './services/oAuth2CodeGranter';\nimport initOAuth2PasswordGranter from './services/oAuth2PasswordGranter';\nimport initOAuth2RefreshTokenGranter from './services/oAuth2RefreshTokenGranter';\nimport initOAuth2TokenGranter from './services/oAuth2TokenGranter';\nimport type {\n OAuth2CodeService,\n OAuth2PasswordService,\n OAuth2AccessTokenService,\n OAuth2RefreshTokenService,\n CheckApplicationService,\n OAuth2GranterService,\n OAuth2Options,\n OAuth2Config,\n} from './services/oAuth2Granters';\nimport initPostAuthLogin, {\n definition as postAuthLoginDefinition,\n} from './handlers/postAuthLogin';\nimport initPostAuthLogout, {\n definition as postAuthLogoutDefinition,\n} from './handlers/postAuthLogout';\nimport initPostAuthRefresh, {\n authCookieHeaderParameter,\n definition as postAuthRefreshDefinition,\n} from './handlers/postAuthRefresh';\nimport initAuthCookiesService, {\n AUTH_API_PREFIX,\n} from './services/authCookies';\nimport type {\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import initGetOAuth2Authorize, {\n definition as getOAuth2AuthorizeDefinition,\n responseTypeParameter as getOAuth2AuthorizeResponseTypeParameter,\n clientIdParameter as getOAuth2AuthorizeClientIdParameter,\n redirectURIParameter as getOAuth2AuthorizeRedirectURIParameter,\n scopeParameter as getOAuth2AuthorizeScopeParameter,\n stateParameter as getOAuth2AuthorizeStateParameter,\n} from './handlers/getOAuth2Authorize';\nimport initPostOAuth2Acknowledge, {\n definition as postOAuth2AcknowledgeDefinition,\n} from './handlers/postOAuth2Acknowledge';\nimport initPostOAuth2Token, {\n definition as postOAuth2TokenDefinition,\n authorizationCodeTokenRequestBodySchema as postOAuth2TokenAuthorizationCodeTokenRequestBodySchema,\n passwordTokenRequestBodySchema as postOAuth2TokenPasswordTokenRequestBodySchema,\n clientCredentialsTokenRequestBodySchema as postOAuth2TokenClientCredentialsTokenRequestBodySchema,\n refreshTokenRequestBodySchema as postOAuth2TokenRefreshTokenRequestBodySchema,\n tokenBodySchema as postOAuth2TokenTokenBodySchema,\n} from './handlers/postOAuth2Token';\nimport initOAuth2Granters, {\n OAUTH2_ERRORS_DESCRIPTORS,\n} from './services/oAuth2Granters';\nimport initOAuth2ClientCredentialsGranter from './services/oAuth2ClientCredentialsGranter';\nimport initOAuth2CodeGranter from './services/oAuth2CodeGranter';\nimport initOAuth2PasswordGranter from './services/oAuth2PasswordGranter';\nimport initOAuth2RefreshTokenGranter from './services/oAuth2RefreshTokenGranter';\nimport initOAuth2TokenGranter from './services/oAuth2TokenGranter';\nimport type {\n OAuth2CodeService,\n OAuth2PasswordService,\n OAuth2AccessTokenService,\n OAuth2RefreshTokenService,\n CheckApplicationService,\n OAuth2GranterService,\n OAuth2Options,\n OAuth2Config,\n} from './services/oAuth2Granters';\nimport initPostAuthLogin, {\n definition as postAuthLoginDefinition,\n} from './handlers/postAuthLogin';\nimport initPostAuthLogout, {\n definition as postAuthLogoutDefinition,\n} from './handlers/postAuthLogout';\nimport initPostAuthRefresh, {\n authCookieHeaderParameter,\n definition as postAuthRefreshDefinition,\n} from './handlers/postAuthRefresh';\nimport initAuthCookiesService, {\n AUTH_API_PREFIX,\n} from './services/authCookies';\nimport type {\n AuthCookiesEnv,\n AuthCookiesConfig,\n AuthCookiesService,\n AuthCookiesData,\n AuthHandlersConfig,\n} from './services/authCookies';\n\nexport type {\n OAuth2CodeService,\n OAuth2PasswordService,\n OAuth2AccessTokenService,\n OAuth2RefreshTokenService,\n CheckApplicationService,\n OAuth2GranterService,\n OAuth2Options,\n OAuth2Config,\n AuthCookiesEnv,\n AuthCookiesConfig,\n AuthCookiesService,\n AuthCookiesData,\n AuthHandlersConfig,\n};\nexport {\n initGetOAuth2Authorize,\n getOAuth2AuthorizeDefinition,\n getOAuth2AuthorizeResponseTypeParameter,\n getOAuth2AuthorizeClientIdParameter,\n getOAuth2AuthorizeRedirectURIParameter,\n getOAuth2AuthorizeScopeParameter,\n getOAuth2AuthorizeStateParameter,\n initPostOAuth2Acknowledge,\n postOAuth2AcknowledgeDefinition,\n initPostOAuth2Token,\n postOAuth2TokenDefinition,\n postOAuth2TokenAuthorizationCodeTokenRequestBodySchema,\n postOAuth2TokenPasswordTokenRequestBodySchema,\n postOAuth2TokenClientCredentialsTokenRequestBodySchema,\n postOAuth2TokenRefreshTokenRequestBodySchema,\n postOAuth2TokenTokenBodySchema,\n OAUTH2_ERRORS_DESCRIPTORS,\n initOAuth2Granters,\n initOAuth2ClientCredentialsGranter,\n initOAuth2CodeGranter,\n initOAuth2PasswordGranter,\n initOAuth2RefreshTokenGranter,\n initOAuth2TokenGranter,\n AUTH_API_PREFIX,\n authCookieHeaderParameter,\n initPostAuthLogin,\n postAuthLoginDefinition,\n initPostAuthLogout,\n postAuthLogoutDefinition,\n initPostAuthRefresh,\n postAuthRefreshDefinition,\n initAuthCookiesService,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AAGA;;AAQA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAWA;;AAGA;;AAGA;;AAIA"}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["initGetOAuth2Authorize","definition","getOAuth2AuthorizeDefinition","responseTypeParameter","getOAuth2AuthorizeResponseTypeParameter","clientIdParameter","getOAuth2AuthorizeClientIdParameter","redirectURIParameter","getOAuth2AuthorizeRedirectURIParameter","scopeParameter","getOAuth2AuthorizeScopeParameter","stateParameter","getOAuth2AuthorizeStateParameter","initPostOAuth2Acknowledge","postOAuth2AcknowledgeDefinition","initPostOAuth2Token","postOAuth2TokenDefinition","authorizationCodeTokenRequestBodySchema","postOAuth2TokenAuthorizationCodeTokenRequestBodySchema","passwordTokenRequestBodySchema","postOAuth2TokenPasswordTokenRequestBodySchema","clientCredentialsTokenRequestBodySchema","postOAuth2TokenClientCredentialsTokenRequestBodySchema","refreshTokenRequestBodySchema","postOAuth2TokenRefreshTokenRequestBodySchema","tokenBodySchema","postOAuth2TokenTokenBodySchema","initOAuth2Granters","OAUTH2_ERRORS_DESCRIPTORS","initOAuth2ClientCredentialsGranter","initOAuth2CodeGranter","initOAuth2PasswordGranter","initOAuth2RefreshTokenGranter","initOAuth2TokenGranter","initPostAuthLogin","postAuthLoginDefinition","initPostAuthLogout","postAuthLogoutDefinition","initPostAuthRefresh","authCookieHeaderParameter","postAuthRefreshDefinition","initAuthCookiesService","AUTH_API_PREFIX"],"sources":["../src/index.ts"],"sourcesContent":["import initGetOAuth2Authorize, {\n definition as getOAuth2AuthorizeDefinition,\n responseTypeParameter as getOAuth2AuthorizeResponseTypeParameter,\n clientIdParameter as getOAuth2AuthorizeClientIdParameter,\n redirectURIParameter as getOAuth2AuthorizeRedirectURIParameter,\n scopeParameter as getOAuth2AuthorizeScopeParameter,\n stateParameter as getOAuth2AuthorizeStateParameter,\n} from './handlers/getOAuth2Authorize';\nimport initPostOAuth2Acknowledge, {\n definition as postOAuth2AcknowledgeDefinition,\n} from './handlers/postOAuth2Acknowledge';\nimport initPostOAuth2Token, {\n definition as postOAuth2TokenDefinition,\n authorizationCodeTokenRequestBodySchema as postOAuth2TokenAuthorizationCodeTokenRequestBodySchema,\n passwordTokenRequestBodySchema as postOAuth2TokenPasswordTokenRequestBodySchema,\n clientCredentialsTokenRequestBodySchema as postOAuth2TokenClientCredentialsTokenRequestBodySchema,\n refreshTokenRequestBodySchema as postOAuth2TokenRefreshTokenRequestBodySchema,\n tokenBodySchema as postOAuth2TokenTokenBodySchema,\n} from './handlers/postOAuth2Token';\nimport initOAuth2Granters, {\n OAUTH2_ERRORS_DESCRIPTORS,\n} from './services/oAuth2Granters';\nimport initOAuth2ClientCredentialsGranter from './services/oAuth2ClientCredentialsGranter';\nimport initOAuth2CodeGranter from './services/oAuth2CodeGranter';\nimport initOAuth2PasswordGranter from './services/oAuth2PasswordGranter';\nimport initOAuth2RefreshTokenGranter from './services/oAuth2RefreshTokenGranter';\nimport initOAuth2TokenGranter from './services/oAuth2TokenGranter';\nimport type {\n OAuth2CodeService,\n OAuth2PasswordService,\n OAuth2AccessTokenService,\n OAuth2RefreshTokenService,\n CheckApplicationService,\n OAuth2GranterService,\n OAuth2Options,\n OAuth2Config,\n} from './services/oAuth2Granters';\nimport initPostAuthLogin, {\n definition as postAuthLoginDefinition,\n} from './handlers/postAuthLogin';\nimport initPostAuthLogout, {\n definition as postAuthLogoutDefinition,\n} from './handlers/postAuthLogout';\nimport initPostAuthRefresh, {\n authCookieHeaderParameter,\n definition as postAuthRefreshDefinition,\n} from './handlers/postAuthRefresh';\nimport initAuthCookiesService, {\n AUTH_API_PREFIX,\n} from './services/authCookies';\nimport type {\n
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["initGetOAuth2Authorize","definition","getOAuth2AuthorizeDefinition","responseTypeParameter","getOAuth2AuthorizeResponseTypeParameter","clientIdParameter","getOAuth2AuthorizeClientIdParameter","redirectURIParameter","getOAuth2AuthorizeRedirectURIParameter","scopeParameter","getOAuth2AuthorizeScopeParameter","stateParameter","getOAuth2AuthorizeStateParameter","initPostOAuth2Acknowledge","postOAuth2AcknowledgeDefinition","initPostOAuth2Token","postOAuth2TokenDefinition","authorizationCodeTokenRequestBodySchema","postOAuth2TokenAuthorizationCodeTokenRequestBodySchema","passwordTokenRequestBodySchema","postOAuth2TokenPasswordTokenRequestBodySchema","clientCredentialsTokenRequestBodySchema","postOAuth2TokenClientCredentialsTokenRequestBodySchema","refreshTokenRequestBodySchema","postOAuth2TokenRefreshTokenRequestBodySchema","tokenBodySchema","postOAuth2TokenTokenBodySchema","initOAuth2Granters","OAUTH2_ERRORS_DESCRIPTORS","initOAuth2ClientCredentialsGranter","initOAuth2CodeGranter","initOAuth2PasswordGranter","initOAuth2RefreshTokenGranter","initOAuth2TokenGranter","initPostAuthLogin","postAuthLoginDefinition","initPostAuthLogout","postAuthLogoutDefinition","initPostAuthRefresh","authCookieHeaderParameter","postAuthRefreshDefinition","initAuthCookiesService","AUTH_API_PREFIX"],"sources":["../src/index.ts"],"sourcesContent":["import initGetOAuth2Authorize, {\n definition as getOAuth2AuthorizeDefinition,\n responseTypeParameter as getOAuth2AuthorizeResponseTypeParameter,\n clientIdParameter as getOAuth2AuthorizeClientIdParameter,\n redirectURIParameter as getOAuth2AuthorizeRedirectURIParameter,\n scopeParameter as getOAuth2AuthorizeScopeParameter,\n stateParameter as getOAuth2AuthorizeStateParameter,\n} from './handlers/getOAuth2Authorize';\nimport initPostOAuth2Acknowledge, {\n definition as postOAuth2AcknowledgeDefinition,\n} from './handlers/postOAuth2Acknowledge';\nimport initPostOAuth2Token, {\n definition as postOAuth2TokenDefinition,\n authorizationCodeTokenRequestBodySchema as postOAuth2TokenAuthorizationCodeTokenRequestBodySchema,\n passwordTokenRequestBodySchema as postOAuth2TokenPasswordTokenRequestBodySchema,\n clientCredentialsTokenRequestBodySchema as postOAuth2TokenClientCredentialsTokenRequestBodySchema,\n refreshTokenRequestBodySchema as postOAuth2TokenRefreshTokenRequestBodySchema,\n tokenBodySchema as postOAuth2TokenTokenBodySchema,\n} from './handlers/postOAuth2Token';\nimport initOAuth2Granters, {\n OAUTH2_ERRORS_DESCRIPTORS,\n} from './services/oAuth2Granters';\nimport initOAuth2ClientCredentialsGranter from './services/oAuth2ClientCredentialsGranter';\nimport initOAuth2CodeGranter from './services/oAuth2CodeGranter';\nimport initOAuth2PasswordGranter from './services/oAuth2PasswordGranter';\nimport initOAuth2RefreshTokenGranter from './services/oAuth2RefreshTokenGranter';\nimport initOAuth2TokenGranter from './services/oAuth2TokenGranter';\nimport type {\n OAuth2CodeService,\n OAuth2PasswordService,\n OAuth2AccessTokenService,\n OAuth2RefreshTokenService,\n CheckApplicationService,\n OAuth2GranterService,\n OAuth2Options,\n OAuth2Config,\n} from './services/oAuth2Granters';\nimport initPostAuthLogin, {\n definition as postAuthLoginDefinition,\n} from './handlers/postAuthLogin';\nimport initPostAuthLogout, {\n definition as postAuthLogoutDefinition,\n} from './handlers/postAuthLogout';\nimport initPostAuthRefresh, {\n authCookieHeaderParameter,\n definition as postAuthRefreshDefinition,\n} from './handlers/postAuthRefresh';\nimport initAuthCookiesService, {\n AUTH_API_PREFIX,\n} from './services/authCookies';\nimport type {\n AuthCookiesEnv,\n AuthCookiesConfig,\n AuthCookiesService,\n AuthCookiesData,\n AuthHandlersConfig,\n} from './services/authCookies';\n\nexport type {\n OAuth2CodeService,\n OAuth2PasswordService,\n OAuth2AccessTokenService,\n OAuth2RefreshTokenService,\n CheckApplicationService,\n OAuth2GranterService,\n OAuth2Options,\n OAuth2Config,\n AuthCookiesEnv,\n AuthCookiesConfig,\n AuthCookiesService,\n AuthCookiesData,\n AuthHandlersConfig,\n};\nexport {\n initGetOAuth2Authorize,\n getOAuth2AuthorizeDefinition,\n getOAuth2AuthorizeResponseTypeParameter,\n getOAuth2AuthorizeClientIdParameter,\n getOAuth2AuthorizeRedirectURIParameter,\n getOAuth2AuthorizeScopeParameter,\n getOAuth2AuthorizeStateParameter,\n initPostOAuth2Acknowledge,\n postOAuth2AcknowledgeDefinition,\n initPostOAuth2Token,\n postOAuth2TokenDefinition,\n postOAuth2TokenAuthorizationCodeTokenRequestBodySchema,\n postOAuth2TokenPasswordTokenRequestBodySchema,\n postOAuth2TokenClientCredentialsTokenRequestBodySchema,\n postOAuth2TokenRefreshTokenRequestBodySchema,\n postOAuth2TokenTokenBodySchema,\n OAUTH2_ERRORS_DESCRIPTORS,\n initOAuth2Granters,\n initOAuth2ClientCredentialsGranter,\n initOAuth2CodeGranter,\n initOAuth2PasswordGranter,\n initOAuth2RefreshTokenGranter,\n initOAuth2TokenGranter,\n AUTH_API_PREFIX,\n authCookieHeaderParameter,\n initPostAuthLogin,\n postAuthLoginDefinition,\n initPostAuthLogout,\n postAuthLogoutDefinition,\n initPostAuthRefresh,\n postAuthRefreshDefinition,\n initAuthCookiesService,\n};\n"],"mappings":"AAAA,OAAOA,sBAAP,IACEC,UAAU,IAAIC,4BADhB,EAEEC,qBAAqB,IAAIC,uCAF3B,EAGEC,iBAAiB,IAAIC,mCAHvB,EAIEC,oBAAoB,IAAIC,sCAJ1B,EAKEC,cAAc,IAAIC,gCALpB,EAMEC,cAAc,IAAIC,gCANpB,QAOO,+BAPP;AAQA,OAAOC,yBAAP,IACEZ,UAAU,IAAIa,+BADhB,QAEO,kCAFP;AAGA,OAAOC,mBAAP,IACEd,UAAU,IAAIe,yBADhB,EAEEC,uCAAuC,IAAIC,sDAF7C,EAGEC,8BAA8B,IAAIC,6CAHpC,EAIEC,uCAAuC,IAAIC,sDAJ7C,EAKEC,6BAA6B,IAAIC,4CALnC,EAMEC,eAAe,IAAIC,8BANrB,QAOO,4BAPP;AAQA,OAAOC,kBAAP,IACEC,yBADF,QAEO,2BAFP;AAGA,OAAOC,kCAAP,MAA+C,2CAA/C;AACA,OAAOC,qBAAP,MAAkC,8BAAlC;AACA,OAAOC,yBAAP,MAAsC,kCAAtC;AACA,OAAOC,6BAAP,MAA0C,sCAA1C;AACA,OAAOC,sBAAP,MAAmC,+BAAnC;AAWA,OAAOC,iBAAP,IACEjC,UAAU,IAAIkC,uBADhB,QAEO,0BAFP;AAGA,OAAOC,kBAAP,IACEnC,UAAU,IAAIoC,wBADhB,QAEO,2BAFP;AAGA,OAAOC,mBAAP,IACEC,yBADF,EAEEtC,UAAU,IAAIuC,yBAFhB,QAGO,4BAHP;AAIA,OAAOC,sBAAP,IACEC,eADF,QAEO,wBAFP;AA0BA,SACE1C,sBADF,EAEEE,4BAFF,EAGEE,uCAHF,EAIEE,mCAJF,EAKEE,sCALF,EAMEE,gCANF,EAOEE,gCAPF,EAQEC,yBARF,EASEC,+BATF,EAUEC,mBAVF,EAWEC,yBAXF,EAYEE,sDAZF,EAaEE,6CAbF,EAcEE,sDAdF,EAeEE,4CAfF,EAgBEE,8BAhBF,EAiBEE,yBAjBF,EAkBED,kBAlBF,EAmBEE,kCAnBF,EAoBEC,qBApBF,EAqBEC,yBArBF,EAsBEC,6BAtBF,EAuBEC,sBAvBF,EAwBES,eAxBF,EAyBEH,yBAzBF,EA0BEL,iBA1BF,EA2BEC,uBA3BF,EA4BEC,kBA5BF,EA6BEC,wBA7BF,EA8BEC,mBA9BF,EA+BEE,yBA/BF,EAgCEC,sBAhCF"}
|
|
@@ -3,15 +3,18 @@ export declare const AUTH_API_PREFIX = "/auth";
|
|
|
3
3
|
export declare type AuthHandlersConfig<AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData> = {
|
|
4
4
|
ROOT_AUTHENTICATION_DATA: AUTHENTICATION_DATA;
|
|
5
5
|
};
|
|
6
|
+
export declare type AuthCookiesEnv = {
|
|
7
|
+
DEV_MODE?: string;
|
|
8
|
+
};
|
|
6
9
|
export declare type AuthCookiesConfig = {
|
|
7
|
-
ENV?: {
|
|
8
|
-
DEV_MODE?: string;
|
|
9
|
-
};
|
|
10
10
|
COOKIES: {
|
|
11
11
|
domain: string;
|
|
12
12
|
};
|
|
13
13
|
BASE_PATH?: string;
|
|
14
14
|
};
|
|
15
|
+
export declare type AuthCookiesDependencies = AuthCookiesConfig & {
|
|
16
|
+
ENV?: AuthCookiesEnv;
|
|
17
|
+
};
|
|
15
18
|
export declare type AuthCookiesData = {
|
|
16
19
|
refresh_token: string;
|
|
17
20
|
access_token: string;
|
|
@@ -22,5 +25,5 @@ export declare type AuthCookiesService = {
|
|
|
22
25
|
}) => string[];
|
|
23
26
|
parse: (content: string) => Partial<AuthCookiesData>;
|
|
24
27
|
};
|
|
25
|
-
declare const _default: import("knifecycle").ServiceInitializer<
|
|
28
|
+
declare const _default: import("knifecycle").ServiceInitializer<AuthCookiesDependencies, AuthCookiesService>;
|
|
26
29
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authCookies.js","names":["AUTH_API_PREFIX","autoService","initAuthCookies","ENV","COOKIES","BASE_PATH","build","data","session","cookie","serialize","access_token","path","httpOnly","domain","DEV_MODE","undefined","secure","sameSite","maxAge","refresh_token","Math","round","ms","parse","cookieHeader"],"sources":["../../src/services/authCookies.ts"],"sourcesContent":["import ms from 'ms';\nimport cookie from 'cookie';\nimport { autoService } from 'knifecycle';\nimport type { BaseAuthenticationData } from '@whook/authorization';\n\nexport const AUTH_API_PREFIX = '/auth';\n\nexport type AuthHandlersConfig<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = {\n ROOT_AUTHENTICATION_DATA: AUTHENTICATION_DATA;\n};\n\nexport type
|
|
1
|
+
{"version":3,"file":"authCookies.js","names":["AUTH_API_PREFIX","autoService","initAuthCookies","ENV","COOKIES","BASE_PATH","build","data","session","cookie","serialize","access_token","path","httpOnly","domain","DEV_MODE","undefined","secure","sameSite","maxAge","refresh_token","Math","round","ms","parse","cookieHeader"],"sources":["../../src/services/authCookies.ts"],"sourcesContent":["import ms from 'ms';\nimport cookie from 'cookie';\nimport { autoService } from 'knifecycle';\nimport type { BaseAuthenticationData } from '@whook/authorization';\n\nexport const AUTH_API_PREFIX = '/auth';\n\nexport type AuthHandlersConfig<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = {\n ROOT_AUTHENTICATION_DATA: AUTHENTICATION_DATA;\n};\n\nexport type AuthCookiesEnv = {\n DEV_MODE?: string;\n};\nexport type AuthCookiesConfig = {\n COOKIES: {\n domain: string;\n };\n BASE_PATH?: string;\n};\n\nexport type AuthCookiesDependencies = AuthCookiesConfig & {\n ENV?: AuthCookiesEnv;\n};\n\nexport type AuthCookiesData = {\n refresh_token: string;\n access_token: string;\n};\n\nexport type AuthCookiesService = {\n build: (\n data?: Partial<AuthCookiesData>,\n options?: { session: boolean },\n ) => string[];\n parse: (content: string) => Partial<AuthCookiesData>;\n};\n\nexport default autoService(initAuthCookies);\n\nasync function initAuthCookies({\n ENV = {},\n COOKIES,\n BASE_PATH = '',\n}: AuthCookiesDependencies): Promise<AuthCookiesService> {\n function build(data: Partial<AuthCookiesData> = {}, { session = true } = {}) {\n return [\n cookie.serialize('access_token', data.access_token || '', {\n path: BASE_PATH + AUTH_API_PREFIX,\n httpOnly: true,\n domain: ENV.DEV_MODE ? undefined : COOKIES.domain,\n secure: !ENV.DEV_MODE,\n ...(ENV.DEV_MODE ? {} : { sameSite: true }),\n ...(data.access_token ? {} : { maxAge: 0 }),\n }),\n cookie.serialize('refresh_token', data.refresh_token || '', {\n path: BASE_PATH + AUTH_API_PREFIX,\n httpOnly: true,\n domain: ENV.DEV_MODE ? undefined : COOKIES.domain,\n secure: !ENV.DEV_MODE,\n ...(ENV.DEV_MODE ? {} : { sameSite: true }),\n ...(session ? {} : { maxAge: Math.round(ms('100y') / 1000) }),\n }),\n ];\n }\n\n function parse(cookieHeader: string): Partial<AuthCookiesData> {\n const data = cookie.parse(cookieHeader);\n\n if (data.access_token && data.refresh_token) {\n return {\n access_token: data.access_token,\n refresh_token: data.refresh_token,\n };\n }\n\n return {};\n }\n\n return {\n build,\n parse,\n };\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAGO,MAAMA,eAAe,GAAG,OAAxB;;;eAmCQ,IAAAC,mBAAA,EAAYC,eAAZ,mD;;;;AAEf,eAAeA,eAAf,CAA+B;EAC7BC,GAAG,GAAG,EADuB;EAE7BC,OAF6B;EAG7BC,SAAS,GAAG;AAHiB,CAA/B,EAIyD;EACvD,SAASC,KAAT,CAAeC,IAA8B,GAAG,EAAhD,EAAoD;IAAEC,OAAO,GAAG;EAAZ,IAAqB,EAAzE,EAA6E;IAC3E,OAAO,CACLC,eAAA,CAAOC,SAAP,CAAiB,cAAjB,EAAiCH,IAAI,CAACI,YAAL,IAAqB,EAAtD,EAA0D;MACxDC,IAAI,EAAEP,SAAS,GAAGL,eADsC;MAExDa,QAAQ,EAAE,IAF8C;MAGxDC,MAAM,EAAEX,GAAG,CAACY,QAAJ,GAAeC,SAAf,GAA2BZ,OAAO,CAACU,MAHa;MAIxDG,MAAM,EAAE,CAACd,GAAG,CAACY,QAJ2C;MAKxD,IAAIZ,GAAG,CAACY,QAAJ,GAAe,EAAf,GAAoB;QAAEG,QAAQ,EAAE;MAAZ,CAAxB,CALwD;MAMxD,IAAIX,IAAI,CAACI,YAAL,GAAoB,EAApB,GAAyB;QAAEQ,MAAM,EAAE;MAAV,CAA7B;IANwD,CAA1D,CADK,EASLV,eAAA,CAAOC,SAAP,CAAiB,eAAjB,EAAkCH,IAAI,CAACa,aAAL,IAAsB,EAAxD,EAA4D;MAC1DR,IAAI,EAAEP,SAAS,GAAGL,eADwC;MAE1Da,QAAQ,EAAE,IAFgD;MAG1DC,MAAM,EAAEX,GAAG,CAACY,QAAJ,GAAeC,SAAf,GAA2BZ,OAAO,CAACU,MAHe;MAI1DG,MAAM,EAAE,CAACd,GAAG,CAACY,QAJ6C;MAK1D,IAAIZ,GAAG,CAACY,QAAJ,GAAe,EAAf,GAAoB;QAAEG,QAAQ,EAAE;MAAZ,CAAxB,CAL0D;MAM1D,IAAIV,OAAO,GAAG,EAAH,GAAQ;QAAEW,MAAM,EAAEE,IAAI,CAACC,KAAL,CAAW,IAAAC,WAAA,EAAG,MAAH,IAAa,IAAxB;MAAV,CAAnB;IAN0D,CAA5D,CATK,CAAP;EAkBD;;EAED,SAASC,KAAT,CAAeC,YAAf,EAA+D;IAC7D,MAAMlB,IAAI,GAAGE,eAAA,CAAOe,KAAP,CAAaC,YAAb,CAAb;;IAEA,IAAIlB,IAAI,CAACI,YAAL,IAAqBJ,IAAI,CAACa,aAA9B,EAA6C;MAC3C,OAAO;QACLT,YAAY,EAAEJ,IAAI,CAACI,YADd;QAELS,aAAa,EAAEb,IAAI,CAACa;MAFf,CAAP;IAID;;IAED,OAAO,EAAP;EACD;;EAED,OAAO;IACLd,KADK;IAELkB;EAFK,CAAP;AAID"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authCookies.mjs","names":["ms","cookie","autoService","AUTH_API_PREFIX","initAuthCookies","ENV","COOKIES","BASE_PATH","build","data","session","serialize","access_token","path","httpOnly","domain","DEV_MODE","undefined","secure","sameSite","maxAge","refresh_token","Math","round","parse","cookieHeader"],"sources":["../../src/services/authCookies.ts"],"sourcesContent":["import ms from 'ms';\nimport cookie from 'cookie';\nimport { autoService } from 'knifecycle';\nimport type { BaseAuthenticationData } from '@whook/authorization';\n\nexport const AUTH_API_PREFIX = '/auth';\n\nexport type AuthHandlersConfig<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = {\n ROOT_AUTHENTICATION_DATA: AUTHENTICATION_DATA;\n};\n\nexport type
|
|
1
|
+
{"version":3,"file":"authCookies.mjs","names":["ms","cookie","autoService","AUTH_API_PREFIX","initAuthCookies","ENV","COOKIES","BASE_PATH","build","data","session","serialize","access_token","path","httpOnly","domain","DEV_MODE","undefined","secure","sameSite","maxAge","refresh_token","Math","round","parse","cookieHeader"],"sources":["../../src/services/authCookies.ts"],"sourcesContent":["import ms from 'ms';\nimport cookie from 'cookie';\nimport { autoService } from 'knifecycle';\nimport type { BaseAuthenticationData } from '@whook/authorization';\n\nexport const AUTH_API_PREFIX = '/auth';\n\nexport type AuthHandlersConfig<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = {\n ROOT_AUTHENTICATION_DATA: AUTHENTICATION_DATA;\n};\n\nexport type AuthCookiesEnv = {\n DEV_MODE?: string;\n};\nexport type AuthCookiesConfig = {\n COOKIES: {\n domain: string;\n };\n BASE_PATH?: string;\n};\n\nexport type AuthCookiesDependencies = AuthCookiesConfig & {\n ENV?: AuthCookiesEnv;\n};\n\nexport type AuthCookiesData = {\n refresh_token: string;\n access_token: string;\n};\n\nexport type AuthCookiesService = {\n build: (\n data?: Partial<AuthCookiesData>,\n options?: { session: boolean },\n ) => string[];\n parse: (content: string) => Partial<AuthCookiesData>;\n};\n\nexport default autoService(initAuthCookies);\n\nasync function initAuthCookies({\n ENV = {},\n COOKIES,\n BASE_PATH = '',\n}: AuthCookiesDependencies): Promise<AuthCookiesService> {\n function build(data: Partial<AuthCookiesData> = {}, { session = true } = {}) {\n return [\n cookie.serialize('access_token', data.access_token || '', {\n path: BASE_PATH + AUTH_API_PREFIX,\n httpOnly: true,\n domain: ENV.DEV_MODE ? undefined : COOKIES.domain,\n secure: !ENV.DEV_MODE,\n ...(ENV.DEV_MODE ? {} : { sameSite: true }),\n ...(data.access_token ? {} : { maxAge: 0 }),\n }),\n cookie.serialize('refresh_token', data.refresh_token || '', {\n path: BASE_PATH + AUTH_API_PREFIX,\n httpOnly: true,\n domain: ENV.DEV_MODE ? undefined : COOKIES.domain,\n secure: !ENV.DEV_MODE,\n ...(ENV.DEV_MODE ? {} : { sameSite: true }),\n ...(session ? {} : { maxAge: Math.round(ms('100y') / 1000) }),\n }),\n ];\n }\n\n function parse(cookieHeader: string): Partial<AuthCookiesData> {\n const data = cookie.parse(cookieHeader);\n\n if (data.access_token && data.refresh_token) {\n return {\n access_token: data.access_token,\n refresh_token: data.refresh_token,\n };\n }\n\n return {};\n }\n\n return {\n build,\n parse,\n };\n}\n"],"mappings":"AAAA,OAAOA,EAAP,MAAe,IAAf;AACA,OAAOC,MAAP,MAAmB,QAAnB;AACA,SAASC,OAAW,IAAXA,QAAT,QAA4B,YAA5B;AAGA,OAAO,MAAMC,eAAe,GAAG,OAAxB;AAmCP,eAAeD,QAAW,CAACE,eAAD,mDAA1B;;AAEA,eAAeA,eAAf,CAA+B;EAC7BC,GAAG,GAAG,EADuB;EAE7BC,OAF6B;EAG7BC,SAAS,GAAG;AAHiB,CAA/B,EAIyD;EACvD,SAASC,KAAT,CAAeC,IAA8B,GAAG,EAAhD,EAAoD;IAAEC,OAAO,GAAG;EAAZ,IAAqB,EAAzE,EAA6E;IAC3E,OAAO,CACLT,MAAM,CAACU,SAAP,CAAiB,cAAjB,EAAiCF,IAAI,CAACG,YAAL,IAAqB,EAAtD,EAA0D;MACxDC,IAAI,EAAEN,SAAS,GAAGJ,eADsC;MAExDW,QAAQ,EAAE,IAF8C;MAGxDC,MAAM,EAAEV,GAAG,CAACW,QAAJ,GAAeC,SAAf,GAA2BX,OAAO,CAACS,MAHa;MAIxDG,MAAM,EAAE,CAACb,GAAG,CAACW,QAJ2C;MAKxD,IAAIX,GAAG,CAACW,QAAJ,GAAe,EAAf,GAAoB;QAAEG,QAAQ,EAAE;MAAZ,CAAxB,CALwD;MAMxD,IAAIV,IAAI,CAACG,YAAL,GAAoB,EAApB,GAAyB;QAAEQ,MAAM,EAAE;MAAV,CAA7B;IANwD,CAA1D,CADK,EASLnB,MAAM,CAACU,SAAP,CAAiB,eAAjB,EAAkCF,IAAI,CAACY,aAAL,IAAsB,EAAxD,EAA4D;MAC1DR,IAAI,EAAEN,SAAS,GAAGJ,eADwC;MAE1DW,QAAQ,EAAE,IAFgD;MAG1DC,MAAM,EAAEV,GAAG,CAACW,QAAJ,GAAeC,SAAf,GAA2BX,OAAO,CAACS,MAHe;MAI1DG,MAAM,EAAE,CAACb,GAAG,CAACW,QAJ6C;MAK1D,IAAIX,GAAG,CAACW,QAAJ,GAAe,EAAf,GAAoB;QAAEG,QAAQ,EAAE;MAAZ,CAAxB,CAL0D;MAM1D,IAAIT,OAAO,GAAG,EAAH,GAAQ;QAAEU,MAAM,EAAEE,IAAI,CAACC,KAAL,CAAWvB,EAAE,CAAC,MAAD,CAAF,GAAa,IAAxB;MAAV,CAAnB;IAN0D,CAA5D,CATK,CAAP;EAkBD;;EAED,SAASwB,KAAT,CAAeC,YAAf,EAA+D;IAC7D,MAAMhB,IAAI,GAAGR,MAAM,CAACuB,KAAP,CAAaC,YAAb,CAAb;;IAEA,IAAIhB,IAAI,CAACG,YAAL,IAAqBH,IAAI,CAACY,aAA9B,EAA6C;MAC3C,OAAO;QACLT,YAAY,EAAEH,IAAI,CAACG,YADd;QAELS,aAAa,EAAEZ,IAAI,CAACY;MAFf,CAAP;IAID;;IAED,OAAO,EAAP;EACD;;EAED,OAAO;IACLb,KADK;IAELgB;EAFK,CAAP;AAID"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whook/oauth2",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.1",
|
|
4
4
|
"description": "OAuth2 implementation for Whook servers",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"homepage": "https://github.com/nfroidure/whook",
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@types/cookie": "^0.5.1",
|
|
48
|
-
"@whook/authorization": "^9.0.
|
|
49
|
-
"@whook/whook": "^9.0.
|
|
48
|
+
"@whook/authorization": "^9.0.1",
|
|
49
|
+
"@whook/whook": "^9.0.1",
|
|
50
50
|
"camelcase": "^6.3.0",
|
|
51
51
|
"common-services": "^10.0.2",
|
|
52
52
|
"cookie": "^0.5.0",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"http-auth-utils": "^3.0.3",
|
|
77
77
|
"jest": "^28.1.0",
|
|
78
78
|
"jsdoc-to-markdown": "^7.1.1",
|
|
79
|
-
"metapak": "^4.0.
|
|
79
|
+
"metapak": "^4.0.4",
|
|
80
80
|
"metapak-nfroidure": "11.2.1",
|
|
81
81
|
"prettier": "^2.6.2",
|
|
82
82
|
"rimraf": "^3.0.2",
|
|
@@ -201,5 +201,6 @@
|
|
|
201
201
|
"prettier": "prettier --write 'src/**/*.ts'",
|
|
202
202
|
"test": "npm run jest",
|
|
203
203
|
"types": "rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist"
|
|
204
|
-
}
|
|
204
|
+
},
|
|
205
|
+
"gitHead": "a5620b3eacf3b500a5db59db9997bf7ed60668d5"
|
|
205
206
|
}
|
package/src/index.ts
CHANGED
|
@@ -49,10 +49,11 @@ import initAuthCookiesService, {
|
|
|
49
49
|
AUTH_API_PREFIX,
|
|
50
50
|
} from './services/authCookies';
|
|
51
51
|
import type {
|
|
52
|
-
|
|
53
|
-
AuthCookiesService,
|
|
52
|
+
AuthCookiesEnv,
|
|
54
53
|
AuthCookiesConfig,
|
|
54
|
+
AuthCookiesService,
|
|
55
55
|
AuthCookiesData,
|
|
56
|
+
AuthHandlersConfig,
|
|
56
57
|
} from './services/authCookies';
|
|
57
58
|
|
|
58
59
|
export type {
|
|
@@ -64,10 +65,11 @@ export type {
|
|
|
64
65
|
OAuth2GranterService,
|
|
65
66
|
OAuth2Options,
|
|
66
67
|
OAuth2Config,
|
|
67
|
-
|
|
68
|
-
AuthCookiesService,
|
|
68
|
+
AuthCookiesEnv,
|
|
69
69
|
AuthCookiesConfig,
|
|
70
|
+
AuthCookiesService,
|
|
70
71
|
AuthCookiesData,
|
|
72
|
+
AuthHandlersConfig,
|
|
71
73
|
};
|
|
72
74
|
export {
|
|
73
75
|
initGetOAuth2Authorize,
|
|
@@ -11,16 +11,20 @@ export type AuthHandlersConfig<
|
|
|
11
11
|
ROOT_AUTHENTICATION_DATA: AUTHENTICATION_DATA;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
export type AuthCookiesEnv = {
|
|
15
|
+
DEV_MODE?: string;
|
|
16
|
+
};
|
|
14
17
|
export type AuthCookiesConfig = {
|
|
15
|
-
ENV?: {
|
|
16
|
-
DEV_MODE?: string;
|
|
17
|
-
};
|
|
18
18
|
COOKIES: {
|
|
19
19
|
domain: string;
|
|
20
20
|
};
|
|
21
21
|
BASE_PATH?: string;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
+
export type AuthCookiesDependencies = AuthCookiesConfig & {
|
|
25
|
+
ENV?: AuthCookiesEnv;
|
|
26
|
+
};
|
|
27
|
+
|
|
24
28
|
export type AuthCookiesData = {
|
|
25
29
|
refresh_token: string;
|
|
26
30
|
access_token: string;
|
|
@@ -40,7 +44,7 @@ async function initAuthCookies({
|
|
|
40
44
|
ENV = {},
|
|
41
45
|
COOKIES,
|
|
42
46
|
BASE_PATH = '',
|
|
43
|
-
}:
|
|
47
|
+
}: AuthCookiesDependencies): Promise<AuthCookiesService> {
|
|
44
48
|
function build(data: Partial<AuthCookiesData> = {}, { session = true } = {}) {
|
|
45
49
|
return [
|
|
46
50
|
cookie.serialize('access_token', data.access_token || '', {
|