@afps-spec/schema 1.0.1 → 1.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afps-spec/schema",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src",
package/src/index.ts CHANGED
@@ -14,6 +14,9 @@ export {
14
14
  // Shared sub-schemas — reusable by consumers
15
15
  authModeEnum,
16
16
  providerDefinition,
17
+ oauth2Config,
18
+ oauth1Config,
19
+ credentialsConfig,
17
20
  providerConfiguration,
18
21
  setupGuide,
19
22
  schemaProperty,
package/src/schemas.ts CHANGED
@@ -99,23 +99,28 @@ const toolInterface = z.object({
99
99
 
100
100
  export const authModeEnum = z.enum(["oauth2", "oauth1", "api_key", "basic", "custom"]);
101
101
 
102
+ /** OAuth2 configuration sub-object. Required fields per §7.2; extensible for implementation-specific fields. */
103
+ export const oauth2Config = z.looseObject({
104
+ authorizationUrl: z.string(),
105
+ tokenUrl: z.string(),
106
+ });
107
+
108
+ /** OAuth1 configuration sub-object. Required fields per §7.3; extensible for implementation-specific fields. */
109
+ export const oauth1Config = z.looseObject({
110
+ requestTokenUrl: z.string(),
111
+ accessTokenUrl: z.string(),
112
+ });
113
+
114
+ /** Credential configuration sub-object. Required fields per §7.4; extensible for implementation-specific fields. */
115
+ export const credentialsConfig = z.looseObject({
116
+ schema: z.record(z.string(), z.unknown()),
117
+ });
118
+
102
119
  export const providerDefinition = z.looseObject({
103
120
  authMode: authModeEnum,
104
- authorizationUrl: z.string().optional(),
105
- tokenUrl: z.string().optional(),
106
- refreshUrl: z.string().optional(),
107
- defaultScopes: z.array(z.string()).optional(),
108
- scopeSeparator: z.string().optional(),
109
- pkceEnabled: z.boolean().optional(),
110
- tokenAuthMethod: z.string().optional(),
111
- authorizationParams: z.record(z.string(), z.unknown()).optional(),
112
- tokenParams: z.record(z.string(), z.unknown()).optional(),
113
- requestTokenUrl: z.string().optional(),
114
- accessTokenUrl: z.string().optional(),
115
- credentialSchema: z.record(z.string(), z.unknown()).optional(),
116
- credentialFieldName: z.string().optional(),
117
- credentialHeaderName: z.string().optional(),
118
- credentialHeaderPrefix: z.string().optional(),
121
+ oauth2: oauth2Config.optional(),
122
+ oauth1: oauth1Config.optional(),
123
+ credentials: credentialsConfig.optional(),
119
124
  authorizedUris: z.array(z.string()).optional(),
120
125
  allowAllUris: z.boolean().optional(),
121
126
  availableScopes: z.array(z.unknown()).optional(),
@@ -197,41 +202,63 @@ export function createSchemas(majorVersion: number) {
197
202
  .superRefine((val, ctx) => {
198
203
  const mode = val.definition?.authMode;
199
204
  if (mode === "oauth2") {
200
- if (!val.definition.authorizationUrl) {
205
+ if (!val.definition.oauth2) {
201
206
  ctx.addIssue({
202
207
  code: "custom",
203
- path: ["definition", "authorizationUrl"],
204
- message: "Required for oauth2 authMode",
205
- });
206
- }
207
- if (!val.definition.tokenUrl) {
208
- ctx.addIssue({
209
- code: "custom",
210
- path: ["definition", "tokenUrl"],
211
- message: "Required for oauth2 authMode",
208
+ path: ["definition", "oauth2"],
209
+ message: "oauth2 configuration object is required for oauth2 authMode",
212
210
  });
211
+ } else {
212
+ if (!val.definition.oauth2.authorizationUrl) {
213
+ ctx.addIssue({
214
+ code: "custom",
215
+ path: ["definition", "oauth2", "authorizationUrl"],
216
+ message: "Required for oauth2 authMode",
217
+ });
218
+ }
219
+ if (!val.definition.oauth2.tokenUrl) {
220
+ ctx.addIssue({
221
+ code: "custom",
222
+ path: ["definition", "oauth2", "tokenUrl"],
223
+ message: "Required for oauth2 authMode",
224
+ });
225
+ }
213
226
  }
214
227
  } else if (mode === "oauth1") {
215
- if (!val.definition.requestTokenUrl) {
228
+ if (!val.definition.oauth1) {
216
229
  ctx.addIssue({
217
230
  code: "custom",
218
- path: ["definition", "requestTokenUrl"],
219
- message: "Required for oauth1 authMode",
231
+ path: ["definition", "oauth1"],
232
+ message: "oauth1 configuration object is required for oauth1 authMode",
220
233
  });
234
+ } else {
235
+ if (!val.definition.oauth1.requestTokenUrl) {
236
+ ctx.addIssue({
237
+ code: "custom",
238
+ path: ["definition", "oauth1", "requestTokenUrl"],
239
+ message: "Required for oauth1 authMode",
240
+ });
241
+ }
242
+ if (!val.definition.oauth1.accessTokenUrl) {
243
+ ctx.addIssue({
244
+ code: "custom",
245
+ path: ["definition", "oauth1", "accessTokenUrl"],
246
+ message: "Required for oauth1 authMode",
247
+ });
248
+ }
221
249
  }
222
- if (!val.definition.accessTokenUrl) {
250
+ } else if (mode === "api_key" || mode === "basic" || mode === "custom") {
251
+ if (!val.definition.credentials) {
223
252
  ctx.addIssue({
224
253
  code: "custom",
225
- path: ["definition", "accessTokenUrl"],
226
- message: "Required for oauth1 authMode",
254
+ path: ["definition", "credentials"],
255
+ message: `credentials configuration object is required for ${mode} authMode`,
227
256
  });
228
- }
229
- } else if (mode === "api_key" || mode === "basic" || mode === "custom") {
230
- if (!val.definition.credentialSchema) {
257
+ } else if (!val.definition.credentials.schema) {
231
258
  ctx.addIssue({
232
259
  code: "custom",
233
- path: ["definition", "credentialSchema"],
234
- message: `Required for ${mode} authMode`,
260
+ path: ["definition", "credentials", "schema"],
261
+ message: `credentials.schema is required for ${mode} authMode`,
235
262
  });
236
263
  }
237
264
  }
@@ -99,66 +99,54 @@
99
99
  "custom"
100
100
  ]
101
101
  },
102
- "authorizationUrl": {
103
- "type": "string"
104
- },
105
- "tokenUrl": {
106
- "type": "string"
107
- },
108
- "refreshUrl": {
109
- "type": "string"
110
- },
111
- "defaultScopes": {
112
- "type": "array",
113
- "items": {
114
- "type": "string"
115
- }
116
- },
117
- "scopeSeparator": {
118
- "type": "string"
119
- },
120
- "pkceEnabled": {
121
- "type": "boolean"
122
- },
123
- "tokenAuthMethod": {
124
- "type": "string"
125
- },
126
- "authorizationParams": {
102
+ "oauth2": {
127
103
  "type": "object",
128
- "propertyNames": {
129
- "type": "string"
104
+ "properties": {
105
+ "authorizationUrl": {
106
+ "type": "string"
107
+ },
108
+ "tokenUrl": {
109
+ "type": "string"
110
+ }
130
111
  },
112
+ "required": [
113
+ "authorizationUrl",
114
+ "tokenUrl"
115
+ ],
131
116
  "additionalProperties": {}
132
117
  },
133
- "tokenParams": {
118
+ "oauth1": {
134
119
  "type": "object",
135
- "propertyNames": {
136
- "type": "string"
120
+ "properties": {
121
+ "requestTokenUrl": {
122
+ "type": "string"
123
+ },
124
+ "accessTokenUrl": {
125
+ "type": "string"
126
+ }
137
127
  },
128
+ "required": [
129
+ "requestTokenUrl",
130
+ "accessTokenUrl"
131
+ ],
138
132
  "additionalProperties": {}
139
133
  },
140
- "requestTokenUrl": {
141
- "type": "string"
142
- },
143
- "accessTokenUrl": {
144
- "type": "string"
145
- },
146
- "credentialSchema": {
134
+ "credentials": {
147
135
  "type": "object",
148
- "propertyNames": {
149
- "type": "string"
136
+ "properties": {
137
+ "schema": {
138
+ "type": "object",
139
+ "propertyNames": {
140
+ "type": "string"
141
+ },
142
+ "additionalProperties": {}
143
+ }
150
144
  },
145
+ "required": [
146
+ "schema"
147
+ ],
151
148
  "additionalProperties": {}
152
149
  },
153
- "credentialFieldName": {
154
- "type": "string"
155
- },
156
- "credentialHeaderName": {
157
- "type": "string"
158
- },
159
- "credentialHeaderPrefix": {
160
- "type": "string"
161
- },
162
150
  "authorizedUris": {
163
151
  "type": "array",
164
152
  "items": {