node-opcua-crypto-web 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +70 -0
- package/dist/index_web.d.ts +632 -0
- package/dist/index_web.js +60716 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) Etienne Rossignon 2015-2022
|
|
4
|
+
Copyright (c) Sterfive.com 2022-2026
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
23
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# node-opcua-crypto-web
|
|
2
|
+
|
|
3
|
+
Pre-bundled, zero-config browser build of [`node-opcua-crypto`](https://www.npmjs.com/package/node-opcua-crypto).
|
|
4
|
+
|
|
5
|
+
## Why this package exists
|
|
6
|
+
|
|
7
|
+
`node-opcua-crypto` is kept lean for Node.js. A browser build has to inline its own
|
|
8
|
+
polyfills (`crypto-browserify`, `stream-browserify`, …), which weighs roughly **347 KB
|
|
9
|
+
gzip** — more than the entire `node-opcua-crypto` tarball. Shipping that inside the main
|
|
10
|
+
package would make every Node consumer download a browser bundle they never import.
|
|
11
|
+
|
|
12
|
+
So it lives here instead, and Node users never pay for it.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
### Automatic (recommended)
|
|
17
|
+
|
|
18
|
+
Install both packages and keep importing `node-opcua-crypto` as usual:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install node-opcua-crypto node-opcua-crypto-web
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { exploreCertificate, convertPEMtoDER } from "node-opcua-crypto";
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`node-opcua-crypto` declares a `"browser"` export condition that redirects to this
|
|
29
|
+
package, so webpack 5, Vite/Rollup, esbuild (`--platform=browser`) and Parcel pick it up
|
|
30
|
+
automatically. Node ignores the condition and keeps the native build — the same source
|
|
31
|
+
file works in both targets.
|
|
32
|
+
|
|
33
|
+
If you bundle for the browser *without* installing this package, your bundler fails with
|
|
34
|
+
an unresolved `node-opcua-crypto-web`. That is deliberate: it tells you the browser build
|
|
35
|
+
is missing rather than silently bundling the Node one.
|
|
36
|
+
|
|
37
|
+
For TypeScript to follow the same condition, add:
|
|
38
|
+
|
|
39
|
+
```jsonc
|
|
40
|
+
{ "compilerOptions": { "customConditions": ["browser"] } }
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Without it, TypeScript keeps the Node types, which describe the same API surface minus
|
|
44
|
+
the Node-only entry points.
|
|
45
|
+
|
|
46
|
+
### Direct
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { exploreCertificate } from "node-opcua-crypto-web";
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Bring your own polyfills
|
|
53
|
+
|
|
54
|
+
If you would rather bundle from source and control the polyfills yourself, skip this
|
|
55
|
+
package and import `node-opcua-crypto/web`. That entry costs the main package almost
|
|
56
|
+
nothing (it shares a chunk with the Node entry), but it still imports `assert`,
|
|
57
|
+
`constants`, `crypto`, `path` and `url`, so your bundler must supply them.
|
|
58
|
+
|
|
59
|
+
## What is inside
|
|
60
|
+
|
|
61
|
+
An ESM-only, fully self-contained bundle — no runtime dependencies, no bare imports.
|
|
62
|
+
`node:crypto` is served by a local shim over `crypto-browserify` that adds the
|
|
63
|
+
`createPublicKey` / `createPrivateKey` functions it lacks, and WebCrypto comes from the
|
|
64
|
+
browser's native `globalThis.crypto` rather than `@peculiar/webcrypto`.
|
|
65
|
+
|
|
66
|
+
There is no CommonJS build. A CJS consumer must use `await import(...)`.
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
MIT — see [LICENSE](./LICENSE).
|