@forgerock/davinci-client 1.1.0 → 1.3.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.
Files changed (84) hide show
  1. package/dist/src/index.d.ts +2 -1
  2. package/dist/src/index.d.ts.map +1 -1
  3. package/dist/src/index.js +2 -1
  4. package/dist/src/index.js.map +1 -1
  5. package/dist/src/lib/client.store.d.ts +47 -46
  6. package/dist/src/lib/client.store.d.ts.map +1 -1
  7. package/dist/src/lib/client.store.js +99 -86
  8. package/dist/src/lib/client.store.js.map +1 -1
  9. package/dist/src/lib/client.store.utils.d.ts +27 -14
  10. package/dist/src/lib/client.store.utils.d.ts.map +1 -1
  11. package/dist/src/lib/client.store.utils.js +15 -2
  12. package/dist/src/lib/client.store.utils.js.map +1 -1
  13. package/dist/src/lib/client.types.d.ts +58 -4
  14. package/dist/src/lib/client.types.d.ts.map +1 -1
  15. package/dist/src/lib/collector.types.d.ts +204 -11
  16. package/dist/src/lib/collector.types.d.ts.map +1 -1
  17. package/dist/src/lib/collector.types.js +0 -3
  18. package/dist/src/lib/collector.types.js.map +1 -1
  19. package/dist/src/lib/collector.utils.d.ts +75 -21
  20. package/dist/src/lib/collector.utils.d.ts.map +1 -1
  21. package/dist/src/lib/collector.utils.js +318 -16
  22. package/dist/src/lib/collector.utils.js.map +1 -1
  23. package/dist/src/lib/config.types.d.ts +3 -3
  24. package/dist/src/lib/config.types.d.ts.map +1 -1
  25. package/dist/src/lib/davinci.api.d.ts +6 -4
  26. package/dist/src/lib/davinci.api.d.ts.map +1 -1
  27. package/dist/src/lib/davinci.api.js +32 -18
  28. package/dist/src/lib/davinci.api.js.map +1 -1
  29. package/dist/src/lib/davinci.types.d.ts +96 -7
  30. package/dist/src/lib/davinci.types.d.ts.map +1 -1
  31. package/dist/src/lib/davinci.utils.d.ts +4 -7
  32. package/dist/src/lib/davinci.utils.d.ts.map +1 -1
  33. package/dist/src/lib/davinci.utils.js +16 -31
  34. package/dist/src/lib/davinci.utils.js.map +1 -1
  35. package/dist/src/lib/fido/fido.d.ts +27 -0
  36. package/dist/src/lib/fido/fido.d.ts.map +1 -0
  37. package/dist/src/lib/fido/fido.js +108 -0
  38. package/dist/src/lib/fido/fido.js.map +1 -0
  39. package/dist/src/lib/fido/fido.utils.d.ts +31 -0
  40. package/dist/src/lib/fido/fido.utils.d.ts.map +1 -0
  41. package/dist/src/lib/fido/fido.utils.js +115 -0
  42. package/dist/src/lib/fido/fido.utils.js.map +1 -0
  43. package/dist/src/lib/node.reducer.d.ts +4 -4
  44. package/dist/src/lib/node.reducer.d.ts.map +1 -1
  45. package/dist/src/lib/node.reducer.js +95 -8
  46. package/dist/src/lib/node.reducer.js.map +1 -1
  47. package/dist/src/lib/node.slice.d.ts +44 -8
  48. package/dist/src/lib/node.slice.d.ts.map +1 -1
  49. package/dist/src/lib/node.slice.js +40 -10
  50. package/dist/src/lib/node.slice.js.map +1 -1
  51. package/dist/src/lib/node.types.d.ts +6 -5
  52. package/dist/src/lib/node.types.d.ts.map +1 -1
  53. package/dist/src/lib/node.utils.d.ts +2 -2
  54. package/dist/src/lib/node.utils.d.ts.map +1 -1
  55. package/dist/src/lib/wellknown.api.d.ts +1 -1
  56. package/dist/src/types.d.ts +18 -4
  57. package/dist/src/types.d.ts.map +1 -1
  58. package/dist/src/types.js +1 -2
  59. package/dist/src/types.js.map +1 -1
  60. package/package.json +11 -20
  61. package/dist/src/lib/authorize.utils.d.ts +0 -22
  62. package/dist/src/lib/authorize.utils.d.ts.map +0 -1
  63. package/dist/src/lib/authorize.utils.js +0 -47
  64. package/dist/src/lib/authorize.utils.js.map +0 -1
  65. package/dist/src/lib/effects/request.effect.mock.d.ts +0 -4
  66. package/dist/src/lib/effects/request.effect.mock.d.ts.map +0 -1
  67. package/dist/src/lib/effects/request.effect.mock.js +0 -106
  68. package/dist/src/lib/effects/request.effect.mock.js.map +0 -1
  69. package/dist/src/lib/effects/request.effect.types.d.ts +0 -20
  70. package/dist/src/lib/effects/request.effect.types.d.ts.map +0 -1
  71. package/dist/src/lib/effects/request.effect.types.js +0 -2
  72. package/dist/src/lib/effects/request.effect.types.js.map +0 -1
  73. package/dist/src/lib/effects/request.effect.unions.d.ts +0 -12
  74. package/dist/src/lib/effects/request.effect.unions.d.ts.map +0 -1
  75. package/dist/src/lib/effects/request.effect.unions.js +0 -16
  76. package/dist/src/lib/effects/request.effect.unions.js.map +0 -1
  77. package/dist/src/lib/effects/request.effect.utils.d.ts +0 -27
  78. package/dist/src/lib/effects/request.effect.utils.d.ts.map +0 -1
  79. package/dist/src/lib/effects/request.effect.utils.js +0 -57
  80. package/dist/src/lib/effects/request.effect.utils.js.map +0 -1
  81. package/dist/src/lib/error.types.d.ts +0 -6
  82. package/dist/src/lib/error.types.d.ts.map +0 -1
  83. package/dist/src/lib/error.types.js +0 -2
  84. package/dist/src/lib/error.types.js.map +0 -1
@@ -4,8 +4,5 @@
4
4
  * This software may be modified and distributed under the terms
5
5
  * of the MIT license. See the LICENSE file for details.
6
6
  */
7
- /** *********************************************************************
8
- * SINGLE-VALUE COLLECTORS
9
- */
10
7
  export {};
11
8
  //# sourceMappingURL=collector.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collector.types.js","sourceRoot":"","sources":["../../../src/lib/collector.types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH;;GAEG"}
1
+ {"version":3,"file":"collector.types.js","sourceRoot":"","sources":["../../../src/lib/collector.types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Import the required types
3
3
  */
4
- import type { ActionCollectors, ActionCollectorTypes, InferSingleValueCollectorType, InferMultiValueCollectorType, SingleValueCollectorTypes, MultiValueCollectorTypes, NoValueCollectorTypes, InferNoValueCollectorType, ValidatedSingleValueCollectorWithValue, ValidatedTextCollector } from './collector.types.js';
5
- import type { MultiSelectFieldValue, ReadOnlyFieldValue, RedirectFieldValue, SingleSelectFieldValue, StandardFieldValue, ValidatedFieldValue } from './davinci.types.js';
4
+ import type { ActionCollectors, ActionCollectorTypes, InferSingleValueCollectorType, InferMultiValueCollectorType, SingleValueCollectorTypes, MultiValueCollectorTypes, NoValueCollectorTypes, InferNoValueCollectorType, ValidatedSingleValueCollectorWithValue, ValidatedTextCollector, InferValueObjectCollectorType, ObjectValueCollectorTypes, UnknownCollector, InferAutoCollectorType, PhoneNumberOutputValue, MultiValueCollectors, ObjectValueCollectors, AutoCollectors, SingleValueAutoCollectorTypes, ObjectValueAutoCollectorTypes } from './collector.types.js';
5
+ import type { DeviceAuthenticationField, DeviceRegistrationField, FidoAuthenticationField, FidoRegistrationField, MultiSelectField, PhoneNumberField, ProtectField, ReadOnlyField, RedirectField, SingleSelectField, StandardField, ValidatedField } from './davinci.types.js';
6
6
  /**
7
7
  * @function returnActionCollector - Creates an ActionCollector object based on the provided field and index.
8
8
  * @param {DaVinciField} field - The field object containing key, label, type, and links.
@@ -10,28 +10,28 @@ import type { MultiSelectFieldValue, ReadOnlyFieldValue, RedirectFieldValue, Sin
10
10
  * @param {ActionCollectorTypes} [collectorType] - Optional type of the ActionCollector.
11
11
  * @returns {ActionCollector} The constructed ActionCollector object.
12
12
  */
13
- export declare function returnActionCollector<CollectorType extends ActionCollectorTypes>(field: RedirectFieldValue | StandardFieldValue, idx: number, collectorType: CollectorType): ActionCollectors;
13
+ export declare function returnActionCollector<CollectorType extends ActionCollectorTypes>(field: RedirectField | StandardField, idx: number, collectorType: CollectorType): ActionCollectors;
14
14
  /**
15
15
  * @function returnFlowCollector - Returns a flow collector object
16
16
  * @param {DaVinciField} field - The field representing the flow button
17
17
  * @param {number} idx - The index of the field in the form
18
18
  * @returns {FlowCollector} - The flow collector object
19
19
  */
20
- export declare function returnFlowCollector(field: StandardFieldValue, idx: number): ActionCollectors;
20
+ export declare function returnFlowCollector(field: StandardField, idx: number): ActionCollectors;
21
21
  /**
22
22
  * @function returnIdpCollector - Returns a social login collector object
23
23
  * @param {DaVinciField} field - The field representing the social login button
24
24
  * @param {number} idx - The index of the field in the form
25
25
  * @returns {SocialLoginCollector} - The social login collector object
26
26
  */
27
- export declare function returnIdpCollector(field: RedirectFieldValue, idx: number): ActionCollectors;
27
+ export declare function returnIdpCollector(field: RedirectField, idx: number): ActionCollectors;
28
28
  /**
29
29
  * @function returnSubmitCollector - Returns a submit collector object
30
30
  * @param {DaVinciField} field - The field representing the submit button
31
31
  * @param {number} idx - The index of the field in the form
32
32
  * @returns {ActionCollector} - The submit collector object
33
33
  */
34
- export declare function returnSubmitCollector(field: StandardFieldValue, idx: number): ActionCollectors;
34
+ export declare function returnSubmitCollector(field: StandardField, idx: number): ActionCollectors;
35
35
  /**
36
36
  * @function returnSingleValueCollector - Creates a SingleValueCollector object based on the provided field, index, and optional collector type.
37
37
  * @param {DaVinciField} field - The field object containing key, label, type, and links.
@@ -39,28 +39,65 @@ export declare function returnSubmitCollector(field: StandardFieldValue, idx: nu
39
39
  * @param {SingleValueCollectorTypes} [collectorType] - Optional type of the SingleValueCollector.
40
40
  * @returns {SingleValueCollector} The constructed SingleValueCollector object.
41
41
  */
42
- export declare function returnSingleValueCollector<Field extends StandardFieldValue | SingleSelectFieldValue | ValidatedFieldValue, CollectorType extends SingleValueCollectorTypes = 'SingleValueCollector'>(field: Field, idx: number, collectorType: CollectorType, data?: string): import("./collector.types.js").SingleSelectCollector | ValidatedSingleValueCollectorWithValue<"TextCollector"> | InferSingleValueCollectorType<CollectorType>;
42
+ export declare function returnSingleValueCollector<Field extends StandardField | SingleSelectField | ValidatedField, CollectorType extends SingleValueCollectorTypes = 'SingleValueCollector'>(field: Field, idx: number, collectorType: CollectorType, data?: string): import("./collector.types.js").SingleSelectCollector | ValidatedSingleValueCollectorWithValue<"TextCollector"> | InferSingleValueCollectorType<CollectorType>;
43
+ /**
44
+ * @function returnSingleValueAutoCollector - Creates a SingleValueAutoCollector object based on the provided field, index, and optional collector type.
45
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
46
+ * @param {number} idx - The index to be used in the id of the AutoCollector.
47
+ * @param {SingleValueAutoCollectorTypes} [collectorType] - Optional type of the AutoCollector.
48
+ * @returns {AutoCollector} The constructed AutoCollector object.
49
+ */
50
+ export declare function returnSingleValueAutoCollector<Field extends ProtectField, CollectorType extends SingleValueAutoCollectorTypes = 'SingleValueAutoCollector'>(field: Field, idx: number, collectorType: CollectorType): import("./collector.types.js").ProtectCollector | InferAutoCollectorType<CollectorType>;
51
+ /**
52
+ * @function returnObjectValueAutoCollector - Creates an ObjectValueAutoCollector object based on the provided field, index, and optional collector type.
53
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
54
+ * @param {number} idx - The index to be used in the id of the AutoCollector.
55
+ * @param {ObjectValueAutoCollectorTypes} [collectorType] - Optional type of the AutoCollector.
56
+ * @returns {AutoCollector} The constructed AutoCollector object.
57
+ */
58
+ export declare function returnObjectValueAutoCollector<Field extends FidoRegistrationField | FidoAuthenticationField, CollectorType extends ObjectValueAutoCollectorTypes = 'ObjectValueAutoCollector'>(field: Field, idx: number, collectorType: CollectorType): import("./collector.types.js").FidoRegistrationCollector | import("./collector.types.js").FidoAuthenticationCollector;
43
59
  /**
44
60
  * @function returnPasswordCollector - Creates a PasswordCollector object based on the provided field and index.
45
61
  * @param {DaVinciField} field - The field object containing key, label, type, and links.
46
62
  * @param {number} idx - The index to be used in the id of the PasswordCollector.
47
63
  * @returns {PasswordCollector} The constructed PasswordCollector object.
48
64
  */
49
- export declare function returnPasswordCollector(field: StandardFieldValue, idx: number): import("./collector.types.js").SingleSelectCollector | import("./collector.types.js").PasswordCollector | ValidatedSingleValueCollectorWithValue<"TextCollector">;
65
+ export declare function returnPasswordCollector(field: StandardField, idx: number): import("./collector.types.js").SingleSelectCollector | import("./collector.types.js").PasswordCollector | ValidatedSingleValueCollectorWithValue<"TextCollector">;
50
66
  /**
51
67
  * @function returnTextCollector - Creates a TextCollector object based on the provided field and index.
52
68
  * @param {DaVinciField} field - The field object containing key, label, type, and links.
53
69
  * @param {number} idx - The index to be used in the id of the TextCollector.
54
70
  * @returns {TextCollector} The constructed TextCollector object.
55
71
  */
56
- export declare function returnTextCollector(field: StandardFieldValue, idx: number, data: string): import("./collector.types.js").TextCollector | import("./collector.types.js").SingleSelectCollector | ValidatedSingleValueCollectorWithValue<"TextCollector">;
72
+ export declare function returnTextCollector(field: StandardField, idx: number, data: string): import("./collector.types.js").TextCollector | import("./collector.types.js").SingleSelectCollector | ValidatedSingleValueCollectorWithValue<"TextCollector">;
57
73
  /**
58
74
  * @function returnSingleSelectCollector - Creates a SingleCollector object based on the provided field and index.
59
75
  * @param {DaVinciField} field - The field object containing key, label, type, and links.
60
76
  * @param {number} idx - The index to be used in the id of the SingleCollector.
61
77
  * @returns {SingleValueCollector} The constructed SingleCollector object.
62
78
  */
63
- export declare function returnSingleSelectCollector(field: SingleSelectFieldValue, idx: number, data: string): import("./collector.types.js").SingleSelectCollector | ValidatedSingleValueCollectorWithValue<"TextCollector">;
79
+ export declare function returnSingleSelectCollector(field: SingleSelectField, idx: number, data: string): import("./collector.types.js").SingleSelectCollector | ValidatedSingleValueCollectorWithValue<"TextCollector">;
80
+ /**
81
+ * @function returnProtectCollector - Creates a ProtectCollector object based on the provided field and index.
82
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
83
+ * @param {number} idx - The index to be used in the id of the ProtectCollector.
84
+ * @returns {ProtectCollector} The constructed ProtectCollector object.
85
+ */
86
+ export declare function returnProtectCollector(field: ProtectField, idx: number): import("./collector.types.js").ProtectCollector;
87
+ /**
88
+ * @function returnFidoRegistrationCollector - Creates a FidoRegistrationCollector object based on the provided field and index.
89
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
90
+ * @param {number} idx - The index to be used in the id of the FidoRegistrationCollector.
91
+ * @returns {FidoRegistrationCollector} The constructed FidoRegistrationCollector object.
92
+ */
93
+ export declare function returnFidoRegistrationCollector(field: FidoRegistrationField, idx: number): import("./collector.types.js").FidoRegistrationCollector | import("./collector.types.js").FidoAuthenticationCollector;
94
+ /**
95
+ * @function returnFidoAuthenticationCollector - Creates a FidoAuthenticationCollector object based on the provided field and index.
96
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
97
+ * @param {number} idx - The index to be used in the id of the FidoAuthenticationCollector.
98
+ * @returns {FidoAuthenticationCollector} The constructed FidoAuthenticationCollector object.
99
+ */
100
+ export declare function returnFidoAuthenticationCollector(field: FidoAuthenticationField, idx: number): import("./collector.types.js").FidoRegistrationCollector | import("./collector.types.js").FidoAuthenticationCollector;
64
101
  /**
65
102
  * @function returnMultiValueCollector - Creates a MultiValueCollector object based on the provided field, index, and optional collector type.
66
103
  * @param {DaVinciField} field - The field object containing key, label, type, and links.
@@ -68,33 +105,50 @@ export declare function returnSingleSelectCollector(field: SingleSelectFieldValu
68
105
  * @param {MultiValueCollectorTypes} [collectorType] - Optional type of the MultiValueCollector.
69
106
  * @returns {MultiValueCollector} The constructed MultiValueCollector object.
70
107
  */
71
- export declare function returnMultiValueCollector<Field extends MultiSelectFieldValue, CollectorType extends MultiValueCollectorTypes = 'MultiValueCollector'>(field: Field, idx: number, collectorType: CollectorType, data?: string[]): InferMultiValueCollectorType<CollectorType>;
108
+ export declare function returnMultiValueCollector<Field extends MultiSelectField, CollectorType extends MultiValueCollectorTypes = 'MultiValueCollector'>(field: Field, idx: number, collectorType: CollectorType, data?: string[]): InferMultiValueCollectorType<CollectorType>;
72
109
  /**
73
110
  * @function returnMultiSelectCollector - Creates a DropDownCollector object based on the provided field and index.
74
111
  * @param {DaVinciField} field - The field object containing key, label, type, and links.
75
112
  * @param {number} idx - The index to be used in the id of the DropDownCollector.
76
113
  * @returns {SingleValueCollector} The constructed DropDownCollector object.
77
114
  */
78
- export declare function returnMultiSelectCollector(field: MultiSelectFieldValue, idx: number, data: string[]): import("./collector.types.js").MultiValueCollectorWithValue<"MultiSelectCollector">;
115
+ export declare function returnMultiSelectCollector(field: MultiSelectField, idx: number, data: string[]): import("./collector.types.js").MultiValueCollectorWithValue<"MultiSelectCollector">;
79
116
  /**
80
- * @function returnMultiValueCollector - Creates a MultiValueCollector object based on the provided field, index, and optional collector type.
117
+ * @function returnObjectCollector - Creates a ObjectCollector object based on the provided field, index, and optional collector type.
81
118
  * @param {DaVinciField} field - The field object containing key, label, type, and links.
82
- * @param {number} idx - The index to be used in the id of the MultiValueCollector.
83
- * @param {MultiValueCollectorTypes} [collectorType] - Optional type of the MultiValueCollector.
84
- * @returns {MultiValueCollector} The constructed MultiValueCollector object.
119
+ * @param {number} idx - The index to be used in the id of the ObjectCollector.
120
+ * @param {ObjectValueCollectorTypes} [collectorType] - Optional type of the ObjectCollector.
121
+ * @returns {ObjectCollector} The constructed ObjectCollector object.
85
122
  */
86
- export declare function returnNoValueCollector<Field extends ReadOnlyFieldValue, CollectorType extends NoValueCollectorTypes = 'NoValueCollector'>(field: Field, idx: number, collectorType: CollectorType): InferNoValueCollectorType<CollectorType>;
123
+ export declare function returnObjectCollector<Field extends DeviceAuthenticationField | DeviceRegistrationField | PhoneNumberField, CollectorType extends ObjectValueCollectorTypes = 'ObjectValueCollector'>(field: Field, idx: number, collectorType: CollectorType, prefillData?: PhoneNumberOutputValue): InferValueObjectCollectorType<CollectorType>;
87
124
  /**
88
- * @function returnMultiSelectCollector - Creates a DropDownCollector object based on the provided field and index.
125
+ * @function returnObjectSelectCollector - Creates a DropDownCollector object based on the provided field and index.
89
126
  * @param {DaVinciField} field - The field object containing key, label, type, and links.
90
127
  * @param {number} idx - The index to be used in the id of the DropDownCollector.
91
128
  * @returns {SingleValueCollector} The constructed DropDownCollector object.
92
129
  */
93
- export declare function returnReadOnlyCollector(field: ReadOnlyFieldValue, idx: number): import("./collector.types.js").NoValueCollectorBase<"ReadOnlyCollector">;
130
+ export declare function returnObjectSelectCollector(field: DeviceAuthenticationField | DeviceRegistrationField, idx: number): import("./collector.types.js").DeviceAuthenticationCollector | import("./collector.types.js").DeviceRegistrationCollector;
131
+ export declare function returnObjectValueCollector(field: PhoneNumberField, idx: number, prefillData: PhoneNumberOutputValue): import("./collector.types.js").PhoneNumberCollector;
132
+ /**
133
+ * @function returnNoValueCollector - Creates a NoValueCollector object based on the provided field, index, and optional collector type.
134
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
135
+ * @param {number} idx - The index to be used in the id of the NoValueCollector.
136
+ * @param {NoValueCollectorTypes} [collectorType] - Optional type of the NoValueCollector.
137
+ * @returns {NoValueCollector} The constructed NoValueCollector object.
138
+ */
139
+ export declare function returnNoValueCollector<Field extends ReadOnlyField, CollectorType extends NoValueCollectorTypes = 'NoValueCollector'>(field: Field, idx: number, collectorType: CollectorType): InferNoValueCollectorType<CollectorType>;
140
+ /**
141
+ * @function returnReadOnlyCollector - Creates a ReadOnlyCollector object based on the provided field and index.
142
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
143
+ * @param {number} idx - The index to be used in the id of the ReadOnlyCollector.
144
+ * @returns {ReadOnlyCollector} The constructed ReadOnlyCollector object.
145
+ */
146
+ export declare function returnReadOnlyCollector(field: ReadOnlyField, idx: number): import("./collector.types.js").NoValueCollectorBase<"ReadOnlyCollector">;
94
147
  /**
95
148
  * @function returnValidator - Creates a validator function based on the provided collector
96
- * @param collector {ValidatedTextCollector} - The collector to which the value will be validated
149
+ * @param {ValidatedTextCollector | ObjectValueCollectors | MultiValueCollectors | AutoCollectors} collector - The collector to which the value will be validated
97
150
  * @returns {function} - A "validator" function that validates the input value
98
151
  */
99
- export declare function returnValidator(collector: ValidatedTextCollector): (value: string) => string[];
152
+ export declare function returnValidator(collector: ValidatedTextCollector | ObjectValueCollectors | MultiValueCollectors | AutoCollectors): (value: string | string[] | Record<string, unknown>) => string[];
153
+ export declare function returnUnknownCollector(field: Record<string, unknown>, idx: number): UnknownCollector;
100
154
  //# sourceMappingURL=collector.utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"collector.utils.d.ts","sourceRoot":"","sources":["../../../src/lib/collector.utils.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,OAAO,KAA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KAEvF;AACD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,sBAAsB,EAC7B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,kHAGb;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,SAAS,qBAAqB,EACnC,aAAa,SAAS,wBAAwB,GAAG,qBAAqB,EACtE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAiCnE,4BAA4B,CAAC,aAAa,CAAC,CACjD;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,qBAAqB,EAC5B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EAAE,uFAGf;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,SAAS,kBAAkB,EAChC,aAAa,SAAS,qBAAqB,GAAG,kBAAkB,EAChE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,GAoBlD,yBAAyB,CAAC,aAAa,CAAC,CAC9C;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,MAAM,4EAE7E;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,sBAAsB,WAEhD,MAAM,cAkBtB"}
1
+ {"version":3,"file":"collector.utils.d.ts","sourceRoot":"","sources":["../../../src/lib/collector.utils.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACpB,6BAA6B,EAC7B,4BAA4B,EAC5B,yBAAyB,EACzB,wBAAwB,EAExB,qBAAqB,EACrB,yBAAyB,EACzB,sCAAsC,EACtC,sBAAsB,EACtB,6BAA6B,EAC7B,yBAAyB,EACzB,gBAAgB,EAChB,sBAAsB,EACtB,sBA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AAuB,GAAG,gBAAgB,EACpF,aAAa,SAAS,yBAAyB,GAAG,sBAAsB,EACxE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,sBAAsB,GAwGxF,6BAA6B,CAAC,aAAa,CAAC,CAClD;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,yBAAyB,GAAG,uBAAuB,EAC1D,GAAG,EAAE,MAAM,6HASZ;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,sBAAsB,uDAGpC;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,SAAS,aAAa,EAC3B,aAAa,SAAS,qBAAqB,GAAG,kBAAkB,EAChE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,GAoBlD,yBAAyB,CAAC,aAAa,CAAC,CAC9C;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,4EAExE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,sBAAsB,GAAG,qBAAqB,GAAG,oBAAoB,GAAG,cAAc,IAGzF,OAAO,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,cA0B3D;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAY3E,gBAAgB,CACtB"}
@@ -156,7 +156,7 @@ export function returnSingleValueCollector(field, idx, collectorType, data) {
156
156
  rule: field.validation?.regex || '',
157
157
  });
158
158
  }
159
- if ('required' in field) {
159
+ if ('required' in field && field.required === true) {
160
160
  validationArray.push({
161
161
  type: 'required',
162
162
  message: 'Value cannot be empty',
@@ -171,7 +171,7 @@ export function returnSingleValueCollector(field, idx, collectorType, data) {
171
171
  name: field.key,
172
172
  input: {
173
173
  key: field.key,
174
- value: '',
174
+ value: data || '',
175
175
  type: field.type,
176
176
  validation: validationArray,
177
177
  },
@@ -204,6 +204,134 @@ export function returnSingleValueCollector(field, idx, collectorType, data) {
204
204
  };
205
205
  }
206
206
  }
207
+ /**
208
+ * @function returnSingleValueAutoCollector - Creates a SingleValueAutoCollector object based on the provided field, index, and optional collector type.
209
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
210
+ * @param {number} idx - The index to be used in the id of the AutoCollector.
211
+ * @param {SingleValueAutoCollectorTypes} [collectorType] - Optional type of the AutoCollector.
212
+ * @returns {AutoCollector} The constructed AutoCollector object.
213
+ */
214
+ export function returnSingleValueAutoCollector(field, idx, collectorType) {
215
+ let error = '';
216
+ if (!('key' in field)) {
217
+ error = `${error}Key is not found in the field object. `;
218
+ }
219
+ if (!('type' in field)) {
220
+ error = `${error}Type is not found in the field object. `;
221
+ }
222
+ if (collectorType === 'ProtectCollector') {
223
+ return {
224
+ category: 'SingleValueAutoCollector',
225
+ error: error || null,
226
+ type: collectorType,
227
+ id: `${field?.key}-${idx}`,
228
+ name: field.key,
229
+ input: {
230
+ key: field.key,
231
+ value: '',
232
+ type: field.type,
233
+ },
234
+ output: {
235
+ key: field.key,
236
+ type: field.type,
237
+ config: {
238
+ behavioralDataCollection: field.behavioralDataCollection,
239
+ universalDeviceIdentification: field.universalDeviceIdentification,
240
+ },
241
+ },
242
+ };
243
+ }
244
+ else {
245
+ return {
246
+ category: 'SingleValueAutoCollector',
247
+ error: error || null,
248
+ type: collectorType || 'SingleValueAutoCollector',
249
+ id: `${field.key}-${idx}`,
250
+ name: field.key,
251
+ input: {
252
+ key: field.key,
253
+ value: '',
254
+ type: field.type,
255
+ },
256
+ output: {
257
+ key: field.key,
258
+ type: field.type,
259
+ },
260
+ };
261
+ }
262
+ }
263
+ /**
264
+ * @function returnObjectValueAutoCollector - Creates an ObjectValueAutoCollector object based on the provided field, index, and optional collector type.
265
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
266
+ * @param {number} idx - The index to be used in the id of the AutoCollector.
267
+ * @param {ObjectValueAutoCollectorTypes} [collectorType] - Optional type of the AutoCollector.
268
+ * @returns {AutoCollector} The constructed AutoCollector object.
269
+ */
270
+ export function returnObjectValueAutoCollector(field, idx, collectorType) {
271
+ let error = '';
272
+ if (!('key' in field)) {
273
+ error = `${error}Key is not found in the field object. `;
274
+ }
275
+ if (!('type' in field)) {
276
+ error = `${error}Type is not found in the field object. `;
277
+ }
278
+ const validationArray = [];
279
+ if ('required' in field && field.required === true) {
280
+ validationArray.push({
281
+ type: 'required',
282
+ message: 'Value cannot be empty',
283
+ rule: true,
284
+ });
285
+ }
286
+ if (field.action === 'REGISTER') {
287
+ return {
288
+ category: 'ObjectValueAutoCollector',
289
+ error: error || null,
290
+ type: collectorType,
291
+ id: `${field?.key}-${idx}`,
292
+ name: field.key,
293
+ input: {
294
+ key: field.key,
295
+ value: {},
296
+ type: field.type,
297
+ validation: validationArray.length ? validationArray : null,
298
+ },
299
+ output: {
300
+ key: field.key,
301
+ type: field.type,
302
+ config: {
303
+ publicKeyCredentialCreationOptions: field.publicKeyCredentialCreationOptions,
304
+ action: field.action,
305
+ trigger: field.trigger,
306
+ },
307
+ },
308
+ };
309
+ }
310
+ else {
311
+ return {
312
+ category: 'ObjectValueAutoCollector',
313
+ error: error || null,
314
+ type: collectorType,
315
+ id: `${field?.key}-${idx}`,
316
+ name: field.key,
317
+ input: {
318
+ key: field.key,
319
+ value: {},
320
+ type: field.type,
321
+ validation: validationArray.length ? validationArray : null,
322
+ },
323
+ output: {
324
+ key: field.key,
325
+ type: field.type,
326
+ config: {
327
+ publicKeyCredentialRequestOptions: field.publicKeyCredentialRequestOptions,
328
+ action: field.action,
329
+ trigger: field.trigger,
330
+ },
331
+ },
332
+ };
333
+ }
334
+ }
207
335
  /**
208
336
  * @function returnPasswordCollector - Creates a PasswordCollector object based on the provided field and index.
209
337
  * @param {DaVinciField} field - The field object containing key, label, type, and links.
@@ -231,6 +359,33 @@ export function returnTextCollector(field, idx, data) {
231
359
  export function returnSingleSelectCollector(field, idx, data) {
232
360
  return returnSingleValueCollector(field, idx, 'SingleSelectCollector', data);
233
361
  }
362
+ /**
363
+ * @function returnProtectCollector - Creates a ProtectCollector object based on the provided field and index.
364
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
365
+ * @param {number} idx - The index to be used in the id of the ProtectCollector.
366
+ * @returns {ProtectCollector} The constructed ProtectCollector object.
367
+ */
368
+ export function returnProtectCollector(field, idx) {
369
+ return returnSingleValueAutoCollector(field, idx, 'ProtectCollector');
370
+ }
371
+ /**
372
+ * @function returnFidoRegistrationCollector - Creates a FidoRegistrationCollector object based on the provided field and index.
373
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
374
+ * @param {number} idx - The index to be used in the id of the FidoRegistrationCollector.
375
+ * @returns {FidoRegistrationCollector} The constructed FidoRegistrationCollector object.
376
+ */
377
+ export function returnFidoRegistrationCollector(field, idx) {
378
+ return returnObjectValueAutoCollector(field, idx, 'FidoRegistrationCollector');
379
+ }
380
+ /**
381
+ * @function returnFidoAuthenticationCollector - Creates a FidoAuthenticationCollector object based on the provided field and index.
382
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
383
+ * @param {number} idx - The index to be used in the id of the FidoAuthenticationCollector.
384
+ * @returns {FidoAuthenticationCollector} The constructed FidoAuthenticationCollector object.
385
+ */
386
+ export function returnFidoAuthenticationCollector(field, idx) {
387
+ return returnObjectValueAutoCollector(field, idx, 'FidoAuthenticationCollector');
388
+ }
234
389
  /**
235
390
  * @function returnMultiValueCollector - Creates a MultiValueCollector object based on the provided field, index, and optional collector type.
236
391
  * @param {DaVinciField} field - The field object containing key, label, type, and links.
@@ -252,6 +407,14 @@ export function returnMultiValueCollector(field, idx, collectorType, data) {
252
407
  if (!('options' in field)) {
253
408
  error = `${error}Options are not found in the field object. `;
254
409
  }
410
+ const validationArray = [];
411
+ if ('required' in field && field.required === true) {
412
+ validationArray.push({
413
+ type: 'required',
414
+ message: 'Value cannot be empty',
415
+ rule: true,
416
+ });
417
+ }
255
418
  return {
256
419
  category: 'MultiValueCollector',
257
420
  error: error || null,
@@ -260,8 +423,9 @@ export function returnMultiValueCollector(field, idx, collectorType, data) {
260
423
  name: field.key,
261
424
  input: {
262
425
  key: field.key,
263
- value: [],
426
+ value: data || [],
264
427
  type: field.type,
428
+ validation: validationArray.length ? validationArray : null,
265
429
  },
266
430
  output: {
267
431
  key: field.key,
@@ -282,11 +446,131 @@ export function returnMultiSelectCollector(field, idx, data) {
282
446
  return returnMultiValueCollector(field, idx, 'MultiSelectCollector', data);
283
447
  }
284
448
  /**
285
- * @function returnMultiValueCollector - Creates a MultiValueCollector object based on the provided field, index, and optional collector type.
449
+ * @function returnObjectCollector - Creates a ObjectCollector object based on the provided field, index, and optional collector type.
286
450
  * @param {DaVinciField} field - The field object containing key, label, type, and links.
287
- * @param {number} idx - The index to be used in the id of the MultiValueCollector.
288
- * @param {MultiValueCollectorTypes} [collectorType] - Optional type of the MultiValueCollector.
289
- * @returns {MultiValueCollector} The constructed MultiValueCollector object.
451
+ * @param {number} idx - The index to be used in the id of the ObjectCollector.
452
+ * @param {ObjectValueCollectorTypes} [collectorType] - Optional type of the ObjectCollector.
453
+ * @returns {ObjectCollector} The constructed ObjectCollector object.
454
+ */
455
+ export function returnObjectCollector(field, idx, collectorType, prefillData) {
456
+ let error = '';
457
+ if (!('key' in field)) {
458
+ error = `${error}Key is not found in the field object. `;
459
+ }
460
+ if (!('label' in field)) {
461
+ error = `${error}Label is not found in the field object. `;
462
+ }
463
+ if (!('type' in field)) {
464
+ error = `${error}Type is not found in the field object. `;
465
+ }
466
+ const validationArray = [];
467
+ if ('required' in field && field.required === true) {
468
+ validationArray.push({
469
+ type: 'required',
470
+ message: 'Value cannot be empty',
471
+ rule: true,
472
+ });
473
+ }
474
+ let options;
475
+ let defaultValue;
476
+ if (field.type === 'DEVICE_AUTHENTICATION') {
477
+ if (!('options' in field)) {
478
+ error = `${error}Device options are not found in the field object. `;
479
+ }
480
+ if (Array.isArray(field.options) && field.options.length === 0) {
481
+ error = `${error}Device options are not an array or is empty. `;
482
+ }
483
+ const unmappedDefault = field.options?.find((device) => device.default);
484
+ defaultValue = {
485
+ type: unmappedDefault ? unmappedDefault.type : '',
486
+ value: unmappedDefault ? unmappedDefault.description : '',
487
+ id: unmappedDefault ? unmappedDefault.id : '',
488
+ };
489
+ // Map DaVinci spec to normalized SDK API
490
+ options =
491
+ field.options?.map((device) => ({
492
+ type: device.type,
493
+ label: device.title,
494
+ content: device.description,
495
+ value: device.id,
496
+ key: device.id,
497
+ default: device.default,
498
+ })) ?? [];
499
+ }
500
+ else if (field.type === 'DEVICE_REGISTRATION') {
501
+ if (!('options' in field)) {
502
+ error = `${error}Device options are not found in the field object. `;
503
+ }
504
+ if (Array.isArray(field.options) && field.options.length === 0) {
505
+ error = `${error}Device options are not an array or is empty. `;
506
+ }
507
+ defaultValue = '';
508
+ // Map DaVinci spec to normalized SDK API
509
+ options =
510
+ field.options?.map((device, idx) => ({
511
+ type: device.type,
512
+ label: device.title,
513
+ content: device.description,
514
+ value: device.type,
515
+ key: `${device.type}-${idx}`,
516
+ })) ?? [];
517
+ }
518
+ else if (field.type === 'PHONE_NUMBER') {
519
+ if ('validatePhoneNumber' in field && field.validatePhoneNumber === true) {
520
+ validationArray.push({
521
+ type: 'validatePhoneNumber',
522
+ message: 'Phone number should be validated',
523
+ rule: true,
524
+ });
525
+ }
526
+ const prefilledCountryCode = prefillData?.countryCode;
527
+ const prefilledPhone = prefillData?.phoneNumber;
528
+ defaultValue = {
529
+ countryCode: prefilledCountryCode ? prefilledCountryCode : field.defaultCountryCode || '',
530
+ phoneNumber: prefilledPhone || '',
531
+ };
532
+ }
533
+ return {
534
+ category: 'ObjectValueCollector',
535
+ error: error || null,
536
+ type: collectorType || 'ObjectValueCollector',
537
+ id: `${field.key}-${idx}`,
538
+ name: field.key,
539
+ input: {
540
+ key: field.key,
541
+ value: defaultValue,
542
+ type: field.type,
543
+ validation: validationArray.length ? validationArray : null,
544
+ },
545
+ output: {
546
+ key: field.key,
547
+ label: field.label,
548
+ type: field.type,
549
+ ...(options && { options: options || [] }),
550
+ ...(defaultValue && { value: defaultValue }),
551
+ },
552
+ };
553
+ }
554
+ /**
555
+ * @function returnObjectSelectCollector - Creates a DropDownCollector object based on the provided field and index.
556
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
557
+ * @param {number} idx - The index to be used in the id of the DropDownCollector.
558
+ * @returns {SingleValueCollector} The constructed DropDownCollector object.
559
+ */
560
+ export function returnObjectSelectCollector(field, idx) {
561
+ return returnObjectCollector(field, idx, field.type === 'DEVICE_AUTHENTICATION'
562
+ ? 'DeviceAuthenticationCollector'
563
+ : 'DeviceRegistrationCollector');
564
+ }
565
+ export function returnObjectValueCollector(field, idx, prefillData) {
566
+ return returnObjectCollector(field, idx, 'PhoneNumberCollector', prefillData);
567
+ }
568
+ /**
569
+ * @function returnNoValueCollector - Creates a NoValueCollector object based on the provided field, index, and optional collector type.
570
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
571
+ * @param {number} idx - The index to be used in the id of the NoValueCollector.
572
+ * @param {NoValueCollectorTypes} [collectorType] - Optional type of the NoValueCollector.
573
+ * @returns {NoValueCollector} The constructed NoValueCollector object.
290
574
  */
291
575
  export function returnNoValueCollector(field, idx, collectorType) {
292
576
  let error = '';
@@ -310,27 +594,31 @@ export function returnNoValueCollector(field, idx, collectorType) {
310
594
  };
311
595
  }
312
596
  /**
313
- * @function returnMultiSelectCollector - Creates a DropDownCollector object based on the provided field and index.
597
+ * @function returnReadOnlyCollector - Creates a ReadOnlyCollector object based on the provided field and index.
314
598
  * @param {DaVinciField} field - The field object containing key, label, type, and links.
315
- * @param {number} idx - The index to be used in the id of the DropDownCollector.
316
- * @returns {SingleValueCollector} The constructed DropDownCollector object.
599
+ * @param {number} idx - The index to be used in the id of the ReadOnlyCollector.
600
+ * @returns {ReadOnlyCollector} The constructed ReadOnlyCollector object.
317
601
  */
318
602
  export function returnReadOnlyCollector(field, idx) {
319
603
  return returnNoValueCollector(field, idx, 'ReadOnlyCollector');
320
604
  }
321
605
  /**
322
606
  * @function returnValidator - Creates a validator function based on the provided collector
323
- * @param collector {ValidatedTextCollector} - The collector to which the value will be validated
607
+ * @param {ValidatedTextCollector | ObjectValueCollectors | MultiValueCollectors | AutoCollectors} collector - The collector to which the value will be validated
324
608
  * @returns {function} - A "validator" function that validates the input value
325
609
  */
326
610
  export function returnValidator(collector) {
327
611
  const rules = collector.input.validation;
328
612
  return (value) => {
329
- return rules.reduce((acc, next) => {
330
- if (next.type === 'required' && !value) {
331
- acc.push(next.message);
613
+ return (rules?.reduce((acc, next) => {
614
+ if (next.type === 'required') {
615
+ if (!value ||
616
+ (Array.isArray(value) && !value.length) ||
617
+ (typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length)) {
618
+ acc.push(next.message);
619
+ }
332
620
  }
333
- else if (next.type === 'regex') {
621
+ else if (next.type === 'regex' && typeof value === 'string') {
334
622
  try {
335
623
  const result = new RegExp(next.rule).test(value);
336
624
  if (!result) {
@@ -343,7 +631,21 @@ export function returnValidator(collector) {
343
631
  }
344
632
  }
345
633
  return acc;
346
- }, []);
634
+ }, []) ?? []);
635
+ };
636
+ }
637
+ export function returnUnknownCollector(field, idx) {
638
+ return {
639
+ category: 'UnknownCollector',
640
+ error: 'Detected an unknown or unsupported collector type',
641
+ type: field['type'],
642
+ id: `${field['key'] || field['type']}-${idx}`,
643
+ name: field['key'] || field['type'],
644
+ output: {
645
+ key: `${field['key'] || field['type']}-${idx}`,
646
+ label: field['label'] || field['content'],
647
+ type: field['type'],
648
+ },
347
649
  };
348
650
  }
349
651
  //# sourceMappingURL=collector.utils.js.map