@zeroad.network/token 0.13.0 → 0.13.2

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
@@ -1,6 +1,6 @@
1
1
  ## Introduction
2
2
 
3
- **@zeroad.network/token** is a TypeScript ready module meant to be used by partnering sites of [Zero Ad Network](https://zeroad.network) platform. It's a lightweight module that works on Nodejs 18 and above, and Bun 1.3 and above runtimes.
3
+ **@zeroad.network/token** is a TypeScript ready module meant to be used by partnering sites of [Zero Ad Network](https://zeroad.network) platform. It's a lightweight module that works on Nodejs v18 and above, Bun v1.1.0 and above, and Deno v2.0.0 and above runtimes.
4
4
 
5
5
  This module allows a Zero Ad Network program partnering sites and Web APIs to verify determine if incoming web requests are coming from our browser extension users with active subscription.
6
6
 
package/dist/index.cjs CHANGED
@@ -1,34 +1,35 @@
1
1
  'use strict';
2
2
 
3
3
  var browser = require('./browser-C2zgnAdK.cjs');
4
- var crypto = require('crypto');
4
+ var node_buffer = require('node:buffer');
5
+ var node_crypto = require('node:crypto');
5
6
 
6
7
  const importPrivateKey = (privateKeyBase64) => {
7
- const keyBuffer = Buffer.from(privateKeyBase64, "base64");
8
- return crypto.createPrivateKey({
8
+ const keyBuffer = node_buffer.Buffer.from(privateKeyBase64, "base64");
9
+ return node_crypto.createPrivateKey({
9
10
  key: keyBuffer,
10
11
  format: "der",
11
12
  type: "pkcs8"
12
13
  });
13
14
  };
14
15
  const importPublicKey = (publicKeyBase64) => {
15
- const keyBuffer = Buffer.from(publicKeyBase64, "base64");
16
- return crypto.createPublicKey({
16
+ const keyBuffer = node_buffer.Buffer.from(publicKeyBase64, "base64");
17
+ return node_crypto.createPublicKey({
17
18
  key: keyBuffer,
18
19
  format: "der",
19
20
  type: "spki"
20
21
  });
21
22
  };
22
23
  const sign = (data, privateKey) => {
23
- const buffer = Buffer.from(data);
24
- return crypto.sign(null, buffer, privateKey);
24
+ const buffer = node_buffer.Buffer.from(data);
25
+ return node_crypto.sign(null, buffer, privateKey);
25
26
  };
26
27
  const verify = (data, signature, publicKey) => {
27
- const dataBuffer = Buffer.from(data);
28
- const sigBuffer = Buffer.from(signature);
29
- return crypto.verify(null, dataBuffer, publicKey, sigBuffer);
28
+ const dataBuffer = node_buffer.Buffer.from(data);
29
+ const sigBuffer = node_buffer.Buffer.from(signature);
30
+ return node_crypto.verify(null, dataBuffer, publicKey, sigBuffer);
30
31
  };
31
- const nonce = (size) => new Uint8Array(crypto.randomBytes(size));
32
+ const nonce = (size) => new Uint8Array(node_crypto.randomBytes(size));
32
33
 
33
34
  const VERSION_BYTES = 1;
34
35
  const NONCE_BYTES = 4;
@@ -131,5 +132,6 @@ exports.PROTOCOL_VERSION = browser.PROTOCOL_VERSION;
131
132
  exports.SERVER_HEADERS = browser.SERVER_HEADERS;
132
133
  exports.ServerHeader = browser.ServerHeader;
133
134
  exports.ZEROAD_NETWORK_PUBLIC_KEY = browser.ZEROAD_NETWORK_PUBLIC_KEY;
135
+ exports.setLogLevel = browser.setLogLevel;
134
136
  exports.ClientHeader = ClientHeader;
135
137
  exports.Site = Site;
package/dist/index.d.cts CHANGED
@@ -24,4 +24,4 @@ declare function Site(options: ServerHeaderOptions): {
24
24
  SERVER_HEADER_VALUE: string;
25
25
  };
26
26
 
27
- export { CLIENT_HEADERS, ClientHeader, ClientParsedHeader, FEATURES, PROTOCOL_VERSION, SERVER_HEADERS, ServerHeaderOptions, Site };
27
+ export { CLIENT_HEADERS, ClientHeader, ClientParsedHeader, FEATURES, PROTOCOL_VERSION, SERVER_HEADERS, ServerHeaderOptions, Site, setLogLevel };
package/dist/index.d.mts CHANGED
@@ -24,4 +24,4 @@ declare function Site(options: ServerHeaderOptions): {
24
24
  SERVER_HEADER_VALUE: string;
25
25
  };
26
26
 
27
- export { CLIENT_HEADERS, ClientHeader, ClientParsedHeader, FEATURES, PROTOCOL_VERSION, SERVER_HEADERS, ServerHeaderOptions, Site };
27
+ export { CLIENT_HEADERS, ClientHeader, ClientParsedHeader, FEATURES, PROTOCOL_VERSION, SERVER_HEADERS, ServerHeaderOptions, Site, setLogLevel };
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { g as getSiteFeaturesNative, C as CLIENT_HEADERS, h as hasFeature, f as fromBase64, P as PROTOCOL_VERSION, l as log, s as setFeatures, t as toBase64, S as ServerHeader, a as setLogLevel, Z as ZEROAD_NETWORK_PUBLIC_KEY } from './browser-DDeUUPbU.mjs';
2
2
  export { c as CURRENT_PROTOCOL_VERSION, F as FEATURES, b as SERVER_HEADERS } from './browser-DDeUUPbU.mjs';
3
- import { createPublicKey, verify as verify$1, randomBytes, createPrivateKey, sign as sign$1 } from 'crypto';
3
+ import { Buffer } from 'node:buffer';
4
+ import { createPublicKey, verify as verify$1, randomBytes, createPrivateKey, sign as sign$1 } from 'node:crypto';
4
5
 
5
6
  const importPrivateKey = (privateKeyBase64) => {
6
7
  const keyBuffer = Buffer.from(privateKeyBase64, "base64");
@@ -123,4 +124,4 @@ function Site(options) {
123
124
  };
124
125
  }
125
126
 
126
- export { CLIENT_HEADERS, ClientHeader, PROTOCOL_VERSION, ServerHeader, Site, ZEROAD_NETWORK_PUBLIC_KEY };
127
+ export { CLIENT_HEADERS, ClientHeader, PROTOCOL_VERSION, ServerHeader, Site, ZEROAD_NETWORK_PUBLIC_KEY, setLogLevel };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@zeroad.network/token",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
4
4
  "license": "Apache-2.0",
5
- "repository": "github:laurynas-karvelis/zeroad-token-ts",
5
+ "repository": "github:laurynas-karvelis/zeroad-token-typescript",
6
6
  "homepage": "https://zeroad.network",
7
7
  "private": false,
8
8
  "author": {
@@ -46,7 +46,7 @@
46
46
  "keys:generate": "bun run ./src/tools/cli.ts",
47
47
  "prettier": "prettier . --write",
48
48
  "build": "pkgroll --target=node18",
49
- "test": "bun test"
49
+ "test": "bun test ./src"
50
50
  },
51
51
  "dependencies": {},
52
52
  "devDependencies": {