js: adding sign method
-- * src/gpgmejs.js: method, update in src/permittedOperations * basic testing in BrowsertestExtension
This commit is contained in:
parent
e38b8beb20
commit
a4ba80c553
@ -17,6 +17,7 @@
|
||||
<script src="tests/startup.js"></script>
|
||||
<script src="tests/encryptTest.js"></script>
|
||||
<script src="tests/encryptDecryptTest.js"></script>
|
||||
<script src="tests/signTest.js"></script>
|
||||
<!-- run tests -->
|
||||
<script src="runbrowsertest.js"></script>
|
||||
</body>
|
||||
|
@ -120,6 +120,44 @@ export class GpgME {
|
||||
|
||||
}
|
||||
|
||||
sign(data, keys, mode='clearsign', base64=false) { //sender
|
||||
if (data === undefined){
|
||||
return Promise.reject(gpgme_error('MSG_EMPTY'));
|
||||
}
|
||||
let key_arr = toKeyIdArray(keys);
|
||||
if (key_arr.length === 0){
|
||||
return Promise.reject(gpgme_error('MSG_NO_KEYS'));
|
||||
}
|
||||
let msg = createMessage('sign');
|
||||
|
||||
msg.setParameter('keys', key_arr);
|
||||
if (base64 === true){
|
||||
msg.setParameter('base64', true);
|
||||
}
|
||||
msg.setParameter('mode', mode);
|
||||
putData(msg, data);
|
||||
if (mode === 'detached') {
|
||||
msg.expected = 'base64';
|
||||
}
|
||||
let me = this;
|
||||
return new Promise(function(resolve,reject) {
|
||||
me.connection.post(msg).then( function(message) {
|
||||
if (mode === 'clearsign'){
|
||||
resolve({
|
||||
data: message.data}
|
||||
);
|
||||
} else if (mode === 'detached') {
|
||||
resolve({
|
||||
data: data,
|
||||
signature: message.data
|
||||
});
|
||||
}
|
||||
}, function(error){
|
||||
reject(error);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
deleteKey(key, delete_secret = false, no_confirm = false){
|
||||
return Promise.reject(gpgme_error('NOT_YET_IMPLEMENTED'));
|
||||
let msg = createMessage('deletekey');
|
||||
|
@ -130,6 +130,49 @@ export const permittedOperations = {
|
||||
// }]
|
||||
}
|
||||
},
|
||||
|
||||
sign: {
|
||||
pinentry: true,
|
||||
required: {
|
||||
'data': {
|
||||
allowed: ['string']},
|
||||
'keys': {
|
||||
allowed: ['string'],
|
||||
array_allowed: true
|
||||
}
|
||||
},
|
||||
optional: {
|
||||
'protocol': {
|
||||
allowed: ['string'],
|
||||
allowed_data: ['cms', 'openpgp']
|
||||
},
|
||||
'chunksize': {
|
||||
allowed: ['number'],
|
||||
},
|
||||
'sender': {
|
||||
allowed: ['string'],
|
||||
},
|
||||
'mode': {
|
||||
allowed: ['string'],
|
||||
allowed_data: ['detached', 'clearsign'] // TODO 'opaque' not used
|
||||
},
|
||||
'base64': {
|
||||
allowed: ['boolean']
|
||||
},
|
||||
'armor': {
|
||||
allowed: ['boolean']
|
||||
},
|
||||
},
|
||||
answer: {
|
||||
type: ['signature', 'ciphertext'],
|
||||
data: ['data'], // Unless armor mode is used a Base64 encoded binary
|
||||
// signature. In armor mode a string with an armored
|
||||
// OpenPGP or a PEM message.
|
||||
params: ['base64']
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/** TBD: querying the Key's information (keyinfo)
|
||||
TBD name: {
|
||||
required: {
|
||||
@ -212,6 +255,5 @@ export const permittedOperations = {
|
||||
*TBD get armored secret different treatment from keyinfo!
|
||||
* TBD key modification?
|
||||
* encryptsign: TBD
|
||||
* verify: TBD
|
||||
*/
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user