Skip to content

Commit 1e54654

Browse files
authored
Merge pull request #100 from NillionNetwork/feat/release-2-0-0
2 parents 01b70e7 + 0bdfdab commit 1e54654

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1278
-1875
lines changed

.github/workflows/cd.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ name: CD
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: ["main"]
66
workflow_dispatch:
77

88
concurrency:
99
group: "publish"
1010
cancel-in-progress: true
1111

1212
permissions:
13-
id-token: write # Required for NPM Trusted Publisher
13+
id-token: write # Required for NPM Trusted Publisher
1414
contents: read
1515

1616
jobs:
@@ -37,13 +37,12 @@ jobs:
3737
steps:
3838
- uses: actions/checkout@v4
3939
with:
40-
submodules: 'recursive'
40+
submodules: "recursive"
4141
- uses: actions/setup-node@v4
4242
with:
43-
node-version: "23"
43+
node-version: "24"
4444
registry-url: "https://registry.npmjs.org"
4545
- uses: pnpm/action-setup@v4
4646
- run: pnpm install
4747
- run: pnpm build
48-
- run: pnpm exec biome ci
49-
- run: tsc
48+
- run: pnpm check

.github/workflows/ci.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v4
1414
with:
15-
submodules: 'recursive'
15+
submodules: "recursive"
1616
- uses: actions/setup-node@v4
1717
with:
18-
node-version: "23"
18+
node-version: "24"
1919
- uses: pnpm/action-setup@v4
2020
- run: pnpm install
2121
- run: pnpm build
22-
- run: pnpm exec biome ci
23-
- run: tsc
22+
- run: pnpm check
2423

2524
test:
2625
needs: check
@@ -29,7 +28,7 @@ jobs:
2928
- uses: actions/checkout@v4
3029
- uses: actions/setup-node@v4
3130
with:
32-
node-version: "23"
31+
node-version: "24"
3332
- uses: pnpm/action-setup@v4
3433
- run: pnpm install
3534
- run: pnpm vitest --coverage

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ dist
1111
docs
1212
dist/**
1313
node_modules/**
14+
tsconfig.tsbuildinfo

.oxfmtrc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"printWidth": 120,
4+
"experimentalSortImports": {
5+
"groups": ["builtin", "external", "internal", ["parent", "sibling", "index"]],
6+
"internalPattern": ["@nillion/"],
7+
"newlinesBetween": true
8+
}
9+
}

.oxlintrc.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["typescript", "import", "unicorn", "vitest"],
4+
"categories": {
5+
"correctness": "warn"
6+
},
7+
"rules": {
8+
"no-nested-ternary": "error",
9+
"no-unneeded-ternary": "error",
10+
"no-unused-vars": "error",
11+
"typescript/no-explicit-any": "error",
12+
"typescript/explicit-function-return-type": "error",
13+
"unicorn/prefer-node-protocol": "error",
14+
"unicorn/filename-case": ["error", { "case": "kebabCase" }],
15+
"import/no-cycle": "error"
16+
},
17+
"overrides": [
18+
{
19+
"files": ["tests/**/*.ts"],
20+
"rules": {
21+
"typescript/no-explicit-any": "off",
22+
"typescript/no-non-null-assertion": "off",
23+
"typescript/no-floating-promises": "off"
24+
}
25+
}
26+
]
27+
}

CONTRIBUTING.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ This project is managed via [pnpm](https://pnpm.io/). To install dependencies ru
1717
The library uses [pino](https://github.com/pinojs/pino) for structured logging. You can control the log level to help debug issues:
1818

1919
1. **Node.js**: Set the `NILLION_LOG_LEVEL` environment variable
20+
2021
```bash
2122
NILLION_LOG_LEVEL=debug pnpm test
2223
NILLION_LOG_LEVEL=trace node your-script.js
2324
```
2425

2526
2. **Browser**: Use the developer console to configure logging
27+
2628
```javascript
2729
// Set log level via localStorage
2830
localStorage.setItem("NILLION_LOG_LEVEL", "debug");
@@ -32,12 +34,12 @@ The library uses [pino](https://github.com/pinojs/pino) for structured logging.
3234
```
3335

3436
3. **Available log levels** (from most to least verbose):
35-
- `trace` - Extremely detailed debugging information
36-
- `debug` - Detailed debugging information
37-
- `info` - General informational messages
38-
- `warn` - Warning messages
39-
- `error` - Error messages only
40-
- `silent` - Disable all logging
37+
- `trace` - Extremely detailed debugging information
38+
- `debug` - Detailed debugging information
39+
- `info` - General informational messages
40+
- `warn` - Warning messages
41+
- `error` - Error messages only
42+
- `silent` - Disable all logging
4143

4244
## Documentation
4345

@@ -49,12 +51,12 @@ The documentation can be generated automatically from the source files using [Ty
4951
All unit tests are executed and their coverage is measured when using [vitest](https://vitest.dev/):
5052
`pnpm test --coverage`
5153

52-
Style conventions are enforced using [Biome](https://biomejs.dev/): `biome check`
54+
Style conventions are enforced using [oxlint](https://oxc.rs/docs/guide/usage/linter) and [oxfmt](https://oxc.rs/docs/guide/usage/formatter): `pnpm check`
5355

5456
## Versioning
5557

5658
The version number format for this library and the changes to the library associated with version number increments conform with [Semantic Versioning 2.0.0](https://semver.org/#semantic-versioning-200).
5759

5860
## Publishing
5961

60-
This library can be published as a [package on npmjs](https://www.npmjs.com/package/@nillion/nuc) via the GitHub Actions workflow.
62+
This library can be published as a [package on npmjs](https://www.npmjs.com/package/@nillion/nuc) via the GitHub Actions workflow.

DOCUMENTATION.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ pnpm install @nillion/nuc
99
```
1010

1111
```typescript
12-
import { Builder, Codec, Signer, Validator } from '@nillion/nuc';
12+
import { Builder, Codec, Signer, Validator } from "@nillion/nuc";
1313
```
1414

1515
## Core Concepts
1616

1717
A Nuc (Nillion User Controlled) token is a type of capability-based authorisation token inspired by the UCAN specification. It grants specific permissions from a sender to a receiver. Three core claims define the actors in this relationship:
1818

1919
| Claim | Role | Description |
20-
|:----------|:------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------|
20+
| :-------- | :---------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------ |
2121
| **`iss`** | **Issuer (Sender)** | The principal who created and signed the token. |
2222
| **`aud`** | **Audience (Receiver)** | The principal the token is addressed to. This is the only entity that can use (i.e., invoke or delegate) the token. |
2323
| **`sub`** | **Subject** | The principal the token is "about". It represents the identity whose authority is being granted. This value must stay the same throughout a delegation chain. |
@@ -29,7 +29,7 @@ In a simple, two-party delegation, the `aud` and `sub` are often the same. When
2929
This example demonstrates the primary workflow of creating delegation and invocation tokens:
3030

3131
```typescript
32-
import { Signer, Builder, Codec, Validator } from '@nillion/nuc';
32+
import { Signer, Builder, Codec, Validator } from "@nillion/nuc";
3333

3434
// Step 1: Create Signers for different parties
3535
// A root authority (e.g., for a server-side process with a private key)
@@ -49,22 +49,23 @@ const serviceDidString = serviceDid.didString; // e.g., "did:key:zDnae..."
4949
// Step 3: Build a root delegation token
5050
// This grants capabilities from the root to the user
5151
const rootDelegation = await Builder.delegation()
52-
.audience(userDid) // Who can use this delegation
53-
.subject(userDid) // Who the delegation is about
54-
.command("/nil/db/collections/read") // The authorized command namespace
55-
.policy([ // Policy rules that must be satisfied
52+
.audience(userDid) // Who can use this delegation
53+
.subject(userDid) // Who the delegation is about
54+
.command("/nil/db/collections/read") // The authorized command namespace
55+
.policy([
56+
// Policy rules that must be satisfied
5657
["==", ".command", "/nil/db/collections"], // Command must be an attenuation
57-
["!=", ".args.collection", "secrets"]
58+
["!=", ".args.collection", "secrets"],
5859
])
59-
.expiresIn(3600 * 1000) // Expires in 1 hour
60+
.expiresIn(3600 * 1000) // Expires in 1 hour
6061
.sign(rootSigner);
6162

6263
// Step 4: Build an invocation token from the delegation
6364
// The user invokes their granted capability for the service
6465
const invocation = await Builder.invocationFrom(rootDelegation)
65-
.audience(serviceDid) // The service that will process this
66-
.command("/nil/db/collections/read") // The specific command being invoked
67-
.arguments({ collection: "users" }) // Arguments for the command
66+
.audience(serviceDid) // The service that will process this
67+
.command("/nil/db/collections/read") // The specific command being invoked
68+
.arguments({ collection: "users" }) // Arguments for the command
6869
.sign(userSigner); // Signed by the user
6970

7071
// Step 5: Serialize for transmission
@@ -81,13 +82,13 @@ try {
8182
params: {
8283
tokenRequirements: {
8384
type: "invocation",
84-
audience: serviceDidString
85-
}
85+
audience: serviceDidString,
86+
},
8687
},
8788
context: {
8889
// Additional context for policy evaluation
89-
environment: "production"
90-
}
90+
environment: "production",
91+
},
9192
});
9293
console.log("Token is valid!", decoded);
9394
} catch (error) {

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ If you're unsure where to start, head over to [docs.nillion.com](https://docs.ni
2121

2222
## License
2323

24-
This project is licensed under the [MIT License](./LICENSE).
24+
This project is licensed under the [MIT License](./LICENSE).

bin/check-version.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
#!/usr/bin/env tsx
22

33
import { appendFileSync } from "node:fs";
4+
45
import semver from "semver";
6+
57
import packageJson from "../package.json";
68

79
interface NpmRegistryResponse {
810
"dist-tags": Record<string, string>;
911
}
1012

11-
async function getNpmVersion(
12-
packageName: string,
13-
distTag: string,
14-
): Promise<string> {
13+
async function getNpmVersion(packageName: string, distTag: string): Promise<string> {
1514
const response = await fetch(`https://registry.npmjs.org/${packageName}`);
1615
if (response.ok) {
1716
const data = (await response.json()) as NpmRegistryResponse;

biome.jsonc

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)