js: fixing errors found by testing
-- * Key.js: Error code for wrong parameter in createKey should be "PARAM_WRONG" * Helpers.js: The property openpgpjs-like Objects were checked for in toKeyIdArray was not defined. * src/permittedOperations.js: updated more expectations and assumptions for the native API
This commit is contained in:
parent
c755287ba8
commit
cf075846fb
@ -48,7 +48,7 @@ export function toKeyIdArray(input){
|
|||||||
if (input[i] instanceof GPGME_Key){
|
if (input[i] instanceof GPGME_Key){
|
||||||
fpr = input[i].fingerprint;
|
fpr = input[i].fingerprint;
|
||||||
} else if (input[i].hasOwnProperty('primaryKey') &&
|
} else if (input[i].hasOwnProperty('primaryKey') &&
|
||||||
input[i].primaryKey.hasOwnProperty(getFingerprint)){
|
input[i].primaryKey.hasOwnProperty('getFingerprint')){
|
||||||
fpr = input[i].primaryKey.getFingerprint();
|
fpr = input[i].primaryKey.getFingerprint();
|
||||||
}
|
}
|
||||||
if (isFingerprint(fpr) === true){
|
if (isFingerprint(fpr) === true){
|
||||||
|
@ -35,13 +35,15 @@ import { Connection } from './Connection';
|
|||||||
|
|
||||||
export function createKey(fingerprint, parent){
|
export function createKey(fingerprint, parent){
|
||||||
if (!isFingerprint(fingerprint)){
|
if (!isFingerprint(fingerprint)){
|
||||||
return gpgme_error('KEY_INVALID');
|
return gpgme_error('PARAM_WRONG');
|
||||||
}
|
}
|
||||||
if ( parent instanceof Connection){
|
if ( parent instanceof Connection){
|
||||||
return new GPGME_Key(fingerprint, parent);
|
return new GPGME_Key(fingerprint, parent);
|
||||||
} else if ( parent.hasOwnProperty('connection') &&
|
} else if ( parent.hasOwnProperty('connection') &&
|
||||||
parent.connection instanceof Connection){
|
parent.connection instanceof Connection){
|
||||||
return new GPGME_Key(fingerprint, parent.connection);
|
return new GPGME_Key(fingerprint, parent.connection);
|
||||||
|
} else {
|
||||||
|
return gpgme_error('PARAM_WRONG');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,55 +122,96 @@ export const permittedOperations = {
|
|||||||
type: ['plaintext'],
|
type: ['plaintext'],
|
||||||
data: ['data'],
|
data: ['data'],
|
||||||
params: ['base64', 'mime'],
|
params: ['base64', 'mime'],
|
||||||
infos: [] // pending. Info about signatures and validity
|
infos: [] // TODO pending. Info about signatures and validity
|
||||||
//signature: [{Key Fingerprint, valid boolean}]
|
//{
|
||||||
|
//signatures: [{
|
||||||
|
//Key : <String>Fingerprint,
|
||||||
|
//valid: <Boolean>
|
||||||
|
// }]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/** TBD: querying the Key's information (keyinfo)
|
||||||
keyinfo: { // querying the Key's information.
|
TBD name: {
|
||||||
required: ['fingerprint'],
|
required: {
|
||||||
anser: {
|
'fingerprint': {
|
||||||
|
allowed: ['string']
|
||||||
|
},
|
||||||
|
},
|
||||||
|
answer: {
|
||||||
type: ['TBD'],
|
type: ['TBD'],
|
||||||
data: [],
|
data: [],
|
||||||
params: ['hasSecret', 'isRevoked', 'isExpired', 'armored',
|
params: ['hasSecret','isRevoked','isExpired','armored',
|
||||||
'timestamp', 'expires', 'pubkey_algo'],
|
'timestamp','expires','pubkey_algo'],
|
||||||
infos: ['subkeys', 'userIds']
|
infos: ['subkeys', 'userIds']
|
||||||
|
// {'hasSecret': <Boolean>,
|
||||||
|
// 'isRevoked': <Boolean>,
|
||||||
|
// 'isExpired': <Boolean>,
|
||||||
|
// 'armored': <String>, // armored public Key block
|
||||||
|
// 'timestamp': <Number>, //
|
||||||
|
// 'expires': <Number>,
|
||||||
|
// 'pubkey_algo': TBD // TBD (optional?),
|
||||||
|
// 'userIds': Array<String>,
|
||||||
|
// 'subkeys': Array<String> Fingerprints of Subkeys
|
||||||
|
// }
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
listkeys:{
|
listkeys:{
|
||||||
optional: ['with-secret', 'pattern'],
|
required: {};
|
||||||
|
optional: {
|
||||||
|
'with-secret':{
|
||||||
|
allowed: ['boolean']
|
||||||
|
},{
|
||||||
|
'pattern': {
|
||||||
|
allowed: ['string']
|
||||||
|
}
|
||||||
|
},
|
||||||
answer: {
|
answer: {
|
||||||
type: ['TBD'], //Array of fingerprints?
|
type: ['TBD'],
|
||||||
infos: ['TBD'] //the property with infos
|
infos: ['TBD']
|
||||||
|
// keys: Array<String> Fingerprints representing the results
|
||||||
},
|
},
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
importkey: {
|
importkey: {
|
||||||
required: ['keyarmored'],
|
required: {
|
||||||
|
'keyarmored': {
|
||||||
|
allowed: ['string']
|
||||||
|
}
|
||||||
|
},
|
||||||
answer: {
|
answer: {
|
||||||
type: ['TBD'],
|
type: ['TBD'],
|
||||||
infos: [''], // for each key if import was a success, if it was an update
|
infos: ['TBD'],
|
||||||
|
// for each key if import was a success,
|
||||||
|
// and if it was an update of preexisting key
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
deletekey: {
|
deletekey: {
|
||||||
required: ['fingerprint'],
|
pinentry: true,
|
||||||
|
required: {
|
||||||
|
'fingerprint': {
|
||||||
|
allowed: ['string'],
|
||||||
|
// array_allowed: TBD Allow several Keys to be deleted at once?
|
||||||
|
},
|
||||||
|
optional: {
|
||||||
|
'TBD' //Flag to delete secret Key ?
|
||||||
|
}
|
||||||
answer: {
|
answer: {
|
||||||
type ['TBD'],
|
type ['TBD'],
|
||||||
infos: [''] //success:true? in gpgme, an error NO_ERROR is returned
|
infos: ['']
|
||||||
|
// TBD (optional) Some kind of 'ok' if delete was successful.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*get armored secret different treatment from keyinfo!
|
*TBD get armored secret different treatment from keyinfo!
|
||||||
*/
|
* TBD key modification?
|
||||||
|
* encryptsign: TBD
|
||||||
/**
|
* verify: TBD
|
||||||
* TBD key modification requests?
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ function unittests (){
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('toKeyIdArray() (converting input to fingerprint', function(){
|
describe('toKeyIdArray() (converting input to fingerprint)', function(){
|
||||||
|
|
||||||
it('Correct fingerprint string', function(){
|
it('Correct fingerprint string', function(){
|
||||||
let test0 = toKeyIdArray(hp.validFingerprint);
|
let test0 = toKeyIdArray(hp.validFingerprint);
|
||||||
|
Loading…
Reference in New Issue
Block a user