@whook/oauth2 25.1.0 → 25.2.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.
Files changed (36) hide show
  1. package/dist/index.d.ts +3 -1
  2. package/dist/index.js +3 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.test.js +5 -5
  5. package/dist/index.test.js.map +1 -1
  6. package/dist/libs/scopes.d.ts +2 -0
  7. package/dist/libs/scopes.js +27 -0
  8. package/dist/libs/scopes.js.map +1 -0
  9. package/dist/routes/getOAuth2WellKnownMetadata.d.ts +8 -1
  10. package/dist/routes/getOAuth2WellKnownMetadata.js +14 -8
  11. package/dist/routes/getOAuth2WellKnownMetadata.js.map +1 -1
  12. package/dist/routes/getOAuth2WellKnownMetadata.test.js +40 -2
  13. package/dist/routes/getOAuth2WellKnownMetadata.test.js.map +1 -1
  14. package/dist/routes/getOAuth2WellKnownProtectedResourceMetadata.d.ts +79 -0
  15. package/dist/routes/getOAuth2WellKnownProtectedResourceMetadata.js +86 -0
  16. package/dist/routes/getOAuth2WellKnownProtectedResourceMetadata.js.map +1 -0
  17. package/dist/routes/getOAuth2WellKnownProtectedResourceMetadata.test.d.ts +1 -0
  18. package/dist/routes/getOAuth2WellKnownProtectedResourceMetadata.test.js +44 -0
  19. package/dist/routes/getOAuth2WellKnownProtectedResourceMetadata.test.js.map +1 -0
  20. package/dist/routes/postOAuth2Acknowledge.d.ts +9 -0
  21. package/dist/routes/postOAuth2Acknowledge.js +12 -2
  22. package/dist/routes/postOAuth2Acknowledge.js.map +1 -1
  23. package/dist/routes/postOAuth2Acknowledge.test.js +2 -2
  24. package/dist/services/authCookies.d.ts +2 -1
  25. package/dist/services/authCookies.js.map +1 -1
  26. package/package.json +4 -4
  27. package/src/index.test.ts +5 -5
  28. package/src/index.ts +11 -0
  29. package/src/libs/scopes.ts +31 -0
  30. package/src/routes/getOAuth2WellKnownMetadata.test.ts +41 -2
  31. package/src/routes/getOAuth2WellKnownMetadata.ts +19 -12
  32. package/src/routes/getOAuth2WellKnownProtectedResourceMetadata.test.ts +49 -0
  33. package/src/routes/getOAuth2WellKnownProtectedResourceMetadata.ts +115 -0
  34. package/src/routes/postOAuth2Acknowledge.test.ts +2 -2
  35. package/src/routes/postOAuth2Acknowledge.ts +16 -2
  36. package/src/services/authCookies.ts +2 -1
@@ -1,9 +1,14 @@
1
1
  import { autoService, location } from 'knifecycle';
2
2
  import { printStackTrace, YError } from 'yerror';
3
- import { setURLError } from './getOAuth2Authorize.js';
3
+ import {
4
+ codeChallengeMethodSchema,
5
+ codeChallengeSchema,
6
+ setURLError,
7
+ } from './getOAuth2Authorize.js';
4
8
  import {
5
9
  type WhookRouteDefinition,
6
10
  type WhookErrorsDescriptors,
11
+ refersTo,
7
12
  } from '@whook/whook';
8
13
  import {
9
14
  type CheckApplicationService,
@@ -67,6 +72,8 @@ export const definition = {
67
72
  description:
68
73
  'Wether the user acknowledged the delegation or not.',
69
74
  },
75
+ codeChallenge: refersTo(codeChallengeSchema),
76
+ codeChallengeMethod: refersTo(codeChallengeMethodSchema),
70
77
  },
71
78
  },
72
79
  },
@@ -75,6 +82,13 @@ export const definition = {
75
82
  responses: {
76
83
  '201': {
77
84
  description: 'Redirection endpoint URI computed.',
85
+ headers: {
86
+ location: {
87
+ schema: {
88
+ type: 'string',
89
+ },
90
+ },
91
+ },
78
92
  content: {
79
93
  'application/json': {
80
94
  schema: {
@@ -207,7 +221,7 @@ async function initPostOAuth2Acknowledge({
207
221
  }
208
222
 
209
223
  return {
210
- status: 302,
224
+ status: 201,
211
225
  headers: {
212
226
  location: url.href,
213
227
  },
@@ -3,6 +3,7 @@ import cookie, { type SerializeOptions } from 'cookie';
3
3
  import { autoService, location } from 'knifecycle';
4
4
  import { type WhookAuthenticationData } from '@whook/authorization';
5
5
  import { type Jsonify } from 'type-fest';
6
+ import { type WhookRouteDefinitionBasePath } from '@whook/whook';
6
7
 
7
8
  export const AUTH_API_PREFIX = '/auth';
8
9
 
@@ -16,7 +17,7 @@ export type AuthCookiesOptions = Jsonify<
16
17
 
17
18
  export interface AuthCookiesConfig {
18
19
  COOKIES: AuthCookiesOptions;
19
- BASE_PATH?: string;
20
+ BASE_PATH?: WhookRouteDefinitionBasePath;
20
21
  }
21
22
 
22
23
  export type AuthCookiesDependencies = AuthCookiesConfig;