| 1 | // Copyright The Notary Project Authors. |
| 2 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | // you may not use this file except in compliance with the License. |
| 4 | // You may obtain a copy of the License at |
| 5 | // |
| 6 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | // |
| 8 | // Unless required by applicable law or agreed to in writing, software |
| 9 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | // See the License for the specific language governing permissions and |
| 12 | // limitations under the License. |
| 13 | |
| 14 | // Package plugin defines the protocol layer for communication between notation |
| 15 | // and notation external plugin. |
| 16 | package plugin |
| 17 | |
| 18 | // BinaryPrefix is the prefix required on all plugin binary names. |
| 19 | const BinaryPrefix = "notation-" |
| 20 | |
| 21 | // ContractVersion is the <major>.<minor> version of the plugin contract. |
| 22 | const ContractVersion = "1.0" |
| 23 | |
| 24 | // Capability is a feature available in the plugin contract. |
| 25 | type Capability string |
| 26 | |
| 27 | const ( |
| 28 | // CapabilitySignatureGenerator is the name of the capability |
| 29 | // for a plugin to support generating raw signatures. |
| 30 | CapabilitySignatureGenerator Capability = "SIGNATURE_GENERATOR.RAW" |
| 31 | |
| 32 | // CapabilityEnvelopeGenerator is the name of the capability |
| 33 | // for a plugin to support generating envelope signatures. |
| 34 | CapabilityEnvelopeGenerator Capability = "SIGNATURE_GENERATOR.ENVELOPE" |
| 35 | |
| 36 | // CapabilityTrustedIdentityVerifier is the name of the |
| 37 | // capability for a plugin to support verifying trusted identities. |
| 38 | CapabilityTrustedIdentityVerifier Capability = "SIGNATURE_VERIFIER.TRUSTED_IDENTITY" |
| 39 | |
| 40 | // CapabilityRevocationCheckVerifier is the name of the |
| 41 | // capability for a plugin to support verifying revocation checks. |
| 42 | CapabilityRevocationCheckVerifier Capability = "SIGNATURE_VERIFIER.REVOCATION_CHECK" |
| 43 | ) |
| 44 | |
| 45 | // Command is a CLI command available in the plugin contract. |
| 46 | type Command string |
| 47 | |
| 48 | // Request defines a plugin request, which is always associated to a command. |
| 49 | type Request interface { |
| 50 | Command() Command |
| 51 | Validate() error |
| 52 | } |
| 53 | |
| 54 | const ( |
| 55 | // CommandGetMetadata is the name of the plugin command |
| 56 | // which must be supported by every plugin and returns the |
| 57 | // plugin metadata. |
| 58 | CommandGetMetadata Command = "get-plugin-metadata" |
| 59 | |
| 60 | // CommandDescribeKey is the name of the plugin command |
| 61 | // which must be supported by every plugin that has the |
| 62 | // SIGNATURE_GENERATOR.RAW capability. |
| 63 | CommandDescribeKey Command = "describe-key" |
| 64 | |
| 65 | // CommandGenerateSignature is the name of the plugin command |
| 66 | // which must be supported by every plugin that has the |
| 67 | // SIGNATURE_GENERATOR.RAW capability. |
| 68 | CommandGenerateSignature Command = "generate-signature" |
| 69 | |
| 70 | // CommandGenerateEnvelope is the name of the plugin command |
| 71 | // which must be supported by every plugin that has the |
| 72 | // SIGNATURE_GENERATOR.ENVELOPE capability. |
| 73 | CommandGenerateEnvelope Command = "generate-envelope" |
| 74 | |
| 75 | // CommandVerifySignature is the name of the plugin command |
| 76 | // which must be supported by every plugin that has |
| 77 | // any SIGNATURE_VERIFIER.* capability |
| 78 | CommandVerifySignature Command = "verify-signature" |
| 79 | |
| 80 | Version Command = "version" |
| 81 | ) |