From 69c00b29c50521fe25ddf5998c24bbbaa9d19c41 Mon Sep 17 00:00:00 2001 From: YuryStrozhevsky Date: Wed, 18 Feb 2015 10:45:47 +0300 Subject: [PATCH] Append infor about usage with Node.js --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8acb61d15..cdfdee21d 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,47 @@ At this time this library should be considered suitable for research and experim * [C++ ASN1:2008 BER coder/decoder](https://github.com/YuryStrozhevsky/C-plus-plus-ASN.1-2008-coder-decoder) - the "father" of [ASN1js][] project; * [Freely available ASN.1:2008 test suite](https://github.com/YuryStrozhevsky/ASN1-2008-free-test-suite) - the suite which can help you to validate (and better understand) any ASN.1 coder/decoder; +## How to use PKIjs with Node.js + +!!! WARNING !!! +Currently there is no "polyfill" of WebCrypto in Node.js. Thus you will not be able to use signature / verification features of PKIjs in Node.js programs. + +In order to use PKIjs you will also need [ASN1js][] plus [node.extend](https://www.npmjs.com/package/node.extend) package. +```javascript + var merge = require("node.extend"); + + var common = require("asn1js/org/pkijs/common"); + var _asn1js = require("asn1js"); + var _pkijs = require("pkijs"); + var _x509schema = require("pkijs/org/pkijs/x509_schema"); + + // #region Merging function/object declarations for ASN1js and PKIjs + var asn1js = merge(true, _asn1js, common); + + var x509schema = merge(true, _x509schema, asn1js); + + var pkijs_1 = merge(true, _pkijs, asn1js); + var pkijs = merge(true, pkijs_1, x509schema); + // #endregion +``` + +After that you will ba able to use ASN1js and PKIjs via common way: +```javascript + // #region Decode and parse X.509 cert + var asn1 = pkijs.org.pkijs.fromBER(certBuffer); + var cert; + try + { + cert = new pkijs.org.pkijs.simpl.CERT({ schema: asn1.result }); + } + catch(ex) + { + return; + } + // #endregion +``` + + ## License Copyright (c) 2014, [GMO GlobalSign](http://www.globalsign.com/) diff --git a/package.json b/package.json index b9198803b..e6ac8e990 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ ], "name": "pkijs", "description": "Public Key Infrastructure (PKI) is the basis of how identity and key management is performed on the web today. PKIjs is a pure JavaScript library implementing the formats that are used in PKI applications. It is built on WebCrypto and aspires to make it possible to build native web applications that utilize X.509 and the related formats on the web without plug-ins", - "version": "1.0.2", + "version": "1.0.3", "repository": { "type": "git", "url": "git://github.com/GlobalSign/PKI.js.git"