@orqenix/transport-security 0.6.0-phase-6
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 +19 -0
- package/README.md +6 -0
- package/dist/adapters.d.ts +15 -0
- package/dist/adapters.d.ts.map +1 -0
- package/dist/adapters.js +27 -0
- package/dist/adapters.js.map +1 -0
- package/dist/capability-token.d.ts +14 -0
- package/dist/capability-token.d.ts.map +1 -0
- package/dist/capability-token.js +49 -0
- package/dist/capability-token.js.map +1 -0
- package/dist/ed25519.d.ts +13 -0
- package/dist/ed25519.d.ts.map +1 -0
- package/dist/ed25519.js +51 -0
- package/dist/ed25519.js.map +1 -0
- package/dist/glob.d.ts +10 -0
- package/dist/glob.d.ts.map +1 -0
- package/dist/glob.js +58 -0
- package/dist/glob.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/key-store.d.ts +26 -0
- package/dist/key-store.d.ts.map +1 -0
- package/dist/key-store.js +49 -0
- package/dist/key-store.js.map +1 -0
- package/dist/signer.d.ts +14 -0
- package/dist/signer.d.ts.map +1 -0
- package/dist/signer.js +18 -0
- package/dist/signer.js.map +1 -0
- package/dist/verifier.d.ts +35 -0
- package/dist/verifier.d.ts.map +1 -0
- package/dist/verifier.js +92 -0
- package/dist/verifier.js.map +1 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright 2026 Milo Nguyen and Orqenix contributors
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
|
|
19
|
+
[Full Apache 2.0 text: include verbatim from https://www.apache.org/licenses/LICENSE-2.0.txt]
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ScopeId } from '@orqenix/mesh-transport-core';
|
|
2
|
+
import { LRUKeyStore } from './key-store.js';
|
|
3
|
+
export interface StructuralIdentityVerifier {
|
|
4
|
+
verifyScopeSig(fromScope: ScopeId, requestIdOrNonce: string, toScope: ScopeId, sigB64u: string): Promise<boolean>;
|
|
5
|
+
}
|
|
6
|
+
export interface Ed25519IdentityVerifierOptions {
|
|
7
|
+
keyStore: LRUKeyStore;
|
|
8
|
+
}
|
|
9
|
+
export declare class Ed25519IdentityVerifier implements StructuralIdentityVerifier {
|
|
10
|
+
private readonly keyStore;
|
|
11
|
+
constructor(opts: Ed25519IdentityVerifierOptions);
|
|
12
|
+
verifyScopeSig(fromScope: ScopeId, requestIdOrNonce: string, toScope: ScopeId, sigB64u: string): Promise<boolean>;
|
|
13
|
+
}
|
|
14
|
+
export declare function makeEd25519IdentityVerifier(keyStore: LRUKeyStore): Ed25519IdentityVerifier;
|
|
15
|
+
//# sourceMappingURL=adapters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,WAAW,0BAA0B;IACzC,cAAc,CACZ,SAAS,EAAE,OAAO,EAClB,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB;AAED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,EAAE,WAAW,CAAC;CACvB;AAED,qBAAa,uBAAwB,YAAW,0BAA0B;IACxE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;gBAC3B,IAAI,EAAE,8BAA8B;IAI1C,cAAc,CAClB,SAAS,EAAE,OAAO,EAClB,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC;CAapB;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,WAAW,GAAG,uBAAuB,CAE1F"}
|
package/dist/adapters.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { b64urlDecode, ed25519Verify, importEd25519PublicKey } from './ed25519.js';
|
|
2
|
+
export class Ed25519IdentityVerifier {
|
|
3
|
+
keyStore;
|
|
4
|
+
constructor(opts) {
|
|
5
|
+
this.keyStore = opts.keyStore;
|
|
6
|
+
}
|
|
7
|
+
async verifyScopeSig(fromScope, requestIdOrNonce, toScope, sigB64u) {
|
|
8
|
+
if (!fromScope || !requestIdOrNonce || !toScope || !sigB64u)
|
|
9
|
+
return false;
|
|
10
|
+
const pubRaw = await this.keyStore.get(fromScope);
|
|
11
|
+
if (!pubRaw)
|
|
12
|
+
return false;
|
|
13
|
+
try {
|
|
14
|
+
const publicKey = await importEd25519PublicKey(pubRaw);
|
|
15
|
+
const sigBytes = b64urlDecode(sigB64u);
|
|
16
|
+
const message = new TextEncoder().encode(`${requestIdOrNonce}.${toScope}`);
|
|
17
|
+
return await ed25519Verify(publicKey, sigBytes, message);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function makeEd25519IdentityVerifier(keyStore) {
|
|
25
|
+
return new Ed25519IdentityVerifier({ keyStore });
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=adapters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapters.js","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAgBnF,MAAM,OAAO,uBAAuB;IACjB,QAAQ,CAAc;IACvC,YAAY,IAAoC;QAC9C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,SAAkB,EAClB,gBAAwB,EACxB,OAAgB,EAChB,OAAe;QAEf,IAAI,CAAC,SAAS,IAAI,CAAC,gBAAgB,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO;YAAE,OAAO,KAAK,CAAC;QAC1E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QAC1B,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,sBAAsB,CAAC,MAAM,CAAC,CAAC;YACvD,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;YACvC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,gBAAgB,IAAI,OAAO,EAAE,CAAC,CAAC;YAC3E,OAAO,MAAM,aAAa,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC3D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF;AAED,MAAM,UAAU,2BAA2B,CAAC,QAAqB;IAC/D,OAAO,IAAI,uBAAuB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ScopeId, CapabilityToken } from '@orqenix/mesh-transport-core';
|
|
2
|
+
export interface CapabilityTokenFields {
|
|
3
|
+
iss: ScopeId;
|
|
4
|
+
sub: ScopeId;
|
|
5
|
+
caps: string[];
|
|
6
|
+
exp: number;
|
|
7
|
+
nbf?: number;
|
|
8
|
+
jti: string;
|
|
9
|
+
sig: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function canonicalSigningBytes(token: Omit<CapabilityTokenFields, 'sig'>): Uint8Array;
|
|
12
|
+
export declare function encodeCapabilityToken(token: CapabilityTokenFields): CapabilityToken;
|
|
13
|
+
export declare function decodeCapabilityToken(s: string): CapabilityTokenFields;
|
|
14
|
+
//# sourceMappingURL=capability-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-token.d.ts","sourceRoot":"","sources":["../src/capability-token.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAO7E,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,qBAAqB,EAAE,KAAK,CAAC,GAAG,UAAU,CAU3F;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,qBAAqB,GAAG,eAAe,CAEnF;AAED,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,MAAM,GAAG,qBAAqB,CA4BtE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Packr, Unpackr } from 'msgpackr';
|
|
2
|
+
import { canonicalize } from '@orqenix/mesh-transport-core';
|
|
3
|
+
import { b64urlDecode, b64urlEncode } from './ed25519.js';
|
|
4
|
+
const packr = new Packr({ useRecords: false });
|
|
5
|
+
const unpackr = new Unpackr({ useRecords: false });
|
|
6
|
+
export function canonicalSigningBytes(token) {
|
|
7
|
+
const stripped = {
|
|
8
|
+
iss: token.iss,
|
|
9
|
+
sub: token.sub,
|
|
10
|
+
caps: [...token.caps].sort(),
|
|
11
|
+
exp: token.exp,
|
|
12
|
+
nbf: token.nbf,
|
|
13
|
+
jti: token.jti,
|
|
14
|
+
};
|
|
15
|
+
return packr.pack(canonicalize(stripped));
|
|
16
|
+
}
|
|
17
|
+
export function encodeCapabilityToken(token) {
|
|
18
|
+
return b64urlEncode(packr.pack(canonicalize(token)));
|
|
19
|
+
}
|
|
20
|
+
export function decodeCapabilityToken(s) {
|
|
21
|
+
const raw = unpackr.unpack(b64urlDecode(s));
|
|
22
|
+
if (!raw || typeof raw !== 'object')
|
|
23
|
+
throw new Error('cap-token: not an object');
|
|
24
|
+
const o = raw;
|
|
25
|
+
for (const k of ['iss', 'sub', 'jti', 'sig']) {
|
|
26
|
+
if (typeof o[k] !== 'string' || o[k].length === 0) {
|
|
27
|
+
throw new Error(`cap-token: field ${k} missing or empty`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (!Array.isArray(o.caps) || o.caps.some((c) => typeof c !== 'string')) {
|
|
31
|
+
throw new Error('cap-token: caps must be string[]');
|
|
32
|
+
}
|
|
33
|
+
if (!Number.isInteger(o.exp) || o.exp <= 0) {
|
|
34
|
+
throw new Error('cap-token: exp must be a positive integer');
|
|
35
|
+
}
|
|
36
|
+
if (o.nbf !== undefined && (!Number.isInteger(o.nbf) || o.nbf <= 0)) {
|
|
37
|
+
throw new Error('cap-token: nbf must be a positive integer when present');
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
iss: o.iss,
|
|
41
|
+
sub: o.sub,
|
|
42
|
+
caps: o.caps,
|
|
43
|
+
exp: o.exp,
|
|
44
|
+
nbf: o.nbf,
|
|
45
|
+
jti: o.jti,
|
|
46
|
+
sig: o.sig,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=capability-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-token.js","sourceRoot":"","sources":["../src/capability-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE1D,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;AAC/C,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;AAYnD,MAAM,UAAU,qBAAqB,CAAC,KAAyC;IAC7E,MAAM,QAAQ,GAAG;QACf,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;QAC5B,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,GAAG,EAAE,KAAK,CAAC,GAAG;KACf,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAA4B;IAChE,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAoB,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,CAAS;IAC7C,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,YAA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AC,CAAC,IAAgB;QACxB,GAAG,EAAE,CAAC,CAAC,GAAa;QACpB,GAAG,EAAE,CAAC,CAAC,GAAyB;QAChC,GAAG,EAAE,CAAC,CAAC,GAAa;QACpB,GAAG,EAAE,CAAC,CAAC,GAAa;KACrB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface Ed25519Keypair {
|
|
2
|
+
publicKey: CryptoKey;
|
|
3
|
+
privateKey: CryptoKey;
|
|
4
|
+
}
|
|
5
|
+
export declare function generateEd25519Keypair(): Promise<Ed25519Keypair>;
|
|
6
|
+
export declare function importEd25519PublicKey(raw: Uint8Array): Promise<CryptoKey>;
|
|
7
|
+
export declare function importEd25519PrivateKey(seed: Uint8Array): Promise<CryptoKey>;
|
|
8
|
+
export declare function exportEd25519PublicKeyRaw(key: CryptoKey): Promise<Uint8Array>;
|
|
9
|
+
export declare function ed25519Sign(privateKey: CryptoKey, message: Uint8Array): Promise<Uint8Array>;
|
|
10
|
+
export declare function ed25519Verify(publicKey: CryptoKey, signature: Uint8Array, message: Uint8Array): Promise<boolean>;
|
|
11
|
+
export declare function b64urlEncode(bytes: Uint8Array): string;
|
|
12
|
+
export declare function b64urlDecode(s: string): Uint8Array;
|
|
13
|
+
//# sourceMappingURL=ed25519.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ed25519.d.ts","sourceRoot":"","sources":["../src/ed25519.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;CACvB;AAED,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,cAAc,CAAC,CAGtE;AAED,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAGhF;AAED,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAIlF;AAED,wBAAsB,yBAAyB,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAEnF;AAED,wBAAsB,WAAW,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAEjG;AAED,wBAAsB,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAMtH;AAaD,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAEtD;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAGlD"}
|
package/dist/ed25519.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const subtle = globalThis.crypto.subtle;
|
|
2
|
+
function toBuf(src) {
|
|
3
|
+
return src.buffer.slice(src.byteOffset, src.byteOffset + src.byteLength);
|
|
4
|
+
}
|
|
5
|
+
export async function generateEd25519Keypair() {
|
|
6
|
+
const kp = (await subtle.generateKey('Ed25519', true, ['sign', 'verify']));
|
|
7
|
+
return { publicKey: kp.publicKey, privateKey: kp.privateKey };
|
|
8
|
+
}
|
|
9
|
+
export async function importEd25519PublicKey(raw) {
|
|
10
|
+
if (raw.length !== 32)
|
|
11
|
+
throw new Error('ed25519: public key must be 32 bytes');
|
|
12
|
+
return await subtle.importKey('raw', toBuf(raw), 'Ed25519', true, ['verify']);
|
|
13
|
+
}
|
|
14
|
+
export async function importEd25519PrivateKey(seed) {
|
|
15
|
+
if (seed.length !== 32)
|
|
16
|
+
throw new Error('ed25519: private seed must be 32 bytes');
|
|
17
|
+
const pkcs8 = wrapEd25519SeedAsPkcs8(seed);
|
|
18
|
+
return await subtle.importKey('pkcs8', toBuf(pkcs8), 'Ed25519', false, ['sign']);
|
|
19
|
+
}
|
|
20
|
+
export async function exportEd25519PublicKeyRaw(key) {
|
|
21
|
+
return new Uint8Array(await subtle.exportKey('raw', key));
|
|
22
|
+
}
|
|
23
|
+
export async function ed25519Sign(privateKey, message) {
|
|
24
|
+
return new Uint8Array(await subtle.sign('Ed25519', privateKey, toBuf(message)));
|
|
25
|
+
}
|
|
26
|
+
export async function ed25519Verify(publicKey, signature, message) {
|
|
27
|
+
try {
|
|
28
|
+
return await subtle.verify('Ed25519', publicKey, toBuf(signature), toBuf(message));
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function wrapEd25519SeedAsPkcs8(seed) {
|
|
35
|
+
const prefix = new Uint8Array([
|
|
36
|
+
0x30, 0x2e, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06,
|
|
37
|
+
0x03, 0x2b, 0x65, 0x70, 0x04, 0x22, 0x04, 0x20,
|
|
38
|
+
]);
|
|
39
|
+
const out = new Uint8Array(prefix.length + 32);
|
|
40
|
+
out.set(prefix, 0);
|
|
41
|
+
out.set(seed, prefix.length);
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
export function b64urlEncode(bytes) {
|
|
45
|
+
return Buffer.from(bytes).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
46
|
+
}
|
|
47
|
+
export function b64urlDecode(s) {
|
|
48
|
+
const pad = s.length % 4 === 0 ? '' : '='.repeat(4 - (s.length % 4));
|
|
49
|
+
return new Uint8Array(Buffer.from(s.replace(/-/g, '+').replace(/_/g, '/') + pad, 'base64'));
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=ed25519.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ed25519.js","sourceRoot":"","sources":["../src/ed25519.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAiB,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC;AAEtD,SAAS,KAAK,CAAC,GAAe;IAC5B,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAA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AE,CAAC,CAAC;AAC1G,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,CAAS;IACpC,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IACrE,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC9F,CAAC"}
|
package/dist/glob.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface CompiledPattern {
|
|
2
|
+
readonly raw: string;
|
|
3
|
+
readonly segments: ReadonlyArray<'*' | '**' | {
|
|
4
|
+
literal: string;
|
|
5
|
+
}>;
|
|
6
|
+
}
|
|
7
|
+
export declare function compileGlob(pattern: string): CompiledPattern;
|
|
8
|
+
export declare function matches(compiled: CompiledPattern, method: string): boolean;
|
|
9
|
+
export declare function methodAllowed(caps: ReadonlyArray<string>, method: string): boolean;
|
|
10
|
+
//# sourceMappingURL=glob.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../src/glob.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,GAAG,GAAG,IAAI,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpE;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAY5D;AAED,wBAAgB,OAAO,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAI1E;AA+BD,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAKlF"}
|
package/dist/glob.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export function compileGlob(pattern) {
|
|
2
|
+
if (typeof pattern !== 'string' || pattern.length === 0) {
|
|
3
|
+
throw new Error('glob: empty pattern');
|
|
4
|
+
}
|
|
5
|
+
const parts = pattern.split('.');
|
|
6
|
+
const out = parts.map((p) => {
|
|
7
|
+
if (p === '*')
|
|
8
|
+
return '*';
|
|
9
|
+
if (p === '**')
|
|
10
|
+
return '**';
|
|
11
|
+
if (p.includes('*'))
|
|
12
|
+
throw new Error(`glob: mixed segment "${p}" not allowed (use whole-segment * or **)`);
|
|
13
|
+
return { literal: p };
|
|
14
|
+
});
|
|
15
|
+
return { raw: pattern, segments: out };
|
|
16
|
+
}
|
|
17
|
+
export function matches(compiled, method) {
|
|
18
|
+
if (typeof method !== 'string' || method.length === 0)
|
|
19
|
+
return false;
|
|
20
|
+
const m = method.split('.');
|
|
21
|
+
return matchHelper(compiled.segments, 0, m, 0);
|
|
22
|
+
}
|
|
23
|
+
function matchHelper(pat, pi, parts, mi) {
|
|
24
|
+
while (pi < pat.length) {
|
|
25
|
+
const seg = pat[pi];
|
|
26
|
+
if (seg === '**') {
|
|
27
|
+
if (pi === pat.length - 1)
|
|
28
|
+
return true;
|
|
29
|
+
for (let take = parts.length - mi; take >= 0; take--) {
|
|
30
|
+
if (matchHelper(pat, pi + 1, parts, mi + take))
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (mi >= parts.length)
|
|
36
|
+
return false;
|
|
37
|
+
if (seg === '*') {
|
|
38
|
+
if (parts[mi].length === 0)
|
|
39
|
+
return false;
|
|
40
|
+
pi++;
|
|
41
|
+
mi++;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (parts[mi] !== seg.literal)
|
|
45
|
+
return false;
|
|
46
|
+
pi++;
|
|
47
|
+
mi++;
|
|
48
|
+
}
|
|
49
|
+
return mi === parts.length;
|
|
50
|
+
}
|
|
51
|
+
export function methodAllowed(caps, method) {
|
|
52
|
+
for (const c of caps) {
|
|
53
|
+
if (matches(compileGlob(c), method))
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=glob.js.map
|
package/dist/glob.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../src/glob.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxD,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IACD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,GAAG,GAAgC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACvD,IAAI,CAAC,KAAK,GAAG;YAAE,OAAO,GAAG,CAAC;QAC1B,IAAI,CAAC,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAC5B,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,2CAA2C,CAAC,CAAC;QAC3G,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,QAAyB,EAAE,MAAc;IAC/D,IAAI,O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AAC;IACD,OAAO,EAAE,KAAK,KAAK,CAAC,MAAM,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAA2B,EAAE,MAAc;IACvE,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC;IACnD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './ed25519.js';
|
|
2
|
+
export * from './capability-token.js';
|
|
3
|
+
export * from './key-store.js';
|
|
4
|
+
export * from './glob.js';
|
|
5
|
+
export * from './verifier.js';
|
|
6
|
+
export * from './signer.js';
|
|
7
|
+
export * from './adapters.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './ed25519.js';
|
|
2
|
+
export * from './capability-token.js';
|
|
3
|
+
export * from './key-store.js';
|
|
4
|
+
export * from './glob.js';
|
|
5
|
+
export * from './verifier.js';
|
|
6
|
+
export * from './signer.js';
|
|
7
|
+
export * from './adapters.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ScopeId } from '@orqenix/mesh-transport-core';
|
|
2
|
+
export interface KeyResolver {
|
|
3
|
+
resolve(scopeId: ScopeId): Promise<Uint8Array | undefined>;
|
|
4
|
+
}
|
|
5
|
+
export interface KeyStoreOptions {
|
|
6
|
+
maxEntries?: number;
|
|
7
|
+
resolver?: KeyResolver;
|
|
8
|
+
}
|
|
9
|
+
export interface KeyStoreStats {
|
|
10
|
+
hits: number;
|
|
11
|
+
misses: number;
|
|
12
|
+
size: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class LRUKeyStore {
|
|
15
|
+
private readonly maxEntries;
|
|
16
|
+
private readonly resolver?;
|
|
17
|
+
private readonly map;
|
|
18
|
+
private hits;
|
|
19
|
+
private misses;
|
|
20
|
+
constructor(opts?: KeyStoreOptions);
|
|
21
|
+
put(scopeId: ScopeId, publicKey: Uint8Array): void;
|
|
22
|
+
get(scopeId: ScopeId): Promise<Uint8Array | undefined>;
|
|
23
|
+
getStats(): KeyStoreStats;
|
|
24
|
+
clear(): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=key-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-store.d.ts","sourceRoot":"","sources":["../src/key-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,WAAW,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAc;IACxC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAkC;IACtD,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,MAAM,CAAK;gBAEP,IAAI,GAAE,eAAoB;IAKtC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,GAAG,IAAI;IAW5C,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAe5D,QAAQ,IAAI,aAAa;IAIzB,KAAK,IAAI,IAAI;CAKd"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export class LRUKeyStore {
|
|
2
|
+
maxEntries;
|
|
3
|
+
resolver;
|
|
4
|
+
map = new Map();
|
|
5
|
+
hits = 0;
|
|
6
|
+
misses = 0;
|
|
7
|
+
constructor(opts = {}) {
|
|
8
|
+
this.maxEntries = opts.maxEntries ?? 4_096;
|
|
9
|
+
this.resolver = opts.resolver;
|
|
10
|
+
}
|
|
11
|
+
put(scopeId, publicKey) {
|
|
12
|
+
if (publicKey.length !== 32)
|
|
13
|
+
throw new Error('LRUKeyStore: public key must be 32 bytes');
|
|
14
|
+
if (this.map.has(scopeId))
|
|
15
|
+
this.map.delete(scopeId);
|
|
16
|
+
this.map.set(scopeId, publicKey);
|
|
17
|
+
while (this.map.size > this.maxEntries) {
|
|
18
|
+
const oldest = this.map.keys().next().value;
|
|
19
|
+
if (oldest === undefined)
|
|
20
|
+
break;
|
|
21
|
+
this.map.delete(oldest);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async get(scopeId) {
|
|
25
|
+
const cached = this.map.get(scopeId);
|
|
26
|
+
if (cached) {
|
|
27
|
+
this.hits++;
|
|
28
|
+
this.map.delete(scopeId);
|
|
29
|
+
this.map.set(scopeId, cached);
|
|
30
|
+
return cached;
|
|
31
|
+
}
|
|
32
|
+
this.misses++;
|
|
33
|
+
if (!this.resolver)
|
|
34
|
+
return undefined;
|
|
35
|
+
const fetched = await this.resolver.resolve(scopeId);
|
|
36
|
+
if (fetched)
|
|
37
|
+
this.put(scopeId, fetched);
|
|
38
|
+
return fetched;
|
|
39
|
+
}
|
|
40
|
+
getStats() {
|
|
41
|
+
return { hits: this.hits, misses: this.misses, size: this.map.size };
|
|
42
|
+
}
|
|
43
|
+
clear() {
|
|
44
|
+
this.map.clear();
|
|
45
|
+
this.hits = 0;
|
|
46
|
+
this.misses = 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=key-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-store.js","sourceRoot":"","sources":["../src/key-store.ts"],"names":[],"mappings":"AAiBA,MAAM,OAAO,WAAW;IACL,UAAU,CAAS;IACnB,QAAQ,CAAe;IACvB,GAAG,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC9C,IAAI,GAAG,CAAC,CAAC;IACT,MAAM,GAAG,CAAC,CAAC;IAEnB,YAAY,OAAwB,EAAE;QACpC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC;QAC3C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAChC,CAAC;IAED,GAAG,CAAC,OAAgB,EAAE,SAAqB;QACzC,IAAI,SAAS,CAAC,MAAM,KAAK,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QACzF,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC;YAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAA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K,EAAE,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;CACF"}
|
package/dist/signer.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ScopeId } from '@orqenix/mesh-transport-core';
|
|
2
|
+
export interface Ed25519SignerOptions {
|
|
3
|
+
fromScope: ScopeId;
|
|
4
|
+
privateKey: CryptoKey;
|
|
5
|
+
}
|
|
6
|
+
export declare class Ed25519Signer {
|
|
7
|
+
readonly fromScope: ScopeId;
|
|
8
|
+
private readonly privateKey;
|
|
9
|
+
constructor(opts: Ed25519SignerOptions);
|
|
10
|
+
signScopeProof(requestId: string, toScope: ScopeId): Promise<string>;
|
|
11
|
+
}
|
|
12
|
+
export type SignFn = (requestId: string, toScope: ScopeId) => Promise<string>;
|
|
13
|
+
export declare function makeSignFn(signer: Ed25519Signer): SignFn;
|
|
14
|
+
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAG5D,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,SAAS,CAAC;CACvB;AAED,qBAAa,aAAa;IACxB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;gBAE3B,IAAI,EAAE,oBAAoB;IAKhC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;CAK3E;AAED,MAAM,MAAM,MAAM,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAE9E,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAExD"}
|
package/dist/signer.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { b64urlEncode, ed25519Sign } from './ed25519.js';
|
|
2
|
+
export class Ed25519Signer {
|
|
3
|
+
fromScope;
|
|
4
|
+
privateKey;
|
|
5
|
+
constructor(opts) {
|
|
6
|
+
this.fromScope = opts.fromScope;
|
|
7
|
+
this.privateKey = opts.privateKey;
|
|
8
|
+
}
|
|
9
|
+
async signScopeProof(requestId, toScope) {
|
|
10
|
+
const canonical = new TextEncoder().encode(`${requestId}.${toScope}`);
|
|
11
|
+
const sig = await ed25519Sign(this.privateKey, canonical);
|
|
12
|
+
return b64urlEncode(sig);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function makeSignFn(signer) {
|
|
16
|
+
return (requestId, toScope) => signer.signScopeProof(requestId, toScope);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=signer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAOzD,MAAM,OAAO,aAAa;IACf,SAAS,CAAU;IACX,UAAU,CAAY;IAEvC,YAAY,IAA0B;QACpC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,SAAiB,EAAE,OAAgB;QACtD,MAAM,SAAS,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,SAAS,IAAI,OAAO,EAAE,CAAC,CAAC;QACtE,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAC1D,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;CACF;AAID,MAAM,UAAU,UAAU,CAAC,MAAqB;IAC9C,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type CapabilityToken, type ScopeId } from '@orqenix/mesh-transport-core';
|
|
2
|
+
import { type CapabilityTokenFields } from './capability-token.js';
|
|
3
|
+
import { LRUKeyStore } from './key-store.js';
|
|
4
|
+
export interface VerifyInput {
|
|
5
|
+
capability: CapabilityToken | string;
|
|
6
|
+
fromScope: ScopeId;
|
|
7
|
+
toScope: ScopeId;
|
|
8
|
+
method: string;
|
|
9
|
+
now?: () => number;
|
|
10
|
+
}
|
|
11
|
+
export interface VerifyOk {
|
|
12
|
+
ok: true;
|
|
13
|
+
token: CapabilityTokenFields;
|
|
14
|
+
}
|
|
15
|
+
export interface VerifyDenied {
|
|
16
|
+
ok: false;
|
|
17
|
+
code: string;
|
|
18
|
+
message: string;
|
|
19
|
+
}
|
|
20
|
+
export type VerifyResult = VerifyOk | VerifyDenied;
|
|
21
|
+
export type DelegationHook = (token: CapabilityTokenFields) => Promise<VerifyResult>;
|
|
22
|
+
export interface CapabilityVerifierOptions {
|
|
23
|
+
keyStore: LRUKeyStore;
|
|
24
|
+
delegation?: DelegationHook;
|
|
25
|
+
}
|
|
26
|
+
export declare class CapabilityVerifier {
|
|
27
|
+
private readonly keyStore;
|
|
28
|
+
private readonly delegation?;
|
|
29
|
+
private globCache;
|
|
30
|
+
constructor(opts: CapabilityVerifierOptions);
|
|
31
|
+
verify(input: VerifyInput): Promise<VerifyResult>;
|
|
32
|
+
private methodAllowed;
|
|
33
|
+
}
|
|
34
|
+
export declare function throwOnDenied(result: VerifyResult): asserts result is VerifyOk;
|
|
35
|
+
//# sourceMappingURL=verifier.d.ts.map
|
|
@@ -0,0 +1 @@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AAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,IAAI,QAAQ,CAI9E"}
|
package/dist/verifier.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { CapabilityError, ErrorCode, } from '@orqenix/mesh-transport-core';
|
|
2
|
+
import { b64urlDecode, ed25519Verify, importEd25519PublicKey } from './ed25519.js';
|
|
3
|
+
import { canonicalSigningBytes, decodeCapabilityToken, } from './capability-token.js';
|
|
4
|
+
import { compileGlob, matches } from './glob.js';
|
|
5
|
+
export class CapabilityVerifier {
|
|
6
|
+
keyStore;
|
|
7
|
+
delegation;
|
|
8
|
+
globCache = new Map();
|
|
9
|
+
constructor(opts) {
|
|
10
|
+
this.keyStore = opts.keyStore;
|
|
11
|
+
this.delegation = opts.delegation;
|
|
12
|
+
}
|
|
13
|
+
async verify(input) {
|
|
14
|
+
const now = (input.now ?? Date.now)();
|
|
15
|
+
let token;
|
|
16
|
+
try {
|
|
17
|
+
if (!input.capability || (typeof input.capability === 'string' && input.capability.length === 0)) {
|
|
18
|
+
return denied(ErrorCode.CAP_MISSING, 'capability missing');
|
|
19
|
+
}
|
|
20
|
+
token = decodeCapabilityToken(String(input.capability));
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
return denied(ErrorCode.CAP_MALFORMED, sanitizeMessage(String(e.message)));
|
|
24
|
+
}
|
|
25
|
+
if (token.nbf !== undefined && now < token.nbf) {
|
|
26
|
+
return denied(ErrorCode.CAP_EXPIRED, 'token not yet valid');
|
|
27
|
+
}
|
|
28
|
+
if (now >= token.exp) {
|
|
29
|
+
return denied(ErrorCode.CAP_EXPIRED, 'token expired');
|
|
30
|
+
}
|
|
31
|
+
const pubRaw = await this.keyStore.get(token.iss);
|
|
32
|
+
if (!pubRaw) {
|
|
33
|
+
return denied(ErrorCode.CAP_SIG_INVALID, 'signature invalid');
|
|
34
|
+
}
|
|
35
|
+
let sigOk = false;
|
|
36
|
+
try {
|
|
37
|
+
const publicKey = await importEd25519PublicKey(pubRaw);
|
|
38
|
+
const sigBytes = b64urlDecode(token.sig);
|
|
39
|
+
const signed = canonicalSigningBytes(token);
|
|
40
|
+
sigOk = await ed25519Verify(publicKey, sigBytes, signed);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
sigOk = false;
|
|
44
|
+
}
|
|
45
|
+
if (!sigOk)
|
|
46
|
+
return denied(ErrorCode.CAP_SIG_INVALID, 'signature invalid');
|
|
47
|
+
if (token.sub !== input.fromScope) {
|
|
48
|
+
return denied(ErrorCode.CAP_SUBJECT_MISMATCH, 'subject mismatch');
|
|
49
|
+
}
|
|
50
|
+
if (token.iss !== input.toScope) {
|
|
51
|
+
return denied(ErrorCode.CAP_ISSUER_MISMATCH, 'issuer mismatch');
|
|
52
|
+
}
|
|
53
|
+
if (!this.methodAllowed(token.caps, input.method)) {
|
|
54
|
+
return denied(ErrorCode.CAP_METHOD_NOT_ALLOWED, 'method not allowed');
|
|
55
|
+
}
|
|
56
|
+
if (this.delegation) {
|
|
57
|
+
const r = await this.delegation(token);
|
|
58
|
+
if (!r.ok)
|
|
59
|
+
return r;
|
|
60
|
+
}
|
|
61
|
+
return { ok: true, token };
|
|
62
|
+
}
|
|
63
|
+
methodAllowed(caps, method) {
|
|
64
|
+
for (const c of caps) {
|
|
65
|
+
let g = this.globCache.get(c);
|
|
66
|
+
if (!g) {
|
|
67
|
+
try {
|
|
68
|
+
g = compileGlob(c);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
this.globCache.set(c, g);
|
|
74
|
+
}
|
|
75
|
+
if (matches(g, method))
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export function throwOnDenied(result) {
|
|
82
|
+
if (!result.ok) {
|
|
83
|
+
throw new CapabilityError(result.message, result.code);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function denied(code, message) {
|
|
87
|
+
return { ok: false, code, message };
|
|
88
|
+
}
|
|
89
|
+
function sanitizeMessage(s) {
|
|
90
|
+
return s.split('\n')[0].slice(0, 160);
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=verifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifier.js","sourceRoot":"","sources":["../src/verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,SAAS,GAIV,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EACL,qBAAqB,EACrB,qBAAqB,GAEtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4BjD,MAAM,OAAO,kBAAkB;IACZ,QAAQ,CAAc;IACtB,UAAU,CAAkB;IACrC,SAAS,GAAG,IAAI,GAAG,EAA0C,CAAC;IAEtE,YAAY,IAA+B;QACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAkB;QAC7B,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAEtC,IAAI,KAA4B,CAAC;QACjC,IAAI,CAAC;YACH,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;gBACjG,OAAO,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;YAC7D,CAAC;YACD,KAAK,GAAG,qBAAqB,CAAC,MAAM,CAAC,KA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CAAC;CACF;AAED,MAAM,UAAU,aAAa,CAAC,MAAoB;IAChD,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAsB,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,IAAY,EAAE,OAAe;IAC3C,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACtC,CAAC;AAED,SAAS,eAAe,CAAC,CAAS;IAChC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACxC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@orqenix/transport-security",
|
|
3
|
+
"version": "0.6.0-phase-6",
|
|
4
|
+
"description": "Ed25519 IdentityVerifier and capability verification pipeline for Orqenix Phase 6. Replaces the no-op verifier/signer placeholders used in Parts 2 and 3-4.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"CHANGELOG.md"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"msgpackr": "^1.11.0",
|
|
23
|
+
"@orqenix/mesh-transport-core": "0.6.0-phase-6"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^22.7.0",
|
|
27
|
+
"@vitest/coverage-v8": "^2.1.0",
|
|
28
|
+
"tsx": "^4.19.0",
|
|
29
|
+
"typescript": "^5.6.0",
|
|
30
|
+
"vitest": "^2.1.0"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public",
|
|
34
|
+
"provenance": false
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=22.0.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc -p tsconfig.json",
|
|
41
|
+
"test": "vitest run --coverage",
|
|
42
|
+
"gate:G40": "vitest run test/G40-gate-wrapper.test.ts --reporter verbose",
|
|
43
|
+
"bench": "vitest run test/bench.p95.test.ts"
|
|
44
|
+
}
|
|
45
|
+
}
|