{"_id":"@panva/asn1.js","_rev":"4106586","name":"@panva/asn1.js","description":"ASN.1 encoder and decoder for Node.js with no dependencies (fork of asn1.js using native BigInt)","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"panva","email":""}],"time":{"modified":"2026-01-11T18:55:42.000Z","created":"2020-02-18T14:37:23.543Z","1.0.0":"2020-02-18T14:37:23.543Z"},"users":{},"author":{"name":"Fedor Indutny"},"repository":{"type":"git","url":"git+https://github.com/panva/asn1.js.git"},"versions":{"1.0.0":{"name":"@panva/asn1.js","version":"1.0.0","description":"ASN.1 encoder and decoder for Node.js with no dependencies (fork of asn1.js using native BigInt)","keywords":["asn.1","bigint","der","pem"],"homepage":"https://github.com/panva/asn1.js","repository":{"type":"git","url":"git+https://github.com/panva/asn1.js.git"},"license":"MIT","author":{"name":"Fedor Indutny"},"main":"lib/asn1.js","scripts":{"lint":"standard","lint-fix":"standard --fix","test":"mocha test/**/*-test.js"},"devDependencies":{"mocha":"^7.0.1","standard":"^14.3.1"},"engines":{"node":">=10.13.0"},"contributors":[{"name":"Filip Skokan","email":"panva.ip@gmail.com"}],"gitHead":"45f8b14bdc797986b02684a60e9954b9bf5dfd14","bugs":{"url":"https://github.com/panva/asn1.js/issues"},"_id":"@panva/asn1.js@1.0.0","_nodeVersion":"12.13.0","_npmVersion":"6.13.7","dist":{"shasum":"dd55ae7b8129e02049f009408b97c61ccf9032f6","size":12999,"noattachment":false,"key":"/@panva/asn1.js/-/@panva/asn1.js-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@panva/asn1.js/download/@panva/asn1.js-1.0.0.tgz"},"maintainers":[{"name":"panva","email":""}],"_npmUser":{"name":"panva","email":"panva.ip@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/asn1.js_1.0.0_1582036643402_0.33768578813763317"},"_hasShrinkwrap":false,"publish_time":1582036643543,"_cnpm_publish_time":1582036643543,"_cnpmcore_publish_time":"2021-12-16T15:11:22.796Z"}},"readme":"# ASN1.js\n\nASN.1 DER Encoder/Decoder and DSL for Node.js with no dependencies\n\n## Acknowledgement\n\nThis is a fork of [@indutny's](https://github.com/indutny) `asn.js` library with the following\nchanges made:\n\n- all `.int()` returns are native `BigInt` values\n- lint using [`standard`](https://github.com/standard/standard)\n\n## Example\n\nDefine model:\n\n```js\nconst asn = require('@panva/asn1.js')\n\nconst Human = asn.define('Human', function () {\n  this.seq().obj(\n    this.key('firstName').octstr(),\n    this.key('lastName').octstr(),\n    this.key('age').int(),\n    this.key('gender').enum({ 0: 'male', 1: 'female' }),\n    this.key('bio').seqof(Bio)\n  )\n})\n\nconst Bio = asn.define('Bio', function () {\n  this.seq().obj(\n    this.key('time').gentime(),\n    this.key('description').octstr()\n  )\n})\n```\n\nEncode data:\n\n```js\nconst output = Human.encode({\n  firstName: 'Thomas',\n  lastName: 'Anderson',\n  age: 28,\n  gender: 'male',\n  bio: [\n    {\n      time: new Date('31 March 1999').getTime(),\n      description: 'freedom of mind'\n    }\n  ]\n}, 'der')\n```\n\nDecode data:\n\n```js\nconst human = Human.decode(output, 'der')\nconsole.log(human)\n/*\n{ firstName: <Buffer 54 68 6f 6d 61 73>,\n  lastName: <Buffer 41 6e 64 65 72 73 6f 6e>,\n  age: 28n,\n  gender: 'male',\n  bio:\n   [ { time: 922820400000,\n       description: <Buffer 66 72 65 65 64 6f 6d 20 6f 66 20 6d 69 6e 64> } ] }\n*/\n```\n\n### Partial decode\n\nIts possible to parse data without stopping on first error. In order to do it,\nyou should call:\n\n```js\nconst human = Human.decode(output, 'der', { partial: true })\nconsole.log(human)\n/*\n{ result: { ... },\n  errors: [ ... ] }\n*/\n```\n","_attachments":{},"homepage":"https://github.com/panva/asn1.js","bugs":{"url":"https://github.com/panva/asn1.js/issues"},"license":"MIT"}