@webpieces/core-util 0.4.760 → 0.4.762
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/package.json +1 -1
- package/src/ContextKey.d.ts +3 -3
- package/src/ContextKey.js +3 -3
- package/src/ContextKey.js.map +1 -1
- package/src/http/ContextMgr.d.ts +2 -2
- package/src/http/ContextMgr.js +2 -2
- package/src/http/ContextMgr.js.map +1 -1
- package/src/http/DestinationTrust.d.ts +5 -5
- package/src/http/DestinationTrust.js +8 -8
- package/src/http/DestinationTrust.js.map +1 -1
- package/src/http/RouteMetadata.d.ts +1 -1
- package/src/http/RouteMetadata.js +1 -1
- package/src/http/RouteMetadata.js.map +1 -1
- package/src/http/RuntimeLocality.d.ts +3 -3
- package/src/http/RuntimeLocality.js +1 -1
- package/src/http/RuntimeLocality.js.map +1 -1
- package/src/http/Secrets.d.ts +2 -2
- package/src/http/Secrets.js +2 -2
- package/src/http/Secrets.js.map +1 -1
- package/src/http/WebpiecesCoreHeaders.d.ts +2 -2
- package/src/http/WebpiecesCoreHeaders.js +22 -7
- package/src/http/WebpiecesCoreHeaders.js.map +1 -1
- package/src/http/{AuthApiKeyCompileAssertions.d.ts → WpAuthApiKeyCompileAssertions.d.ts} +4 -4
- package/src/http/{AuthApiKeyCompileAssertions.js → WpAuthApiKeyCompileAssertions.js} +25 -11
- package/src/http/WpAuthApiKeyCompileAssertions.js.map +1 -0
- package/src/http/{AuthJwtCompileAssertions.d.ts → WpAuthJwtCompileAssertions.d.ts} +2 -0
- package/src/http/{AuthJwtCompileAssertions.js → WpAuthJwtCompileAssertions.js} +19 -12
- package/src/http/WpAuthJwtCompileAssertions.js.map +1 -0
- package/src/http/auth-mode.d.ts +8 -8
- package/src/http/auth-mode.js +1 -1
- package/src/http/auth-mode.js.map +1 -1
- package/src/http/decorators.d.ts +47 -44
- package/src/http/decorators.js +95 -81
- package/src/http/decorators.js.map +1 -1
- package/src/index.d.ts +3 -1
- package/src/index.js +23 -12
- package/src/index.js.map +1 -1
- package/src/ipc/IpcDecorators.d.ts +23 -0
- package/src/ipc/IpcDecorators.js +104 -0
- package/src/ipc/IpcDecorators.js.map +1 -0
- package/src/ipc/IpcIdentity.d.ts +3 -0
- package/src/ipc/IpcIdentity.js +14 -0
- package/src/ipc/IpcIdentity.js.map +1 -0
- package/src/ipc/IpcProtocol.js +6 -6
- package/src/ipc/IpcProtocol.js.map +1 -1
- package/src/ipc/index.d.ts +4 -2
- package/src/ipc/index.js +16 -5
- package/src/ipc/index.js.map +1 -1
- package/src/http/AuthApiKeyCompileAssertions.js.map +0 -1
- package/src/http/AuthJwtCompileAssertions.js.map +0 -1
- package/src/ipc/IpcCompileAssertions.d.ts +0 -4
- package/src/ipc/IpcCompileAssertions.js +0 -39
- package/src/ipc/IpcCompileAssertions.js.map +0 -1
- package/src/ipc/IpcContract.d.ts +0 -32
- package/src/ipc/IpcContract.js +0 -65
- package/src/ipc/IpcContract.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IpcCompileAssertions.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/ipc/IpcCompileAssertions.ts"],"names":[],"mappings":";;;AAAA,+CAA8E;AAC9E,uDAAgD;AAChD,MAAM,OAAO;IACY;IAArB,YAAqB,EAAU;QAAV,OAAE,GAAF,EAAE,CAAQ;IAAG,CAAC;CACtC;AACD,MAAM,MAAM;IACR,0IAA0I;IAC1I,KAAK,CAAC,KAAc;QAChB,IAAI,CAAC,CAAC,KAAK,YAAY,OAAO,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACrE,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AACD,MAAe,GAAG;CAGjB;AACD,MAAM,UAAU;IACH,KAAK,GAAG,IAAI,uBAAS,CAAC,OAAO,EAAE,IAAI,MAAM,EAAE,EAAE,IAAI,MAAM,EAAE,EAAE,IAAI,uBAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;CACzF;AACD,MAAe,WAAW;CAEzB;AACD,oGAAoG;AACpG,MAAa,oBAAoB;IAC7B,oIAAoI;IACpI,MAAM,CAAC,wBAAwB;QAC3B,oEAAoE;QACpE,IAAI,yBAAW,CAAC,YAAY,EAAE,GAAG,EAAE,IAAI,UAAU,EAAE,CAAC,CAAC;QACrD,wEAAwE;QACxE,MAAM,QAAQ,GAA4B,IAAI,UAAU,EAAE,CAAC;QAC3D,KAAK,QAAQ,CAAC;IAClB,CAAC;CACJ;AATD,oDASC","sourcesContent":["import { IpcContract, IpcMethod, IpcMethods, IpcSchema } from './IpcContract';\nimport { MaskSpec } from '../http/LogFieldMask';\nclass Request {\n constructor(readonly id: string) {}\n}\nclass Schema implements IpcSchema<Request> {\n // webpieces-disable no-any-unknown -- untrusted IPC data is schema-validated; generic dispatch cannot assume a DTO type before validation\n parse(value: unknown): Request {\n if (!(value instanceof Request)) throw new Error('Expected Request');\n return value;\n }\n}\nabstract class Api {\n abstract first(request: Request): Promise<Request>;\n abstract second(request: Request): Promise<Request>;\n}\nclass Incomplete {\n readonly first = new IpcMethod('first', new Schema(), new Schema(), new MaskSpec({}));\n}\nabstract class MultipleApi {\n abstract bad(a: Request, b: Request): Promise<Request>;\n}\n/** These assertions compile in package builds, unlike transpiled-only spec files. Never invoked. */\nexport class IpcCompileAssertions {\n // webpieces-disable no-function-outside-class -- portable stateless IPC primitive; no platform DI container exists on this boundary\n static assertExhaustiveMetadata(): void {\n // @ts-expect-error every API member needs explicit runtime metadata\n new IpcContract('incomplete', Api, new Incomplete());\n // @ts-expect-error multi-argument API methods are not IPC DTO contracts\n const multiple: IpcMethods<MultipleApi> = new Incomplete();\n void multiple;\n }\n}\n"]}
|
package/src/ipc/IpcContract.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { MaskSpec } from '../http/LogFieldMask';
|
|
2
|
-
/** A portable schema owns parsing and validation, including class reconstruction. */
|
|
3
|
-
export interface IpcSchema<T> {
|
|
4
|
-
parse(value: unknown): T;
|
|
5
|
-
}
|
|
6
|
-
/** Acknowledged void has an explicit null wire representation. */
|
|
7
|
-
export declare class IpcVoidSchema implements IpcSchema<void> {
|
|
8
|
-
parse(value: unknown): void;
|
|
9
|
-
}
|
|
10
|
-
export declare class IpcMethod<Q, R> {
|
|
11
|
-
readonly id: string;
|
|
12
|
-
readonly request: IpcSchema<Q>;
|
|
13
|
-
readonly response: IpcSchema<R>;
|
|
14
|
-
readonly mask: MaskSpec;
|
|
15
|
-
readonly kind: 'request' | 'notification';
|
|
16
|
-
constructor(id: string, request: IpcSchema<Q>, response: IpcSchema<R>, mask: MaskSpec, kind?: 'request' | 'notification');
|
|
17
|
-
}
|
|
18
|
-
/** Every API member must have exactly one DTO argument and a Promise reply. */
|
|
19
|
-
export type IpcMethods<T> = {
|
|
20
|
-
[K in keyof T]: T[K] extends (...args: infer A) => Promise<infer R> ? A extends [infer Q] ? IpcMethod<Q, R> : never : never;
|
|
21
|
-
};
|
|
22
|
-
export type IpcApiType<T> = abstract new (...args: never[]) => T;
|
|
23
|
-
/** Runtime metadata is declared once beside the shared contract. IDs survive minification. */
|
|
24
|
-
export declare class IpcContract<T extends object> {
|
|
25
|
-
readonly id: string;
|
|
26
|
-
readonly api: IpcApiType<T>;
|
|
27
|
-
readonly methods: Readonly<IpcMethods<T>>;
|
|
28
|
-
constructor(id: string, api: IpcApiType<T>, methods: IpcMethods<T>);
|
|
29
|
-
}
|
|
30
|
-
export declare class IpcIdentity {
|
|
31
|
-
static assert(value: unknown, label: string): asserts value is string;
|
|
32
|
-
}
|
package/src/ipc/IpcContract.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IpcIdentity = exports.IpcContract = exports.IpcMethod = exports.IpcVoidSchema = void 0;
|
|
4
|
-
const errors_1 = require("../errors");
|
|
5
|
-
/** Acknowledged void has an explicit null wire representation. */
|
|
6
|
-
class IpcVoidSchema {
|
|
7
|
-
// webpieces-disable no-any-unknown -- untrusted IPC data is schema-validated; generic dispatch cannot assume a DTO type before validation
|
|
8
|
-
parse(value) {
|
|
9
|
-
if (value !== null && value !== undefined) {
|
|
10
|
-
throw new errors_1.BadRequestError('Expected an acknowledged void response');
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.IpcVoidSchema = IpcVoidSchema;
|
|
15
|
-
class IpcMethod {
|
|
16
|
-
id;
|
|
17
|
-
request;
|
|
18
|
-
response;
|
|
19
|
-
mask;
|
|
20
|
-
kind;
|
|
21
|
-
constructor(id, request, response, mask, kind = 'request') {
|
|
22
|
-
this.id = id;
|
|
23
|
-
this.request = request;
|
|
24
|
-
this.response = response;
|
|
25
|
-
this.mask = mask;
|
|
26
|
-
this.kind = kind;
|
|
27
|
-
IpcIdentity.assert(id, 'method');
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.IpcMethod = IpcMethod;
|
|
31
|
-
/** Runtime metadata is declared once beside the shared contract. IDs survive minification. */
|
|
32
|
-
class IpcContract {
|
|
33
|
-
id;
|
|
34
|
-
api;
|
|
35
|
-
methods;
|
|
36
|
-
constructor(id, api, methods) {
|
|
37
|
-
this.id = id;
|
|
38
|
-
this.api = api;
|
|
39
|
-
IpcIdentity.assert(id, 'API');
|
|
40
|
-
const ids = new Set();
|
|
41
|
-
for (const key of Object.keys(methods)) {
|
|
42
|
-
// webpieces-disable no-any-unknown -- untrusted IPC data is schema-validated; generic dispatch cannot assume a DTO type before validation
|
|
43
|
-
const method = methods[key];
|
|
44
|
-
if (!(method instanceof IpcMethod) ||
|
|
45
|
-
ids.has(method.id) ||
|
|
46
|
-
['then', 'constructor', '__proto__'].includes(key)) {
|
|
47
|
-
throw new errors_1.BadRequestError(`Invalid or duplicate IPC metadata: ${id}.${key}`);
|
|
48
|
-
}
|
|
49
|
-
ids.add(method.id);
|
|
50
|
-
Object.freeze(method);
|
|
51
|
-
}
|
|
52
|
-
this.methods = Object.freeze(Object.assign(Object.create(null), methods));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.IpcContract = IpcContract;
|
|
56
|
-
class IpcIdentity {
|
|
57
|
-
// webpieces-disable no-function-outside-class -- portable stateless IPC primitive; no platform DI container exists on this boundary; webpieces-disable no-any-unknown -- untrusted IPC data is schema-validated; generic dispatch cannot assume a DTO type before validation
|
|
58
|
-
static assert(value, label) {
|
|
59
|
-
if (typeof value !== 'string' || !/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/.test(value)) {
|
|
60
|
-
throw new errors_1.BadRequestError(`Invalid IPC ${label} identity`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.IpcIdentity = IpcIdentity;
|
|
65
|
-
//# sourceMappingURL=IpcContract.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IpcContract.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/ipc/IpcContract.ts"],"names":[],"mappings":";;;AACA,sCAA4C;AAQ5C,kEAAkE;AAClE,MAAa,aAAa;IACtB,0IAA0I;IAC1I,KAAK,CAAC,KAAc;QAChB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxC,MAAM,IAAI,wBAAe,CAAC,wCAAwC,CAAC,CAAC;QACxE,CAAC;IACL,CAAC;CACJ;AAPD,sCAOC;AAED,MAAa,SAAS;IAEL;IACA;IACA;IACA;IACA;IALb,YACa,EAAU,EACV,OAAqB,EACrB,QAAsB,EACtB,IAAc,EACd,OAAmC,SAAS;QAJ5C,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAc;QACrB,aAAQ,GAAR,QAAQ,CAAc;QACtB,SAAI,GAAJ,IAAI,CAAU;QACd,SAAI,GAAJ,IAAI,CAAwC;QAErD,WAAW,CAAC,MAAM,CAAC,EAAE,EAAE,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,EAAE,CAAC;YAClF,MAAM,IAAI,wBAAe,CAAC,eAAe,KAAK,WAAW,CAAC,CAAC;QAC/D,CAAC;IACL,CAAC;CACJ;AAPD,kCAOC","sourcesContent":["import { MaskSpec } from '../http/LogFieldMask';\nimport { BadRequestError } from '../errors';\n\n/** A portable schema owns parsing and validation, including class reconstruction. */\nexport interface IpcSchema<T> {\n // webpieces-disable no-any-unknown -- untrusted IPC data is schema-validated; generic dispatch cannot assume a DTO type before validation\n parse(value: unknown): T;\n}\n\n/** Acknowledged void has an explicit null wire representation. */\nexport class IpcVoidSchema implements IpcSchema<void> {\n // webpieces-disable no-any-unknown -- untrusted IPC data is schema-validated; generic dispatch cannot assume a DTO type before validation\n parse(value: unknown): void {\n if (value !== null && value !== undefined) {\n throw new BadRequestError('Expected an acknowledged void response');\n }\n }\n}\n\nexport class IpcMethod<Q, R> {\n constructor(\n readonly id: string,\n readonly request: IpcSchema<Q>,\n readonly response: IpcSchema<R>,\n readonly mask: MaskSpec,\n readonly kind: 'request' | 'notification' = 'request',\n ) {\n IpcIdentity.assert(id, 'method');\n }\n}\n\n/** Every API member must have exactly one DTO argument and a Promise reply. */\nexport type IpcMethods<T> = {\n [K in keyof T]: T[K] extends (...args: infer A) => Promise<infer R>\n ? A extends [infer Q]\n ? IpcMethod<Q, R>\n : never\n : never;\n};\nexport type IpcApiType<T> = abstract new (...args: never[]) => T;\n\n/** Runtime metadata is declared once beside the shared contract. IDs survive minification. */\nexport class IpcContract<T extends object> {\n readonly methods: Readonly<IpcMethods<T>>;\n constructor(\n readonly id: string,\n readonly api: IpcApiType<T>,\n methods: IpcMethods<T>,\n ) {\n IpcIdentity.assert(id, 'API');\n const ids = new Set<string>();\n for (const key of Object.keys(methods)) {\n // webpieces-disable no-any-unknown -- untrusted IPC data is schema-validated; generic dispatch cannot assume a DTO type before validation\n const method: unknown = methods[key as keyof T];\n if (\n !(method instanceof IpcMethod) ||\n ids.has(method.id) ||\n ['then', 'constructor', '__proto__'].includes(key)\n ) {\n throw new BadRequestError(`Invalid or duplicate IPC metadata: ${id}.${key}`);\n }\n ids.add(method.id);\n Object.freeze(method);\n }\n this.methods = Object.freeze(Object.assign(Object.create(null), methods));\n }\n}\n\nexport class IpcIdentity {\n // webpieces-disable no-function-outside-class -- portable stateless IPC primitive; no platform DI container exists on this boundary; webpieces-disable no-any-unknown -- untrusted IPC data is schema-validated; generic dispatch cannot assume a DTO type before validation\n static assert(value: unknown, label: string): asserts value is string {\n if (typeof value !== 'string' || !/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/.test(value)) {\n throw new BadRequestError(`Invalid IPC ${label} identity`);\n }\n }\n}\n"]}
|