@kontrolia/shared 1.0.0
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/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/permission-key.d.ts +13 -0
- package/dist/permission-key.d.ts.map +1 -0
- package/dist/permission-key.js +11 -0
- package/dist/types.d.ts +46 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 KontrolIA Auth Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @kontrolia/shared
|
|
2
|
+
|
|
3
|
+
Tipos y utilidades TypeScript compartidos por todos los paquetes y apps de [KontrolIA Auth](https://github.com/rauldolores/auth) (claims del JWT, tipos de usuario/organización, constantes). No suele instalarse directamente — llega como dependencia transitiva de `@kontrolia/auth`, `@kontrolia/react`, etc.
|
|
4
|
+
|
|
5
|
+
## Instalación
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @kontrolia/shared
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Documentación
|
|
12
|
+
|
|
13
|
+
Ver la [guía completa](https://github.com/rauldolores/auth) del monorepo.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PermissionKey } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Permission keys are dot-separated hierarchies:
|
|
4
|
+
* "<application>.<resource>.<action>", e.g. "facturacion.facturas.crear".
|
|
5
|
+
*/
|
|
6
|
+
export interface ParsedPermissionKey {
|
|
7
|
+
application: string;
|
|
8
|
+
resource: string;
|
|
9
|
+
action: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function parsePermissionKey(key: PermissionKey): ParsedPermissionKey;
|
|
12
|
+
export declare function buildPermissionKey(parts: ParsedPermissionKey): PermissionKey;
|
|
13
|
+
//# sourceMappingURL=permission-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-key.d.ts","sourceRoot":"","sources":["../src/permission-key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,mBAAmB,CAS1E;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,mBAAmB,GAAG,aAAa,CAE5E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function parsePermissionKey(key) {
|
|
2
|
+
const segments = key.split(".");
|
|
3
|
+
if (segments.length !== 3) {
|
|
4
|
+
throw new Error(`Invalid permission key "${key}": expected "<application>.<resource>.<action>"`);
|
|
5
|
+
}
|
|
6
|
+
const [application, resource, action] = segments;
|
|
7
|
+
return { application, resource, action };
|
|
8
|
+
}
|
|
9
|
+
export function buildPermissionKey(parts) {
|
|
10
|
+
return `${parts.application}.${parts.resource}.${parts.action}`;
|
|
11
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface KontroliaUser {
|
|
2
|
+
id: string;
|
|
3
|
+
email: string | null;
|
|
4
|
+
fullName: string | null;
|
|
5
|
+
avatarUrl: string | null;
|
|
6
|
+
locale: string | null;
|
|
7
|
+
timezone: string | null;
|
|
8
|
+
lastSeenAt: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface KontroliaOrganization {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
slug: string;
|
|
14
|
+
settings: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface KontroliaMembership {
|
|
17
|
+
id: string;
|
|
18
|
+
organizationId: string;
|
|
19
|
+
status: "active" | "invited" | "suspended";
|
|
20
|
+
roles: string[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Shape of the custom claims injected by kontrolia.custom_access_token_hook
|
|
24
|
+
* (see packages/db/migrations/0007_custom_access_token_hook.sql). Present
|
|
25
|
+
* under the top-level JWT claims, decoded by @kontrolia/auth.
|
|
26
|
+
*/
|
|
27
|
+
export interface KontroliaTokenClaims {
|
|
28
|
+
sub: string;
|
|
29
|
+
/** Correlates to auth.sessions.id — used to identify/revoke this specific device's session. */
|
|
30
|
+
session_id: string;
|
|
31
|
+
organization_id: string | null;
|
|
32
|
+
roles: string[];
|
|
33
|
+
permissions: string[];
|
|
34
|
+
exp: number;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
export interface KontroliaInvitation {
|
|
38
|
+
id: string;
|
|
39
|
+
organizationId: string;
|
|
40
|
+
email: string;
|
|
41
|
+
roleId: string | null;
|
|
42
|
+
expiresAt: string;
|
|
43
|
+
}
|
|
44
|
+
/** A single "resource.action" permission key, e.g. "facturacion.facturas.crear". */
|
|
45
|
+
export type PermissionKey = string;
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;IAC3C,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,+FAA+F;IAC/F,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,oFAAoF;AACpF,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kontrolia/shared",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Shared TypeScript types and utilities used across every KontrolIA Auth package and app.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"kontrolia",
|
|
8
|
+
"auth",
|
|
9
|
+
"types"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/rauldolores/auth.git",
|
|
14
|
+
"directory": "packages/shared"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/rauldolores/auth#readme",
|
|
17
|
+
"bugs": "https://github.com/rauldolores/auth/issues",
|
|
18
|
+
"author": "KontrolIA",
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"type": "module",
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"eslint": "^9.17.0",
|
|
30
|
+
"typescript": "^5.7.2",
|
|
31
|
+
"@kontrolia/config": "0.1.0"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc -p tsconfig.json",
|
|
35
|
+
"dev": "tsc -p tsconfig.json --watch",
|
|
36
|
+
"lint": "eslint .",
|
|
37
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
38
|
+
"clean": "rimraf dist"
|
|
39
|
+
}
|
|
40
|
+
}
|