1asn1js
2======
3
4asn1js is a JavaScript generic ASN.1 parser/decoder that can decode any valid ASN.1 DER or BER structures.
5
6An example page that can decode Base64-encoded (raw base64, PEM armoring and `begin-base64` are recognized) or Hex-encoded (or local files with some browsers) is included and can be used both [online on the official website](https://lapo.it/asn1js/) or [offline (ZIP file)](https://lapo.it/asn1js/asn1js.zip).
7
8Usage with `npm` / `yarn`
9-------------------------
10
11This package can be installed with either npm or yarn via the following commands:
12
13```sh
14npm install @lapo/asn1js
15# or other tools
16pnpm install @lapo/asn1js
17yarn add @lapo/asn1js
18```
19
20Assuming a standard javascript bundler is setup you can import it like so:
21
22```js
23import ASN1 from '@lapo/asn1js';
24```
25
26A submodule of this package can also be imported:
27
28```js
29import Hex from '@lapo/asn1js/hex';
30```
31
32Unfortunately until [`require(esm)` gets released](https://joyeecheung.github.io/blog/2024/03/18/require-esm-in-node-js/) it is necessary to use async `import()` when used from CommonJS (legacy NodeJS) code.
33
34Usage on the web
35--------------------
36
37Can be [tested on JSFiddle](https://jsfiddle.net/lapo/y6t2wo7q/).
38
39```html
40<script>
41import { ASN1} from 'https://unpkg.com/@lapo/asn1js@2.0.0/asn1.js';
42import { Hex } from 'https://unpkg.com/@lapo/asn1js@2.0.0/hex.js';
43
44document.body.innerText = ASN1.decode(Hex.decode('06032B6570')).content();
45</script>
46```
47
48ISC license
49-----------
50
51ASN.1 JavaScript decoder Copyright (c) 2008-2024 Lapo Luchini <lapo@lapo.it>
52
53Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
54
55THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
56
57credits
58-------
59
60- OBJECT IDENTIFIER values are recognized using data taken from Peter Gutmann's [dumpasn1](https://www.cs.auckland.ac.nz/~pgut001/#standards) program.
61- BMPString support added by [Felipe Gasper](https://github.com/FGasper)
62- extended tag support added by [Péter Budai](https://www.peterbudai.eu/)
63- patches by [Gergely Nagy](https://github.com/ngg)
64- Relative OID support added by [Mistial Developer](https://github.com/mistial-dev)
65- dark mode and other UI improvements by [Oliver Burgmaier](https://github.com/olibu/)
66- patches by [Nicolai Søborg](https://github.com/NicolaiSoeborg)
67
68links
69-----
70
71- [official website](https://lapo.it/asn1js/)
72- [dedicated domain](https://asn1js.eu/)
73- [InDefero tracker](http://idf.lapo.it/p/asn1js/)
74- [GitHub mirror](https://github.com/lapo-luchini/asn1js)
75- [Ohloh code stats](https://www.openhub.net/p/asn1js)