@comper/mermaid-parser 1.0.10 → 1.0.12
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/crypto-stub.d.ts +22 -0
- package/dist/crypto-stub.d.ts.map +1 -0
- package/dist/crypto-stub.js +89 -0
- package/dist/crypto-stub.js.map +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight crypto stub for validation-only environments without Node.js APIs
|
|
3
|
+
* Provides minimal UUID generation and hashing without cryptographic guarantees
|
|
4
|
+
*/
|
|
5
|
+
declare function randomUUID(): string;
|
|
6
|
+
declare function randomFillSync(buffer: Uint8Array): Uint8Array;
|
|
7
|
+
declare class HashStub {
|
|
8
|
+
private algorithm;
|
|
9
|
+
private data;
|
|
10
|
+
constructor(algorithm: string);
|
|
11
|
+
update(data: string | Uint8Array, encoding?: string): this;
|
|
12
|
+
digest(encoding?: 'hex' | 'base64' | 'buffer'): string | Buffer;
|
|
13
|
+
}
|
|
14
|
+
declare function createHash(algorithm: string): HashStub;
|
|
15
|
+
export { randomUUID, randomFillSync, createHash };
|
|
16
|
+
declare const _default: {
|
|
17
|
+
randomUUID: typeof randomUUID;
|
|
18
|
+
randomFillSync: typeof randomFillSync;
|
|
19
|
+
createHash: typeof createHash;
|
|
20
|
+
};
|
|
21
|
+
export default _default;
|
|
22
|
+
//# sourceMappingURL=crypto-stub.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto-stub.d.ts","sourceRoot":"","sources":["../src/crypto-stub.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,iBAAS,UAAU,IAAI,MAAM,CAkB5B;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAMtD;AAID,cAAM,QAAQ;IACZ,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,IAAI,CAAc;gBAEd,SAAS,EAAE,MAAM;IAI7B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAU1D,MAAM,CAAC,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM;CA2BhE;AAED,iBAAS,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,CAE/C;AAGD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC;;;;;;AAClD,wBAIE"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight crypto stub for validation-only environments without Node.js APIs
|
|
3
|
+
* Provides minimal UUID generation and hashing without cryptographic guarantees
|
|
4
|
+
*/
|
|
5
|
+
// Simple pseudo-random UUID v4 generator (NOT cryptographically secure)
|
|
6
|
+
// Only use this for validation/testing, not for production security purposes
|
|
7
|
+
function randomUUID() {
|
|
8
|
+
// Generate a pseudo-random UUID v4
|
|
9
|
+
const hex = '0123456789abcdef';
|
|
10
|
+
let uuid = '';
|
|
11
|
+
for (let i = 0; i < 36; i++) {
|
|
12
|
+
if (i === 8 || i === 13 || i === 18 || i === 23) {
|
|
13
|
+
uuid += '-';
|
|
14
|
+
}
|
|
15
|
+
else if (i === 14) {
|
|
16
|
+
uuid += '4'; // Version 4
|
|
17
|
+
}
|
|
18
|
+
else if (i === 19) {
|
|
19
|
+
uuid += hex[(Math.random() * 4 | 8)]; // Variant bits
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
uuid += hex[Math.random() * 16 | 0];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return uuid;
|
|
26
|
+
}
|
|
27
|
+
function randomFillSync(buffer) {
|
|
28
|
+
// Fill with pseudo-random values
|
|
29
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
30
|
+
buffer[i] = Math.random() * 256 | 0;
|
|
31
|
+
}
|
|
32
|
+
return buffer;
|
|
33
|
+
}
|
|
34
|
+
// Simple deterministic hash stub (NOT cryptographically secure)
|
|
35
|
+
// For validation purposes only - returns consistent mock hashes
|
|
36
|
+
class HashStub {
|
|
37
|
+
algorithm;
|
|
38
|
+
data = '';
|
|
39
|
+
constructor(algorithm) {
|
|
40
|
+
this.algorithm = algorithm;
|
|
41
|
+
}
|
|
42
|
+
update(data, encoding) {
|
|
43
|
+
if (typeof data === 'string') {
|
|
44
|
+
this.data += data;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// Convert Uint8Array to string
|
|
48
|
+
this.data += String.fromCharCode(...data);
|
|
49
|
+
}
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
digest(encoding) {
|
|
53
|
+
// Create a simple hash-like string based on the data
|
|
54
|
+
// This is NOT a real hash, just a deterministic mock for validation
|
|
55
|
+
let hash = 0;
|
|
56
|
+
for (let i = 0; i < this.data.length; i++) {
|
|
57
|
+
hash = ((hash << 5) - hash) + this.data.charCodeAt(i);
|
|
58
|
+
hash = hash & hash; // Convert to 32-bit integer
|
|
59
|
+
}
|
|
60
|
+
// Generate a deterministic "hash" string
|
|
61
|
+
const hashHex = Math.abs(hash).toString(16).padStart(8, '0');
|
|
62
|
+
// Extend to appropriate length for the algorithm
|
|
63
|
+
const length = this.algorithm === 'md5' ? 32 : 64; // md5: 128 bits, sha256: 256 bits
|
|
64
|
+
const fullHash = hashHex.repeat(Math.ceil(length / hashHex.length)).slice(0, length);
|
|
65
|
+
if (encoding === 'hex' || !encoding) {
|
|
66
|
+
return fullHash;
|
|
67
|
+
}
|
|
68
|
+
else if (encoding === 'base64') {
|
|
69
|
+
// Convert hex to base64-like string (simplified)
|
|
70
|
+
return btoa(fullHash.match(/.{2}/g)?.map(h => String.fromCharCode(parseInt(h, 16))).join('') || '');
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// Return as Buffer-like object (Uint8Array)
|
|
74
|
+
const bytes = new Uint8Array(fullHash.match(/.{2}/g)?.map(h => parseInt(h, 16)) || []);
|
|
75
|
+
return bytes; // Cast to Buffer type
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function createHash(algorithm) {
|
|
80
|
+
return new HashStub(algorithm);
|
|
81
|
+
}
|
|
82
|
+
// Export both named and default
|
|
83
|
+
export { randomUUID, randomFillSync, createHash };
|
|
84
|
+
export default {
|
|
85
|
+
randomUUID,
|
|
86
|
+
randomFillSync,
|
|
87
|
+
createHash,
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=crypto-stub.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto-stub.js","sourceRoot":"","sources":["../src/crypto-stub.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wEAAwE;AACxE,6EAA6E;AAC7E,SAAS,UAAU;IACjB,mCAAmC;IACnC,MAAM,GAAG,GAAG,kBAAkB,CAAC;IAC/B,IAAI,IAAI,GAAG,EAAE,CAAC;IAEd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;YAChD,IAAI,IAAI,GAAG,CAAC;QACd,CAAC;aAAM,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;YACpB,IAAI,IAAI,GAAG,CAAC,CAAC,YAAY;QAC3B,CAAC;aAAM,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;YACpB,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe;QACvD,CAAC;aAAM,CAAC;YACN,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CA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C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC;AAClD,eAAe;IACb,UAAU;IACV,cAAc;IACd,UAAU;CACX,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comper/mermaid-parser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "Lightweight Mermaid diagram validator for server-side environments - validation without rendering",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
"types": "./dist/dompurify-stub.d.ts",
|
|
17
17
|
"import": "./dist/dompurify-stub.js",
|
|
18
18
|
"default": "./dist/dompurify-stub.js"
|
|
19
|
+
},
|
|
20
|
+
"./crypto-stub": {
|
|
21
|
+
"types": "./dist/crypto-stub.d.ts",
|
|
22
|
+
"import": "./dist/crypto-stub.js",
|
|
23
|
+
"default": "./dist/crypto-stub.js"
|
|
19
24
|
}
|
|
20
25
|
},
|
|
21
26
|
"files": [
|