@anhlp/alp-runtime 0.0.0-beta.1 → 0.10.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.
package/NOTICE DELETED
@@ -1,7 +0,0 @@
1
- ALP
2
- Copyright 2026 Lê Phúc Anh
3
-
4
- Licensed under the Apache License, Version 2.0 (see LICENSE).
5
-
6
- Where a package's bundled files include third-party code, its
7
- THIRD-PARTY-NOTICES.txt names each package and reproduces its licence.
@@ -1,2 +0,0 @@
1
- /** ALP's permission gate, not an OS sandbox or protection against concurrent link swaps. */
2
- export declare function writablePath(file: unknown, workdir: string): boolean;
@@ -1,44 +0,0 @@
1
- // packages/runtime/src/permission-path.ts
2
- import { lstatSync, realpathSync } from "node:fs";
3
- import path from "node:path";
4
- import os from "node:os";
5
- function canonical(file) {
6
- const absolute = path.isAbsolute(file) ? file : `${process.cwd()}${path.sep}${file}`;
7
- let current = path.parse(absolute).root;
8
- for (const part of absolute.slice(current.length).split(process.platform === "win32" ? /[\\/]/ : /\//)) {
9
- if (!part || part === ".") continue;
10
- if (part === "..") {
11
- current = path.dirname(current);
12
- continue;
13
- }
14
- const candidate = path.join(current, part);
15
- try {
16
- current = realpathSync.native(candidate);
17
- } catch (error) {
18
- if (error?.code !== "ENOENT") throw error;
19
- try {
20
- if (lstatSync(candidate).isSymbolicLink()) throw new Error("Dangling symlink");
21
- } catch (infoError) {
22
- if (infoError?.code !== "ENOENT") throw infoError;
23
- }
24
- current = candidate;
25
- }
26
- }
27
- return current;
28
- }
29
- var contains = (root, file) => {
30
- const relative = path.relative(root, file);
31
- return relative === "" || relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
32
- };
33
- function writablePath(file, workdir) {
34
- if (typeof file !== "string" || !file.trim() || file.includes("\0")) return false;
35
- try {
36
- const target = canonical(path.isAbsolute(file) ? file : `${workdir}${path.sep}${file}`);
37
- return contains(canonical(workdir), target) || contains(canonical(os.tmpdir()), target);
38
- } catch {
39
- return false;
40
- }
41
- }
42
- export {
43
- writablePath
44
- };
@@ -1,37 +0,0 @@
1
- import { lstatSync, realpathSync } from 'node:fs';
2
- import path from 'node:path';
3
- import os from 'node:os';
4
-
5
- /** Resolve each component before '..', matching filesystem traversal through links.
6
- * Missing leaves are allowed for creation; dangling links and other errors fail closed. */
7
- function canonical(file: string): string {
8
- const absolute = path.isAbsolute(file) ? file : `${process.cwd()}${path.sep}${file}`;
9
- let current = path.parse(absolute).root;
10
- for (const part of absolute.slice(current.length).split(process.platform === 'win32' ? /[\\/]/ : /\//)) {
11
- if (!part || part === '.') continue;
12
- if (part === '..') { current = path.dirname(current); continue; }
13
- const candidate = path.join(current, part);
14
- try { current = realpathSync.native(candidate); }
15
- catch (error: any) {
16
- if (error?.code !== 'ENOENT') throw error;
17
- try {
18
- if (lstatSync(candidate).isSymbolicLink()) throw new Error('Dangling symlink');
19
- } catch (infoError: any) { if (infoError?.code !== 'ENOENT') throw infoError; }
20
- current = candidate;
21
- }
22
- }
23
- return current;
24
- }
25
- const contains = (root: string, file: string) => {
26
- const relative = path.relative(root, file);
27
- return relative === '' || (relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative));
28
- };
29
-
30
- /** ALP's permission gate, not an OS sandbox or protection against concurrent link swaps. */
31
- export function writablePath(file: unknown, workdir: string): boolean {
32
- if (typeof file !== 'string' || !file.trim() || file.includes('\0')) return false;
33
- try {
34
- const target = canonical(path.isAbsolute(file) ? file : `${workdir}${path.sep}${file}`);
35
- return contains(canonical(workdir), target) || contains(canonical(os.tmpdir()), target);
36
- } catch { return false; }
37
- }