@tozielinski/next-upstash-nonce 1.1.5 → 1.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.2.2](https://github.com/tozielinski/next-upstash-nonce/compare/v1.2.1...v1.2.2) (2025-11-21)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * add .npmignore ([4aafa2c](https://github.com/tozielinski/next-upstash-nonce/commit/4aafa2c9f4081c44030babbeb35c8a5573ef6c3b))
9
+
10
+ ## [1.2.1](https://github.com/tozielinski/next-upstash-nonce/compare/v1.2.0...v1.2.1) (2025-11-21)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * error in npm publish ([d337519](https://github.com/tozielinski/next-upstash-nonce/commit/d3375198b2bcabd846c5f7d04cb44e2059a71462))
16
+
17
+ ## [1.2.0](https://github.com/tozielinski/next-upstash-nonce/compare/v1.1.5...v1.2.0) (2025-11-21)
18
+
19
+
20
+ ### Features
21
+
22
+ * replaced crypto by uuid ([38e2076](https://github.com/tozielinski/next-upstash-nonce/commit/38e2076fe5139848e05c37d3961eec01d84cc346))
23
+
3
24
  ## [1.1.5](https://github.com/tozielinski/next-upstash-nonce/compare/v1.1.4...v1.1.5) (2025-11-21)
4
25
 
5
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tozielinski/next-upstash-nonce",
3
- "version": "1.1.5",
3
+ "version": "1.2.2",
4
4
  "description": "Create, store, verify and delete nonces in Redis by Upstash for Next.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,34 +0,0 @@
1
- name: Publish to npm
2
-
3
- on:
4
- push:
5
- tags:
6
- - "v*.*.*"
7
-
8
- permissions:
9
- contents: read
10
-
11
- jobs:
12
- publish:
13
- name: Publish package to npm
14
- runs-on: ubuntu-latest
15
- permissions:
16
- id-token: write
17
- contents: write
18
- steps:
19
- - uses: actions/checkout@v4
20
-
21
- - name: Setup Node
22
- uses: actions/setup-node@v4
23
- with:
24
- node-version: "20"
25
- registry-url: "https://registry.npmjs.org/"
26
-
27
- - name: Install dependencies
28
- run: npm ci
29
-
30
- - name: Build
31
- run: npm run build
32
-
33
- - name: Publish to npm via Trusted Publishing
34
- run: npm publish --access public
@@ -1,27 +0,0 @@
1
- name: Release Please
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- permissions:
9
- contents: write
10
- pull-requests: write
11
-
12
- jobs:
13
- release:
14
- runs-on: ubuntu-latest
15
-
16
- steps:
17
- - uses: actions/checkout@v4
18
-
19
- - name: Run Release Please
20
- uses: googleapis/release-please-action@v4
21
- with:
22
- token: ${{ secrets.GH_PAT }}
23
- release-type: node
24
- path: "." # das root package
25
- config-file: .release-please-config.json
26
- manifest-file: .release-please-manifest.json
27
-
@@ -1,9 +0,0 @@
1
- {
2
- "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3
- "release-type": "node",
4
- "packages": {
5
- ".": {
6
- "component": "next-upstash-nonce"
7
- }
8
- }
9
- }
@@ -1,3 +0,0 @@
1
- {
2
- ".": "1.1.5"
3
- }
package/dist/index.d.ts DELETED
@@ -1,29 +0,0 @@
1
- import { Redis } from "@upstash/redis";
2
- export type NonceOptions = {
3
- length?: number;
4
- ttlSeconds?: number;
5
- prefix?: string;
6
- };
7
- export declare class NonceManager {
8
- private redis;
9
- private length;
10
- private ttlSeconds;
11
- private prefix;
12
- constructor(redis: Redis, opts?: NonceOptions);
13
- /**
14
- * generates a new, secure nonce,
15
- * inserts it into Redis with a TTL,
16
- * and returns the nonce string.
17
- */
18
- create(): Promise<string>;
19
- /**
20
- * verifies a nonce and deletes it from Redis,
21
- * returning true if the nonce exists and has not expired.
22
- */
23
- verifyAndDelete(nonce: string): Promise<boolean>;
24
- /**
25
- * Optional: delete a nonce from Redis manually
26
- */
27
- delete(nonce: string): Promise<void>;
28
- }
29
- export default NonceManager;
package/dist/index.js DELETED
@@ -1,66 +0,0 @@
1
- "use strict";
2
- 'use server';
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.NonceManager = void 0;
5
- const uuid_1 = require("uuid");
6
- class NonceManager {
7
- constructor(redis, opts = {}) {
8
- this.redis = redis;
9
- this.length = opts.length ?? 32; // default 32 bytes -> 64 hex chars
10
- this.ttlSeconds = opts.ttlSeconds ?? 60 * 5; // default 5 minutes
11
- this.prefix = opts.prefix ?? "nonce:";
12
- }
13
- /**
14
- * generates a new, secure nonce,
15
- * inserts it into Redis with a TTL,
16
- * and returns the nonce string.
17
- */
18
- async create() {
19
- // const buffer = crypto.randomBytes(this.length);
20
- // const nonce = buffer.toString("hex");
21
- const nonce = (0, uuid_1.v4)();
22
- const key = this.prefix + nonce;
23
- // console.log("creating nonce:", nonce);
24
- // set with ttl (nx not required — collisions extremely unlikely)
25
- await this.redis.set(key, "1", { ex: this.ttlSeconds });
26
- return nonce;
27
- }
28
- /**
29
- * verifies a nonce and deletes it from Redis,
30
- * returning true if the nonce exists and has not expired.
31
- */
32
- async verifyAndDelete(nonce) {
33
- if (!nonce)
34
- return false;
35
- // const key = this.prefix + nonce;
36
- //
37
- // const script = `
38
- // local v = redis.call('GET', KEYS[1])
39
- // if v then
40
- // redis.call('DEL', KEYS[1])
41
- // return v
42
- // end
43
- // return nil
44
- // `;
45
- try {
46
- const res = await this.redis.get(`nonce:${nonce}`);
47
- // const res = await (this.redis as any).eval(script, { keys: [key] });
48
- if (res)
49
- await this.redis.del(`nonce:${nonce}`);
50
- return res !== null;
51
- }
52
- catch (err) {
53
- console.error("verifyAndDelete error:", err);
54
- return false;
55
- }
56
- }
57
- /**
58
- * Optional: delete a nonce from Redis manually
59
- */
60
- async delete(nonce) {
61
- const key = this.prefix + nonce;
62
- await this.redis.del(key);
63
- }
64
- }
65
- exports.NonceManager = NonceManager;
66
- exports.default = NonceManager;