2018-04-18 14:38:06 +00:00
|
|
|
/* gpgme.js - Javascript integration for gpgme
|
|
|
|
* Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
|
|
|
|
*
|
|
|
|
* This file is part of GPGME.
|
|
|
|
*
|
|
|
|
* GPGME is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2.1 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GPGME is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* SPDX-License-Identifier: LGPL-2.1+
|
2018-06-06 11:05:53 +00:00
|
|
|
*
|
|
|
|
* Author(s):
|
|
|
|
* Maximilian Krambach <mkrambach@intevation.de>
|
2018-04-18 14:38:06 +00:00
|
|
|
*/
|
|
|
|
|
2018-06-06 11:05:53 +00:00
|
|
|
/**
|
2018-07-10 12:32:26 +00:00
|
|
|
* @typedef {Object} messageProperty
|
|
|
|
* A message Property is defined by it's key.
|
|
|
|
* @property {Array<String>} allowed Array of allowed types.
|
|
|
|
* Currently accepted values are 'number', 'string', 'boolean'.
|
|
|
|
* @property {Boolean} array_allowed If the value can be an array of types
|
|
|
|
* defined in allowed
|
2018-07-18 11:43:47 +00:00
|
|
|
* @property {Array<*>} allowed_data (optional) restricts to the given values
|
2018-07-10 12:32:26 +00:00
|
|
|
*/
|
2018-04-18 14:38:06 +00:00
|
|
|
|
2018-07-10 12:32:26 +00:00
|
|
|
/**
|
|
|
|
* Definition of the possible interactions with gpgme-json.
|
|
|
|
* @param {Object} operation Each operation is named by a key and contains
|
|
|
|
* the following properties:
|
|
|
|
* @property {messageProperty} required An object with all required parameters
|
|
|
|
* @property {messageProperty} optional An object with all optional parameters
|
|
|
|
* @property {Boolean} pinentry (optional) If true, a password dialog is
|
|
|
|
* expected, thus a connection tuimeout is not advisable
|
|
|
|
* @property {Object} answer The definition on what to expect as answer, if the
|
|
|
|
* answer is not an error
|
|
|
|
* @property {Array<String>} answer.type the type(s) as reported by gpgme-json.
|
|
|
|
* @property {Object} answer.data key-value combinations of expected properties
|
|
|
|
* of an answer and their type ('boolean', 'string', object)
|
|
|
|
@const
|
|
|
|
*/
|
2018-04-18 14:38:06 +00:00
|
|
|
export const permittedOperations = {
|
|
|
|
encrypt: {
|
2018-08-20 13:12:01 +00:00
|
|
|
pinentry: true, // TODO only with signing_keys
|
2018-04-27 18:03:09 +00:00
|
|
|
required: {
|
|
|
|
'keys': {
|
|
|
|
allowed: ['string'],
|
|
|
|
array_allowed: true
|
|
|
|
},
|
|
|
|
'data': {
|
2018-05-22 12:24:16 +00:00
|
|
|
allowed: ['string']
|
2018-04-27 18:03:09 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
optional: {
|
|
|
|
'protocol': {
|
|
|
|
allowed: ['string'],
|
|
|
|
allowed_data: ['cms', 'openpgp']
|
|
|
|
},
|
2018-05-28 15:26:56 +00:00
|
|
|
'signing_keys': {
|
|
|
|
allowed: ['string'],
|
|
|
|
array_allowed: true
|
|
|
|
},
|
|
|
|
'base64': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'mime': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'armor': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'always-trust': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'no-encrypt-to': {
|
|
|
|
allowed: ['string'],
|
|
|
|
array_allowed: true
|
|
|
|
},
|
|
|
|
'no-compress': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'throw-keyids': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'want-address': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'wrap': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
}
|
|
|
|
},
|
2018-04-18 14:38:06 +00:00
|
|
|
answer: {
|
|
|
|
type: ['ciphertext'],
|
2018-06-08 15:54:58 +00:00
|
|
|
data: {
|
|
|
|
'data': 'string',
|
|
|
|
'base64':'boolean'
|
|
|
|
}
|
2018-04-18 14:38:06 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
decrypt: {
|
2018-04-25 09:32:21 +00:00
|
|
|
pinentry: true,
|
2018-04-27 18:03:09 +00:00
|
|
|
required: {
|
|
|
|
'data': {
|
2018-05-22 12:24:16 +00:00
|
|
|
allowed: ['string']
|
2018-04-27 18:03:09 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
optional: {
|
|
|
|
'protocol': {
|
|
|
|
allowed: ['string'],
|
|
|
|
allowed_data: ['cms', 'openpgp']
|
|
|
|
},
|
|
|
|
'base64': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
}
|
|
|
|
},
|
2018-04-18 14:38:06 +00:00
|
|
|
answer: {
|
|
|
|
type: ['plaintext'],
|
2018-06-08 15:54:58 +00:00
|
|
|
data: {
|
|
|
|
'data': 'string',
|
|
|
|
'base64': 'boolean',
|
|
|
|
'mime': 'boolean',
|
2018-08-17 16:25:57 +00:00
|
|
|
'signatures': 'object',
|
|
|
|
'info': 'object'
|
2018-06-08 15:54:58 +00:00
|
|
|
}
|
2018-04-25 13:59:36 +00:00
|
|
|
}
|
|
|
|
},
|
2018-05-24 13:16:18 +00:00
|
|
|
|
|
|
|
sign: {
|
|
|
|
pinentry: true,
|
|
|
|
required: {
|
|
|
|
'data': {
|
2018-08-20 13:12:01 +00:00
|
|
|
allowed: ['string'] },
|
2018-05-24 13:16:18 +00:00
|
|
|
'keys': {
|
|
|
|
allowed: ['string'],
|
|
|
|
array_allowed: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
optional: {
|
|
|
|
'protocol': {
|
|
|
|
allowed: ['string'],
|
|
|
|
allowed_data: ['cms', 'openpgp']
|
|
|
|
},
|
|
|
|
'sender': {
|
|
|
|
allowed: ['string'],
|
|
|
|
},
|
|
|
|
'mode': {
|
|
|
|
allowed: ['string'],
|
2018-06-06 11:05:53 +00:00
|
|
|
allowed_data: ['detached', 'clearsign']
|
|
|
|
// TODO 'opaque' is not used, but available on native app
|
2018-05-24 13:16:18 +00:00
|
|
|
},
|
|
|
|
'base64': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'armor': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
},
|
|
|
|
answer: {
|
|
|
|
type: ['signature', 'ciphertext'],
|
2018-06-08 15:54:58 +00:00
|
|
|
data: {
|
|
|
|
'data': 'string',
|
2018-08-17 16:25:57 +00:00
|
|
|
'base64':'boolean'
|
2018-06-08 15:54:58 +00:00
|
|
|
}
|
|
|
|
|
2018-05-24 13:16:18 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-06-06 11:05:53 +00:00
|
|
|
// note: For the meaning of the optional keylist flags, refer to
|
|
|
|
// https://www.gnupg.org/documentation/manuals/gpgme/Key-Listing-Mode.html
|
2018-05-25 17:02:18 +00:00
|
|
|
keylist:{
|
|
|
|
required: {},
|
2018-06-06 11:05:53 +00:00
|
|
|
|
2018-05-04 10:56:59 +00:00
|
|
|
optional: {
|
2018-05-25 17:02:18 +00:00
|
|
|
'protocol': {
|
|
|
|
allowed: ['string'],
|
|
|
|
allowed_data: ['cms', 'openpgp']
|
|
|
|
},
|
|
|
|
'secret': {
|
2018-05-04 10:56:59 +00:00
|
|
|
allowed: ['boolean']
|
2018-05-25 17:02:18 +00:00
|
|
|
},
|
|
|
|
'extern': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'local':{
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
2018-07-04 10:11:35 +00:00
|
|
|
'locate': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
2018-05-25 17:02:18 +00:00
|
|
|
'sigs':{
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'notations':{
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'tofu': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'ephemeral': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'validate': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'keys': {
|
|
|
|
allowed: ['string'],
|
|
|
|
array_allowed: true
|
2018-05-04 10:56:59 +00:00
|
|
|
}
|
|
|
|
},
|
2018-05-25 17:02:18 +00:00
|
|
|
answer: {
|
2018-05-28 15:26:56 +00:00
|
|
|
type: ['keys'],
|
2018-06-08 15:54:58 +00:00
|
|
|
data: {
|
|
|
|
'base64': 'boolean',
|
|
|
|
'keys': 'object'
|
|
|
|
}
|
2018-05-25 17:02:18 +00:00
|
|
|
}
|
2018-04-25 13:59:36 +00:00
|
|
|
},
|
|
|
|
|
2018-05-28 15:26:56 +00:00
|
|
|
export: {
|
|
|
|
required: {},
|
|
|
|
optional: {
|
|
|
|
'protocol': {
|
|
|
|
allowed: ['string'],
|
|
|
|
allowed_data: ['cms', 'openpgp']
|
|
|
|
},
|
|
|
|
'keys': {
|
|
|
|
allowed: ['string'],
|
|
|
|
array_allowed: true
|
|
|
|
},
|
|
|
|
'armor': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'extern': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'minimal': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'raw': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
2018-07-12 09:36:55 +00:00
|
|
|
'pkcs12': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
'with-sec-fprs': {
|
2018-05-28 15:26:56 +00:00
|
|
|
allowed: ['boolean']
|
|
|
|
}
|
|
|
|
// secret: not yet implemented
|
|
|
|
},
|
|
|
|
answer: {
|
|
|
|
type: ['keys'],
|
2018-06-08 15:54:58 +00:00
|
|
|
data: {
|
|
|
|
'data': 'string',
|
2018-07-12 09:36:55 +00:00
|
|
|
'base64': 'boolean',
|
|
|
|
'sec-fprs': 'object'
|
2018-06-08 15:54:58 +00:00
|
|
|
}
|
2018-05-28 15:26:56 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
import: {
|
2018-05-04 10:56:59 +00:00
|
|
|
required: {
|
2018-05-28 15:26:56 +00:00
|
|
|
'data': {
|
2018-05-04 10:56:59 +00:00
|
|
|
allowed: ['string']
|
|
|
|
}
|
|
|
|
},
|
2018-05-28 15:26:56 +00:00
|
|
|
optional: {
|
|
|
|
'protocol': {
|
|
|
|
allowed: ['string'],
|
|
|
|
allowed_data: ['cms', 'openpgp']
|
|
|
|
},
|
|
|
|
'base64': {
|
|
|
|
allowed: ['boolean']
|
|
|
|
},
|
|
|
|
},
|
2018-04-25 13:59:36 +00:00
|
|
|
answer: {
|
2018-05-28 15:26:56 +00:00
|
|
|
type: [],
|
2018-06-08 15:54:58 +00:00
|
|
|
data: {
|
2018-07-03 10:41:49 +00:00
|
|
|
'result': 'object'
|
2018-06-08 15:54:58 +00:00
|
|
|
}
|
2018-04-25 13:59:36 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-05-28 15:26:56 +00:00
|
|
|
delete: {
|
2018-05-04 10:56:59 +00:00
|
|
|
pinentry: true,
|
2018-05-28 15:26:56 +00:00
|
|
|
required:{
|
|
|
|
'key': {
|
|
|
|
allowed: ['string']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
optional: {
|
|
|
|
'protocol': {
|
2018-05-04 10:56:59 +00:00
|
|
|
allowed: ['string'],
|
2018-05-28 15:26:56 +00:00
|
|
|
allowed_data: ['cms', 'openpgp']
|
2018-05-04 10:56:59 +00:00
|
|
|
},
|
2018-05-28 15:26:56 +00:00
|
|
|
},
|
2018-04-25 13:59:36 +00:00
|
|
|
answer: {
|
2018-06-08 15:54:58 +00:00
|
|
|
data: {
|
|
|
|
'success': 'boolean'
|
|
|
|
}
|
2018-04-18 14:38:06 +00:00
|
|
|
}
|
2018-05-28 15:26:56 +00:00
|
|
|
},
|
2018-05-25 17:02:18 +00:00
|
|
|
|
|
|
|
version: {
|
|
|
|
required: {},
|
|
|
|
optional: {},
|
|
|
|
answer: {
|
|
|
|
type: [''],
|
2018-06-08 15:54:58 +00:00
|
|
|
data: {
|
|
|
|
'gpgme': 'string',
|
|
|
|
'info': 'object'
|
|
|
|
}
|
2018-05-25 17:02:18 +00:00
|
|
|
}
|
2018-06-11 10:08:50 +00:00
|
|
|
},
|
2018-06-06 11:05:53 +00:00
|
|
|
|
2018-06-11 10:08:50 +00:00
|
|
|
createkey: {
|
2018-06-13 13:22:03 +00:00
|
|
|
pinentry: true,
|
2018-06-11 10:08:50 +00:00
|
|
|
required: {
|
|
|
|
userid: {
|
|
|
|
allowed: ['string']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
optional: {
|
|
|
|
algo: {
|
|
|
|
allowed: ['string']
|
|
|
|
},
|
|
|
|
expires: {
|
|
|
|
allowed: ['number'],
|
|
|
|
}
|
|
|
|
},
|
|
|
|
answer: {
|
|
|
|
type: [''],
|
2018-08-20 13:12:01 +00:00
|
|
|
data: { 'fingerprint': 'string' }
|
2018-06-11 10:08:50 +00:00
|
|
|
}
|
2018-06-13 13:22:03 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
verify: {
|
|
|
|
required: {
|
|
|
|
data: {
|
|
|
|
allowed: ['string']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
optional: {
|
|
|
|
'protocol': {
|
|
|
|
allowed: ['string'],
|
|
|
|
allowed_data: ['cms', 'openpgp']
|
|
|
|
},
|
|
|
|
'signature': {
|
|
|
|
allowed: ['string']
|
|
|
|
},
|
|
|
|
'base64':{
|
|
|
|
allowed: ['boolean']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
answer: {
|
|
|
|
type: ['plaintext'],
|
|
|
|
data:{
|
|
|
|
data: 'string',
|
|
|
|
base64:'boolean',
|
|
|
|
info: 'object'
|
2018-08-20 13:12:01 +00:00
|
|
|
// info.file_name: Optional string of the plaintext file name.
|
|
|
|
// info.is_mime: Boolean if the messages claims it is MIME.
|
|
|
|
// info.signatures: Array of signatures
|
2018-06-13 13:22:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
config_opt: {
|
|
|
|
required: {
|
|
|
|
'component':{
|
|
|
|
allowed: ['string'],
|
|
|
|
// allowed_data: ['gpg'] // TODO check all available
|
|
|
|
},
|
|
|
|
'option': {
|
|
|
|
allowed: ['string'],
|
|
|
|
// allowed_data: ['default-key'] // TODO check all available
|
|
|
|
}
|
|
|
|
},
|
|
|
|
optional: {},
|
|
|
|
answer: {
|
|
|
|
type: [],
|
|
|
|
data: {
|
|
|
|
option: 'object'
|
|
|
|
}
|
|
|
|
}
|
2018-06-11 10:08:50 +00:00
|
|
|
}
|
2018-06-13 13:22:03 +00:00
|
|
|
|
2018-06-06 11:05:53 +00:00
|
|
|
/**
|
|
|
|
* TBD handling of secrets
|
|
|
|
* TBD key modification?
|
|
|
|
*/
|
|
|
|
|
|
|
|
};
|