@lucaapp/service-utils 5.24.4 → 5.25.0
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.
|
@@ -213,9 +213,14 @@ class ServiceIdentity {
|
|
|
213
213
|
});
|
|
214
214
|
if (!debug) {
|
|
215
215
|
this.axiosClient.interceptors.response.use(response => response, error => {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
delete
|
|
216
|
+
const headers = error?.config?.headers;
|
|
217
|
+
if (headers) {
|
|
218
|
+
if (typeof headers.delete === 'function') {
|
|
219
|
+
headers.delete(JWT_HEADER_NAME);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
delete headers[JWT_HEADER_NAME];
|
|
223
|
+
}
|
|
219
224
|
}
|
|
220
225
|
return Promise.reject(error);
|
|
221
226
|
});
|
package/dist/lib/validation.d.ts
CHANGED
|
@@ -209,7 +209,7 @@ declare const z: {
|
|
|
209
209
|
nullablePhoneNumber: () => ZodEffects<ZodEffects<ZodString, string, string>, string | null, string>;
|
|
210
210
|
strongPassword: () => ZodEffects<ZodString, string, string>;
|
|
211
211
|
zipCode: (locale?: validator.PostalCodeLocale) => ZodEffects<ZodString, string>;
|
|
212
|
-
countryCode: () => ZodString
|
|
212
|
+
countryCode: () => ZodEffects<ZodString, string, string>;
|
|
213
213
|
moneyDecimalString: (locale?: string) => ZodEffects<ZodString, string, string>;
|
|
214
214
|
moneyFromFloat: () => ZodEffects<ZodEffects<ZodNumber>, Money>;
|
|
215
215
|
moneyFromInt: () => ZodEffects<ZodNumber, Money>;
|
|
@@ -386,5 +386,6 @@ declare const z: {
|
|
|
386
386
|
Logic?: any;
|
|
387
387
|
}>;
|
|
388
388
|
};
|
|
389
|
+
export declare const isPostalCodeForCountry: (postalCode: string, countryCode: string) => boolean;
|
|
389
390
|
export * from 'zod';
|
|
390
391
|
export { z };
|
package/dist/lib/validation.js
CHANGED
|
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.z = exports.preprocessBooleanFromString = exports.preprocessBooleanFromQueryString = exports.preprocessNumberFromQueryString = exports.preprocessArrayFromQueryString = void 0;
|
|
21
|
+
exports.z = exports.isPostalCodeForCountry = exports.preprocessBooleanFromString = exports.preprocessBooleanFromQueryString = exports.preprocessNumberFromQueryString = exports.preprocessArrayFromQueryString = void 0;
|
|
22
22
|
const url_1 = require("url");
|
|
23
23
|
const zod_1 = require("zod");
|
|
24
24
|
const validator_1 = __importDefault(require("validator"));
|
|
@@ -36,6 +36,7 @@ const ALPHANUMERIC_REGEX = /^[\da-z]+$/i;
|
|
|
36
36
|
const ONBOARDING_BUSINESS_ENTITY_REGEX = /^[\w !&'()*+,./£À-ÿāăąćĉċčđēėęěĝğģĥħĩīįİıĵķĸĺļłńņōőœŗřśŝşšţŦũūŭůűųŵŷźżžơưếệ''-]+$/i;
|
|
37
37
|
const ONBOARDING_NAME_REGEX = /^[\s'.A-Za-z£À-žơưếệ''-]+$/;
|
|
38
38
|
const COUNTRY_CODE_REGEX = /^[A-Z]{2}$/;
|
|
39
|
+
const HAS_LETTER_REGEX = /\p{L}/u;
|
|
39
40
|
const PASSWORD_REQUIREMENTS = {
|
|
40
41
|
minLength: 9,
|
|
41
42
|
minNumbers: 1,
|
|
@@ -108,6 +109,7 @@ const z = {
|
|
|
108
109
|
safeBusinessStringForOnboarding: () => zod_1.z
|
|
109
110
|
.string()
|
|
110
111
|
.regex(ONBOARDING_BUSINESS_ENTITY_REGEX)
|
|
112
|
+
.regex(HAS_LETTER_REGEX)
|
|
111
113
|
.max(255)
|
|
112
114
|
.trim()
|
|
113
115
|
.min(1)
|
|
@@ -119,6 +121,7 @@ const z = {
|
|
|
119
121
|
safeNameForOnboarding: () => zod_1.z
|
|
120
122
|
.string()
|
|
121
123
|
.regex(ONBOARDING_NAME_REGEX)
|
|
124
|
+
.regex(HAS_LETTER_REGEX)
|
|
122
125
|
.max(255)
|
|
123
126
|
.trim()
|
|
124
127
|
.min(1)
|
|
@@ -202,7 +205,10 @@ const z = {
|
|
|
202
205
|
.trim()
|
|
203
206
|
.max(255)
|
|
204
207
|
.refine(value => validator_1.default.isPostalCode(value, locale || 'any')),
|
|
205
|
-
countryCode: () => zod_1.z
|
|
208
|
+
countryCode: () => zod_1.z
|
|
209
|
+
.string()
|
|
210
|
+
.regex(COUNTRY_CODE_REGEX)
|
|
211
|
+
.refine(value => validator_1.default.isISO31661Alpha2(value)),
|
|
206
212
|
// Money validators
|
|
207
213
|
moneyDecimalString: (locale) => zod_1.z
|
|
208
214
|
.string()
|
|
@@ -432,4 +438,12 @@ const z = {
|
|
|
432
438
|
}),
|
|
433
439
|
};
|
|
434
440
|
exports.z = z;
|
|
441
|
+
const isPostalCodeForCountry = (postalCode, countryCode) => {
|
|
442
|
+
const locale = countryCode;
|
|
443
|
+
if (!validator_1.default.isPostalCodeLocales.includes(locale)) {
|
|
444
|
+
return true;
|
|
445
|
+
}
|
|
446
|
+
return validator_1.default.isPostalCode(postalCode, locale);
|
|
447
|
+
};
|
|
448
|
+
exports.isPostalCodeForCountry = isPostalCodeForCountry;
|
|
435
449
|
__exportStar(require("zod"), exports);
|