@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.
- package/README.md +354 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/lib/authorize.utils.d.ts +22 -0
- package/dist/lib/authorize.utils.d.ts.map +1 -0
- package/dist/lib/authorize.utils.js +23 -0
- package/dist/lib/client.store.d.ts +149 -0
- package/dist/lib/client.store.d.ts.map +1 -0
- package/dist/lib/client.store.js +131 -0
- package/dist/lib/client.store.utils.d.ts +46 -0
- package/dist/lib/client.store.utils.d.ts.map +1 -0
- package/dist/lib/client.store.utils.js +19 -0
- package/dist/lib/client.types.d.ts +9 -0
- package/dist/lib/client.types.d.ts.map +1 -0
- package/dist/lib/collector.types.d.ts +78 -0
- package/dist/lib/collector.types.d.ts.map +1 -0
- package/dist/lib/collector.utils.d.ts +54 -0
- package/dist/lib/collector.utils.d.ts.map +1 -0
- package/dist/lib/collector.utils.js +88 -0
- package/dist/lib/config.slice.d.ts +35 -0
- package/dist/lib/config.slice.d.ts.map +1 -0
- package/dist/lib/config.slice.js +40 -0
- package/dist/lib/config.types.d.ts +9 -0
- package/dist/lib/config.types.d.ts.map +1 -0
- package/dist/lib/davinci.api.d.ts +20 -0
- package/dist/lib/davinci.api.d.ts.map +1 -0
- package/dist/lib/davinci.api.js +172 -0
- package/dist/lib/davinci.types.d.ts +185 -0
- package/dist/lib/davinci.types.d.ts.map +1 -0
- package/dist/lib/davinci.utils.d.ts +18 -0
- package/dist/lib/davinci.utils.d.ts.map +1 -0
- package/dist/lib/davinci.utils.js +102 -0
- package/dist/lib/error.types.d.ts +6 -0
- package/dist/lib/error.types.d.ts.map +1 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/node.reducer.d.ts +22 -0
- package/dist/lib/node.reducer.d.ts.map +1 -0
- package/dist/lib/node.reducer.js +31 -0
- package/dist/lib/node.slice.d.ts +134 -0
- package/dist/lib/node.slice.d.ts.map +1 -0
- package/dist/lib/node.slice.js +160 -0
- package/dist/lib/node.types.d.ts +109 -0
- package/dist/lib/node.types.d.ts.map +1 -0
- package/dist/lib/wellknown.api.d.ts +5 -0
- package/dist/lib/wellknown.api.d.ts.map +1 -0
- package/dist/lib/wellknown.api.js +15 -0
- package/dist/lib/wellknown.types.d.ts +38 -0
- package/dist/lib/wellknown.types.d.ts.map +1 -0
- package/dist/types.d.ts +23 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { createApi as p, fetchBaseQuery as y } from "@reduxjs/toolkit/query";
|
|
2
|
+
import { createAuthorizeUrl as l } from "./authorize.utils.js";
|
|
3
|
+
import { transformActionRequest as f, handleResponse as u, transformSubmitRequest as h } from "./davinci.utils.js";
|
|
4
|
+
const w = p({
|
|
5
|
+
reducerPath: "davinci",
|
|
6
|
+
baseQuery: y({
|
|
7
|
+
prepareHeaders: (a) => (a.set("Accept", "application/json"), a.set("x-requested-with", "ping-sdk"), a.set("x-requested-platform", "javascript"), a)
|
|
8
|
+
}),
|
|
9
|
+
endpoints: (a) => ({
|
|
10
|
+
/**
|
|
11
|
+
* @method flow - method for initiating a new flow with the DaVinci API
|
|
12
|
+
*/
|
|
13
|
+
flow: a.mutation({
|
|
14
|
+
/**
|
|
15
|
+
* @method queryFn - This is just a wrapper around the fetch call
|
|
16
|
+
*/
|
|
17
|
+
async queryFn(i, t, r, o) {
|
|
18
|
+
const e = t.getState(), n = e.node.server._links, s = f(e.node, i.action);
|
|
19
|
+
let c = "";
|
|
20
|
+
return n && "next" in n && (c = n.next.href || ""), await o({
|
|
21
|
+
// TODO: If we don't have a `next.href`, we should handle this better
|
|
22
|
+
url: c,
|
|
23
|
+
credentials: "include",
|
|
24
|
+
method: "POST",
|
|
25
|
+
headers: {
|
|
26
|
+
"Content-Type": "application/json",
|
|
27
|
+
interactionId: e.node.server.interactionId,
|
|
28
|
+
interactionToken: e.node.server.interactionToken
|
|
29
|
+
},
|
|
30
|
+
body: JSON.stringify(s)
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* @method onQueryStarted - method for handling the response from the DaVinci API
|
|
35
|
+
*
|
|
36
|
+
* The method name below is a bit misleading. It is not just
|
|
37
|
+
* called when the query is started, but throughout the lifecycle of
|
|
38
|
+
* the API, including when the query is fulfilled. This is because
|
|
39
|
+
* the query is started, and then the response is awaited, and then
|
|
40
|
+
* the response is processed.
|
|
41
|
+
*
|
|
42
|
+
* NOTE: The below is repeated for each endpoint, which is not "DRY",
|
|
43
|
+
* but doing it inline reduces the typing complexity as all the
|
|
44
|
+
* parameters are pre-typed from the library.
|
|
45
|
+
*/
|
|
46
|
+
async onQueryStarted(i, t) {
|
|
47
|
+
let r;
|
|
48
|
+
try {
|
|
49
|
+
r = (await t.queryFulfilled).meta?.response;
|
|
50
|
+
} catch (e) {
|
|
51
|
+
r = e.meta?.response;
|
|
52
|
+
}
|
|
53
|
+
const o = t.getCacheEntry();
|
|
54
|
+
u(o, t.dispatch, r?.status || 0);
|
|
55
|
+
}
|
|
56
|
+
}),
|
|
57
|
+
/**
|
|
58
|
+
* @method next - method for initiating the next node in the current flow
|
|
59
|
+
*/
|
|
60
|
+
next: a.mutation({
|
|
61
|
+
/**
|
|
62
|
+
* @method queryFn - This is just a wrapper around the fetch call
|
|
63
|
+
*/
|
|
64
|
+
async queryFn(i, t, r, o) {
|
|
65
|
+
const e = t.getState(), n = e.node.server._links;
|
|
66
|
+
let s, c = "";
|
|
67
|
+
return n && "next" in n && (c = n.next.href || ""), i ? s = i : s = h(e.node), await o({
|
|
68
|
+
url: c,
|
|
69
|
+
credentials: "include",
|
|
70
|
+
method: "POST",
|
|
71
|
+
headers: {
|
|
72
|
+
"Content-Type": "application/json",
|
|
73
|
+
interactionId: e.node.server.interactionId,
|
|
74
|
+
interactionToken: e.node.server.interactionToken
|
|
75
|
+
},
|
|
76
|
+
body: JSON.stringify(s)
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
/**
|
|
80
|
+
* @method onQueryStarted - method for handling the response from the DaVinci API
|
|
81
|
+
*
|
|
82
|
+
* The method name below is a bit misleading. It is not just
|
|
83
|
+
* called when the query is started, but throughout the lifecycle of
|
|
84
|
+
* the API, including when the query is fulfilled. This is because
|
|
85
|
+
* the query is started, and then the response is awaited, and then
|
|
86
|
+
* the response is processed.
|
|
87
|
+
*
|
|
88
|
+
* NOTE: The below is repeated for each endpoint, which is not "DRY",
|
|
89
|
+
* but doing it inline reduces the typing complexity as all the
|
|
90
|
+
* parameters are pre-typed from the library.
|
|
91
|
+
*/
|
|
92
|
+
async onQueryStarted(i, t) {
|
|
93
|
+
let r;
|
|
94
|
+
try {
|
|
95
|
+
r = (await t.queryFulfilled).meta?.response;
|
|
96
|
+
} catch (e) {
|
|
97
|
+
r = e.meta?.response;
|
|
98
|
+
}
|
|
99
|
+
const o = t.getCacheEntry();
|
|
100
|
+
u(o, t.dispatch, r?.status || 0);
|
|
101
|
+
}
|
|
102
|
+
}),
|
|
103
|
+
/**
|
|
104
|
+
* @method start - method for initiating a DaVinci flow
|
|
105
|
+
* @param - needs no arguments, but need to declare types to make it explicit
|
|
106
|
+
*/
|
|
107
|
+
start: a.mutation({
|
|
108
|
+
/**
|
|
109
|
+
* @method queryFn - This is just a wrapper around the fetch call
|
|
110
|
+
*/
|
|
111
|
+
async queryFn(i, t, r, o) {
|
|
112
|
+
const e = t.getState();
|
|
113
|
+
if (!e)
|
|
114
|
+
return {
|
|
115
|
+
error: {
|
|
116
|
+
status: 400,
|
|
117
|
+
data: "Store must be initialized before use"
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const n = e.config.endpoints.authorize;
|
|
121
|
+
if (!n)
|
|
122
|
+
return { error: { status: 400, data: "authorizeEndpoint URL must be set" } };
|
|
123
|
+
try {
|
|
124
|
+
const s = await l(n, {
|
|
125
|
+
clientId: e?.config?.clientId,
|
|
126
|
+
login: "redirect",
|
|
127
|
+
// TODO: improve this in SDK to be more semantic
|
|
128
|
+
redirectUri: e?.config?.redirectUri,
|
|
129
|
+
responseType: e?.config?.responseType,
|
|
130
|
+
scope: e?.config?.scope
|
|
131
|
+
});
|
|
132
|
+
return await o({
|
|
133
|
+
url: s,
|
|
134
|
+
credentials: "include",
|
|
135
|
+
method: "GET",
|
|
136
|
+
headers: {
|
|
137
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
} catch (s) {
|
|
141
|
+
return s instanceof Error ? { error: { status: 400, data: s.message } } : { error: { status: 400, data: "An unknown error occurred" } };
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
/**
|
|
145
|
+
* @method onQueryStarted - method for handling the response from the DaVinci API
|
|
146
|
+
*
|
|
147
|
+
* The method name below is a bit misleading. It is not just
|
|
148
|
+
* called when the query is started, but throughout the lifecycle of
|
|
149
|
+
* the API, including when the query is fulfilled. This is because
|
|
150
|
+
* the query is started, and then the response is awaited, and then
|
|
151
|
+
* the response is processed.
|
|
152
|
+
*
|
|
153
|
+
* NOTE: The below is repeated for each endpoint, which is not "DRY",
|
|
154
|
+
* but doing it inline reduces the typing complexity as all the
|
|
155
|
+
* parameters are pre-typed from the library.
|
|
156
|
+
*/
|
|
157
|
+
async onQueryStarted(i, t) {
|
|
158
|
+
let r;
|
|
159
|
+
try {
|
|
160
|
+
r = (await t.queryFulfilled).meta?.response;
|
|
161
|
+
} catch (e) {
|
|
162
|
+
r = e.meta?.response;
|
|
163
|
+
}
|
|
164
|
+
const o = t.getCacheEntry();
|
|
165
|
+
u(o, t.dispatch, r?.status || 0);
|
|
166
|
+
}
|
|
167
|
+
})
|
|
168
|
+
})
|
|
169
|
+
});
|
|
170
|
+
export {
|
|
171
|
+
w as davinciApi
|
|
172
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { FetchBaseQueryError, FetchBaseQueryMeta, MutationResultSelectorResult } from '@reduxjs/toolkit/query';
|
|
2
|
+
export interface DaVinciRequest {
|
|
3
|
+
id: string;
|
|
4
|
+
eventName: string;
|
|
5
|
+
interactionId: string;
|
|
6
|
+
parameters: {
|
|
7
|
+
eventType: 'submit' | 'action';
|
|
8
|
+
data: {
|
|
9
|
+
actionKey: string;
|
|
10
|
+
formData?: Record<string, unknown>;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Base Response for DaVinci API
|
|
16
|
+
*/
|
|
17
|
+
export interface DaVinciBaseResponse {
|
|
18
|
+
capabilityName?: string;
|
|
19
|
+
companyId?: string;
|
|
20
|
+
connectionId?: string;
|
|
21
|
+
connectorId?: string;
|
|
22
|
+
id?: string;
|
|
23
|
+
interactionId?: string;
|
|
24
|
+
interactionToken?: string;
|
|
25
|
+
isResponseCompatibleWithMobileAndWebSdks?: boolean;
|
|
26
|
+
status?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface Links {
|
|
29
|
+
[key: string]: {
|
|
30
|
+
href?: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Next or Continuation Response DaVinci API
|
|
35
|
+
*/
|
|
36
|
+
export interface DaVinciField {
|
|
37
|
+
type: string;
|
|
38
|
+
key: string;
|
|
39
|
+
label: string;
|
|
40
|
+
links?: Links;
|
|
41
|
+
}
|
|
42
|
+
export interface DaVinciNextResponse extends DaVinciBaseResponse {
|
|
43
|
+
_links?: Links;
|
|
44
|
+
eventName?: string;
|
|
45
|
+
formData?: {
|
|
46
|
+
value?: {
|
|
47
|
+
[key: string]: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
form?: {
|
|
51
|
+
name?: string;
|
|
52
|
+
description?: string;
|
|
53
|
+
components?: {
|
|
54
|
+
fields?: DaVinciField[];
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Error Response from DaVinci API
|
|
60
|
+
*/
|
|
61
|
+
interface NestedErrorDetails {
|
|
62
|
+
code?: string;
|
|
63
|
+
target?: string;
|
|
64
|
+
message?: string;
|
|
65
|
+
innerError?: {
|
|
66
|
+
history?: string;
|
|
67
|
+
unsatisfiedRequirements?: string[];
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface ErrorDetail {
|
|
71
|
+
message: string;
|
|
72
|
+
rawResponse?: {
|
|
73
|
+
_embedded?: {
|
|
74
|
+
users?: Array<unknown>;
|
|
75
|
+
};
|
|
76
|
+
code?: string;
|
|
77
|
+
count?: number;
|
|
78
|
+
details?: NestedErrorDetails[];
|
|
79
|
+
id?: string;
|
|
80
|
+
message?: string;
|
|
81
|
+
size?: number;
|
|
82
|
+
userFilter?: string;
|
|
83
|
+
[key: string]: unknown;
|
|
84
|
+
};
|
|
85
|
+
statusCode?: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The original DaVinci response is appended to the cache, so we are going
|
|
89
|
+
* to pull it and dispatch the appropriate action based on the response.
|
|
90
|
+
*/
|
|
91
|
+
export type DaVinciCacheEntry = {
|
|
92
|
+
data?: DaVinciBaseResponse;
|
|
93
|
+
error?: {
|
|
94
|
+
data: DaVinciBaseResponse;
|
|
95
|
+
status: number;
|
|
96
|
+
};
|
|
97
|
+
} & {
|
|
98
|
+
data?: any;
|
|
99
|
+
error?: any;
|
|
100
|
+
} & MutationResultSelectorResult<any>;
|
|
101
|
+
export interface DavinciErrorResponse extends DaVinciBaseResponse {
|
|
102
|
+
code: string | number;
|
|
103
|
+
message: string;
|
|
104
|
+
cause?: string | null;
|
|
105
|
+
details?: ErrorDetail[];
|
|
106
|
+
doNotSendToOE?: boolean;
|
|
107
|
+
error?: {
|
|
108
|
+
code?: string;
|
|
109
|
+
message?: string;
|
|
110
|
+
};
|
|
111
|
+
errorCategory?: string;
|
|
112
|
+
errorMessage?: string;
|
|
113
|
+
expected?: boolean;
|
|
114
|
+
isErrorCustomized?: boolean;
|
|
115
|
+
httpResponseCode: number;
|
|
116
|
+
metricAttributes?: {
|
|
117
|
+
[key: string]: unknown;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export interface DaVinciFailureResponse extends DaVinciBaseResponse {
|
|
121
|
+
error?: {
|
|
122
|
+
code?: string;
|
|
123
|
+
message?: string;
|
|
124
|
+
[key: string]: unknown;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Success Response DaVinci API
|
|
129
|
+
*/
|
|
130
|
+
export interface OAuthDetails {
|
|
131
|
+
code?: string;
|
|
132
|
+
state?: string;
|
|
133
|
+
[key: string]: unknown;
|
|
134
|
+
}
|
|
135
|
+
export interface DaVinciSuccessResponse extends DaVinciBaseResponse {
|
|
136
|
+
environment: {
|
|
137
|
+
id: string;
|
|
138
|
+
[key: string]: unknown;
|
|
139
|
+
};
|
|
140
|
+
status: string;
|
|
141
|
+
success: true;
|
|
142
|
+
_links?: Links;
|
|
143
|
+
authorizeResponse?: OAuthDetails;
|
|
144
|
+
resetCookie?: boolean;
|
|
145
|
+
session?: {
|
|
146
|
+
id?: string;
|
|
147
|
+
[key: string]: unknown;
|
|
148
|
+
};
|
|
149
|
+
sessionToken?: string;
|
|
150
|
+
sessionTokenMaxAge?: number;
|
|
151
|
+
subFlowSettings?: {
|
|
152
|
+
cssLinks?: unknown[];
|
|
153
|
+
cssUrl?: unknown;
|
|
154
|
+
jsLinks?: unknown[];
|
|
155
|
+
loadingScreenSettings?: unknown;
|
|
156
|
+
reactSkUrl?: unknown;
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Redux Types
|
|
161
|
+
*/
|
|
162
|
+
export interface DaVinciAction {
|
|
163
|
+
action: string;
|
|
164
|
+
}
|
|
165
|
+
export interface DaVinciErrorCacheEntry<T> {
|
|
166
|
+
error: {
|
|
167
|
+
data: T;
|
|
168
|
+
};
|
|
169
|
+
requestId: string;
|
|
170
|
+
status: 'fulfilled' | 'pending' | 'rejected';
|
|
171
|
+
endpointName: 'next' | 'flow' | 'start';
|
|
172
|
+
startedTimeStamp: number;
|
|
173
|
+
fulfilledTimeStamp: number;
|
|
174
|
+
isUninitialized: boolean;
|
|
175
|
+
isLoading: boolean;
|
|
176
|
+
isSuccess: boolean;
|
|
177
|
+
isError: boolean;
|
|
178
|
+
}
|
|
179
|
+
export interface ThrownQueryError {
|
|
180
|
+
error: FetchBaseQueryError;
|
|
181
|
+
isHandledError: boolean;
|
|
182
|
+
meta: FetchBaseQueryMeta;
|
|
183
|
+
}
|
|
184
|
+
export {};
|
|
185
|
+
//# sourceMappingURL=davinci.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"davinci.types.d.ts","sourceRoot":"","sources":["../../src/lib/davinci.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,4BAA4B,EAC7B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE;QACV,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAC;QAC/B,IAAI,EAAE;YACJ,SAAS,EAAE,MAAM,CAAC;YAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;SACpC,CAAC;KACH,CAAC;CACH;AAED;;GAEG;AAEH,MAAM,WAAW,mBAAmB;IAElC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAA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AW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,KAAK,EAAE;QACL,IAAI,EAAE,CAAC,CAAC;KACT,CAAC;IACF,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC;IAC7C,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IACxC,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,mBAAmB,CAAC;IAC3B,cAAc,EAAE,OAAO,CAAC;IACxB,IAAI,EAAE,kBAAkB,CAAC;CAC1B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Dispatch } from '@reduxjs/toolkit';
|
|
2
|
+
import { DaVinciCacheEntry, DaVinciRequest } from './davinci.types';
|
|
3
|
+
import { ContinueNode } from './node.types';
|
|
4
|
+
/**
|
|
5
|
+
* @function transformSubmitRequest - Transforms a NextNode into a DaVinciRequest for form submissions
|
|
6
|
+
* @param {ContinueNode} node - The node to transform into a DaVinciRequest
|
|
7
|
+
* @returns {DaVinciRequest} - The transformed request object
|
|
8
|
+
*/
|
|
9
|
+
export declare function transformSubmitRequest(node: ContinueNode): DaVinciRequest;
|
|
10
|
+
/**
|
|
11
|
+
* @function transformActionRequest - Transforms a NextNode into a DaVinciRequest for action requests
|
|
12
|
+
* @param {ContinueNode} node - The node to transform into a DaVinciRequest
|
|
13
|
+
* @param {string} action - The action to transform into a DaVinciRequest
|
|
14
|
+
* @returns {DaVinciRequest} - The transformed request object
|
|
15
|
+
*/
|
|
16
|
+
export declare function transformActionRequest(node: ContinueNode, action: string): DaVinciRequest;
|
|
17
|
+
export declare function handleResponse(cacheEntry: DaVinciCacheEntry, dispatch: Dispatch, status: number): void;
|
|
18
|
+
//# sourceMappingURL=davinci.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"davinci.utils.d.ts","sourceRoot":"","sources":["../../src/lib/davinci.utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD,OAAO,KAAK,EACV,iBAAiB,EAIjB,cAAc,EAEf,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,YAAY,GAAG,cAAc,CAyBzE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,CAYzF;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAsH/F"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { nodeSlice as o } from "./node.slice.js";
|
|
2
|
+
function n(t) {
|
|
3
|
+
const a = t.client?.collectors?.filter(
|
|
4
|
+
(e) => e.category === "SingleValueCollector"
|
|
5
|
+
)?.reduce((e, r) => (e[r.input.key] = r.input.value, e), {});
|
|
6
|
+
return {
|
|
7
|
+
id: t.server.id || "",
|
|
8
|
+
eventName: t.server.eventName || "",
|
|
9
|
+
interactionId: t.server.interactionId || "",
|
|
10
|
+
parameters: {
|
|
11
|
+
eventType: "submit",
|
|
12
|
+
data: {
|
|
13
|
+
actionKey: t.client?.action || "",
|
|
14
|
+
formData: a || {}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function d(t, s) {
|
|
20
|
+
return {
|
|
21
|
+
id: t.server.id || "",
|
|
22
|
+
eventName: t.server.eventName || "",
|
|
23
|
+
interactionId: t.server.interactionId || "",
|
|
24
|
+
parameters: {
|
|
25
|
+
eventType: "action",
|
|
26
|
+
data: {
|
|
27
|
+
actionKey: s
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function f(t, s, a) {
|
|
33
|
+
if (t.isError && t.error.status >= 500) {
|
|
34
|
+
const e = t.error.data, r = t.requestId;
|
|
35
|
+
s(o.actions.failure({ data: e, requestId: r, httpStatus: t.error.status }));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (t.isError && t.error.status >= 400 && t.error.status < 500) {
|
|
39
|
+
const e = t.error.data, r = t.requestId;
|
|
40
|
+
if (e.code === 1999 || e.code === "requestTimedOut") {
|
|
41
|
+
s(o.actions.failure({ data: e, requestId: r, httpStatus: t.error.status }));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (e.connectorId === "pingOneAuthenticationConnector" && (e.capabilityName === "returnSuccessResponseRedirect" || e.capabilityName === "setSession")) {
|
|
45
|
+
s(o.actions.failure({ data: e, requestId: r, httpStatus: t.error.status }));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
s(o.actions.error({ data: e, requestId: r, httpStatus: t.error.status }));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (t.isError && t.error.status === "FETCH_ERROR") {
|
|
52
|
+
const e = {
|
|
53
|
+
code: t.error.status,
|
|
54
|
+
message: "Fetch Error: Please ensure a correct Client ID for your OAuth application."
|
|
55
|
+
}, r = t.requestId;
|
|
56
|
+
s(o.actions.failure({ data: e, requestId: r, httpStatus: t.error.status }));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (t.isSuccess && "error" in t.data) {
|
|
60
|
+
const e = t.data, r = t.requestId;
|
|
61
|
+
s(
|
|
62
|
+
o.actions.failure({
|
|
63
|
+
data: e.error,
|
|
64
|
+
requestId: r,
|
|
65
|
+
httpStatus: a
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (t.isSuccess && "status" in t.data) {
|
|
71
|
+
const e = t.data.status.toLowerCase();
|
|
72
|
+
if (e === "failure") {
|
|
73
|
+
const r = t.data, i = t.requestId;
|
|
74
|
+
s(
|
|
75
|
+
o.actions.failure({
|
|
76
|
+
data: r.error,
|
|
77
|
+
requestId: i,
|
|
78
|
+
httpStatus: e
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (t.isSuccess) {
|
|
85
|
+
const e = t.requestId;
|
|
86
|
+
if ("eventName" in t.data && t.data.eventName === "continue") {
|
|
87
|
+
const r = t.data;
|
|
88
|
+
s(o.actions.next({ data: r, requestId: e, httpStatus: a }));
|
|
89
|
+
} else if ("session" in t.data || "authorizeResponse" in t.data) {
|
|
90
|
+
const r = t.data;
|
|
91
|
+
s(o.actions.success({ data: r, requestId: e, httpStatus: a }));
|
|
92
|
+
} else {
|
|
93
|
+
const r = t.data;
|
|
94
|
+
s(o.actions.failure({ data: r, requestId: e, httpStatus: a }));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
f as handleResponse,
|
|
100
|
+
d as transformActionRequest,
|
|
101
|
+
n as transformSubmitRequest
|
|
102
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.types.d.ts","sourceRoot":"","sources":["../../src/lib/error.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EACA,gBAAgB,GAChB,eAAe,GACf,gBAAgB,GAChB,eAAe,GACf,aAAa,GACb,eAAe,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DaVinciField } from './davinci.types';
|
|
2
|
+
import { ActionCollector, FlowCollector, PasswordCollector, SingleValueCollector, SocialLoginCollector, SubmitCollector, TextCollector } from './collector.types.js';
|
|
3
|
+
/**
|
|
4
|
+
* @const nextCollectorValues - Action for setting the next collector values
|
|
5
|
+
* @see https://redux-toolkit.js.org/api/createAction
|
|
6
|
+
*
|
|
7
|
+
* This is for internal "collector" setup for handling the state of the current node
|
|
8
|
+
*/
|
|
9
|
+
export declare const nextCollectorValues: import('@reduxjs/toolkit').ActionCreatorWithPayload<DaVinciField[], string>;
|
|
10
|
+
export declare const updateCollectorValues: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
11
|
+
id: string;
|
|
12
|
+
value: string;
|
|
13
|
+
index?: number;
|
|
14
|
+
}, string>;
|
|
15
|
+
/**
|
|
16
|
+
* @const nodeCollectorReducer - Reducer for handling the collector values
|
|
17
|
+
* @see https://redux-toolkit.js.org/api/createReducer
|
|
18
|
+
*/
|
|
19
|
+
export declare const nodeCollectorReducer: import('@reduxjs/toolkit').Reducer<(FlowCollector | PasswordCollector | TextCollector | SocialLoginCollector | SubmitCollector | ActionCollector<"ActionCollector"> | SingleValueCollector<"SingleValueCollector">)[]> & {
|
|
20
|
+
getInitialState: () => (FlowCollector | PasswordCollector | TextCollector | SocialLoginCollector | SubmitCollector | ActionCollector<"ActionCollector"> | SingleValueCollector<"SingleValueCollector">)[];
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=node.reducer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.reducer.d.ts","sourceRoot":"","sources":["../../src/lib/node.reducer.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EACL,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACd,MAAM,sBAAsB,CAAC;AAE9B;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,6EAA4C,CAAC;AAC7E,eAAO,MAAM,qBAAqB;QAC5B,MAAM;WACH,MAAM;YACL,MAAM;UACC,CAAC;AAelB;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;CAkD/B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createAction as c, createReducer as a } from "@reduxjs/toolkit";
|
|
2
|
+
import { returnTextCollector as u, returnPasswordCollector as s, returnSocialLoginCollector as C, returnFlowCollector as p, returnSubmitCollector as T, returnActionCollector as i, returnSingleValueCollector as d } from "./collector.utils.js";
|
|
3
|
+
const O = c("node/next"), S = c("node/update"), w = [], m = a(w, (n) => {
|
|
4
|
+
n.addCase(O, (l, e) => e.payload.map((o, r) => {
|
|
5
|
+
switch (o.type) {
|
|
6
|
+
case "SUBMIT_BUTTON":
|
|
7
|
+
return T(o, r);
|
|
8
|
+
case "FLOW_BUTTON":
|
|
9
|
+
return p(o, r);
|
|
10
|
+
case "SOCIAL_LOGIN_BUTTON":
|
|
11
|
+
return C(o, r);
|
|
12
|
+
case "PASSWORD":
|
|
13
|
+
return s(o, r);
|
|
14
|
+
case "TEXT":
|
|
15
|
+
return u(o, r);
|
|
16
|
+
}
|
|
17
|
+
return o.type.includes("BUTTON") ? i(o, r, "ActionCollector") : d(o, r, "SingleValueCollector");
|
|
18
|
+
}) || []).addCase(S, (l, e) => {
|
|
19
|
+
const t = l.find((o) => o.id === e.payload.id);
|
|
20
|
+
if (!t)
|
|
21
|
+
throw new Error("No collector found to update");
|
|
22
|
+
if (t.category === "ActionCollector")
|
|
23
|
+
throw new Error("ActionCollectors are read-only");
|
|
24
|
+
t.input.value = e.payload.value;
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
export {
|
|
28
|
+
O as nextCollectorValues,
|
|
29
|
+
m as nodeCollectorReducer,
|
|
30
|
+
S as updateCollectorValues
|
|
31
|
+
};
|