@careflair/common 1.0.18 → 1.0.20
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/index.d.ts +1 -0
- package/dist/index.js +4 -1
- package/dist/schemas/applicationSchema.d.ts +16 -0
- package/dist/schemas/applicationSchema.js +31 -0
- package/dist/schemas/forms.d.ts +1 -1
- package/dist/schemas/forms.js +2 -12
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/index.js +4 -1
- package/dist/utils/html.d.ts +11 -0
- package/dist/utils/html.js +97 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +2 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export { AvailabilitiesSchemaZod, AvailabilityZodInput, } from "./schemas/availa
|
|
|
5
5
|
export { HourlyRateInputZod, HourlyRateInputZodType, } from "./schemas/hourlyRateSchemaValidation";
|
|
6
6
|
export { ServicesSchema, validateServices, } from "./schemas/businessServicesValidation";
|
|
7
7
|
export { VideoProvider, VideoValidationResult, detectVideoProvider, isValidCommunityVideoUrl, isValidYouTubeOrVimeoUrl, validateVideoLink, } from "./utils/videoValidation";
|
|
8
|
+
export { applicationSchema, ApplicationFormValues, isValidVideoUrl, } from "./schemas/applicationSchema";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateVideoLink = exports.isValidYouTubeOrVimeoUrl = exports.isValidCommunityVideoUrl = exports.detectVideoProvider = exports.validateServices = exports.ServicesSchema = exports.HourlyRateInputZod = exports.AvailabilitiesSchemaZod = exports.WorkHistorySchema = exports.EducationAndTrainingSchema = exports.UserRegistrationSchema = void 0;
|
|
3
|
+
exports.isValidVideoUrl = exports.applicationSchema = exports.validateVideoLink = exports.isValidYouTubeOrVimeoUrl = exports.isValidCommunityVideoUrl = exports.detectVideoProvider = exports.validateServices = exports.ServicesSchema = exports.HourlyRateInputZod = exports.AvailabilitiesSchemaZod = exports.WorkHistorySchema = exports.EducationAndTrainingSchema = exports.UserRegistrationSchema = void 0;
|
|
4
4
|
var userValiationSchema_1 = require("./schemas/userValiationSchema");
|
|
5
5
|
Object.defineProperty(exports, "UserRegistrationSchema", { enumerable: true, get: function () { return userValiationSchema_1.UserRegistrationSchema; } });
|
|
6
6
|
var educationSchemas_1 = require("./schemas/educationSchemas");
|
|
@@ -19,3 +19,6 @@ Object.defineProperty(exports, "detectVideoProvider", { enumerable: true, get: f
|
|
|
19
19
|
Object.defineProperty(exports, "isValidCommunityVideoUrl", { enumerable: true, get: function () { return videoValidation_1.isValidCommunityVideoUrl; } });
|
|
20
20
|
Object.defineProperty(exports, "isValidYouTubeOrVimeoUrl", { enumerable: true, get: function () { return videoValidation_1.isValidYouTubeOrVimeoUrl; } });
|
|
21
21
|
Object.defineProperty(exports, "validateVideoLink", { enumerable: true, get: function () { return videoValidation_1.validateVideoLink; } });
|
|
22
|
+
var applicationSchema_1 = require("./schemas/applicationSchema");
|
|
23
|
+
Object.defineProperty(exports, "applicationSchema", { enumerable: true, get: function () { return applicationSchema_1.applicationSchema; } });
|
|
24
|
+
Object.defineProperty(exports, "isValidVideoUrl", { enumerable: true, get: function () { return applicationSchema_1.isValidVideoUrl; } });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const isValidVideoUrl: (url: string) => boolean;
|
|
3
|
+
export declare const applicationSchema: z.ZodObject<{
|
|
4
|
+
proposal: z.ZodString;
|
|
5
|
+
videoLink: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
|
6
|
+
amount: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
proposal: string;
|
|
9
|
+
videoLink?: string | undefined;
|
|
10
|
+
amount?: string | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
proposal: string;
|
|
13
|
+
videoLink?: string | undefined;
|
|
14
|
+
amount?: string | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
export type ApplicationFormValues = z.infer<typeof applicationSchema>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applicationSchema = exports.isValidVideoUrl = void 0;
|
|
4
|
+
const videoValidation_1 = require("../utils/videoValidation");
|
|
5
|
+
const limits_1 = require("../constants/limits");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
// Helper function to validate YouTube or Vimeo URLs (using unified validation)
|
|
8
|
+
const isValidVideoUrl = (url) => {
|
|
9
|
+
return (0, videoValidation_1.isValidYouTubeOrVimeoUrl)(url);
|
|
10
|
+
};
|
|
11
|
+
exports.isValidVideoUrl = isValidVideoUrl;
|
|
12
|
+
exports.applicationSchema = zod_1.z.object({
|
|
13
|
+
proposal: zod_1.z
|
|
14
|
+
.string()
|
|
15
|
+
.min(100, "Cover letter must be at least 100 characters long")
|
|
16
|
+
.max(5000, "Cover letter cannot exceed 5000 characters"),
|
|
17
|
+
videoLink: zod_1.z
|
|
18
|
+
.string()
|
|
19
|
+
.optional()
|
|
20
|
+
.refine((val) => !val || (0, exports.isValidVideoUrl)(val), {
|
|
21
|
+
message: "Please provide a valid YouTube or Vimeo URL",
|
|
22
|
+
}),
|
|
23
|
+
amount: zod_1.z
|
|
24
|
+
.string()
|
|
25
|
+
.optional()
|
|
26
|
+
.refine((val) => !val ||
|
|
27
|
+
(parseFloat(val) >= limits_1.MIN_HOURLY_RATE &&
|
|
28
|
+
parseFloat(val) <= limits_1.MAX_HOURLY_RATE), {
|
|
29
|
+
message: `Hourly rate must be between $${limits_1.MIN_HOURLY_RATE} and $${limits_1.MAX_HOURLY_RATE}`,
|
|
30
|
+
}),
|
|
31
|
+
});
|
package/dist/schemas/forms.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const registrationFormSchema: z.ZodEffects<z.ZodObject<{
|
|
|
7
7
|
lastName: z.ZodString;
|
|
8
8
|
email: z.ZodString;
|
|
9
9
|
username: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
10
|
-
role: z.
|
|
10
|
+
role: z.ZodString;
|
|
11
11
|
password: z.ZodString;
|
|
12
12
|
confirmPassword: z.ZodString;
|
|
13
13
|
fingerPrint: z.ZodOptional<z.ZodString>;
|
package/dist/schemas/forms.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.WorkHistoryFormSchema = exports.EducationAndTrainingFormSchema = exports
|
|
|
4
4
|
const libphonenumber_js_1 = require("libphonenumber-js");
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
const limits_1 = require("../constants/limits");
|
|
7
|
-
const enums_1 = require("../enums");
|
|
8
7
|
const validation_1 = require("./validation");
|
|
9
8
|
/**
|
|
10
9
|
* Registration form schema
|
|
@@ -31,12 +30,7 @@ exports.registrationFormSchema = zod_1.z
|
|
|
31
30
|
.refine((value) => !value.startsWith("_"), "Username cannot start with an underscore")
|
|
32
31
|
.refine((value) => !value.endsWith("_"), "Username cannot end with an underscore")
|
|
33
32
|
.refine((value) => !value.includes("__"), "Username cannot contain consecutive underscores"),
|
|
34
|
-
role: zod_1.z
|
|
35
|
-
.string()
|
|
36
|
-
.min(1, "Please select your role")
|
|
37
|
-
.refine((val) => Object.values(enums_1.UserRole).includes(val), {
|
|
38
|
-
message: "Please select a valid role",
|
|
39
|
-
}),
|
|
33
|
+
role: zod_1.z.string().min(1, "Please select your role"),
|
|
40
34
|
password: validation_1.passwordSchema,
|
|
41
35
|
confirmPassword: zod_1.z.string().min(1, "Confirm password is required"),
|
|
42
36
|
fingerPrint: zod_1.z.string().optional(),
|
|
@@ -91,11 +85,7 @@ exports.ContactDetailsFormSchema = zod_1.z.object({
|
|
|
91
85
|
})
|
|
92
86
|
.optional()
|
|
93
87
|
.or(zod_1.z.literal("")),
|
|
94
|
-
email: zod_1.z
|
|
95
|
-
.string()
|
|
96
|
-
.email("Invalid email address")
|
|
97
|
-
.optional()
|
|
98
|
-
.or(zod_1.z.literal("")),
|
|
88
|
+
email: zod_1.z.string().email("Invalid email address").optional().or(zod_1.z.literal("")),
|
|
99
89
|
website: zod_1.z
|
|
100
90
|
.string()
|
|
101
91
|
.regex(/^(?:https?:\/\/)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?$/, "Invalid URL")
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export { AvailabilitiesSchemaZod, AvailabilityZodInput, } from "./availabilitySc
|
|
|
5
5
|
export { HourlyRateInputZod, HourlyRateInputZodType, } from "./hourlyRateSchemaValidation";
|
|
6
6
|
export { ServicesSchema, SupportWorkerServicesSchema, validateServices, validateSupportWorkerServices, } from "./businessServicesValidation";
|
|
7
7
|
export { generalOTPSchema, pinSchema, ResetPasswordSchema } from "./otp";
|
|
8
|
+
export { applicationSchema, ApplicationFormValues, isValidVideoUrl, } from "./applicationSchema";
|
package/dist/schemas/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResetPasswordSchema = exports.pinSchema = exports.generalOTPSchema = exports.validateSupportWorkerServices = exports.validateServices = exports.SupportWorkerServicesSchema = exports.ServicesSchema = exports.HourlyRateInputZod = exports.AvailabilitiesSchemaZod = exports.WorkHistorySchema = exports.EducationAndTrainingSchema = exports.UserRegistrationSchema = void 0;
|
|
3
|
+
exports.isValidVideoUrl = exports.applicationSchema = exports.ResetPasswordSchema = exports.pinSchema = exports.generalOTPSchema = exports.validateSupportWorkerServices = exports.validateServices = exports.SupportWorkerServicesSchema = exports.ServicesSchema = exports.HourlyRateInputZod = exports.AvailabilitiesSchemaZod = exports.WorkHistorySchema = exports.EducationAndTrainingSchema = exports.UserRegistrationSchema = void 0;
|
|
4
4
|
var userValiationSchema_1 = require("./userValiationSchema");
|
|
5
5
|
Object.defineProperty(exports, "UserRegistrationSchema", { enumerable: true, get: function () { return userValiationSchema_1.UserRegistrationSchema; } });
|
|
6
6
|
var educationSchemas_1 = require("./educationSchemas");
|
|
@@ -20,3 +20,6 @@ var otp_1 = require("./otp");
|
|
|
20
20
|
Object.defineProperty(exports, "generalOTPSchema", { enumerable: true, get: function () { return otp_1.generalOTPSchema; } });
|
|
21
21
|
Object.defineProperty(exports, "pinSchema", { enumerable: true, get: function () { return otp_1.pinSchema; } });
|
|
22
22
|
Object.defineProperty(exports, "ResetPasswordSchema", { enumerable: true, get: function () { return otp_1.ResetPasswordSchema; } });
|
|
23
|
+
var applicationSchema_1 = require("./applicationSchema");
|
|
24
|
+
Object.defineProperty(exports, "applicationSchema", { enumerable: true, get: function () { return applicationSchema_1.applicationSchema; } });
|
|
25
|
+
Object.defineProperty(exports, "isValidVideoUrl", { enumerable: true, get: function () { return applicationSchema_1.isValidVideoUrl; } });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type SanitizeHtmlOptions = {
|
|
2
|
+
allowedTags?: string[];
|
|
3
|
+
allowedAttr?: string[];
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Cross-platform HTML sanitizer
|
|
7
|
+
* On web: Uses DOMPurify if available (more robust)
|
|
8
|
+
* On React Native: Uses regex-based sanitizer (simpler but effective)
|
|
9
|
+
*/
|
|
10
|
+
export declare const sanitizeHtml: (content: string, options?: SanitizeHtmlOptions) => string;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sanitizeHtml = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Cross-platform HTML sanitizer
|
|
6
|
+
* On web: Uses DOMPurify if available (more robust)
|
|
7
|
+
* On React Native: Uses regex-based sanitizer (simpler but effective)
|
|
8
|
+
*/
|
|
9
|
+
const sanitizeHtml = (content, options = {}) => {
|
|
10
|
+
if (!content)
|
|
11
|
+
return '';
|
|
12
|
+
const { allowedTags = ['p', 'strong', 'em', 'ul', 'ol', 'li', 'br', 'a'], allowedAttr = ['href', 'target', 'rel', 'class'], } = options;
|
|
13
|
+
// Check if we're in a browser environment with DOMPurify available
|
|
14
|
+
if (typeof window !== 'undefined' && typeof window.DOMPurify !== 'undefined') {
|
|
15
|
+
const DOMPurify = window.DOMPurify;
|
|
16
|
+
const purifyConfig = {
|
|
17
|
+
ALLOWED_TAGS: allowedTags,
|
|
18
|
+
ALLOWED_ATTR: allowedAttr,
|
|
19
|
+
};
|
|
20
|
+
return DOMPurify.sanitize(content, purifyConfig);
|
|
21
|
+
}
|
|
22
|
+
// Fallback: Regex-based sanitizer for React Native
|
|
23
|
+
return sanitizeHtmlRegex(content, { allowedTags, allowedAttr });
|
|
24
|
+
};
|
|
25
|
+
exports.sanitizeHtml = sanitizeHtml;
|
|
26
|
+
/**
|
|
27
|
+
* Regex-based HTML sanitizer for React Native
|
|
28
|
+
* Removes dangerous tags and attributes while preserving allowed tags
|
|
29
|
+
*/
|
|
30
|
+
const sanitizeHtmlRegex = (html, options) => {
|
|
31
|
+
let cleaned = html;
|
|
32
|
+
const { allowedTags = [], allowedAttr = [] } = options;
|
|
33
|
+
// Remove script and style tags completely
|
|
34
|
+
cleaned = cleaned
|
|
35
|
+
.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, '')
|
|
36
|
+
.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, '')
|
|
37
|
+
.replace(/<!--[\s\S]*?-->/g, '');
|
|
38
|
+
// Remove dangerous attributes (javascript:, onclick, etc.)
|
|
39
|
+
cleaned = cleaned.replace(/\s*on\w+\s*=\s*["'][^"']*["']/gi, '');
|
|
40
|
+
cleaned = cleaned.replace(/\s*on\w+\s*=\s*[^\s>]*/gi, '');
|
|
41
|
+
cleaned = cleaned.replace(/javascript:/gi, '');
|
|
42
|
+
// Build regex for allowed tags
|
|
43
|
+
const allowedTagsRegex = allowedTags.join('|');
|
|
44
|
+
// Remove all tags except allowed ones
|
|
45
|
+
if (allowedTags.length > 0) {
|
|
46
|
+
// First, protect allowed tags
|
|
47
|
+
const tagPlaceholders = {};
|
|
48
|
+
let placeholderIndex = 0;
|
|
49
|
+
// Replace allowed tags with placeholders temporarily
|
|
50
|
+
cleaned = cleaned.replace(new RegExp(`<(${allowedTagsRegex})([^>]*)>`, 'gi'), (match, tag, attrs) => {
|
|
51
|
+
// Clean attributes - only keep allowed ones
|
|
52
|
+
let cleanAttrs = '';
|
|
53
|
+
if (attrs) {
|
|
54
|
+
const attrRegex = new RegExp(`\\s*(${allowedAttr.join('|')})\\s*=\\s*["']([^"']*)["']`, 'gi');
|
|
55
|
+
const matches = attrs.match(attrRegex);
|
|
56
|
+
if (matches) {
|
|
57
|
+
cleanAttrs = ' ' + matches.join(' ');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const placeholder = `__TAG_${placeholderIndex}__`;
|
|
61
|
+
tagPlaceholders[placeholder] = `<${tag}${cleanAttrs}>`;
|
|
62
|
+
placeholderIndex++;
|
|
63
|
+
return placeholder;
|
|
64
|
+
});
|
|
65
|
+
// Replace closing tags
|
|
66
|
+
cleaned = cleaned.replace(new RegExp(`</(${allowedTagsRegex})>`, 'gi'), (match, tag) => {
|
|
67
|
+
const placeholder = `__TAG_${placeholderIndex}__`;
|
|
68
|
+
tagPlaceholders[placeholder] = `</${tag}>`;
|
|
69
|
+
placeholderIndex++;
|
|
70
|
+
return placeholder;
|
|
71
|
+
});
|
|
72
|
+
// Remove all remaining tags
|
|
73
|
+
cleaned = cleaned.replace(/<[^>]*>/g, '');
|
|
74
|
+
// Restore allowed tags
|
|
75
|
+
Object.keys(tagPlaceholders).forEach((placeholder) => {
|
|
76
|
+
cleaned = cleaned.replace(placeholder, tagPlaceholders[placeholder]);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
// No allowed tags, strip all HTML
|
|
81
|
+
cleaned = cleaned.replace(/<[^>]*>/g, '');
|
|
82
|
+
}
|
|
83
|
+
// Decode common HTML entities
|
|
84
|
+
cleaned = cleaned
|
|
85
|
+
.replace(/ /g, ' ')
|
|
86
|
+
.replace(/&/g, '&')
|
|
87
|
+
.replace(/</g, '<')
|
|
88
|
+
.replace(/>/g, '>')
|
|
89
|
+
.replace(/"/g, '"')
|
|
90
|
+
.replace(/'/g, "'")
|
|
91
|
+
.replace(/'/g, "'")
|
|
92
|
+
.replace(/'/g, "'")
|
|
93
|
+
.replace(///g, '/');
|
|
94
|
+
// Normalize whitespace
|
|
95
|
+
cleaned = cleaned.replace(/\s+/g, ' ').trim();
|
|
96
|
+
return cleaned;
|
|
97
|
+
};
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED