@b3dotfun/sdk 0.0.70-alpha.1 → 0.0.70

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.
Files changed (123) hide show
  1. package/dist/cjs/anyspend/index.d.ts +0 -1
  2. package/dist/cjs/anyspend/index.js +0 -1
  3. package/dist/cjs/anyspend/react/components/AnySpend.d.ts +0 -6
  4. package/dist/cjs/anyspend/react/components/AnySpend.js +1 -13
  5. package/dist/cjs/anyspend/react/components/AnySpendBondKit.d.ts +1 -3
  6. package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +2 -2
  7. package/dist/cjs/anyspend/react/components/AnySpendBuySpin.d.ts +1 -2
  8. package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +2 -2
  9. package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +0 -1
  10. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +2 -6
  11. package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +0 -1
  12. package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +1 -3
  13. package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.d.ts +1 -2
  14. package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.js +2 -2
  15. package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +1 -2
  16. package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
  17. package/dist/cjs/anyspend/react/components/AnySpendStakeB3.d.ts +1 -2
  18. package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +2 -2
  19. package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +1 -2
  20. package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +2 -2
  21. package/dist/cjs/anyspend/react/components/AnySpendStakeUpside.d.ts +1 -2
  22. package/dist/cjs/anyspend/react/components/AnySpendStakeUpside.js +2 -2
  23. package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +1 -2
  24. package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
  25. package/dist/cjs/anyspend/react/components/AnySpendTournament.d.ts +0 -2
  26. package/dist/cjs/anyspend/react/components/AnySpendTournament.js +1 -1
  27. package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +1 -2
  28. package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +2 -2
  29. package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.d.ts +1 -2
  30. package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +2 -2
  31. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +1 -2
  32. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +0 -1
  33. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +1 -2
  34. package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +0 -16
  35. package/dist/cjs/anyspend/services/anyspend.d.ts +1 -2
  36. package/dist/cjs/anyspend/services/anyspend.js +1 -2
  37. package/dist/cjs/anyspend/types/api.d.ts +0 -295
  38. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +0 -4
  39. package/dist/esm/anyspend/index.d.ts +0 -1
  40. package/dist/esm/anyspend/index.js +0 -1
  41. package/dist/esm/anyspend/react/components/AnySpend.d.ts +0 -6
  42. package/dist/esm/anyspend/react/components/AnySpend.js +1 -13
  43. package/dist/esm/anyspend/react/components/AnySpendBondKit.d.ts +1 -3
  44. package/dist/esm/anyspend/react/components/AnySpendBondKit.js +2 -2
  45. package/dist/esm/anyspend/react/components/AnySpendBuySpin.d.ts +1 -2
  46. package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +2 -2
  47. package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +0 -1
  48. package/dist/esm/anyspend/react/components/AnySpendCustom.js +2 -6
  49. package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +0 -1
  50. package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +1 -3
  51. package/dist/esm/anyspend/react/components/AnySpendDepositUpside.d.ts +1 -2
  52. package/dist/esm/anyspend/react/components/AnySpendDepositUpside.js +2 -2
  53. package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +1 -2
  54. package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
  55. package/dist/esm/anyspend/react/components/AnySpendStakeB3.d.ts +1 -2
  56. package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +2 -2
  57. package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +1 -2
  58. package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +2 -2
  59. package/dist/esm/anyspend/react/components/AnySpendStakeUpside.d.ts +1 -2
  60. package/dist/esm/anyspend/react/components/AnySpendStakeUpside.js +2 -2
  61. package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +1 -2
  62. package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
  63. package/dist/esm/anyspend/react/components/AnySpendTournament.d.ts +0 -2
  64. package/dist/esm/anyspend/react/components/AnySpendTournament.js +1 -1
  65. package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +1 -2
  66. package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +2 -2
  67. package/dist/esm/anyspend/react/components/AnyspendSignatureMint.d.ts +1 -2
  68. package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +2 -2
  69. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +1 -2
  70. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +0 -1
  71. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +1 -2
  72. package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +0 -16
  73. package/dist/esm/anyspend/services/anyspend.d.ts +1 -2
  74. package/dist/esm/anyspend/services/anyspend.js +1 -2
  75. package/dist/esm/anyspend/types/api.d.ts +0 -295
  76. package/dist/esm/global-account/react/stores/useModalStore.d.ts +0 -4
  77. package/dist/types/anyspend/index.d.ts +0 -1
  78. package/dist/types/anyspend/react/components/AnySpend.d.ts +0 -6
  79. package/dist/types/anyspend/react/components/AnySpendBondKit.d.ts +1 -3
  80. package/dist/types/anyspend/react/components/AnySpendBuySpin.d.ts +1 -2
  81. package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +0 -1
  82. package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +0 -1
  83. package/dist/types/anyspend/react/components/AnySpendDepositUpside.d.ts +1 -2
  84. package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +1 -2
  85. package/dist/types/anyspend/react/components/AnySpendStakeB3.d.ts +1 -2
  86. package/dist/types/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +1 -2
  87. package/dist/types/anyspend/react/components/AnySpendStakeUpside.d.ts +1 -2
  88. package/dist/types/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +1 -2
  89. package/dist/types/anyspend/react/components/AnySpendTournament.d.ts +0 -2
  90. package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +1 -2
  91. package/dist/types/anyspend/react/components/AnyspendSignatureMint.d.ts +1 -2
  92. package/dist/types/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +0 -1
  93. package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +0 -16
  94. package/dist/types/anyspend/services/anyspend.d.ts +1 -2
  95. package/dist/types/anyspend/types/api.d.ts +0 -295
  96. package/dist/types/global-account/react/stores/useModalStore.d.ts +0 -4
  97. package/package.json +1 -1
  98. package/src/anyspend/index.ts +0 -1
  99. package/src/anyspend/react/components/AnySpend.tsx +0 -23
  100. package/src/anyspend/react/components/AnySpendBondKit.tsx +1 -3
  101. package/src/anyspend/react/components/AnySpendBuySpin.tsx +0 -3
  102. package/src/anyspend/react/components/AnySpendCustom.tsx +1 -8
  103. package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +0 -4
  104. package/src/anyspend/react/components/AnySpendDepositUpside.tsx +0 -3
  105. package/src/anyspend/react/components/AnySpendNFT.tsx +0 -3
  106. package/src/anyspend/react/components/AnySpendStakeB3.tsx +0 -3
  107. package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +0 -3
  108. package/src/anyspend/react/components/AnySpendStakeUpside.tsx +0 -3
  109. package/src/anyspend/react/components/AnySpendStakeUpsideExactIn.tsx +0 -3
  110. package/src/anyspend/react/components/AnySpendTournament.tsx +0 -3
  111. package/src/anyspend/react/components/AnyspendDepositHype.tsx +0 -3
  112. package/src/anyspend/react/components/AnyspendSignatureMint.tsx +0 -3
  113. package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +0 -2
  114. package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +1 -13
  115. package/src/anyspend/services/anyspend.ts +0 -3
  116. package/src/anyspend/types/api.ts +0 -295
  117. package/src/global-account/react/stores/useModalStore.ts +0 -4
  118. package/dist/cjs/anyspend/utils/validation.d.ts +0 -67
  119. package/dist/cjs/anyspend/utils/validation.js +0 -157
  120. package/dist/esm/anyspend/utils/validation.d.ts +0 -67
  121. package/dist/esm/anyspend/utils/validation.js +0 -153
  122. package/dist/types/anyspend/utils/validation.d.ts +0 -67
  123. package/src/anyspend/utils/validation.ts +0 -209
@@ -1,67 +0,0 @@
1
- export interface ValidationResult {
2
- isValid: boolean;
3
- error?: string;
4
- cleaned?: string;
5
- }
6
- export interface StringValidationOptions {
7
- required?: boolean;
8
- defaultValue?: () => string;
9
- minLength?: number;
10
- maxLength?: number;
11
- pattern?: RegExp;
12
- patternErrorMessage?: string;
13
- trim?: boolean;
14
- toLowerCase?: boolean;
15
- toUpperCase?: boolean;
16
- customValidator?: (value: string) => {
17
- valid: boolean;
18
- error?: string;
19
- };
20
- }
21
- /**
22
- * Generic string validator with configurable rules
23
- */
24
- export declare function validateString(value: string | undefined, options: StringValidationOptions): ValidationResult;
25
- /**
26
- * Common validation patterns
27
- */
28
- export declare const ValidationPatterns: {
29
- readonly ALPHANUMERIC: RegExp;
30
- readonly ALPHANUMERIC_WITH_DASH_UNDERSCORE: RegExp;
31
- readonly ALPHANUMERIC_WITH_SAFE_CHARS: RegExp;
32
- readonly SAFE_IDENTIFIER: RegExp;
33
- readonly NO_CONTROL_CHARS: RegExp;
34
- readonly URL_SAFE: RegExp;
35
- readonly NUMERIC: RegExp;
36
- readonly HEX: RegExp;
37
- };
38
- /**
39
- * Pre-configured validators for common use cases
40
- */
41
- export declare const Validators: {
42
- /**
43
- * Validates client reference IDs (alphanumeric + safe chars)
44
- * Returns undefined if not provided
45
- */
46
- clientReferenceId: (value?: string) => ValidationResult;
47
- /**
48
- * Validates alphanumeric strings (letters and numbers only)
49
- */
50
- alphanumeric: (value?: string, required?: boolean) => ValidationResult;
51
- /**
52
- * Validates wallet addresses (hex format)
53
- */
54
- walletAddress: (value?: string, required?: boolean) => ValidationResult;
55
- /**
56
- * Validates order IDs (UUID format)
57
- */
58
- orderId: (value?: string) => ValidationResult;
59
- /**
60
- * Validates URL-safe strings
61
- */
62
- urlSafe: (value?: string, maxLength?: number) => ValidationResult;
63
- /**
64
- * Validates safe identifiers (no injection risks)
65
- */
66
- safeIdentifier: (value?: string, required?: boolean) => ValidationResult;
67
- };
@@ -1,157 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Validators = exports.ValidationPatterns = void 0;
4
- exports.validateString = validateString;
5
- /**
6
- * Generic string validator with configurable rules
7
- */
8
- function validateString(value, options) {
9
- const { required = false, defaultValue, minLength, maxLength, pattern, patternErrorMessage, trim = true, toLowerCase = false, toUpperCase = false, customValidator, } = options;
10
- // Handle empty/undefined
11
- if (!value || (trim && value.trim() === "")) {
12
- if (required && !defaultValue) {
13
- return { isValid: false, error: "This field is required" };
14
- }
15
- if (defaultValue) {
16
- return { isValid: true, cleaned: defaultValue() };
17
- }
18
- return { isValid: true, cleaned: undefined };
19
- }
20
- // Pre-processing
21
- let cleaned = value;
22
- if (trim)
23
- cleaned = cleaned.trim();
24
- if (toLowerCase)
25
- cleaned = cleaned.toLowerCase();
26
- if (toUpperCase)
27
- cleaned = cleaned.toUpperCase();
28
- // Length validation
29
- if (minLength !== undefined && cleaned.length < minLength) {
30
- return {
31
- isValid: false,
32
- error: `Minimum length is ${minLength} characters`,
33
- };
34
- }
35
- if (maxLength !== undefined && cleaned.length > maxLength) {
36
- return {
37
- isValid: false,
38
- error: `Maximum length is ${maxLength} characters`,
39
- };
40
- }
41
- // Pattern validation
42
- if (pattern && !pattern.test(cleaned)) {
43
- return {
44
- isValid: false,
45
- error: patternErrorMessage || "Invalid format",
46
- };
47
- }
48
- // Custom validation
49
- if (customValidator) {
50
- const customResult = customValidator(cleaned);
51
- if (!customResult.valid) {
52
- return { isValid: false, error: customResult.error };
53
- }
54
- }
55
- return { isValid: true, cleaned };
56
- }
57
- /**
58
- * Common validation patterns
59
- */
60
- exports.ValidationPatterns = {
61
- ALPHANUMERIC: /^[a-zA-Z0-9]+$/,
62
- ALPHANUMERIC_WITH_DASH_UNDERSCORE: /^[a-zA-Z0-9_-]+$/,
63
- ALPHANUMERIC_WITH_SAFE_CHARS: /^[a-zA-Z0-9_.\-]+$/,
64
- SAFE_IDENTIFIER: /^[a-zA-Z0-9_.\-]+$/, // For IDs, references
65
- NO_CONTROL_CHARS: /^[^\x00-\x1F\x7F]+$/,
66
- URL_SAFE: /^[a-zA-Z0-9_.\-~]+$/,
67
- NUMERIC: /^\d+$/,
68
- HEX: /^[0-9a-fA-F]+$/,
69
- };
70
- /**
71
- * Pre-configured validators for common use cases
72
- */
73
- exports.Validators = {
74
- /**
75
- * Validates client reference IDs (alphanumeric + safe chars)
76
- * Returns undefined if not provided
77
- */
78
- clientReferenceId: (value) => validateString(value, {
79
- required: false,
80
- maxLength: 255,
81
- pattern: exports.ValidationPatterns.SAFE_IDENTIFIER,
82
- patternErrorMessage: "Only letters, numbers, hyphens, underscores, and dots allowed",
83
- trim: true,
84
- customValidator: val => {
85
- // Additional security checks
86
- const dangerous = /('|"|;|--|\/\*|\*\/|<|>|script)/i;
87
- if (dangerous.test(val)) {
88
- return {
89
- valid: false,
90
- error: "Contains potentially dangerous characters",
91
- };
92
- }
93
- return { valid: true };
94
- },
95
- }),
96
- /**
97
- * Validates alphanumeric strings (letters and numbers only)
98
- */
99
- alphanumeric: (value, required = false) => validateString(value, {
100
- required,
101
- pattern: exports.ValidationPatterns.ALPHANUMERIC,
102
- patternErrorMessage: "Only letters and numbers allowed",
103
- trim: true,
104
- }),
105
- /**
106
- * Validates wallet addresses (hex format)
107
- */
108
- walletAddress: (value, required = true) => validateString(value, {
109
- required,
110
- minLength: 42,
111
- maxLength: 42,
112
- pattern: /^0x[a-fA-F0-9]{40}$/,
113
- patternErrorMessage: "Invalid wallet address format",
114
- trim: true,
115
- toLowerCase: true,
116
- }),
117
- /**
118
- * Validates order IDs (UUID format)
119
- */
120
- orderId: (value) => validateString(value, {
121
- required: false,
122
- pattern: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
123
- patternErrorMessage: "Invalid order ID format",
124
- trim: true,
125
- toLowerCase: true,
126
- }),
127
- /**
128
- * Validates URL-safe strings
129
- */
130
- urlSafe: (value, maxLength = 255) => validateString(value, {
131
- maxLength,
132
- pattern: exports.ValidationPatterns.URL_SAFE,
133
- patternErrorMessage: "Contains invalid URL characters",
134
- trim: true,
135
- }),
136
- /**
137
- * Validates safe identifiers (no injection risks)
138
- */
139
- safeIdentifier: (value, required = false) => validateString(value, {
140
- required,
141
- maxLength: 255,
142
- pattern: exports.ValidationPatterns.SAFE_IDENTIFIER,
143
- patternErrorMessage: "Invalid identifier format",
144
- customValidator: val => {
145
- // Additional security checks
146
- const dangerous = /('|"|;|--|\/\*|\*\/|<|>|script)/i;
147
- if (dangerous.test(val)) {
148
- return {
149
- valid: false,
150
- error: "Contains potentially dangerous characters",
151
- };
152
- }
153
- return { valid: true };
154
- },
155
- trim: true,
156
- }),
157
- };
@@ -1,67 +0,0 @@
1
- export interface ValidationResult {
2
- isValid: boolean;
3
- error?: string;
4
- cleaned?: string;
5
- }
6
- export interface StringValidationOptions {
7
- required?: boolean;
8
- defaultValue?: () => string;
9
- minLength?: number;
10
- maxLength?: number;
11
- pattern?: RegExp;
12
- patternErrorMessage?: string;
13
- trim?: boolean;
14
- toLowerCase?: boolean;
15
- toUpperCase?: boolean;
16
- customValidator?: (value: string) => {
17
- valid: boolean;
18
- error?: string;
19
- };
20
- }
21
- /**
22
- * Generic string validator with configurable rules
23
- */
24
- export declare function validateString(value: string | undefined, options: StringValidationOptions): ValidationResult;
25
- /**
26
- * Common validation patterns
27
- */
28
- export declare const ValidationPatterns: {
29
- readonly ALPHANUMERIC: RegExp;
30
- readonly ALPHANUMERIC_WITH_DASH_UNDERSCORE: RegExp;
31
- readonly ALPHANUMERIC_WITH_SAFE_CHARS: RegExp;
32
- readonly SAFE_IDENTIFIER: RegExp;
33
- readonly NO_CONTROL_CHARS: RegExp;
34
- readonly URL_SAFE: RegExp;
35
- readonly NUMERIC: RegExp;
36
- readonly HEX: RegExp;
37
- };
38
- /**
39
- * Pre-configured validators for common use cases
40
- */
41
- export declare const Validators: {
42
- /**
43
- * Validates client reference IDs (alphanumeric + safe chars)
44
- * Returns undefined if not provided
45
- */
46
- clientReferenceId: (value?: string) => ValidationResult;
47
- /**
48
- * Validates alphanumeric strings (letters and numbers only)
49
- */
50
- alphanumeric: (value?: string, required?: boolean) => ValidationResult;
51
- /**
52
- * Validates wallet addresses (hex format)
53
- */
54
- walletAddress: (value?: string, required?: boolean) => ValidationResult;
55
- /**
56
- * Validates order IDs (UUID format)
57
- */
58
- orderId: (value?: string) => ValidationResult;
59
- /**
60
- * Validates URL-safe strings
61
- */
62
- urlSafe: (value?: string, maxLength?: number) => ValidationResult;
63
- /**
64
- * Validates safe identifiers (no injection risks)
65
- */
66
- safeIdentifier: (value?: string, required?: boolean) => ValidationResult;
67
- };
@@ -1,153 +0,0 @@
1
- /**
2
- * Generic string validator with configurable rules
3
- */
4
- export function validateString(value, options) {
5
- const { required = false, defaultValue, minLength, maxLength, pattern, patternErrorMessage, trim = true, toLowerCase = false, toUpperCase = false, customValidator, } = options;
6
- // Handle empty/undefined
7
- if (!value || (trim && value.trim() === "")) {
8
- if (required && !defaultValue) {
9
- return { isValid: false, error: "This field is required" };
10
- }
11
- if (defaultValue) {
12
- return { isValid: true, cleaned: defaultValue() };
13
- }
14
- return { isValid: true, cleaned: undefined };
15
- }
16
- // Pre-processing
17
- let cleaned = value;
18
- if (trim)
19
- cleaned = cleaned.trim();
20
- if (toLowerCase)
21
- cleaned = cleaned.toLowerCase();
22
- if (toUpperCase)
23
- cleaned = cleaned.toUpperCase();
24
- // Length validation
25
- if (minLength !== undefined && cleaned.length < minLength) {
26
- return {
27
- isValid: false,
28
- error: `Minimum length is ${minLength} characters`,
29
- };
30
- }
31
- if (maxLength !== undefined && cleaned.length > maxLength) {
32
- return {
33
- isValid: false,
34
- error: `Maximum length is ${maxLength} characters`,
35
- };
36
- }
37
- // Pattern validation
38
- if (pattern && !pattern.test(cleaned)) {
39
- return {
40
- isValid: false,
41
- error: patternErrorMessage || "Invalid format",
42
- };
43
- }
44
- // Custom validation
45
- if (customValidator) {
46
- const customResult = customValidator(cleaned);
47
- if (!customResult.valid) {
48
- return { isValid: false, error: customResult.error };
49
- }
50
- }
51
- return { isValid: true, cleaned };
52
- }
53
- /**
54
- * Common validation patterns
55
- */
56
- export const ValidationPatterns = {
57
- ALPHANUMERIC: /^[a-zA-Z0-9]+$/,
58
- ALPHANUMERIC_WITH_DASH_UNDERSCORE: /^[a-zA-Z0-9_-]+$/,
59
- ALPHANUMERIC_WITH_SAFE_CHARS: /^[a-zA-Z0-9_.\-]+$/,
60
- SAFE_IDENTIFIER: /^[a-zA-Z0-9_.\-]+$/, // For IDs, references
61
- NO_CONTROL_CHARS: /^[^\x00-\x1F\x7F]+$/,
62
- URL_SAFE: /^[a-zA-Z0-9_.\-~]+$/,
63
- NUMERIC: /^\d+$/,
64
- HEX: /^[0-9a-fA-F]+$/,
65
- };
66
- /**
67
- * Pre-configured validators for common use cases
68
- */
69
- export const Validators = {
70
- /**
71
- * Validates client reference IDs (alphanumeric + safe chars)
72
- * Returns undefined if not provided
73
- */
74
- clientReferenceId: (value) => validateString(value, {
75
- required: false,
76
- maxLength: 255,
77
- pattern: ValidationPatterns.SAFE_IDENTIFIER,
78
- patternErrorMessage: "Only letters, numbers, hyphens, underscores, and dots allowed",
79
- trim: true,
80
- customValidator: val => {
81
- // Additional security checks
82
- const dangerous = /('|"|;|--|\/\*|\*\/|<|>|script)/i;
83
- if (dangerous.test(val)) {
84
- return {
85
- valid: false,
86
- error: "Contains potentially dangerous characters",
87
- };
88
- }
89
- return { valid: true };
90
- },
91
- }),
92
- /**
93
- * Validates alphanumeric strings (letters and numbers only)
94
- */
95
- alphanumeric: (value, required = false) => validateString(value, {
96
- required,
97
- pattern: ValidationPatterns.ALPHANUMERIC,
98
- patternErrorMessage: "Only letters and numbers allowed",
99
- trim: true,
100
- }),
101
- /**
102
- * Validates wallet addresses (hex format)
103
- */
104
- walletAddress: (value, required = true) => validateString(value, {
105
- required,
106
- minLength: 42,
107
- maxLength: 42,
108
- pattern: /^0x[a-fA-F0-9]{40}$/,
109
- patternErrorMessage: "Invalid wallet address format",
110
- trim: true,
111
- toLowerCase: true,
112
- }),
113
- /**
114
- * Validates order IDs (UUID format)
115
- */
116
- orderId: (value) => validateString(value, {
117
- required: false,
118
- pattern: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
119
- patternErrorMessage: "Invalid order ID format",
120
- trim: true,
121
- toLowerCase: true,
122
- }),
123
- /**
124
- * Validates URL-safe strings
125
- */
126
- urlSafe: (value, maxLength = 255) => validateString(value, {
127
- maxLength,
128
- pattern: ValidationPatterns.URL_SAFE,
129
- patternErrorMessage: "Contains invalid URL characters",
130
- trim: true,
131
- }),
132
- /**
133
- * Validates safe identifiers (no injection risks)
134
- */
135
- safeIdentifier: (value, required = false) => validateString(value, {
136
- required,
137
- maxLength: 255,
138
- pattern: ValidationPatterns.SAFE_IDENTIFIER,
139
- patternErrorMessage: "Invalid identifier format",
140
- customValidator: val => {
141
- // Additional security checks
142
- const dangerous = /('|"|;|--|\/\*|\*\/|<|>|script)/i;
143
- if (dangerous.test(val)) {
144
- return {
145
- valid: false,
146
- error: "Contains potentially dangerous characters",
147
- };
148
- }
149
- return { valid: true };
150
- },
151
- trim: true,
152
- }),
153
- };
@@ -1,67 +0,0 @@
1
- export interface ValidationResult {
2
- isValid: boolean;
3
- error?: string;
4
- cleaned?: string;
5
- }
6
- export interface StringValidationOptions {
7
- required?: boolean;
8
- defaultValue?: () => string;
9
- minLength?: number;
10
- maxLength?: number;
11
- pattern?: RegExp;
12
- patternErrorMessage?: string;
13
- trim?: boolean;
14
- toLowerCase?: boolean;
15
- toUpperCase?: boolean;
16
- customValidator?: (value: string) => {
17
- valid: boolean;
18
- error?: string;
19
- };
20
- }
21
- /**
22
- * Generic string validator with configurable rules
23
- */
24
- export declare function validateString(value: string | undefined, options: StringValidationOptions): ValidationResult;
25
- /**
26
- * Common validation patterns
27
- */
28
- export declare const ValidationPatterns: {
29
- readonly ALPHANUMERIC: RegExp;
30
- readonly ALPHANUMERIC_WITH_DASH_UNDERSCORE: RegExp;
31
- readonly ALPHANUMERIC_WITH_SAFE_CHARS: RegExp;
32
- readonly SAFE_IDENTIFIER: RegExp;
33
- readonly NO_CONTROL_CHARS: RegExp;
34
- readonly URL_SAFE: RegExp;
35
- readonly NUMERIC: RegExp;
36
- readonly HEX: RegExp;
37
- };
38
- /**
39
- * Pre-configured validators for common use cases
40
- */
41
- export declare const Validators: {
42
- /**
43
- * Validates client reference IDs (alphanumeric + safe chars)
44
- * Returns undefined if not provided
45
- */
46
- clientReferenceId: (value?: string) => ValidationResult;
47
- /**
48
- * Validates alphanumeric strings (letters and numbers only)
49
- */
50
- alphanumeric: (value?: string, required?: boolean) => ValidationResult;
51
- /**
52
- * Validates wallet addresses (hex format)
53
- */
54
- walletAddress: (value?: string, required?: boolean) => ValidationResult;
55
- /**
56
- * Validates order IDs (UUID format)
57
- */
58
- orderId: (value?: string) => ValidationResult;
59
- /**
60
- * Validates URL-safe strings
61
- */
62
- urlSafe: (value?: string, maxLength?: number) => ValidationResult;
63
- /**
64
- * Validates safe identifiers (no injection risks)
65
- */
66
- safeIdentifier: (value?: string, required?: boolean) => ValidationResult;
67
- };