@zeroad.network/token 0.13.1 → 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 +1 -1
- package/dist/index.cjs +12 -11
- package/dist/index.mjs +2 -1
- package/package.json +2 -2
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
32
|
+
const nonce = (size) => new Uint8Array(node_crypto.randomBytes(size));
|
|
32
33
|
|
|
33
34
|
const VERSION_BYTES = 1;
|
|
34
35
|
const NONCE_BYTES = 4;
|
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 {
|
|
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");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeroad.network/token",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": "github:laurynas-karvelis/zeroad-token-typescript",
|
|
6
6
|
"homepage": "https://zeroad.network",
|
|
@@ -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": {
|