@astrale-os/kernel-client 0.6.0-beta.67 → 0.6.0-beta.69
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/auth/auth.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export interface AuthApi {
|
|
|
12
12
|
whoami(options?: RequestOptions): Promise<Identity & Authentication>;
|
|
13
13
|
whois(input: WhoisInput, options?: RequestOptions): Promise<(Identity & Authentication) | null>;
|
|
14
14
|
can(input: PolicyDecisionInput, options?: RequestOptions): Promise<boolean>;
|
|
15
|
+
/** One ordered decision per check; batches above the Kernel bound are split and rejoined. */
|
|
16
|
+
can(input: readonly PolicyDecisionInput[], options?: RequestOptions): Promise<readonly boolean[]>;
|
|
15
17
|
impersonate(input: ImpersonateOptions, options?: RequestOptions): Promise<MintedCredential>;
|
|
16
18
|
mint(input: MintOptions, options?: RequestOptions): Promise<MintedCredential>;
|
|
17
19
|
delegate(identity: IdentityId, input: DelegateOptions, options?: RequestOptions): Promise<MintedCredential>;
|
|
@@ -9,5 +9,8 @@ export interface PolicyDecisionInput {
|
|
|
9
9
|
}
|
|
10
10
|
export declare const IDENTITY_CAN_PATH: NodePath;
|
|
11
11
|
export declare function authorizationApi(call: AuthCall): Readonly<{
|
|
12
|
-
can
|
|
12
|
+
can: {
|
|
13
|
+
(input: PolicyDecisionInput, options?: RequestOptions): Promise<boolean>;
|
|
14
|
+
(input: readonly PolicyDecisionInput[], options?: RequestOptions): Promise<readonly boolean[]>;
|
|
15
|
+
};
|
|
13
16
|
}>;
|
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
import { Path } from '@astrale-os/kernel-core/path';
|
|
2
|
+
import { MAXIMUM_CHECKS } from '@astrale-os/kernel-core/schema/kernel/syscalls/contracts';
|
|
2
3
|
import { identity } from '@astrale-os/kernel-core/schema/kernel/syscalls/references';
|
|
3
4
|
const identityOwner = Path.project(identity.whoami.owner);
|
|
4
5
|
export const IDENTITY_CAN_PATH = Path.staticMethod(identityOwner, identity.can.name).raw;
|
|
5
6
|
export function authorizationApi(call) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const output = (await call(IDENTITY_CAN_PATH,
|
|
7
|
+
async function can(input, options) {
|
|
8
|
+
if (!isBatch(input)) {
|
|
9
|
+
const output = (await call(IDENTITY_CAN_PATH, check(input), options));
|
|
9
10
|
return output.allowed;
|
|
10
|
-
}
|
|
11
|
-
|
|
11
|
+
}
|
|
12
|
+
const batches = [];
|
|
13
|
+
for (let offset = 0; offset < input.length; offset += MAXIMUM_CHECKS) {
|
|
14
|
+
batches.push(input.slice(offset, offset + MAXIMUM_CHECKS));
|
|
15
|
+
}
|
|
16
|
+
const decided = await Promise.all(batches.map(async (batch) => {
|
|
17
|
+
const output = (await call(IDENTITY_CAN_PATH, Object.freeze({ checks: batch.map(check) }), options));
|
|
18
|
+
if (output.decisions.length !== batch.length) {
|
|
19
|
+
throw new TypeError('Identity.can answered a different number of decisions.');
|
|
20
|
+
}
|
|
21
|
+
return output.decisions.map(({ allowed }) => allowed);
|
|
22
|
+
}));
|
|
23
|
+
return Object.freeze(decided.flat());
|
|
24
|
+
}
|
|
25
|
+
return Object.freeze({ can });
|
|
26
|
+
}
|
|
27
|
+
function isBatch(input) {
|
|
28
|
+
return Array.isArray(input);
|
|
29
|
+
}
|
|
30
|
+
function check(input) {
|
|
31
|
+
return Object.freeze({ policy: policyPath(input.policy), object: input.object });
|
|
12
32
|
}
|
|
13
33
|
function policyPath(input) {
|
|
14
34
|
return input instanceof Path || typeof input === 'string'
|
|
@@ -97,9 +97,23 @@ export class SessionDispatcher {
|
|
|
97
97
|
...sessionTransportOptions(operation, options.idempotencyKey),
|
|
98
98
|
routing: learned.route.via,
|
|
99
99
|
};
|
|
100
|
+
// The source has admitted this fingerprint against the exact Publication carried by Via.
|
|
101
|
+
// Pin that revision at the destination so existing Workers can execute the same admitted
|
|
102
|
+
// callable without understanding the newer fingerprint Target representation. The cache
|
|
103
|
+
// remains partitioned by the original fingerprint, and stale recovery re-admits it at source.
|
|
104
|
+
const destinationCall = typeof call.target !== 'string' && call.target.fingerprint !== undefined
|
|
105
|
+
? {
|
|
106
|
+
...call,
|
|
107
|
+
target: invocationProtocol.Target({
|
|
108
|
+
callable: call.target.callable,
|
|
109
|
+
revision: learned.route.via.publication.revision,
|
|
110
|
+
...(call.target.instance === undefined ? {} : { instance: call.target.instance }),
|
|
111
|
+
}),
|
|
112
|
+
}
|
|
113
|
+
: call;
|
|
100
114
|
const result = await runSessionOperation(operation, () => trace === undefined
|
|
101
|
-
? authenticated(envelope.client, learned.credential).dispatch(
|
|
102
|
-
: dispatchTrace(envelope.client, learned.credential,
|
|
115
|
+
? authenticated(envelope.client, learned.credential).dispatch(destinationCall, requestOptions)
|
|
116
|
+
: dispatchTrace(envelope.client, learned.credential, destinationCall, requestOptions, trace));
|
|
103
117
|
if (result.kind === 'redirect') {
|
|
104
118
|
throw new ClientError('A destination redirect is invalid; only the source Kernel may redirect.');
|
|
105
119
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/kernel-client",
|
|
3
|
-
"version": "0.6.0-beta.
|
|
3
|
+
"version": "0.6.0-beta.69",
|
|
4
4
|
"description": "Universal Client — protocol-first, transport-agnostic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astrale",
|
|
@@ -65,14 +65,14 @@
|
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@astrale-os/kernel-core": "0.9.0-beta.
|
|
69
|
-
"@astrale-os/kernel-dsl": "0.2.0-beta.
|
|
70
|
-
"@astrale-os/kernel-protocol": "0.5.0-beta.
|
|
68
|
+
"@astrale-os/kernel-core": "0.9.0-beta.52",
|
|
69
|
+
"@astrale-os/kernel-dsl": "0.2.0-beta.37",
|
|
70
|
+
"@astrale-os/kernel-protocol": "0.5.0-beta.58",
|
|
71
71
|
"@tanstack/pacer": "0.20.1",
|
|
72
72
|
"msgpackr": "^2.0.5"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@astrale-os/kernel-server": "0.5.0-beta.
|
|
75
|
+
"@astrale-os/kernel-server": "0.5.0-beta.60",
|
|
76
76
|
"@astrale/typescript-config": "npm:@jsr/astrale__typescript-config@~1.1.0",
|
|
77
77
|
"@types/node": "^22.0.0",
|
|
78
78
|
"typescript": "7.0.2",
|