@kya-os/consent 0.1.21 → 0.1.23

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 (161) hide show
  1. package/dist/bundle/inline.d.ts.map +1 -1
  2. package/dist/bundle/inline.js +2 -2
  3. package/dist/bundle/inline.js.map +1 -1
  4. package/dist/cjs/bundle/inline.js +2 -2
  5. package/dist/cjs/bundle/inline.js.map +1 -1
  6. package/dist/cjs/components/mcp-consent.js +0 -14
  7. package/dist/cjs/components/mcp-consent.js.map +1 -1
  8. package/dist/cjs/templates/modes/oauth.template.js +0 -28
  9. package/dist/cjs/templates/modes/oauth.template.js.map +1 -1
  10. package/dist/components/mcp-consent.d.ts.map +1 -1
  11. package/dist/components/mcp-consent.js +0 -14
  12. package/dist/components/mcp-consent.js.map +1 -1
  13. package/dist/consent.js +0 -14
  14. package/dist/consent.min.js +11 -25
  15. package/dist/templates/modes/oauth.template.d.ts.map +1 -1
  16. package/package.json +1 -1
  17. package/dist/bundle/index.d.ts +0 -44
  18. package/dist/bundle/shell.d.ts +0 -126
  19. package/dist/bundle/shell.js +0 -295
  20. package/dist/bundle/shell.js.map +0 -1
  21. package/dist/components/consent-button.d.ts +0 -61
  22. package/dist/components/consent-button.js +0 -177
  23. package/dist/components/consent-button.js.map +0 -1
  24. package/dist/components/consent-checkbox.d.ts +0 -61
  25. package/dist/components/consent-checkbox.js +0 -220
  26. package/dist/components/consent-checkbox.js.map +0 -1
  27. package/dist/components/consent-input.d.ts +0 -91
  28. package/dist/components/consent-input.js +0 -332
  29. package/dist/components/consent-input.js.map +0 -1
  30. package/dist/components/consent-oauth-button.d.ts +0 -87
  31. package/dist/components/consent-oauth-button.js +0 -389
  32. package/dist/components/consent-oauth-button.js.map +0 -1
  33. package/dist/components/consent-otp-input.d.ts +0 -92
  34. package/dist/components/consent-otp-input.js +0 -385
  35. package/dist/components/consent-otp-input.js.map +0 -1
  36. package/dist/components/consent-permissions.d.ts +0 -104
  37. package/dist/components/consent-permissions.js +0 -430
  38. package/dist/components/consent-permissions.js.map +0 -1
  39. package/dist/components/consent-shell.d.ts +0 -72
  40. package/dist/components/consent-shell.js +0 -231
  41. package/dist/components/consent-shell.js.map +0 -1
  42. package/dist/components/consent-terms.d.ts +0 -89
  43. package/dist/components/consent-terms.js +0 -284
  44. package/dist/components/consent-terms.js.map +0 -1
  45. package/dist/components/index.d.ts +0 -19
  46. package/dist/constants/auth-modes.d.ts +0 -59
  47. package/dist/constants/auth-modes.js +0 -120
  48. package/dist/constants/auth-modes.js.map +0 -1
  49. package/dist/constants/colors.d.ts +0 -38
  50. package/dist/constants/colors.js +0 -37
  51. package/dist/constants/colors.js.map +0 -1
  52. package/dist/constants/defaults.d.ts +0 -112
  53. package/dist/constants/defaults.js +0 -143
  54. package/dist/constants/defaults.js.map +0 -1
  55. package/dist/constants/index.d.ts +0 -12
  56. package/dist/constants/index.js +0 -16
  57. package/dist/constants/index.js.map +0 -1
  58. package/dist/index.d.ts +0 -19
  59. package/dist/index.js +0 -28
  60. package/dist/index.js.map +0 -1
  61. package/dist/react/index.d.ts +0 -123
  62. package/dist/resolution/index.d.ts +0 -12
  63. package/dist/resolution/index.js +0 -12
  64. package/dist/resolution/index.js.map +0 -1
  65. package/dist/resolution/resolve-branding.d.ts +0 -70
  66. package/dist/resolution/resolve-branding.js +0 -149
  67. package/dist/resolution/resolve-branding.js.map +0 -1
  68. package/dist/resolution/resolve-config.d.ts +0 -81
  69. package/dist/resolution/resolve-config.js +0 -258
  70. package/dist/resolution/resolve-config.js.map +0 -1
  71. package/dist/resolution/resolve-copy.d.ts +0 -53
  72. package/dist/resolution/resolve-copy.js +0 -128
  73. package/dist/resolution/resolve-copy.js.map +0 -1
  74. package/dist/schemas/api.schemas.js +0 -162
  75. package/dist/schemas/api.schemas.js.map +0 -1
  76. package/dist/schemas/branding.schemas.d.ts +0 -100
  77. package/dist/schemas/branding.schemas.js +0 -54
  78. package/dist/schemas/branding.schemas.js.map +0 -1
  79. package/dist/schemas/config.schemas.js +0 -141
  80. package/dist/schemas/config.schemas.js.map +0 -1
  81. package/dist/schemas/index.d.ts +0 -13
  82. package/dist/schemas/index.js +0 -13
  83. package/dist/schemas/index.js.map +0 -1
  84. package/dist/schemas/modes.schemas.js +0 -104
  85. package/dist/schemas/modes.schemas.js.map +0 -1
  86. package/dist/security/escape.d.ts +0 -114
  87. package/dist/security/escape.js +0 -197
  88. package/dist/security/escape.js.map +0 -1
  89. package/dist/security/index.d.ts +0 -10
  90. package/dist/security/index.js +0 -10
  91. package/dist/security/index.js.map +0 -1
  92. package/dist/security/validators.d.ts +0 -98
  93. package/dist/security/validators.js +0 -199
  94. package/dist/security/validators.js.map +0 -1
  95. package/dist/styles/css-variables.d.ts +0 -78
  96. package/dist/styles/css-variables.js +0 -120
  97. package/dist/styles/css-variables.js.map +0 -1
  98. package/dist/styles/index.d.ts +0 -12
  99. package/dist/styles/index.js +0 -12
  100. package/dist/styles/index.js.map +0 -1
  101. package/dist/styles/stylesheet.d.ts +0 -57
  102. package/dist/styles/stylesheet.js +0 -197
  103. package/dist/styles/stylesheet.js.map +0 -1
  104. package/dist/styles/tokens.d.ts +0 -141
  105. package/dist/styles/tokens.js +0 -180
  106. package/dist/styles/tokens.js.map +0 -1
  107. package/dist/templates/base/base-template.d.ts +0 -81
  108. package/dist/templates/base/base-template.js +0 -278
  109. package/dist/templates/base/base-template.js.map +0 -1
  110. package/dist/templates/base/components.d.ts +0 -120
  111. package/dist/templates/base/components.js +0 -279
  112. package/dist/templates/base/components.js.map +0 -1
  113. package/dist/templates/base/index.d.ts +0 -8
  114. package/dist/templates/base/index.js +0 -8
  115. package/dist/templates/base/index.js.map +0 -1
  116. package/dist/templates/index.d.ts +0 -18
  117. package/dist/templates/index.js +0 -18
  118. package/dist/templates/index.js.map +0 -1
  119. package/dist/templates/modes/consent-only.template.d.ts +0 -36
  120. package/dist/templates/modes/consent-only.template.js +0 -70
  121. package/dist/templates/modes/consent-only.template.js.map +0 -1
  122. package/dist/templates/modes/credentials.template.d.ts +0 -65
  123. package/dist/templates/modes/credentials.template.js +0 -410
  124. package/dist/templates/modes/credentials.template.js.map +0 -1
  125. package/dist/templates/modes/index.d.ts +0 -14
  126. package/dist/templates/modes/index.js +0 -14
  127. package/dist/templates/modes/index.js.map +0 -1
  128. package/dist/templates/modes/magic-link.template.d.ts +0 -33
  129. package/dist/templates/modes/magic-link.template.js +0 -192
  130. package/dist/templates/modes/magic-link.template.js.map +0 -1
  131. package/dist/templates/modes/oauth.template.d.ts +0 -40
  132. package/dist/templates/modes/oauth.template.js +0 -149
  133. package/dist/templates/modes/oauth.template.js.map +0 -1
  134. package/dist/templates/modes/otp.template.d.ts +0 -35
  135. package/dist/templates/modes/otp.template.js +0 -312
  136. package/dist/templates/modes/otp.template.js.map +0 -1
  137. package/dist/templates/modes/success.template.d.ts +0 -41
  138. package/dist/templates/registry.d.ts +0 -68
  139. package/dist/templates/registry.js +0 -125
  140. package/dist/templates/registry.js.map +0 -1
  141. package/dist/types/api.types.d.ts +0 -147
  142. package/dist/types/api.types.js +0 -9
  143. package/dist/types/api.types.js.map +0 -1
  144. package/dist/types/branding.types.d.ts +0 -53
  145. package/dist/types/branding.types.js +0 -9
  146. package/dist/types/branding.types.js.map +0 -1
  147. package/dist/types/config.types.d.ts +0 -201
  148. package/dist/types/config.types.js +0 -9
  149. package/dist/types/config.types.js.map +0 -1
  150. package/dist/types/copy.types.d.ts +0 -109
  151. package/dist/types/copy.types.js +0 -9
  152. package/dist/types/copy.types.js.map +0 -1
  153. package/dist/types/index.d.ts +0 -15
  154. package/dist/types/index.js +0 -15
  155. package/dist/types/index.js.map +0 -1
  156. package/dist/types/modes.types.d.ts +0 -287
  157. package/dist/types/modes.types.js +0 -136
  158. package/dist/types/modes.types.js.map +0 -1
  159. package/dist/types/page.types.d.ts +0 -120
  160. package/dist/types/page.types.js +0 -9
  161. package/dist/types/page.types.js.map +0 -1
@@ -1,104 +0,0 @@
1
- /**
2
- * Consent Mode Schemas
3
- *
4
- * Zod validation schemas for auth mode configurations.
5
- *
6
- * @module @kya-os/consent/schemas/modes
7
- */
8
- import { z } from "zod";
9
- import { AUTH_MODES } from "../types/modes.types.js";
10
- /**
11
- * Auth Mode Schema
12
- */
13
- export const AuthModeSchema = z.enum([
14
- AUTH_MODES.CONSENT_ONLY,
15
- AUTH_MODES.CREDENTIALS,
16
- AUTH_MODES.OAUTH,
17
- AUTH_MODES.MAGIC_LINK,
18
- AUTH_MODES.OTP,
19
- AUTH_MODES.QR_CODE,
20
- AUTH_MODES.PASSKEY,
21
- AUTH_MODES.IDV,
22
- ]);
23
- /**
24
- * Credentials Config Schema
25
- */
26
- export const CredentialsConfigSchema = z.object({
27
- usernameLabel: z.string().max(100).optional(),
28
- usernamePlaceholder: z.string().max(200).optional(),
29
- passwordLabel: z.string().max(100).optional(),
30
- passwordPlaceholder: z.string().max(200).optional(),
31
- showRememberMe: z.boolean().optional(),
32
- showForgotPassword: z.boolean().optional(),
33
- forgotPasswordUrl: z.string().url().optional(),
34
- });
35
- /**
36
- * OAuth Config Schema
37
- */
38
- export const OAuthConfigSchema = z.object({
39
- providerId: z.string().max(100).optional(),
40
- providerName: z.string().max(100).optional(),
41
- buttonText: z.string().max(100).optional(),
42
- });
43
- /**
44
- * Magic Link Config Schema
45
- */
46
- export const MagicLinkConfigSchema = z.object({
47
- enabled: z.boolean().optional(),
48
- emailLabel: z.string().max(100).optional(),
49
- emailPlaceholder: z.string().max(200).optional(),
50
- buttonText: z.string().max(100).optional(),
51
- resendCooldown: z.number().int().min(30).max(600).optional(),
52
- });
53
- /**
54
- * OTP Config Schema
55
- */
56
- export const OTPConfigSchema = z.object({
57
- enabled: z.boolean().optional(),
58
- phoneLabel: z.string().max(100).optional(),
59
- phonePlaceholder: z.string().max(200).optional(),
60
- instructions: z.string().max(500).optional(),
61
- digits: z.union([z.literal(4), z.literal(6), z.literal(8)]).optional(),
62
- resendCooldown: z.number().int().min(30).max(600).optional(),
63
- });
64
- /**
65
- * QR Code Config Schema
66
- */
67
- export const QRCodeConfigSchema = z.object({
68
- enabled: z.boolean().optional(),
69
- instructions: z.string().max(500).optional(),
70
- size: z.number().int().min(100).max(500).optional(),
71
- showManualEntry: z.boolean().optional(),
72
- });
73
- /**
74
- * Passkey Config Schema
75
- */
76
- export const PasskeyConfigSchema = z.object({
77
- enabled: z.boolean().optional(),
78
- instructions: z.string().max(500).optional(),
79
- buttonText: z.string().max(100).optional(),
80
- showCompatibilityInfo: z.boolean().optional(),
81
- });
82
- /**
83
- * IDV Config Schema
84
- */
85
- export const IDVConfigSchema = z.object({
86
- enabled: z.boolean().optional(),
87
- providerName: z.string().max(100).optional(),
88
- verificationType: z.enum(["document", "selfie", "both"]).optional(),
89
- instructions: z.string().max(500).optional(),
90
- estimatedTime: z.string().max(50).optional(),
91
- });
92
- /**
93
- * Mode Configs Schema
94
- */
95
- export const ModeConfigsSchema = z.object({
96
- credentials: CredentialsConfigSchema.optional(),
97
- oauth: OAuthConfigSchema.optional(),
98
- magicLink: MagicLinkConfigSchema.optional(),
99
- otp: OTPConfigSchema.optional(),
100
- qrCode: QRCodeConfigSchema.optional(),
101
- passkey: PasskeyConfigSchema.optional(),
102
- idv: IDVConfigSchema.optional(),
103
- });
104
- //# sourceMappingURL=modes.schemas.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modes.schemas.js","sourceRoot":"","sources":["../../src/schemas/modes.schemas.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC;IACnC,UAAU,CAAC,YAAY;IACvB,UAAU,CAAC,WAAW;IACtB,UAAU,CAAC,KAAK;IAChB,UAAU,CAAC,UAAU;IACrB,UAAU,CAAC,GAAG;IACd,UAAU,CAAC,OA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EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;IAC5C,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;CAC7C,CAAC,CAAC;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,WAAW,EAAE,uBAAuB,CAAC,QAAQ,EAAE;IAC/C,KAAK,EAAE,iBAAiB,CAAC,QAAQ,EAAE;IACnC,SAAS,EAAE,qBAAqB,CAAC,QAAQ,EAAE;IAC3C,GAAG,EAAE,eAAe,CAAC,QAAQ,EAAE;IAC/B,MAAM,EAAE,kBAAkB,CAAC,QAAQ,EAAE;IACrC,OAAO,EAAE,mBAAmB,CAAC,QAAQ,EAAE;IACvC,GAAG,EAAE,eAAe,CAAC,QAAQ,EAAE;CAChC,CAAC,CAAC"}
@@ -1,114 +0,0 @@
1
- /**
2
- * HTML/JS Escape Utilities
3
- *
4
- * XSS prevention utilities for rendering user content safely.
5
- *
6
- * @module @kya-os/consent/security/escape
7
- */
8
- /**
9
- * Escape HTML special characters to prevent XSS
10
- *
11
- * Converts characters that have special meaning in HTML to their
12
- * entity equivalents, making them safe to insert into HTML content.
13
- *
14
- * @param text - The text to escape
15
- * @returns HTML-safe string
16
- *
17
- * @example
18
- * ```typescript
19
- * escapeHtml('<script>alert("xss")</script>')
20
- * // Returns: '&lt;script&gt;alert(&quot;xss&quot;)&lt;/script&gt;'
21
- * ```
22
- */
23
- export declare function escapeHtml(text: string): string;
24
- /**
25
- * Escape text for use in HTML attributes
26
- *
27
- * More comprehensive escaping than escapeHtml, including backticks
28
- * and equals signs which can be dangerous in attribute contexts.
29
- *
30
- * @param value - The value to escape
31
- * @returns Attribute-safe string
32
- *
33
- * @example
34
- * ```typescript
35
- * escapeAttr('value" onclick="alert(1)')
36
- * // Returns: 'value&quot; onclick&#x3D;&quot;alert(1)'
37
- * ```
38
- */
39
- export declare function escapeAttr(value: string): string;
40
- /**
41
- * Escape text for use in JavaScript strings
42
- *
43
- * Uses JSON.stringify to properly escape all special characters
44
- * that could break out of a JavaScript string context.
45
- *
46
- * @param text - The text to escape
47
- * @returns JS-safe string (without surrounding quotes)
48
- *
49
- * @example
50
- * ```typescript
51
- * escapeJs('hello\nworld')
52
- * // Returns: '"hello\\nworld"' (with quotes from JSON.stringify)
53
- * ```
54
- */
55
- export declare function escapeJs(text: string): string;
56
- /**
57
- * Escape text for use in JavaScript, returning value without quotes
58
- *
59
- * @param text - The text to escape
60
- * @returns JS-safe string content (without surrounding quotes)
61
- *
62
- * @example
63
- * ```typescript
64
- * escapeJsValue('hello\nworld')
65
- * // Returns: 'hello\\nworld'
66
- * ```
67
- */
68
- export declare function escapeJsValue(text: string): string;
69
- /**
70
- * Escape URL for use in href or src attributes
71
- *
72
- * Only allows http, https, and mailto protocols. Returns empty
73
- * string for dangerous protocols like javascript:.
74
- *
75
- * @param url - The URL to escape
76
- * @returns Safe URL or empty string
77
- *
78
- * @example
79
- * ```typescript
80
- * escapeUrl('javascript:alert(1)')
81
- * // Returns: ''
82
- *
83
- * escapeUrl('https://example.com/?q=test')
84
- * // Returns: 'https://example.com/?q=test'
85
- * ```
86
- */
87
- export declare function escapeUrl(url: string | undefined): string;
88
- /**
89
- * Create a safe HTML string from template literals
90
- *
91
- * Automatically escapes interpolated values while preserving
92
- * the template structure.
93
- *
94
- * @param strings - Template literal strings
95
- * @param values - Interpolated values to escape
96
- * @returns Safe HTML string
97
- *
98
- * @example
99
- * ```typescript
100
- * const userInput = '<script>alert("xss")</script>';
101
- * const html = safeHtml`<div>${userInput}</div>`;
102
- * // Returns: '<div>&lt;script&gt;alert(&quot;xss&quot;)&lt;/script&gt;</div>'
103
- * ```
104
- */
105
- export declare function safeHtml(strings: TemplateStringsArray, ...values: unknown[]): string;
106
- /**
107
- * Create a safe attribute value from template literals
108
- *
109
- * @param strings - Template literal strings
110
- * @param values - Interpolated values to escape
111
- * @returns Safe attribute string
112
- */
113
- export declare function safeAttr(strings: TemplateStringsArray, ...values: unknown[]): string;
114
- //# sourceMappingURL=escape.d.ts.map
@@ -1,197 +0,0 @@
1
- /**
2
- * HTML/JS Escape Utilities
3
- *
4
- * XSS prevention utilities for rendering user content safely.
5
- *
6
- * @module @kya-os/consent/security/escape
7
- */
8
- /**
9
- * HTML entities to escape
10
- */
11
- const HTML_ESCAPE_MAP = {
12
- "&": "&amp;",
13
- "<": "&lt;",
14
- ">": "&gt;",
15
- '"': "&quot;",
16
- "'": "&#x27;",
17
- };
18
- /**
19
- * Additional characters to escape in attributes
20
- */
21
- const ATTR_ESCAPE_MAP = {
22
- ...HTML_ESCAPE_MAP,
23
- "`": "&#x60;",
24
- "=": "&#x3D;",
25
- };
26
- /**
27
- * Escape HTML special characters to prevent XSS
28
- *
29
- * Converts characters that have special meaning in HTML to their
30
- * entity equivalents, making them safe to insert into HTML content.
31
- *
32
- * @param text - The text to escape
33
- * @returns HTML-safe string
34
- *
35
- * @example
36
- * ```typescript
37
- * escapeHtml('<script>alert("xss")</script>')
38
- * // Returns: '&lt;script&gt;alert(&quot;xss&quot;)&lt;/script&gt;'
39
- * ```
40
- */
41
- export function escapeHtml(text) {
42
- if (!text)
43
- return "";
44
- return text.replace(/[&<>"']/g, (char) => HTML_ESCAPE_MAP[char] ?? char);
45
- }
46
- /**
47
- * Escape text for use in HTML attributes
48
- *
49
- * More comprehensive escaping than escapeHtml, including backticks
50
- * and equals signs which can be dangerous in attribute contexts.
51
- *
52
- * @param value - The value to escape
53
- * @returns Attribute-safe string
54
- *
55
- * @example
56
- * ```typescript
57
- * escapeAttr('value" onclick="alert(1)')
58
- * // Returns: 'value&quot; onclick&#x3D;&quot;alert(1)'
59
- * ```
60
- */
61
- export function escapeAttr(value) {
62
- if (!value)
63
- return "";
64
- return value.replace(/[&<>"'`=]/g, (char) => ATTR_ESCAPE_MAP[char] ?? char);
65
- }
66
- /**
67
- * Escape text for use in JavaScript strings
68
- *
69
- * Uses JSON.stringify to properly escape all special characters
70
- * that could break out of a JavaScript string context.
71
- *
72
- * @param text - The text to escape
73
- * @returns JS-safe string (without surrounding quotes)
74
- *
75
- * @example
76
- * ```typescript
77
- * escapeJs('hello\nworld')
78
- * // Returns: '"hello\\nworld"' (with quotes from JSON.stringify)
79
- * ```
80
- */
81
- export function escapeJs(text) {
82
- if (!text)
83
- return '""';
84
- return JSON.stringify(text);
85
- }
86
- /**
87
- * Escape text for use in JavaScript, returning value without quotes
88
- *
89
- * @param text - The text to escape
90
- * @returns JS-safe string content (without surrounding quotes)
91
- *
92
- * @example
93
- * ```typescript
94
- * escapeJsValue('hello\nworld')
95
- * // Returns: 'hello\\nworld'
96
- * ```
97
- */
98
- export function escapeJsValue(text) {
99
- if (!text)
100
- return "";
101
- // JSON.stringify adds quotes, remove them
102
- const escaped = JSON.stringify(text);
103
- return escaped.slice(1, -1);
104
- }
105
- /**
106
- * Escape URL for use in href or src attributes
107
- *
108
- * Only allows http, https, and mailto protocols. Returns empty
109
- * string for dangerous protocols like javascript:.
110
- *
111
- * @param url - The URL to escape
112
- * @returns Safe URL or empty string
113
- *
114
- * @example
115
- * ```typescript
116
- * escapeUrl('javascript:alert(1)')
117
- * // Returns: ''
118
- *
119
- * escapeUrl('https://example.com/?q=test')
120
- * // Returns: 'https://example.com/?q=test'
121
- * ```
122
- */
123
- export function escapeUrl(url) {
124
- if (!url)
125
- return "";
126
- // Check for dangerous protocols
127
- const lowerUrl = url.toLowerCase().trim();
128
- if (lowerUrl.startsWith("javascript:") ||
129
- lowerUrl.startsWith("data:") ||
130
- lowerUrl.startsWith("vbscript:") ||
131
- lowerUrl.startsWith("file:")) {
132
- return "";
133
- }
134
- // Try to parse as URL to validate
135
- try {
136
- const parsed = new URL(url);
137
- if (!["http:", "https:", "mailto:"].includes(parsed.protocol)) {
138
- return "";
139
- }
140
- }
141
- catch {
142
- // Block protocol-relative URLs (//evil.com) which bypass protocol checks
143
- if (url.startsWith("//")) {
144
- return "";
145
- }
146
- // If it's a relative URL (single slash, hash, or query), that's okay
147
- if (!url.startsWith("/") && !url.startsWith("#") && !url.startsWith("?")) {
148
- // Absolute URL that failed to parse - unsafe
149
- return "";
150
- }
151
- }
152
- // Escape any HTML characters in the URL (but not = or ` which are safe in URLs)
153
- return escapeHtml(url);
154
- }
155
- /**
156
- * Create a safe HTML string from template literals
157
- *
158
- * Automatically escapes interpolated values while preserving
159
- * the template structure.
160
- *
161
- * @param strings - Template literal strings
162
- * @param values - Interpolated values to escape
163
- * @returns Safe HTML string
164
- *
165
- * @example
166
- * ```typescript
167
- * const userInput = '<script>alert("xss")</script>';
168
- * const html = safeHtml`<div>${userInput}</div>`;
169
- * // Returns: '<div>&lt;script&gt;alert(&quot;xss&quot;)&lt;/script&gt;</div>'
170
- * ```
171
- */
172
- export function safeHtml(strings, ...values) {
173
- let result = strings[0] ?? "";
174
- for (let i = 0; i < values.length; i++) {
175
- const value = values[i];
176
- const escaped = value === null || value === undefined ? "" : escapeHtml(String(value));
177
- result += escaped + (strings[i + 1] ?? "");
178
- }
179
- return result;
180
- }
181
- /**
182
- * Create a safe attribute value from template literals
183
- *
184
- * @param strings - Template literal strings
185
- * @param values - Interpolated values to escape
186
- * @returns Safe attribute string
187
- */
188
- export function safeAttr(strings, ...values) {
189
- let result = strings[0] ?? "";
190
- for (let i = 0; i < values.length; i++) {
191
- const value = values[i];
192
- const escaped = value === null || value === undefined ? "" : escapeAttr(String(value));
193
- result += escaped + (strings[i + 1] ?? "");
194
- }
195
- return result;
196
- }
197
- //# sourceMappingURL=escape.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"escape.js","sourceRoot":"","sources":["../../src/security/escape.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,eAAe,GAA2B;IAC9C,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,QAAQ;IACb,GAAG,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AAE,CAAC;QACvC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxB,MAAM,OAAO,GACX,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACzE,MAAM,IAAI,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CACtB,OAA6B,EAC7B,GAAG,MAAiB;IAEpB,IAAI,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxB,MAAM,OAAO,GACX,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACzE,MAAM,IAAI,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,10 +0,0 @@
1
- /**
2
- * Consent Security Utilities
3
- *
4
- * XSS prevention and input validation utilities.
5
- *
6
- * @module @kya-os/consent/security
7
- */
8
- export * from "./escape.js";
9
- export * from "./validators.js";
10
- //# sourceMappingURL=index.d.ts.map
@@ -1,10 +0,0 @@
1
- /**
2
- * Consent Security Utilities
3
- *
4
- * XSS prevention and input validation utilities.
5
- *
6
- * @module @kya-os/consent/security
7
- */
8
- export * from "./escape.js";
9
- export * from "./validators.js";
10
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/security/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
@@ -1,98 +0,0 @@
1
- /**
2
- * Security Validators
3
- *
4
- * Input validation utilities for secure rendering.
5
- *
6
- * @module @kya-os/consent/security/validators
7
- */
8
- /**
9
- * Validate that a string is a valid hex color
10
- *
11
- * Only accepts 6-digit hex colors with # prefix.
12
- *
13
- * @param color - Color string to validate
14
- * @returns The color if valid, undefined otherwise
15
- *
16
- * @example
17
- * ```typescript
18
- * validateColor('#2563EB') // Returns '#2563EB'
19
- * validateColor('2563EB') // Returns undefined
20
- * validateColor('#fff') // Returns undefined (3-digit not allowed)
21
- * ```
22
- */
23
- export declare function validateColor(color: string | undefined): string | undefined;
24
- /**
25
- * Validate that a string is a valid URL
26
- *
27
- * Only accepts http and https protocols.
28
- *
29
- * @param url - URL string to validate
30
- * @returns The URL if valid, undefined otherwise
31
- *
32
- * @example
33
- * ```typescript
34
- * validateUrl('https://example.com') // Returns 'https://example.com'
35
- * validateUrl('javascript:alert(1)') // Returns undefined
36
- * validateUrl('ftp://files.example.com') // Returns undefined
37
- * ```
38
- */
39
- export declare function validateUrl(url: string | undefined): string | undefined;
40
- /**
41
- * Validate that a string is a valid email address
42
- *
43
- * Uses a simple but effective email pattern.
44
- *
45
- * @param email - Email string to validate
46
- * @returns The email if valid, undefined otherwise
47
- */
48
- export declare function validateEmail(email: string | undefined): string | undefined;
49
- /**
50
- * Validate that a string is a valid DID
51
- *
52
- * @param did - DID string to validate
53
- * @returns The DID if valid, undefined otherwise
54
- */
55
- export declare function validateDid(did: string | undefined): string | undefined;
56
- /**
57
- * Validate that a string contains no control characters
58
- *
59
- * @param text - Text to validate
60
- * @returns The text if valid, undefined otherwise
61
- */
62
- export declare function validateNoControlChars(text: string | undefined): string | undefined;
63
- /**
64
- * Validate and sanitize a string for display
65
- *
66
- * Removes control characters and trims whitespace.
67
- *
68
- * @param text - Text to sanitize
69
- * @param maxLength - Maximum allowed length
70
- * @returns Sanitized text or undefined if invalid
71
- */
72
- export declare function sanitizeDisplayText(text: string | undefined, maxLength?: number): string | undefined;
73
- /**
74
- * Validate that a string is alphanumeric with underscores only
75
- *
76
- * Useful for field names and identifiers.
77
- *
78
- * @param text - Text to validate
79
- * @returns The text if valid, undefined otherwise
80
- */
81
- export declare function validateIdentifier(text: string | undefined): string | undefined;
82
- /**
83
- * Check if a value is a safe integer within range
84
- *
85
- * @param value - Value to check
86
- * @param min - Minimum value (inclusive)
87
- * @param max - Maximum value (inclusive)
88
- * @returns True if valid
89
- */
90
- export declare function isValidInteger(value: unknown, min?: number, max?: number): value is number;
91
- /**
92
- * Validate a CSRF token format
93
- *
94
- * @param token - Token to validate
95
- * @returns The token if valid, undefined otherwise
96
- */
97
- export declare function validateCSRFToken(token: string | undefined): string | undefined;
98
- //# sourceMappingURL=validators.d.ts.map