@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.
@@ -1,52 +1,7 @@
1
1
  /**
2
2
  * Cryptographic utilities for test helpers
3
3
  *
4
- * Provides Base64URL encoding for JWT creation and other crypto operations.
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;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOnD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAM9D;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAiB5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAMlD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIpD"}
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"}
@@ -1,92 +1,7 @@
1
1
  /**
2
2
  * Cryptographic utilities for test helpers
3
3
  *
4
- * Provides Base64URL encoding for JWT creation and other crypto operations.
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
@@ -1 +1 @@
1
- {"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/utils/crypto.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5C,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACjF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAiB;IACpD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACj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EAAE,EAAE,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,KAAiB;IAC1C,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;SACrB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SAC3C,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
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.0",
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": "^5.0.5",
70
+ "rimraf": "^6.1.2",
70
71
  "typescript": "^5.9.3",
71
72
  "vitest": "^4.0.15"
72
73
  },