@ianacaburian/generate-key-file 0.1.2 → 1.0.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/README.md +30 -9
- package/dist/index.cjs +76 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +74 -36
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Ports juce_KeyGeneration::generateKeyFile() to node.
|
|
4
4
|
|
|
5
|
-

|
|
6
|
-

|
|
7
|
-

|
|
5
|
+
[](https://github.com/ianacaburian/generate-key-file/actions)
|
|
6
|
+
[](https://www.npmjs.com/package/@ianacaburian/generate-key-file)
|
|
7
|
+
[](https://twitter.com/intent/tweet?text=Need%20to%20auth%20a%20JUCE%20app%20in%20nodejs%20%3F%20Check%20out%20generate-key-file%20by%20%40ianacaburian%20%20&url=https%3A%2F%2Fgithub.com%2Fianacaburian%2Fgenerate-key-file)
|
|
9
8
|
|
|
10
9
|
## Installation
|
|
11
10
|
|
|
@@ -15,7 +14,15 @@ npm i @ianacaburian/generate-key-file
|
|
|
15
14
|
|
|
16
15
|
## Usage
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
### `generateKeyFile`
|
|
18
|
+
|
|
19
|
+
- Signature:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
generateKeyFile(params: GenerateKeyFileParams, date: Date = new Date()) => string
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- Example:
|
|
19
26
|
|
|
20
27
|
```
|
|
21
28
|
import { generateKeyFile } from '@ianacaburian/generate-key-file'
|
|
@@ -54,7 +61,15 @@ const keyFileContent = generateKeyFile({
|
|
|
54
61
|
*/
|
|
55
62
|
```
|
|
56
63
|
|
|
57
|
-
|
|
64
|
+
### `generateExpiringKeyFile`
|
|
65
|
+
|
|
66
|
+
- Signature:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
generateExpiringKeyFile(params: GenerateExpiringKeyFileParams, date: Date = new Date()) => string
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- Example:
|
|
58
73
|
|
|
59
74
|
```
|
|
60
75
|
import { generateExpiringKeyFile } from '@ianacaburian/generate-key-file'
|
|
@@ -106,10 +121,16 @@ npm run open:test/console # Open test/console project in Xcode.
|
|
|
106
121
|
npm run install:test/console # Build and install the test/console bins.
|
|
107
122
|
```
|
|
108
123
|
|
|
109
|
-
Optional: Set "FC_NUM_RUMS" (default=1) to specify how many times to run
|
|
110
|
-
(randomly generated) propery-based test -- see
|
|
111
|
-
[fast-check](https://github.com/dubzzz/fast-check).
|
|
124
|
+
- Optional: Set "FC_NUM_RUMS" (default=1) to specify how many times to run
|
|
125
|
+
each (randomly generated) propery-based test -- see
|
|
126
|
+
[fast-check](https://github.com/dubzzz/fast-check).
|
|
112
127
|
|
|
113
128
|
```
|
|
114
129
|
FC_NUM_RUNS=1000 npm run test # Run each fc test 1000 times.
|
|
115
130
|
```
|
|
131
|
+
|
|
132
|
+
- Optional: Set "FC_SEED" (default=1) to specify the seed for each fc test.
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
FC_SEED=2 npm run test # Run each fc test with seed=2.
|
|
136
|
+
```
|
package/dist/index.cjs
CHANGED
|
@@ -20,10 +20,44 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
|
-
|
|
23
|
+
generateExpiringKeyFile: () => generateExpiringKeyFile,
|
|
24
|
+
generateKeyFile: () => generateKeyFile
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(src_exports);
|
|
26
27
|
|
|
28
|
+
// src/juce/JuceDateString.ts
|
|
29
|
+
var JuceDateString = class {
|
|
30
|
+
static inHexMs(date) {
|
|
31
|
+
return date.getTime().toString(16);
|
|
32
|
+
}
|
|
33
|
+
static inFormattedComment(date) {
|
|
34
|
+
const months = [
|
|
35
|
+
"Jan",
|
|
36
|
+
"Feb",
|
|
37
|
+
"Mar",
|
|
38
|
+
"Apr",
|
|
39
|
+
"May",
|
|
40
|
+
"Jun",
|
|
41
|
+
"Jul",
|
|
42
|
+
"Aug",
|
|
43
|
+
"Sep",
|
|
44
|
+
"Oct",
|
|
45
|
+
"Nov",
|
|
46
|
+
"Dec"
|
|
47
|
+
];
|
|
48
|
+
const day = date.getDate().toString();
|
|
49
|
+
const month = months[date.getMonth()];
|
|
50
|
+
const year = date.getFullYear();
|
|
51
|
+
let hours = date.getHours();
|
|
52
|
+
const minutes = date.getMinutes().toString().padStart(2, "0");
|
|
53
|
+
const seconds = date.getSeconds().toString().padStart(2, "0");
|
|
54
|
+
const ampm = hours >= 12 ? "pm" : "am";
|
|
55
|
+
hours = hours % 12;
|
|
56
|
+
hours = hours ? hours : 12;
|
|
57
|
+
return `${day} ${month} ${year} ${hours}:${minutes}:${seconds}${ampm}`;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
27
61
|
// src/juce/JuceKeyFileUtils.ts
|
|
28
62
|
var import_fast_xml_parser = require("fast-xml-parser");
|
|
29
63
|
|
|
@@ -94,8 +128,8 @@ var xmlAttributeValueProcessor = (value) => (
|
|
|
94
128
|
var xmlBuilder = new import_fast_xml_parser.XMLBuilder({
|
|
95
129
|
ignoreAttributes: false,
|
|
96
130
|
suppressEmptyNode: true,
|
|
131
|
+
// processEntities is disabled since it doesn't port to juce as is
|
|
97
132
|
processEntities: false,
|
|
98
|
-
// Disabled since it doesn't port to juce as is
|
|
99
133
|
attributeValueProcessor: (_, value) => xmlAttributeValueProcessor(value)
|
|
100
134
|
});
|
|
101
135
|
var JuceKeyFileUtils = class {
|
|
@@ -113,7 +147,6 @@ var JuceKeyFileUtils = class {
|
|
|
113
147
|
[`@_${machineNumbersAttributeName}`]: machineNumbers,
|
|
114
148
|
"@_app": appName,
|
|
115
149
|
"@_date": date,
|
|
116
|
-
// Does not affect key file decryption
|
|
117
150
|
...expiryTime ? { "@_expiryTime": expiryTime } : {}
|
|
118
151
|
}
|
|
119
152
|
};
|
|
@@ -152,39 +185,6 @@ Expires: ${expiryTime}` : "");
|
|
|
152
185
|
}
|
|
153
186
|
};
|
|
154
187
|
|
|
155
|
-
// src/juce/JuceDateString.ts
|
|
156
|
-
var JuceDateString = class {
|
|
157
|
-
static inHexMs(date) {
|
|
158
|
-
return date.getTime().toString(16);
|
|
159
|
-
}
|
|
160
|
-
static inFormattedComment(date) {
|
|
161
|
-
const months = [
|
|
162
|
-
"Jan",
|
|
163
|
-
"Feb",
|
|
164
|
-
"Mar",
|
|
165
|
-
"Apr",
|
|
166
|
-
"May",
|
|
167
|
-
"Jun",
|
|
168
|
-
"Jul",
|
|
169
|
-
"Aug",
|
|
170
|
-
"Sep",
|
|
171
|
-
"Oct",
|
|
172
|
-
"Nov",
|
|
173
|
-
"Dec"
|
|
174
|
-
];
|
|
175
|
-
const day = date.getDate().toString();
|
|
176
|
-
const month = months[date.getMonth()];
|
|
177
|
-
const year = date.getFullYear();
|
|
178
|
-
let hours = date.getHours();
|
|
179
|
-
const minutes = date.getMinutes().toString().padStart(2, "0");
|
|
180
|
-
const seconds = date.getSeconds().toString().padStart(2, "0");
|
|
181
|
-
const ampm = hours >= 12 ? "pm" : "am";
|
|
182
|
-
hours = hours % 12;
|
|
183
|
-
hours = hours ? hours : 12;
|
|
184
|
-
return `${day} ${month} ${year} ${hours}:${minutes}:${seconds}${ampm}`;
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
|
|
188
188
|
// src/juce/JuceRSAKey.ts
|
|
189
189
|
var JuceRSAKey = class {
|
|
190
190
|
constructor(s) {
|
|
@@ -271,8 +271,47 @@ var JuceKeyGeneration = class {
|
|
|
271
271
|
);
|
|
272
272
|
}
|
|
273
273
|
};
|
|
274
|
+
|
|
275
|
+
// src/types.ts
|
|
276
|
+
var import_zod = require("zod");
|
|
277
|
+
var createKeyFileCommentParamsValidator = import_zod.z.object({
|
|
278
|
+
appName: import_zod.z.string().min(1),
|
|
279
|
+
userEmail: import_zod.z.string().min(1).email(),
|
|
280
|
+
userName: import_zod.z.string().min(1),
|
|
281
|
+
machineNumbers: import_zod.z.string().min(1)
|
|
282
|
+
});
|
|
283
|
+
var machineNumbersAttributeNameValidator = import_zod.z.enum([
|
|
284
|
+
"mach",
|
|
285
|
+
"expiring_mach"
|
|
286
|
+
]);
|
|
287
|
+
var createKeyFileContentLineParamsValidator = createKeyFileCommentParamsValidator.extend({
|
|
288
|
+
machineNumbersAttributeName: machineNumbersAttributeNameValidator
|
|
289
|
+
});
|
|
290
|
+
var rsaKeyComponentsValidator = import_zod.z.string().refine(
|
|
291
|
+
// Ports juce::RSAKey::RSAKey() and juce::RSAKey::applyToValue()
|
|
292
|
+
(x) => x.includes(",") && x.split(",").every((p) => !JuceBigInteger.fromHex(p).isZero())
|
|
293
|
+
);
|
|
294
|
+
var generateKeyFileParamsValidator = createKeyFileCommentParamsValidator.extend({
|
|
295
|
+
privateKey: rsaKeyComponentsValidator
|
|
296
|
+
});
|
|
297
|
+
var generateExpiringKeyFileParamsValidator = generateKeyFileParamsValidator.extend({
|
|
298
|
+
expiryTime: import_zod.z.date()
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
// src/generateKeyFile.ts
|
|
302
|
+
var generateKeyFile = (params, date = /* @__PURE__ */ new Date()) => {
|
|
303
|
+
const paramsParse = generateKeyFileParamsValidator.parse(params);
|
|
304
|
+
return JuceKeyGeneration.generateKeyFile(paramsParse, date);
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
// src/generateExpiringKeyFile.ts
|
|
308
|
+
var generateExpiringKeyFile = (params, date = /* @__PURE__ */ new Date()) => {
|
|
309
|
+
const paramsParse = generateExpiringKeyFileParamsValidator.parse(params);
|
|
310
|
+
return JuceKeyGeneration.generateExpiringKeyFile(paramsParse, date);
|
|
311
|
+
};
|
|
274
312
|
// Annotate the CommonJS export names for ESM import in node:
|
|
275
313
|
0 && (module.exports = {
|
|
276
|
-
|
|
314
|
+
generateExpiringKeyFile,
|
|
315
|
+
generateKeyFile
|
|
277
316
|
});
|
|
278
317
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/juce/JuceKeyFileUtils.ts","../src/juce/JuceBigInteger.ts","../src/juce/JuceDateString.ts","../src/juce/JuceRSAKey.ts","../src/juce/JuceKeyGeneration.ts"],"sourcesContent":["export * from './juce/JuceKeyGeneration'\nexport {\n type GenerateKeyFileParams,\n type GenerateExpiringKeyFileParams\n} from './types'\n","import { XMLBuilder } from 'fast-xml-parser'\nimport {\n CreateKeyFileCommentParams,\n CreateKeyFileContentLineParams\n} from 'src/types'\n\nimport { JuceBigInteger } from './JuceBigInteger'\nimport { JuceRSAKey } from './JuceRSAKey'\n\nconst XML_DECLARATION = '<?xml version=\"1.0\" encoding=\"UTF-8\"?>'\n\nconst legalXmlCharRegex =\n // Ports juce::XmlOutputFunctions::LegalCharLookupTable\n /^[a-zA-Z0-9 .,;:\\-()_+=?!$#@[\\]/|*%~{}'\\\\]$/\n\nconst xmlAttributeCharProcessor = (char: string): string =>\n // Ports juce::XmlOutputFunctions::escapeIllegalXMLChars()\n char.length !== 1\n ? ''\n : legalXmlCharRegex.test(char)\n ? char\n : char === '&'\n ? '&'\n : char === '\"'\n ? '"'\n : char === '>'\n ? '>'\n : char === '<'\n ? '<'\n : `&#${char.charCodeAt(0)};`\n\nconst xmlAttributeValueProcessor = (value: unknown): string =>\n // Ports juce::XmlOutputFunctions::escapeIllegalXMLChars()\n typeof value !== 'string'\n ? ''\n : value.split('').map(xmlAttributeCharProcessor).join('')\n\nconst xmlBuilder = new XMLBuilder({\n ignoreAttributes: false,\n suppressEmptyNode: true,\n processEntities: false, // Disabled since it doesn't port to juce as is\n attributeValueProcessor: (_, value) => xmlAttributeValueProcessor(value)\n})\n\nexport class JuceKeyFileUtils {\n static createKeyFileContentLine(\n {\n appName,\n userEmail,\n userName,\n machineNumbers,\n machineNumbersAttributeName\n }: CreateKeyFileContentLineParams,\n date: string,\n expiryTime?: string\n ): string {\n // Ports juce::KeyFileUtils::createKeyFileContent\n // and juce::KeyFileUtils::encryptXML\n const xml = {\n key: {\n '@_user': userName,\n '@_email': userEmail,\n [`@_${machineNumbersAttributeName}`]: machineNumbers,\n '@_app': appName,\n '@_date': date, // Does not affect key file decryption\n ...(expiryTime ? { '@_expiryTime': expiryTime } : {})\n }\n }\n return [XML_DECLARATION, xmlBuilder.build(xml).trim()].join(' ')\n }\n\n static createKeyFileComment(\n {\n appName,\n userEmail,\n userName,\n machineNumbers\n }: CreateKeyFileCommentParams,\n created: string,\n expiryTime?: string\n ): string {\n // Ports juce::KeyFileUtils::createKeyFileComment\n return (\n `Keyfile for ${appName}\\r\\n` +\n `${userName ? `User: ${userName}\\r\\n` : ''}` +\n `Email: ${userEmail}\\r\\n` +\n `Machine numbers: ${machineNumbers}\\r\\n` +\n `Created: ${created}` +\n (expiryTime ? `\\r\\nExpires: ${expiryTime}` : '')\n )\n }\n\n static encryptXMLLine(xmlLine: string, privateKey: JuceRSAKey): string {\n // Ports juce::KeyFileUtils::encryptXML\n const val = JuceBigInteger.fromUTF8MemoryBlock(xmlLine)\n privateKey.applyToValue(val)\n return val.toHex()\n }\n\n static createKeyFile(\n comment: string,\n xmlLine: string,\n rsaPrivateKey: JuceRSAKey\n ): string {\n // Ports juce::KeyFileUtils::createKeyFile\n let asHex = '#' + this.encryptXMLLine(xmlLine, rsaPrivateKey)\n\n const lines: string[] = []\n lines.push(comment)\n lines.push('')\n\n const charsPerLine = 70\n while (asHex.length > 0) {\n lines.push(asHex.substring(0, charsPerLine))\n asHex = asHex.substring(charsPerLine)\n }\n\n lines.push('')\n\n return lines.join('\\r\\n')\n }\n}\n","import { BigInteger as JSBN } from 'jsbn'\n\nexport class JuceBigInteger {\n constructor(public value: bigint = 0n) {}\n\n static fromJSBN(b: JSBN): JuceBigInteger {\n return JuceBigInteger.fromHex(b.toString(16))\n }\n\n toJSBN(): JSBN {\n return new JSBN(this.toHex(), 16)\n }\n\n static fromHex(hex: string): JuceBigInteger {\n const h = hex.trim()\n return new JuceBigInteger(h ? BigInt(`0x${h}`) : 0n)\n }\n\n toHex(): string {\n return this.value.toString(16)\n }\n\n static fromUTF8MemoryBlock(input: string): JuceBigInteger {\n // Ports juce::BigInteger::loadFromMemoryBlock()\n const u = Buffer.from(input, 'utf8')\n const b = new JuceBigInteger()\n for (let i = u.length - 1; i >= 0; i--) {\n b.value = (b.value << 8n) | BigInt(u[i])\n }\n return b\n }\n\n isZero(): boolean {\n return this.value === 0n\n }\n\n divideBy(divisor: JuceBigInteger, remainder: JuceBigInteger): void {\n // Ports juce::BigInteger::divideBy()\n if (divisor.isZero()) {\n this.value = 0n\n return\n }\n const b = this.toJSBN()\n const d = divisor.toJSBN()\n const [q, r] = b.divideAndRemainder(d)\n this.value = JuceBigInteger.fromJSBN(q).value\n remainder.value = JuceBigInteger.fromJSBN(r).value\n }\n\n exponentModulo(exponent: JuceBigInteger, modulus: JuceBigInteger): void {\n // Ports juce::BigInteger::exponentModulo()\n const b = this.toJSBN()\n const e = exponent.toJSBN()\n const m = modulus.toJSBN()\n const em = b.modPow(e, m)\n this.value = JuceBigInteger.fromJSBN(em).value\n }\n}\n","export class JuceDateString {\n static inHexMs(date: Date): string {\n // Ports juce::String::toHexString (juce::Time::getCurrentTime().toMilliseconds())\n return date.getTime().toString(16)\n }\n\n static inFormattedComment(date: Date): string {\n // Ports juce::Time::getCurrentTime().toString (true, true)\n // prettier-ignore\n const months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', \n 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]\n const day = date.getDate().toString()\n const month = months[date.getMonth()]\n const year = date.getFullYear()\n let hours = date.getHours()\n const minutes = date.getMinutes().toString().padStart(2, '0')\n const seconds = date.getSeconds().toString().padStart(2, '0')\n const ampm = hours >= 12 ? 'pm' : 'am'\n hours = hours % 12\n hours = hours ? hours : 12\n return `${day} ${month} ${year} ${hours}:${minutes}:${seconds}${ampm}`\n }\n}\n","// import { BigInteger as JSBN } from 'jsbn'\n\nimport { JuceBigInteger } from './JuceBigInteger'\n\nexport class JuceRSAKey {\n protected part1: JuceBigInteger\n protected part2: JuceBigInteger\n constructor(public s: string) {\n // Ports juce::RSAKey::RSAKey()\n if (s.includes(',')) {\n const [p1, p2] = s.split(',').map(p => JuceBigInteger.fromHex(p))\n this.part1 = p1\n this.part2 = p2\n } else {\n this.part1 = new JuceBigInteger()\n this.part2 = new JuceBigInteger()\n }\n }\n applyToValue(val: JuceBigInteger): void {\n // Ports juce::RSAKey::applyToValue()\n if (this.part1.isZero() || this.part2.isZero() || val.value <= 0n) {\n return\n }\n\n const result = new JuceBigInteger()\n\n while (!val.isZero()) {\n result.value *= this.part2.value\n\n const remainder = new JuceBigInteger()\n val.divideBy(this.part2, remainder)\n\n remainder.exponentModulo(this.part1, this.part2)\n\n result.value += remainder.value\n }\n\n val.value = result.value\n }\n}\n","import { JuceKeyFileUtils } from 'src/juce/JuceKeyFileUtils'\nimport { GenerateExpiringKeyFileParams, GenerateKeyFileParams } from 'src/types'\n\nimport { JuceDateString } from './JuceDateString'\nimport { JuceRSAKey } from './JuceRSAKey'\n\nexport class JuceKeyGeneration {\n static generateKeyFile(\n params: GenerateKeyFileParams,\n date: Date = new Date()\n ) {\n const xml = JuceKeyFileUtils.createKeyFileContentLine(\n {\n appName: params.appName,\n userEmail: params.userEmail,\n userName: params.userName,\n machineNumbers: params.machineNumbers,\n machineNumbersAttributeName: 'mach'\n },\n JuceDateString.inHexMs(date)\n )\n const comment = JuceKeyFileUtils.createKeyFileComment(\n {\n appName: params.appName,\n userEmail: params.userEmail,\n userName: params.userName,\n machineNumbers: params.machineNumbers\n },\n JuceDateString.inFormattedComment(date)\n )\n return JuceKeyFileUtils.createKeyFile(\n comment,\n xml,\n new JuceRSAKey(params.privateKey)\n )\n }\n\n static generateExpiringKeyFile(\n params: GenerateExpiringKeyFileParams,\n date: Date = new Date()\n ) {\n const xml = JuceKeyFileUtils.createKeyFileContentLine(\n {\n appName: params.appName,\n userEmail: params.userEmail,\n userName: params.userName,\n machineNumbers: params.machineNumbers,\n machineNumbersAttributeName: 'expiring_mach'\n },\n JuceDateString.inHexMs(date),\n JuceDateString.inHexMs(params.expiryTime)\n )\n const comment = JuceKeyFileUtils.createKeyFileComment(\n {\n appName: params.appName,\n userEmail: params.userEmail,\n userName: params.userName,\n machineNumbers: params.machineNumbers\n },\n JuceDateString.inFormattedComment(date),\n JuceDateString.inFormattedComment(params.expiryTime)\n )\n return JuceKeyFileUtils.createKeyFile(\n comment,\n xml,\n new JuceRSAKey(params.privateKey)\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,6BAA2B;;;ACA3B,kBAAmC;AAE5B,IAAM,iBAAN,MAAM,gBAAe;AAAA,EACxB,YAAmB,QAAgB,IAAI;AAApB;AAAA,EAAqB;AAAA,EAExC,OAAO,SAAS,GAAyB;AACrC,WAAO,gBAAe,QAAQ,EAAE,SAAS,EAAE,CAAC;AAAA,EAChD;AAAA,EAEA,SAAe;AACX,WAAO,IAAI,YAAAA,WAAK,KAAK,MAAM,GAAG,EAAE;AAAA,EACpC;AAAA,EAEA,OAAO,QAAQ,KAA6B;AACxC,UAAM,IAAI,IAAI,KAAK;AACnB,WAAO,IAAI,gBAAe,IAAI,OAAO,KAAK,CAAC,EAAE,IAAI,EAAE;AAAA,EACvD;AAAA,EAEA,QAAgB;AACZ,WAAO,KAAK,MAAM,SAAS,EAAE;AAAA,EACjC;AAAA,EAEA,OAAO,oBAAoB,OAA+B;AAEtD,UAAM,IAAI,OAAO,KAAK,OAAO,MAAM;AACnC,UAAM,I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AA,MACjC;AAAA,MACA,eAAe,QAAQ,IAAI;AAAA,MAC3B,eAAe,QAAQ,OAAO,UAAU;AAAA,IAC5C;AACA,UAAM,UAAU,iBAAiB;AAAA,MAC7B;AAAA,QACI,SAAS,OAAO;AAAA,QAChB,WAAW,OAAO;AAAA,QAClB,UAAU,OAAO;AAAA,QACjB,gBAAgB,OAAO;AAAA,MAC3B;AAAA,MACA,eAAe,mBAAmB,IAAI;AAAA,MACtC,eAAe,mBAAmB,OAAO,UAAU;AAAA,IACvD;AACA,WAAO,iBAAiB;AAAA,MACpB;AAAA,MACA;AAAA,MACA,IAAI,WAAW,OAAO,UAAU;AAAA,IACpC;AAAA,EACJ;AACJ;","names":["JSBN"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/juce/JuceDateString.ts","../src/juce/JuceKeyFileUtils.ts","../src/juce/JuceBigInteger.ts","../src/juce/JuceRSAKey.ts","../src/juce/JuceKeyGeneration.ts","../src/types.ts","../src/generateKeyFile.ts","../src/generateExpiringKeyFile.ts"],"sourcesContent":["export {\n type GenerateKeyFileParams,\n type GenerateExpiringKeyFileParams\n} from './types'\n\nexport { generateKeyFile } from './generateKeyFile'\nexport { generateExpiringKeyFile } from './generateExpiringKeyFile'\n","export class JuceDateString {\n static inHexMs(date: Date): string {\n // Ports juce::String::toHexString (juce::Time::getCurrentTime().toMilliseconds())\n return date.getTime().toString(16)\n }\n\n static inFormattedComment(date: Date): string {\n // Ports juce::Time::getCurrentTime().toString (true, true)\n // prettier-ignore\n const months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', \n 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]\n const day = date.getDate().toString()\n const month = months[date.getMonth()]\n const year = date.getFullYear()\n let hours = date.getHours()\n const minutes = date.getMinutes().toString().padStart(2, '0')\n const seconds = date.getSeconds().toString().padStart(2, '0')\n const ampm = hours >= 12 ? 'pm' : 'am'\n hours = hours % 12\n hours = hours ? hours : 12\n return `${day} ${month} ${year} ${hours}:${minutes}:${seconds}${ampm}`\n }\n}\n","import { XMLBuilder } from 'fast-xml-parser'\nimport {\n CreateKeyFileCommentParams,\n CreateKeyFileContentLineParams\n} from 'src/types'\n\nimport { JuceBigInteger } from './JuceBigInteger'\nimport { JuceRSAKey } from './JuceRSAKey'\n\nconst XML_DECLARATION = '<?xml version=\"1.0\" encoding=\"UTF-8\"?>'\n\nconst legalXmlCharRegex =\n // Ports juce::XmlOutputFunctions::LegalCharLookupTable\n /^[a-zA-Z0-9 .,;:\\-()_+=?!$#@[\\]/|*%~{}'\\\\]$/\n\nconst xmlAttributeCharProcessor = (char: string): string =>\n // Ports juce::XmlOutputFunctions::escapeIllegalXMLChars()\n char.length !== 1\n ? ''\n : legalXmlCharRegex.test(char)\n ? char\n : char === '&'\n ? '&'\n : char === '\"'\n ? '"'\n : char === '>'\n ? '>'\n : char === '<'\n ? '<'\n : `&#${char.charCodeAt(0)};`\n\nconst xmlAttributeValueProcessor = (value: unknown): string =>\n // Ports juce::XmlOutputFunctions::escapeIllegalXMLChars()\n typeof value !== 'string'\n ? ''\n : value.split('').map(xmlAttributeCharProcessor).join('')\n\nconst xmlBuilder = new XMLBuilder({\n ignoreAttributes: false,\n suppressEmptyNode: true,\n // processEntities is disabled since it doesn't port to juce as is\n processEntities: false,\n attributeValueProcessor: (_, value) => xmlAttributeValueProcessor(value)\n})\n\nexport class JuceKeyFileUtils {\n static createKeyFileContentLine(\n {\n appName,\n userEmail,\n userName,\n machineNumbers,\n machineNumbersAttributeName\n }: CreateKeyFileContentLineParams,\n date: string,\n expiryTime?: string\n ): string {\n // Ports juce::KeyFileUtils::createKeyFileContent\n // and juce::KeyFileUtils::encryptXML\n const xml = {\n key: {\n '@_user': userName,\n '@_email': userEmail,\n [`@_${machineNumbersAttributeName}`]: machineNumbers,\n '@_app': appName,\n '@_date': date,\n ...(expiryTime ? { '@_expiryTime': expiryTime } : {})\n }\n }\n return [XML_DECLARATION, xmlBuilder.build(xml).trim()].join(' ')\n }\n\n static createKeyFileComment(\n {\n appName,\n userEmail,\n userName,\n machineNumbers\n }: CreateKeyFileCommentParams,\n created: string,\n expiryTime?: string\n ): string {\n // Ports juce::KeyFileUtils::createKeyFileComment\n return (\n `Keyfile for ${appName}\\r\\n` +\n `${userName ? `User: ${userName}\\r\\n` : ''}` +\n `Email: ${userEmail}\\r\\n` +\n `Machine numbers: ${machineNumbers}\\r\\n` +\n `Created: ${created}` +\n (expiryTime ? `\\r\\nExpires: ${expiryTime}` : '')\n )\n }\n\n static encryptXMLLine(xmlLine: string, privateKey: JuceRSAKey): string {\n // Ports juce::KeyFileUtils::encryptXML\n const val = JuceBigInteger.fromUTF8MemoryBlock(xmlLine)\n privateKey.applyToValue(val)\n return val.toHex()\n }\n\n static createKeyFile(\n comment: string,\n xmlLine: string,\n rsaPrivateKey: JuceRSAKey\n ): string {\n // Ports juce::KeyFileUtils::createKeyFile\n let asHex = '#' + this.encryptXMLLine(xmlLine, rsaPrivateKey)\n\n const lines: string[] = []\n lines.push(comment)\n lines.push('')\n\n const charsPerLine = 70\n while (asHex.length > 0) {\n lines.push(asHex.substring(0, charsPerLine))\n asHex = asHex.substring(charsPerLine)\n }\n\n lines.push('')\n\n return lines.join('\\r\\n')\n }\n}\n","import { BigInteger as JSBN } from 'jsbn'\n\nexport class JuceBigInteger {\n constructor(public value: bigint = 0n) {}\n\n static fromJSBN(b: JSBN): JuceBigInteger {\n return JuceBigInteger.fromHex(b.toString(16))\n }\n\n toJSBN(): JSBN {\n return new JSBN(this.toHex(), 16)\n }\n\n static fromHex(hex: string): JuceBigInteger {\n const h = hex.trim()\n return new JuceBigInteger(h ? BigInt(`0x${h}`) : 0n)\n }\n\n toHex(): string {\n return this.value.toString(16)\n }\n\n static fromUTF8MemoryBlock(input: string): JuceBigInteger {\n // Ports juce::BigInteger::loadFromMemoryBlock()\n const u = Buffer.from(input, 'utf8')\n const b = new JuceBigInteger()\n for (let i = u.length - 1; i >= 0; i--) {\n b.value = (b.value << 8n) | BigInt(u[i])\n }\n return b\n }\n\n isZero(): boolean {\n return this.value === 0n\n }\n\n divideBy(divisor: JuceBigInteger, remainder: JuceBigInteger): void {\n // Ports juce::BigInteger::divideBy()\n if (divisor.isZero()) {\n this.value = 0n\n return\n }\n const b = this.toJSBN()\n const d = divisor.toJSBN()\n const [q, r] = b.divideAndRemainder(d)\n this.value = JuceBigInteger.fromJSBN(q).value\n remainder.value = JuceBigInteger.fromJSBN(r).value\n }\n\n exponentModulo(exponent: JuceBigInteger, modulus: JuceBigInteger): void {\n // Ports juce::BigInteger::exponentModulo()\n const b = this.toJSBN()\n const e = exponent.toJSBN()\n const m = modulus.toJSBN()\n const em = b.modPow(e, m)\n this.value = JuceBigInteger.fromJSBN(em).value\n }\n}\n","import { JuceBigInteger } from './JuceBigInteger'\n\nexport class JuceRSAKey {\n protected part1: JuceBigInteger\n protected part2: JuceBigInteger\n constructor(public s: string) {\n // Ports juce::RSAKey::RSAKey()\n if (s.includes(',')) {\n const [p1, p2] = s.split(',').map(p => JuceBigInteger.fromHex(p))\n this.part1 = p1\n this.part2 = p2\n } else {\n this.part1 = new JuceBigInteger()\n this.part2 = new JuceBigInteger()\n }\n }\n applyToValue(val: JuceBigInteger): void {\n // Ports juce::RSAKey::applyToValue()\n if (this.part1.isZero() || this.part2.isZero() || val.value <= 0n) {\n return\n }\n\n const result = new JuceBigInteger()\n\n while (!val.isZero()) {\n result.value *= this.part2.value\n\n const remainder = new JuceBigInteger()\n val.divideBy(this.part2, remainder)\n\n remainder.exponentModulo(this.part1, this.part2)\n\n result.value += remainder.value\n }\n\n val.value = result.value\n }\n}\n","import { GenerateExpiringKeyFileParams, GenerateKeyFileParams } from 'src/types'\n\nimport { JuceDateString } from './JuceDateString'\nimport { JuceKeyFileUtils } from './JuceKeyFileUtils'\nimport { JuceRSAKey } from './JuceRSAKey'\n\nexport class JuceKeyGeneration {\n static generateKeyFile(\n params: GenerateKeyFileParams,\n date: Date = new Date()\n ) {\n const xml = JuceKeyFileUtils.createKeyFileContentLine(\n {\n appName: params.appName,\n userEmail: params.userEmail,\n userName: params.userName,\n machineNumbers: params.machineNumbers,\n machineNumbersAttributeName: 'mach'\n },\n JuceDateString.inHexMs(date)\n )\n const comment = JuceKeyFileUtils.createKeyFileComment(\n {\n appName: params.appName,\n userEmail: params.userEmail,\n userName: params.userName,\n machineNumbers: params.machineNumbers\n },\n JuceDateString.inFormattedComment(date)\n )\n return JuceKeyFileUtils.createKeyFile(\n comment,\n xml,\n new JuceRSAKey(params.privateKey)\n )\n }\n\n static generateExpiringKeyFile(\n params: GenerateExpiringKeyFileParams,\n date: Date = new Date()\n ) {\n const xml = JuceKeyFileUtils.createKeyFileContentLine(\n {\n appName: params.appName,\n userEmail: params.userEmail,\n userName: params.userName,\n machineNumbers: params.machineNumbers,\n machineNumbersAttributeName: 'expiring_mach'\n },\n JuceDateString.inHexMs(date),\n JuceDateString.inHexMs(params.expiryTime)\n )\n const comment = JuceKeyFileUtils.createKeyFileComment(\n {\n appName: params.appName,\n userEmail: params.userEmail,\n userName: params.userName,\n machineNumbers: params.machineNumbers\n },\n JuceDateString.inFormattedComment(date),\n JuceDateString.inFormattedComment(params.expiryTime)\n )\n return JuceKeyFileUtils.createKeyFile(\n comment,\n xml,\n new JuceRSAKey(params.privateKey)\n )\n }\n}\n","import { z } from 'zod'\n\nimport { JuceBigInteger } from './juce/JuceBigInteger'\n\nexport const createKeyFileCommentParamsValidator = z.object({\n appName: z.string().min(1),\n userEmail: z.string().min(1).email(),\n userName: z.string().min(1),\n machineNumbers: z.string().min(1)\n})\nexport type CreateKeyFileCommentParams = z.infer<\n typeof createKeyFileCommentParamsValidator\n>\n\nexport const machineNumbersAttributeNameValidator = z.enum([\n 'mach',\n 'expiring_mach'\n])\nexport type MachineNumbersAttributeName = z.infer<\n typeof machineNumbersAttributeNameValidator\n>\n\nexport const createKeyFileContentLineParamsValidator =\n createKeyFileCommentParamsValidator.extend({\n machineNumbersAttributeName: machineNumbersAttributeNameValidator\n })\nexport type CreateKeyFileContentLineParams = z.infer<\n typeof createKeyFileContentLineParamsValidator\n>\n\nexport const rsaKeyComponentsValidator = z.string().refine(\n // Ports juce::RSAKey::RSAKey() and juce::RSAKey::applyToValue()\n x =>\n x.includes(',') &&\n x.split(',').every(p => !JuceBigInteger.fromHex(p).isZero())\n)\nexport type RSAKeyComponents = z.infer<typeof rsaKeyComponentsValidator>\n\nexport const generateKeyFileParamsValidator =\n createKeyFileCommentParamsValidator.extend({\n privateKey: rsaKeyComponentsValidator\n })\nexport type GenerateKeyFileParams = z.infer<\n typeof generateKeyFileParamsValidator\n>\n\nexport const generateExpiringKeyFileParamsValidator =\n generateKeyFileParamsValidator.extend({\n expiryTime: z.date()\n })\nexport type GenerateExpiringKeyFileParams = z.infer<\n typeof generateExpiringKeyFileParamsValidator\n>\n","import { JuceKeyGeneration } from './juce/JuceKeyGeneration'\nimport { GenerateKeyFileParams, generateKeyFileParamsValidator } from './types'\n\nexport const generateKeyFile = (\n params: GenerateKeyFileParams,\n date: Date = new Date()\n) => {\n const paramsParse = generateKeyFileParamsValidator.parse(params)\n return JuceKeyGeneration.generateKeyFile(paramsParse, date)\n}\n","import { JuceKeyGeneration } from './juce/JuceKeyGeneration'\nimport {\n GenerateExpiringKeyFileParams,\n generateExpiringKeyFileParamsValidator\n} from './types'\n\nexport const generateExpiringKeyFile = (\n params: GenerateExpiringKeyFileParams,\n date: Date = new Date()\n) => {\n const paramsParse = generateExpiringKeyFileParamsValidator.parse(params)\n return JuceKeyGeneration.generateExpiringKeyFile(paramsParse, date)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,iBAAN,MAAqB;AAAA,EACxB,OAAO,QAAQ,MAAoB;AAE/B,WAAO,KAAK,QAAQ,EAAE,SAAS,EAAE;AAAA,EACrC;AAAA,EAEA,OAAO,mBAAmB,MAAoB;AAG1C,UAAM,SAAS;AAAA,MAAE;A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jC,CAAC;AAKE,IAAM,4BAA4B,aAAE,OAAO,EAAE;AAAA;AAAA,EAEhD,OACI,EAAE,SAAS,GAAG,KACd,EAAE,MAAM,GAAG,EAAE,MAAM,OAAK,CAAC,eAAe,QAAQ,CAAC,EAAE,OAAO,CAAC;AACnE;AAGO,IAAM,iCACT,oCAAoC,OAAO;AAAA,EACvC,YAAY;AAChB,CAAC;AAKE,IAAM,yCACT,+BAA+B,OAAO;AAAA,EAClC,YAAY,aAAE,KAAK;AACvB,CAAC;;;AC9CE,IAAM,kBAAkB,CAC3B,QACA,OAAa,oBAAI,KAAK,MACrB;AACD,QAAM,cAAc,+BAA+B,MAAM,MAAM;AAC/D,SAAO,kBAAkB,gBAAgB,aAAa,IAAI;AAC9D;;;ACHO,IAAM,0BAA0B,CACnC,QACA,OAAa,oBAAI,KAAK,MACrB;AACD,QAAM,cAAc,uCAAuC,MAAM,MAAM;AACvE,SAAO,kBAAkB,wBAAwB,aAAa,IAAI;AACtE;","names":["JSBN"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -47,9 +47,8 @@ declare const generateExpiringKeyFileParamsValidator: z.ZodObject<z.objectUtil.e
|
|
|
47
47
|
}>;
|
|
48
48
|
type GenerateExpiringKeyFileParams = z.infer<typeof generateExpiringKeyFileParamsValidator>;
|
|
49
49
|
|
|
50
|
-
declare
|
|
51
|
-
static generateKeyFile(params: GenerateKeyFileParams, date?: Date): string;
|
|
52
|
-
static generateExpiringKeyFile(params: GenerateExpiringKeyFileParams, date?: Date): string;
|
|
53
|
-
}
|
|
50
|
+
declare const generateKeyFile: (params: GenerateKeyFileParams, date?: Date) => string;
|
|
54
51
|
|
|
55
|
-
|
|
52
|
+
declare const generateExpiringKeyFile: (params: GenerateExpiringKeyFileParams, date?: Date) => string;
|
|
53
|
+
|
|
54
|
+
export { type GenerateExpiringKeyFileParams, type GenerateKeyFileParams, generateExpiringKeyFile, generateKeyFile };
|
package/dist/index.d.ts
CHANGED
|
@@ -47,9 +47,8 @@ declare const generateExpiringKeyFileParamsValidator: z.ZodObject<z.objectUtil.e
|
|
|
47
47
|
}>;
|
|
48
48
|
type GenerateExpiringKeyFileParams = z.infer<typeof generateExpiringKeyFileParamsValidator>;
|
|
49
49
|
|
|
50
|
-
declare
|
|
51
|
-
static generateKeyFile(params: GenerateKeyFileParams, date?: Date): string;
|
|
52
|
-
static generateExpiringKeyFile(params: GenerateExpiringKeyFileParams, date?: Date): string;
|
|
53
|
-
}
|
|
50
|
+
declare const generateKeyFile: (params: GenerateKeyFileParams, date?: Date) => string;
|
|
54
51
|
|
|
55
|
-
|
|
52
|
+
declare const generateExpiringKeyFile: (params: GenerateExpiringKeyFileParams, date?: Date) => string;
|
|
53
|
+
|
|
54
|
+
export { type GenerateExpiringKeyFileParams, type GenerateKeyFileParams, generateExpiringKeyFile, generateKeyFile };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
// src/juce/JuceDateString.ts
|
|
2
|
+
var JuceDateString = class {
|
|
3
|
+
static inHexMs(date) {
|
|
4
|
+
return date.getTime().toString(16);
|
|
5
|
+
}
|
|
6
|
+
static inFormattedComment(date) {
|
|
7
|
+
const months = [
|
|
8
|
+
"Jan",
|
|
9
|
+
"Feb",
|
|
10
|
+
"Mar",
|
|
11
|
+
"Apr",
|
|
12
|
+
"May",
|
|
13
|
+
"Jun",
|
|
14
|
+
"Jul",
|
|
15
|
+
"Aug",
|
|
16
|
+
"Sep",
|
|
17
|
+
"Oct",
|
|
18
|
+
"Nov",
|
|
19
|
+
"Dec"
|
|
20
|
+
];
|
|
21
|
+
const day = date.getDate().toString();
|
|
22
|
+
const month = months[date.getMonth()];
|
|
23
|
+
const year = date.getFullYear();
|
|
24
|
+
let hours = date.getHours();
|
|
25
|
+
const minutes = date.getMinutes().toString().padStart(2, "0");
|
|
26
|
+
const seconds = date.getSeconds().toString().padStart(2, "0");
|
|
27
|
+
const ampm = hours >= 12 ? "pm" : "am";
|
|
28
|
+
hours = hours % 12;
|
|
29
|
+
hours = hours ? hours : 12;
|
|
30
|
+
return `${day} ${month} ${year} ${hours}:${minutes}:${seconds}${ampm}`;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
1
34
|
// src/juce/JuceKeyFileUtils.ts
|
|
2
35
|
import { XMLBuilder } from "fast-xml-parser";
|
|
3
36
|
|
|
@@ -68,8 +101,8 @@ var xmlAttributeValueProcessor = (value) => (
|
|
|
68
101
|
var xmlBuilder = new XMLBuilder({
|
|
69
102
|
ignoreAttributes: false,
|
|
70
103
|
suppressEmptyNode: true,
|
|
104
|
+
// processEntities is disabled since it doesn't port to juce as is
|
|
71
105
|
processEntities: false,
|
|
72
|
-
// Disabled since it doesn't port to juce as is
|
|
73
106
|
attributeValueProcessor: (_, value) => xmlAttributeValueProcessor(value)
|
|
74
107
|
});
|
|
75
108
|
var JuceKeyFileUtils = class {
|
|
@@ -87,7 +120,6 @@ var JuceKeyFileUtils = class {
|
|
|
87
120
|
[`@_${machineNumbersAttributeName}`]: machineNumbers,
|
|
88
121
|
"@_app": appName,
|
|
89
122
|
"@_date": date,
|
|
90
|
-
// Does not affect key file decryption
|
|
91
123
|
...expiryTime ? { "@_expiryTime": expiryTime } : {}
|
|
92
124
|
}
|
|
93
125
|
};
|
|
@@ -126,39 +158,6 @@ Expires: ${expiryTime}` : "");
|
|
|
126
158
|
}
|
|
127
159
|
};
|
|
128
160
|
|
|
129
|
-
// src/juce/JuceDateString.ts
|
|
130
|
-
var JuceDateString = class {
|
|
131
|
-
static inHexMs(date) {
|
|
132
|
-
return date.getTime().toString(16);
|
|
133
|
-
}
|
|
134
|
-
static inFormattedComment(date) {
|
|
135
|
-
const months = [
|
|
136
|
-
"Jan",
|
|
137
|
-
"Feb",
|
|
138
|
-
"Mar",
|
|
139
|
-
"Apr",
|
|
140
|
-
"May",
|
|
141
|
-
"Jun",
|
|
142
|
-
"Jul",
|
|
143
|
-
"Aug",
|
|
144
|
-
"Sep",
|
|
145
|
-
"Oct",
|
|
146
|
-
"Nov",
|
|
147
|
-
"Dec"
|
|
148
|
-
];
|
|
149
|
-
const day = date.getDate().toString();
|
|
150
|
-
const month = months[date.getMonth()];
|
|
151
|
-
const year = date.getFullYear();
|
|
152
|
-
let hours = date.getHours();
|
|
153
|
-
const minutes = date.getMinutes().toString().padStart(2, "0");
|
|
154
|
-
const seconds = date.getSeconds().toString().padStart(2, "0");
|
|
155
|
-
const ampm = hours >= 12 ? "pm" : "am";
|
|
156
|
-
hours = hours % 12;
|
|
157
|
-
hours = hours ? hours : 12;
|
|
158
|
-
return `${day} ${month} ${year} ${hours}:${minutes}:${seconds}${ampm}`;
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
|
|
162
161
|
// src/juce/JuceRSAKey.ts
|
|
163
162
|
var JuceRSAKey = class {
|
|
164
163
|
constructor(s) {
|
|
@@ -245,7 +244,46 @@ var JuceKeyGeneration = class {
|
|
|
245
244
|
);
|
|
246
245
|
}
|
|
247
246
|
};
|
|
247
|
+
|
|
248
|
+
// src/types.ts
|
|
249
|
+
import { z } from "zod";
|
|
250
|
+
var createKeyFileCommentParamsValidator = z.object({
|
|
251
|
+
appName: z.string().min(1),
|
|
252
|
+
userEmail: z.string().min(1).email(),
|
|
253
|
+
userName: z.string().min(1),
|
|
254
|
+
machineNumbers: z.string().min(1)
|
|
255
|
+
});
|
|
256
|
+
var machineNumbersAttributeNameValidator = z.enum([
|
|
257
|
+
"mach",
|
|
258
|
+
"expiring_mach"
|
|
259
|
+
]);
|
|
260
|
+
var createKeyFileContentLineParamsValidator = createKeyFileCommentParamsValidator.extend({
|
|
261
|
+
machineNumbersAttributeName: machineNumbersAttributeNameValidator
|
|
262
|
+
});
|
|
263
|
+
var rsaKeyComponentsValidator = z.string().refine(
|
|
264
|
+
// Ports juce::RSAKey::RSAKey() and juce::RSAKey::applyToValue()
|
|
265
|
+
(x) => x.includes(",") && x.split(",").every((p) => !JuceBigInteger.fromHex(p).isZero())
|
|
266
|
+
);
|
|
267
|
+
var generateKeyFileParamsValidator = createKeyFileCommentParamsValidator.extend({
|
|
268
|
+
privateKey: rsaKeyComponentsValidator
|
|
269
|
+
});
|
|
270
|
+
var generateExpiringKeyFileParamsValidator = generateKeyFileParamsValidator.extend({
|
|
271
|
+
expiryTime: z.date()
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// src/generateKeyFile.ts
|
|
275
|
+
var generateKeyFile = (params, date = /* @__PURE__ */ new Date()) => {
|
|
276
|
+
const paramsParse = generateKeyFileParamsValidator.parse(params);
|
|
277
|
+
return JuceKeyGeneration.generateKeyFile(paramsParse, date);
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
// src/generateExpiringKeyFile.ts
|
|
281
|
+
var generateExpiringKeyFile = (params, date = /* @__PURE__ */ new Date()) => {
|
|
282
|
+
const paramsParse = generateExpiringKeyFileParamsValidator.parse(params);
|
|
283
|
+
return JuceKeyGeneration.generateExpiringKeyFile(paramsParse, date);
|
|
284
|
+
};
|
|
248
285
|
export {
|
|
249
|
-
|
|
286
|
+
generateExpiringKeyFile,
|
|
287
|
+
generateKeyFile
|
|
250
288
|
};
|
|
251
289
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/juce/JuceKeyFileUtils.ts","../src/juce/JuceBigInteger.ts","../src/juce/JuceDateString.ts","../src/juce/JuceRSAKey.ts","../src/juce/JuceKeyGeneration.ts"],"sourcesContent":["import { XMLBuilder } from 'fast-xml-parser'\nimport {\n CreateKeyFileCommentParams,\n CreateKeyFileContentLineParams\n} from 'src/types'\n\nimport { JuceBigInteger } from './JuceBigInteger'\nimport { JuceRSAKey } from './JuceRSAKey'\n\nconst XML_DECLARATION = '<?xml version=\"1.0\" encoding=\"UTF-8\"?>'\n\nconst legalXmlCharRegex =\n // Ports juce::XmlOutputFunctions::LegalCharLookupTable\n /^[a-zA-Z0-9 .,;:\\-()_+=?!$#@[\\]/|*%~{}'\\\\]$/\n\nconst xmlAttributeCharProcessor = (char: string): string =>\n // Ports juce::XmlOutputFunctions::escapeIllegalXMLChars()\n char.length !== 1\n ? ''\n : legalXmlCharRegex.test(char)\n ? char\n : char === '&'\n ? '&'\n : char === '\"'\n ? '"'\n : char === '>'\n ? '>'\n : char === '<'\n ? '<'\n : `&#${char.charCodeAt(0)};`\n\nconst xmlAttributeValueProcessor = (value: unknown): string =>\n // Ports juce::XmlOutputFunctions::escapeIllegalXMLChars()\n typeof value !== 'string'\n ? ''\n : value.split('').map(xmlAttributeCharProcessor).join('')\n\nconst xmlBuilder = new XMLBuilder({\n ignoreAttributes: false,\n suppressEmptyNode: true,\n processEntities: false, // Disabled since it doesn't port to juce as is\n attributeValueProcessor: (_, value) => xmlAttributeValueProcessor(value)\n})\n\nexport class JuceKeyFileUtils {\n static createKeyFileContentLine(\n {\n appName,\n userEmail,\n userName,\n machineNumbers,\n machineNumbersAttributeName\n }: CreateKeyFileContentLineParams,\n date: string,\n expiryTime?: string\n ): string {\n // Ports juce::KeyFileUtils::createKeyFileContent\n // and juce::KeyFileUtils::encryptXML\n const xml = {\n key: {\n '@_user': userName,\n '@_email': userEmail,\n [`@_${machineNumbersAttributeName}`]: machineNumbers,\n '@_app': appName,\n '@_date': date, // Does not affect key file decryption\n ...(expiryTime ? { '@_expiryTime': expiryTime } : {})\n }\n }\n return [XML_DECLARATION, xmlBuilder.build(xml).trim()].join(' ')\n }\n\n static createKeyFileComment(\n {\n appName,\n userEmail,\n userName,\n machineNumbers\n }: CreateKeyFileCommentParams,\n created: string,\n expiryTime?: string\n ): string {\n // Ports juce::KeyFileUtils::createKeyFileComment\n return (\n `Keyfile for ${appName}\\r\\n` +\n `${userName ? `User: ${userName}\\r\\n` : ''}` +\n `Email: ${userEmail}\\r\\n` +\n `Machine numbers: ${machineNumbers}\\r\\n` +\n `Created: ${created}` +\n (expiryTime ? `\\r\\nExpires: ${expiryTime}` : '')\n )\n }\n\n static encryptXMLLine(xmlLine: string, privateKey: JuceRSAKey): string {\n // Ports juce::KeyFileUtils::encryptXML\n const val = JuceBigInteger.fromUTF8MemoryBlock(xmlLine)\n privateKey.applyToValue(val)\n return val.toHex()\n }\n\n static createKeyFile(\n comment: string,\n xmlLine: string,\n rsaPrivateKey: JuceRSAKey\n ): string {\n // Ports juce::KeyFileUtils::createKeyFile\n let asHex = '#' + this.encryptXMLLine(xmlLine, rsaPrivateKey)\n\n const lines: string[] = []\n lines.push(comment)\n lines.push('')\n\n const charsPerLine = 70\n while (asHex.length > 0) {\n lines.push(asHex.substring(0, charsPerLine))\n asHex = asHex.substring(charsPerLine)\n }\n\n lines.push('')\n\n return lines.join('\\r\\n')\n }\n}\n","import { BigInteger as JSBN } from 'jsbn'\n\nexport class JuceBigInteger {\n constructor(public value: bigint = 0n) {}\n\n static fromJSBN(b: JSBN): JuceBigInteger {\n return JuceBigInteger.fromHex(b.toString(16))\n }\n\n toJSBN(): JSBN {\n return new JSBN(this.toHex(), 16)\n }\n\n static fromHex(hex: string): JuceBigInteger {\n const h = hex.trim()\n return new JuceBigInteger(h ? BigInt(`0x${h}`) : 0n)\n }\n\n toHex(): string {\n return this.value.toString(16)\n }\n\n static fromUTF8MemoryBlock(input: string): JuceBigInteger {\n // Ports juce::BigInteger::loadFromMemoryBlock()\n const u = Buffer.from(input, 'utf8')\n const b = new JuceBigInteger()\n for (let i = u.length - 1; i >= 0; i--) {\n b.value = (b.value << 8n) | BigInt(u[i])\n }\n return b\n }\n\n isZero(): boolean {\n return this.value === 0n\n }\n\n divideBy(divisor: JuceBigInteger, remainder: JuceBigInteger): void {\n // Ports juce::BigInteger::divideBy()\n if (divisor.isZero()) {\n this.value = 0n\n return\n }\n const b = this.toJSBN()\n const d = divisor.toJSBN()\n const [q, r] = b.divideAndRemainder(d)\n this.value = JuceBigInteger.fromJSBN(q).value\n remainder.value = JuceBigInteger.fromJSBN(r).value\n }\n\n exponentModulo(exponent: JuceBigInteger, modulus: JuceBigInteger): void {\n // Ports juce::BigInteger::exponentModulo()\n const b = this.toJSBN()\n const e = exponent.toJSBN()\n const m = modulus.toJSBN()\n const em = b.modPow(e, m)\n this.value = JuceBigInteger.fromJSBN(em).value\n }\n}\n","export class JuceDateString {\n static inHexMs(date: Date): string {\n // Ports juce::String::toHexString (juce::Time::getCurrentTime().toMilliseconds())\n return date.getTime().toString(16)\n }\n\n static inFormattedComment(date: Date): string {\n // Ports juce::Time::getCurrentTime().toString (true, true)\n // prettier-ignore\n const months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', \n 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]\n const day = date.getDate().toString()\n const month = months[date.getMonth()]\n const year = date.getFullYear()\n let hours = date.getHours()\n const minutes = date.getMinutes().toString().padStart(2, '0')\n const seconds = date.getSeconds().toString().padStart(2, '0')\n const ampm = hours >= 12 ? 'pm' : 'am'\n hours = hours % 12\n hours = hours ? hours : 12\n return `${day} ${month} ${year} ${hours}:${minutes}:${seconds}${ampm}`\n }\n}\n","// import { BigInteger as JSBN } from 'jsbn'\n\nimport { JuceBigInteger } from './JuceBigInteger'\n\nexport class JuceRSAKey {\n protected part1: JuceBigInteger\n protected part2: JuceBigInteger\n constructor(public s: string) {\n // Ports juce::RSAKey::RSAKey()\n if (s.includes(',')) {\n const [p1, p2] = s.split(',').map(p => JuceBigInteger.fromHex(p))\n this.part1 = p1\n this.part2 = p2\n } else {\n this.part1 = new JuceBigInteger()\n this.part2 = new JuceBigInteger()\n }\n }\n applyToValue(val: JuceBigInteger): void {\n // Ports juce::RSAKey::applyToValue()\n if (this.part1.isZero() || this.part2.isZero() || val.value <= 0n) {\n return\n }\n\n const result = new JuceBigInteger()\n\n while (!val.isZero()) {\n result.value *= this.part2.value\n\n const remainder = new JuceBigInteger()\n val.divideBy(this.part2, remainder)\n\n remainder.exponentModulo(this.part1, this.part2)\n\n result.value += remainder.value\n }\n\n val.value = result.value\n }\n}\n","import { JuceKeyFileUtils } from 'src/juce/JuceKeyFileUtils'\nimport { GenerateExpiringKeyFileParams, GenerateKeyFileParams } from 'src/types'\n\nimport { JuceDateString } from './JuceDateString'\nimport { JuceRSAKey } from './JuceRSAKey'\n\nexport class JuceKeyGeneration {\n static generateKeyFile(\n params: GenerateKeyFileParams,\n date: Date = new Date()\n ) {\n const xml = JuceKeyFileUtils.createKeyFileContentLine(\n {\n appName: params.appName,\n userEmail: params.userEmail,\n userName: params.userName,\n machineNumbers: params.machineNumbers,\n machineNumbersAttributeName: 'mach'\n },\n JuceDateString.inHexMs(date)\n )\n const comment = JuceKeyFileUtils.createKeyFileComment(\n {\n appName: params.appName,\n userEmail: params.userEmail,\n userName: params.userName,\n machineNumbers: params.machineNumbers\n },\n JuceDateString.inFormattedComment(date)\n )\n return JuceKeyFileUtils.createKeyFile(\n comment,\n xml,\n new JuceRSAKey(params.privateKey)\n )\n }\n\n static generateExpiringKeyFile(\n params: GenerateExpiringKeyFileParams,\n date: Date = new Date()\n ) {\n const xml = JuceKeyFileUtils.createKeyFileContentLine(\n {\n appName: params.appName,\n userEmail: params.userEmail,\n userName: params.userName,\n machineNumbers: params.machineNumbers,\n machineNumbersAttributeName: 'expiring_mach'\n },\n JuceDateString.inHexMs(date),\n JuceDateString.inHexMs(params.expiryTime)\n )\n const comment = JuceKeyFileUtils.createKeyFileComment(\n {\n appName: params.appName,\n userEmail: params.userEmail,\n userName: params.userName,\n machineNumbers: params.machineNumbers\n },\n JuceDateString.inFormattedComment(date),\n JuceDateString.inFormattedComment(params.expiryTime)\n )\n return JuceKeyFileUtils.createKeyFile(\n comment,\n xml,\n new JuceRSAKey(params.privateKey)\n )\n }\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;;;ACA3B,SAAS,cAAc,YAAY;AAE5B,IAAM,iBAAN,MAAM,gBAAe;AAAA,EACxB,YAAmB,QAAgB,IAAI;AAApB;AAAA,EAAqB;AAAA,EAExC,OAAO,SAAS,GAAyB;AACrC,WAAO,gBAAe,QAAQ,EAAE,SAA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AAO;AAAA,QACjB,gBAAgB,OAAO;AAAA,MAC3B;AAAA,MACA,eAAe,mBAAmB,IAAI;AAAA,IAC1C;AACA,WAAO,iBAAiB;AAAA,MACpB;AAAA,MACA;AAAA,MACA,IAAI,WAAW,OAAO,UAAU;AAAA,IACpC;AAAA,EACJ;AAAA,EAEA,OAAO,wBACH,QACA,OAAa,oBAAI,KAAK,GACxB;AACE,UAAM,MAAM,iBAAiB;AAAA,MACzB;AAAA,QACI,SAAS,OAAO;AAAA,QAChB,WAAW,OAAO;AAAA,QAClB,UAAU,OAAO;AAAA,QACjB,gBAAgB,OAAO;AAAA,QACvB,6BAA6B;AAAA,MACjC;AAAA,MACA,eAAe,QAAQ,IAAI;AAAA,MAC3B,eAAe,QAAQ,OAAO,UAAU;AAAA,IAC5C;AACA,UAAM,UAAU,iBAAiB;AAAA,MAC7B;AAAA,QACI,SAAS,OAAO;AAAA,QAChB,WAAW,OAAO;AAAA,QAClB,UAAU,OAAO;AAAA,QACjB,gBAAgB,OAAO;AAAA,MAC3B;AAAA,MACA,eAAe,mBAAmB,IAAI;AAAA,MACtC,eAAe,mBAAmB,OAAO,UAAU;AAAA,IACvD;AACA,WAAO,iBAAiB;AAAA,MACpB;AAAA,MACA;AAAA,MACA,IAAI,WAAW,OAAO,UAAU;AAAA,IACpC;AAAA,EACJ;AACJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/juce/JuceDateString.ts","../src/juce/JuceKeyFileUtils.ts","../src/juce/JuceBigInteger.ts","../src/juce/JuceRSAKey.ts","../src/juce/JuceKeyGeneration.ts","../src/types.ts","../src/generateKeyFile.ts","../src/generateExpiringKeyFile.ts"],"sourcesContent":["export class JuceDateString {\n static inHexMs(date: Date): string {\n // Ports juce::String::toHexString (juce::Time::getCurrentTime().toMilliseconds())\n return date.getTime().toString(16)\n }\n\n static inFormattedComment(date: Date): string {\n // Ports juce::Time::getCurrentTime().toString (true, true)\n // prettier-ignore\n const months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', \n 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]\n const day = date.getDate().toString()\n const month = months[date.getMonth()]\n const year = date.getFullYear()\n let hours = date.getHours()\n const minutes = date.getMinutes().toString().padStart(2, '0')\n const seconds = date.getSeconds().toString().padStart(2, '0')\n const ampm = hours >= 12 ? 'pm' : 'am'\n hours = hours % 12\n hours = hours ? hours : 12\n return `${day} ${month} ${year} ${hours}:${minutes}:${seconds}${ampm}`\n }\n}\n","import { XMLBuilder } from 'fast-xml-parser'\nimport {\n CreateKeyFileCommentParams,\n CreateKeyFileContentLineParams\n} from 'src/types'\n\nimport { JuceBigInteger } from './JuceBigInteger'\nimport { JuceRSAKey } from './JuceRSAKey'\n\nconst XML_DECLARATION = '<?xml version=\"1.0\" encoding=\"UTF-8\"?>'\n\nconst legalXmlCharRegex =\n // Ports juce::XmlOutputFunctions::LegalCharLookupTable\n /^[a-zA-Z0-9 .,;:\\-()_+=?!$#@[\\]/|*%~{}'\\\\]$/\n\nconst xmlAttributeCharProcessor = (char: string): string =>\n // Ports juce::XmlOutputFunctions::escapeIllegalXMLChars()\n char.length !== 1\n ? ''\n : legalXmlCharRegex.test(char)\n ? char\n : char === '&'\n ? '&'\n : char === '\"'\n ? '"'\n : char === '>'\n ? '>'\n : char === '<'\n ? '<'\n : `&#${char.charCodeAt(0)};`\n\nconst xmlAttributeValueProcessor = (value: unknown): string =>\n // Ports juce::XmlOutputFunctions::escapeIllegalXMLChars()\n typeof value !== 'string'\n ? ''\n : value.split('').map(xmlAttributeCharProcessor).join('')\n\nconst xmlBuilder = new XMLBuilder({\n ignoreAttributes: false,\n suppressEmptyNode: true,\n // processEntities is disabled since it doesn't port to juce as is\n processEntities: false,\n attributeValueProcessor: (_, value) => xmlAttributeValueProcessor(value)\n})\n\nexport class JuceKeyFileUtils {\n static createKeyFileContentLine(\n {\n appName,\n userEmail,\n userName,\n machineNumbers,\n machineNumbersAttributeName\n }: CreateKeyFileContentLineParams,\n date: string,\n expiryTime?: string\n ): string {\n // Ports juce::KeyFileUtils::createKeyFileContent\n // and juce::KeyFileUtils::encryptXML\n const xml = {\n key: {\n '@_user': userName,\n '@_email': userEmail,\n [`@_${machineNumbersAttributeName}`]: machineNumbers,\n '@_app': appName,\n '@_date': date,\n ...(expiryTime ? { '@_expiryTime': expiryTime } : {})\n }\n }\n return [XML_DECLARATION, xmlBuilder.build(xml).trim()].join(' ')\n }\n\n static createKeyFileComment(\n {\n appName,\n userEmail,\n userName,\n machineNumbers\n }: CreateKeyFileCommentParams,\n created: string,\n expiryTime?: string\n ): string {\n // Ports juce::KeyFileUtils::createKeyFileComment\n return (\n `Keyfile for ${appName}\\r\\n` +\n `${userName ? `User: ${userName}\\r\\n` : ''}` +\n `Email: ${userEmail}\\r\\n` +\n `Machine numbers: ${machineNumbers}\\r\\n` +\n `Created: ${created}` +\n (expiryTime ? `\\r\\nExpires: ${expiryTime}` : '')\n )\n }\n\n static encryptXMLLine(xmlLine: string, privateKey: JuceRSAKey): string {\n // Ports juce::KeyFileUtils::encryptXML\n const val = JuceBigInteger.fromUTF8MemoryBlock(xmlLine)\n privateKey.applyToValue(val)\n return val.toHex()\n }\n\n static createKeyFile(\n comment: string,\n xmlLine: string,\n rsaPrivateKey: JuceRSAKey\n ): string {\n // Ports juce::KeyFileUtils::createKeyFile\n let asHex = '#' + this.encryptXMLLine(xmlLine, rsaPrivateKey)\n\n const lines: string[] = []\n lines.push(comment)\n lines.push('')\n\n const charsPerLine = 70\n while (asHex.length > 0) {\n lines.push(asHex.substring(0, charsPerLine))\n asHex = asHex.substring(charsPerLine)\n }\n\n lines.push('')\n\n return lines.join('\\r\\n')\n }\n}\n","import { BigInteger as JSBN } from 'jsbn'\n\nexport class JuceBigInteger {\n constructor(public value: bigint = 0n) {}\n\n static fromJSBN(b: JSBN): JuceBigInteger {\n return JuceBigInteger.fromHex(b.toString(16))\n }\n\n toJSBN(): JSBN {\n return new JSBN(this.toHex(), 16)\n }\n\n static fromHex(hex: string): JuceBigInteger {\n const h = hex.trim()\n return new JuceBigInteger(h ? BigInt(`0x${h}`) : 0n)\n }\n\n toHex(): string {\n return this.value.toString(16)\n }\n\n static fromUTF8MemoryBlock(input: string): JuceBigInteger {\n // Ports juce::BigInteger::loadFromMemoryBlock()\n const u = Buffer.from(input, 'utf8')\n const b = new JuceBigInteger()\n for (let i = u.length - 1; i >= 0; i--) {\n b.value = (b.value << 8n) | BigInt(u[i])\n }\n return b\n }\n\n isZero(): boolean {\n return this.value === 0n\n }\n\n divideBy(divisor: JuceBigInteger, remainder: JuceBigInteger): void {\n // Ports juce::BigInteger::divideBy()\n if (divisor.isZero()) {\n this.value = 0n\n return\n }\n const b = this.toJSBN()\n const d = divisor.toJSBN()\n const [q, r] = b.divideAndRemainder(d)\n this.value = JuceBigInteger.fromJSBN(q).value\n remainder.value = JuceBigInteger.fromJSBN(r).value\n }\n\n exponentModulo(exponent: JuceBigInteger, modulus: JuceBigInteger): void {\n // Ports juce::BigInteger::exponentModulo()\n const b = this.toJSBN()\n const e = exponent.toJSBN()\n const m = modulus.toJSBN()\n const em = b.modPow(e, m)\n this.value = JuceBigInteger.fromJSBN(em).value\n }\n}\n","import { JuceBigInteger } from './JuceBigInteger'\n\nexport class JuceRSAKey {\n protected part1: JuceBigInteger\n protected part2: JuceBigInteger\n constructor(public s: string) {\n // Ports juce::RSAKey::RSAKey()\n if (s.includes(',')) {\n const [p1, p2] = s.split(',').map(p => JuceBigInteger.fromHex(p))\n this.part1 = p1\n this.part2 = p2\n } else {\n this.part1 = new JuceBigInteger()\n this.part2 = new JuceBigInteger()\n }\n }\n applyToValue(val: JuceBigInteger): void {\n // Ports juce::RSAKey::applyToValue()\n if (this.part1.isZero() || this.part2.isZero() || val.value <= 0n) {\n return\n }\n\n const result = new JuceBigInteger()\n\n while (!val.isZero()) {\n result.value *= this.part2.value\n\n const remainder = new JuceBigInteger()\n val.divideBy(this.part2, remainder)\n\n remainder.exponentModulo(this.part1, this.part2)\n\n result.value += remainder.value\n }\n\n val.value = result.value\n }\n}\n","import { GenerateExpiringKeyFileParams, GenerateKeyFileParams } from 'src/types'\n\nimport { JuceDateString } from './JuceDateString'\nimport { JuceKeyFileUtils } from './JuceKeyFileUtils'\nimport { JuceRSAKey } from './JuceRSAKey'\n\nexport class JuceKeyGeneration {\n static generateKeyFile(\n params: GenerateKeyFileParams,\n date: Date = new Date()\n ) {\n const xml = JuceKeyFileUtils.createKeyFileContentLine(\n {\n appName: params.appName,\n userEmail: params.userEmail,\n userName: params.userName,\n machineNumbers: params.machineNumbers,\n machineNumbersAttributeName: 'mach'\n },\n JuceDateString.inHexMs(date)\n )\n const comment = JuceKeyFileUtils.createKeyFileComment(\n {\n appName: params.appName,\n userEmail: params.userEmail,\n userName: params.userName,\n machineNumbers: params.machineNumbers\n },\n JuceDateString.inFormattedComment(date)\n )\n return JuceKeyFileUtils.createKeyFile(\n comment,\n xml,\n new JuceRSAKey(params.privateKey)\n )\n }\n\n static generateExpiringKeyFile(\n params: GenerateExpiringKeyFileParams,\n date: Date = new Date()\n ) {\n const xml = JuceKeyFileUtils.createKeyFileContentLine(\n {\n appName: params.appName,\n userEmail: params.userEmail,\n userName: params.userName,\n machineNumbers: params.machineNumbers,\n machineNumbersAttributeName: 'expiring_mach'\n },\n JuceDateString.inHexMs(date),\n JuceDateString.inHexMs(params.expiryTime)\n )\n const comment = JuceKeyFileUtils.createKeyFileComment(\n {\n appName: params.appName,\n userEmail: params.userEmail,\n userName: params.userName,\n machineNumbers: params.machineNumbers\n },\n JuceDateString.inFormattedComment(date),\n JuceDateString.inFormattedComment(params.expiryTime)\n )\n return JuceKeyFileUtils.createKeyFile(\n comment,\n xml,\n new JuceRSAKey(params.privateKey)\n )\n }\n}\n","import { z } from 'zod'\n\nimport { JuceBigInteger } from './juce/JuceBigInteger'\n\nexport const createKeyFileCommentParamsValidator = z.object({\n appName: z.string().min(1),\n userEmail: z.string().min(1).email(),\n userName: z.string().min(1),\n machineNumbers: z.string().min(1)\n})\nexport type CreateKeyFileCommentParams = z.infer<\n typeof createKeyFileCommentParamsValidator\n>\n\nexport const machineNumbersAttributeNameValidator = z.enum([\n 'mach',\n 'expiring_mach'\n])\nexport type MachineNumbersAttributeName = z.infer<\n typeof machineNumbersAttributeNameValidator\n>\n\nexport const createKeyFileContentLineParamsValidator =\n createKeyFileCommentParamsValidator.extend({\n machineNumbersAttributeName: machineNumbersAttributeNameValidator\n })\nexport type CreateKeyFileContentLineParams = z.infer<\n typeof createKeyFileContentLineParamsValidator\n>\n\nexport const rsaKeyComponentsValidator = z.string().refine(\n // Ports juce::RSAKey::RSAKey() and juce::RSAKey::applyToValue()\n x =>\n x.includes(',') &&\n x.split(',').every(p => !JuceBigInteger.fromHex(p).isZero())\n)\nexport type RSAKeyComponents = z.infer<typeof rsaKeyComponentsValidator>\n\nexport const generateKeyFileParamsValidator =\n createKeyFileCommentParamsValidator.extend({\n privateKey: rsaKeyComponentsValidator\n })\nexport type GenerateKeyFileParams = z.infer<\n typeof generateKeyFileParamsValidator\n>\n\nexport const generateExpiringKeyFileParamsValidator =\n generateKeyFileParamsValidator.extend({\n expiryTime: z.date()\n })\nexport type GenerateExpiringKeyFileParams = z.infer<\n typeof generateExpiringKeyFileParamsValidator\n>\n","import { JuceKeyGeneration } from './juce/JuceKeyGeneration'\nimport { GenerateKeyFileParams, generateKeyFileParamsValidator } from './types'\n\nexport const generateKeyFile = (\n params: GenerateKeyFileParams,\n date: Date = new Date()\n) => {\n const paramsParse = generateKeyFileParamsValidator.parse(params)\n return JuceKeyGeneration.generateKeyFile(paramsParse, date)\n}\n","import { JuceKeyGeneration } from './juce/JuceKeyGeneration'\nimport {\n GenerateExpiringKeyFileParams,\n generateExpiringKeyFileParamsValidator\n} from './types'\n\nexport const generateExpiringKeyFile = (\n params: GenerateExpiringKeyFileParams,\n date: Date = new Date()\n) => {\n const paramsParse = generateExpiringKeyFileParamsValidator.parse(params)\n return JuceKeyGeneration.generateExpiringKeyFile(params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AE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC1B,gBAAgB,EAAE,OAAO,EAAE,IAAI,CAAC;AACpC,CAAC;AAKM,IAAM,uCAAuC,EAAE,KAAK;AAAA,EACvD;AAAA,EACA;AACJ,CAAC;AAKM,IAAM,0CACT,oCAAoC,OAAO;AAAA,EACvC,6BAA6B;AACjC,CAAC;AAKE,IAAM,4BAA4B,EAAE,OAAO,EAAE;AAAA;AAAA,EAEhD,OACI,EAAE,SAAS,GAAG,KACd,EAAE,MAAM,GAAG,EAAE,MAAM,OAAK,CAAC,eAAe,QAAQ,CAAC,EAAE,OAAO,CAAC;AACnE;AAGO,IAAM,iCACT,oCAAoC,OAAO;AAAA,EACvC,YAAY;AAChB,CAAC;AAKE,IAAM,yCACT,+BAA+B,OAAO;AAAA,EAClC,YAAY,EAAE,KAAK;AACvB,CAAC;;;AC9CE,IAAM,kBAAkB,CAC3B,QACA,OAAa,oBAAI,KAAK,MACrB;AACD,QAAM,cAAc,+BAA+B,MAAM,MAAM;AAC/D,SAAO,kBAAkB,gBAAgB,aAAa,IAAI;AAC9D;;;ACHO,IAAM,0BAA0B,CACnC,QACA,OAAa,oBAAI,KAAK,MACrB;AACD,QAAM,cAAc,uCAAuC,MAAM,MAAM;AACvE,SAAO,kBAAkB,wBAAwB,aAAa,IAAI;AACtE;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ianacaburian/generate-key-file",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Ports juce_KeyGeneration::generateKeyFile() to node.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"lint": "eslint src",
|
|
15
15
|
"clean:test": "rm -rf test/bin/* && cd test/console && ./script/clean-build.sh",
|
|
16
16
|
"open:test/console": "cd test/console && ./script/open-xcode-macos-dev.sh",
|
|
17
|
-
"install:test/console": "cmake -S test/console -B test/console/build && cmake --build test/console/build && cmake --install test/console/build --prefix test
|
|
17
|
+
"install:test/console": "cmake -S test/console -B test/console/build && cmake --build test/console/build && cmake --install test/console/build --prefix test",
|
|
18
18
|
"build": "npm run lint && npm run install:test/console && tsup",
|
|
19
19
|
"test": "vitest"
|
|
20
20
|
},
|