Skip to content

Commit

Permalink
chore(kms-local): rename parameters of sign() method & separate sig…
Browse files Browse the repository at this point in the history
…ning code into methods
  • Loading branch information
mirceanis committed Jun 1, 2021
1 parent a95c124 commit ab80721
Show file tree
Hide file tree
Showing 15 changed files with 312 additions and 224 deletions.
18 changes: 9 additions & 9 deletions __tests__/shared/keyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ export default (testContext: {

it('should sign JWT using generic signer', async () => {
const signature = await agent.keyManagerSign({
kid: importedKey.kid,
algorithm: 'ES256K',
data: 'bla.bla',
alg: 'ES256K',
enc: 'utf-8',
encoding: 'utf-8',
keyRef: importedKey.kid,
})
expect(signature).toEqual(
'pNAFkgmuKhqMbb_6Km--ZmY7UCkWunWUuNajSfF6rv5lEa5nNXCU7cnZBZVptU7u8h150qetqkqUaahAf-Cepw',
Expand All @@ -285,10 +285,10 @@ export default (testContext: {
})

const rawTx = await agent.keyManagerSign({
alg: 'eth_signTransaction',
algorithm: 'eth_signTransaction',
data: txData,
enc: 'hex',
kid: importedKey.kid,
encoding: 'hex',
keyRef: importedKey.kid,
})

expect(rawTx).toEqual(
Expand Down Expand Up @@ -323,10 +323,10 @@ export default (testContext: {

it('should sign JWT using generic signer', async () => {
const signature = await agent.keyManagerSign({
kid: importedKey.kid,
keyRef: importedKey.kid,
data: 'bla.bla',
alg: 'EdDSA',
enc: 'utf-8',
algorithm: 'EdDSA',
encoding: 'utf-8',
})
expect(signature).toEqual(
'_2P0iukN2CPH1nQ6LeBm1zQHHp3U4wSYDrpeWTWkp7yuzJex6O60Z4OhdfD5I9WPHV734US8n5vyD2VDbT1UCg',
Expand Down
76 changes: 38 additions & 38 deletions packages/core/plugin.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"required": [
"didUrl"
],
"description": "Input arguments for {@link IResolver.resolveDid | resolveDid}"
"description": "Input arguments for {@link IResolver.resolveDid | resolveDid }"
},
"DIDResolutionOptions": {
"type": "object",
Expand Down Expand Up @@ -357,7 +357,7 @@
"type",
"kms"
],
"description": "Input arguments for {@link IKeyManager.keyManagerCreate | keyManagerCreate}"
"description": "Input arguments for {@link IKeyManager.keyManagerCreate | keyManagerCreate }"
},
"TKeyType": {
"type": "string",
Expand Down Expand Up @@ -437,7 +437,7 @@
"kid",
"data"
],
"description": "Input arguments for {@link IKeyManager.keyManagerDecryptJWE | keyManagerDecryptJWE}"
"description": "Input arguments for {@link IKeyManager.keyManagerDecryptJWE | keyManagerDecryptJWE }"
},
"IKeyManagerDeleteArgs": {
"type": "object",
Expand All @@ -450,7 +450,7 @@
"required": [
"kid"
],
"description": "Input arguments for {@link IKeyManager.keyManagerDelete | keyManagerDelete}"
"description": "Input arguments for {@link IKeyManager.keyManagerDelete | keyManagerDelete }"
},
"IKeyManagerEncryptJWEArgs": {
"type": "object",
Expand Down Expand Up @@ -507,7 +507,7 @@
"to",
"data"
],
"description": "Input arguments for {@link IKeyManager.keyManagerEncryptJWE | keyManagerEncryptJWE}"
"description": "Input arguments for {@link IKeyManager.keyManagerEncryptJWE | keyManagerEncryptJWE }"
},
"IKeyManagerGetArgs": {
"type": "object",
Expand All @@ -520,24 +520,24 @@
"required": [
"kid"
],
"description": "Input arguments for {@link IKeyManager.keyManagerGet | keyManagerGet}"
"description": "Input arguments for {@link IKeyManager.keyManagerGet | keyManagerGet }"
},
"IKeyManagerSignArgs": {
"type": "object",
"properties": {
"kid": {
"keyRef": {
"type": "string",
"description": "Key ID"
"description": "The key handle, as returned during `keyManagerCreateKey`"
},
"alg": {
"algorithm": {
"type": "string",
"description": "The algorithm to use for signing. This must be one of the algorithms supported by the KMS for this key type."
"description": "The algorithm to use for signing. This must be one of the algorithms supported by the KMS for this key type.\n\nThe algorithm used here should match one of the names listed in `IKey.meta.algorithms`"
},
"data": {
"type": "string",
"description": "Data to sign"
},
"enc": {
"encoding": {
"type": "string",
"enum": [
"utf-8",
Expand All @@ -549,10 +549,10 @@
}
},
"required": [
"kid",
"keyRef",
"data"
],
"description": "Input arguments for {@link IKeyManager.keyManagerSign | keyManagerSign}"
"description": "Input arguments for {@link IKeyManager.keyManagerSign | keyManagerSign }"
},
"IKeyManagerSignEthTXArgs": {
"type": "object",
Expand All @@ -570,7 +570,7 @@
"kid",
"transaction"
],
"description": "Input arguments for {@link IKeyManager.keyManagerSignEthTX | keyManagerSignEthTX}"
"description": "Input arguments for {@link IKeyManager.keyManagerSignEthTX | keyManagerSignEthTX }"
},
"IKeyManagerSignJWTArgs": {
"type": "object",
Expand Down Expand Up @@ -635,7 +635,7 @@
"kid",
"data"
],
"description": "Input arguments for {@link IKeyManager.keyManagerSignJWT | keyManagerSignJWT}"
"description": "Input arguments for {@link IKeyManager.keyManagerSignJWT | keyManagerSignJWT }"
}
},
"methods": {
Expand Down Expand Up @@ -758,7 +758,7 @@
"did",
"key"
],
"description": "Input arguments for {@link IDIDManager.didManagerAddKey | didManagerAddKey}"
"description": "Input arguments for {@link IDIDManager.didManagerAddKey | didManagerAddKey }"
},
"IKey": {
"type": "object",
Expand Down Expand Up @@ -842,7 +842,7 @@
"did",
"service"
],
"description": "Input arguments for {@link IDIDManager.didManagerAddService | didManagerAddService}"
"description": "Input arguments for {@link IDIDManager.didManagerAddService | didManagerAddService }"
},
"IService": {
"type": "object",
Expand Down Expand Up @@ -891,7 +891,7 @@
"description": "Optional. Identifier provider specific options"
}
},
"description": "Input arguments for {@link IDIDManager.didManagerCreate | didManagerCreate}"
"description": "Input arguments for {@link IDIDManager.didManagerCreate | didManagerCreate }"
},
"IIdentifier": {
"type": "object",
Expand Down Expand Up @@ -946,7 +946,7 @@
"required": [
"did"
],
"description": "Input arguments for {@link IDIDManager.didManagerDelete | didManagerDelete}"
"description": "Input arguments for {@link IDIDManager.didManagerDelete | didManagerDelete }"
},
"IDIDManagerFindArgs": {
"type": "object",
Expand All @@ -960,7 +960,7 @@
"description": "Optional. Provider"
}
},
"description": "Input arguments for {@link IDIDManager.didManagerFind | didManagerFind}"
"description": "Input arguments for {@link IDIDManager.didManagerFind | didManagerFind }"
},
"IDIDManagerGetArgs": {
"type": "object",
Expand All @@ -973,7 +973,7 @@
"required": [
"did"
],
"description": "Input arguments for {@link IDIDManager.didManagerGet | didManagerGet}"
"description": "Input arguments for {@link IDIDManager.didManagerGet | didManagerGet }"
},
"IDIDManagerGetByAliasArgs": {
"type": "object",
Expand All @@ -990,7 +990,7 @@
"required": [
"alias"
],
"description": "Input arguments for {@link IDIDManager.didManagerGetByAlias | didManagerGetByAlias}"
"description": "Input arguments for {@link IDIDManager.didManagerGetByAlias | didManagerGetByAlias }"
},
"IDIDManagerGetOrCreateArgs": {
"type": "object",
Expand All @@ -1015,7 +1015,7 @@
"required": [
"alias"
],
"description": "Input arguments for {@link IDIDManager.didManagerGetOrCreate | didManagerGetOrCreate}"
"description": "Input arguments for {@link IDIDManager.didManagerGetOrCreate | didManagerGetOrCreate }"
},
"IDIDManagerRemoveKeyArgs": {
"type": "object",
Expand All @@ -1037,7 +1037,7 @@
"did",
"kid"
],
"description": "Input arguments for {@link IDIDManager.didManagerRemoveKey | didManagerRemoveKey}"
"description": "Input arguments for {@link IDIDManager.didManagerRemoveKey | didManagerRemoveKey }"
},
"IDIDManagerRemoveServiceArgs": {
"type": "object",
Expand All @@ -1059,7 +1059,7 @@
"did",
"id"
],
"description": "Input arguments for {@link IDIDManager.didManagerRemoveService | didManagerRemoveService}"
"description": "Input arguments for {@link IDIDManager.didManagerRemoveService | didManagerRemoveService }"
},
"IDIDManagerSetAliasArgs": {
"type": "object",
Expand All @@ -1077,7 +1077,7 @@
"did",
"alias"
],
"description": "Input arguments for {@link IDIDManager.didManagerSetAlias | didManagerSetAlias}"
"description": "Input arguments for {@link IDIDManager.didManagerSetAlias | didManagerSetAlias }"
}
},
"methods": {
Expand Down Expand Up @@ -1221,7 +1221,7 @@
"required": [
"id"
],
"description": "Input arguments for {@link IDataStore.dataStoreGetMessage | dataStoreGetMessage}"
"description": "Input arguments for {@link IDataStore.dataStoreGetMessage | dataStoreGetMessage }"
},
"IMessage": {
"type": "object",
Expand Down Expand Up @@ -1407,7 +1407,7 @@
"credentialSubject",
"proof"
],
"description": "Verifiable Credential {@link https://github.com/decentralized-identifier/did-jwt-vc}"
"description": "Verifiable Credential {@link https://github.com/decentralized-identifier/did-jwt-vc }"
},
"VerifiablePresentation": {
"type": "object",
Expand Down Expand Up @@ -1465,7 +1465,7 @@
"verifiableCredential",
"proof"
],
"description": "Verifiable Presentation {@link https://github.com/decentralized-identifier/did-jwt-vc}"
"description": "Verifiable Presentation {@link https://github.com/decentralized-identifier/did-jwt-vc }"
},
"IDataStoreGetVerifiableCredentialArgs": {
"type": "object",
Expand All @@ -1478,7 +1478,7 @@
"required": [
"hash"
],
"description": "Input arguments for {@link IDataStore.dataStoreGetVerifiableCredential | dataStoreGetVerifiableCredential}"
"description": "Input arguments for {@link IDataStore.dataStoreGetVerifiableCredential | dataStoreGetVerifiableCredential }"
},
"IDataStoreGetVerifiablePresentationArgs": {
"type": "object",
Expand All @@ -1491,7 +1491,7 @@
"required": [
"hash"
],
"description": "Input arguments for {@link IDataStore.dataStoreGetVerifiablePresentation | dataStoreGetVerifiablePresentation}"
"description": "Input arguments for {@link IDataStore.dataStoreGetVerifiablePresentation | dataStoreGetVerifiablePresentation }"
},
"IDataStoreSaveMessageArgs": {
"type": "object",
Expand All @@ -1504,7 +1504,7 @@
"required": [
"message"
],
"description": "Input arguments for {@link IDataStore.dataStoreSaveMessage | dataStoreSaveMessage}"
"description": "Input arguments for {@link IDataStore.dataStoreSaveMessage | dataStoreSaveMessage }"
},
"IDataStoreSaveVerifiableCredentialArgs": {
"type": "object",
Expand All @@ -1517,7 +1517,7 @@
"required": [
"verifiableCredential"
],
"description": "Input arguments for {@link IDataStore.dataStoreSaveVerifiableCredential | dataStoreSaveVerifiableCredential}"
"description": "Input arguments for {@link IDataStore.dataStoreSaveVerifiableCredential | dataStoreSaveVerifiableCredential }"
},
"IDataStoreSaveVerifiablePresentationArgs": {
"type": "object",
Expand All @@ -1530,7 +1530,7 @@
"required": [
"verifiablePresentation"
],
"description": "Input arguments for {@link IDataStore.dataStoreSaveVerifiablePresentation | dataStoreSaveVerifiablePresentation}"
"description": "Input arguments for {@link IDataStore.dataStoreSaveVerifiablePresentation | dataStoreSaveVerifiablePresentation }"
}
},
"methods": {
Expand Down Expand Up @@ -1610,13 +1610,13 @@
},
"save": {
"type": "boolean",
"description": "Optional. If set to `true`, the message will be saved using {@link IDataStore.dataStoreSaveMessage | dataStoreSaveMessage}"
"description": "Optional. If set to `true`, the message will be saved using {@link IDataStore.dataStoreSaveMessage | dataStoreSaveMessage }"
}
},
"required": [
"raw"
],
"description": "Input arguments for {@link IMessageHandler.handleMessage | handleMessage}"
"description": "Input arguments for {@link IMessageHandler.handleMessage | handleMessage }"
},
"IMetaData": {
"type": "object",
Expand Down Expand Up @@ -1802,7 +1802,7 @@
"credentialSubject",
"proof"
],
"description": "Verifiable Credential {@link https://github.com/decentralized-identifier/did-jwt-vc}"
"description": "Verifiable Credential {@link https://github.com/decentralized-identifier/did-jwt-vc }"
},
"VerifiablePresentation": {
"type": "object",
Expand Down Expand Up @@ -1860,7 +1860,7 @@
"verifiableCredential",
"proof"
],
"description": "Verifiable Presentation {@link https://github.com/decentralized-identifier/did-jwt-vc}"
"description": "Verifiable Presentation {@link https://github.com/decentralized-identifier/did-jwt-vc }"
}
},
"methods": {
Expand Down
10 changes: 6 additions & 4 deletions packages/core/src/types/IKeyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,17 @@ export interface IKeyManagerDecryptJWEArgs {
*/
export interface IKeyManagerSignArgs {
/**
* Key ID
* The key handle, as returned during `keyManagerCreateKey`
*/
kid: string
keyRef: string

/**
* The algorithm to use for signing.
* This must be one of the algorithms supported by the KMS for this key type.
*
* The algorithm used here should match one of the names listed in `IKey.meta.algorithms`
*/
alg?: string
algorithm?: string

/**
* Data to sign
Expand All @@ -105,7 +107,7 @@ export interface IKeyManagerSignArgs {
/**
* If the data is a "string" then you can specify which encoding is used. Default is "utf-8"
*/
enc?: 'utf-8' | 'base16' | 'base64' | 'hex'
encoding?: 'utf-8' | 'base16' | 'base64' | 'hex'

[x: string]: any
}
Expand Down
Loading

0 comments on commit ab80721

Please sign in to comment.