This repository has been archived by the owner on May 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
AuthenticationSchema.js
89 lines (86 loc) · 3.24 KB
/
AuthenticationSchema.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
'use strict';
const makeSchema = require('../utils/makeSchema');
const AuthenticationBasicConfigSchema = require('./AuthenticationBasicConfigSchema.js');
const AuthenticationCustomConfigSchema = require('./AuthenticationCustomConfigSchema.js');
const AuthenticationDigestConfigSchema = require('./AuthenticationDigestConfigSchema.js');
const AuthenticationOAuth1ConfigSchema = require('./AuthenticationOAuth1ConfigSchema.js');
const AuthenticationOAuth2ConfigSchema = require('./AuthenticationOAuth2ConfigSchema.js');
const AuthenticationSessionConfigSchema = require('./AuthenticationSessionConfigSchema.js');
const FieldsSchema = require('./FieldsSchema');
const FunctionSchema = require('./FunctionSchema');
const RequestSchema = require('./RequestSchema');
module.exports = makeSchema(
{
id: '/AuthenticationSchema',
description: 'Represents authentication schemes.',
examples: [
{ type: 'basic', test: '$func$2$f$' },
{ type: 'custom', test: '$func$2$f$', fields: [{ key: 'abc' }] },
{
type: 'custom',
test: '$func$2$f$',
connectionLabel: '{{bundle.inputData.abc}}'
},
{ type: 'custom', test: '$func$2$f$', connectionLabel: '$func$2$f$' },
{ type: 'custom', test: '$func$2$f$', connectionLabel: { url: 'abc' } }
],
antiExamples: [
{},
'$func$2$f$',
{ type: 'unknown', test: '$func$2$f$' },
{ type: 'custom', test: '$func$2$f$', fields: '$func$2$f$' },
{
type: 'custom',
test: '$func$2$f$',
fields: [{ key: 'abc' }, '$func$2$f$']
}
],
type: 'object',
required: ['type', 'test'],
properties: {
type: {
description: 'Choose which scheme you want to use.',
type: 'string',
enum: ['basic', 'custom', 'digest', 'oauth1', 'oauth2', 'session']
},
test: {
description:
'A function or request that confirms the authentication is working.',
oneOf: [{ $ref: RequestSchema.id }, { $ref: FunctionSchema.id }]
},
fields: {
description:
'Fields you can request from the user before they connect your app to Zapier.',
$ref: FieldsSchema.id
},
connectionLabel: {
description:
'A string with variables, function, or request that returns the connection label for the authenticated user.',
anyOf: [
{ $ref: RequestSchema.id },
{ $ref: FunctionSchema.id },
{ type: 'string' }
]
},
// this is preferred to laying out config: anyOf: [...]
basicConfig: { $ref: AuthenticationBasicConfigSchema.id },
customConfig: { $ref: AuthenticationCustomConfigSchema.id },
digestConfig: { $ref: AuthenticationDigestConfigSchema.id },
oauth1Config: { $ref: AuthenticationOAuth1ConfigSchema.id },
oauth2Config: { $ref: AuthenticationOAuth2ConfigSchema.id },
sessionConfig: { $ref: AuthenticationSessionConfigSchema.id }
},
additionalProperties: false
},
[
FieldsSchema,
FunctionSchema,
RequestSchema,
AuthenticationBasicConfigSchema,
AuthenticationCustomConfigSchema,
AuthenticationDigestConfigSchema,
AuthenticationOAuth1ConfigSchema,
AuthenticationOAuth2ConfigSchema,
AuthenticationSessionConfigSchema
]
);