@kinotic-ai/core 5.0.0-beta.23 → 5.0.0-beta.25
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/dist/index.cjs +4 -34
- package/dist/index.d.cts +4 -132
- package/dist/index.d.ts +4 -132
- package/dist/index.js +4 -34
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -69,7 +69,6 @@ __export(exports_src, {
|
|
|
69
69
|
scopeOptionalMethodNames: () => scopeOptionalMethodNames,
|
|
70
70
|
receivesContext: () => receivesContext,
|
|
71
71
|
isAdvertised: () => isAdvertised,
|
|
72
|
-
declaresAuthz: () => declaresAuthz,
|
|
73
72
|
declareServiceDefinitions: () => declareServiceDefinitions,
|
|
74
73
|
createCRI: () => createCRI,
|
|
75
74
|
buildServerUrl: () => buildServerUrl,
|
|
@@ -111,9 +110,6 @@ __export(exports_src, {
|
|
|
111
110
|
ChainedCredentialsResolver: () => ChainedCredentialsResolver,
|
|
112
111
|
BearerCredentialsResolver: () => BearerCredentialsResolver,
|
|
113
112
|
BasicCredentialsResolver: () => BasicCredentialsResolver,
|
|
114
|
-
AuthzUnchecked: () => AuthzUnchecked,
|
|
115
|
-
AuthzResource: () => AuthzResource,
|
|
116
|
-
AuthzCheck: () => AuthzCheck,
|
|
117
113
|
AuthorizationException: () => AuthorizationException,
|
|
118
114
|
AbstractIterablePage: () => AbstractIterablePage
|
|
119
115
|
});
|
|
@@ -129,7 +125,7 @@ function buildServerUrl(server, scheme) {
|
|
|
129
125
|
return scheme + (server.useSSL ? "s" : "") + "://" + server.host + (server.port ? ":" + server.port : "");
|
|
130
126
|
}
|
|
131
127
|
function buildBrokerUrl(server) {
|
|
132
|
-
return buildServerUrl(server, "ws") + "/v1";
|
|
128
|
+
return buildServerUrl(server, "ws") + "/api/v1";
|
|
133
129
|
}
|
|
134
130
|
var SessionKeepAliveMode;
|
|
135
131
|
((SessionKeepAliveMode2) => {
|
|
@@ -1185,8 +1181,6 @@ var versionRegistry = new WeakMap;
|
|
|
1185
1181
|
var zonesRegistry = new WeakMap;
|
|
1186
1182
|
var advertisedRegistry = new WeakMap;
|
|
1187
1183
|
var contextMarkedFunctions = new WeakSet;
|
|
1188
|
-
var authzResourceClasses = new WeakSet;
|
|
1189
|
-
var authzUncheckedClasses = new WeakSet;
|
|
1190
1184
|
function findInConstructorChain(registry, constructor) {
|
|
1191
1185
|
let current = constructor;
|
|
1192
1186
|
while (current) {
|
|
@@ -1277,28 +1271,6 @@ function resolveEffectiveZone(constructor) {
|
|
|
1277
1271
|
}
|
|
1278
1272
|
return effectiveZone;
|
|
1279
1273
|
}
|
|
1280
|
-
function AuthzResource(declaration) {
|
|
1281
|
-
return function(value, _context) {
|
|
1282
|
-
authzResourceClasses.add(value);
|
|
1283
|
-
};
|
|
1284
|
-
}
|
|
1285
|
-
function AuthzCheck(declaration) {
|
|
1286
|
-
return function(_value, _context) {};
|
|
1287
|
-
}
|
|
1288
|
-
function AuthzUnchecked(value, context2) {
|
|
1289
|
-
if (context2.kind === "class") {
|
|
1290
|
-
authzUncheckedClasses.add(value);
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
function declaresAuthz(serviceInstance) {
|
|
1294
|
-
let ret = false;
|
|
1295
|
-
let current = serviceInstance.constructor;
|
|
1296
|
-
while (current && !ret) {
|
|
1297
|
-
ret = authzResourceClasses.has(current) || authzUncheckedClasses.has(current);
|
|
1298
|
-
current = Object.getPrototypeOf(current);
|
|
1299
|
-
}
|
|
1300
|
-
return ret;
|
|
1301
|
-
}
|
|
1302
1274
|
function Publish(namespace, name, advertise = false) {
|
|
1303
1275
|
return function(value, _context) {
|
|
1304
1276
|
advertisedRegistry.set(value, advertise);
|
|
@@ -1326,7 +1298,7 @@ var import_api2 = __toESM(require("@opentelemetry/api"));
|
|
|
1326
1298
|
// packages/core/package.json
|
|
1327
1299
|
var package_default = {
|
|
1328
1300
|
name: "@kinotic-ai/core",
|
|
1329
|
-
version: "5.0.0-beta.
|
|
1301
|
+
version: "5.0.0-beta.25",
|
|
1330
1302
|
type: "module",
|
|
1331
1303
|
files: [
|
|
1332
1304
|
"dist"
|
|
@@ -1786,7 +1758,7 @@ class TextEventFactory {
|
|
|
1786
1758
|
return event;
|
|
1787
1759
|
}
|
|
1788
1760
|
}
|
|
1789
|
-
var
|
|
1761
|
+
var APPLICATION_SERVICE_DIRECTORY = "app-api~org.kinotic.app.api.services.ApplicationServiceDirectory";
|
|
1790
1762
|
var APPLICATION_ZONE = /^app\.[^.]+\.([^.]+)(\.|$)/;
|
|
1791
1763
|
var declaredDefinitions = new Map;
|
|
1792
1764
|
function declareServiceDefinitions(definitions) {
|
|
@@ -1830,8 +1802,6 @@ function directoryEntryOf(serviceInstance, serviceIdentifier) {
|
|
|
1830
1802
|
advertised: isAdvertised(serviceInstance),
|
|
1831
1803
|
serviceDefinition: definition
|
|
1832
1804
|
};
|
|
1833
|
-
} else if (declaresAuthz(serviceInstance)) {
|
|
1834
|
-
throw new Error(`${qualifiedName} declares a resource or is marked unchecked, but the project declares no definition for it;` + " run kinotic sync and import the generated ServiceDefinitions module");
|
|
1835
1805
|
}
|
|
1836
1806
|
}
|
|
1837
1807
|
return ret;
|
|
@@ -1891,7 +1861,7 @@ class ServiceRegistry {
|
|
|
1891
1861
|
}
|
|
1892
1862
|
async registerEntry(entry) {
|
|
1893
1863
|
this.debugLogger(`Registering ${entry.zone}~${qualifiedNameOf(entry.serviceDefinition.namespace, entry.serviceDefinition.name)} in the directory`);
|
|
1894
|
-
await this.serviceProxy(
|
|
1864
|
+
await this.serviceProxy(APPLICATION_SERVICE_DIRECTORY).invoke("register", [entry]);
|
|
1895
1865
|
}
|
|
1896
1866
|
registerContextInterceptor(interceptor) {
|
|
1897
1867
|
this.contextInterceptor = interceptor;
|
package/dist/index.d.cts
CHANGED
|
@@ -788,80 +788,6 @@ declare class KinoticSingleton implements IKinotic {
|
|
|
788
788
|
*/
|
|
789
789
|
declare const Kinotic: KinoticSingleton;
|
|
790
790
|
/**
|
|
791
|
-
* A role a service declares for its resource type beside the built-in `viewer`, `editor` and `admin`: a bundle
|
|
792
|
-
* of the type's own permissions, defined by the generated model, named like a built-in role and granted the
|
|
793
|
-
* same way.
|
|
794
|
-
*/
|
|
795
|
-
interface AuthzRoleDeclaration {
|
|
796
|
-
/** The role's id, `<type>.<level>`, with a lowercase identifier no built-in role of the type uses as the level. */
|
|
797
|
-
id: string;
|
|
798
|
-
/** The short names of the permissions the role bundles, each one a permission a function of the type needs. */
|
|
799
|
-
permissions: string[];
|
|
800
|
-
}
|
|
801
|
-
/**
|
|
802
|
-
* What a service declares about the resource its functions act on, as {@link AuthzResource} declares it.
|
|
803
|
-
*/
|
|
804
|
-
interface AuthzResourceDeclaration {
|
|
805
|
-
/**
|
|
806
|
-
* The resource type, a single lowercase identifier such as `report`: it names the type in the model, prefixes
|
|
807
|
-
* the type's permissions (`report_can_view`) and roles (`report.editor`), and is the type of the resource every
|
|
808
|
-
* function is checked on unless the function names another with {@link AuthzCheck}.
|
|
809
|
-
*/
|
|
810
|
-
value: string;
|
|
811
|
-
/**
|
|
812
|
-
* The type that contains this one, such as `tenant` for `report`: a grant made on a resource of the parent type
|
|
813
|
-
* inherits to every resource of this type inside it, and a function naming no resource of its own, such as a
|
|
814
|
-
* listing or a create, is checked on the parent. Absent for a root type.
|
|
815
|
-
*/
|
|
816
|
-
parent?: string | null;
|
|
817
|
-
/**
|
|
818
|
-
* The resource every function of the service is checked on, for a service whose functions act on one resource
|
|
819
|
-
* the request does not name: a template over the caller's scope, `{@applicationId}` or `{@tenantId}`, or a literal
|
|
820
|
-
* id. A function naming its own resource with {@link AuthzCheck} is unaffected.
|
|
821
|
-
*/
|
|
822
|
-
resourceId?: string | null;
|
|
823
|
-
/**
|
|
824
|
-
* The permission every function of the service needs, as a short name such as `can_manage`, for a service whose
|
|
825
|
-
* functions all need the one permission whatever their names. A function declaring a permission of its own with
|
|
826
|
-
* {@link AuthzCheck} keeps it. Name the service's strictest permission.
|
|
827
|
-
*/
|
|
828
|
-
permission?: string | null;
|
|
829
|
-
/** Roles of this type beside the built-in ones, each bundling permissions the type's functions need. */
|
|
830
|
-
roles?: AuthzRoleDeclaration[] | null;
|
|
831
|
-
}
|
|
832
|
-
/**
|
|
833
|
-
* What a function declares about its check, as {@link AuthzCheck} declares it; whatever is left out is derived
|
|
834
|
-
* from the function's name and parameters, as described on {@link AuthzResource}.
|
|
835
|
-
*/
|
|
836
|
-
interface AuthzCheckDeclaration {
|
|
837
|
-
/**
|
|
838
|
-
* The permission the function needs, as a short name such as `can_generate`. In the model it is prefixed by
|
|
839
|
-
* the type it is about, so `can_generate` on a `report` service is `report_can_generate`.
|
|
840
|
-
*/
|
|
841
|
-
permission?: string | null;
|
|
842
|
-
/**
|
|
843
|
-
* The type of the resource the check is made on, when it is not the service's own type, such as the parent for a
|
|
844
|
-
* create. A type name, never a template.
|
|
845
|
-
*/
|
|
846
|
-
resource?: string | null;
|
|
847
|
-
/**
|
|
848
|
-
* The id of the resource the check is made on, as a template over the function's parameters and the caller's
|
|
849
|
-
* scope: `{reportId}` is a parameter's value, `{registration.id}` a property of an object parameter, and
|
|
850
|
-
* `{@applicationId}` or `{@tenantId}` the matching id of the caller's scope.
|
|
851
|
-
*/
|
|
852
|
-
resourceId?: string | null;
|
|
853
|
-
/**
|
|
854
|
-
* Short names of permissions on the same type that this permission also grants, so a role bundling
|
|
855
|
-
* `can_generate` declared with `implies: ['can_view']` views what it generates.
|
|
856
|
-
*/
|
|
857
|
-
implies?: string[] | null;
|
|
858
|
-
/**
|
|
859
|
-
* True for a function whose check must not be answered from the engine's caches, because a stale allow would
|
|
860
|
-
* be a security event.
|
|
861
|
-
*/
|
|
862
|
-
consistent?: boolean;
|
|
863
|
-
}
|
|
864
|
-
/**
|
|
865
791
|
* Marks the getter or method that provides the service's scope, which targets requests at one
|
|
866
792
|
* specific instance of the service, such as the copy running on a particular node. It is
|
|
867
793
|
* invoked on each instance when the instance registers with the ServiceRegistry.
|
|
@@ -913,59 +839,6 @@ declare function Context(value: Function, _context: ClassMethodDecoratorContext)
|
|
|
913
839
|
*/
|
|
914
840
|
declare function receivesContext(serviceInstance: object, methodName: string): boolean;
|
|
915
841
|
/**
|
|
916
|
-
* Marks a published service as acting on one type of resource, which `kinotic sync` reads from the class's
|
|
917
|
-
* source into the service's definition, which the runtime registers in the platform's service directory when
|
|
918
|
-
* the service comes online, so every request to the service is authorized before the service sees it. The type
|
|
919
|
-
* and the permissions its functions need become part of the application's authorization model, where roles
|
|
920
|
-
* bundle permissions and grants bind roles to callers.
|
|
921
|
-
*
|
|
922
|
-
* A function's check has three parts: the permission it needs, the type of the resource it is checked on, and
|
|
923
|
-
* the id of that resource. Each part is derived from the function's name and parameters where it can be;
|
|
924
|
-
* {@link AuthzCheck} states a part derivation gets wrong or cannot know, and {@link AuthzUnchecked} marks a
|
|
925
|
-
* function served with no check. A function left with no check and no marker fails the service's registration.
|
|
926
|
-
*
|
|
927
|
-
* The permission is derived from the first word of the function's name: `find`, `get`, `count`, `search` and
|
|
928
|
-
* `list` need `can_view`; `save`, `update` and `set` need `can_edit`; `delete` and `remove` need `can_delete`;
|
|
929
|
-
* `create` needs `can_edit` of this type on the parent. The resource's id is the parameter named `id` or
|
|
930
|
-
* `<type>Id` (`reportId` for the type `report`), else the `id` of the first object parameter; a function with
|
|
931
|
-
* neither is checked on the parent, whose id is found the same way with the parent's name, else on the caller's
|
|
932
|
-
* own scope.
|
|
933
|
-
*
|
|
934
|
-
* Example: with `@AuthzResource({value: 'report', parent: 'tenant'})`, `findById(id: string)` is checked for
|
|
935
|
-
* `report_can_view` on the report `id` names, `save(report: Report)` for `report_can_edit` on the report
|
|
936
|
-
* `report.id` names, and `findReports()` for `report_can_view` on the caller's tenant, with nothing declared on
|
|
937
|
-
* them. A runtime holding no definition for a service declaring a resource refuses to serve it.
|
|
938
|
-
* @param declaration the resource type, or the type with its parent, resource id, permission and roles
|
|
939
|
-
*/
|
|
940
|
-
declare function AuthzResource(declaration: AuthzResourceDeclaration | string): (value: Function, _context: ClassDecoratorContext<any>) => void;
|
|
941
|
-
/**
|
|
942
|
-
* States a part of one function's check that derivation gets wrong or cannot know, which `kinotic sync` reads
|
|
943
|
-
* into the service's definition: the permission, the type of the resource, or its id. Every part left out keeps
|
|
944
|
-
* the derived value, or the one the service declares with {@link AuthzResource}, so a function states only the
|
|
945
|
-
* part derivation misses. A function served with no check is marked {@link AuthzUnchecked} instead.
|
|
946
|
-
*
|
|
947
|
-
* Example: `@AuthzCheck({permission: 'can_report', resourceId: '{registration.id}'})` on
|
|
948
|
-
* `heartbeat(registration: Registration)`, whose name derives no permission and whose id is inside the body.
|
|
949
|
-
* @param declaration the parts of the check derivation cannot read from the function's name and parameters
|
|
950
|
-
*/
|
|
951
|
-
declare function AuthzCheck(declaration: AuthzCheckDeclaration): (_value: Function, _context: ClassMethodDecoratorContext) => void;
|
|
952
|
-
/**
|
|
953
|
-
* Marks a function of an {@link AuthzResource} service, or a whole class declaring no resource, as served with
|
|
954
|
-
* no authorization check, which `kinotic sync` reads into the service's definition: any caller the service's
|
|
955
|
-
* zone admits may call it, and the service itself is responsible for answering only what the caller may see or
|
|
956
|
-
* do. It is for a function that has no resource to check, such as a listing of the caller's own grants, and for a
|
|
957
|
-
* service whose every function answers for the caller alone. The mark is the only way a function is served
|
|
958
|
-
* unchecked: a function the definition neither checks nor marks is refused. A function carrying this and
|
|
959
|
-
* {@link AuthzCheck} fails the service's registration, as does a class carrying this and {@link AuthzResource}.
|
|
960
|
-
*/
|
|
961
|
-
declare function AuthzUnchecked(value: Function, context: ClassDecoratorContext<any> | ClassMethodDecoratorContext): void;
|
|
962
|
-
/**
|
|
963
|
-
* Returns whether the given service instance's class, or a class it extends, declares an {@link AuthzResource} or
|
|
964
|
-
* is marked {@link AuthzUnchecked}: either way the service's definition carries what the platform serves it by.
|
|
965
|
-
* @param serviceInstance the service instance to inspect
|
|
966
|
-
*/
|
|
967
|
-
declare function declaresAuthz(serviceInstance: object): boolean;
|
|
968
|
-
/**
|
|
969
842
|
* Registers each instance of the decorated class with the Kinotic ServiceRegistry.
|
|
970
843
|
* The service name defaults to the class name; {@link Version}, {@link Scope}, and {@link Zone}
|
|
971
844
|
* on the same class refine the registration.
|
|
@@ -978,9 +851,8 @@ declare function Publish(namespace?: string | null, name?: string, advertise?: b
|
|
|
978
851
|
import { ServiceDefinition as ServiceDefinition2 } from "@kinotic-ai/idl";
|
|
979
852
|
/**
|
|
980
853
|
* A service of an application as its runtime registers it in the platform's service directory: the application
|
|
981
|
-
* it belongs to, where it is addressed, whether it is advertised, and its definition
|
|
982
|
-
*
|
|
983
|
-
* functions declare, and the service's liveness.
|
|
854
|
+
* it belongs to, where it is addressed, whether it is advertised, and its definition. The platform owns
|
|
855
|
+
* everything else about the directory's entry, such as the service's liveness.
|
|
984
856
|
*/
|
|
985
857
|
interface ServiceDirectoryEntry {
|
|
986
858
|
/**
|
|
@@ -1000,7 +872,7 @@ interface ServiceDirectoryEntry {
|
|
|
1000
872
|
*/
|
|
1001
873
|
advertised: boolean;
|
|
1002
874
|
/**
|
|
1003
|
-
* The service's definition: its functions,
|
|
875
|
+
* The service's definition: its functions, with the parameters a request carries and what each returns.
|
|
1004
876
|
*/
|
|
1005
877
|
serviceDefinition: ServiceDefinition2;
|
|
1006
878
|
}
|
|
@@ -1601,4 +1473,4 @@ declare class ParticipantConstants {
|
|
|
1601
1473
|
/** The clientId the test server's TestSecurityService maps to the ANONYMOUS role in core package tests. */
|
|
1602
1474
|
static readonly CLI_PARTICIPANT_ID: string;
|
|
1603
1475
|
}
|
|
1604
|
-
export { validateZone, validateLabel, scopeOptionalMethodNames, receivesContext, isAdvertised,
|
|
1476
|
+
export { validateZone, validateLabel, scopeOptionalMethodNames, receivesContext, isAdvertised, declareServiceDefinitions, createCRI, buildServerUrl, buildBrokerUrl, Zone, WebSocketFactory, Version, TextEventFactory, Sort, SessionKeepAliveMode, SessionCredentialsResolver, ServiceRegistry, ServiceIdentifier, ServiceDirectoryEntry, ServiceContext, ServerInfo, ScopeOptional, Scope, RpcError, ResolvedCredentials, Publish, ParticipantConstants, Participant, Pageable, Page, Order, OffsetPageable, NullHandling, KinoticSingleton, KinoticPlugin, Kinotic, JsonEventFactory, IterablePage, Identifiable, IWebSocket, IServiceRegistry, IServiceProxy, IParticipant, IKinotic, IEventFactory, IEventBus, IEvent, IEditableDataSource, IDataSource, ICrudServiceProxyFactory, ICrudServiceProxy, FunctionalIterablePage, EventConstants, EventBus, Event, EnvCredentialsResolver, Direction, DefaultCRI, DataSourceUtils, CursorPageable, CrudServiceProxyFactory, CrudServiceProxy, CredentialsResolver, ContextInterceptor, Context, ConnectedInfo, ConnectOptions, ChainedCredentialsResolver, CRI, BearerCredentialsResolver, BasicCredentialsResolver, AuthorizationException, AbstractIterablePage };
|
package/dist/index.d.ts
CHANGED
|
@@ -788,80 +788,6 @@ declare class KinoticSingleton implements IKinotic {
|
|
|
788
788
|
*/
|
|
789
789
|
declare const Kinotic: KinoticSingleton;
|
|
790
790
|
/**
|
|
791
|
-
* A role a service declares for its resource type beside the built-in `viewer`, `editor` and `admin`: a bundle
|
|
792
|
-
* of the type's own permissions, defined by the generated model, named like a built-in role and granted the
|
|
793
|
-
* same way.
|
|
794
|
-
*/
|
|
795
|
-
interface AuthzRoleDeclaration {
|
|
796
|
-
/** The role's id, `<type>.<level>`, with a lowercase identifier no built-in role of the type uses as the level. */
|
|
797
|
-
id: string;
|
|
798
|
-
/** The short names of the permissions the role bundles, each one a permission a function of the type needs. */
|
|
799
|
-
permissions: string[];
|
|
800
|
-
}
|
|
801
|
-
/**
|
|
802
|
-
* What a service declares about the resource its functions act on, as {@link AuthzResource} declares it.
|
|
803
|
-
*/
|
|
804
|
-
interface AuthzResourceDeclaration {
|
|
805
|
-
/**
|
|
806
|
-
* The resource type, a single lowercase identifier such as `report`: it names the type in the model, prefixes
|
|
807
|
-
* the type's permissions (`report_can_view`) and roles (`report.editor`), and is the type of the resource every
|
|
808
|
-
* function is checked on unless the function names another with {@link AuthzCheck}.
|
|
809
|
-
*/
|
|
810
|
-
value: string;
|
|
811
|
-
/**
|
|
812
|
-
* The type that contains this one, such as `tenant` for `report`: a grant made on a resource of the parent type
|
|
813
|
-
* inherits to every resource of this type inside it, and a function naming no resource of its own, such as a
|
|
814
|
-
* listing or a create, is checked on the parent. Absent for a root type.
|
|
815
|
-
*/
|
|
816
|
-
parent?: string | null;
|
|
817
|
-
/**
|
|
818
|
-
* The resource every function of the service is checked on, for a service whose functions act on one resource
|
|
819
|
-
* the request does not name: a template over the caller's scope, `{@applicationId}` or `{@tenantId}`, or a literal
|
|
820
|
-
* id. A function naming its own resource with {@link AuthzCheck} is unaffected.
|
|
821
|
-
*/
|
|
822
|
-
resourceId?: string | null;
|
|
823
|
-
/**
|
|
824
|
-
* The permission every function of the service needs, as a short name such as `can_manage`, for a service whose
|
|
825
|
-
* functions all need the one permission whatever their names. A function declaring a permission of its own with
|
|
826
|
-
* {@link AuthzCheck} keeps it. Name the service's strictest permission.
|
|
827
|
-
*/
|
|
828
|
-
permission?: string | null;
|
|
829
|
-
/** Roles of this type beside the built-in ones, each bundling permissions the type's functions need. */
|
|
830
|
-
roles?: AuthzRoleDeclaration[] | null;
|
|
831
|
-
}
|
|
832
|
-
/**
|
|
833
|
-
* What a function declares about its check, as {@link AuthzCheck} declares it; whatever is left out is derived
|
|
834
|
-
* from the function's name and parameters, as described on {@link AuthzResource}.
|
|
835
|
-
*/
|
|
836
|
-
interface AuthzCheckDeclaration {
|
|
837
|
-
/**
|
|
838
|
-
* The permission the function needs, as a short name such as `can_generate`. In the model it is prefixed by
|
|
839
|
-
* the type it is about, so `can_generate` on a `report` service is `report_can_generate`.
|
|
840
|
-
*/
|
|
841
|
-
permission?: string | null;
|
|
842
|
-
/**
|
|
843
|
-
* The type of the resource the check is made on, when it is not the service's own type, such as the parent for a
|
|
844
|
-
* create. A type name, never a template.
|
|
845
|
-
*/
|
|
846
|
-
resource?: string | null;
|
|
847
|
-
/**
|
|
848
|
-
* The id of the resource the check is made on, as a template over the function's parameters and the caller's
|
|
849
|
-
* scope: `{reportId}` is a parameter's value, `{registration.id}` a property of an object parameter, and
|
|
850
|
-
* `{@applicationId}` or `{@tenantId}` the matching id of the caller's scope.
|
|
851
|
-
*/
|
|
852
|
-
resourceId?: string | null;
|
|
853
|
-
/**
|
|
854
|
-
* Short names of permissions on the same type that this permission also grants, so a role bundling
|
|
855
|
-
* `can_generate` declared with `implies: ['can_view']` views what it generates.
|
|
856
|
-
*/
|
|
857
|
-
implies?: string[] | null;
|
|
858
|
-
/**
|
|
859
|
-
* True for a function whose check must not be answered from the engine's caches, because a stale allow would
|
|
860
|
-
* be a security event.
|
|
861
|
-
*/
|
|
862
|
-
consistent?: boolean;
|
|
863
|
-
}
|
|
864
|
-
/**
|
|
865
791
|
* Marks the getter or method that provides the service's scope, which targets requests at one
|
|
866
792
|
* specific instance of the service, such as the copy running on a particular node. It is
|
|
867
793
|
* invoked on each instance when the instance registers with the ServiceRegistry.
|
|
@@ -913,59 +839,6 @@ declare function Context(value: Function, _context: ClassMethodDecoratorContext)
|
|
|
913
839
|
*/
|
|
914
840
|
declare function receivesContext(serviceInstance: object, methodName: string): boolean;
|
|
915
841
|
/**
|
|
916
|
-
* Marks a published service as acting on one type of resource, which `kinotic sync` reads from the class's
|
|
917
|
-
* source into the service's definition, which the runtime registers in the platform's service directory when
|
|
918
|
-
* the service comes online, so every request to the service is authorized before the service sees it. The type
|
|
919
|
-
* and the permissions its functions need become part of the application's authorization model, where roles
|
|
920
|
-
* bundle permissions and grants bind roles to callers.
|
|
921
|
-
*
|
|
922
|
-
* A function's check has three parts: the permission it needs, the type of the resource it is checked on, and
|
|
923
|
-
* the id of that resource. Each part is derived from the function's name and parameters where it can be;
|
|
924
|
-
* {@link AuthzCheck} states a part derivation gets wrong or cannot know, and {@link AuthzUnchecked} marks a
|
|
925
|
-
* function served with no check. A function left with no check and no marker fails the service's registration.
|
|
926
|
-
*
|
|
927
|
-
* The permission is derived from the first word of the function's name: `find`, `get`, `count`, `search` and
|
|
928
|
-
* `list` need `can_view`; `save`, `update` and `set` need `can_edit`; `delete` and `remove` need `can_delete`;
|
|
929
|
-
* `create` needs `can_edit` of this type on the parent. The resource's id is the parameter named `id` or
|
|
930
|
-
* `<type>Id` (`reportId` for the type `report`), else the `id` of the first object parameter; a function with
|
|
931
|
-
* neither is checked on the parent, whose id is found the same way with the parent's name, else on the caller's
|
|
932
|
-
* own scope.
|
|
933
|
-
*
|
|
934
|
-
* Example: with `@AuthzResource({value: 'report', parent: 'tenant'})`, `findById(id: string)` is checked for
|
|
935
|
-
* `report_can_view` on the report `id` names, `save(report: Report)` for `report_can_edit` on the report
|
|
936
|
-
* `report.id` names, and `findReports()` for `report_can_view` on the caller's tenant, with nothing declared on
|
|
937
|
-
* them. A runtime holding no definition for a service declaring a resource refuses to serve it.
|
|
938
|
-
* @param declaration the resource type, or the type with its parent, resource id, permission and roles
|
|
939
|
-
*/
|
|
940
|
-
declare function AuthzResource(declaration: AuthzResourceDeclaration | string): (value: Function, _context: ClassDecoratorContext<any>) => void;
|
|
941
|
-
/**
|
|
942
|
-
* States a part of one function's check that derivation gets wrong or cannot know, which `kinotic sync` reads
|
|
943
|
-
* into the service's definition: the permission, the type of the resource, or its id. Every part left out keeps
|
|
944
|
-
* the derived value, or the one the service declares with {@link AuthzResource}, so a function states only the
|
|
945
|
-
* part derivation misses. A function served with no check is marked {@link AuthzUnchecked} instead.
|
|
946
|
-
*
|
|
947
|
-
* Example: `@AuthzCheck({permission: 'can_report', resourceId: '{registration.id}'})` on
|
|
948
|
-
* `heartbeat(registration: Registration)`, whose name derives no permission and whose id is inside the body.
|
|
949
|
-
* @param declaration the parts of the check derivation cannot read from the function's name and parameters
|
|
950
|
-
*/
|
|
951
|
-
declare function AuthzCheck(declaration: AuthzCheckDeclaration): (_value: Function, _context: ClassMethodDecoratorContext) => void;
|
|
952
|
-
/**
|
|
953
|
-
* Marks a function of an {@link AuthzResource} service, or a whole class declaring no resource, as served with
|
|
954
|
-
* no authorization check, which `kinotic sync` reads into the service's definition: any caller the service's
|
|
955
|
-
* zone admits may call it, and the service itself is responsible for answering only what the caller may see or
|
|
956
|
-
* do. It is for a function that has no resource to check, such as a listing of the caller's own grants, and for a
|
|
957
|
-
* service whose every function answers for the caller alone. The mark is the only way a function is served
|
|
958
|
-
* unchecked: a function the definition neither checks nor marks is refused. A function carrying this and
|
|
959
|
-
* {@link AuthzCheck} fails the service's registration, as does a class carrying this and {@link AuthzResource}.
|
|
960
|
-
*/
|
|
961
|
-
declare function AuthzUnchecked(value: Function, context: ClassDecoratorContext<any> | ClassMethodDecoratorContext): void;
|
|
962
|
-
/**
|
|
963
|
-
* Returns whether the given service instance's class, or a class it extends, declares an {@link AuthzResource} or
|
|
964
|
-
* is marked {@link AuthzUnchecked}: either way the service's definition carries what the platform serves it by.
|
|
965
|
-
* @param serviceInstance the service instance to inspect
|
|
966
|
-
*/
|
|
967
|
-
declare function declaresAuthz(serviceInstance: object): boolean;
|
|
968
|
-
/**
|
|
969
842
|
* Registers each instance of the decorated class with the Kinotic ServiceRegistry.
|
|
970
843
|
* The service name defaults to the class name; {@link Version}, {@link Scope}, and {@link Zone}
|
|
971
844
|
* on the same class refine the registration.
|
|
@@ -978,9 +851,8 @@ declare function Publish(namespace?: string | null, name?: string, advertise?: b
|
|
|
978
851
|
import { ServiceDefinition as ServiceDefinition2 } from "@kinotic-ai/idl";
|
|
979
852
|
/**
|
|
980
853
|
* A service of an application as its runtime registers it in the platform's service directory: the application
|
|
981
|
-
* it belongs to, where it is addressed, whether it is advertised, and its definition
|
|
982
|
-
*
|
|
983
|
-
* functions declare, and the service's liveness.
|
|
854
|
+
* it belongs to, where it is addressed, whether it is advertised, and its definition. The platform owns
|
|
855
|
+
* everything else about the directory's entry, such as the service's liveness.
|
|
984
856
|
*/
|
|
985
857
|
interface ServiceDirectoryEntry {
|
|
986
858
|
/**
|
|
@@ -1000,7 +872,7 @@ interface ServiceDirectoryEntry {
|
|
|
1000
872
|
*/
|
|
1001
873
|
advertised: boolean;
|
|
1002
874
|
/**
|
|
1003
|
-
* The service's definition: its functions,
|
|
875
|
+
* The service's definition: its functions, with the parameters a request carries and what each returns.
|
|
1004
876
|
*/
|
|
1005
877
|
serviceDefinition: ServiceDefinition2;
|
|
1006
878
|
}
|
|
@@ -1601,4 +1473,4 @@ declare class ParticipantConstants {
|
|
|
1601
1473
|
/** The clientId the test server's TestSecurityService maps to the ANONYMOUS role in core package tests. */
|
|
1602
1474
|
static readonly CLI_PARTICIPANT_ID: string;
|
|
1603
1475
|
}
|
|
1604
|
-
export { validateZone, validateLabel, scopeOptionalMethodNames, receivesContext, isAdvertised,
|
|
1476
|
+
export { validateZone, validateLabel, scopeOptionalMethodNames, receivesContext, isAdvertised, declareServiceDefinitions, createCRI, buildServerUrl, buildBrokerUrl, Zone, WebSocketFactory, Version, TextEventFactory, Sort, SessionKeepAliveMode, SessionCredentialsResolver, ServiceRegistry, ServiceIdentifier, ServiceDirectoryEntry, ServiceContext, ServerInfo, ScopeOptional, Scope, RpcError, ResolvedCredentials, Publish, ParticipantConstants, Participant, Pageable, Page, Order, OffsetPageable, NullHandling, KinoticSingleton, KinoticPlugin, Kinotic, JsonEventFactory, IterablePage, Identifiable, IWebSocket, IServiceRegistry, IServiceProxy, IParticipant, IKinotic, IEventFactory, IEventBus, IEvent, IEditableDataSource, IDataSource, ICrudServiceProxyFactory, ICrudServiceProxy, FunctionalIterablePage, EventConstants, EventBus, Event, EnvCredentialsResolver, Direction, DefaultCRI, DataSourceUtils, CursorPageable, CrudServiceProxyFactory, CrudServiceProxy, CredentialsResolver, ContextInterceptor, Context, ConnectedInfo, ConnectOptions, ChainedCredentialsResolver, CRI, BearerCredentialsResolver, BasicCredentialsResolver, AuthorizationException, AbstractIterablePage };
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ function buildServerUrl(server, scheme) {
|
|
|
8
8
|
return scheme + (server.useSSL ? "s" : "") + "://" + server.host + (server.port ? ":" + server.port : "");
|
|
9
9
|
}
|
|
10
10
|
function buildBrokerUrl(server) {
|
|
11
|
-
return buildServerUrl(server, "ws") + "/v1";
|
|
11
|
+
return buildServerUrl(server, "ws") + "/api/v1";
|
|
12
12
|
}
|
|
13
13
|
var SessionKeepAliveMode;
|
|
14
14
|
((SessionKeepAliveMode2) => {
|
|
@@ -1064,8 +1064,6 @@ var versionRegistry = new WeakMap;
|
|
|
1064
1064
|
var zonesRegistry = new WeakMap;
|
|
1065
1065
|
var advertisedRegistry = new WeakMap;
|
|
1066
1066
|
var contextMarkedFunctions = new WeakSet;
|
|
1067
|
-
var authzResourceClasses = new WeakSet;
|
|
1068
|
-
var authzUncheckedClasses = new WeakSet;
|
|
1069
1067
|
function findInConstructorChain(registry, constructor) {
|
|
1070
1068
|
let current = constructor;
|
|
1071
1069
|
while (current) {
|
|
@@ -1156,28 +1154,6 @@ function resolveEffectiveZone(constructor) {
|
|
|
1156
1154
|
}
|
|
1157
1155
|
return effectiveZone;
|
|
1158
1156
|
}
|
|
1159
|
-
function AuthzResource(declaration) {
|
|
1160
|
-
return function(value, _context) {
|
|
1161
|
-
authzResourceClasses.add(value);
|
|
1162
|
-
};
|
|
1163
|
-
}
|
|
1164
|
-
function AuthzCheck(declaration) {
|
|
1165
|
-
return function(_value, _context) {};
|
|
1166
|
-
}
|
|
1167
|
-
function AuthzUnchecked(value, context2) {
|
|
1168
|
-
if (context2.kind === "class") {
|
|
1169
|
-
authzUncheckedClasses.add(value);
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
function declaresAuthz(serviceInstance) {
|
|
1173
|
-
let ret = false;
|
|
1174
|
-
let current = serviceInstance.constructor;
|
|
1175
|
-
while (current && !ret) {
|
|
1176
|
-
ret = authzResourceClasses.has(current) || authzUncheckedClasses.has(current);
|
|
1177
|
-
current = Object.getPrototypeOf(current);
|
|
1178
|
-
}
|
|
1179
|
-
return ret;
|
|
1180
|
-
}
|
|
1181
1157
|
function Publish(namespace, name, advertise = false) {
|
|
1182
1158
|
return function(value, _context) {
|
|
1183
1159
|
advertisedRegistry.set(value, advertise);
|
|
@@ -1205,7 +1181,7 @@ import opentelemetry, { context as context2, propagation as propagation2, trace,
|
|
|
1205
1181
|
// packages/core/package.json
|
|
1206
1182
|
var package_default = {
|
|
1207
1183
|
name: "@kinotic-ai/core",
|
|
1208
|
-
version: "5.0.0-beta.
|
|
1184
|
+
version: "5.0.0-beta.25",
|
|
1209
1185
|
type: "module",
|
|
1210
1186
|
files: [
|
|
1211
1187
|
"dist"
|
|
@@ -1668,7 +1644,7 @@ class TextEventFactory {
|
|
|
1668
1644
|
return event;
|
|
1669
1645
|
}
|
|
1670
1646
|
}
|
|
1671
|
-
var
|
|
1647
|
+
var APPLICATION_SERVICE_DIRECTORY = "app-api~org.kinotic.app.api.services.ApplicationServiceDirectory";
|
|
1672
1648
|
var APPLICATION_ZONE = /^app\.[^.]+\.([^.]+)(\.|$)/;
|
|
1673
1649
|
var declaredDefinitions = new Map;
|
|
1674
1650
|
function declareServiceDefinitions(definitions) {
|
|
@@ -1712,8 +1688,6 @@ function directoryEntryOf(serviceInstance, serviceIdentifier) {
|
|
|
1712
1688
|
advertised: isAdvertised(serviceInstance),
|
|
1713
1689
|
serviceDefinition: definition
|
|
1714
1690
|
};
|
|
1715
|
-
} else if (declaresAuthz(serviceInstance)) {
|
|
1716
|
-
throw new Error(`${qualifiedName} declares a resource or is marked unchecked, but the project declares no definition for it;` + " run kinotic sync and import the generated ServiceDefinitions module");
|
|
1717
1691
|
}
|
|
1718
1692
|
}
|
|
1719
1693
|
return ret;
|
|
@@ -1773,7 +1747,7 @@ class ServiceRegistry {
|
|
|
1773
1747
|
}
|
|
1774
1748
|
async registerEntry(entry) {
|
|
1775
1749
|
this.debugLogger(`Registering ${entry.zone}~${qualifiedNameOf(entry.serviceDefinition.namespace, entry.serviceDefinition.name)} in the directory`);
|
|
1776
|
-
await this.serviceProxy(
|
|
1750
|
+
await this.serviceProxy(APPLICATION_SERVICE_DIRECTORY).invoke("register", [entry]);
|
|
1777
1751
|
}
|
|
1778
1752
|
registerContextInterceptor(interceptor) {
|
|
1779
1753
|
this.contextInterceptor = interceptor;
|
|
@@ -2141,7 +2115,6 @@ export {
|
|
|
2141
2115
|
scopeOptionalMethodNames,
|
|
2142
2116
|
receivesContext,
|
|
2143
2117
|
isAdvertised,
|
|
2144
|
-
declaresAuthz,
|
|
2145
2118
|
declareServiceDefinitions,
|
|
2146
2119
|
createCRI,
|
|
2147
2120
|
buildServerUrl,
|
|
@@ -2183,9 +2156,6 @@ export {
|
|
|
2183
2156
|
ChainedCredentialsResolver,
|
|
2184
2157
|
BearerCredentialsResolver,
|
|
2185
2158
|
BasicCredentialsResolver,
|
|
2186
|
-
AuthzUnchecked,
|
|
2187
|
-
AuthzResource,
|
|
2188
|
-
AuthzCheck,
|
|
2189
2159
|
AuthorizationException,
|
|
2190
2160
|
AbstractIterablePage
|
|
2191
2161
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kinotic-ai/core",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.25",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"vitest": "^4.1.4"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@kinotic-ai/idl": "^5.0.0-beta.
|
|
72
|
+
"@kinotic-ai/idl": "^5.0.0-beta.5",
|
|
73
73
|
"@opentelemetry/api": "^1.9.1",
|
|
74
74
|
"@opentelemetry/semantic-conventions": "^1.40.0",
|
|
75
75
|
"@stomp/rx-stomp": "^2.4.0",
|