astro-altcha 0.1.3 → 0.1.5

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 CHANGED
@@ -1,5 +1,10 @@
1
1
  # `astro-altcha`
2
2
 
3
+ ![CI](https://codeberg.org/Trombach/astro-altcha/badges/workflows/ci.yml/badge.svg)
4
+ ![Release](https://codeberg.org/Trombach/astro-altcha/badges/release.svg)
5
+ ![NPM Version](https://img.shields.io/npm/v/astro-altcha)
6
+
7
+
3
8
  > **Warning** Early development. Expect bugs and frequent breaking changes.
4
9
 
5
10
  This is an [Astro integration](https://docs.astro.build/en/guides/integrations-guide/) that sets up altcha for Astro.
@@ -7,7 +7,7 @@ function createChallengeHandler(hmacSecret, config, deriveKeyFunc) {
7
7
  if (context.cache.enabled) context.cache.set(false);
8
8
  const challenge = await createChallenge({
9
9
  ...config.challengeOptions,
10
- expiresAt: Date.now() * 1e3 + config.challengeExpiresAfterMinutes * 60,
10
+ expiresAt: Math.floor(Date.now() / 1e3 + config.challengeExpiresAfterMinutes * 60),
11
11
  deriveKey: deriveKeyFunc,
12
12
  hmacSignatureSecret: hmacSecret,
13
13
  hmacKeySignatureSecret: await deriveHmacKeySecret(hmacSecret)
@@ -9,18 +9,20 @@ declare const altchaPayloadSchema: z.ZodObject<{
9
9
  cost: z.ZodNumber;
10
10
  keyLength: z.ZodNumber;
11
11
  keyPrefix: z.ZodString;
12
- keySignature: z.ZodString;
12
+ keySignature: z.ZodOptional<z.ZodString>;
13
13
  nonce: z.ZodString;
14
14
  salt: z.ZodString;
15
- }, z.core.$strip>;
15
+ expiresAt: z.ZodOptional<z.ZodInt>;
16
+ }, z.core.$loose>;
16
17
  signature: z.ZodString;
17
- }, z.core.$strip>;
18
+ }, z.core.$loose>;
18
19
  solution: z.ZodObject<{
19
20
  counter: z.ZodNumber;
20
21
  derivedKey: z.ZodString;
21
22
  time: z.ZodNumber;
22
- }, z.core.$strip>;
23
- }, z.core.$strip>;
23
+ }, z.core.$loose>;
24
+ }, z.core.$loose>;
24
25
  export type AltchaPayload = z.infer<typeof altchaPayloadSchema>;
25
26
  export declare function createAltchaMiddlewareHandler(hmacSecret: string, deriveKeyFunc: DeriveKeyFunction): MiddlewareHandler;
26
- //#endregion
27
+ //#endregion
28
+ export {};
@@ -4,20 +4,21 @@ import { z } from "astro/zod";
4
4
  import { base64ToString } from "uint8array-extras";
5
5
 
6
6
  //#region src/api/altcha-middleware.ts
7
- const altchaPayloadSchema = z.object({
8
- challenge: z.object({
9
- parameters: z.object({
7
+ const altchaPayloadSchema = z.looseObject({
8
+ challenge: z.looseObject({
9
+ parameters: z.looseObject({
10
10
  algorithm: z.string(),
11
11
  cost: z.number(),
12
12
  keyLength: z.number(),
13
13
  keyPrefix: z.string(),
14
- keySignature: z.string(),
14
+ keySignature: z.string().optional(),
15
15
  nonce: z.string(),
16
- salt: z.string()
16
+ salt: z.string(),
17
+ expiresAt: z.int().optional()
17
18
  }),
18
19
  signature: z.string()
19
20
  }),
20
- solution: z.object({
21
+ solution: z.looseObject({
21
22
  counter: z.number(),
22
23
  derivedKey: z.string(),
23
24
  time: z.number()
@@ -47,7 +48,7 @@ function createAltchaMiddlewareHandler(hmacSecret, deriveKeyFunc) {
47
48
  return next();
48
49
  }
49
50
  const result = await verify(altchaPayload, deriveKeyFunc, hmacSecret, await deriveHmacKeySecret(hmacSecret), store);
50
- if (result.error) {
51
+ if (result.error && !result.verification) {
51
52
  context.logger?.error(`Error verifying altcha payload: ${result.error}`);
52
53
  return next();
53
54
  }
@@ -62,4 +62,5 @@ export type AltchaFormProps = {
62
62
  name?: AltchaWidgetName;
63
63
  };
64
64
  } & astroHTML.JSX.FormHTMLAttributes;
65
- //#endregion
65
+ //#endregion
66
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-altcha",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Altcha integration for Astro",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -46,11 +46,11 @@
46
46
  "homepage": "https://codeberg.org/Trombach/astro-altcha",
47
47
  "license": "MIT",
48
48
  "peerDependencies": {
49
- "astro": "^6.0.0"
49
+ "astro": "^6.0.0 || ^7.0.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@astrojs/check": "0.9.10",
53
- "tsdown": "0.23.0"
53
+ "tsdown": "0.23.1"
54
54
  },
55
55
  "dependencies": {
56
56
  "altcha": "^3.2.3",