@haneinfo/m2m-api-key 0.0.0-stage → 8.0.4

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.
Files changed (87) hide show
  1. package/LICENSE +14 -0
  2. package/dist/api-key-machine.strategy.d.ts +25 -0
  3. package/dist/api-key-machine.strategy.d.ts.map +1 -0
  4. package/dist/api-key-machine.strategy.js +110 -0
  5. package/dist/api-key-machine.strategy.js.map +1 -0
  6. package/dist/api-key-rate-limiter.d.ts +10 -0
  7. package/dist/api-key-rate-limiter.d.ts.map +1 -0
  8. package/dist/api-key-rate-limiter.js +53 -0
  9. package/dist/api-key-rate-limiter.js.map +1 -0
  10. package/dist/api-key.guard.d.ts +26 -0
  11. package/dist/api-key.guard.d.ts.map +1 -0
  12. package/dist/api-key.guard.js +109 -0
  13. package/dist/api-key.guard.js.map +1 -0
  14. package/dist/api-keys.controller.d.ts +29 -0
  15. package/dist/api-keys.controller.d.ts.map +1 -0
  16. package/dist/api-keys.controller.js +119 -0
  17. package/dist/api-keys.controller.js.map +1 -0
  18. package/dist/api-keys.module.d.ts +24 -0
  19. package/dist/api-keys.module.d.ts.map +1 -0
  20. package/dist/api-keys.module.js +85 -0
  21. package/dist/api-keys.module.js.map +1 -0
  22. package/dist/api-keys.service.d.ts +51 -0
  23. package/dist/api-keys.service.d.ts.map +1 -0
  24. package/dist/api-keys.service.js +153 -0
  25. package/dist/api-keys.service.js.map +1 -0
  26. package/dist/decorators/scopes.decorator.d.ts +3 -0
  27. package/dist/decorators/scopes.decorator.d.ts.map +1 -0
  28. package/dist/decorators/scopes.decorator.js +8 -0
  29. package/dist/decorators/scopes.decorator.js.map +1 -0
  30. package/dist/dto/api-key.dto.d.ts +37 -0
  31. package/dist/dto/api-key.dto.d.ts.map +1 -0
  32. package/dist/dto/api-key.dto.js +22 -0
  33. package/dist/dto/api-key.dto.js.map +1 -0
  34. package/dist/frontend/api-key-row-actions.d.ts +3 -0
  35. package/dist/frontend/api-key-row-actions.d.ts.map +1 -0
  36. package/dist/frontend/api-key-row-actions.js +54 -0
  37. package/dist/frontend/api-key-row-actions.js.map +1 -0
  38. package/dist/frontend/api-keys-table.d.ts +3 -0
  39. package/dist/frontend/api-keys-table.d.ts.map +1 -0
  40. package/dist/frontend/api-keys-table.js +11 -0
  41. package/dist/frontend/api-keys-table.js.map +1 -0
  42. package/dist/frontend/create-api-key-dialog.d.ts +3 -0
  43. package/dist/frontend/create-api-key-dialog.d.ts.map +1 -0
  44. package/dist/frontend/create-api-key-dialog.js +43 -0
  45. package/dist/frontend/create-api-key-dialog.js.map +1 -0
  46. package/dist/frontend/created-api-key-reveal.d.ts +3 -0
  47. package/dist/frontend/created-api-key-reveal.d.ts.map +1 -0
  48. package/dist/frontend/created-api-key-reveal.js +17 -0
  49. package/dist/frontend/created-api-key-reveal.js.map +1 -0
  50. package/dist/frontend/index.d.ts +7 -0
  51. package/dist/frontend/index.d.ts.map +1 -0
  52. package/dist/frontend/index.js +22 -0
  53. package/dist/frontend/index.js.map +1 -0
  54. package/dist/frontend/types.d.ts +98 -0
  55. package/dist/frontend/types.d.ts.map +1 -0
  56. package/dist/frontend/types.js +6 -0
  57. package/dist/frontend/types.js.map +1 -0
  58. package/dist/frontend.d.ts +9 -0
  59. package/dist/frontend.d.ts.map +1 -0
  60. package/dist/frontend.js +13 -0
  61. package/dist/frontend.js.map +1 -0
  62. package/dist/guards/admin.guard.d.ts +7 -0
  63. package/dist/guards/admin.guard.d.ts.map +1 -0
  64. package/dist/guards/admin.guard.js +6 -0
  65. package/dist/guards/admin.guard.js.map +1 -0
  66. package/dist/guards/scope.guard.d.ts +11 -0
  67. package/dist/guards/scope.guard.d.ts.map +1 -0
  68. package/dist/guards/scope.guard.js +53 -0
  69. package/dist/guards/scope.guard.js.map +1 -0
  70. package/dist/index.d.ts +12 -0
  71. package/dist/index.d.ts.map +1 -0
  72. package/dist/index.js +33 -0
  73. package/dist/index.js.map +1 -0
  74. package/dist/plugin.d.ts +16 -0
  75. package/dist/plugin.d.ts.map +1 -0
  76. package/dist/plugin.js +109 -0
  77. package/dist/plugin.js.map +1 -0
  78. package/dist/scope-matcher.service.d.ts +12 -0
  79. package/dist/scope-matcher.service.d.ts.map +1 -0
  80. package/dist/scope-matcher.service.js +28 -0
  81. package/dist/scope-matcher.service.js.map +1 -0
  82. package/haneinfo.plugin.json +82 -0
  83. package/package.json +95 -3
  84. package/plugin.d.ts +2 -0
  85. package/plugin.js +4 -0
  86. package/prisma/api-key.prisma +43 -0
  87. package/README.md +0 -3
@@ -0,0 +1,82 @@
1
+ {
2
+ "schemaVersion": "haneinfo.plugin/v1",
3
+ "id": "m2m-api-key",
4
+ "displayName": "Machine-to-Machine API Keys",
5
+ "cardinality": "singleton",
6
+ "distribution": "official",
7
+ "engine": {
8
+ "haneinfoPluginApi": "^1.0.0",
9
+ "node": ">=22.0.0",
10
+ "frameworks": {
11
+ "@nestjs/common": "^11.0.5",
12
+ "@nestjs/core": "^11.0.5",
13
+ "@prisma/client": "^6.2.0",
14
+ "lucide-react": "^1.22.0",
15
+ "react": "^19.0.0",
16
+ "react-dom": "^19.0.0"
17
+ }
18
+ },
19
+ "provides": ["haneinfo.machine-auth-provider", "haneinfo.scope-matcher"],
20
+ "requires": [
21
+ "haneinfo.identity-store",
22
+ "haneinfo.prisma",
23
+ "haneinfo.principal-context",
24
+ "haneinfo.authentication-strategy-registry"
25
+ ],
26
+ "optionalRequires": ["haneinfo.audit-sink", "haneinfo.rbac-policy"],
27
+ "facets": {
28
+ "backend": {
29
+ "modulePath": "./dist/api-keys.module.js",
30
+ "exportName": "ApiKeysModule",
31
+ "controllerRoutes": ["api-keys"],
32
+ "providerTokens": ["haneinfo.scope-matcher"]
33
+ },
34
+ "frontend": {
35
+ "adminPages": [
36
+ {
37
+ "id": "api-keys",
38
+ "routePath": "/dashboard/api-keys",
39
+ "title": "apiKeys",
40
+ "componentExport": "ApiKeysTable",
41
+ "requiredPermission": "m2m:api-key:read",
42
+ "order": 30
43
+ }
44
+ ],
45
+ "navigationItems": [
46
+ {
47
+ "id": "api-keys",
48
+ "title": "apiKeys",
49
+ "href": "/dashboard/api-keys",
50
+ "icon": "Key",
51
+ "order": 30,
52
+ "section": "admin",
53
+ "requiredPermission": "m2m:api-key:read",
54
+ "after": "roles"
55
+ }
56
+ ],
57
+ "i18nNamespace": "apiKeys",
58
+ "clientEntry": "./dist/frontend.js"
59
+ },
60
+ "prisma": {
61
+ "owns": ["ApiKey"],
62
+ "augments": [
63
+ {
64
+ "targetModel": "User",
65
+ "field": "actingApiKeys",
66
+ "owner": "identity-core",
67
+ "type": "ApiKey[] @relation(\"ApiKeyActingUser\")"
68
+ }
69
+ ],
70
+ "schemaFragment": "prisma/api-key.prisma",
71
+ "schemaDigest": "sha256:374b3ec85889c1d51f7510319db99571b97b61a3dfa75d987bb5df467daf7d92"
72
+ },
73
+ "permissions": {
74
+ "definitions": [
75
+ "m2m:api-key:create",
76
+ "m2m:api-key:update",
77
+ "m2m:api-key:delete",
78
+ "m2m:api-key:read"
79
+ ]
80
+ }
81
+ }
82
+ }
package/package.json CHANGED
@@ -1,6 +1,98 @@
1
1
  {
2
2
  "name": "@haneinfo/m2m-api-key",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "8.0.4",
4
+ "private": false,
5
+ "files": [
6
+ "dist",
7
+ "prisma",
8
+ "haneinfo.plugin.json",
9
+ "plugin.js",
10
+ "plugin.d.ts"
11
+ ],
12
+ "type": "commonjs",
13
+ "main": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "./plugin": {
21
+ "types": "./dist/plugin.d.ts",
22
+ "default": "./dist/plugin.js"
23
+ },
24
+ "./frontend": {
25
+ "types": "./dist/frontend.d.ts",
26
+ "default": "./dist/frontend.js"
27
+ },
28
+ "./haneinfo.plugin.json": "./haneinfo.plugin.json",
29
+ "./prisma/api-key.prisma": "./prisma/api-key.prisma",
30
+ "./package.json": "./package.json"
31
+ },
32
+ "dependencies": {
33
+ "@haneinfo/common": "0.3.4",
34
+ "@haneinfo/frontend-shell": "1.2.0",
35
+ "@haneinfo/plugin-api": "1.4.0"
36
+ },
37
+ "peerDependencies": {
38
+ "@haneinfo/common": "^0.3.4",
39
+ "@haneinfo/frontend-shell": "^1.1.0",
40
+ "@haneinfo/plugin-host-nest": "^2.0.0",
41
+ "@haneinfo/rbac": "^7.0.0",
42
+ "@nestjs/common": "^11.0.0",
43
+ "@nestjs/core": "^11.0.0",
44
+ "@prisma/client": "^6.19.0",
45
+ "lucide-react": "^1.22.0",
46
+ "react": "^19.0.0",
47
+ "react-dom": "^19.0.0",
48
+ "zod": "^4.4.0"
49
+ },
50
+ "peerDependenciesMeta": {
51
+ "@haneinfo/frontend-shell": {
52
+ "optional": true
53
+ },
54
+ "@haneinfo/rbac": {
55
+ "optional": true
56
+ },
57
+ "lucide-react": {
58
+ "optional": true
59
+ },
60
+ "react": {
61
+ "optional": true
62
+ },
63
+ "react-dom": {
64
+ "optional": true
65
+ }
66
+ },
67
+ "devDependencies": {
68
+ "@nestjs/common": "^11.0.0",
69
+ "@nestjs/core": "^11.0.0",
70
+ "@nestjs/testing": "^11.0.0",
71
+ "@prisma/client": "^6.19.0",
72
+ "@types/node": "^24.13.0",
73
+ "@types/react": "^19.2.17",
74
+ "@types/react-dom": "^19.2.3",
75
+ "lucide-react": "^1.22.0",
76
+ "react": "^19.2.7",
77
+ "react-dom": "^19.2.7",
78
+ "typescript": "^5.9.3",
79
+ "vitest": "^4.1.11",
80
+ "zod": "^4.4.0",
81
+ "@haneinfo/plugin-testkit": "2.2.0",
82
+ "@haneinfo/plugin-host-nest": "2.0.0",
83
+ "@haneinfo/frontend-shell": "1.2.0",
84
+ "@haneinfo/common": "0.3.4",
85
+ "@haneinfo/rbac": "7.0.4"
86
+ },
87
+ "license": "UNLICENSED",
88
+ "publishConfig": {
89
+ "registry": "https://registry.npmjs.org/",
90
+ "access": "public"
91
+ },
92
+ "scripts": {
93
+ "build": "tsc -p tsconfig.build.json",
94
+ "dev": "tsc -p tsconfig.build.json --watch",
95
+ "test": "vitest run",
96
+ "typecheck": "tsc --noEmit"
97
+ }
6
98
  }
package/plugin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ // See plugin.js for why this file exists (classic/node10 moduleResolution compatibility shim).
2
+ export * from './dist/plugin';
package/plugin.js ADDED
@@ -0,0 +1,4 @@
1
+ // Compatibility shim for consumers whose TypeScript config uses "classic"/"node10"
2
+ // moduleResolution, which resolves `@haneinfo/m2m-api-key/plugin` by looking for a real file at
3
+ // the package root — it does not consult package.json's "exports" map at all.
4
+ module.exports = require('./dist/plugin');
@@ -0,0 +1,43 @@
1
+ // Requires @haneinfo/rbac's role.prisma fragment (for the Role relation) to also
2
+ // be present in this app's prisma/schema/ folder.
3
+
4
+ /// Machine-to-machine API key for external integrations (n8n, AI agents).
5
+ /// Created by ADMIN only. Raw key is shown once at creation and never stored. @internal
6
+ model ApiKey {
7
+ id String @id @default(cuid())
8
+ /// Human-readable label, e.g. "n8n production" or "AI agent read-only".
9
+ name String
10
+ /// First chars of the raw key, shown in lists for identification (e.g. "an_live_a1b2c3d4").
11
+ prefix String
12
+ /// SHA-256 hash of the raw key. The raw key is never persisted.
13
+ hashedKey String @unique @map("hashed_key")
14
+ /// Role this key authenticates as; FK to roles table.
15
+ roleId String @map("role_id")
16
+ role Role @relation(fields: [roleId], references: [id])
17
+ /// User this key acts as for identity-bound writes (createdById, ownership checks).
18
+ /// Must be a dedicated service-account user, never a real employee's personal
19
+ /// account — see policy note below. Null = no bound identity; endpoints
20
+ /// requiring a real user must reject such calls.
21
+ /// onDelete: Restrict — deleting a bound user is blocked; unbind or deactivate
22
+ /// the key first. (In practice Users are never hard-deleted in this framework,
23
+ /// only soft-disabled via `isActive`; Restrict is defense-in-depth, not the
24
+ /// primary safeguard — see the isActive check in the guard.)
25
+ actingUserId String? @map("acting_user_id")
26
+ actingUser User? @relation("ApiKeyActingUser", fields: [actingUserId], references: [id], onDelete: Restrict)
27
+ /// Module-level scopes, e.g. ["users:read","users:*"]. "*" = all scopes. Empty = deny all.
28
+ scopes String[]
29
+ /// Requests per minute. null = system default (60).
30
+ rateLimit Int? @map("rate_limit")
31
+ /// Whether this key can be used. Set false to revoke without deleting.
32
+ isActive Boolean @default(true) @map("is_active")
33
+ /// Optional expiry. null = never expires.
34
+ expiresAt DateTime? @map("expires_at")
35
+ /// Email of the ADMIN who created this key. Snapshot string, no FK.
36
+ createdBy String? @map("created_by")
37
+ /// Timestamp of last successful authentication with this key.
38
+ lastUsedAt DateTime? @map("last_used_at")
39
+ createdAt DateTime @default(now()) @map("created_at")
40
+ updatedAt DateTime @updatedAt @map("updated_at")
41
+
42
+ @@map("api_keys")
43
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.