Skip to content

Commit bae994b

Browse files
authored
Merge pull request #93 from NillionNetwork/feat/require-expiry
2 parents 978b616 + 7b485ce commit bae994b

34 files changed

+1757
-1694
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ jobs:
2121
- run: pnpm build
2222
- run: pnpm exec biome ci
2323
- run: tsc
24-
- run: pnpm attw
2524

2625
test:
2726
needs: check

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ node_modules
99
dist
1010
**/coverage
1111
docs
12+
dist/**
13+
node_modules/**

DOCUMENTATION.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const rootDelegation = await Builder.delegation()
5656
["==", ".command", "/nil/db/collections"], // Command must be an attenuation
5757
["!=", ".args.collection", "secrets"]
5858
])
59-
.expiresAt(Date.now() + 3600 * 1000) // Expires in 1 hour
59+
.expiresIn(3600 * 1000) // Expires in 1 hour
6060
.sign(rootSigner);
6161

6262
// Step 4: Build an invocation token from the delegation
@@ -71,13 +71,12 @@ const invocation = await Builder.invocationFrom(rootDelegation)
7171
const tokenString = Codec.serializeBase64Url(invocation);
7272
console.log("Token to send:", tokenString);
7373

74-
// Step 6: (Optional) Decode and validate the token
75-
// This would typically happen on the receiving service
76-
const decoded = Codec.decodeBase64Url(tokenString);
74+
// Step 6: (Optional) Parse and validate the token
75+
// This would typically happen on the receiving service.
7776
const rootDid = await rootSigner.getDid();
7877

7978
try {
80-
Validator.validate(decoded, {
79+
const decoded = Validator.parse(tokenString, {
8180
rootIssuers: [rootDid.didString], // Use the Did string for validation
8281
params: {
8382
tokenRequirements: {
@@ -90,7 +89,7 @@ try {
9089
environment: "production"
9190
}
9291
});
93-
console.log("Token is valid!");
92+
console.log("Token is valid!", decoded);
9493
} catch (error) {
9594
// It's safer to check the error message against exported constants
9695
// to avoid breaking changes if the message text is updated.

biome.jsonc

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.2.4/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.3.5/schema.json",
33
"vcs": {
44
"enabled": true,
55
"clientKind": "git",
66
"useIgnoreFile": true
77
},
88
"files": {
9-
"ignoreUnknown": false,
10-
"includes": [
11-
"**/*.ts",
12-
"**/*.mjs",
13-
"**/*.json",
14-
"!**/src/services/payer/gen",
15-
"!**/scripts",
16-
"!**/nilvm"
17-
]
9+
"ignoreUnknown": true,
10+
"includes": ["**", "!src/services/payer/gen"]
1811
},
1912
"formatter": {
2013
"enabled": true,

package.json

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nillion/nuc",
3-
"version": "1.0.0",
3+
"version": "1.1.0-rc.0",
44
"license": "MIT",
55
"repository": "https://github.com/NillionNetwork/nuc-ts",
66
"engines": {
@@ -9,8 +9,8 @@
99
"type": "module",
1010
"exports": {
1111
".": {
12-
"types": "./dist/lib.d.ts",
13-
"import": "./dist/lib.js"
12+
"types": "./dist/lib.d.mts",
13+
"import": "./dist/lib.mjs"
1414
},
1515
"./package.json": "./package.json"
1616
},
@@ -20,60 +20,67 @@
2020
"install-hooks": "lefthook install",
2121
"test": "vitest --run",
2222
"build:proto": "npx buf generate",
23-
"build": "pnpm build:proto && tsup",
24-
"attw": "attw --profile esm-only --pack ."
23+
"build": "pnpm build:proto && tsdown"
2524
},
2625
"peerDependencies": {
2726
"pino": "^9.7.0"
2827
},
2928
"dependencies": {
30-
"@bufbuild/protobuf": "^2.9.0",
31-
"@cosmjs/proto-signing": "^0.36.1",
32-
"@cosmjs/stargate": "^0.36.1",
29+
"@bufbuild/protobuf": "^2.10.1",
30+
"@cosmjs/proto-signing": "^0.37.0",
31+
"@cosmjs/stargate": "^0.37.0",
3332
"@noble/curves": "^2.0.1",
3433
"@noble/hashes": "^2.0.1",
3534
"@scure/base": "^2.0.0",
36-
"es-toolkit": "^1.40.0",
37-
"ethers": "^6.15.0",
35+
"es-toolkit": "^1.41.0",
3836
"http-status-codes": "^2.3.0",
39-
"ky": "^1.12.0",
37+
"ky": "^1.14.0",
4038
"multiformats": "^13.4.1",
41-
"viem": "^2.38.3",
39+
"viem": "^2.39.0",
4240
"zod": "^4.1.12"
4341
},
4442
"devDependencies": {
45-
"@arethetypeswrong/cli": "^0.18.2",
46-
"@biomejs/biome": "2.2.6",
47-
"@bufbuild/buf": "^1.58.0",
48-
"@bufbuild/protoc-gen-es": "^2.9.0",
43+
"@biomejs/biome": "2.3.5",
44+
"@bufbuild/buf": "^1.59.0",
45+
"@bufbuild/protoc-gen-es": "^2.10.1",
4946
"@commitlint/cli": "^20.1.0",
5047
"@commitlint/config-conventional": "^20.0.0",
5148
"@commitlint/types": "^20.0.0",
52-
"@keplr-wallet/types": "^0.12.280",
49+
"@keplr-wallet/types": "^0.12.287",
5350
"@types/debug": "^4.1.12",
54-
"@types/node": "^24.8.1",
51+
"@types/node": "^24.10.1",
5552
"@types/semver": "^7.7.1",
56-
"@vitest/coverage-v8": "^3.2.4",
53+
"@vitest/coverage-v8": "^4.0.9",
54+
"abitype": "^1.1.1",
5755
"docker-compose": "^1.3.0",
5856
"dotenv": "^17.2.3",
5957
"fast-check": "^4.3.0",
60-
"lefthook": "^2.0.0",
58+
"lefthook": "^2.0.4",
6159
"semver": "^7.7.3",
62-
"tsup": "^8.5.0",
60+
"tsdown": "^0.16.4",
6361
"tsx": "^4.20.6",
64-
"type-fest": "^5.1.0",
62+
"type-fest": "^5.2.0",
6563
"typedoc": "^0.28.14",
6664
"typescript": "^5.9.3",
67-
"vite": "^7.1.11",
65+
"vite": "^7.2.2",
6866
"vite-tsconfig-paths": "^5.1.4",
69-
"vitest": "^3.2.4"
67+
"vitest": "^4.0.9"
7068
},
71-
"packageManager": "pnpm@10.18.3",
69+
"packageManager": "pnpm@10.22.0",
7270
"files": [
7371
"dist",
7472
"LICENSE",
7573
"README.md",
7674
"DOCUMENTATION.md",
7775
"CONTRIBUTING.md"
78-
]
76+
],
77+
"tsdown": {
78+
"entry": "./src/lib.ts",
79+
"format": "esm",
80+
"clean": true,
81+
"alias": {
82+
"#": "./src",
83+
"#tests": "./tests"
84+
}
85+
}
7986
}

0 commit comments

Comments
 (0)