2016-09-15 12:17:17 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------
|
|
|
|
|
// This file just describes the interface
|
|
|
|
|
//
|
|
|
|
|
// New backends can start from here
|
|
|
|
|
// -------------------------------------------
|
|
|
|
|
|
|
|
|
|
exports = module.exports = {
|
2021-08-13 17:22:28 -07:00
|
|
|
removePrivateFields,
|
|
|
|
|
injectPrivateFields,
|
|
|
|
|
upsert,
|
|
|
|
|
get,
|
|
|
|
|
del,
|
|
|
|
|
wait,
|
2022-01-05 22:41:41 -08:00
|
|
|
verifyDomainConfig
|
2016-09-15 12:17:17 +02:00
|
|
|
};
|
|
|
|
|
|
2021-08-13 17:22:28 -07:00
|
|
|
const assert = require('assert'),
|
|
|
|
|
BoxError = require('../boxerror.js');
|
2016-09-15 12:17:17 +02:00
|
|
|
|
2019-02-08 11:11:49 +01:00
|
|
|
function removePrivateFields(domainObject) {
|
2020-05-14 23:01:44 +02:00
|
|
|
// in-place removal of tokens and api keys with constants.SECRET_PLACEHOLDER
|
2019-02-08 11:11:49 +01:00
|
|
|
return domainObject;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-04 10:21:42 -08:00
|
|
|
// eslint-disable-next-line no-unused-vars
|
2019-02-09 19:08:15 +01:00
|
|
|
function injectPrivateFields(newConfig, currentConfig) {
|
2020-05-14 23:01:44 +02:00
|
|
|
// in-place injection of tokens and api keys which came in with constants.SECRET_PLACEHOLDER
|
2019-02-09 19:08:15 +01:00
|
|
|
}
|
|
|
|
|
|
2023-03-18 09:41:20 +01:00
|
|
|
// replaces any existing records or creates new records of subdomain+type with values
|
2022-02-04 09:37:02 -08:00
|
|
|
async function upsert(domainObject, subdomain, type, values) {
|
2019-01-04 18:44:54 -08:00
|
|
|
assert.strictEqual(typeof domainObject, 'object');
|
2022-02-03 16:15:14 -08:00
|
|
|
assert.strictEqual(typeof subdomain, 'string');
|
2016-09-15 12:17:17 +02:00
|
|
|
assert.strictEqual(typeof type, 'string');
|
2021-05-02 11:26:08 -07:00
|
|
|
assert(Array.isArray(values));
|
2016-09-15 12:17:17 +02:00
|
|
|
|
2018-06-29 22:25:34 +02:00
|
|
|
// Result: none
|
2016-09-15 12:17:17 +02:00
|
|
|
|
2022-02-04 09:37:02 -08:00
|
|
|
throw new BoxError(BoxError.NOT_IMPLEMENTED, 'upsert is not implemented');
|
2016-09-15 12:17:17 +02:00
|
|
|
}
|
|
|
|
|
|
2023-03-18 09:41:20 +01:00
|
|
|
// NOTE: returns empty array when there are no records
|
2022-02-04 09:37:02 -08:00
|
|
|
async function get(domainObject, subdomain, type) {
|
2019-01-04 18:44:54 -08:00
|
|
|
assert.strictEqual(typeof domainObject, 'object');
|
2022-02-03 16:15:14 -08:00
|
|
|
assert.strictEqual(typeof subdomain, 'string');
|
2016-09-15 12:17:17 +02:00
|
|
|
assert.strictEqual(typeof type, 'string');
|
|
|
|
|
|
|
|
|
|
// Result: Array of matching DNS records in string format
|
|
|
|
|
|
2022-02-04 09:37:02 -08:00
|
|
|
throw new BoxError(BoxError.NOT_IMPLEMENTED, 'get is not implemented');
|
2016-09-15 12:17:17 +02:00
|
|
|
}
|
|
|
|
|
|
2023-03-18 09:41:20 +01:00
|
|
|
// must only delete records that match values
|
2022-02-04 09:37:02 -08:00
|
|
|
async function del(domainObject, subdomain, type, values) {
|
2019-01-04 18:44:54 -08:00
|
|
|
assert.strictEqual(typeof domainObject, 'object');
|
2022-02-03 16:15:14 -08:00
|
|
|
assert.strictEqual(typeof subdomain, 'string');
|
2016-09-15 12:17:17 +02:00
|
|
|
assert.strictEqual(typeof type, 'string');
|
2021-05-02 11:26:08 -07:00
|
|
|
assert(Array.isArray(values));
|
2016-09-15 12:17:17 +02:00
|
|
|
|
|
|
|
|
// Result: none
|
|
|
|
|
|
2022-02-04 09:37:02 -08:00
|
|
|
throw new BoxError(BoxError.NOT_IMPLEMENTED, 'del is not implemented');
|
2016-09-15 12:17:17 +02:00
|
|
|
}
|
|
|
|
|
|
2022-02-03 16:15:14 -08:00
|
|
|
async function wait(domainObject, subdomain, type, value, options) {
|
2019-01-04 18:44:54 -08:00
|
|
|
assert.strictEqual(typeof domainObject, 'object');
|
2022-02-03 16:15:14 -08:00
|
|
|
assert.strictEqual(typeof subdomain, 'string');
|
2019-01-04 18:44:54 -08:00
|
|
|
assert.strictEqual(typeof type, 'string');
|
|
|
|
|
assert.strictEqual(typeof value, 'string');
|
|
|
|
|
assert(options && typeof options === 'object'); // { interval: 5000, times: 50000 }
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-03 16:15:14 -08:00
|
|
|
async function verifyDomainConfig(domainObject) {
|
2019-01-04 18:44:54 -08:00
|
|
|
assert.strictEqual(typeof domainObject, 'object');
|
2017-01-10 11:11:41 +01:00
|
|
|
|
2022-01-05 22:41:41 -08:00
|
|
|
// Result: domainConfig object
|
2017-01-10 11:11:41 +01:00
|
|
|
|
2022-02-03 16:15:14 -08:00
|
|
|
throw new BoxError(BoxError.NOT_IMPLEMENTED, 'verifyDomainConfig is not implemented');
|
2017-01-10 11:11:41 +01:00
|
|
|
}
|