altcha-lib 0.3.0 → 0.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/README.md CHANGED
@@ -28,6 +28,22 @@ const challenge = await createChallenge({
28
28
  const ok = await verifySolution(payload, hmacKey);
29
29
  ```
30
30
 
31
+ ### Usage with Node.js 16
32
+
33
+ In Node.js version 16, there is no global reference to crypto by default. To use this library, you need to add the following code to your codebase:
34
+
35
+ ```ts
36
+ globalThis.crypto = require('node:crypto').webcrypto;
37
+ ```
38
+
39
+ Or with `import` syntax:
40
+
41
+ ```ts
42
+ import { webcrypto } from 'node:crypto';
43
+
44
+ globalThis.crypto = webcrypto;
45
+ ```
46
+
31
47
  ## API
32
48
 
33
49
  ### `createChallenge(options)`
@@ -1,4 +1,3 @@
1
- import './crypto.js';
2
1
  import type { Algorithm } from './types.js';
3
2
  export declare const encoder: TextEncoder;
4
3
  export declare function ab2hex(ab: ArrayBuffer | Uint8Array): string;
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.randomInt = exports.randomBytes = exports.hmacHex = exports.hmac = exports.hashHex = exports.hash = exports.ab2hex = exports.encoder = void 0;
4
- // @denoify-line-ignore
5
- require("./crypto.js");
6
4
  exports.encoder = new TextEncoder();
7
5
  function ab2hex(ab) {
8
6
  return [...new Uint8Array(ab)]
package/dist/helpers.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import './crypto.js';
2
1
  import type { Algorithm } from './types.js';
3
2
  export declare const encoder: TextEncoder;
4
3
  export declare function ab2hex(ab: ArrayBuffer | Uint8Array): string;
package/dist/helpers.js CHANGED
@@ -1,5 +1,3 @@
1
- // @denoify-line-ignore
2
- import './crypto.js';
3
1
  export const encoder = new TextEncoder();
4
2
  export function ab2hex(ab) {
5
3
  return [...new Uint8Array(ab)]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "altcha-lib",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "A library for creating and verifying ALTCHA challenges for Node.js, Bun and Deno.",
5
5
  "author": "Daniel Regeci",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- if (!('crypto' in globalThis)) {
4
- // eslint-disable-next-line @typescript-eslint/no-var-requires
5
- globalThis.crypto = require('node:crypto').webcrypto;
6
- }
package/dist/crypto.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/crypto.js DELETED
@@ -1,5 +0,0 @@
1
- if (!('crypto' in globalThis)) {
2
- // eslint-disable-next-line @typescript-eslint/no-var-requires
3
- globalThis.crypto = require('node:crypto').webcrypto;
4
- }
5
- export {};