@xivdyetools/test-utils 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils/crypto.d.ts +2 -47
- package/dist/utils/crypto.d.ts.map +1 -1
- package/dist/utils/crypto.js +2 -87
- package/dist/utils/crypto.js.map +1 -1
- package/package.json +3 -2
package/dist/utils/crypto.d.ts
CHANGED
|
@@ -1,52 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cryptographic utilities for test helpers
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* REFACTOR-001: Re-exports from @xivdyetools/crypto to consolidate implementations
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
* Encode a string to Base64URL format (RFC 4648)
|
|
8
|
-
* Used for JWT header and payload encoding
|
|
9
|
-
*
|
|
10
|
-
* @param str - The string to encode
|
|
11
|
-
* @returns Base64URL encoded string
|
|
12
|
-
*/
|
|
13
|
-
export declare function base64UrlEncode(str: string): string;
|
|
14
|
-
/**
|
|
15
|
-
* Encode bytes to Base64URL format
|
|
16
|
-
*
|
|
17
|
-
* @param bytes - The bytes to encode
|
|
18
|
-
* @returns Base64URL encoded string
|
|
19
|
-
*/
|
|
20
|
-
export declare function base64UrlEncodeBytes(bytes: Uint8Array): string;
|
|
21
|
-
/**
|
|
22
|
-
* Decode a Base64URL string to bytes
|
|
23
|
-
*
|
|
24
|
-
* @param str - The Base64URL string to decode
|
|
25
|
-
* @returns Decoded bytes as Uint8Array
|
|
26
|
-
*/
|
|
27
|
-
export declare function base64UrlDecodeBytes(str: string): Uint8Array;
|
|
28
|
-
/**
|
|
29
|
-
* Decode a Base64URL string
|
|
30
|
-
*
|
|
31
|
-
* NOTE: For proper UTF-8 roundtrip with base64UrlEncode(), this function
|
|
32
|
-
* decodes the binary bytes back to a UTF-8 string using TextDecoder.
|
|
33
|
-
*
|
|
34
|
-
* @param str - The Base64URL string to decode
|
|
35
|
-
* @returns Decoded UTF-8 string
|
|
36
|
-
*/
|
|
37
|
-
export declare function base64UrlDecode(str: string): string;
|
|
38
|
-
/**
|
|
39
|
-
* Convert a hex string to Uint8Array
|
|
40
|
-
*
|
|
41
|
-
* @param hex - The hex string
|
|
42
|
-
* @returns Uint8Array of bytes
|
|
43
|
-
*/
|
|
44
|
-
export declare function hexToBytes(hex: string): Uint8Array;
|
|
45
|
-
/**
|
|
46
|
-
* Convert Uint8Array to hex string
|
|
47
|
-
*
|
|
48
|
-
* @param bytes - The bytes to convert
|
|
49
|
-
* @returns Hex string
|
|
50
|
-
*/
|
|
51
|
-
export declare function bytesToHex(bytes: Uint8Array): string;
|
|
6
|
+
export { base64UrlEncode, base64UrlEncodeBytes, base64UrlDecode, base64UrlDecodeBytes, hexToBytes, bytesToHex, } from '@xivdyetools/crypto';
|
|
52
7
|
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/utils/crypto.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/utils/crypto.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,UAAU,EACV,UAAU,GACX,MAAM,qBAAqB,CAAC"}
|
package/dist/utils/crypto.js
CHANGED
|
@@ -1,92 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cryptographic utilities for test helpers
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* REFACTOR-001: Re-exports from @xivdyetools/crypto to consolidate implementations
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
* Encode a string to Base64URL format (RFC 4648)
|
|
8
|
-
* Used for JWT header and payload encoding
|
|
9
|
-
*
|
|
10
|
-
* @param str - The string to encode
|
|
11
|
-
* @returns Base64URL encoded string
|
|
12
|
-
*/
|
|
13
|
-
export function base64UrlEncode(str) {
|
|
14
|
-
const bytes = new TextEncoder().encode(str);
|
|
15
|
-
let binary = '';
|
|
16
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
17
|
-
binary += String.fromCharCode(bytes[i]);
|
|
18
|
-
}
|
|
19
|
-
return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Encode bytes to Base64URL format
|
|
23
|
-
*
|
|
24
|
-
* @param bytes - The bytes to encode
|
|
25
|
-
* @returns Base64URL encoded string
|
|
26
|
-
*/
|
|
27
|
-
export function base64UrlEncodeBytes(bytes) {
|
|
28
|
-
let binary = '';
|
|
29
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
30
|
-
binary += String.fromCharCode(bytes[i]);
|
|
31
|
-
}
|
|
32
|
-
return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Decode a Base64URL string to bytes
|
|
36
|
-
*
|
|
37
|
-
* @param str - The Base64URL string to decode
|
|
38
|
-
* @returns Decoded bytes as Uint8Array
|
|
39
|
-
*/
|
|
40
|
-
export function base64UrlDecodeBytes(str) {
|
|
41
|
-
// Add padding if needed
|
|
42
|
-
let base64 = str.replace(/-/g, '+').replace(/_/g, '/');
|
|
43
|
-
while (base64.length % 4) {
|
|
44
|
-
base64 += '=';
|
|
45
|
-
}
|
|
46
|
-
// Decode to binary string
|
|
47
|
-
const binary = atob(base64);
|
|
48
|
-
// Convert binary string to Uint8Array
|
|
49
|
-
const bytes = new Uint8Array(binary.length);
|
|
50
|
-
for (let i = 0; i < binary.length; i++) {
|
|
51
|
-
bytes[i] = binary.charCodeAt(i);
|
|
52
|
-
}
|
|
53
|
-
return bytes;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Decode a Base64URL string
|
|
57
|
-
*
|
|
58
|
-
* NOTE: For proper UTF-8 roundtrip with base64UrlEncode(), this function
|
|
59
|
-
* decodes the binary bytes back to a UTF-8 string using TextDecoder.
|
|
60
|
-
*
|
|
61
|
-
* @param str - The Base64URL string to decode
|
|
62
|
-
* @returns Decoded UTF-8 string
|
|
63
|
-
*/
|
|
64
|
-
export function base64UrlDecode(str) {
|
|
65
|
-
const bytes = base64UrlDecodeBytes(str);
|
|
66
|
-
return new TextDecoder().decode(bytes);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Convert a hex string to Uint8Array
|
|
70
|
-
*
|
|
71
|
-
* @param hex - The hex string
|
|
72
|
-
* @returns Uint8Array of bytes
|
|
73
|
-
*/
|
|
74
|
-
export function hexToBytes(hex) {
|
|
75
|
-
const bytes = new Uint8Array(hex.length / 2);
|
|
76
|
-
for (let i = 0; i < hex.length; i += 2) {
|
|
77
|
-
bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16);
|
|
78
|
-
}
|
|
79
|
-
return bytes;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Convert Uint8Array to hex string
|
|
83
|
-
*
|
|
84
|
-
* @param bytes - The bytes to convert
|
|
85
|
-
* @returns Hex string
|
|
86
|
-
*/
|
|
87
|
-
export function bytesToHex(bytes) {
|
|
88
|
-
return Array.from(bytes)
|
|
89
|
-
.map((b) => b.toString(16).padStart(2, '0'))
|
|
90
|
-
.join('');
|
|
91
|
-
}
|
|
6
|
+
export { base64UrlEncode, base64UrlEncodeBytes, base64UrlDecode, base64UrlDecodeBytes, hexToBytes, bytesToHex, } from '@xivdyetools/crypto';
|
|
92
7
|
//# sourceMappingURL=crypto.js.map
|
package/dist/utils/crypto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/utils/crypto.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/utils/crypto.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,UAAU,EACV,UAAU,GACX,MAAM,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xivdyetools/test-utils",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Shared testing utilities for the xivdyetools ecosystem",
|
|
5
5
|
"author": "XIV Dye Tools",
|
|
6
6
|
"license": "MIT",
|
|
@@ -60,13 +60,14 @@
|
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
+
"@xivdyetools/crypto": "^1.0.0",
|
|
63
64
|
"@xivdyetools/types": "^1.1.1"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
67
|
"@cloudflare/workers-types": "^4.20241205.0",
|
|
67
68
|
"@testing-library/dom": "^10.0.0",
|
|
68
69
|
"@vitest/coverage-v8": "^4.0.15",
|
|
69
|
-
"rimraf": "^
|
|
70
|
+
"rimraf": "^6.1.2",
|
|
70
71
|
"typescript": "^5.9.3",
|
|
71
72
|
"vitest": "^4.0.15"
|
|
72
73
|
},
|