@teamblind/axeda-core 0.1.0-alpha.0 → 0.1.0-alpha.1

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,11 @@
1
1
  # @teamblind/axeda-core
2
2
 
3
+ ## 0.1.0-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - ce83aff: Shorten the ids of audit events from 50 to 36 characters so they fit the `id` column Better Auth creates on MySQL (`varchar(36)`); on SQLite and PostgreSQL the length was never a problem, which is why it went unnoticed. They still sort by time as text, also within one millisecond or when the clock goes back, and carry 88 random bits against collisions between processes. Events already stored keep their ids and keep their place in the order.
8
+
3
9
  ## 0.1.0-alpha.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The authorization policy and use cases of Axeda: effective permissions with downward inheritance, anti-escalation rules, companies, businesses, invitations, users, menus and audit. It depends on neither Better Auth nor any HTTP framework; it talks to storage through ports.
4
4
 
5
- > **Status:** alpha (`0.1.0-alpha.0`); the API can still change before 1.0. Install with `npm install @teamblind/axeda-core@alpha`. Documentation: [English](https://github.com/teamblindmx/axeda/tree/main/docs/en) · [Español](https://github.com/teamblindmx/axeda/tree/main/docs/es).
5
+ > **Status:** alpha (`0.1.0-alpha.1`); the API can still change before 1.0. Install with `npm install @teamblind/axeda-core@alpha`. Documentation: [English](https://github.com/teamblindmx/axeda/tree/main/docs/en) · [Español](https://github.com/teamblindmx/axeda/tree/main/docs/es).
6
6
 
7
7
  ```ts
8
8
  import { createAxeda } from '@teamblind/axeda-core';
@@ -10,4 +10,6 @@ import { createAxeda } from '@teamblind/axeda-core';
10
10
 
11
11
  Most applications use it through [`@teamblind/axeda-better-auth`](https://github.com/teamblindmx/axeda/tree/main/packages/better-auth) and only import types or `createAxeda` directly for tests.
12
12
 
13
+ Guides: [Quick start](https://github.com/teamblindmx/axeda/blob/main/docs/en/quickstart.md) · [Configuration](https://github.com/teamblindmx/axeda/blob/main/docs/en/configuration.md) · [Reference](https://github.com/teamblindmx/axeda/blob/main/docs/en/reference.md) · [Upgrading](https://github.com/teamblindmx/axeda/blob/main/docs/en/upgrading.md).
14
+
13
15
  Part of [Axeda](https://github.com/teamblindmx/axeda), hierarchical authorization (global → company → business) on top of [Better Auth](https://www.better-auth.com). Licensed under [Apache-2.0](LICENSE).
@@ -22,10 +22,12 @@ export interface AuditEvent {
22
22
  export type NewAuditEvent = Omit<AuditEvent, 'id' | 'at'>;
23
23
  /** Tamaño máximo de `metadata` serializado (S12). */
24
24
  export declare const MAX_AUDIT_METADATA_BYTES = 2048;
25
+ /** Largo de un identificador de auditoría: cabe en la columna `id` de Better Auth en MySQL. */
26
+ export declare const AUDIT_ID_LENGTH = 36;
25
27
  /**
26
- * Generador de identificadores de auditoría que ordenan cronológicamente como cadenas:
27
- * milisegundos, un contador (estrictamente creciente dentro del proceso, aunque el reloj
28
- * retroceda o dos eventos caigan en el mismo milisegundo) y un UUID para evitar colisiones
29
- * entre procesos.
28
+ * Generador de identificadores de auditoría que ordenan cronológicamente como cadenas, de
29
+ * `AUDIT_ID_LENGTH` caracteres: milisegundos, un contador (estrictamente creciente dentro del
30
+ * proceso, aunque el reloj retroceda o dos eventos caigan en el mismo milisegundo) y 88 bits
31
+ * aleatorios para evitar colisiones entre procesos.
30
32
  */
31
33
  export declare function createAuditIdFactory(): (at: Date) => string;
@@ -1,10 +1,12 @@
1
1
  /** Tamaño máximo de `metadata` serializado (S12). */
2
2
  export const MAX_AUDIT_METADATA_BYTES = 2048;
3
+ /** Largo de un identificador de auditoría: cabe en la columna `id` de Better Auth en MySQL. */
4
+ export const AUDIT_ID_LENGTH = 36;
3
5
  /**
4
- * Generador de identificadores de auditoría que ordenan cronológicamente como cadenas:
5
- * milisegundos, un contador (estrictamente creciente dentro del proceso, aunque el reloj
6
- * retroceda o dos eventos caigan en el mismo milisegundo) y un UUID para evitar colisiones
7
- * entre procesos.
6
+ * Generador de identificadores de auditoría que ordenan cronológicamente como cadenas, de
7
+ * `AUDIT_ID_LENGTH` caracteres: milisegundos, un contador (estrictamente creciente dentro del
8
+ * proceso, aunque el reloj retroceda o dos eventos caigan en el mismo milisegundo) y 88 bits
9
+ * aleatorios para evitar colisiones entre procesos.
8
10
  */
9
11
  export function createAuditIdFactory() {
10
12
  let lastMillis = 0;
@@ -13,6 +15,7 @@ export function createAuditIdFactory() {
13
15
  const millis = Math.max(at.getTime(), lastMillis);
14
16
  sequence = millis === lastMillis ? sequence + 1 : 0;
15
17
  lastMillis = millis;
16
- return `${millis.toString(36).padStart(9, '0')}${sequence.toString(36).padStart(4, '0')}-${globalThis.crypto.randomUUID()}`;
18
+ const random = Array.from(globalThis.crypto.getRandomValues(new Uint8Array(11)), (byte) => byte.toString(16).padStart(2, '0')).join('');
19
+ return `${millis.toString(36).padStart(9, '0')}${sequence.toString(36).padStart(4, '0')}-${random}`;
17
20
  };
18
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamblind/axeda-core",
3
- "version": "0.1.0-alpha.0",
3
+ "version": "0.1.0-alpha.1",
4
4
  "description": "Axeda core: hierarchical authorization policy, use cases and ports (no Better Auth or framework dependencies).",
5
5
  "license": "Apache-2.0",
6
6
  "author": "TeamBlind",