avancement planning
This commit is contained in:
+4
-6
@@ -1,7 +1,4 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.EphemeralSigner = void 0;
|
||||
/*
|
||||
@@ -19,20 +16,21 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
const crypto_1 = __importDefault(require("crypto"));
|
||||
const crypto_1 = require("crypto");
|
||||
const EC_KEYPAIR_TYPE = 'ec';
|
||||
const P256_CURVE = 'P-256';
|
||||
// Signer implementation which uses an ephemeral keypair to sign artifacts.
|
||||
// The private key lives only in memory and is tied to the lifetime of the
|
||||
// EphemeralSigner instance.
|
||||
class EphemeralSigner {
|
||||
keypair;
|
||||
constructor() {
|
||||
this.keypair = crypto_1.default.generateKeyPairSync(EC_KEYPAIR_TYPE, {
|
||||
this.keypair = (0, crypto_1.generateKeyPairSync)(EC_KEYPAIR_TYPE, {
|
||||
namedCurve: P256_CURVE,
|
||||
});
|
||||
}
|
||||
async sign(data) {
|
||||
const signature = crypto_1.default.sign(null, data, this.keypair.privateKey);
|
||||
const signature = (0, crypto_1.sign)('sha256', data, this.keypair.privateKey);
|
||||
const publicKey = this.keypair.publicKey
|
||||
.export({ format: 'pem', type: 'spki' })
|
||||
.toString('ascii');
|
||||
|
||||
Reference in New Issue
Block a user