@forgerock/davinci-client 0.1.3

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 (53) hide show
  1. package/README.md +354 -0
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +4 -0
  5. package/dist/lib/authorize.utils.d.ts +22 -0
  6. package/dist/lib/authorize.utils.d.ts.map +1 -0
  7. package/dist/lib/authorize.utils.js +23 -0
  8. package/dist/lib/client.store.d.ts +149 -0
  9. package/dist/lib/client.store.d.ts.map +1 -0
  10. package/dist/lib/client.store.js +131 -0
  11. package/dist/lib/client.store.utils.d.ts +46 -0
  12. package/dist/lib/client.store.utils.d.ts.map +1 -0
  13. package/dist/lib/client.store.utils.js +19 -0
  14. package/dist/lib/client.types.d.ts +9 -0
  15. package/dist/lib/client.types.d.ts.map +1 -0
  16. package/dist/lib/collector.types.d.ts +78 -0
  17. package/dist/lib/collector.types.d.ts.map +1 -0
  18. package/dist/lib/collector.utils.d.ts +54 -0
  19. package/dist/lib/collector.utils.d.ts.map +1 -0
  20. package/dist/lib/collector.utils.js +88 -0
  21. package/dist/lib/config.slice.d.ts +35 -0
  22. package/dist/lib/config.slice.d.ts.map +1 -0
  23. package/dist/lib/config.slice.js +40 -0
  24. package/dist/lib/config.types.d.ts +9 -0
  25. package/dist/lib/config.types.d.ts.map +1 -0
  26. package/dist/lib/davinci.api.d.ts +20 -0
  27. package/dist/lib/davinci.api.d.ts.map +1 -0
  28. package/dist/lib/davinci.api.js +172 -0
  29. package/dist/lib/davinci.types.d.ts +185 -0
  30. package/dist/lib/davinci.types.d.ts.map +1 -0
  31. package/dist/lib/davinci.utils.d.ts +18 -0
  32. package/dist/lib/davinci.utils.d.ts.map +1 -0
  33. package/dist/lib/davinci.utils.js +102 -0
  34. package/dist/lib/error.types.d.ts +6 -0
  35. package/dist/lib/error.types.d.ts.map +1 -0
  36. package/dist/lib/index.d.ts +3 -0
  37. package/dist/lib/index.d.ts.map +1 -0
  38. package/dist/lib/node.reducer.d.ts +22 -0
  39. package/dist/lib/node.reducer.d.ts.map +1 -0
  40. package/dist/lib/node.reducer.js +31 -0
  41. package/dist/lib/node.slice.d.ts +134 -0
  42. package/dist/lib/node.slice.d.ts.map +1 -0
  43. package/dist/lib/node.slice.js +160 -0
  44. package/dist/lib/node.types.d.ts +109 -0
  45. package/dist/lib/node.types.d.ts.map +1 -0
  46. package/dist/lib/wellknown.api.d.ts +5 -0
  47. package/dist/lib/wellknown.api.d.ts.map +1 -0
  48. package/dist/lib/wellknown.api.js +15 -0
  49. package/dist/lib/wellknown.types.d.ts +38 -0
  50. package/dist/lib/wellknown.types.d.ts.map +1 -0
  51. package/dist/types.d.ts +23 -0
  52. package/dist/types.d.ts.map +1 -0
  53. package/package.json +36 -0
@@ -0,0 +1,131 @@
1
+ import { createClientStore as d } from "./client.store.utils.js";
2
+ import { nodeSlice as n } from "./node.slice.js";
3
+ import { davinciApi as o } from "./davinci.api.js";
4
+ import { configSlice as p } from "./config.slice.js";
5
+ import { wellknownApi as g } from "./wellknown.api.js";
6
+ async function C({ config: a }) {
7
+ const t = d();
8
+ if (!a.serverConfig.wellknown)
9
+ throw new Error("`wellknown` property is a required as part of the `config.serverOptions`");
10
+ if (!a.clientId)
11
+ throw new Error("`clientId` property is a required as part of the `config`");
12
+ const { data: i } = await t.dispatch(
13
+ g.endpoints.wellknown.initiate(a.serverConfig.wellknown)
14
+ );
15
+ if (!i)
16
+ throw new Error("error fetching `wellknown` response for OpenId Configuration");
17
+ return t.dispatch(p.actions.set({ ...a, wellknownResponse: i })), {
18
+ // Pass store methods to the client
19
+ subscribe: t.subscribe,
20
+ /**
21
+ * @method flow - Method for initiating a new flow, different than current flow
22
+ * @param {DaVinciAction} action - the action to initiate the flow
23
+ * @returns {function} - an async function to call the flow
24
+ */
25
+ flow: (e) => e.action ? async function() {
26
+ return await t.dispatch(o.endpoints.flow.initiate(e)), n.selectSlice(t.getState());
27
+ } : (console.error("Missing `argument.action`"), async function() {
28
+ return { error: { message: "Missing argument.action", type: "argument_error" } };
29
+ }),
30
+ /**
31
+ * @method next - Method for initiating the next node in the current flow
32
+ * @param {DaVinciRequest} args - the arguments to pass to the next
33
+ * @returns {Promise} - a promise that resolves to the next node
34
+ */
35
+ next: async (e) => {
36
+ const r = n.selectSlice(t.getState());
37
+ return r.status === "start" ? {
38
+ ...r,
39
+ error: "Please use `start` before calling `next`"
40
+ } : (await t.dispatch(o.endpoints.next.initiate(e)), n.selectSlice(t.getState()));
41
+ },
42
+ /**
43
+ * @method start - Method for initiating a DaVinci flow
44
+ * @returns {Promise} - a promise that initiates a DaVinci flow and returns a node
45
+ */
46
+ start: async () => (await t.dispatch(o.endpoints.start.initiate()), t.getState().node),
47
+ /**
48
+ * @method update - Exclusive method for updating the current node with user provided values
49
+ * @param {SingleValueCollector} collector - the collector to update
50
+ * @returns {function} - an function to call for updating collector value
51
+ */
52
+ update: (e) => {
53
+ if (!e.id)
54
+ return console.error("Argument for `collector` has no ID"), function() {
55
+ return {
56
+ error: { message: "Argument for `collector` has no ID", type: "argument_error" }
57
+ };
58
+ };
59
+ const { id: r } = e, s = n.selectors.selectCollector(t.getState(), r);
60
+ return s ? s.category !== "SingleValueCollector" ? (console.error("Collector is not a SingleValueCollector and cannot be updated"), function() {
61
+ return {
62
+ error: {
63
+ message: "Collector is not a SingleValueCollector and cannot be updated",
64
+ type: "state_error"
65
+ }
66
+ };
67
+ }) : function(c, l) {
68
+ try {
69
+ return t.dispatch(n.actions.update({ id: r, value: c, index: l })), null;
70
+ } catch (u) {
71
+ return { error: { message: u.message, type: "internal_error" } };
72
+ }
73
+ } : function() {
74
+ return console.error("Collector not found"), {
75
+ error: { message: "Collector not found", type: "state_error" }
76
+ };
77
+ };
78
+ },
79
+ /**
80
+ * @method client - Selector to get the node.client from state
81
+ * @returns {Node.client} - the client property from the current node
82
+ */
83
+ getClient: () => n.selectors.selectClient(t.getState()),
84
+ /**
85
+ * @method collectors - Selector to get the collectors from state
86
+ * @returns {Collector[]} - The collectors from the current node in state
87
+ */
88
+ getCollectors: () => {
89
+ const e = t.getState(), r = n.selectors.selectClient(e);
90
+ return r && "collectors" in r ? n.selectors.selectCollectors(e) || [] : [];
91
+ },
92
+ getError: () => {
93
+ const e = t.getState();
94
+ return n.selectors.selectError(e);
95
+ },
96
+ /**
97
+ * @method node - Selector to get the node from state
98
+ * @returns {Node} - the current node from state
99
+ */
100
+ getNode: () => n.selectSlice(t.getState()),
101
+ /**
102
+ * @method server - Selector to get the node.server from state
103
+ * @returns {Node.server} - the server property from the current node
104
+ */
105
+ getServer: () => {
106
+ const e = t.getState();
107
+ return n.selectors.selectServer(e);
108
+ },
109
+ /**
110
+ * Utilities to help query cached responses from server
111
+ */
112
+ cache: {
113
+ getLatestResponse: () => {
114
+ const e = n.selectSlice(t.getState());
115
+ if (!e.cache?.key)
116
+ return console.error("Cannot find current node's cache key or no current node"), { error: { message: "Cannot find current node", type: "state_error" } };
117
+ const r = o.endpoints.flow.select(e.cache.key), s = o.endpoints.next.select(e.cache.key), c = o.endpoints.start.select(e.cache.key);
118
+ return r || s || c;
119
+ },
120
+ getResponseWithId: (e) => {
121
+ if (!e)
122
+ return console.error("Please provide the cache key"), { error: { message: "Please provide the cache key", type: "argument_error" } };
123
+ const r = o.endpoints.flow.select(e), s = o.endpoints.next.select(e), c = o.endpoints.start.select(e);
124
+ return r || s || c;
125
+ }
126
+ }
127
+ };
128
+ }
129
+ export {
130
+ C as davinci
131
+ };
@@ -0,0 +1,46 @@
1
+ import { ErrorNode, ContinueNode, StartNode, SuccessNode } from '../types.js';
2
+ export declare function createClientStore(): import('@reduxjs/toolkit').EnhancedStore<{
3
+ config: {
4
+ endpoints: import('./wellknown.types.js').Endpoints;
5
+ clientId: string;
6
+ redirectUri: string;
7
+ responseType: string;
8
+ scope: string;
9
+ };
10
+ node: import('./node.types.js').ContinueNode | import('./node.types.js').ErrorNode | import('./node.types.js').FailureNode | import('./node.types.js').StartNode | import('./node.types.js').SuccessNode;
11
+ davinci: import('@reduxjs/toolkit/query').CombinedState<{
12
+ flow: import('@reduxjs/toolkit/query').MutationDefinition<any, import('@reduxjs/toolkit/query').BaseQueryFn<string | import('@reduxjs/toolkit/query').FetchArgs, unknown, import('@reduxjs/toolkit/query').FetchBaseQueryError, {}, import('@reduxjs/toolkit/query').FetchBaseQueryMeta>, never, unknown, "davinci">;
13
+ next: import('@reduxjs/toolkit/query').MutationDefinition<any, import('@reduxjs/toolkit/query').BaseQueryFn<string | import('@reduxjs/toolkit/query').FetchArgs, unknown, import('@reduxjs/toolkit/query').FetchBaseQueryError, {}, import('@reduxjs/toolkit/query').FetchBaseQueryMeta>, never, unknown, "davinci">;
14
+ start: import('@reduxjs/toolkit/query').MutationDefinition<void, import('@reduxjs/toolkit/query').BaseQueryFn<string | import('@reduxjs/toolkit/query').FetchArgs, unknown, import('@reduxjs/toolkit/query').FetchBaseQueryError, {}, import('@reduxjs/toolkit/query').FetchBaseQueryMeta>, never, unknown, "davinci">;
15
+ }, never, "davinci">;
16
+ wellknown: import('@reduxjs/toolkit/query').CombinedState<{
17
+ wellknown: import('@reduxjs/toolkit/query').QueryDefinition<string, import('@reduxjs/toolkit/query').BaseQueryFn<string | import('@reduxjs/toolkit/query').FetchArgs, unknown, import('@reduxjs/toolkit/query').FetchBaseQueryError, {}, import('@reduxjs/toolkit/query').FetchBaseQueryMeta>, never, import('./wellknown.types.js').WellknownResponse, "wellknown">;
18
+ }, never, "wellknown">;
19
+ }, import('@reduxjs/toolkit').UnknownAction, import('@reduxjs/toolkit').Tuple<[import('@reduxjs/toolkit').StoreEnhancer<{
20
+ dispatch: import('@reduxjs/toolkit').ThunkDispatch<{
21
+ config: {
22
+ endpoints: import('./wellknown.types.js').Endpoints;
23
+ clientId: string;
24
+ redirectUri: string;
25
+ responseType: string;
26
+ scope: string;
27
+ };
28
+ node: import('./node.types.js').ContinueNode | import('./node.types.js').ErrorNode | import('./node.types.js').FailureNode | import('./node.types.js').StartNode | import('./node.types.js').SuccessNode;
29
+ davinci: import('@reduxjs/toolkit/query').CombinedState<{
30
+ flow: import('@reduxjs/toolkit/query').MutationDefinition<any, import('@reduxjs/toolkit/query').BaseQueryFn<string | import('@reduxjs/toolkit/query').FetchArgs, unknown, import('@reduxjs/toolkit/query').FetchBaseQueryError, {}, import('@reduxjs/toolkit/query').FetchBaseQueryMeta>, never, unknown, "davinci">;
31
+ next: import('@reduxjs/toolkit/query').MutationDefinition<any, import('@reduxjs/toolkit/query').BaseQueryFn<string | import('@reduxjs/toolkit/query').FetchArgs, unknown, import('@reduxjs/toolkit/query').FetchBaseQueryError, {}, import('@reduxjs/toolkit/query').FetchBaseQueryMeta>, never, unknown, "davinci">;
32
+ start: import('@reduxjs/toolkit/query').MutationDefinition<void, import('@reduxjs/toolkit/query').BaseQueryFn<string | import('@reduxjs/toolkit/query').FetchArgs, unknown, import('@reduxjs/toolkit/query').FetchBaseQueryError, {}, import('@reduxjs/toolkit/query').FetchBaseQueryMeta>, never, unknown, "davinci">;
33
+ }, never, "davinci">;
34
+ wellknown: import('@reduxjs/toolkit/query').CombinedState<{
35
+ wellknown: import('@reduxjs/toolkit/query').QueryDefinition<string, import('@reduxjs/toolkit/query').BaseQueryFn<string | import('@reduxjs/toolkit/query').FetchArgs, unknown, import('@reduxjs/toolkit/query').FetchBaseQueryError, {}, import('@reduxjs/toolkit/query').FetchBaseQueryMeta>, never, import('./wellknown.types.js').WellknownResponse, "wellknown">;
36
+ }, never, "wellknown">;
37
+ }, undefined, import('@reduxjs/toolkit').UnknownAction>;
38
+ }>, import('@reduxjs/toolkit').StoreEnhancer]>>;
39
+ type ClientStore = typeof createClientStore;
40
+ export type RootState = ReturnType<ReturnType<ClientStore>['getState']>;
41
+ export interface RootStateWithNode<T extends ErrorNode | ContinueNode | StartNode | SuccessNode> extends RootState {
42
+ node: T;
43
+ }
44
+ export type AppDispatch = ReturnType<ReturnType<ClientStore>['dispatch']>;
45
+ export {};
46
+ //# sourceMappingURL=client.store.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.store.utils.d.ts","sourceRoot":"","sources":["../../src/lib/client.store.utils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG9E,wBAAgB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gDAWhC;AAED,KAAK,WAAW,GAAG,OAAO,iBAAiB,CAAC;AAE5C,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;AAExE,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,SAAS,GAAG,YAAY,GAAG,SAAS,GAAG,WAAW,CAC7F,SAAQ,SAAS;IACjB,IAAI,EAAE,CAAC,CAAC;CACT;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { configureStore as c } from "@reduxjs/toolkit";
2
+ import { configSlice as i } from "./config.slice.js";
3
+ import { nodeSlice as d } from "./node.slice.js";
4
+ import { davinciApi as r } from "./davinci.api.js";
5
+ import { wellknownApi as e } from "./wellknown.api.js";
6
+ function f() {
7
+ return c({
8
+ reducer: {
9
+ config: i.reducer,
10
+ node: d.reducer,
11
+ [r.reducerPath]: r.reducer,
12
+ [e.reducerPath]: e.reducer
13
+ },
14
+ middleware: (o) => o().concat(r.middleware).concat(e.middleware)
15
+ });
16
+ }
17
+ export {
18
+ f as createClientStore
19
+ };
@@ -0,0 +1,9 @@
1
+ import { GenericError } from './error.types';
2
+ import { ErrorNode, FailureNode, ContinueNode, StartNode, SuccessNode } from './node.types';
3
+ export type InitFlow = (() => Promise<{
4
+ error: GenericError;
5
+ }>) | (() => Promise<ContinueNode | ErrorNode | StartNode | SuccessNode | FailureNode>);
6
+ export type Updater = (value: string, index?: number) => {
7
+ error: GenericError;
8
+ } | null;
9
+ //# sourceMappingURL=client.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.types.d.ts","sourceRoot":"","sources":["../../src/lib/client.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE5F,MAAM,MAAM,QAAQ,GAChB,CAAC,MAAM,OAAO,CAAC;IAAE,KAAK,EAAE,YAAY,CAAA;CAAE,CAAC,CAAC,GACxC,CAAC,MAAM,OAAO,CAAC,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC;AAEtF,MAAM,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK;IAAE,KAAK,EAAE,YAAY,CAAA;CAAE,GAAG,IAAI,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @interface SingleValueCollector - Represents a request to collect a single value from the user, like email or password.
3
+ */
4
+ export type SingleValueCollectorTypes = 'TextCollector' | 'PasswordCollector' | 'SingleValueCollector';
5
+ export interface SingleValueCollectorWithValue<T extends SingleValueCollectorTypes> {
6
+ category: 'SingleValueCollector';
7
+ error: string | null;
8
+ type: T;
9
+ id: string;
10
+ name: string;
11
+ input: {
12
+ key: string;
13
+ value: string | number | boolean;
14
+ type: string;
15
+ };
16
+ output: {
17
+ key: string;
18
+ label: string;
19
+ type: string;
20
+ value: string;
21
+ };
22
+ }
23
+ export interface SingleValueCollectorNoValue<T extends SingleValueCollectorTypes> {
24
+ category: 'SingleValueCollector';
25
+ error: string | null;
26
+ type: T;
27
+ id: string;
28
+ name: string;
29
+ input: {
30
+ key: string;
31
+ value: string | number | boolean;
32
+ type: string;
33
+ };
34
+ output: {
35
+ key: string;
36
+ label: string;
37
+ type: string;
38
+ };
39
+ }
40
+ export type SingleValueCollectors = SingleValueCollectorWithValue<'SingleValueCollector'> | SingleValueCollectorWithValue<'TextCollector'> | SingleValueCollectorNoValue<'PasswordCollector'>;
41
+ export type SingleValueCollector<T extends SingleValueCollectorTypes> = SingleValueCollectorWithValue<T> | SingleValueCollectorNoValue<T>;
42
+ /**
43
+ * @interface ActionCollector - Represents a user option to perform an action, like submitting a form or choosing another flow.
44
+ */
45
+ export type ActionCollectorTypes = 'FlowCollector' | 'SubmitCollector' | 'SocialLoginCollector' | 'ActionCollector';
46
+ export interface ActionCollectorNoUrl<T extends ActionCollectorTypes> {
47
+ category: 'ActionCollector';
48
+ error: string | null;
49
+ type: T;
50
+ id: string;
51
+ name: string;
52
+ output: {
53
+ key: string;
54
+ label: string;
55
+ type: string;
56
+ };
57
+ }
58
+ export interface ActionCollectorWithUrl<T extends ActionCollectorTypes> {
59
+ category: 'ActionCollector';
60
+ error: string | null;
61
+ type: T;
62
+ id: string;
63
+ name: string;
64
+ output: {
65
+ key: string;
66
+ label: string;
67
+ type: string;
68
+ url?: string | null;
69
+ };
70
+ }
71
+ export type ActionCollector<T extends ActionCollectorTypes> = ActionCollectorNoUrl<T> | ActionCollectorWithUrl<T>;
72
+ export type ActionCollectors = ActionCollectorWithUrl<'SocialLoginCollector'> | ActionCollectorNoUrl<'ActionCollector'> | ActionCollectorNoUrl<'FlowCollector'> | ActionCollectorNoUrl<'SubmitCollector'>;
73
+ export type FlowCollector = ActionCollectorNoUrl<'FlowCollector'>;
74
+ export type PasswordCollector = SingleValueCollectorNoValue<'PasswordCollector'>;
75
+ export type TextCollector = SingleValueCollectorWithValue<'TextCollector'>;
76
+ export type SocialLoginCollector = ActionCollectorWithUrl<'SocialLoginCollector'>;
77
+ export type SubmitCollector = ActionCollectorNoUrl<'SubmitCollector'>;
78
+ //# sourceMappingURL=collector.types.d.ts.map
@@ -0,0 +1 @@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B,CAAC,eAAe,CAAC,GACrC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;AAE5C,MAAM,MAAM,aAAa,GAAG,oBAAoB,CAAC,eAAe,CAAC,CAAC;AAClE,MAAM,MAAM,iBAAiB,GAAG,2BAA2B,CAAC,mBAAmB,CAAC,CAAC;AACjF,MAAM,MAAM,aAAa,GAAG,6BAA6B,CAAC,eAAe,CAAC,CAAC;AAC3E,MAAM,MAAM,oBAAoB,GAAG,sBAAsB,CAAC,sBAAsB,CAAC,CAAC;AAClF,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { ActionCollectors, ActionCollectorTypes, SingleValueCollectors, SingleValueCollectorTypes } from './collector.types';
2
+ import { DaVinciField } from './davinci.types';
3
+ /**
4
+ * @function returnActionCollector - Creates an ActionCollector object based on the provided field and index.
5
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
6
+ * @param {number} idx - The index to be used in the id of the ActionCollector.
7
+ * @param {ActionCollectorTypes} [collectorType] - Optional type of the ActionCollector.
8
+ * @returns {ActionCollector} The constructed ActionCollector object.
9
+ */
10
+ export declare function returnActionCollector<CollectorType extends ActionCollectorTypes>(field: DaVinciField, idx: number, collectorType: CollectorType): ActionCollectors;
11
+ /**
12
+ * @function returnFlowCollector - Returns a flow collector object
13
+ * @param {DaVinciField} field - The field representing the flow button
14
+ * @param {number} idx - The index of the field in the form
15
+ * @returns {FlowCollector} - The flow collector object
16
+ */
17
+ export declare function returnFlowCollector(field: DaVinciField, idx: number): ActionCollectors;
18
+ /**
19
+ * @function returnSocialLoginCollector - Returns a social login collector object
20
+ * @param {DaVinciField} field - The field representing the social login button
21
+ * @param {number} idx - The index of the field in the form
22
+ * @returns {SocialLoginCollector} - The social login collector object
23
+ */
24
+ export declare function returnSocialLoginCollector(field: DaVinciField, idx: number): ActionCollectors;
25
+ /**
26
+ * @function returnSubmitCollector - Returns a submit collector object
27
+ * @param {DaVinciField} field - The field representing the submit button
28
+ * @param {number} idx - The index of the field in the form
29
+ * @returns {ActionCollector} - The submit collector object
30
+ */
31
+ export declare function returnSubmitCollector(field: DaVinciField, idx: number): ActionCollectors;
32
+ /**
33
+ * @function returnSingleValueCollector - Creates a SingleValueCollector object based on the provided field, index, and optional collector type.
34
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
35
+ * @param {number} idx - The index to be used in the id of the SingleValueCollector.
36
+ * @param {SingleValueCollectorTypes} [collectorType] - Optional type of the SingleValueCollector.
37
+ * @returns {SingleValueCollector} The constructed SingleValueCollector object.
38
+ */
39
+ export declare function returnSingleValueCollector<CollectorType extends SingleValueCollectorTypes = 'SingleValueCollector'>(field: DaVinciField, idx: number, collectorType: CollectorType): SingleValueCollectors;
40
+ /**
41
+ * @function returnPasswordCollector - Creates a PasswordCollector object based on the provided field and index.
42
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
43
+ * @param {number} idx - The index to be used in the id of the PasswordCollector.
44
+ * @returns {PasswordCollector} The constructed PasswordCollector object.
45
+ */
46
+ export declare function returnPasswordCollector(field: DaVinciField, idx: number): SingleValueCollectors;
47
+ /**
48
+ * @function returnTextCollector - Creates a TextCollector object based on the provided field and index.
49
+ * @param {DaVinciField} field - The field object containing key, label, type, and links.
50
+ * @param {number} idx - The index to be used in the id of the TextCollector.
51
+ * @returns {TextCollector} The constructed TextCollector object.
52
+ */
53
+ export declare function returnTextCollector(field: DaVinciField, idx: number): SingleValueCollectors;
54
+ //# sourceMappingURL=collector.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collector.utils.d.ts","sourceRoot":"","sources":["../../src/lib/collector.utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,EAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,SAAS,oBAAoB,EAC9E,KAAK,EAAE,YAAY,EACnB,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,aAAa,GAC3B,gBAAgB,CAwClB;AAED;;;;;GAKG;AAEH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,oBAEnE;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,oBAE1E;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,oBAErE;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,aAAa,SAAS,yBAAyB,GAAG,sBAAsB,EACxE,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,GAAG,qBAAqB,CAkDvF;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,yBAEvE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,yBAEnE"}
@@ -0,0 +1,88 @@
1
+ function r(e, o, n) {
2
+ let t = "";
3
+ return "key" in e || (t = `${t}Key is not found in the field object. `), "label" in e || (t = `${t}Label is not found in the field object. `), "type" in e || (t = `${t}Type is not found in the field object. `), n === "SocialLoginCollector" ? {
4
+ category: "ActionCollector",
5
+ error: t || null,
6
+ type: n,
7
+ id: `${e.key}-${o}`,
8
+ name: e.key,
9
+ output: {
10
+ key: e.key,
11
+ label: e.label,
12
+ type: e.type,
13
+ url: e.links?.authenticate?.href || null
14
+ }
15
+ } : {
16
+ category: "ActionCollector",
17
+ error: t || null,
18
+ type: n || "ActionCollector",
19
+ id: `${e.key}-${o}`,
20
+ name: e.key,
21
+ output: {
22
+ key: e.key,
23
+ label: e.label,
24
+ type: e.type
25
+ }
26
+ };
27
+ }
28
+ function u(e, o) {
29
+ return r(e, o, "FlowCollector");
30
+ }
31
+ function y(e, o) {
32
+ return r(e, o, "SocialLoginCollector");
33
+ }
34
+ function c(e, o) {
35
+ return r(e, o, "SubmitCollector");
36
+ }
37
+ function l(e, o, n) {
38
+ let t = "";
39
+ return "key" in e || (t = `${t}Key is not found in the field object. `), "label" in e || (t = `${t}Label is not found in the field object. `), "type" in e || (t = `${t}Type is not found in the field object. `), n === "PasswordCollector" ? {
40
+ category: "SingleValueCollector",
41
+ error: t || null,
42
+ type: n,
43
+ id: `${e.key}-${o}`,
44
+ name: e.key,
45
+ input: {
46
+ key: e.key,
47
+ value: "",
48
+ type: e.type
49
+ },
50
+ output: {
51
+ key: e.key,
52
+ label: e.label,
53
+ type: e.type
54
+ }
55
+ } : {
56
+ category: "SingleValueCollector",
57
+ error: t || null,
58
+ type: n || "SingleValueCollector",
59
+ id: `${e.key}-${o}`,
60
+ name: e.key,
61
+ input: {
62
+ key: e.key,
63
+ value: "",
64
+ type: e.type
65
+ },
66
+ output: {
67
+ key: e.key,
68
+ label: e.label,
69
+ type: e.type,
70
+ value: ""
71
+ }
72
+ };
73
+ }
74
+ function a(e, o) {
75
+ return l(e, o, "PasswordCollector");
76
+ }
77
+ function i(e, o) {
78
+ return l(e, o, "TextCollector");
79
+ }
80
+ export {
81
+ r as returnActionCollector,
82
+ u as returnFlowCollector,
83
+ a as returnPasswordCollector,
84
+ l as returnSingleValueCollector,
85
+ y as returnSocialLoginCollector,
86
+ c as returnSubmitCollector,
87
+ i as returnTextCollector
88
+ };
@@ -0,0 +1,35 @@
1
+ import { PayloadAction } from '@reduxjs/toolkit';
2
+ import { InternalDaVinciConfig } from './config.types.js';
3
+ import { Endpoints } from './wellknown.types.js';
4
+ /**
5
+ * @const configSlice - Define the configuration slice for Redux state management
6
+ * @see https://redux-toolkit.js.org/api/createslice
7
+ */
8
+ export declare const configSlice: import('@reduxjs/toolkit').Slice<{
9
+ endpoints: Endpoints;
10
+ clientId: string;
11
+ redirectUri: string;
12
+ responseType: string;
13
+ scope: string;
14
+ }, {
15
+ /**
16
+ * @method set - Set the configuration for the DaVinci client
17
+ * @param {Object} state - The current state of the slice
18
+ * @param {PayloadAction<InternalDaVinciConfig>} action - The action to be dispatched
19
+ * @returns {void}
20
+ */
21
+ set(state: import('immer').WritableDraft<{
22
+ endpoints: Endpoints;
23
+ clientId: string;
24
+ redirectUri: string;
25
+ responseType: string;
26
+ scope: string;
27
+ }>, action: PayloadAction<InternalDaVinciConfig>): void;
28
+ }, "config", "config", import('@reduxjs/toolkit').SliceSelectors<{
29
+ endpoints: Endpoints;
30
+ clientId: string;
31
+ redirectUri: string;
32
+ responseType: string;
33
+ scope: string;
34
+ }>>;
35
+ //# sourceMappingURL=config.slice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.slice.d.ts","sourceRoot":"","sources":["../../src/lib/config.slice.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEnE;;GAEG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAcjD;;;GAGG;AACH,eAAO,MAAM,WAAW;eAXL,SAAS;;;;;;IAgBxB;;;;;OAKG;;mBArBY,SAAS;;;;;gBAsBL,aAAa,CAAC,qBAAqB,CAAC;;eAtBxC,SAAS;;;;;GAkD1B,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { createSlice as d } from "@reduxjs/toolkit";
2
+ const c = {
3
+ endpoints: {},
4
+ clientId: "",
5
+ redirectUri: "",
6
+ responseType: "",
7
+ scope: ""
8
+ }, t = d({
9
+ name: "config",
10
+ initialState: c,
11
+ reducerPath: "config",
12
+ reducers: {
13
+ /**
14
+ * @method set - Set the configuration for the DaVinci client
15
+ * @param {Object} state - The current state of the slice
16
+ * @param {PayloadAction<InternalDaVinciConfig>} action - The action to be dispatched
17
+ * @returns {void}
18
+ */
19
+ set(o, e) {
20
+ o.clientId = e.payload.clientId || "", o.redirectUri = e.payload.redirectUri || `${location.origin}/handle-redirect`, "responseType" in e.payload && e.payload.responseType ? o.responseType = e.payload.responseType : o.responseType = "code", o.scope = e.payload.scope || "openid";
21
+ const {
22
+ authorization_endpoint: n,
23
+ issuer: i,
24
+ introspection_endpoint: p,
25
+ token_endpoint: r,
26
+ userinfo_endpoint: s
27
+ } = e.payload.wellknownResponse;
28
+ o.endpoints = {
29
+ authorize: n,
30
+ issuer: i,
31
+ introspection: p,
32
+ tokens: r,
33
+ userinfo: s
34
+ };
35
+ }
36
+ }
37
+ });
38
+ export {
39
+ t as configSlice
40
+ };
@@ -0,0 +1,9 @@
1
+ import { AsyncConfigOptions } from '@forgerock/javascript-sdk/src/config/interfaces';
2
+ import { WellknownResponse } from './wellknown.types';
3
+ export interface DaVinciConfig extends AsyncConfigOptions {
4
+ responseType?: string;
5
+ }
6
+ export interface InternalDaVinciConfig extends DaVinciConfig {
7
+ wellknownResponse: WellknownResponse;
8
+ }
9
+ //# sourceMappingURL=config.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.types.d.ts","sourceRoot":"","sources":["../../src/lib/config.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAC;AAC1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,WAAW,aAAc,SAAQ,kBAAkB;IACvD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC1D,iBAAiB,EAAE,iBAAiB,CAAC;CACtC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @const davinciApi - Define the DaVinci API for Redux state management
3
+ * @see https://redux-toolkit.js.org/rtk-query/overview
4
+ */
5
+ export declare const davinciApi: import('@reduxjs/toolkit/query').Api<import('@reduxjs/toolkit/query').BaseQueryFn<string | import('@reduxjs/toolkit/query').FetchArgs, unknown, import('@reduxjs/toolkit/query').FetchBaseQueryError, {}, import('@reduxjs/toolkit/query').FetchBaseQueryMeta>, {
6
+ /**
7
+ * @method flow - method for initiating a new flow with the DaVinci API
8
+ */
9
+ flow: import('@reduxjs/toolkit/query').MutationDefinition<any, import('@reduxjs/toolkit/query').BaseQueryFn<string | import('@reduxjs/toolkit/query').FetchArgs, unknown, import('@reduxjs/toolkit/query').FetchBaseQueryError, {}, import('@reduxjs/toolkit/query').FetchBaseQueryMeta>, never, unknown, "davinci">;
10
+ /**
11
+ * @method next - method for initiating the next node in the current flow
12
+ */
13
+ next: import('@reduxjs/toolkit/query').MutationDefinition<any, import('@reduxjs/toolkit/query').BaseQueryFn<string | import('@reduxjs/toolkit/query').FetchArgs, unknown, import('@reduxjs/toolkit/query').FetchBaseQueryError, {}, import('@reduxjs/toolkit/query').FetchBaseQueryMeta>, never, unknown, "davinci">;
14
+ /**
15
+ * @method start - method for initiating a DaVinci flow
16
+ * @param - needs no arguments, but need to declare types to make it explicit
17
+ */
18
+ start: import('@reduxjs/toolkit/query').MutationDefinition<void, import('@reduxjs/toolkit/query').BaseQueryFn<string | import('@reduxjs/toolkit/query').FetchArgs, unknown, import('@reduxjs/toolkit/query').FetchBaseQueryError, {}, import('@reduxjs/toolkit/query').FetchBaseQueryMeta>, never, unknown, "davinci">;
19
+ }, "davinci", never, typeof import('@reduxjs/toolkit/query').coreModuleName>;
20
+ //# sourceMappingURL=davinci.api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"davinci.api.d.ts","sourceRoot":"","sources":["../../src/lib/davinci.api.ts"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,eAAO,MAAM,UAAU;IAWnB;;OAEG;;IAsEH;;OAEG;;IA2EH;;;OAGG;;4EAwFL,CAAC"}