-
Notifications
You must be signed in to change notification settings - Fork 190
/
Copy pathAuthenticationSchema.js
118 lines (115 loc) · 3.61 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
'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.',
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,
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: [
{
example: {},
reason: 'Missing required keys: type and test',
},
{
example: '$func$2$f$',
reason: 'Must be object',
},
{
example: {
type: 'unknown',
test: '$func$2$f$',
},
reason: 'Invalid value for key: type',
},
{
example: {
type: 'custom',
test: '$func$2$f$',
fields: '$func$2$f$',
},
reason: 'Invalid value for key: fields',
},
],
},
[
FieldsSchema,
FunctionSchema,
RequestSchema,
AuthenticationBasicConfigSchema,
AuthenticationCustomConfigSchema,
AuthenticationDigestConfigSchema,
AuthenticationOAuth1ConfigSchema,
AuthenticationOAuth2ConfigSchema,
AuthenticationSessionConfigSchema,
]
);