@ai-ecoverse/slicc-kernel 1.176.2 → 1.178.0

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.
@@ -30,6 +30,7 @@ export type { RouteTable } from './kernel/net/routes.js';
30
30
  export { SEALED_FETCH_VERSION, type SealedFetchHook, type SealedFetchRequest, type SealedOption, } from './kernel/net/sealed-fetch.js';
31
31
  export type { NetworkUplink, ResolveAnswer, ResolveFamily, UplinkTraits, } from './kernel/net/uplink.js';
32
32
  export type { SealedAbortReason, SealedCaller, SealedHook, SealedRequest, SealedRequester, } from './kernel/sealed.js';
33
+ export type { SealedOAuthConfig, SealedOAuthError, SealedOAuthIdentity, SealedOAuthReply, SealedOAuthRequest, SealedOAuthState, SealedOAuthStatus, } from './kernel/sealed-oauth.js';
33
34
  export type { ConnectorStamp } from './kernel/socket.js';
34
35
  export type { HostfsEvent, HostfsGrant, HostfsGrantHook, HostfsPortGrant, HostfsTransport, } from './mount/hostfs.js';
35
36
  export { serveHostfsPort } from './mount/hostfs.js';
@@ -44,7 +45,7 @@ export type { JsCred, JsSyncContext, JsSyncFile } from './process/js/js-sync.js'
44
45
  export type { JsThread, JsThreadContext, JsThreadSpawnOptions } from './process/js/js-thread.js';
45
46
  export type { JsTermios, JsTty, JsTtySize } from './process/js/js-tty.js';
46
47
  export type { JsWebSocket, JsWebSocketClose, JsWebSocketMessage, JsWebSocketOptions, } from './process/js/js-websocket.js';
47
- export type { ApproveHook, SudoAnswer, SudoDenial, SudoRequest, SudoStdin } from './sudo.js';
48
+ export type { ApproveHook, SudoAnswer, SudoApproval, SudoDenial, SudoReply, SudoRequest, SudoStdin, } from './sudo.js';
48
49
  export { type FetchTransportOptions, fetchTransport, type HeaderList, type NetworkExit, type NetworkRedirectPolicy, type NetworkRequest, type NetworkResponse, type NetworkTraits, type NetworkTransport, type NetworkWebSocket, type NetworkWebSocketRequest, } from './transport.js';
49
50
  export type { Account, AddGroup, AddUser, Group, RemoveUser } from './users.js';
50
51
  export interface NetworkOptions {
@@ -0,0 +1,74 @@
1
+ export declare const SEALED_OAUTH_TIMEOUT_MS = 45000;
2
+ export declare const SEALED_OAUTH_OPS: ReadonlySet<string>;
3
+ export interface SealedOAuthIdentity {
4
+ name: string;
5
+ provider: string;
6
+ account: string;
7
+ }
8
+ export interface SealedOAuthConfig {
9
+ tokenUrl: string;
10
+ clientId: string;
11
+ authMethod: 'none';
12
+ scope?: string;
13
+ resource?: string;
14
+ }
15
+ export type SealedOAuthRequest = {
16
+ v: 1;
17
+ } & ({
18
+ op: 'capabilities';
19
+ } | (SealedOAuthIdentity & {
20
+ op: 'oauthGrant';
21
+ accessToken: string;
22
+ refreshToken?: string;
23
+ tokenType?: string;
24
+ expiresAt?: number;
25
+ oauth: SealedOAuthConfig;
26
+ }) | (SealedOAuthIdentity & {
27
+ op: 'oauthStatus' | 'oauthRefresh' | 'oauthRemove';
28
+ }));
29
+ export type SealedOAuthState = 'ready' | 'refreshing' | 'expired' | 'reauth-required' | 'removed' | 'locked';
30
+ export interface SealedOAuthStatus {
31
+ v: 1;
32
+ placeholder: string;
33
+ state: SealedOAuthState;
34
+ expiresAt: number | null;
35
+ refreshable: boolean;
36
+ }
37
+ declare const MESSAGES: {
38
+ readonly EINVAL: 'Invalid OAuth request';
39
+ readonly ENOENT: 'OAuth credential not found';
40
+ readonly EEXIST: 'OAuth credential identity conflicts';
41
+ readonly EACCES: 'OAuth operation refused';
42
+ readonly EAGAIN: 'OAuth credential changed; try again';
43
+ readonly ENOTSUP: 'OAuth operation is not supported';
44
+ readonly ENOTCONN: 'Vault is unavailable';
45
+ readonly ETIMEDOUT: 'Vault request timed out';
46
+ readonly EIO: 'Invalid vault reply';
47
+ };
48
+ declare const CAUSES: {
49
+ readonly 'vault-locked': 'Vault is locked';
50
+ readonly 'oauth-reauth-required': 'OAuth sign-in is required';
51
+ readonly 'oauth-refresh-failed': 'OAuth refresh failed';
52
+ };
53
+ export interface SealedOAuthError {
54
+ v: 1;
55
+ error: {
56
+ code: keyof typeof MESSAGES;
57
+ cause?: keyof typeof CAUSES;
58
+ message: string;
59
+ };
60
+ }
61
+ export type SealedOAuthReply = SealedOAuthStatus | {
62
+ v: 1;
63
+ removed: true;
64
+ } | {
65
+ v: 1;
66
+ capabilities: {
67
+ kernelOAuth?: 1;
68
+ };
69
+ } | SealedOAuthError;
70
+ export declare function sealedOAuthOperation(op: string): boolean;
71
+ export declare function validateSealedOAuth(req: Record<string, unknown>): void;
72
+ export declare function sealedOAuthError(code?: keyof typeof MESSAGES, cause?: keyof typeof CAUSES): SealedOAuthError;
73
+ export declare function sealedOAuthReply(op: string, value: unknown): SealedOAuthReply;
74
+ export {};
@@ -89,6 +89,7 @@ export declare class SealedBroker {
89
89
  readonly tickets: TicketBook;
90
90
  readonly sessions: SessionScrubs;
91
91
  askTimeoutMs: number;
92
+ oauthTimeoutMs: number;
92
93
  userOf: (uid: number) => Promise<string | undefined>;
93
94
  factsOf: (pid: number) => Promise<SealedProcessFacts | undefined>;
94
95
  constructor(hook: SealedHook | undefined, users: UsersMode, timeoutMs?: number, tagOf?: (pid: number) => readonly string[] | undefined);
@@ -76,6 +76,9 @@ export interface LauncherOptions {
76
76
  embedder?: EmbedderHook;
77
77
  approve?: ApproveHook;
78
78
  sudoTimeoutMs?: number;
79
+ sudoClock?: {
80
+ now(): number;
81
+ };
79
82
  protect?: Protection;
80
83
  cron?: CronOptions;
81
84
  moduleUrl?: ModuleUrlMaker;
@@ -395,6 +398,8 @@ export declare class Launcher {
395
398
  private threadsOf;
396
399
  private crontab;
397
400
  private sudo;
401
+ private timestampOwner;
402
+ private startedOf;
398
403
  private visudo;
399
404
  private spawner;
400
405
  private childGroup;
@@ -29,11 +29,12 @@ export type { ClipboardHook, ClipboardStamp } from './kernel/clipboard.js';
29
29
  export type { EmbedderHook, EmbedderKindPolicy, EmbedderReply, EmbedderRequest, EmbedderStamp, } from './kernel/embedder.js';
30
30
  export { SEALED_FETCH_VERSION, type SealedFetchHook, type SealedFetchRequest, type SealedOption, } from './kernel/net/sealed-fetch.js';
31
31
  export type { SealedAbortReason, SealedCaller, SealedHook, SealedRequest, SealedRequester, } from './kernel/sealed.js';
32
+ export type { SealedOAuthConfig, SealedOAuthError, SealedOAuthIdentity, SealedOAuthReply, SealedOAuthRequest, SealedOAuthState, SealedOAuthStatus, } from './kernel/sealed-oauth.js';
32
33
  export type { ConnectorStamp } from './kernel/socket.js';
33
34
  export type { HostfsEvent, HostfsGrant, HostfsGrantHook, HostfsPortGrant, HostfsTransport, } from './mount/hostfs.js';
34
35
  export { serveHostfsPort } from './mount/hostfs.js';
35
36
  export type { MountEntry, MountSpec } from './mount/mount-fs.js';
36
- export type { ApproveHook, SudoAnswer, SudoDenial, SudoRequest, SudoStdin } from './sudo.js';
37
+ export type { ApproveHook, SudoAnswer, SudoApproval, SudoDenial, SudoReply, SudoRequest, SudoStdin, } from './sudo.js';
37
38
  export type { NetworkRedirectPolicy } from './transport.js';
38
39
  export { fetchTransport, type NetworkTransport } from './transport.js';
39
40
  export { memoryRoot };
@@ -70,6 +71,11 @@ export interface NodeKernelOptions {
70
71
  cron?: {
71
72
  clock?: CronClock;
72
73
  };
74
+ sudo?: {
75
+ clock?: {
76
+ now(): number;
77
+ };
78
+ };
73
79
  compileCache?: string | false;
74
80
  warmWorker?: boolean;
75
81
  warmWorkers?: number;
@@ -177,6 +177,8 @@ export type JsSudoAnswer = {
177
177
  list: string;
178
178
  } | {
179
179
  run: string[];
180
+ } | {
181
+ done: true;
180
182
  } | {
181
183
  pid: number;
182
184
  };
@@ -0,0 +1,28 @@
1
+ import type { TimestampType } from './sudoers.js';
2
+ export declare const TIMESTAMPS_MAX = 64;
3
+ export interface TimestampOwner {
4
+ uid: number;
5
+ terminal?: {
6
+ tty: string;
7
+ sid: number;
8
+ started: number;
9
+ } | undefined;
10
+ parent?: {
11
+ pid: number;
12
+ started: number;
13
+ } | undefined;
14
+ }
15
+ export interface TimestampPolicy {
16
+ type: TimestampType;
17
+ minutes: number;
18
+ }
19
+ export declare function timestampKey(owner: TimestampOwner, type: TimestampType): string | undefined;
20
+ export declare class Timestamps {
21
+ private readonly users;
22
+ private readonly now;
23
+ constructor(now: () => number);
24
+ current(owner: TimestampOwner, policy: TimestampPolicy): boolean;
25
+ stamp(owner: TimestampOwner, policy: TimestampPolicy): boolean;
26
+ invalidate(owner: TimestampOwner, type: TimestampType): void;
27
+ remove(uid: number): void;
28
+ }
@@ -1,5 +1,6 @@
1
1
  import type { KernelFs, UsersMode } from './fs/types.js';
2
2
  import type { Cred } from './kernel/cred.js';
3
+ import { type TimestampOwner } from './sudo-timestamp.js';
3
4
  import { type UserDb } from './users.js';
4
5
  export { SUDOERS, SUDOERS_D } from './sudoers.js';
5
6
  export declare const SECURE_PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
@@ -23,6 +24,8 @@ export interface SudoRequest {
23
24
  always: boolean;
24
25
  stdin?: SudoStdin;
25
26
  rootOnly?: Record<string, boolean>;
27
+ validate?: true;
28
+ timestamp?: true;
26
29
  }
27
30
  export type SudoStdin = 'tty' | 'none' | 'pipe' | 'file';
28
31
  export type SudoAnswer = 'once' | 'always' | 'deny';
@@ -30,9 +33,14 @@ export interface SudoDenial {
30
33
  answer: 'deny';
31
34
  message: string;
32
35
  }
36
+ export interface SudoApproval {
37
+ answer: 'once' | 'always';
38
+ timestamp: true;
39
+ }
40
+ export type SudoReply = SudoAnswer | SudoDenial | SudoApproval;
33
41
  export type ApproveHook = (req: SudoRequest, options: {
34
42
  signal: AbortSignal;
35
- }) => SudoAnswer | SudoDenial | Promise<SudoAnswer | SudoDenial>;
43
+ }) => SudoReply | Promise<SudoReply>;
36
44
  export interface SudoCall {
37
45
  op: 'proc-sudo';
38
46
  args: string[];
@@ -54,6 +62,8 @@ export type SudoResult = {
54
62
  list: string;
55
63
  } | {
56
64
  run: string[];
65
+ } | {
66
+ done: true;
57
67
  } | {
58
68
  grant: SudoGrant;
59
69
  notice?: string;
@@ -63,6 +73,8 @@ export interface SudoCaller {
63
73
  pid: number;
64
74
  tags?: readonly string[] | undefined;
65
75
  tty?: string | null | undefined;
76
+ terminal?: TimestampOwner['terminal'];
77
+ parent?: TimestampOwner['parent'];
66
78
  stdin: SudoStdin;
67
79
  report?: ((line: string) => Promise<void>) | undefined;
68
80
  }
@@ -89,11 +101,13 @@ export interface SudoOptions {
89
101
  approve?: ApproveHook | undefined;
90
102
  timeoutMs?: number | undefined;
91
103
  warn?: (message: string) => void;
104
+ now?: (() => number) | undefined;
92
105
  }
93
106
  export declare class Sudo {
94
107
  private readonly o;
95
108
  private readonly warned;
96
109
  private readonly pending;
110
+ private readonly timestamps;
97
111
  private next;
98
112
  constructor(options: SudoOptions);
99
113
  private warn;
@@ -114,6 +128,11 @@ export declare class Sudo {
114
128
  private untrusted;
115
129
  private locate;
116
130
  request(caller: SudoCaller, call: SudoCall, signal: AbortSignal): Promise<SudoResult>;
131
+ private command;
132
+ private validate;
133
+ private pendingFor;
134
+ private stamped;
135
+ private logged;
117
136
  private always;
118
137
  private listed;
119
138
  private ask;
@@ -16,8 +16,27 @@ export interface Rule {
16
16
  stdin?: 'none';
17
17
  cmnd: Command | '*';
18
18
  }
19
+ export type TimestampType = 'tty' | 'ppid' | 'global';
20
+ export interface Settings {
21
+ timestampTimeout?: number;
22
+ timestampType?: TimestampType;
23
+ }
24
+ export interface DefaultsEntry {
25
+ who: string[] | null;
26
+ settings: Settings;
27
+ params: string[];
28
+ }
29
+ export interface Resolved {
30
+ timestampTimeout: number;
31
+ timestampType: TimestampType;
32
+ matching: DefaultsEntry[];
33
+ }
34
+ export declare const TIMESTAMP_TIMEOUT = 5;
35
+ export declare const TIMESTAMP_TYPE: TimestampType;
19
36
  export type PolicyLine = {
20
37
  rules: Rule[];
38
+ } | {
39
+ defaults: DefaultsEntry;
21
40
  } | {
22
41
  error: string;
23
42
  } | null;
@@ -26,12 +45,16 @@ export declare function splitWords(text: string): string[] | undefined;
26
45
  export declare function quoteWord(word: string): string;
27
46
  export declare function commandMatches(cmnd: Command | '*', argv: readonly string[]): boolean;
28
47
  export declare function commandText(cmnd: Command): string;
48
+ export declare function resolveDefaults(entries: readonly DefaultsEntry[], applies: (who: string) => boolean): Resolved;
49
+ export declare function defaultsText(entries: readonly DefaultsEntry[]): string[];
29
50
  export declare function parseLine(line: string, file?: string): PolicyLine;
30
51
  export interface PolicyError {
31
52
  line: number;
32
53
  message: string;
33
54
  }
34
- export declare function parsePolicy(text: string, file?: string): {
55
+ export interface Policy {
35
56
  rules: Rule[];
57
+ defaults: DefaultsEntry[];
36
58
  errors: PolicyError[];
37
- };
59
+ }
60
+ export declare function parsePolicy(text: string, file?: string): Policy;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-kernel",
3
- "version": "1.176.2",
3
+ "version": "1.178.0",
4
4
  "description": "SLICC's wasm-realm kernel: run Emscripten programs in the browser against OPFS, with fork, spawn, pipes and waitpid",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -70,7 +70,7 @@
70
70
  },
71
71
  "devDependencies": {
72
72
  "@ai-ecoverse/py-numpy": "2.5.4-4",
73
- "@ai-ecoverse/slicc-cdp": "1.47.2",
73
+ "@ai-ecoverse/slicc-cdp": "1.47.4",
74
74
  "@ai-ecoverse/slicc-scrub": "1.1.0",
75
75
  "@ai-ecoverse/slicc-shared-web": "2.13.10",
76
76
  "@ai-ecoverse/wasi-cargo": "0.99.0-6",
@@ -78,7 +78,7 @@
78
78
  "@ai-ecoverse/wasi-ripgrep": "15.2.0-5",
79
79
  "@ai-ecoverse/wasi-rustc": "1.98.1-10",
80
80
  "@ai-ecoverse/wasi-zig": "0.16.0-20",
81
- "@ai-ecoverse/wasix-python": "3.15.0-7",
81
+ "@ai-ecoverse/wasix-python": "3.15.0-8",
82
82
  "@ai-ecoverse/wasm-bash": "5.3.0-23",
83
83
  "@ai-ecoverse/wasm-coreutils": "9.12.0-15",
84
84
  "@ai-ecoverse/wasm-curl": "8.22.0-10",