@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.
- package/LICENSE +14 -0
- package/dist/api-key-machine.strategy.d.ts +25 -0
- package/dist/api-key-machine.strategy.d.ts.map +1 -0
- package/dist/api-key-machine.strategy.js +110 -0
- package/dist/api-key-machine.strategy.js.map +1 -0
- package/dist/api-key-rate-limiter.d.ts +10 -0
- package/dist/api-key-rate-limiter.d.ts.map +1 -0
- package/dist/api-key-rate-limiter.js +53 -0
- package/dist/api-key-rate-limiter.js.map +1 -0
- package/dist/api-key.guard.d.ts +26 -0
- package/dist/api-key.guard.d.ts.map +1 -0
- package/dist/api-key.guard.js +109 -0
- package/dist/api-key.guard.js.map +1 -0
- package/dist/api-keys.controller.d.ts +29 -0
- package/dist/api-keys.controller.d.ts.map +1 -0
- package/dist/api-keys.controller.js +119 -0
- package/dist/api-keys.controller.js.map +1 -0
- package/dist/api-keys.module.d.ts +24 -0
- package/dist/api-keys.module.d.ts.map +1 -0
- package/dist/api-keys.module.js +85 -0
- package/dist/api-keys.module.js.map +1 -0
- package/dist/api-keys.service.d.ts +51 -0
- package/dist/api-keys.service.d.ts.map +1 -0
- package/dist/api-keys.service.js +153 -0
- package/dist/api-keys.service.js.map +1 -0
- package/dist/decorators/scopes.decorator.d.ts +3 -0
- package/dist/decorators/scopes.decorator.d.ts.map +1 -0
- package/dist/decorators/scopes.decorator.js +8 -0
- package/dist/decorators/scopes.decorator.js.map +1 -0
- package/dist/dto/api-key.dto.d.ts +37 -0
- package/dist/dto/api-key.dto.d.ts.map +1 -0
- package/dist/dto/api-key.dto.js +22 -0
- package/dist/dto/api-key.dto.js.map +1 -0
- package/dist/frontend/api-key-row-actions.d.ts +3 -0
- package/dist/frontend/api-key-row-actions.d.ts.map +1 -0
- package/dist/frontend/api-key-row-actions.js +54 -0
- package/dist/frontend/api-key-row-actions.js.map +1 -0
- package/dist/frontend/api-keys-table.d.ts +3 -0
- package/dist/frontend/api-keys-table.d.ts.map +1 -0
- package/dist/frontend/api-keys-table.js +11 -0
- package/dist/frontend/api-keys-table.js.map +1 -0
- package/dist/frontend/create-api-key-dialog.d.ts +3 -0
- package/dist/frontend/create-api-key-dialog.d.ts.map +1 -0
- package/dist/frontend/create-api-key-dialog.js +43 -0
- package/dist/frontend/create-api-key-dialog.js.map +1 -0
- package/dist/frontend/created-api-key-reveal.d.ts +3 -0
- package/dist/frontend/created-api-key-reveal.d.ts.map +1 -0
- package/dist/frontend/created-api-key-reveal.js +17 -0
- package/dist/frontend/created-api-key-reveal.js.map +1 -0
- package/dist/frontend/index.d.ts +7 -0
- package/dist/frontend/index.d.ts.map +1 -0
- package/dist/frontend/index.js +22 -0
- package/dist/frontend/index.js.map +1 -0
- package/dist/frontend/types.d.ts +98 -0
- package/dist/frontend/types.d.ts.map +1 -0
- package/dist/frontend/types.js +6 -0
- package/dist/frontend/types.js.map +1 -0
- package/dist/frontend.d.ts +9 -0
- package/dist/frontend.d.ts.map +1 -0
- package/dist/frontend.js +13 -0
- package/dist/frontend.js.map +1 -0
- package/dist/guards/admin.guard.d.ts +7 -0
- package/dist/guards/admin.guard.d.ts.map +1 -0
- package/dist/guards/admin.guard.js +6 -0
- package/dist/guards/admin.guard.js.map +1 -0
- package/dist/guards/scope.guard.d.ts +11 -0
- package/dist/guards/scope.guard.d.ts.map +1 -0
- package/dist/guards/scope.guard.js +53 -0
- package/dist/guards/scope.guard.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +16 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +109 -0
- package/dist/plugin.js.map +1 -0
- package/dist/scope-matcher.service.d.ts +12 -0
- package/dist/scope-matcher.service.d.ts.map +1 -0
- package/dist/scope-matcher.service.js +28 -0
- package/dist/scope-matcher.service.js.map +1 -0
- package/haneinfo.plugin.json +82 -0
- package/package.json +95 -3
- package/plugin.d.ts +2 -0
- package/plugin.js +4 -0
- package/prisma/api-key.prisma +43 -0
- package/README.md +0 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.CreatedApiKeyReveal = CreatedApiKeyReveal;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const frontend_shell_1 = require("@haneinfo/frontend-shell");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
function CreatedApiKeyReveal({ created, onDone }) {
|
|
9
|
+
const t = (0, frontend_shell_1.useTranslations)('apiKeys');
|
|
10
|
+
const [copied, setCopied] = (0, react_1.useState)(false);
|
|
11
|
+
async function handleCopy() {
|
|
12
|
+
await navigator.clipboard.writeText(created.key);
|
|
13
|
+
setCopied(true);
|
|
14
|
+
}
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)(frontend_shell_1.DialogHeader, { children: [(0, jsx_runtime_1.jsx)(frontend_shell_1.DialogTitle, { children: t('createdTitle') }), (0, jsx_runtime_1.jsx)(frontend_shell_1.DialogDescription, { children: t('createdDescription') })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-2 py-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "break-all rounded-md border bg-muted p-3 font-mono text-sm", children: created.key }), (0, jsx_runtime_1.jsx)(frontend_shell_1.Button, { type: "button", variant: "outline", onClick: handleCopy, children: copied ? t('copied') : t('copyToClipboard') })] }), (0, jsx_runtime_1.jsx)(frontend_shell_1.DialogFooter, { children: (0, jsx_runtime_1.jsx)(frontend_shell_1.Button, { type: "button", onClick: onDone, disabled: !copied, children: t('doneAfterCopy') }) })] }));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=created-api-key-reveal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"created-api-key-reveal.js","sourceRoot":"","sources":["../../src/frontend/created-api-key-reveal.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAab,kDA8BC;;AAzCD,6DAOkC;AAClC,iCAAiC;AAGjC,SAAgB,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,EAA4B;IAC/E,MAAM,CAAC,GAAG,IAAA,gCAAe,EAAC,SAAS,CAAC,CAAC;IACrC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAE5C,KAAK,UAAU,UAAU;QACvB,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjD,SAAS,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CACL,4CACE,wBAAC,6BAAY,eACX,uBAAC,4BAAW,cAAE,CAAC,CAAC,cAAc,CAAC,GAAe,EAC9C,uBAAC,kCAAiB,cAAE,CAAC,CAAC,oBAAoB,CAAC,GAAqB,IACnD,EACf,iCAAK,SAAS,EAAC,0BAA0B,aACvC,gCAAK,SAAS,EAAC,4DAA4D,YACxE,OAAO,CAAC,GAAG,GACR,EACN,uBAAC,uBAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAC,SAAS,EAAC,OAAO,EAAE,UAAU,YACxD,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,GACrC,IACL,EACN,uBAAC,6BAAY,cACX,uBAAC,uBAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,MAAM,YACrD,CAAC,CAAC,eAAe,CAAC,GACZ,GACI,IACX,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ApiKeyRowActions } from './api-key-row-actions.js';
|
|
2
|
+
export { ApiKeysTable } from './api-keys-table.js';
|
|
3
|
+
export { CreateApiKeyDialog } from './create-api-key-dialog.js';
|
|
4
|
+
export { CreatedApiKeyReveal } from './created-api-key-reveal.js';
|
|
5
|
+
export type { ApiKeyRoleOption, ApiKeyRoleRef, ApiKeyRow, ApiKeyRowActionsProps, ApiKeyScopeOption, ApiKeySortField, ApiKeysTableKey, ApiKeysTableProps, CreateApiKeyDialogProps, CreateApiKeyResponse, CreateApiKeyResult, CreatedApiKeyRevealProps, ServiceAccountOption, } from './types.js';
|
|
6
|
+
export { SCOPE_ACTIONS, SCOPE_RESOURCES } from './types.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/frontend/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SCOPE_RESOURCES = exports.SCOPE_ACTIONS = exports.CreatedApiKeyReveal = exports.CreateApiKeyDialog = exports.ApiKeysTable = exports.ApiKeyRowActions = void 0;
|
|
4
|
+
// Named re-exports, not `export * from`: TypeScript's CJS `export *` compiles to a `for...in`
|
|
5
|
+
// enumeration over the re-exported module (see `__exportStar`'s helper in the compiled output).
|
|
6
|
+
// Next.js's RSC client-reference proxy (what a 'use client' module becomes when required from a
|
|
7
|
+
// Server Component) only implements property-access (`get`), not enumeration -- so `for...in`
|
|
8
|
+
// silently copies zero properties from it, and anything re-exported that way from this barrel
|
|
9
|
+
// resolves to `undefined` in a Server Component. A named export compiles to direct property
|
|
10
|
+
// access on the proxy instead, which works.
|
|
11
|
+
var api_key_row_actions_js_1 = require("./api-key-row-actions.js");
|
|
12
|
+
Object.defineProperty(exports, "ApiKeyRowActions", { enumerable: true, get: function () { return api_key_row_actions_js_1.ApiKeyRowActions; } });
|
|
13
|
+
var api_keys_table_js_1 = require("./api-keys-table.js");
|
|
14
|
+
Object.defineProperty(exports, "ApiKeysTable", { enumerable: true, get: function () { return api_keys_table_js_1.ApiKeysTable; } });
|
|
15
|
+
var create_api_key_dialog_js_1 = require("./create-api-key-dialog.js");
|
|
16
|
+
Object.defineProperty(exports, "CreateApiKeyDialog", { enumerable: true, get: function () { return create_api_key_dialog_js_1.CreateApiKeyDialog; } });
|
|
17
|
+
var created_api_key_reveal_js_1 = require("./created-api-key-reveal.js");
|
|
18
|
+
Object.defineProperty(exports, "CreatedApiKeyReveal", { enumerable: true, get: function () { return created_api_key_reveal_js_1.CreatedApiKeyReveal; } });
|
|
19
|
+
var types_js_1 = require("./types.js");
|
|
20
|
+
Object.defineProperty(exports, "SCOPE_ACTIONS", { enumerable: true, get: function () { return types_js_1.SCOPE_ACTIONS; } });
|
|
21
|
+
Object.defineProperty(exports, "SCOPE_RESOURCES", { enumerable: true, get: function () { return types_js_1.SCOPE_RESOURCES; } });
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/frontend/index.ts"],"names":[],"mappings":";;;AAAA,8FAA8F;AAC9F,gGAAgG;AAChG,gGAAgG;AAChG,8FAA8F;AAC9F,8FAA8F;AAC9F,4FAA4F;AAC5F,4CAA4C;AAC5C,mEAA4D;AAAnD,0HAAA,gBAAgB,OAAA;AACzB,yDAAmD;AAA1C,iHAAA,YAAY,OAAA;AACrB,uEAAgE;AAAvD,8HAAA,kBAAkB,OAAA;AAC3B,yEAAkE;AAAzD,gIAAA,mBAAmB,OAAA;AAgB5B,uCAA4D;AAAnD,yGAAA,aAAa,OAAA;AAAE,2GAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { SortableLinkComponent, SortOrder } from '@haneinfo/frontend-shell' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
4
|
+
export type ApiKeySortField = 'name' | 'lastUsedAt';
|
|
5
|
+
export type ApiKeysTableKey = 'actingUser' | 'actingUserNone' | 'active' | 'inactive' | 'key' | 'lastUsed' | 'name' | 'never' | 'noApiKeys' | 'role' | 'scopes' | 'status';
|
|
6
|
+
export interface ApiKeyRoleRef {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
displayName: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ApiKeyRow {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
prefix: string;
|
|
15
|
+
roleId: string;
|
|
16
|
+
actingUserId: string | null;
|
|
17
|
+
role: ApiKeyRoleRef;
|
|
18
|
+
scopes: string[];
|
|
19
|
+
rateLimit: number | null;
|
|
20
|
+
isActive: boolean;
|
|
21
|
+
expiresAt: string | null;
|
|
22
|
+
createdBy: string | null;
|
|
23
|
+
lastUsedAt: string | null;
|
|
24
|
+
createdAt: string;
|
|
25
|
+
updatedAt: string;
|
|
26
|
+
}
|
|
27
|
+
export interface CreateApiKeyResponse {
|
|
28
|
+
id: string;
|
|
29
|
+
key: string;
|
|
30
|
+
prefix: string;
|
|
31
|
+
name: string;
|
|
32
|
+
roleId: string;
|
|
33
|
+
role: ApiKeyRoleRef;
|
|
34
|
+
scopes: string[];
|
|
35
|
+
createdAt: string;
|
|
36
|
+
}
|
|
37
|
+
export interface CreateApiKeyResult {
|
|
38
|
+
error?: string;
|
|
39
|
+
created?: CreateApiKeyResponse;
|
|
40
|
+
}
|
|
41
|
+
export interface ApiKeyRoleOption {
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
displayName: string;
|
|
45
|
+
}
|
|
46
|
+
export interface ServiceAccountOption {
|
|
47
|
+
id: string;
|
|
48
|
+
email: string;
|
|
49
|
+
name: string | null;
|
|
50
|
+
}
|
|
51
|
+
export interface ApiKeyScopeOption {
|
|
52
|
+
value: string;
|
|
53
|
+
label: string;
|
|
54
|
+
}
|
|
55
|
+
export declare const SCOPE_RESOURCES: readonly ["users", "api-keys"];
|
|
56
|
+
export declare const SCOPE_ACTIONS: readonly ["read", "write"];
|
|
57
|
+
export interface ApiKeysTableProps {
|
|
58
|
+
apiKeys: ApiKeyRow[];
|
|
59
|
+
serviceAccounts: ServiceAccountOption[];
|
|
60
|
+
sortField: string | undefined;
|
|
61
|
+
sortOrder: SortOrder | undefined;
|
|
62
|
+
LinkComponent: SortableLinkComponent;
|
|
63
|
+
buildSortHref: (field: ApiKeySortField, order: SortOrder) => string;
|
|
64
|
+
t: (key: ApiKeysTableKey) => string;
|
|
65
|
+
setApiKeyActiveAction: (id: string, isActive: boolean) => Promise<{
|
|
66
|
+
error?: string;
|
|
67
|
+
}>;
|
|
68
|
+
deleteApiKeyAction: (id: string) => Promise<{
|
|
69
|
+
error?: string;
|
|
70
|
+
}>;
|
|
71
|
+
updateApiKeyActingUserAction: (id: string, actingUserId: string | null) => Promise<{
|
|
72
|
+
error?: string;
|
|
73
|
+
}>;
|
|
74
|
+
}
|
|
75
|
+
export interface CreateApiKeyDialogProps {
|
|
76
|
+
roles: ApiKeyRoleOption[];
|
|
77
|
+
serviceAccounts: ServiceAccountOption[];
|
|
78
|
+
scopeOptions?: ApiKeyScopeOption[];
|
|
79
|
+
createApiKeyAction: (formData: FormData) => Promise<CreateApiKeyResult>;
|
|
80
|
+
}
|
|
81
|
+
export interface CreatedApiKeyRevealProps {
|
|
82
|
+
created: CreateApiKeyResponse;
|
|
83
|
+
onDone: () => void;
|
|
84
|
+
}
|
|
85
|
+
export interface ApiKeyRowActionsProps {
|
|
86
|
+
apiKey: ApiKeyRow;
|
|
87
|
+
serviceAccounts: ServiceAccountOption[];
|
|
88
|
+
setApiKeyActiveAction: (id: string, isActive: boolean) => Promise<{
|
|
89
|
+
error?: string;
|
|
90
|
+
}>;
|
|
91
|
+
deleteApiKeyAction: (id: string) => Promise<{
|
|
92
|
+
error?: string;
|
|
93
|
+
}>;
|
|
94
|
+
updateApiKeyActingUserAction: (id: string, actingUserId: string | null) => Promise<{
|
|
95
|
+
error?: string;
|
|
96
|
+
}>;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/frontend/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;IAC/E,iBAAiB,EAAE,QAAQ;CAC5B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,YAAY,CAAC;AAEpD,MAAM,MAAM,eAAe,GACvB,YAAY,GACZ,gBAAgB,GAChB,QAAQ,GACR,UAAU,GACV,KAAK,GACL,UAAU,GACV,MAAM,GACN,OAAO,GACP,WAAW,GACX,MAAM,GACN,QAAQ,GACR,QAAQ,CAAC;AAEb,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAA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qBAAqB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,OAAO,CAAC;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtF,kBAAkB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,4BAA4B,EAAE,CAC5B,EAAE,EAAE,MAAM,EACV,YAAY,EAAE,MAAM,GAAG,IAAI,KACxB,OAAO,CAAC;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SCOPE_ACTIONS = exports.SCOPE_RESOURCES = void 0;
|
|
4
|
+
exports.SCOPE_RESOURCES = ['users', 'api-keys'];
|
|
5
|
+
exports.SCOPE_ACTIONS = ['read', 'write'];
|
|
6
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/frontend/types.ts"],"names":[],"mappings":";;;AA4Ea,QAAA,eAAe,GAAG,CAAC,OAAO,EAAE,UAAU,CAAU,CAAC;AACjD,QAAA,aAAa,GAAG,CAAC,MAAM,EAAE,OAAO,CAAU,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 3 frontend facet exports for `@haneinfo/m2m-api-key/frontend` (PL3-06).
|
|
3
|
+
*/
|
|
4
|
+
export interface M2mApiKeyFrontendContribution {
|
|
5
|
+
readonly kind: 'haneinfo.m2m-api-key.frontend';
|
|
6
|
+
}
|
|
7
|
+
export type { ApiKeyRoleOption, ApiKeyRoleRef, ApiKeyRow, ApiKeyRowActionsProps, ApiKeyScopeOption, ApiKeySortField, ApiKeysTableKey, ApiKeysTableProps, CreateApiKeyDialogProps, CreateApiKeyResponse, CreateApiKeyResult, CreatedApiKeyRevealProps, ServiceAccountOption, } from './frontend/index.js';
|
|
8
|
+
export { ApiKeyRowActions, ApiKeysTable, CreateApiKeyDialog, CreatedApiKeyReveal, SCOPE_ACTIONS, SCOPE_RESOURCES, } from './frontend/index.js';
|
|
9
|
+
//# sourceMappingURL=frontend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontend.d.ts","sourceRoot":"","sources":["../src/frontend.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,IAAI,EAAE,+BAA+B,CAAC;CAChD;AAED,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,eAAe,GAChB,MAAM,qBAAqB,CAAC"}
|
package/dist/frontend.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SCOPE_RESOURCES = exports.SCOPE_ACTIONS = exports.CreatedApiKeyReveal = exports.CreateApiKeyDialog = exports.ApiKeysTable = exports.ApiKeyRowActions = void 0;
|
|
4
|
+
// Named re-exports, not `export * from`: see frontend/index.ts for why -- a `for...in`-based
|
|
5
|
+
// re-export silently drops anything backed by an RSC client-reference proxy.
|
|
6
|
+
var index_js_1 = require("./frontend/index.js");
|
|
7
|
+
Object.defineProperty(exports, "ApiKeyRowActions", { enumerable: true, get: function () { return index_js_1.ApiKeyRowActions; } });
|
|
8
|
+
Object.defineProperty(exports, "ApiKeysTable", { enumerable: true, get: function () { return index_js_1.ApiKeysTable; } });
|
|
9
|
+
Object.defineProperty(exports, "CreateApiKeyDialog", { enumerable: true, get: function () { return index_js_1.CreateApiKeyDialog; } });
|
|
10
|
+
Object.defineProperty(exports, "CreatedApiKeyReveal", { enumerable: true, get: function () { return index_js_1.CreatedApiKeyReveal; } });
|
|
11
|
+
Object.defineProperty(exports, "SCOPE_ACTIONS", { enumerable: true, get: function () { return index_js_1.SCOPE_ACTIONS; } });
|
|
12
|
+
Object.defineProperty(exports, "SCOPE_RESOURCES", { enumerable: true, get: function () { return index_js_1.SCOPE_RESOURCES; } });
|
|
13
|
+
//# sourceMappingURL=frontend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontend.js","sourceRoot":"","sources":["../src/frontend.ts"],"names":[],"mappings":";;;AAsBA,6FAA6F;AAC7F,6EAA6E;AAC7E,gDAO6B;AAN3B,4GAAA,gBAAgB,OAAA;AAChB,wGAAA,YAAY,OAAA;AACZ,8GAAA,kBAAkB,OAAA;AAClB,+GAAA,mBAAmB,OAAA;AACnB,yGAAA,aAAa,OAAA;AACb,2GAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SystemAdminGuard } from '@haneinfo/plugin-host-nest';
|
|
2
|
+
/**
|
|
3
|
+
* API keys' name for the host's `SystemAdminGuard`. This file used to carry its own copy with a
|
|
4
|
+
* bare `'ADMIN'` literal — no shared constant, nothing to compare it against (Gate G1 review S9).
|
|
5
|
+
*/
|
|
6
|
+
export { SystemAdminGuard as ApiKeyAdminGuard };
|
|
7
|
+
//# sourceMappingURL=admin.guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.guard.d.ts","sourceRoot":"","sources":["../../src/guards/admin.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;;GAGG;AACH,OAAO,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiKeyAdminGuard = void 0;
|
|
4
|
+
const plugin_host_nest_1 = require("@haneinfo/plugin-host-nest");
|
|
5
|
+
Object.defineProperty(exports, "ApiKeyAdminGuard", { enumerable: true, get: function () { return plugin_host_nest_1.SystemAdminGuard; } });
|
|
6
|
+
//# sourceMappingURL=admin.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.guard.js","sourceRoot":"","sources":["../../src/guards/admin.guard.ts"],"names":[],"mappings":";;;AAAA,iEAA8D;AAMjC,iGANpB,mCAAgB,OAMoB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether `grantedScopes` (an API key's scopes, or an MCP call context's scopes) satisfy
|
|
4
|
+
* `requiredScope`. Shared between this guard and `@haneinfo/mcp-server`'s tool registry, which
|
|
5
|
+
* has the same `module:action` scope shape and the same "*" wildcard convention.
|
|
6
|
+
*/
|
|
7
|
+
export declare function matchScope(grantedScopes: string[], requiredScope: string): boolean;
|
|
8
|
+
export declare class ScopeGuard implements CanActivate {
|
|
9
|
+
canActivate(ctx: ExecutionContext): boolean;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=scope.guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.guard.d.ts","sourceRoot":"","sources":["../../src/guards/scope.guard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAkC,MAAM,gBAAgB,CAAC;AAG/F;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAElF;AAED,qBACa,UAAW,YAAW,WAAW;IAC5C,WAAW,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO;CAkC5C"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ScopeGuard = void 0;
|
|
10
|
+
exports.matchScope = matchScope;
|
|
11
|
+
const plugin_api_1 = require("@haneinfo/plugin-api");
|
|
12
|
+
const common_1 = require("@nestjs/common");
|
|
13
|
+
const scopes_decorator_1 = require("../decorators/scopes.decorator");
|
|
14
|
+
/**
|
|
15
|
+
* Checks whether `grantedScopes` (an API key's scopes, or an MCP call context's scopes) satisfy
|
|
16
|
+
* `requiredScope`. Shared between this guard and `@haneinfo/mcp-server`'s tool registry, which
|
|
17
|
+
* has the same `module:action` scope shape and the same "*" wildcard convention.
|
|
18
|
+
*/
|
|
19
|
+
function matchScope(grantedScopes, requiredScope) {
|
|
20
|
+
return (0, plugin_api_1.matchScope)(grantedScopes, requiredScope);
|
|
21
|
+
}
|
|
22
|
+
let ScopeGuard = class ScopeGuard {
|
|
23
|
+
canActivate(ctx) {
|
|
24
|
+
// Use Reflect.getMetadata directly to avoid injecting Reflector across package boundaries.
|
|
25
|
+
// Handler metadata takes priority over class metadata (same as Reflector.getAllAndOverride).
|
|
26
|
+
const required = Reflect.getMetadata(scopes_decorator_1.SCOPES_KEY, ctx.getHandler()) ??
|
|
27
|
+
Reflect.getMetadata(scopes_decorator_1.SCOPES_KEY, ctx.getClass());
|
|
28
|
+
const { user } = ctx.switchToHttp().getRequest();
|
|
29
|
+
// JWT users are not scope-restricted — scopes are an API-key-only mechanism, and a JWT
|
|
30
|
+
// principal's authorization is decided by AdminGuard/PermissionGuard instead.
|
|
31
|
+
if (!user?.isApiKey)
|
|
32
|
+
return true;
|
|
33
|
+
// FAIL CLOSED for API-key principals: no @Scopes() reachable on the handler *or* the
|
|
34
|
+
// controller class means the route never declared what an API key is allowed to do
|
|
35
|
+
// there. Previously this returned true, so adding a handler to a ScopeGuard-protected
|
|
36
|
+
// controller without a @Scopes() decorator silently granted every API key full access to
|
|
37
|
+
// it. An intentionally scope-free M2M route must now say so explicitly with
|
|
38
|
+
// `@Scopes('*')`.
|
|
39
|
+
if (!required?.length) {
|
|
40
|
+
throw new common_1.ForbiddenException('This route declares no API key scopes; API key access is denied by default');
|
|
41
|
+
}
|
|
42
|
+
const granted = user.scopes ?? [];
|
|
43
|
+
const allowed = required.every((req) => matchScope(granted, req));
|
|
44
|
+
if (!allowed)
|
|
45
|
+
throw new common_1.ForbiddenException('Insufficient API key scopes');
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.ScopeGuard = ScopeGuard;
|
|
50
|
+
exports.ScopeGuard = ScopeGuard = __decorate([
|
|
51
|
+
(0, common_1.Injectable)()
|
|
52
|
+
], ScopeGuard);
|
|
53
|
+
//# sourceMappingURL=scope.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.guard.js","sourceRoot":"","sources":["../../src/guards/scope.guard.ts"],"names":[],"mappings":";;;;;;;;;AASA,gCAEC;AAXD,qDAAwE;AACxE,2CAA+F;AAC/F,qEAA4D;AAE5D;;;;GAIG;AACH,SAAgB,UAAU,CAAC,aAAuB,EAAE,aAAqB;IAC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-key-rate-limiter';
|
|
4
|
+
export * from './api-keys.controller';
|
|
5
|
+
export * from './api-keys.module';
|
|
6
|
+
export * from './api-keys.service';
|
|
7
|
+
export * from './decorators/scopes.decorator';
|
|
8
|
+
export * from './dto/api-key.dto';
|
|
9
|
+
export * from './guards/admin.guard';
|
|
10
|
+
export * from './guards/scope.guard';
|
|
11
|
+
export * from './scope-matcher.service';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,iBAAiB,CAAC;AAGhC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,+BAA+B,CAAC;AAE9C,cAAc,mBAAmB,CAAC;AAElC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Module
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
__exportStar(require("./api-key.guard"), exports);
|
|
19
|
+
// Strategy & Service / Controller
|
|
20
|
+
__exportStar(require("./api-key-machine.strategy"), exports);
|
|
21
|
+
__exportStar(require("./api-key-rate-limiter"), exports);
|
|
22
|
+
__exportStar(require("./api-keys.controller"), exports);
|
|
23
|
+
__exportStar(require("./api-keys.module"), exports);
|
|
24
|
+
__exportStar(require("./api-keys.service"), exports);
|
|
25
|
+
// Decorators
|
|
26
|
+
__exportStar(require("./decorators/scopes.decorator"), exports);
|
|
27
|
+
// Dto
|
|
28
|
+
__exportStar(require("./dto/api-key.dto"), exports);
|
|
29
|
+
// Guards
|
|
30
|
+
__exportStar(require("./guards/admin.guard"), exports);
|
|
31
|
+
__exportStar(require("./guards/scope.guard"), exports);
|
|
32
|
+
__exportStar(require("./scope-matcher.service"), exports);
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,SAAS;;;;;;;;;;;;;;;;AAET,kDAAgC;AAEhC,kCAAkC;AAClC,6DAA2C;AAC3C,yDAAuC;AACvC,wDAAsC;AACtC,oDAAkC;AAClC,qDAAmC;AACnC,aAAa;AACb,gEAA8C;AAC9C,MAAM;AACN,oDAAkC;AAClC,SAAS;AACT,uDAAqC;AACrC,uDAAqC;AACrC,0DAAwC"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@haneinfo/m2m-api-key/plugin` — manifest and plugin descriptor (PL3-06, PL4-03).
|
|
3
|
+
*/
|
|
4
|
+
import { type PluginManifestV1, SCOPE_MATCHER, type ScopeMatcherPort } from '@haneinfo/plugin-api';
|
|
5
|
+
import { ApiKeyMachineStrategy } from './api-key-machine.strategy';
|
|
6
|
+
import { ApiKeysModule } from './api-keys.module';
|
|
7
|
+
import { matchScope } from './guards/scope.guard';
|
|
8
|
+
import { ScopeMatcherService } from './scope-matcher.service';
|
|
9
|
+
export { ApiKeyMachineStrategy, matchScope, SCOPE_MATCHER, type ScopeMatcherPort, ScopeMatcherService, };
|
|
10
|
+
/** SHA-256 of `prisma/api-key.prisma` with LF endings. */
|
|
11
|
+
export declare const M2M_API_KEY_SCHEMA_DIGEST = "sha256:374b3ec85889c1d51f7510319db99571b97b61a3dfa75d987bb5df467daf7d92";
|
|
12
|
+
/** Mirrors `haneinfo.plugin.json`. */
|
|
13
|
+
export declare const m2mApiKeyManifest: PluginManifestV1;
|
|
14
|
+
export declare const m2mApiKeyPlugin: import("@haneinfo/plugin-api").DefinedPlugin<unknown, typeof ApiKeysModule>;
|
|
15
|
+
export declare function m2mApiKey(): import("@haneinfo/plugin-api").DefinedPlugin<unknown, typeof ApiKeysModule>;
|
|
16
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAEL,KAAK,gBAAgB,EACrB,aAAa,EACb,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,aAAa,EACb,KAAK,gBAAgB,EACrB,mBAAmB,GACpB,CAAC;AAEF,0DAA0D;AAC1D,eAAO,MAAM,yBAAyB,4EACqC,CAAC;AAE5E,sCAAsC;AACtC,eAAO,MAAM,iBAAiB,EAAE,gBAiF/B,CAAC;AAEF,eAAO,MAAM,eAAe,6EAG1B,CAAC;AAEH,wBAAgB,SAAS,gFAExB"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `@haneinfo/m2m-api-key/plugin` — manifest and plugin descriptor (PL3-06, PL4-03).
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.m2mApiKeyPlugin = exports.m2mApiKeyManifest = exports.M2M_API_KEY_SCHEMA_DIGEST = exports.ScopeMatcherService = exports.SCOPE_MATCHER = exports.matchScope = exports.ApiKeyMachineStrategy = void 0;
|
|
7
|
+
exports.m2mApiKey = m2mApiKey;
|
|
8
|
+
const plugin_api_1 = require("@haneinfo/plugin-api");
|
|
9
|
+
Object.defineProperty(exports, "SCOPE_MATCHER", { enumerable: true, get: function () { return plugin_api_1.SCOPE_MATCHER; } });
|
|
10
|
+
const api_key_machine_strategy_1 = require("./api-key-machine.strategy");
|
|
11
|
+
Object.defineProperty(exports, "ApiKeyMachineStrategy", { enumerable: true, get: function () { return api_key_machine_strategy_1.ApiKeyMachineStrategy; } });
|
|
12
|
+
const api_keys_module_1 = require("./api-keys.module");
|
|
13
|
+
const scope_guard_1 = require("./guards/scope.guard");
|
|
14
|
+
Object.defineProperty(exports, "matchScope", { enumerable: true, get: function () { return scope_guard_1.matchScope; } });
|
|
15
|
+
const scope_matcher_service_1 = require("./scope-matcher.service");
|
|
16
|
+
Object.defineProperty(exports, "ScopeMatcherService", { enumerable: true, get: function () { return scope_matcher_service_1.ScopeMatcherService; } });
|
|
17
|
+
/** SHA-256 of `prisma/api-key.prisma` with LF endings. */
|
|
18
|
+
exports.M2M_API_KEY_SCHEMA_DIGEST = 'sha256:374b3ec85889c1d51f7510319db99571b97b61a3dfa75d987bb5df467daf7d92';
|
|
19
|
+
/** Mirrors `haneinfo.plugin.json`. */
|
|
20
|
+
exports.m2mApiKeyManifest = {
|
|
21
|
+
schemaVersion: 'haneinfo.plugin/v1',
|
|
22
|
+
id: 'm2m-api-key',
|
|
23
|
+
displayName: 'Machine-to-Machine API Keys',
|
|
24
|
+
cardinality: 'singleton',
|
|
25
|
+
distribution: 'official',
|
|
26
|
+
engine: {
|
|
27
|
+
haneinfoPluginApi: '^1.0.0',
|
|
28
|
+
node: '>=22.0.0',
|
|
29
|
+
frameworks: {
|
|
30
|
+
'@nestjs/common': '^11.0.5',
|
|
31
|
+
'@nestjs/core': '^11.0.5',
|
|
32
|
+
'@prisma/client': '^6.2.0',
|
|
33
|
+
'lucide-react': '^1.22.0',
|
|
34
|
+
react: '^19.0.0',
|
|
35
|
+
'react-dom': '^19.0.0',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
provides: ['haneinfo.machine-auth-provider', 'haneinfo.scope-matcher'],
|
|
39
|
+
requires: [
|
|
40
|
+
'haneinfo.identity-store',
|
|
41
|
+
'haneinfo.prisma',
|
|
42
|
+
'haneinfo.principal-context',
|
|
43
|
+
'haneinfo.authentication-strategy-registry',
|
|
44
|
+
],
|
|
45
|
+
optionalRequires: ['haneinfo.audit-sink', 'haneinfo.rbac-policy'],
|
|
46
|
+
facets: {
|
|
47
|
+
backend: {
|
|
48
|
+
modulePath: './dist/api-keys.module.js',
|
|
49
|
+
exportName: 'ApiKeysModule',
|
|
50
|
+
controllerRoutes: ['api-keys'],
|
|
51
|
+
providerTokens: ['haneinfo.scope-matcher'],
|
|
52
|
+
},
|
|
53
|
+
frontend: {
|
|
54
|
+
adminPages: [
|
|
55
|
+
{
|
|
56
|
+
id: 'api-keys',
|
|
57
|
+
routePath: '/dashboard/api-keys',
|
|
58
|
+
title: 'apiKeys',
|
|
59
|
+
componentExport: 'ApiKeysTable',
|
|
60
|
+
requiredPermission: 'm2m:api-key:read',
|
|
61
|
+
order: 30,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
navigationItems: [
|
|
65
|
+
{
|
|
66
|
+
id: 'api-keys',
|
|
67
|
+
title: 'apiKeys',
|
|
68
|
+
href: '/dashboard/api-keys',
|
|
69
|
+
icon: 'Key',
|
|
70
|
+
order: 30,
|
|
71
|
+
section: 'admin',
|
|
72
|
+
requiredPermission: 'm2m:api-key:read',
|
|
73
|
+
after: 'roles',
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
i18nNamespace: 'apiKeys',
|
|
77
|
+
clientEntry: './dist/frontend.js',
|
|
78
|
+
},
|
|
79
|
+
prisma: {
|
|
80
|
+
owns: ['ApiKey'],
|
|
81
|
+
augments: [
|
|
82
|
+
{
|
|
83
|
+
targetModel: 'User',
|
|
84
|
+
field: 'actingApiKeys',
|
|
85
|
+
owner: 'identity-core',
|
|
86
|
+
type: 'ApiKey[] @relation("ApiKeyActingUser")',
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
schemaFragment: 'prisma/api-key.prisma',
|
|
90
|
+
schemaDigest: exports.M2M_API_KEY_SCHEMA_DIGEST,
|
|
91
|
+
},
|
|
92
|
+
permissions: {
|
|
93
|
+
definitions: [
|
|
94
|
+
'm2m:api-key:create',
|
|
95
|
+
'm2m:api-key:update',
|
|
96
|
+
'm2m:api-key:delete',
|
|
97
|
+
'm2m:api-key:read',
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
exports.m2mApiKeyPlugin = (0, plugin_api_1.definePlugin)({
|
|
103
|
+
manifest: exports.m2mApiKeyManifest,
|
|
104
|
+
backend: () => api_keys_module_1.ApiKeysModule,
|
|
105
|
+
});
|
|
106
|
+
function m2mApiKey() {
|
|
107
|
+
return exports.m2mApiKeyPlugin;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";AAAA;;GAE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AE,EAAE;iBACV;aACF;YACD,eAAe,EAAE;gBACf;oBACE,EAAE,EAAE,UAAU;oBACd,KAAK,EAAE,SAAS;oBAChB,IAAI,EAAE,qBAAqB;oBAC3B,IAAI,EAAE,KAAK;oBACX,KAAK,EAAE,EAAE;oBACT,OAAO,EAAE,OAAO;oBAChB,kBAAkB,EAAE,kBAAkB;oBACtC,KAAK,EAAE,OAAO;iBACf;aACF;YACD,aAAa,EAAE,SAAS;YACxB,WAAW,EAAE,oBAAoB;SAClC;QACD,MAAM,EAAE;YACN,IAAI,EAAE,CAAC,QAAQ,CAAC;YAChB,QAAQ,EAAE;gBACR;oBACE,WAAW,EAAE,MAAM;oBACnB,KAAK,EAAE,eAAe;oBACtB,KAAK,EAAE,eAAe;oBACtB,IAAI,EAAE,wCAAwC;iBAC/C;aACF;YACD,cAAc,EAAE,uBAAuB;YACvC,YAAY,EAAE,iCAAyB;SACxC;QACD,WAAW,EAAE;YACX,WAAW,EAAE;gBACX,oBAAoB;gBACpB,oBAAoB;gBACpB,oBAAoB;gBACpB,kBAAkB;aACnB;SACF;KACF;CACF,CAAC;AAEW,QAAA,eAAe,GAAG,IAAA,yBAAY,EAAC;IAC1C,QAAQ,EAAE,yBAAiB;IAC3B,OAAO,EAAE,GAAG,EAAE,CAAC,+BAAa;CAC7B,CAAC,CAAC;AAEH,SAAgB,SAAS;IACvB,OAAO,uBAAe,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ScopeMatcherPort } from '@haneinfo/plugin-api';
|
|
2
|
+
/**
|
|
3
|
+
* `haneinfo.scope-matcher` capability service (051 PL4-03).
|
|
4
|
+
*
|
|
5
|
+
* Implements the minimal `ScopeMatcherPort` contract so other capabilities (such as
|
|
6
|
+
* `@haneinfo/metadata-schema` or `@haneinfo/mcp-server`) can inject `SCOPE_MATCHER`
|
|
7
|
+
* without directly depending on `@haneinfo/m2m-api-key`'s guards or controllers.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ScopeMatcherService implements ScopeMatcherPort {
|
|
10
|
+
matches(scopes: string[], required: string): boolean;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=scope-matcher.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-matcher.service.d.ts","sourceRoot":"","sources":["../src/scope-matcher.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAI7D;;;;;;GAMG;AACH,qBACa,mBAAoB,YAAW,gBAAgB;IAC1D,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;CAGrD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ScopeMatcherService = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const scope_guard_1 = require("./guards/scope.guard");
|
|
12
|
+
/**
|
|
13
|
+
* `haneinfo.scope-matcher` capability service (051 PL4-03).
|
|
14
|
+
*
|
|
15
|
+
* Implements the minimal `ScopeMatcherPort` contract so other capabilities (such as
|
|
16
|
+
* `@haneinfo/metadata-schema` or `@haneinfo/mcp-server`) can inject `SCOPE_MATCHER`
|
|
17
|
+
* without directly depending on `@haneinfo/m2m-api-key`'s guards or controllers.
|
|
18
|
+
*/
|
|
19
|
+
let ScopeMatcherService = class ScopeMatcherService {
|
|
20
|
+
matches(scopes, required) {
|
|
21
|
+
return (0, scope_guard_1.matchScope)(scopes, required);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.ScopeMatcherService = ScopeMatcherService;
|
|
25
|
+
exports.ScopeMatcherService = ScopeMatcherService = __decorate([
|
|
26
|
+
(0, common_1.Injectable)()
|
|
27
|
+
], ScopeMatcherService);
|
|
28
|
+
//# sourceMappingURL=scope-matcher.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-matcher.service.js","sourceRoot":"","sources":["../src/scope-matcher.service.ts"],"names":[],"mappings":";;;;;;;;;AACA,2CAA4C;AAC5C,sDAAkD;AAElD;;;;;;GAMG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,OAAO,CAAC,MAAgB,EAAE,QAAgB;QACxC,OAAO,IAAA,wBAAU,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC;CACF,CAAA;AAJY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;GACA,mBAAmB,CAI/B"}
|