@go-mondo/identity-sdk 0.0.2-beta.44 → 0.0.2-beta.45

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 (64) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/.tsbuildinfo/cjs.json +1 -1
  3. package/.tsbuildinfo/esm.json +1 -1
  4. package/CHANGELOG.md +7 -0
  5. package/dist/cjs/oauth/authorize/schema/grants/authorization-code.d.ts +3 -2
  6. package/dist/cjs/oauth/authorize/schema/grants/authorization-code.d.ts.map +1 -1
  7. package/dist/cjs/oauth/authorize/schema/grants/authorization-code.js +11 -7
  8. package/dist/cjs/oauth/authorize/schema/grants/authorization-code.test.js +34 -34
  9. package/dist/cjs/oauth/authorize/schema/grants/implicit.d.ts +3 -2
  10. package/dist/cjs/oauth/authorize/schema/grants/implicit.d.ts.map +1 -1
  11. package/dist/cjs/oauth/authorize/schema/grants/implicit.js +2 -2
  12. package/dist/cjs/oauth/authorize/schema/schema.d.ts +3 -2
  13. package/dist/cjs/oauth/authorize/schema/schema.d.ts.map +1 -1
  14. package/dist/cjs/oauth/authorize/schema/schema.js +2 -2
  15. package/dist/cjs/oauth/common/schema.d.ts.map +1 -1
  16. package/dist/cjs/oauth/common/schema.js +7 -5
  17. package/dist/cjs/oauth/common/schema.test.js +0 -7
  18. package/dist/cjs/oauth/token/schema/grants/authorization-code.d.ts +9 -5
  19. package/dist/cjs/oauth/token/schema/grants/authorization-code.d.ts.map +1 -1
  20. package/dist/cjs/oauth/token/schema/grants/authorization-code.js +31 -11
  21. package/dist/cjs/oauth/token/schema/grants/client-credentials.d.ts +8 -15
  22. package/dist/cjs/oauth/token/schema/grants/client-credentials.d.ts.map +1 -1
  23. package/dist/cjs/oauth/token/schema/grants/client-credentials.js +18 -20
  24. package/dist/cjs/oauth/token/schema/grants/common.d.ts +6 -0
  25. package/dist/cjs/oauth/token/schema/grants/common.d.ts.map +1 -0
  26. package/dist/cjs/oauth/token/schema/grants/common.js +52 -0
  27. package/dist/cjs/oauth/token/schema/grants/refresh-token.d.ts +8 -4
  28. package/dist/cjs/oauth/token/schema/grants/refresh-token.d.ts.map +1 -1
  29. package/dist/cjs/oauth/token/schema/grants/refresh-token.js +23 -10
  30. package/dist/cjs/oauth/token/schema/schema.d.ts +19 -9
  31. package/dist/cjs/oauth/token/schema/schema.d.ts.map +1 -1
  32. package/dist/cjs/oauth/token/schema/schema.js +50 -5
  33. package/dist/cjs/oauth/token/schema/schema.test.js +13 -11
  34. package/dist/esm/oauth/authorize/schema/grants/authorization-code.d.ts +3 -2
  35. package/dist/esm/oauth/authorize/schema/grants/authorization-code.d.ts.map +1 -1
  36. package/dist/esm/oauth/authorize/schema/grants/authorization-code.js +10 -6
  37. package/dist/esm/oauth/authorize/schema/grants/authorization-code.test.js +35 -35
  38. package/dist/esm/oauth/authorize/schema/grants/implicit.d.ts +3 -2
  39. package/dist/esm/oauth/authorize/schema/grants/implicit.d.ts.map +1 -1
  40. package/dist/esm/oauth/authorize/schema/grants/implicit.js +1 -1
  41. package/dist/esm/oauth/authorize/schema/schema.d.ts +3 -2
  42. package/dist/esm/oauth/authorize/schema/schema.d.ts.map +1 -1
  43. package/dist/esm/oauth/authorize/schema/schema.js +3 -3
  44. package/dist/esm/oauth/common/schema.d.ts.map +1 -1
  45. package/dist/esm/oauth/common/schema.js +7 -5
  46. package/dist/esm/oauth/common/schema.test.js +0 -7
  47. package/dist/esm/oauth/token/schema/grants/authorization-code.d.ts +9 -5
  48. package/dist/esm/oauth/token/schema/grants/authorization-code.d.ts.map +1 -1
  49. package/dist/esm/oauth/token/schema/grants/authorization-code.js +30 -10
  50. package/dist/esm/oauth/token/schema/grants/client-credentials.d.ts +9 -16
  51. package/dist/esm/oauth/token/schema/grants/client-credentials.d.ts.map +1 -1
  52. package/dist/esm/oauth/token/schema/grants/client-credentials.js +16 -18
  53. package/dist/esm/oauth/token/schema/grants/common.d.ts +6 -0
  54. package/dist/esm/oauth/token/schema/grants/common.d.ts.map +1 -0
  55. package/dist/esm/oauth/token/schema/grants/common.js +16 -0
  56. package/dist/esm/oauth/token/schema/grants/refresh-token.d.ts +8 -4
  57. package/dist/esm/oauth/token/schema/grants/refresh-token.d.ts.map +1 -1
  58. package/dist/esm/oauth/token/schema/grants/refresh-token.js +21 -8
  59. package/dist/esm/oauth/token/schema/schema.d.ts +20 -10
  60. package/dist/esm/oauth/token/schema/schema.d.ts.map +1 -1
  61. package/dist/esm/oauth/token/schema/schema.js +52 -7
  62. package/dist/esm/oauth/token/schema/schema.test.js +14 -12
  63. package/package.json +1 -1
  64. package/dist/esm/package.json +0 -1
@@ -33,31 +33,29 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ClientCredentialsSchema = exports.ClientCredentialsPayloadSchema = void 0;
36
+ exports.ClientCredentialsRequestSchema = void 0;
37
37
  const z = __importStar(require("zod/v4"));
38
- const schema_js_1 = require("../../../../app/schema.js");
39
- const schema_js_2 = require("../../../common/schema.js");
38
+ const schema_js_1 = require("../../../common/schema.js");
39
+ const common_js_1 = require("./common.js");
40
40
  /**
41
41
  * @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.4.2
42
42
  */
43
- const GrantTypeSchema = z.enum([schema_js_2.GrantType.CLIENT_CREDENTIALS]);
43
+ const GrantTypeSchema = z.enum([schema_js_1.GrantType.CLIENT_CREDENTIALS]);
44
44
  /**
45
- * What the incoming body may look like.
45
+ * Note: Prior to using this schema, the headers should be checked for
46
+ * HTTP Basic Authentication. If present, the client_id and client_secret
47
+ * should be included in with the payload before parsing.
46
48
  *
47
- * Note: the client_id and client_secrete may (likely) be in Authorization header
49
+ * @see https://datatracker.ietf.org/doc/html/rfc6749#section-4.4.2
48
50
  */
49
- exports.ClientCredentialsPayloadSchema = z.object({
50
- grant_type: GrantTypeSchema,
51
- scope: z.string().optional(),
52
- client_id: schema_js_1.AppIdSchema.optional(),
53
- client_secret: z.string().optional(),
54
- ...schema_js_2.OptionalSchema.shape,
55
- });
56
- exports.ClientCredentialsSchema = z.object({
57
- ...exports.ClientCredentialsPayloadSchema.omit({
58
- client_id: true,
59
- client_secret: true,
60
- }).shape,
61
- client_id: schema_js_1.AppIdSchema,
62
- client_secret: z.string(),
51
+ exports.ClientCredentialsRequestSchema = z.object({
52
+ /**
53
+ * REQUIRED. Value MUST be set to "client_credentials".
54
+ */
55
+ grant_type: GrantTypeSchema.describe('The grant type.'),
56
+ /**
57
+ * OPTIONAL. The scope of the access request.
58
+ */
59
+ scope: schema_js_1.ScopeSchema.optional(),
60
+ ...common_js_1.ClientRequestSchema.shape,
63
61
  });
@@ -0,0 +1,6 @@
1
+ import * as z from 'zod/v4';
2
+ export declare const ClientRequestSchema: z.ZodObject<{
3
+ client_id: z.ZodString;
4
+ client_secret: z.ZodString;
5
+ }, z.core.$strip>;
6
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../../src/oauth/token/schema/grants/common.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,eAAO,MAAM,mBAAmB;;;iBAc9B,CAAC"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ClientRequestSchema = void 0;
37
+ const app_1 = require("src/app");
38
+ const z = __importStar(require("zod/v4"));
39
+ exports.ClientRequestSchema = z.object({
40
+ /**
41
+ * REQUIRED. The client identifier.
42
+ * NOTE: This is only required in the body if the client is NOT authenticating
43
+ * via the HTTP "Authorization" header (Basic Auth).
44
+ */
45
+ client_id: app_1.AppIdSchema.describe('The Client ID.'),
46
+ /**
47
+ * REQUIRED. The client secret.
48
+ * NOTE: This is only required in the body if the client is NOT authenticating
49
+ * via the HTTP "Authorization" header (Basic Auth).
50
+ */
51
+ client_secret: z.string().min(1).describe('The Client Secret.'),
52
+ });
@@ -1,12 +1,16 @@
1
1
  import * as z from 'zod/v4';
2
- export declare const RefreshTokenSchema: z.ZodObject<{
2
+ /**
3
+ * @see https://datatracker.ietf.org/doc/html/rfc6749#section-6
4
+ */
5
+ export declare const RefreshTokenRequestSchema: z.ZodObject<{
6
+ client_id: z.ZodString;
7
+ client_secret: z.ZodString;
3
8
  grant_type: z.ZodEnum<{
4
9
  refresh_token: "refresh_token";
5
10
  }>;
6
11
  refresh_token: z.ZodString;
7
12
  scope: z.ZodOptional<z.ZodString>;
8
- client_id: z.ZodString;
9
- client_secret: z.ZodString;
10
13
  }, z.core.$strip>;
11
- export type RefreshTokenPayload = z.output<typeof RefreshTokenSchema>;
14
+ export type RefreshTokenRequestInput = z.input<typeof RefreshTokenRequestSchema>;
15
+ export type RefreshTokenRequestPayload = z.output<typeof RefreshTokenRequestSchema>;
12
16
  //# sourceMappingURL=refresh-token.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"refresh-token.d.ts","sourceRoot":"","sources":["../../../../../../src/oauth/token/schema/grants/refresh-token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAS5B,eAAO,MAAM,kBAAkB;;;;;;;;iBAM7B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
1
+ {"version":3,"file":"refresh-token.d.ts","sourceRoot":"","sources":["../../../../../../src/oauth/token/schema/grants/refresh-token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAS5B;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;iBAmBpC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,yBAAyB,CACjC,CAAC;AACF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAC/C,OAAO,yBAAyB,CACjC,CAAC"}
@@ -33,18 +33,31 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.RefreshTokenSchema = void 0;
36
+ exports.RefreshTokenRequestSchema = void 0;
37
37
  const z = __importStar(require("zod/v4"));
38
- const schema_js_1 = require("../../../../app/schema.js");
39
- const schema_js_2 = require("../../../common/schema.js");
38
+ const schema_js_1 = require("../../../common/schema.js");
39
+ const common_js_1 = require("./common.js");
40
40
  /**
41
41
  * @see https://datatracker.ietf.org/doc/html/rfc6749#section-6
42
42
  */
43
- const GrantTypeSchema = z.enum([schema_js_2.GrantType.REFRESH_TOKEN]);
44
- exports.RefreshTokenSchema = z.object({
45
- grant_type: GrantTypeSchema,
46
- refresh_token: z.string(),
47
- scope: z.string().optional(),
48
- client_id: schema_js_1.AppIdSchema,
49
- client_secret: z.string(),
43
+ const GrantTypeSchema = z.enum([schema_js_1.GrantType.REFRESH_TOKEN]);
44
+ /**
45
+ * @see https://datatracker.ietf.org/doc/html/rfc6749#section-6
46
+ */
47
+ exports.RefreshTokenRequestSchema = z.object({
48
+ /**
49
+ * REQUIRED. Value MUST be set to "refresh_token".
50
+ */
51
+ grant_type: GrantTypeSchema.describe('The grant type.'),
52
+ /**
53
+ * REQUIRED. The refresh token issued to the client.
54
+ */
55
+ refresh_token: z.string().min(1).describe('The refresh token.'),
56
+ /**
57
+ * OPTIONAL. The scope of the access request. If omitted, the scope is
58
+ * unchanged from the original grant. If specified, it must be equal to or
59
+ * a subset of the original scope.
60
+ */
61
+ scope: schema_js_1.ScopeSchema.optional(),
62
+ ...common_js_1.ClientRequestSchema.shape,
50
63
  });
@@ -5,31 +5,41 @@ export * from './grants/refresh-token.js';
5
5
  /**
6
6
  * Union(s)
7
7
  */
8
- export declare const Schema: z.ZodDiscriminatedUnion<[z.ZodObject<{
8
+ export declare const RequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
9
9
  code_verifier: z.ZodOptional<z.ZodString>;
10
+ client_id: z.ZodString;
11
+ client_secret: z.ZodString;
10
12
  grant_type: z.ZodEnum<{
11
13
  authorization_code: "authorization_code";
12
14
  }>;
13
15
  code: z.ZodString;
14
- client_id: z.ZodString;
15
- client_secret: z.ZodOptional<z.ZodString>;
16
- redirect_uri: z.ZodURL;
16
+ redirect_uri: z.ZodOptional<z.ZodURL>;
17
17
  }, z.core.$strip>, z.ZodObject<{
18
18
  client_id: z.ZodString;
19
19
  client_secret: z.ZodString;
20
- audience: z.ZodOptional<z.ZodString>;
21
- scope: z.ZodOptional<z.ZodString>;
22
20
  grant_type: z.ZodEnum<{
23
21
  client_credentials: "client_credentials";
24
22
  }>;
23
+ scope: z.ZodOptional<z.ZodString>;
25
24
  }, z.core.$strip>, z.ZodObject<{
25
+ client_id: z.ZodString;
26
+ client_secret: z.ZodString;
26
27
  grant_type: z.ZodEnum<{
27
28
  refresh_token: "refresh_token";
28
29
  }>;
29
30
  refresh_token: z.ZodString;
30
31
  scope: z.ZodOptional<z.ZodString>;
31
- client_id: z.ZodString;
32
- client_secret: z.ZodString;
33
32
  }, z.core.$strip>], "grant_type">;
34
- export type Payload = z.output<typeof Schema>;
33
+ export type RequestInput = z.input<typeof RequestSchema>;
34
+ export type RequestPayload = z.output<typeof RequestSchema>;
35
+ export declare const ResponseSchema: z.ZodObject<{
36
+ access_token: z.ZodString;
37
+ token_type: z.ZodLiteral<"Bearer">;
38
+ expires_in: z.ZodOptional<z.ZodNumber>;
39
+ refresh_token: z.ZodOptional<z.ZodString>;
40
+ scope: z.ZodOptional<z.ZodString>;
41
+ id_token: z.ZodOptional<z.ZodString>;
42
+ }, z.core.$strip>;
43
+ export type ResponseInput = z.input<typeof ResponseSchema>;
44
+ export type ResponsePayload = z.output<typeof ResponseSchema>;
35
45
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../../src/oauth/token/schema/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAM5B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;iCAIjB,CAAC;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../../src/oauth/token/schema/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAO5B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;iCAIxB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACzD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAK5D,eAAO,MAAM,cAAc;;;;;;;iBA6CzB,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAC3D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC"}
@@ -36,8 +36,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.Schema = void 0;
39
+ exports.ResponseSchema = exports.RequestSchema = void 0;
40
40
  const z = __importStar(require("zod/v4"));
41
+ const schema_js_1 = require("../../common/schema.js");
41
42
  const authorization_code_js_1 = require("./grants/authorization-code.js");
42
43
  const client_credentials_js_1 = require("./grants/client-credentials.js");
43
44
  const refresh_token_js_1 = require("./grants/refresh-token.js");
@@ -47,8 +48,52 @@ __exportStar(require("./grants/refresh-token.js"), exports);
47
48
  /**
48
49
  * Union(s)
49
50
  */
50
- exports.Schema = z.discriminatedUnion('grant_type', [
51
- authorization_code_js_1.AuthorizationCodeSchema,
52
- client_credentials_js_1.ClientCredentialsSchema,
53
- refresh_token_js_1.RefreshTokenSchema,
51
+ exports.RequestSchema = z.discriminatedUnion('grant_type', [
52
+ authorization_code_js_1.AuthorizationCodeRequestSchema,
53
+ client_credentials_js_1.ClientCredentialsRequestSchema,
54
+ refresh_token_js_1.RefreshTokenRequestSchema,
54
55
  ]);
56
+ /*
57
+ * @see https://datatracker.ietf.org/doc/html/rfc6749#section-5.1
58
+ */
59
+ exports.ResponseSchema = z.object({
60
+ /**
61
+ * REQUIRED. The access token issued by the authorization server.
62
+ * Typically a JWT or an opaque string.
63
+ */
64
+ access_token: z
65
+ .string()
66
+ .min(1)
67
+ .describe('The access token issued by the authorization server.'),
68
+ /**
69
+ * REQUIRED. The type of the token issued. Value is typically 'Bearer'.
70
+ */
71
+ token_type: z
72
+ .literal('Bearer')
73
+ .describe('The type of the token issued. Must be "Bearer".'),
74
+ /**
75
+ * RECOMMENDED. The lifetime in seconds of the access token.
76
+ * For example, the value 3600 represents an expiration time of one hour.
77
+ */
78
+ expires_in: z
79
+ .number()
80
+ .int()
81
+ .positive()
82
+ .optional()
83
+ .describe('The lifetime in seconds of the access token.'),
84
+ /**
85
+ * OPTIONAL. The refresh token, which can be used to obtain a new access token
86
+ * when the current one expires.
87
+ */
88
+ refresh_token: z.string().min(1).optional().describe('The refresh token.'),
89
+ /**
90
+ * OPTIONAL. The scope of the access token as issued by the authorization server.
91
+ * If omitted, the scope is the same as the scope originally requested by the client.
92
+ */
93
+ scope: schema_js_1.ScopeSchema.optional(),
94
+ /**
95
+ * OPTIONAL, for OpenID Connect (OIDC). The ID token, a JWT that contains claims
96
+ * about the authentication of the end-user.
97
+ */
98
+ id_token: z.string().min(1).optional().describe('The ID Token (OIDC only).'),
99
+ });
@@ -10,9 +10,10 @@ const schema_js_1 = require("./schema.js");
10
10
  grant_type: 'authorization_code',
11
11
  code: 'auth_code_123',
12
12
  client_id: (0, utils_js_1.generateAppId)(),
13
+ client_secret: 'secret_123',
13
14
  redirect_uri: 'https://example.com/callback',
14
15
  };
15
- const result = schema_js_1.Schema.safeParse(payload);
16
+ const result = schema_js_1.RequestSchema.safeParse(payload);
16
17
  // Parse succeeds for valid data
17
18
  (0, vitest_1.expect)(result.success).toBe(true);
18
19
  if (result.success) {
@@ -24,10 +25,11 @@ const schema_js_1 = require("./schema.js");
24
25
  grant_type: 'authorization_code',
25
26
  code: 'auth_code_123',
26
27
  client_id: (0, utils_js_1.generateAppId)(),
28
+ client_secret: 'secret_123',
27
29
  redirect_uri: 'https://example.com/callback',
28
30
  code_verifier: 'pkce_verifier_123',
29
31
  };
30
- const result = schema_js_1.Schema.safeParse(payload);
32
+ const result = schema_js_1.RequestSchema.safeParse(payload);
31
33
  // Parse succeeds for valid data
32
34
  (0, vitest_1.expect)(result.success).toBe(true);
33
35
  if (result.success) {
@@ -42,7 +44,7 @@ const schema_js_1 = require("./schema.js");
42
44
  client_secret: 'secret_123',
43
45
  redirect_uri: 'https://example.com/callback',
44
46
  };
45
- const result = schema_js_1.Schema.safeParse(payload);
47
+ const result = schema_js_1.RequestSchema.safeParse(payload);
46
48
  // Parse succeeds for valid data
47
49
  (0, vitest_1.expect)(result.success).toBe(true);
48
50
  if (result.success) {
@@ -56,7 +58,7 @@ const schema_js_1 = require("./schema.js");
56
58
  client_secret: 'secret_123',
57
59
  scope: 'read write',
58
60
  };
59
- const result = schema_js_1.Schema.safeParse(payload);
61
+ const result = schema_js_1.RequestSchema.safeParse(payload);
60
62
  // Parse succeeds for valid data
61
63
  (0, vitest_1.expect)(result.success).toBe(true);
62
64
  if (result.success) {
@@ -71,7 +73,7 @@ const schema_js_1 = require("./schema.js");
71
73
  client_secret: 'secret_123',
72
74
  scope: 'read',
73
75
  };
74
- const result = schema_js_1.Schema.safeParse(payload);
76
+ const result = schema_js_1.RequestSchema.safeParse(payload);
75
77
  // Parse succeeds for valid data
76
78
  (0, vitest_1.expect)(result.success).toBe(true);
77
79
  if (result.success) {
@@ -85,7 +87,7 @@ const schema_js_1 = require("./schema.js");
85
87
  client_id: (0, utils_js_1.generateAppId)(),
86
88
  redirect_uri: 'https://example.com/callback',
87
89
  };
88
- const result = schema_js_1.Schema.safeParse(payload);
90
+ const result = schema_js_1.RequestSchema.safeParse(payload);
89
91
  (0, vitest_1.expect)(result.success).toBe(false);
90
92
  });
91
93
  (0, vitest_1.test)('should reject authorization code without required fields', () => {
@@ -94,7 +96,7 @@ const schema_js_1 = require("./schema.js");
94
96
  client_id: (0, utils_js_1.generateAppId)(),
95
97
  // missing code and redirect_uri
96
98
  };
97
- const result = schema_js_1.Schema.safeParse(payload);
99
+ const result = schema_js_1.RequestSchema.safeParse(payload);
98
100
  (0, vitest_1.expect)(result.success).toBe(false);
99
101
  });
100
102
  (0, vitest_1.test)('should reject invalid redirect URI', () => {
@@ -104,7 +106,7 @@ const schema_js_1 = require("./schema.js");
104
106
  client_id: (0, utils_js_1.generateAppId)(),
105
107
  redirect_uri: 'not-a-valid-url',
106
108
  };
107
- const result = schema_js_1.Schema.safeParse(payload);
109
+ const result = schema_js_1.RequestSchema.safeParse(payload);
108
110
  (0, vitest_1.expect)(result.success).toBe(false);
109
111
  });
110
112
  (0, vitest_1.test)('should reject client credentials without required fields', () => {
@@ -113,7 +115,7 @@ const schema_js_1 = require("./schema.js");
113
115
  client_id: (0, utils_js_1.generateAppId)(),
114
116
  // missing client_secret
115
117
  };
116
- const result = schema_js_1.Schema.safeParse(payload);
118
+ const result = schema_js_1.RequestSchema.safeParse(payload);
117
119
  (0, vitest_1.expect)(result.success).toBe(false);
118
120
  });
119
121
  (0, vitest_1.test)('should reject refresh token without required fields', () => {
@@ -122,14 +124,14 @@ const schema_js_1 = require("./schema.js");
122
124
  client_id: 'app_123',
123
125
  // missing refresh_token and client_secret
124
126
  };
125
- const result = schema_js_1.Schema.safeParse(payload);
127
+ const result = schema_js_1.RequestSchema.safeParse(payload);
126
128
  (0, vitest_1.expect)(result.success).toBe(false);
127
129
  });
128
130
  (0, vitest_1.test)('should reject completely invalid payload', () => {
129
131
  const payload = {
130
132
  invalid: 'data',
131
133
  };
132
- const result = schema_js_1.Schema.safeParse(payload);
134
+ const result = schema_js_1.RequestSchema.safeParse(payload);
133
135
  (0, vitest_1.expect)(result.success).toBe(false);
134
136
  });
135
137
  });
@@ -1,6 +1,6 @@
1
1
  import * as z from 'zod/v4';
2
2
  export declare const CodeChallengeSchema: z.ZodString;
3
- export declare const AuthorizationCodeSchema: z.ZodObject<{
3
+ export declare const AuthorizationCodeRequestSchema: z.ZodObject<{
4
4
  code_challenge_method: z.ZodOptional<z.ZodEnum<{
5
5
  S256: "S256";
6
6
  plain: "plain";
@@ -29,5 +29,6 @@ export declare const AuthorizationCodeSchema: z.ZodObject<{
29
29
  scope: z.ZodOptional<z.ZodString>;
30
30
  state: z.ZodOptional<z.ZodString>;
31
31
  }, z.core.$strip>;
32
- export type AuthorizationCodePayload = z.output<typeof AuthorizationCodeSchema>;
32
+ export type AuthorizationCodeRequestInput = z.input<typeof AuthorizationCodeRequestSchema>;
33
+ export type AuthorizationCodeRequestPayload = z.output<typeof AuthorizationCodeRequestSchema>;
33
34
  //# sourceMappingURL=authorization-code.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authorization-code.d.ts","sourceRoot":"","sources":["../../../../../../src/oauth/authorize/schema/grants/authorization-code.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAiB5B,eAAO,MAAM,mBAAmB,aAKmC,CAAC;AAmCpE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyBhC,CAAC;AACL,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
1
+ {"version":3,"file":"authorization-code.d.ts","sourceRoot":"","sources":["../../../../../../src/oauth/authorize/schema/grants/authorization-code.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAiB5B,eAAO,MAAM,mBAAmB,aAKmC,CAAC;AAyCpE,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyBvC,CAAC;AACL,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CACjD,OAAO,8BAA8B,CACtC,CAAC;AACF,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,MAAM,CACpD,OAAO,8BAA8B,CACtC,CAAC"}
@@ -30,11 +30,15 @@ export const CodeChallengeSchema = z
30
30
  // message: 'code_challenge and code_challenge_method must both be present or both be absent',
31
31
  // });
32
32
  const OAuthSchema = z.object({
33
- response_type: ResponseTypeSchema,
34
- client_id: AppIdSchema,
35
- redirect_uri: z.url().optional(),
36
- scope: z.string().optional(),
37
- state: z.string().optional(),
33
+ response_type: ResponseTypeSchema.describe('Must be set to "code" for Authorization Code flow.'),
34
+ client_id: AppIdSchema.describe('The Client ID.'),
35
+ redirect_uri: z.url().optional().describe('The callback URL.'),
36
+ scope: z
37
+ .string()
38
+ .min(1)
39
+ .optional()
40
+ .describe('Space-delimited scope strings.'),
41
+ state: z.string().min(1).optional().describe('Opaque value to prevent CSRF.'),
38
42
  });
39
43
  const OIDCSchema = z.object({
40
44
  nonce: z.string().optional(),
@@ -42,7 +46,7 @@ const OIDCSchema = z.object({
42
46
  prompt: AuthorizationPromptSchema.optional(),
43
47
  max_age: z.number().int().min(0).optional(),
44
48
  });
45
- export const AuthorizationCodeSchema = z
49
+ export const AuthorizationCodeRequestSchema = z
46
50
  .object({
47
51
  ...OAuthSchema.shape,
48
52
  ...OIDCSchema.shape,