@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.
- package/.release-please-manifest.json +1 -1
- package/.tsbuildinfo/cjs.json +1 -1
- package/.tsbuildinfo/esm.json +1 -1
- package/CHANGELOG.md +7 -0
- package/dist/cjs/oauth/authorize/schema/grants/authorization-code.d.ts +3 -2
- package/dist/cjs/oauth/authorize/schema/grants/authorization-code.d.ts.map +1 -1
- package/dist/cjs/oauth/authorize/schema/grants/authorization-code.js +11 -7
- package/dist/cjs/oauth/authorize/schema/grants/authorization-code.test.js +34 -34
- package/dist/cjs/oauth/authorize/schema/grants/implicit.d.ts +3 -2
- package/dist/cjs/oauth/authorize/schema/grants/implicit.d.ts.map +1 -1
- package/dist/cjs/oauth/authorize/schema/grants/implicit.js +2 -2
- package/dist/cjs/oauth/authorize/schema/schema.d.ts +3 -2
- package/dist/cjs/oauth/authorize/schema/schema.d.ts.map +1 -1
- package/dist/cjs/oauth/authorize/schema/schema.js +2 -2
- package/dist/cjs/oauth/common/schema.d.ts.map +1 -1
- package/dist/cjs/oauth/common/schema.js +7 -5
- package/dist/cjs/oauth/common/schema.test.js +0 -7
- package/dist/cjs/oauth/token/schema/grants/authorization-code.d.ts +9 -5
- package/dist/cjs/oauth/token/schema/grants/authorization-code.d.ts.map +1 -1
- package/dist/cjs/oauth/token/schema/grants/authorization-code.js +31 -11
- package/dist/cjs/oauth/token/schema/grants/client-credentials.d.ts +8 -15
- package/dist/cjs/oauth/token/schema/grants/client-credentials.d.ts.map +1 -1
- package/dist/cjs/oauth/token/schema/grants/client-credentials.js +18 -20
- package/dist/cjs/oauth/token/schema/grants/common.d.ts +6 -0
- package/dist/cjs/oauth/token/schema/grants/common.d.ts.map +1 -0
- package/dist/cjs/oauth/token/schema/grants/common.js +52 -0
- package/dist/cjs/oauth/token/schema/grants/refresh-token.d.ts +8 -4
- package/dist/cjs/oauth/token/schema/grants/refresh-token.d.ts.map +1 -1
- package/dist/cjs/oauth/token/schema/grants/refresh-token.js +23 -10
- package/dist/cjs/oauth/token/schema/schema.d.ts +19 -9
- package/dist/cjs/oauth/token/schema/schema.d.ts.map +1 -1
- package/dist/cjs/oauth/token/schema/schema.js +50 -5
- package/dist/cjs/oauth/token/schema/schema.test.js +13 -11
- package/dist/esm/oauth/authorize/schema/grants/authorization-code.d.ts +3 -2
- package/dist/esm/oauth/authorize/schema/grants/authorization-code.d.ts.map +1 -1
- package/dist/esm/oauth/authorize/schema/grants/authorization-code.js +10 -6
- package/dist/esm/oauth/authorize/schema/grants/authorization-code.test.js +35 -35
- package/dist/esm/oauth/authorize/schema/grants/implicit.d.ts +3 -2
- package/dist/esm/oauth/authorize/schema/grants/implicit.d.ts.map +1 -1
- package/dist/esm/oauth/authorize/schema/grants/implicit.js +1 -1
- package/dist/esm/oauth/authorize/schema/schema.d.ts +3 -2
- package/dist/esm/oauth/authorize/schema/schema.d.ts.map +1 -1
- package/dist/esm/oauth/authorize/schema/schema.js +3 -3
- package/dist/esm/oauth/common/schema.d.ts.map +1 -1
- package/dist/esm/oauth/common/schema.js +7 -5
- package/dist/esm/oauth/common/schema.test.js +0 -7
- package/dist/esm/oauth/token/schema/grants/authorization-code.d.ts +9 -5
- package/dist/esm/oauth/token/schema/grants/authorization-code.d.ts.map +1 -1
- package/dist/esm/oauth/token/schema/grants/authorization-code.js +30 -10
- package/dist/esm/oauth/token/schema/grants/client-credentials.d.ts +9 -16
- package/dist/esm/oauth/token/schema/grants/client-credentials.d.ts.map +1 -1
- package/dist/esm/oauth/token/schema/grants/client-credentials.js +16 -18
- package/dist/esm/oauth/token/schema/grants/common.d.ts +6 -0
- package/dist/esm/oauth/token/schema/grants/common.d.ts.map +1 -0
- package/dist/esm/oauth/token/schema/grants/common.js +16 -0
- package/dist/esm/oauth/token/schema/grants/refresh-token.d.ts +8 -4
- package/dist/esm/oauth/token/schema/grants/refresh-token.d.ts.map +1 -1
- package/dist/esm/oauth/token/schema/grants/refresh-token.js +21 -8
- package/dist/esm/oauth/token/schema/schema.d.ts +20 -10
- package/dist/esm/oauth/token/schema/schema.d.ts.map +1 -1
- package/dist/esm/oauth/token/schema/schema.js +52 -7
- package/dist/esm/oauth/token/schema/schema.test.js +14 -12
- package/package.json +1 -1
- package/dist/esm/package.json +0 -1
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
import * as z from 'zod/v4';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { GrantType, ScopeSchema } from '../../../common/schema.js';
|
|
3
|
+
import { ClientRequestSchema } from './common.js';
|
|
4
4
|
/**
|
|
5
5
|
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-6
|
|
6
6
|
*/
|
|
7
7
|
const GrantTypeSchema = z.enum([GrantType.REFRESH_TOKEN]);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
/**
|
|
9
|
+
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-6
|
|
10
|
+
*/
|
|
11
|
+
export const RefreshTokenRequestSchema = z.object({
|
|
12
|
+
/**
|
|
13
|
+
* REQUIRED. Value MUST be set to "refresh_token".
|
|
14
|
+
*/
|
|
15
|
+
grant_type: GrantTypeSchema.describe('The grant type.'),
|
|
16
|
+
/**
|
|
17
|
+
* REQUIRED. The refresh token issued to the client.
|
|
18
|
+
*/
|
|
19
|
+
refresh_token: z.string().min(1).describe('The refresh token.'),
|
|
20
|
+
/**
|
|
21
|
+
* OPTIONAL. The scope of the access request. If omitted, the scope is
|
|
22
|
+
* unchanged from the original grant. If specified, it must be equal to or
|
|
23
|
+
* a subset of the original scope.
|
|
24
|
+
*/
|
|
25
|
+
scope: ScopeSchema.optional(),
|
|
26
|
+
...ClientRequestSchema.shape,
|
|
14
27
|
});
|
|
@@ -5,31 +5,41 @@ export * from './grants/refresh-token.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Union(s)
|
|
7
7
|
*/
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const RequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
9
9
|
code_verifier: z.ZodOptional<z.ZodString>;
|
|
10
|
+
client_id: any;
|
|
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
|
-
|
|
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
|
-
client_id:
|
|
18
|
+
client_id: any;
|
|
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: any;
|
|
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
|
|
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;
|
|
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"}
|
|
@@ -1,15 +1,60 @@
|
|
|
1
1
|
import * as z from 'zod/v4';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { ScopeSchema } from '../../common/schema.js';
|
|
3
|
+
import { AuthorizationCodeRequestSchema } from './grants/authorization-code.js';
|
|
4
|
+
import { ClientCredentialsRequestSchema } from './grants/client-credentials.js';
|
|
5
|
+
import { RefreshTokenRequestSchema } from './grants/refresh-token.js';
|
|
5
6
|
export * from './grants/authorization-code.js';
|
|
6
7
|
export * from './grants/client-credentials.js';
|
|
7
8
|
export * from './grants/refresh-token.js';
|
|
8
9
|
/**
|
|
9
10
|
* Union(s)
|
|
10
11
|
*/
|
|
11
|
-
export const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export const RequestSchema = z.discriminatedUnion('grant_type', [
|
|
13
|
+
AuthorizationCodeRequestSchema,
|
|
14
|
+
ClientCredentialsRequestSchema,
|
|
15
|
+
RefreshTokenRequestSchema,
|
|
15
16
|
]);
|
|
17
|
+
/*
|
|
18
|
+
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-5.1
|
|
19
|
+
*/
|
|
20
|
+
export const ResponseSchema = z.object({
|
|
21
|
+
/**
|
|
22
|
+
* REQUIRED. The access token issued by the authorization server.
|
|
23
|
+
* Typically a JWT or an opaque string.
|
|
24
|
+
*/
|
|
25
|
+
access_token: z
|
|
26
|
+
.string()
|
|
27
|
+
.min(1)
|
|
28
|
+
.describe('The access token issued by the authorization server.'),
|
|
29
|
+
/**
|
|
30
|
+
* REQUIRED. The type of the token issued. Value is typically 'Bearer'.
|
|
31
|
+
*/
|
|
32
|
+
token_type: z
|
|
33
|
+
.literal('Bearer')
|
|
34
|
+
.describe('The type of the token issued. Must be "Bearer".'),
|
|
35
|
+
/**
|
|
36
|
+
* RECOMMENDED. The lifetime in seconds of the access token.
|
|
37
|
+
* For example, the value 3600 represents an expiration time of one hour.
|
|
38
|
+
*/
|
|
39
|
+
expires_in: z
|
|
40
|
+
.number()
|
|
41
|
+
.int()
|
|
42
|
+
.positive()
|
|
43
|
+
.optional()
|
|
44
|
+
.describe('The lifetime in seconds of the access token.'),
|
|
45
|
+
/**
|
|
46
|
+
* OPTIONAL. The refresh token, which can be used to obtain a new access token
|
|
47
|
+
* when the current one expires.
|
|
48
|
+
*/
|
|
49
|
+
refresh_token: z.string().min(1).optional().describe('The refresh token.'),
|
|
50
|
+
/**
|
|
51
|
+
* OPTIONAL. The scope of the access token as issued by the authorization server.
|
|
52
|
+
* If omitted, the scope is the same as the scope originally requested by the client.
|
|
53
|
+
*/
|
|
54
|
+
scope: ScopeSchema.optional(),
|
|
55
|
+
/**
|
|
56
|
+
* OPTIONAL, for OpenID Connect (OIDC). The ID token, a JWT that contains claims
|
|
57
|
+
* about the authentication of the end-user.
|
|
58
|
+
*/
|
|
59
|
+
id_token: z.string().min(1).optional().describe('The ID Token (OIDC only).'),
|
|
60
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from 'vitest';
|
|
2
2
|
import { generateAppId } from '../../../app/utils.js';
|
|
3
|
-
import {
|
|
3
|
+
import { RequestSchema } from './schema.js';
|
|
4
4
|
describe('OAuth Token - Schema', () => {
|
|
5
5
|
describe('Schema union', () => {
|
|
6
6
|
test('should accept authorization code grant', () => {
|
|
@@ -8,9 +8,10 @@ describe('OAuth Token - Schema', () => {
|
|
|
8
8
|
grant_type: 'authorization_code',
|
|
9
9
|
code: 'auth_code_123',
|
|
10
10
|
client_id: generateAppId(),
|
|
11
|
+
client_secret: 'secret_123',
|
|
11
12
|
redirect_uri: 'https://example.com/callback',
|
|
12
13
|
};
|
|
13
|
-
const result =
|
|
14
|
+
const result = RequestSchema.safeParse(payload);
|
|
14
15
|
// Parse succeeds for valid data
|
|
15
16
|
expect(result.success).toBe(true);
|
|
16
17
|
if (result.success) {
|
|
@@ -22,10 +23,11 @@ describe('OAuth Token - Schema', () => {
|
|
|
22
23
|
grant_type: 'authorization_code',
|
|
23
24
|
code: 'auth_code_123',
|
|
24
25
|
client_id: generateAppId(),
|
|
26
|
+
client_secret: 'secret_123',
|
|
25
27
|
redirect_uri: 'https://example.com/callback',
|
|
26
28
|
code_verifier: 'pkce_verifier_123',
|
|
27
29
|
};
|
|
28
|
-
const result =
|
|
30
|
+
const result = RequestSchema.safeParse(payload);
|
|
29
31
|
// Parse succeeds for valid data
|
|
30
32
|
expect(result.success).toBe(true);
|
|
31
33
|
if (result.success) {
|
|
@@ -40,7 +42,7 @@ describe('OAuth Token - Schema', () => {
|
|
|
40
42
|
client_secret: 'secret_123',
|
|
41
43
|
redirect_uri: 'https://example.com/callback',
|
|
42
44
|
};
|
|
43
|
-
const result =
|
|
45
|
+
const result = RequestSchema.safeParse(payload);
|
|
44
46
|
// Parse succeeds for valid data
|
|
45
47
|
expect(result.success).toBe(true);
|
|
46
48
|
if (result.success) {
|
|
@@ -54,7 +56,7 @@ describe('OAuth Token - Schema', () => {
|
|
|
54
56
|
client_secret: 'secret_123',
|
|
55
57
|
scope: 'read write',
|
|
56
58
|
};
|
|
57
|
-
const result =
|
|
59
|
+
const result = RequestSchema.safeParse(payload);
|
|
58
60
|
// Parse succeeds for valid data
|
|
59
61
|
expect(result.success).toBe(true);
|
|
60
62
|
if (result.success) {
|
|
@@ -69,7 +71,7 @@ describe('OAuth Token - Schema', () => {
|
|
|
69
71
|
client_secret: 'secret_123',
|
|
70
72
|
scope: 'read',
|
|
71
73
|
};
|
|
72
|
-
const result =
|
|
74
|
+
const result = RequestSchema.safeParse(payload);
|
|
73
75
|
// Parse succeeds for valid data
|
|
74
76
|
expect(result.success).toBe(true);
|
|
75
77
|
if (result.success) {
|
|
@@ -83,7 +85,7 @@ describe('OAuth Token - Schema', () => {
|
|
|
83
85
|
client_id: generateAppId(),
|
|
84
86
|
redirect_uri: 'https://example.com/callback',
|
|
85
87
|
};
|
|
86
|
-
const result =
|
|
88
|
+
const result = RequestSchema.safeParse(payload);
|
|
87
89
|
expect(result.success).toBe(false);
|
|
88
90
|
});
|
|
89
91
|
test('should reject authorization code without required fields', () => {
|
|
@@ -92,7 +94,7 @@ describe('OAuth Token - Schema', () => {
|
|
|
92
94
|
client_id: generateAppId(),
|
|
93
95
|
// missing code and redirect_uri
|
|
94
96
|
};
|
|
95
|
-
const result =
|
|
97
|
+
const result = RequestSchema.safeParse(payload);
|
|
96
98
|
expect(result.success).toBe(false);
|
|
97
99
|
});
|
|
98
100
|
test('should reject invalid redirect URI', () => {
|
|
@@ -102,7 +104,7 @@ describe('OAuth Token - Schema', () => {
|
|
|
102
104
|
client_id: generateAppId(),
|
|
103
105
|
redirect_uri: 'not-a-valid-url',
|
|
104
106
|
};
|
|
105
|
-
const result =
|
|
107
|
+
const result = RequestSchema.safeParse(payload);
|
|
106
108
|
expect(result.success).toBe(false);
|
|
107
109
|
});
|
|
108
110
|
test('should reject client credentials without required fields', () => {
|
|
@@ -111,7 +113,7 @@ describe('OAuth Token - Schema', () => {
|
|
|
111
113
|
client_id: generateAppId(),
|
|
112
114
|
// missing client_secret
|
|
113
115
|
};
|
|
114
|
-
const result =
|
|
116
|
+
const result = RequestSchema.safeParse(payload);
|
|
115
117
|
expect(result.success).toBe(false);
|
|
116
118
|
});
|
|
117
119
|
test('should reject refresh token without required fields', () => {
|
|
@@ -120,14 +122,14 @@ describe('OAuth Token - Schema', () => {
|
|
|
120
122
|
client_id: 'app_123',
|
|
121
123
|
// missing refresh_token and client_secret
|
|
122
124
|
};
|
|
123
|
-
const result =
|
|
125
|
+
const result = RequestSchema.safeParse(payload);
|
|
124
126
|
expect(result.success).toBe(false);
|
|
125
127
|
});
|
|
126
128
|
test('should reject completely invalid payload', () => {
|
|
127
129
|
const payload = {
|
|
128
130
|
invalid: 'data',
|
|
129
131
|
};
|
|
130
|
-
const result =
|
|
132
|
+
const result = RequestSchema.safeParse(payload);
|
|
131
133
|
expect(result.success).toBe(false);
|
|
132
134
|
});
|
|
133
135
|
});
|
package/package.json
CHANGED
package/dist/esm/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{ "type": "module" }
|