renusify 3.0.2 → 3.1.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.
@@ -4,7 +4,7 @@
4
4
  v-scroll="{handler:onScroll,target:target}"
5
5
  :style="{'max-height': height,'height': height}"
6
6
  :class="{'overflow-div':height}" class="infinite-page-container">
7
- <transition-group :class="{'flex-column-reverse':isChat}"
7
+ <transition-group v-if="!noItem" :class="{'flex-column-reverse':isChat}"
8
8
  :name="isChat?'slide-up':'slide-down'"
9
9
  class="row"
10
10
  tag="div">
@@ -16,23 +16,17 @@
16
16
  </r-col>
17
17
  </transition-group>
18
18
  </div>
19
- <div v-if="noItem"
20
- class="text-center title-2"
21
- >{{ noItemMsg }}
22
- </div>
19
+ <!-- noItem slot for empty contents. Provide noItem, noItemMsg props -->
20
+ <slot :noItem="noItem" :noItemMsg="noItemMsg" name="noItem">
21
+ <div v-if="noItem"
22
+ class="text-center title-2"
23
+ >{{ noItemMsg }}
24
+ </div>
25
+ </slot>
23
26
  </r-container>
24
27
  </template>
25
28
  <script setup>
26
- import {
27
- ref,
28
- computed,
29
- onMounted,
30
- onUnmounted,
31
- onActivated,
32
- onDeactivated,
33
- watch,
34
- inject, nextTick
35
- } from 'vue'
29
+ import {computed, inject, nextTick, onActivated, onDeactivated, onMounted, onUnmounted, ref, watch} from 'vue'
36
30
 
37
31
  const props = defineProps({
38
32
  /**
@@ -259,7 +259,7 @@
259
259
  </template>
260
260
 
261
261
  <script setup>
262
- import {ref, computed, watch, onMounted, inject} from 'vue'
262
+ import {computed, inject, onMounted, ref, watch} from 'vue'
263
263
  import ManageFooter from "./footer.vue";
264
264
  import ManageHeader from "./header.vue";
265
265
 
@@ -543,8 +543,6 @@ const sortSetup = (item) => {
543
543
  const ok = () => {
544
544
  table.value.startTime = false
545
545
  page.value = 1
546
- sortBy.value = null
547
- sortType.value = 0
548
546
  autoSend.value = false
549
547
  showForm.value = false
550
548
  refresh()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "renusify",
3
- "version": "3.0.2",
3
+ "version": "3.1.0",
4
4
  "description": "Vue3 Framework",
5
5
  "keywords": [
6
6
  "vuejs",
@@ -0,0 +1,281 @@
1
+ import SimpleRng from "./random";
2
+
3
+ export default class Cryptor {
4
+ constructor() {
5
+ this.matrix = 32;
6
+ }
7
+
8
+ packUint32BE(value) {
9
+ const bytes = new Uint8Array(4);
10
+ bytes[0] = (value >> 24) & 0xFF;
11
+ bytes[1] = (value >> 16) & 0xFF;
12
+ bytes[2] = (value >> 8) & 0xFF;
13
+ bytes[3] = value & 0xFF;
14
+ return bytes;
15
+ }
16
+
17
+ unpackUint32BE(bytes, offset = 0) {
18
+ return ((bytes[offset] << 24) |
19
+ (bytes[offset + 1] << 16) |
20
+ (bytes[offset + 2] << 8) |
21
+ bytes[offset + 3]) >>> 0;
22
+ }
23
+
24
+ encrypt(data, key) {
25
+ const matrixSize = this.matrix;
26
+ const pad = (matrixSize - ((10 + data.length) % matrixSize)) % matrixSize;
27
+ const keyBytes = this.generatePassword(matrixSize, this.stringToBytes(key));
28
+
29
+ const dataSize = this.packUint32BE(data.length);
30
+
31
+ const randomPrefix = this.getRandomBytes(6);
32
+ const seedRandom = randomPrefix.reduce((sum, b) => sum + b, 0);
33
+
34
+ const paddedText = new Uint8Array(10 + data.length + pad);
35
+ paddedText.set(dataSize, 0);
36
+ paddedText.set(randomPrefix, 4);
37
+ paddedText.set(data, 10);
38
+
39
+ if (pad > 0) {
40
+ paddedText.fill(1, 10 + data.length, 10 + data.length + pad);
41
+ }
42
+
43
+ const seedSum = keyBytes.reduce((sum, b) => sum + b, 0);
44
+ this.shuffle(paddedText, seedSum + seedRandom, 5);
45
+
46
+ for (let i = 0; i < paddedText.length; i += matrixSize) {
47
+ const end = Math.min(i + matrixSize, paddedText.length);
48
+ const seed = (i + matrixSize < paddedText.length) ? paddedText[i + matrixSize] : keyBytes[0];
49
+ const chunkCopy = new Uint8Array(paddedText.slice(i, end));
50
+ this.shuffle(chunkCopy, seed + seedRandom, 2);
51
+ paddedText.set(chunkCopy, i);
52
+ }
53
+
54
+ this.mix(matrixSize, paddedText, keyBytes);
55
+
56
+ const result = new Uint8Array(paddedText.length + 2);
57
+ result.set(paddedText, 0);
58
+ result[paddedText.length] = (seedRandom >> 8) & 0xFF;
59
+ result[paddedText.length + 1] = seedRandom & 0xFF;
60
+
61
+ return result;
62
+ }
63
+
64
+ encryptText(text, key) {
65
+ const data = this.stringToBytes(text);
66
+ const encrypted = this.encrypt(data, key);
67
+ return this.base64UrlEncode(encrypted);
68
+ }
69
+
70
+ decrypt(encoded, key) {
71
+ if (encoded.length < 8) {
72
+ throw new Error('Invalid Token Matrix Length.');
73
+ }
74
+
75
+ const seedRandom = (encoded[encoded.length - 2] << 8) | encoded[encoded.length - 1];
76
+ const decoded = new Uint8Array(encoded.slice(0, -2));
77
+ const matrixSize = this.matrix;
78
+
79
+ const keyBytes = this.generatePassword(matrixSize, this.stringToBytes(key));
80
+ this.unmix(matrixSize, decoded, keyBytes);
81
+
82
+ for (let i = Math.floor(decoded.length / matrixSize) * matrixSize; i >= 0; i -= matrixSize) {
83
+ const end = Math.min(i + matrixSize, decoded.length);
84
+ const seed = (i + matrixSize < decoded.length) ? decoded[i + matrixSize] : keyBytes[0];
85
+ const chunkCopy = new Uint8Array(decoded.slice(i, end));
86
+ this.unshuffle(chunkCopy, seed + seedRandom, 2);
87
+ decoded.set(chunkCopy, i);
88
+ }
89
+
90
+ const seedSum = keyBytes.reduce((sum, b) => sum + b, 0);
91
+ this.unshuffle(decoded, seedSum + seedRandom, 5);
92
+
93
+ const dataSize = this.unpackUint32BE(decoded, 0);
94
+
95
+ if (decoded.length < dataSize + 10) {
96
+ throw new Error('Invalid Token Matrix Length');
97
+ }
98
+
99
+ return decoded.slice(10, 10 + dataSize);
100
+ }
101
+
102
+ decryptText(encoded, key) {
103
+ const padding = encoded.length % 4;
104
+ const paddedInput = padding === 0 ? encoded : encoded + '='.repeat(4 - padding);
105
+
106
+ const data = this.base64UrlDecode(paddedInput);
107
+ const decrypted = this.decrypt(data, key);
108
+ return this.bytesToString(decrypted);
109
+ }
110
+
111
+ setMatrix(size) {
112
+ if (size > 0) {
113
+ this.matrix = size;
114
+ }
115
+ }
116
+
117
+ generatePassword(matrix, password) {
118
+ const result = new Uint8Array(matrix);
119
+ const passwordLen = password.length;
120
+
121
+ if (passwordLen === 0) {
122
+ return result;
123
+ }
124
+
125
+ const repeats = Math.floor(matrix / passwordLen);
126
+ const remainder = matrix % passwordLen;
127
+
128
+ for (let i = 0; i < repeats; i++) {
129
+ const start = i * passwordLen;
130
+ result.set(password, start);
131
+ }
132
+
133
+ if (remainder > 0) {
134
+ const start = repeats * passwordLen;
135
+ result.set(password.slice(0, remainder), start);
136
+ }
137
+
138
+ return result;
139
+ }
140
+
141
+ shuffle(data, seed, step) {
142
+ const rng = new SimpleRng(seed);
143
+ const length = data.length;
144
+
145
+ for (let i = length - 1; i > 0; i -= step) {
146
+ const j = Math.floor(rng.genRange(0, i));
147
+ [data[i], data[j]] = [data[j], data[i]];
148
+ }
149
+ }
150
+
151
+ unshuffle(data, seed, step) {
152
+ const rng = new SimpleRng(seed);
153
+ const length = data.length;
154
+ const swaps = [];
155
+
156
+ for (let i = length - 1; i > 0; i -= step) {
157
+ const j = Math.floor(rng.genRange(0, i));
158
+ swaps.push([i, j]);
159
+ }
160
+
161
+ for (let k = swaps.length - 1; k >= 0; k--) {
162
+ const [i, j] = swaps[k];
163
+ [data[i], data[j]] = [data[j], data[i]];
164
+ }
165
+ }
166
+
167
+ mix(blockSize, buf, key) {
168
+ let prevBlock = new Uint8Array(key);
169
+
170
+ for (let i = 0; i < buf.length; i += blockSize) {
171
+ const blockEnd = Math.min(i + blockSize, buf.length);
172
+ for (let j = 0; j < blockEnd - i && j < prevBlock.length; j++) {
173
+ buf[i + j] ^= prevBlock[j];
174
+ }
175
+ prevBlock = new Uint8Array(buf.slice(i, blockEnd));
176
+ }
177
+ }
178
+
179
+ unmix(blockSize, buf, key) {
180
+ const blocks = [];
181
+ for (let i = 0; i < buf.length; i += blockSize) {
182
+ const end = Math.min(i + blockSize, buf.length);
183
+ blocks.push(new Uint8Array(buf.slice(i, end)));
184
+ }
185
+
186
+ for (let i = blocks.length - 1; i >= 0; i--) {
187
+ if (i === 0) {
188
+ for (let j = 0; j < blocks[i].length && j < key.length; j++) {
189
+ blocks[i][j] ^= key[j];
190
+ }
191
+ } else {
192
+ for (let j = 0; j < blocks[i].length && j < blocks[i - 1].length; j++) {
193
+ blocks[i][j] ^= blocks[i - 1][j];
194
+ }
195
+ }
196
+ }
197
+
198
+ let offset = 0;
199
+ for (const block of blocks) {
200
+ buf.set(block, offset);
201
+ offset += block.length;
202
+ }
203
+ }
204
+
205
+ getRandomBytes(length) {
206
+ const rng = new SimpleRng(Date.now());
207
+ return rng.getRandomBytes(length);
208
+ }
209
+
210
+ base64UrlEncode(data) {
211
+ if (typeof Buffer !== 'undefined') {
212
+ // Node.js
213
+ return Buffer.from(data)
214
+ .toString('base64')
215
+ .replace(/\+/g, '-')
216
+ .replace(/\//g, '_')
217
+ .replace(/=+$/, '');
218
+ } else {
219
+ // Browser
220
+ let binary = '';
221
+ for (let i = 0; i < data.length; i++) {
222
+ binary += String.fromCharCode(data[i]);
223
+ }
224
+ return btoa(binary)
225
+ .replace(/\+/g, '-')
226
+ .replace(/\//g, '_')
227
+ .replace(/=+$/, '');
228
+ }
229
+ }
230
+
231
+ base64UrlDecode(encoded) {
232
+ let padded = encoded;
233
+ const padding = encoded.length % 4;
234
+ if (padding !== 0) {
235
+ padded += '='.repeat(4 - padding);
236
+ }
237
+ const base64 = padded.replace(/-/g, '+').replace(/_/g, '/');
238
+
239
+ if (typeof Buffer !== 'undefined') {
240
+ // Node.js
241
+ return new Uint8Array(Buffer.from(base64, 'base64'));
242
+ } else {
243
+ // Browser
244
+ const binary = atob(base64);
245
+ const bytes = new Uint8Array(binary.length);
246
+ for (let i = 0; i < binary.length; i++) {
247
+ bytes[i] = binary.charCodeAt(i);
248
+ }
249
+ return bytes;
250
+ }
251
+ }
252
+
253
+ stringToBytes(str) {
254
+ if (typeof TextEncoder !== 'undefined') {
255
+ return new TextEncoder().encode(str);
256
+ }
257
+ if (typeof Buffer !== 'undefined') {
258
+ return new Uint8Array(Buffer.from(str, 'utf-8'));
259
+ }
260
+ const bytes = new Uint8Array(str.length);
261
+ for (let i = 0; i < str.length; i++) {
262
+ bytes[i] = str.charCodeAt(i) & 0xFF;
263
+ }
264
+ return bytes;
265
+ }
266
+
267
+ bytesToString(bytes) {
268
+ if (typeof TextDecoder !== 'undefined') {
269
+ return new TextDecoder('utf-8').decode(bytes);
270
+ }
271
+ if (typeof Buffer !== 'undefined') {
272
+ return Buffer.from(bytes).toString('utf-8');
273
+ }
274
+
275
+ let str = '';
276
+ for (let i = 0; i < bytes.length; i++) {
277
+ str += String.fromCharCode(bytes[i]);
278
+ }
279
+ return str;
280
+ }
281
+ }
@@ -0,0 +1,52 @@
1
+ export default class SimpleRng {
2
+ constructor(seed) {
3
+ this.state = BigInt(seed) & 0xFFFFFFFFFFFFFFFFn;
4
+ }
5
+
6
+ static newWithTimeSeed() {
7
+ return new SimpleRng(Date.now());
8
+ }
9
+
10
+ nextU32() {
11
+ this.state = (this.state * 6364136223846793005n + 1442695040888963407n) & 0xFFFFFFFFFFFFFFFFn;
12
+ return Number((this.state >> 32n) & 0xFFFFFFFFn);
13
+ }
14
+
15
+ nextU64() {
16
+ const high = this.nextU32();
17
+ const low = this.nextU32();
18
+ return (high << 32) | low;
19
+ }
20
+
21
+ nextF64() {
22
+ const val = this.nextU32();
23
+ return val / 4294967295.0;
24
+ }
25
+
26
+ genRange(low, high) {
27
+ return low + (high - low) * this.nextF64();
28
+ }
29
+
30
+ getRandomBytes(length) {
31
+ const byteArray = new Uint8Array(length);
32
+ const chunks = Math.floor(length / 4);
33
+ const remainder = length % 4;
34
+
35
+ for (let i = 0; i < chunks; i++) {
36
+ const random = this.nextU32();
37
+ byteArray[i * 4] = random & 0xFF;
38
+ byteArray[i * 4 + 1] = (random >> 8) & 0xFF;
39
+ byteArray[i * 4 + 2] = (random >> 16) & 0xFF;
40
+ byteArray[i * 4 + 3] = (random >> 24) & 0xFF;
41
+ }
42
+
43
+ if (remainder > 0) {
44
+ const random = this.nextU32();
45
+ for (let i = 0; i < remainder; i++) {
46
+ byteArray[chunks * 4 + i] = (random >> (i * 8)) & 0xFF;
47
+ }
48
+ }
49
+
50
+ return byteArray;
51
+ }
52
+ }