keycloakify 7.6.3 → 7.6.5

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.
Files changed (54) hide show
  1. package/README.md +2 -0
  2. package/account/kcContext/KcContext.d.ts +1 -0
  3. package/account/kcContext/KcContext.js.map +1 -1
  4. package/account/kcContext/kcContextMocks.js +1 -0
  5. package/account/kcContext/kcContextMocks.js.map +1 -1
  6. package/bin/eject-keycloak-page.js +6 -6
  7. package/bin/eject-keycloak-page.js.map +1 -1
  8. package/bin/keycloakify/BuildOptions.d.ts +1 -1
  9. package/bin/keycloakify/BuildOptions.js +5 -5
  10. package/bin/keycloakify/BuildOptions.js.map +1 -1
  11. package/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl +3 -2
  12. package/bin/keycloakify/generateFtl/generateFtl.d.ts +2 -0
  13. package/bin/keycloakify/generateFtl/generateFtl.js +5 -5
  14. package/bin/keycloakify/generateFtl/generateFtl.js.map +1 -1
  15. package/bin/keycloakify/generateJavaStackFiles.d.ts +1 -1
  16. package/bin/keycloakify/generateJavaStackFiles.js +3 -3
  17. package/bin/keycloakify/generateJavaStackFiles.js.map +1 -1
  18. package/bin/keycloakify/generateKeycloakThemeResources.d.ts +2 -0
  19. package/bin/keycloakify/generateKeycloakThemeResources.js +4 -3
  20. package/bin/keycloakify/generateKeycloakThemeResources.js.map +1 -1
  21. package/bin/keycloakify/keycloakify.js +8 -2
  22. package/bin/keycloakify/keycloakify.js.map +1 -1
  23. package/bin/keycloakify/parsedPackageJson.d.ts +89 -2
  24. package/bin/keycloakify/parsedPackageJson.js +4 -4
  25. package/bin/keycloakify/parsedPackageJson.js.map +1 -1
  26. package/bin/tools/jar.d.ts +19 -3
  27. package/bin/tools/jar.js +151 -58
  28. package/bin/tools/jar.js.map +1 -1
  29. package/bin/tools/walk.d.ts +2 -2
  30. package/bin/tools/walk.js +3 -3
  31. package/bin/tools/walk.js.map +1 -1
  32. package/login/kcContext/KcContext.d.ts +1 -0
  33. package/login/kcContext/KcContext.js.map +1 -1
  34. package/login/kcContext/kcContextMocks.js +1 -0
  35. package/login/kcContext/kcContextMocks.js.map +1 -1
  36. package/package.json +5 -6
  37. package/src/account/kcContext/KcContext.ts +1 -0
  38. package/src/account/kcContext/kcContextMocks.ts +1 -0
  39. package/src/bin/eject-keycloak-page.ts +2 -4
  40. package/src/bin/keycloakify/BuildOptions.ts +2 -2
  41. package/src/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl +3 -2
  42. package/src/bin/keycloakify/generateFtl/generateFtl.ts +6 -3
  43. package/src/bin/keycloakify/generateJavaStackFiles.ts +4 -4
  44. package/src/bin/keycloakify/generateKeycloakThemeResources.ts +5 -2
  45. package/src/bin/keycloakify/keycloakify.ts +10 -2
  46. package/src/bin/keycloakify/parsedPackageJson.ts +3 -3
  47. package/src/bin/tools/jar.ts +58 -65
  48. package/src/bin/tools/walk.ts +5 -5
  49. package/src/login/kcContext/KcContext.ts +1 -0
  50. package/src/login/kcContext/kcContextMocks.ts +1 -0
  51. package/bin/tools/zip.d.ts +0 -29
  52. package/bin/tools/zip.js +0 -330
  53. package/bin/tools/zip.js.map +0 -1
  54. package/src/bin/tools/zip.ts +0 -246
@@ -1,246 +0,0 @@
1
- import { Transform, TransformOptions } from "stream";
2
- import { createReadStream } from "fs";
3
- import { stat } from "fs/promises";
4
- import { Blob } from "buffer";
5
-
6
- import { deflateBuffer, deflateStream } from "./deflate";
7
-
8
- /**
9
- * Zip source
10
- * @property filename the name of the entry in the archie
11
- * @property path of the source file, if the source is an actual file
12
- * @property data the actual data buffer, if the source is constructed in-memory
13
- */
14
- export type ZipSource = { path: string } & ({ fsPath: string } | { data: Buffer });
15
-
16
- export type ZipRecord = {
17
- path: string;
18
- compression: "deflate" | undefined;
19
- uncompressedSize: number;
20
- compressedSize?: number;
21
- crc32?: number;
22
- offset?: number;
23
- };
24
-
25
- /**
26
- * @returns the actual byte size of an string
27
- */
28
- function utf8size(s: string) {
29
- return new Blob([s]).size;
30
- }
31
-
32
- /**
33
- * @param record
34
- * @returns a buffer representing a Zip local header
35
- * @link https://en.wikipedia.org/wiki/ZIP_(file_format)#Local_file_header
36
- */
37
- function localHeader(record: ZipRecord) {
38
- const { path, compression, uncompressedSize } = record;
39
- const filenameSize = utf8size(path);
40
- const buf = Buffer.alloc(30 + filenameSize);
41
-
42
- buf.writeUInt32LE(0x04_03_4b_50, 0); // local header signature
43
- buf.writeUInt16LE(10, 4); // min version
44
- // we write 0x08 because crc and compressed size are unknown at
45
- buf.writeUInt16LE(0x08, 6); // general purpose bit flag
46
- buf.writeUInt16LE(compression ? ({ "deflate": 8 } as const)[compression] : 0, 8);
47
- buf.writeUInt16LE(0, 10); // modified time
48
- buf.writeUInt16LE(0, 12); // modified date
49
- buf.writeUInt32LE(0, 14); // crc unknown
50
- buf.writeUInt32LE(0, 18); // compressed size unknown
51
- buf.writeUInt32LE(uncompressedSize, 22);
52
- buf.writeUInt16LE(filenameSize, 26);
53
- buf.writeUInt16LE(0, 28); // extra field length
54
- buf.write(path, 30, "utf-8");
55
-
56
- return buf;
57
- }
58
-
59
- /**
60
- * @param record
61
- * @returns a buffer representing a Zip central header
62
- * @link https://en.wikipedia.org/wiki/ZIP_(file_format)#Central_directory_file_header
63
- */
64
- function centralHeader(record: ZipRecord) {
65
- const { path, compression, crc32, compressedSize, uncompressedSize, offset } = record;
66
- const filenameSize = utf8size(path);
67
- const buf = Buffer.alloc(46 + filenameSize);
68
- const isFile = !path.endsWith("/");
69
-
70
- if (typeof offset === "undefined") throw new Error("Illegal argument");
71
-
72
- // we don't want to deal with possibly messed up file or directory
73
- // permissions, so we ignore the original permissions
74
- const externalAttr = isFile ? 0x81a40000 : 0x41ed0000;
75
-
76
- buf.writeUInt32LE(0x0201_4b50, 0); // central header signature
77
- buf.writeUInt16LE(10, 4); // version
78
- buf.writeUInt16LE(10, 6); // min version
79
- buf.writeUInt16LE(0, 8); // general purpose bit flag
80
- buf.writeUInt16LE(compression ? ({ "deflate": 8 } as const)[compression] : 0, 10);
81
- buf.writeUInt16LE(0, 12); // modified time
82
- buf.writeUInt16LE(0, 14); // modified date
83
- buf.writeUInt32LE(crc32 || 0, 16);
84
- buf.writeUInt32LE(compressedSize || 0, 20);
85
- buf.writeUInt32LE(uncompressedSize, 24);
86
- buf.writeUInt16LE(filenameSize, 28);
87
- buf.writeUInt16LE(0, 30); // extra field length
88
- buf.writeUInt16LE(0, 32); // comment field length
89
- buf.writeUInt16LE(0, 34); // disk number
90
- buf.writeUInt16LE(0, 36); // internal
91
- buf.writeUInt32LE(externalAttr, 38); // external
92
- buf.writeUInt32LE(offset, 42); // offset where file starts
93
- buf.write(path, 46, "utf-8");
94
-
95
- return buf;
96
- }
97
-
98
- /**
99
- * @returns a buffer representing an Zip End-Of-Central-Directory block
100
- * @link https://en.wikipedia.org/wiki/ZIP_(file_format)#End_of_central_directory_record_(EOCD)
101
- */
102
- function eocd({ offset, cdSize, nRecords }: { offset: number; cdSize: number; nRecords: number }) {
103
- const buf = Buffer.alloc(22);
104
- buf.writeUint32LE(0x06054b50, 0); // eocd signature
105
- buf.writeUInt16LE(0, 4); // disc number
106
- buf.writeUint16LE(0, 6); // disc where central directory starts
107
- buf.writeUint16LE(nRecords, 8); // records on this disc
108
- buf.writeUInt16LE(nRecords, 10); // records total
109
- buf.writeUInt32LE(cdSize, 12); // byte size of cd
110
- buf.writeUInt32LE(offset, 16); // cd offset
111
- buf.writeUint16LE(0, 20); // comment length
112
-
113
- return buf;
114
- }
115
-
116
- /**
117
- * @returns a stream Transform, which reads a stream of ZipRecords and
118
- * writes a bytestream
119
- */
120
- export default function zip() {
121
- /**
122
- * This is called when the input stream of ZipSource items is finished.
123
- * Will write central directory and end-of-central-direcotry blocks.
124
- */
125
- const final = () => {
126
- // write central directory
127
- let cdSize = 0;
128
- for (const record of records) {
129
- const head = centralHeader(record);
130
- zipTransform.push(head);
131
- cdSize += head.length;
132
- }
133
-
134
- // write end-of-central-directory
135
- zipTransform.push(eocd({ offset, cdSize, nRecords: records.length }));
136
- // signal stream end
137
- zipTransform.push(null);
138
- };
139
-
140
- /**
141
- * Write a directory entry to the archive
142
- * @param path
143
- */
144
- const writeDir = async (path: string) => {
145
- const record: ZipRecord = {
146
- path: path + "/",
147
- offset,
148
- compression: undefined,
149
- uncompressedSize: 0
150
- };
151
- const head = localHeader(record);
152
- zipTransform.push(head);
153
- records.push(record);
154
- offset += head.length;
155
- };
156
-
157
- /**
158
- * Write a file entry to the archive
159
- * @param archivePath path of the file in archive
160
- * @param fsPath path to file on filesystem
161
- * @param size of the actual, uncompressed, file
162
- */
163
- const writeFile = async (archivePath: string, fsPath: string, size: number) => {
164
- const record: ZipRecord = {
165
- path: archivePath,
166
- offset,
167
- compression: "deflate",
168
- uncompressedSize: size
169
- };
170
- const head = localHeader(record);
171
- zipTransform.push(head);
172
-
173
- const { crc32, compressedSize } = await deflateStream(createReadStream(fsPath), chunk => zipTransform.push(chunk));
174
-
175
- record.crc32 = crc32;
176
- record.compressedSize = compressedSize;
177
- records.push(record);
178
- offset += head.length + compressedSize;
179
- };
180
-
181
- /**
182
- * Write archive record based on filesystem file or directory
183
- * @param archivePath path of item in archive
184
- * @param fsPath path to item on filesystem
185
- */
186
- const writeFromPath = async (archivePath: string, fsPath: string) => {
187
- const fileStats = await stat(fsPath);
188
- fileStats.isDirectory() ? await writeDir(archivePath) /**/ : await writeFile(archivePath, fsPath, fileStats.size) /**/;
189
- };
190
-
191
- /**
192
- * Write archive record based on data in a buffer
193
- * @param path
194
- * @param data
195
- */
196
- const writeFromBuffer = async (path: string, data: Buffer) => {
197
- const { deflated, crc32 } = await deflateBuffer(data);
198
- const record: ZipRecord = {
199
- path,
200
- compression: "deflate",
201
- crc32,
202
- uncompressedSize: data.length,
203
- compressedSize: deflated.length,
204
- offset
205
- };
206
- const head = localHeader(record);
207
- zipTransform.push(head);
208
- zipTransform.push(deflated);
209
- records.push(record);
210
- offset += head.length + deflated.length;
211
- };
212
-
213
- /**
214
- * Write an archive record
215
- * @param source
216
- */
217
- const writeRecord = async (source: ZipSource) => {
218
- if ("fsPath" in source) await writeFromPath(source.path, source.fsPath);
219
- else if ("data" in source) await writeFromBuffer(source.path, source.data);
220
- else throw new Error("Illegal argument " + typeof source + " " + JSON.stringify(source));
221
- };
222
-
223
- /**
224
- * The actual stream transform function
225
- * @param source
226
- * @param _ encoding, ignored
227
- * @param cb
228
- */
229
- const transform: TransformOptions["transform"] = async (source: ZipSource, _, cb) => {
230
- await writeRecord(source);
231
- cb();
232
- };
233
-
234
- /** offset and records keep local state during processing */
235
- let offset = 0;
236
- const records: ZipRecord[] = [];
237
-
238
- const zipTransform = new Transform({
239
- readableObjectMode: false,
240
- writableObjectMode: true,
241
- transform,
242
- final
243
- });
244
-
245
- return zipTransform;
246
- }