Skip to content

Commit 2080be8

Browse files
authored
Merge pull request #15 from NillionNetwork/feat/rename-to-blindfold
2 parents 5907f8e + 41f5a76 commit 2080be8

File tree

11 files changed

+1326
-817
lines changed

11 files changed

+1326
-817
lines changed

.github/workflows/cd.yaml

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,46 @@
11
name: CD
22

33
on:
4+
push:
5+
branches: [ "main" ]
46
workflow_dispatch:
5-
inputs:
6-
tag:
7-
description: 'NPM tag'
8-
type: choice
9-
required: true
10-
options:
11-
- next
12-
- latest
137

148
concurrency:
159
group: "publish"
1610
cancel-in-progress: true
11+
1712
jobs:
18-
publish-nilql:
13+
check-version:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
should_publish: ${{ steps.check-version.outputs.local_version_is_higher }}
17+
tag: ${{ steps.check-version.outputs.tag }}
18+
version: ${{ steps.check-version.outputs.local_version }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: "24"
24+
- uses: pnpm/action-setup@v4
25+
- run: pnpm install
26+
- id: check-version
27+
run: pnpm exec tsx bin/check-version.ts
28+
29+
publish:
30+
needs: check-version
31+
if: needs.check-version.outputs.should_publish == 'true'
1932
runs-on: ubuntu-latest
2033
steps:
2134
- uses: actions/checkout@v4
35+
with:
36+
submodules: 'recursive'
2237
- uses: actions/setup-node@v4
2338
with:
24-
node-version: "23"
39+
node-version: "24"
2540
registry-url: "https://registry.npmjs.org"
2641
- uses: pnpm/action-setup@v4
2742
- run: pnpm install
2843
- run: pnpm build
29-
- run: pnpm exportscheck
3044
- env:
3145
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
32-
run: pnpm publish --tag ${{ github.event.inputs.tag }}
46+
run: pnpm publish --tag ${{ needs.check-version.outputs.tag }} --no-git-checks

.github/workflows/ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
pnpm install
3131
pnpm biome ci
3232
pnpm typecheck
33+
pnpm attw
3334
3435
test:
3536
name: Test and report coverage

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
# nilQL
2-
[![npm](https://badge.fury.io/js/nilql.svg)](https://www.npmjs.com/package/@nillion/nilql)
3-
[![ci](https://github.com/nillionnetwork/nilql-ts/actions/workflows/ci.yaml/badge.svg)](https://github.com/nillionnetwork/nilql-ts/actions)
4-
[![coveralls](https://coveralls.io/repos/github/NillionNetwork/nilql-ts/badge.svg?branch=main)](https://coveralls.io/github/NillionNetwork/nilql-ts)
1+
# blindfold-ts
2+
3+
[![npm](https://badge.fury.io/js/blindfold.svg)](https://www.npmjs.com/package/@nillion/blindfold)
4+
[![ci](https://github.com/nillionnetwork/blindfold-ts/actions/workflows/ci.yaml/badge.svg)](https://github.com/nillionnetwork/blindfold-ts/actions)
5+
[![coveralls](https://coveralls.io/repos/github/NillionNetwork/blindfold-ts/badge.svg?branch=main)](https://coveralls.io/github/NillionNetwork/blindfold-ts)
56

67
Library for working with encrypted data within nilDB queries and replies.
78

89
## Description and Purpose
910

10-
This library provides cryptographic operations that are compatible with nilDB nodes and clusters, allowing developers to leverage certain privacy-enhancing technologies (PETs) when storing, operating upon, and retrieving data while working with nilDB. The table below summarizes the functionalities available in nilQL.
11+
This library provides cryptographic operations that are compatible with nilDB nodes and clusters, allowing developers to leverage certain privacy-enhancing technologies (PETs) when storing, operating upon, and retrieving data while working with nilDB. The table below summarizes the functionalities available in blindfold.
1112

1213
| Cluster | Operation | Implementation Details | Supported Types |
1314
|----------------|-----------|-------------------------------------------------------------------|---------------------------------------------------|
@@ -38,7 +39,7 @@ pnpm install
3839
The library can be imported in the usual way:
3940

4041
```ts
41-
import { nilql } from "@nillion/nilql";
42+
import { blindfold } from "@nillion/blindfold";
4243
```
4344

4445
### Example: Generating Keys
@@ -47,35 +48,35 @@ The example below generates a `SecretKey` instance for a single-node cluster:
4748

4849
```ts
4950
const cluster = {"nodes": [{}]};
50-
const secretKey = await nilql.SecretKey.generate(cluster, {"store": true});
51+
const secretKey = await blindfold.SecretKey.generate(cluster, {"store": true});
5152
```
5253

5354
The example below generates a `SecretKey` instance for a multiple-node (*i.e.*, three-node) cluster with a two-share decryption threshold:
5455

5556
```ts
5657
const cluster = {"nodes": [{}, {}, {}]};
57-
const secretKey = await nilql.SecretKey.generate(cluster, {"sum": true}, 2);
58+
const secretKey = await blindfold.SecretKey.generate(cluster, {"sum": true}, 2);
5859
```
5960

6061
### Example: Encrypting and Decrypting Data
6162

6263
The below example encrypts and decrypts a string:
6364

6465
```ts
65-
const secretKey = await nilql.SecretKey.generate({"nodes": [{}]}, {"store": true});
66+
const secretKey = await blindfold.SecretKey.generate({"nodes": [{}]}, {"store": true});
6667
const plaintext = "abc";
67-
const ciphertext = await nilql.encrypt(secretKey, plaintext);
68-
const decrypted = await nilql.decrypt(secretKey, ciphertext);
68+
const ciphertext = await blindfold.encrypt(secretKey, plaintext);
69+
const decrypted = await blindfold.decrypt(secretKey, ciphertext);
6970
console.log(plaintext, decrypted); // Should output `abc abc`.
7071
```
7172

7273
The below example encrypts and decrypts an integer:
7374

7475
```ts
75-
const secretKey = await nilql.SecretKey.generate({"nodes": [{}, {}, {}]}, {"sum": true}, 2);
76+
const secretKey = await blindfold.SecretKey.generate({"nodes": [{}, {}, {}]}, {"sum": true}, 2);
7677
const plaintext = BigInt(123);
77-
const ciphertext = await nilql.encrypt(secretKey, plaintext);
78-
const decrypted = await nilql.decrypt(secretKey, ciphertext);
78+
const ciphertext = await blindfold.encrypt(secretKey, plaintext);
79+
const decrypted = await blindfold.decrypt(secretKey, ciphertext);
7980
console.log(plaintext, decrypted); // Should output `123n 123n`.
8081
```
8182

bin/check-version.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env tsx
2+
3+
import { appendFileSync } from "node:fs";
4+
import semver from "semver";
5+
import packageJson from "../package.json";
6+
7+
interface NpmRegistryResponse {
8+
"dist-tags": Record<string, string>;
9+
}
10+
11+
async function getNpmVersion(
12+
packageName: string,
13+
distTag: string,
14+
): Promise<string> {
15+
const response = await fetch(`https://registry.npmjs.org/${packageName}`);
16+
if (response.ok) {
17+
const data = (await response.json()) as NpmRegistryResponse;
18+
return data["dist-tags"][distTag] || "0.0.0";
19+
}
20+
return "0.0.0";
21+
}
22+
23+
function writeGitHubOutput(key: string, value: string): void {
24+
const githubOutput = process.env.GITHUB_OUTPUT;
25+
if (githubOutput) {
26+
appendFileSync(githubOutput, `${key}=${value}\n`);
27+
}
28+
console.log(`${key}=${value}`);
29+
}
30+
31+
async function main(): Promise<void> {
32+
// Validate version format
33+
if (!semver.valid(packageJson.version)) {
34+
throw new Error(`Invalid version format: ${packageJson.version}`);
35+
}
36+
37+
// Determine tag based on pre-release status
38+
const distTag = semver.prerelease(packageJson.version) ? "next" : "latest";
39+
const localVersion = packageJson.version;
40+
const publicVersion = await getNpmVersion(packageJson.name, distTag);
41+
const localVersionIsHigher = semver.gt(localVersion, publicVersion);
42+
43+
// Write outputs
44+
writeGitHubOutput("local_version_is_higher", localVersionIsHigher.toString());
45+
writeGitHubOutput("local_version", localVersion);
46+
writeGitHubOutput("published_version", publicVersion);
47+
writeGitHubOutput("tag", distTag);
48+
}
49+
50+
// E.g. if this file is the entry point
51+
if (import.meta.url === `file://${process.argv[1]}`) {
52+
main().catch(console.error);
53+
}

biome.jsonc

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.0.4/schema.json",
33
"vcs": {
44
"enabled": true,
55
"clientKind": "git",
66
"useIgnoreFile": true
77
},
88
"files": {
99
"ignoreUnknown": false,
10-
"include": ["**/*.ts", "**/*.mjs", "**/*.json"]
10+
"includes": ["**/*.ts", "**/*.mjs", "**/*.json"]
1111
},
1212
"formatter": {
1313
"enabled": true,
1414
"indentStyle": "space"
1515
},
16-
"organizeImports": {
17-
"enabled": true
18-
},
16+
"assist": { "actions": { "source": { "organizeImports": "on" } } },
1917
"linter": {
2018
"enabled": true,
2119
"rules": {
@@ -24,7 +22,17 @@
2422
"useExhaustiveDependencies": "off"
2523
},
2624
"style": {
27-
"noNonNullAssertion": "warn"
25+
"noNonNullAssertion": "warn",
26+
"noParameterAssign": "error",
27+
"useAsConstAssertion": "error",
28+
"useDefaultParameterLast": "error",
29+
"useEnumInitializers": "error",
30+
"useSelfClosingElements": "error",
31+
"useSingleVarDeclarator": "error",
32+
"noUnusedTemplateLiteral": "error",
33+
"useNumberNamespace": "error",
34+
"noInferrableTypes": "error",
35+
"noUselessElse": "error"
2836
}
2937
}
3038
},

package.json

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
{
2-
"name": "@nillion/nilql",
3-
"version": "0.0.0-alpha.15",
2+
"name": "@nillion/blindfold",
3+
"version": "0.1.0-rc.0",
44
"description": "Library for working with encrypted data within NilDB queries and replies.",
55
"license": "MIT",
6-
"homepage": "https://github.com/nillionnetwork/nilql-ts",
7-
"bugs": {
8-
"url": "https://github.com/nillionnetwork/nilql-ts/issues"
9-
},
10-
"repository": {
11-
"type": "git",
12-
"url": "git+https://github.com/nillionnetwork/nilql-ts.git"
13-
},
6+
"homepage": "https://github.com/nillionnetwork/blindfold-ts",
147
"type": "module",
158
"module": "./dist/index.js",
169
"types": "./dist/index.d.ts",
@@ -32,7 +25,7 @@
3225
"test": "vitest run",
3326
"lint": "biome check",
3427
"typecheck": "tsc",
35-
"exportscheck": "attw --pack .",
28+
"attw": "attw --pack .",
3629
"install-hooks": "lefthook install"
3730
},
3831
"engines": {
@@ -44,24 +37,29 @@
4437
"paillier-bigint": "^3.4.3"
4538
},
4639
"devDependencies": {
47-
"@arethetypeswrong/cli": "^0.17.4",
48-
"@biomejs/biome": "^1.9.4",
49-
"@commitlint/cli": "^19.8.0",
50-
"@commitlint/config-conventional": "^19.8.0",
51-
"@commitlint/types": "^19.8.0",
40+
"@arethetypeswrong/cli": "^0.18.2",
41+
"@biomejs/biome": "^2.0.4",
42+
"@commitlint/cli": "^19.8.1",
43+
"@commitlint/config-conventional": "^19.8.1",
44+
"@commitlint/types": "^19.8.1",
5245
"@types/libsodium-wrappers": "^0.7.14",
5346
"@types/libsodium-wrappers-sumo": "^0.7.8",
54-
"@types/node": "^22.14.1",
55-
"@vitest/coverage-v8": "^3.1.1",
47+
"@types/node": "^24.0.3",
48+
"@types/semver": "^7.7.0",
49+
"@vitest/coverage-v8": "^3.2.4",
5650
"coveralls": "^3.1.1",
5751
"crypto-browserify": "^3.12.1",
58-
"lefthook": "^1.11.10",
59-
"tsup": "^8.4.0",
52+
"lefthook": "^1.11.14",
53+
"semver": "^7.7.2",
54+
"tsup": "^8.5.0",
55+
"tsx": "^4.20.3",
6056
"typescript": "^5.8.3",
61-
"vite": "^6.2.6",
57+
"vite": "^6.3.5",
6258
"vite-tsconfig-paths": "^5.1.4",
63-
"vitest": "^3.1.1"
59+
"vitest": "^3.2.4"
6460
},
65-
"files": ["dist"],
66-
"packageManager": "[email protected]"
61+
"files": [
62+
"dist"
63+
],
64+
"packageManager": "[email protected]"
6765
}

0 commit comments

Comments
 (0)