@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 +1 -1
- package/src/index.ts +3 -0
- package/src/schemas.ts +63 -36
- package/v1/provider.schema.json +36 -48
package/package.json
CHANGED
package/src/index.ts
CHANGED
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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.
|
|
205
|
+
if (!val.definition.oauth2) {
|
|
201
206
|
ctx.addIssue({
|
|
202
207
|
code: "custom",
|
|
203
|
-
path: ["definition", "
|
|
204
|
-
message: "
|
|
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.
|
|
228
|
+
if (!val.definition.oauth1) {
|
|
216
229
|
ctx.addIssue({
|
|
217
230
|
code: "custom",
|
|
218
|
-
path: ["definition", "
|
|
219
|
-
message: "
|
|
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
|
-
|
|
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", "
|
|
226
|
-
message:
|
|
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", "
|
|
234
|
-
message: `
|
|
260
|
+
path: ["definition", "credentials", "schema"],
|
|
261
|
+
message: `credentials.schema is required for ${mode} authMode`,
|
|
235
262
|
});
|
|
236
263
|
}
|
|
237
264
|
}
|
package/v1/provider.schema.json
CHANGED
|
@@ -99,66 +99,54 @@
|
|
|
99
99
|
"custom"
|
|
100
100
|
]
|
|
101
101
|
},
|
|
102
|
-
"
|
|
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
|
-
"
|
|
129
|
-
"
|
|
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
|
-
"
|
|
118
|
+
"oauth1": {
|
|
134
119
|
"type": "object",
|
|
135
|
-
"
|
|
136
|
-
"
|
|
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
|
-
"
|
|
141
|
-
"type": "string"
|
|
142
|
-
},
|
|
143
|
-
"accessTokenUrl": {
|
|
144
|
-
"type": "string"
|
|
145
|
-
},
|
|
146
|
-
"credentialSchema": {
|
|
134
|
+
"credentials": {
|
|
147
135
|
"type": "object",
|
|
148
|
-
"
|
|
149
|
-
"
|
|
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": {
|