@kya-os/consent 0.1.7 → 0.1.9
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/bundle/inline.d.ts.map +1 -1
- package/dist/bundle/inline.js +2 -2
- package/dist/bundle/inline.js.map +1 -1
- package/dist/components/mcp-consent.d.ts +5 -0
- package/dist/components/mcp-consent.d.ts.map +1 -1
- package/dist/components/mcp-consent.js +12 -0
- package/dist/components/mcp-consent.js.map +1 -1
- package/dist/consent.js +7 -0
- package/dist/consent.min.js +2 -2
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +2 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/schemas/api.schemas.d.ts +153 -153
- package/dist/schemas/config.schemas.d.ts +160 -160
- package/dist/schemas/modes.schemas.d.ts +28 -28
- package/package.json +1 -1
- package/dist/utils/credential-fields.d.ts +0 -63
- package/dist/utils/credential-fields.d.ts.map +0 -1
- package/dist/utils/credential-fields.js +0 -166
- package/dist/utils/credential-fields.js.map +0 -1
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -5
- package/dist/utils/index.js.map +0 -1
|
@@ -23,21 +23,21 @@ export declare const CredentialsConfigSchema: z.ZodObject<{
|
|
|
23
23
|
showForgotPassword: z.ZodOptional<z.ZodBoolean>;
|
|
24
24
|
forgotPasswordUrl: z.ZodOptional<z.ZodString>;
|
|
25
25
|
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
showForgotPassword?: boolean | undefined;
|
|
27
|
+
forgotPasswordUrl?: string | undefined;
|
|
26
28
|
usernameLabel?: string | undefined;
|
|
27
29
|
usernamePlaceholder?: string | undefined;
|
|
28
30
|
passwordLabel?: string | undefined;
|
|
29
31
|
passwordPlaceholder?: string | undefined;
|
|
30
32
|
showRememberMe?: boolean | undefined;
|
|
33
|
+
}, {
|
|
31
34
|
showForgotPassword?: boolean | undefined;
|
|
32
35
|
forgotPasswordUrl?: string | undefined;
|
|
33
|
-
}, {
|
|
34
36
|
usernameLabel?: string | undefined;
|
|
35
37
|
usernamePlaceholder?: string | undefined;
|
|
36
38
|
passwordLabel?: string | undefined;
|
|
37
39
|
passwordPlaceholder?: string | undefined;
|
|
38
40
|
showRememberMe?: boolean | undefined;
|
|
39
|
-
showForgotPassword?: boolean | undefined;
|
|
40
|
-
forgotPasswordUrl?: string | undefined;
|
|
41
41
|
}>;
|
|
42
42
|
export type CredentialsConfigSchemaType = z.infer<typeof CredentialsConfigSchema>;
|
|
43
43
|
/**
|
|
@@ -67,17 +67,17 @@ export declare const MagicLinkConfigSchema: z.ZodObject<{
|
|
|
67
67
|
buttonText: z.ZodOptional<z.ZodString>;
|
|
68
68
|
resendCooldown: z.ZodOptional<z.ZodNumber>;
|
|
69
69
|
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
resendCooldown?: number | undefined;
|
|
70
71
|
buttonText?: string | undefined;
|
|
71
72
|
enabled?: boolean | undefined;
|
|
72
73
|
emailLabel?: string | undefined;
|
|
73
74
|
emailPlaceholder?: string | undefined;
|
|
74
|
-
resendCooldown?: number | undefined;
|
|
75
75
|
}, {
|
|
76
|
+
resendCooldown?: number | undefined;
|
|
76
77
|
buttonText?: string | undefined;
|
|
77
78
|
enabled?: boolean | undefined;
|
|
78
79
|
emailLabel?: string | undefined;
|
|
79
80
|
emailPlaceholder?: string | undefined;
|
|
80
|
-
resendCooldown?: number | undefined;
|
|
81
81
|
}>;
|
|
82
82
|
export type MagicLinkConfigSchemaType = z.infer<typeof MagicLinkConfigSchema>;
|
|
83
83
|
/**
|
|
@@ -91,19 +91,19 @@ export declare const OTPConfigSchema: z.ZodObject<{
|
|
|
91
91
|
digits: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<4>, z.ZodLiteral<6>, z.ZodLiteral<8>]>>;
|
|
92
92
|
resendCooldown: z.ZodOptional<z.ZodNumber>;
|
|
93
93
|
}, "strip", z.ZodTypeAny, {
|
|
94
|
-
enabled?: boolean | undefined;
|
|
95
94
|
resendCooldown?: number | undefined;
|
|
95
|
+
enabled?: boolean | undefined;
|
|
96
96
|
phoneLabel?: string | undefined;
|
|
97
97
|
phonePlaceholder?: string | undefined;
|
|
98
98
|
instructions?: string | undefined;
|
|
99
|
-
digits?:
|
|
99
|
+
digits?: 4 | 6 | 8 | undefined;
|
|
100
100
|
}, {
|
|
101
|
-
enabled?: boolean | undefined;
|
|
102
101
|
resendCooldown?: number | undefined;
|
|
102
|
+
enabled?: boolean | undefined;
|
|
103
103
|
phoneLabel?: string | undefined;
|
|
104
104
|
phonePlaceholder?: string | undefined;
|
|
105
105
|
instructions?: string | undefined;
|
|
106
|
-
digits?:
|
|
106
|
+
digits?: 4 | 6 | 8 | undefined;
|
|
107
107
|
}>;
|
|
108
108
|
export type OTPConfigSchemaType = z.infer<typeof OTPConfigSchema>;
|
|
109
109
|
/**
|
|
@@ -182,21 +182,21 @@ export declare const ModeConfigsSchema: z.ZodObject<{
|
|
|
182
182
|
showForgotPassword: z.ZodOptional<z.ZodBoolean>;
|
|
183
183
|
forgotPasswordUrl: z.ZodOptional<z.ZodString>;
|
|
184
184
|
}, "strip", z.ZodTypeAny, {
|
|
185
|
+
showForgotPassword?: boolean | undefined;
|
|
186
|
+
forgotPasswordUrl?: string | undefined;
|
|
185
187
|
usernameLabel?: string | undefined;
|
|
186
188
|
usernamePlaceholder?: string | undefined;
|
|
187
189
|
passwordLabel?: string | undefined;
|
|
188
190
|
passwordPlaceholder?: string | undefined;
|
|
189
191
|
showRememberMe?: boolean | undefined;
|
|
192
|
+
}, {
|
|
190
193
|
showForgotPassword?: boolean | undefined;
|
|
191
194
|
forgotPasswordUrl?: string | undefined;
|
|
192
|
-
}, {
|
|
193
195
|
usernameLabel?: string | undefined;
|
|
194
196
|
usernamePlaceholder?: string | undefined;
|
|
195
197
|
passwordLabel?: string | undefined;
|
|
196
198
|
passwordPlaceholder?: string | undefined;
|
|
197
199
|
showRememberMe?: boolean | undefined;
|
|
198
|
-
showForgotPassword?: boolean | undefined;
|
|
199
|
-
forgotPasswordUrl?: string | undefined;
|
|
200
200
|
}>>;
|
|
201
201
|
oauth: z.ZodOptional<z.ZodObject<{
|
|
202
202
|
providerId: z.ZodOptional<z.ZodString>;
|
|
@@ -218,17 +218,17 @@ export declare const ModeConfigsSchema: z.ZodObject<{
|
|
|
218
218
|
buttonText: z.ZodOptional<z.ZodString>;
|
|
219
219
|
resendCooldown: z.ZodOptional<z.ZodNumber>;
|
|
220
220
|
}, "strip", z.ZodTypeAny, {
|
|
221
|
+
resendCooldown?: number | undefined;
|
|
221
222
|
buttonText?: string | undefined;
|
|
222
223
|
enabled?: boolean | undefined;
|
|
223
224
|
emailLabel?: string | undefined;
|
|
224
225
|
emailPlaceholder?: string | undefined;
|
|
225
|
-
resendCooldown?: number | undefined;
|
|
226
226
|
}, {
|
|
227
|
+
resendCooldown?: number | undefined;
|
|
227
228
|
buttonText?: string | undefined;
|
|
228
229
|
enabled?: boolean | undefined;
|
|
229
230
|
emailLabel?: string | undefined;
|
|
230
231
|
emailPlaceholder?: string | undefined;
|
|
231
|
-
resendCooldown?: number | undefined;
|
|
232
232
|
}>>;
|
|
233
233
|
otp: z.ZodOptional<z.ZodObject<{
|
|
234
234
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -238,19 +238,19 @@ export declare const ModeConfigsSchema: z.ZodObject<{
|
|
|
238
238
|
digits: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<4>, z.ZodLiteral<6>, z.ZodLiteral<8>]>>;
|
|
239
239
|
resendCooldown: z.ZodOptional<z.ZodNumber>;
|
|
240
240
|
}, "strip", z.ZodTypeAny, {
|
|
241
|
-
enabled?: boolean | undefined;
|
|
242
241
|
resendCooldown?: number | undefined;
|
|
242
|
+
enabled?: boolean | undefined;
|
|
243
243
|
phoneLabel?: string | undefined;
|
|
244
244
|
phonePlaceholder?: string | undefined;
|
|
245
245
|
instructions?: string | undefined;
|
|
246
|
-
digits?:
|
|
246
|
+
digits?: 4 | 6 | 8 | undefined;
|
|
247
247
|
}, {
|
|
248
|
-
enabled?: boolean | undefined;
|
|
249
248
|
resendCooldown?: number | undefined;
|
|
249
|
+
enabled?: boolean | undefined;
|
|
250
250
|
phoneLabel?: string | undefined;
|
|
251
251
|
phonePlaceholder?: string | undefined;
|
|
252
252
|
instructions?: string | undefined;
|
|
253
|
-
digits?:
|
|
253
|
+
digits?: 4 | 6 | 8 | undefined;
|
|
254
254
|
}>>;
|
|
255
255
|
qrCode: z.ZodOptional<z.ZodObject<{
|
|
256
256
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -305,13 +305,13 @@ export declare const ModeConfigsSchema: z.ZodObject<{
|
|
|
305
305
|
}>>;
|
|
306
306
|
}, "strip", z.ZodTypeAny, {
|
|
307
307
|
credentials?: {
|
|
308
|
+
showForgotPassword?: boolean | undefined;
|
|
309
|
+
forgotPasswordUrl?: string | undefined;
|
|
308
310
|
usernameLabel?: string | undefined;
|
|
309
311
|
usernamePlaceholder?: string | undefined;
|
|
310
312
|
passwordLabel?: string | undefined;
|
|
311
313
|
passwordPlaceholder?: string | undefined;
|
|
312
314
|
showRememberMe?: boolean | undefined;
|
|
313
|
-
showForgotPassword?: boolean | undefined;
|
|
314
|
-
forgotPasswordUrl?: string | undefined;
|
|
315
315
|
} | undefined;
|
|
316
316
|
oauth?: {
|
|
317
317
|
providerId?: string | undefined;
|
|
@@ -319,12 +319,12 @@ export declare const ModeConfigsSchema: z.ZodObject<{
|
|
|
319
319
|
buttonText?: string | undefined;
|
|
320
320
|
} | undefined;
|
|
321
321
|
otp?: {
|
|
322
|
-
enabled?: boolean | undefined;
|
|
323
322
|
resendCooldown?: number | undefined;
|
|
323
|
+
enabled?: boolean | undefined;
|
|
324
324
|
phoneLabel?: string | undefined;
|
|
325
325
|
phonePlaceholder?: string | undefined;
|
|
326
326
|
instructions?: string | undefined;
|
|
327
|
-
digits?:
|
|
327
|
+
digits?: 4 | 6 | 8 | undefined;
|
|
328
328
|
} | undefined;
|
|
329
329
|
passkey?: {
|
|
330
330
|
buttonText?: string | undefined;
|
|
@@ -340,11 +340,11 @@ export declare const ModeConfigsSchema: z.ZodObject<{
|
|
|
340
340
|
estimatedTime?: string | undefined;
|
|
341
341
|
} | undefined;
|
|
342
342
|
magicLink?: {
|
|
343
|
+
resendCooldown?: number | undefined;
|
|
343
344
|
buttonText?: string | undefined;
|
|
344
345
|
enabled?: boolean | undefined;
|
|
345
346
|
emailLabel?: string | undefined;
|
|
346
347
|
emailPlaceholder?: string | undefined;
|
|
347
|
-
resendCooldown?: number | undefined;
|
|
348
348
|
} | undefined;
|
|
349
349
|
qrCode?: {
|
|
350
350
|
enabled?: boolean | undefined;
|
|
@@ -354,13 +354,13 @@ export declare const ModeConfigsSchema: z.ZodObject<{
|
|
|
354
354
|
} | undefined;
|
|
355
355
|
}, {
|
|
356
356
|
credentials?: {
|
|
357
|
+
showForgotPassword?: boolean | undefined;
|
|
358
|
+
forgotPasswordUrl?: string | undefined;
|
|
357
359
|
usernameLabel?: string | undefined;
|
|
358
360
|
usernamePlaceholder?: string | undefined;
|
|
359
361
|
passwordLabel?: string | undefined;
|
|
360
362
|
passwordPlaceholder?: string | undefined;
|
|
361
363
|
showRememberMe?: boolean | undefined;
|
|
362
|
-
showForgotPassword?: boolean | undefined;
|
|
363
|
-
forgotPasswordUrl?: string | undefined;
|
|
364
364
|
} | undefined;
|
|
365
365
|
oauth?: {
|
|
366
366
|
providerId?: string | undefined;
|
|
@@ -368,12 +368,12 @@ export declare const ModeConfigsSchema: z.ZodObject<{
|
|
|
368
368
|
buttonText?: string | undefined;
|
|
369
369
|
} | undefined;
|
|
370
370
|
otp?: {
|
|
371
|
-
enabled?: boolean | undefined;
|
|
372
371
|
resendCooldown?: number | undefined;
|
|
372
|
+
enabled?: boolean | undefined;
|
|
373
373
|
phoneLabel?: string | undefined;
|
|
374
374
|
phonePlaceholder?: string | undefined;
|
|
375
375
|
instructions?: string | undefined;
|
|
376
|
-
digits?:
|
|
376
|
+
digits?: 4 | 6 | 8 | undefined;
|
|
377
377
|
} | undefined;
|
|
378
378
|
passkey?: {
|
|
379
379
|
buttonText?: string | undefined;
|
|
@@ -389,11 +389,11 @@ export declare const ModeConfigsSchema: z.ZodObject<{
|
|
|
389
389
|
estimatedTime?: string | undefined;
|
|
390
390
|
} | undefined;
|
|
391
391
|
magicLink?: {
|
|
392
|
+
resendCooldown?: number | undefined;
|
|
392
393
|
buttonText?: string | undefined;
|
|
393
394
|
enabled?: boolean | undefined;
|
|
394
395
|
emailLabel?: string | undefined;
|
|
395
396
|
emailPlaceholder?: string | undefined;
|
|
396
|
-
resendCooldown?: number | undefined;
|
|
397
397
|
} | undefined;
|
|
398
398
|
qrCode?: {
|
|
399
399
|
enabled?: boolean | undefined;
|
package/package.json
CHANGED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Credential Form Field Utilities
|
|
3
|
-
*
|
|
4
|
-
* Utilities for parsing and rendering dynamic credential form fields
|
|
5
|
-
* based on the provider's requestBodyTemplate configuration.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* const template = { email: '{{email}}', password: '{{password}}' };
|
|
10
|
-
* const fields = parseCredentialFields(template);
|
|
11
|
-
* // Returns:
|
|
12
|
-
* // [
|
|
13
|
-
* // { name: 'email', apiName: 'email', type: 'email', label: 'Email', required: true },
|
|
14
|
-
* // { name: 'password', apiName: 'password', type: 'password', label: 'Password', required: true }
|
|
15
|
-
* // ]
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* Credential form field metadata for dynamic form rendering
|
|
20
|
-
*/
|
|
21
|
-
export interface CredentialField {
|
|
22
|
-
/** Form field name (used in FormData submission) */
|
|
23
|
-
name: string;
|
|
24
|
-
/** API field name in requestBodyTemplate (may differ from form name) */
|
|
25
|
-
apiName: string;
|
|
26
|
-
/** Human-readable label for the input */
|
|
27
|
-
label: string;
|
|
28
|
-
/** Placeholder text for the input */
|
|
29
|
-
placeholder: string;
|
|
30
|
-
/** HTML input type */
|
|
31
|
-
type: "text" | "password" | "email" | "tel" | "date" | "number";
|
|
32
|
-
/** HTML autocomplete attribute */
|
|
33
|
-
autocomplete: string;
|
|
34
|
-
/** Whether field is required */
|
|
35
|
-
required: boolean;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Parse credential fields from a requestBodyTemplate.
|
|
39
|
-
*
|
|
40
|
-
* Extracts field definitions from template placeholders like `{{fieldName}}`
|
|
41
|
-
* and infers appropriate input types, labels, and autocomplete attributes.
|
|
42
|
-
*
|
|
43
|
-
* @param requestBodyTemplate - Template object with API field names as keys and `{{fieldName}}` as values
|
|
44
|
-
* @returns Array of CredentialField objects for form rendering
|
|
45
|
-
*/
|
|
46
|
-
export declare function parseCredentialFields(requestBodyTemplate: Record<string, string>): CredentialField[];
|
|
47
|
-
/**
|
|
48
|
-
* Infer HTML input type from field name
|
|
49
|
-
*/
|
|
50
|
-
export declare function inferInputType(fieldName: string): "text" | "password" | "email" | "tel" | "date" | "number";
|
|
51
|
-
/**
|
|
52
|
-
* Convert field name to human-readable label
|
|
53
|
-
*/
|
|
54
|
-
export declare function humanizeFieldName(name: string): string;
|
|
55
|
-
/**
|
|
56
|
-
* Get appropriate placeholder text for a field
|
|
57
|
-
*/
|
|
58
|
-
export declare function getPlaceholder(fieldName: string, inputType: string): string;
|
|
59
|
-
/**
|
|
60
|
-
* Get appropriate autocomplete attribute for a field
|
|
61
|
-
*/
|
|
62
|
-
export declare function getAutocomplete(fieldName: string, inputType: string): string;
|
|
63
|
-
//# sourceMappingURL=credential-fields.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"credential-fields.d.ts","sourceRoot":"","sources":["../../src/utils/credential-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,sBAAsB;IACtB,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;IAChE,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,gCAAgC;IAChC,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1C,eAAe,EAAE,CA6BnB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAkD3D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,MAAM,CAeR;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,MAAM,CAwCR"}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Credential Form Field Utilities
|
|
3
|
-
*
|
|
4
|
-
* Utilities for parsing and rendering dynamic credential form fields
|
|
5
|
-
* based on the provider's requestBodyTemplate configuration.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* const template = { email: '{{email}}', password: '{{password}}' };
|
|
10
|
-
* const fields = parseCredentialFields(template);
|
|
11
|
-
* // Returns:
|
|
12
|
-
* // [
|
|
13
|
-
* // { name: 'email', apiName: 'email', type: 'email', label: 'Email', required: true },
|
|
14
|
-
* // { name: 'password', apiName: 'password', type: 'password', label: 'Password', required: true }
|
|
15
|
-
* // ]
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* Parse credential fields from a requestBodyTemplate.
|
|
20
|
-
*
|
|
21
|
-
* Extracts field definitions from template placeholders like `{{fieldName}}`
|
|
22
|
-
* and infers appropriate input types, labels, and autocomplete attributes.
|
|
23
|
-
*
|
|
24
|
-
* @param requestBodyTemplate - Template object with API field names as keys and `{{fieldName}}` as values
|
|
25
|
-
* @returns Array of CredentialField objects for form rendering
|
|
26
|
-
*/
|
|
27
|
-
export function parseCredentialFields(requestBodyTemplate) {
|
|
28
|
-
const fields = [];
|
|
29
|
-
for (const [apiFieldName, template] of Object.entries(requestBodyTemplate)) {
|
|
30
|
-
const match = template.match(/\{\{(\w+)\}\}/);
|
|
31
|
-
if (match && match[1]) {
|
|
32
|
-
const formFieldName = match[1];
|
|
33
|
-
const inputType = inferInputType(formFieldName);
|
|
34
|
-
fields.push({
|
|
35
|
-
name: formFieldName,
|
|
36
|
-
apiName: apiFieldName,
|
|
37
|
-
label: humanizeFieldName(formFieldName),
|
|
38
|
-
placeholder: getPlaceholder(formFieldName, inputType),
|
|
39
|
-
type: inputType,
|
|
40
|
-
autocomplete: getAutocomplete(formFieldName, inputType),
|
|
41
|
-
required: true,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
// Sort fields: non-password fields first, password fields last
|
|
46
|
-
return fields.sort((a, b) => {
|
|
47
|
-
const aIsPassword = a.type === "password";
|
|
48
|
-
const bIsPassword = b.type === "password";
|
|
49
|
-
if (aIsPassword && !bIsPassword)
|
|
50
|
-
return 1;
|
|
51
|
-
if (!aIsPassword && bIsPassword)
|
|
52
|
-
return -1;
|
|
53
|
-
return 0;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Infer HTML input type from field name
|
|
58
|
-
*/
|
|
59
|
-
export function inferInputType(fieldName) {
|
|
60
|
-
const lower = fieldName.toLowerCase();
|
|
61
|
-
// Password-like fields
|
|
62
|
-
if (lower.includes("password") ||
|
|
63
|
-
lower.includes("pass") ||
|
|
64
|
-
lower.includes("secret") ||
|
|
65
|
-
lower.includes("pin")) {
|
|
66
|
-
return "password";
|
|
67
|
-
}
|
|
68
|
-
// Email fields
|
|
69
|
-
if (lower.includes("email") || lower.includes("mail")) {
|
|
70
|
-
return "email";
|
|
71
|
-
}
|
|
72
|
-
// Phone fields
|
|
73
|
-
if (lower.includes("phone") ||
|
|
74
|
-
lower.includes("tel") ||
|
|
75
|
-
lower.includes("mobile") ||
|
|
76
|
-
lower.includes("cell")) {
|
|
77
|
-
return "tel";
|
|
78
|
-
}
|
|
79
|
-
// Date fields
|
|
80
|
-
if (lower.includes("date") ||
|
|
81
|
-
lower.includes("dob") ||
|
|
82
|
-
lower.includes("birthday") ||
|
|
83
|
-
lower.includes("birth")) {
|
|
84
|
-
return "date";
|
|
85
|
-
}
|
|
86
|
-
// Number fields
|
|
87
|
-
if (lower.includes("age") ||
|
|
88
|
-
lower.includes("zip") ||
|
|
89
|
-
lower.includes("ssn") ||
|
|
90
|
-
lower.includes("code") ||
|
|
91
|
-
lower.includes("otp")) {
|
|
92
|
-
return "number";
|
|
93
|
-
}
|
|
94
|
-
return "text";
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Convert field name to human-readable label
|
|
98
|
-
*/
|
|
99
|
-
export function humanizeFieldName(name) {
|
|
100
|
-
return name
|
|
101
|
-
.replace(/([A-Z])/g, " $1") // Add space before capitals (camelCase)
|
|
102
|
-
.replace(/[_-]/g, " ") // Replace underscores/hyphens with spaces
|
|
103
|
-
.replace(/^\w/, (c) => c.toUpperCase()) // Capitalize first letter
|
|
104
|
-
.trim();
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Get appropriate placeholder text for a field
|
|
108
|
-
*/
|
|
109
|
-
export function getPlaceholder(fieldName, inputType) {
|
|
110
|
-
const label = humanizeFieldName(fieldName);
|
|
111
|
-
switch (inputType) {
|
|
112
|
-
case "email":
|
|
113
|
-
return "you@example.com";
|
|
114
|
-
case "password":
|
|
115
|
-
return "••••••••";
|
|
116
|
-
case "tel":
|
|
117
|
-
return "+1 (555) 123-4567";
|
|
118
|
-
case "date":
|
|
119
|
-
return "YYYY-MM-DD";
|
|
120
|
-
default:
|
|
121
|
-
return `Enter your ${label.toLowerCase()}`;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Get appropriate autocomplete attribute for a field
|
|
126
|
-
*/
|
|
127
|
-
export function getAutocomplete(fieldName, inputType) {
|
|
128
|
-
const lower = fieldName.toLowerCase();
|
|
129
|
-
// Explicit mappings
|
|
130
|
-
if (lower.includes("username") || lower.includes("user")) {
|
|
131
|
-
return "username";
|
|
132
|
-
}
|
|
133
|
-
if (lower.includes("email")) {
|
|
134
|
-
return "email";
|
|
135
|
-
}
|
|
136
|
-
if (lower.includes("phone") || lower.includes("tel") || lower.includes("mobile")) {
|
|
137
|
-
return "tel";
|
|
138
|
-
}
|
|
139
|
-
if (lower.includes("password") || lower.includes("pass")) {
|
|
140
|
-
return "current-password";
|
|
141
|
-
}
|
|
142
|
-
if (lower.includes("dob") || lower.includes("birthday") || lower.includes("birth")) {
|
|
143
|
-
return "bday";
|
|
144
|
-
}
|
|
145
|
-
if (lower.includes("name") && lower.includes("first")) {
|
|
146
|
-
return "given-name";
|
|
147
|
-
}
|
|
148
|
-
if (lower.includes("name") && lower.includes("last")) {
|
|
149
|
-
return "family-name";
|
|
150
|
-
}
|
|
151
|
-
if (lower.includes("name")) {
|
|
152
|
-
return "name";
|
|
153
|
-
}
|
|
154
|
-
// Fallback based on type
|
|
155
|
-
switch (inputType) {
|
|
156
|
-
case "email":
|
|
157
|
-
return "email";
|
|
158
|
-
case "password":
|
|
159
|
-
return "current-password";
|
|
160
|
-
case "tel":
|
|
161
|
-
return "tel";
|
|
162
|
-
default:
|
|
163
|
-
return "off";
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
//# sourceMappingURL=credential-fields.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"credential-fields.js","sourceRoot":"","sources":["../../src/utils/credential-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAsBH;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,mBAA2C;IAE3C,MAAM,MAAM,GAAsB,EAAE,CAAC;IAErC,KAAK,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAC3E,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC9C,IAAI,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YACtB,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAC/B,MAAM,SAAS,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;YAEhD,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,aAAa;gBACnB,OAAO,EAAE,YAAY;gBACrB,KAAK,EAAE,iBAAiB,CAAC,aAAa,CAAC;gBACvC,WAAW,EAAE,cAAc,CAAC,aAAa,EAAE,SAAS,CAAC;gBACrD,IAAI,EAAE,SAAS;gBACf,YAAY,EAAE,eAAe,CAAC,aAAa,EAAE,SAAS,CAAC;gBACvD,QAAQ,EAAE,IAAI;aACf,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,+DAA+D;IAC/D,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1B,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI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O,KAAK,CAAC;QACf;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC"}
|
package/dist/utils/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,KAAK,eAAe,GACrB,MAAM,wBAAwB,CAAC"}
|
package/dist/utils/index.js
DELETED
package/dist/utils/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,eAAe,GAEhB,MAAM,wBAAwB,CAAC"}
|