@forgerock/davinci-client 0.0.0-beta-20251124184351 → 0.0.0-beta-20251222204813
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +10 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib/client.store.d.ts +352 -0
- package/dist/src/lib/client.store.d.ts.map +1 -0
- package/dist/src/lib/client.store.js +308 -0
- package/dist/src/lib/client.store.js.map +1 -0
- package/dist/src/lib/client.store.utils.d.ts +74 -0
- package/dist/src/lib/client.store.utils.d.ts.map +1 -0
- package/dist/src/lib/client.store.utils.js +48 -0
- package/dist/src/lib/client.store.utils.js.map +1 -0
- package/dist/src/lib/client.types.d.ts +71 -0
- package/dist/src/lib/client.types.d.ts.map +1 -0
- package/dist/src/lib/client.types.js +2 -0
- package/dist/src/lib/client.types.js.map +1 -0
- package/dist/src/lib/collector.types.d.ts +448 -0
- package/dist/src/lib/collector.types.d.ts.map +1 -0
- package/dist/src/lib/collector.types.js +8 -0
- package/dist/src/lib/collector.types.js.map +1 -0
- package/dist/src/lib/collector.utils.d.ts +154 -0
- package/dist/src/lib/collector.utils.d.ts.map +1 -0
- package/dist/src/lib/collector.utils.js +651 -0
- package/dist/src/lib/collector.utils.js.map +1 -0
- package/dist/src/lib/config.slice.d.ts +42 -0
- package/dist/src/lib/config.slice.d.ts.map +1 -0
- package/dist/src/lib/config.slice.js +59 -0
- package/dist/src/lib/config.slice.js.map +1 -0
- package/dist/src/lib/config.types.d.ts +12 -0
- package/dist/src/lib/config.types.d.ts.map +1 -0
- package/dist/src/lib/config.types.js +2 -0
- package/dist/src/lib/config.types.js.map +1 -0
- package/dist/src/lib/davinci.api.d.ts +31 -0
- package/dist/src/lib/davinci.api.d.ts.map +1 -0
- package/dist/src/lib/davinci.api.js +347 -0
- package/dist/src/lib/davinci.api.js.map +1 -0
- package/dist/src/lib/davinci.types.d.ts +328 -0
- package/dist/src/lib/davinci.types.d.ts.map +1 -0
- package/dist/src/lib/davinci.types.js +11 -0
- package/dist/src/lib/davinci.types.js.map +1 -0
- package/dist/src/lib/davinci.utils.d.ts +22 -0
- package/dist/src/lib/davinci.utils.d.ts.map +1 -0
- package/dist/src/lib/davinci.utils.js +170 -0
- package/dist/src/lib/davinci.utils.js.map +1 -0
- package/dist/src/lib/fido/fido.d.ts +27 -0
- package/dist/src/lib/fido/fido.d.ts.map +1 -0
- package/dist/src/lib/fido/fido.js +108 -0
- package/dist/src/lib/fido/fido.js.map +1 -0
- package/dist/src/lib/fido/fido.utils.d.ts +31 -0
- package/dist/src/lib/fido/fido.utils.d.ts.map +1 -0
- package/dist/src/lib/fido/fido.utils.js +115 -0
- package/dist/src/lib/fido/fido.utils.js.map +1 -0
- package/dist/src/lib/index.d.ts +3 -0
- package/dist/src/lib/index.d.ts.map +1 -0
- package/dist/src/lib/index.js +9 -0
- package/dist/src/lib/index.js.map +1 -0
- package/dist/src/lib/node.reducer.d.ts +27 -0
- package/dist/src/lib/node.reducer.d.ts.map +1 -0
- package/dist/src/lib/node.reducer.js +230 -0
- package/dist/src/lib/node.reducer.js.map +1 -0
- package/dist/src/lib/node.slice.d.ts +181 -0
- package/dist/src/lib/node.slice.d.ts.map +1 -0
- package/dist/src/lib/node.slice.js +261 -0
- package/dist/src/lib/node.slice.js.map +1 -0
- package/dist/src/lib/node.types.d.ts +119 -0
- package/dist/src/lib/node.types.d.ts.map +1 -0
- package/dist/src/lib/node.types.js +2 -0
- package/dist/src/lib/node.types.js.map +1 -0
- package/dist/src/lib/node.utils.d.ts +4 -0
- package/dist/src/lib/node.utils.d.ts.map +1 -0
- package/dist/src/lib/node.utils.js +32 -0
- package/dist/src/lib/node.utils.js.map +1 -0
- package/dist/src/lib/wellknown.api.d.ts +5 -0
- package/dist/src/lib/wellknown.api.d.ts.map +1 -0
- package/dist/src/lib/wellknown.api.js +22 -0
- package/dist/src/lib/wellknown.api.js.map +1 -0
- package/dist/src/lib/wellknown.types.d.ts +38 -0
- package/dist/src/lib/wellknown.types.d.ts.map +1 -0
- package/dist/src/lib/wellknown.types.js +2 -0
- package/dist/src/lib/wellknown.types.js.map +1 -0
- package/dist/src/types.d.ts +45 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +7 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* This software may be modified and distributed under the terms
|
|
5
|
+
* of the MIT license. See the LICENSE file for details.
|
|
6
|
+
*/
|
|
7
|
+
import { Micro } from 'effect';
|
|
8
|
+
import { exitIsFail, exitIsSuccess } from 'effect/Micro';
|
|
9
|
+
import { transformAssertion, transformAuthenticationOptions, transformPublicKeyCredential, transformRegistrationOptions, } from './fido.utils.js';
|
|
10
|
+
/**
|
|
11
|
+
* A client function that returns a set of methods for transforming DaVinci data and
|
|
12
|
+
* interacting with the WebAuthn API for registration and authentication
|
|
13
|
+
* @function fido
|
|
14
|
+
* @returns {FidoClient} - A set of methods for FIDO registration and authentication
|
|
15
|
+
*/
|
|
16
|
+
export function fido() {
|
|
17
|
+
return {
|
|
18
|
+
/**
|
|
19
|
+
* Call WebAuthn API to create keypair and get public key credential
|
|
20
|
+
*/
|
|
21
|
+
register: async function register(options) {
|
|
22
|
+
const createCredentialµ = Micro.sync(() => transformRegistrationOptions(options)).pipe(Micro.flatMap((publicKeyCredentialCreationOptions) => Micro.tryPromise({
|
|
23
|
+
try: () => navigator.credentials.create({
|
|
24
|
+
publicKey: publicKeyCredentialCreationOptions,
|
|
25
|
+
}),
|
|
26
|
+
catch: (error) => {
|
|
27
|
+
console.error('Failed to create keypair: ', error);
|
|
28
|
+
return {
|
|
29
|
+
error: 'registration_error',
|
|
30
|
+
message: 'FIDO registration failed',
|
|
31
|
+
type: 'fido_error',
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
})), Micro.flatMap((credential) => {
|
|
35
|
+
if (!credential) {
|
|
36
|
+
return Micro.fail({
|
|
37
|
+
error: 'registration_error',
|
|
38
|
+
message: 'FIDO registration failed: No credential returned',
|
|
39
|
+
type: 'fido_error',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const formattedCredential = transformPublicKeyCredential(credential);
|
|
44
|
+
return Micro.succeed(formattedCredential);
|
|
45
|
+
}
|
|
46
|
+
}));
|
|
47
|
+
const result = await Micro.runPromiseExit(createCredentialµ);
|
|
48
|
+
if (exitIsSuccess(result)) {
|
|
49
|
+
return result.value;
|
|
50
|
+
}
|
|
51
|
+
else if (exitIsFail(result)) {
|
|
52
|
+
return result.cause.error;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return {
|
|
56
|
+
error: 'fido_registration_error',
|
|
57
|
+
message: result.cause.message,
|
|
58
|
+
type: 'unknown_error',
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* Call WebAuthn API to get assertion
|
|
64
|
+
*/
|
|
65
|
+
authenticate: async function authenticate(options) {
|
|
66
|
+
const getAssertionµ = Micro.sync(() => transformAuthenticationOptions(options)).pipe(Micro.flatMap((publicKeyCredentialRequestOptions) => Micro.tryPromise({
|
|
67
|
+
try: () => navigator.credentials.get({
|
|
68
|
+
publicKey: publicKeyCredentialRequestOptions,
|
|
69
|
+
}),
|
|
70
|
+
catch: (error) => {
|
|
71
|
+
console.error('Failed to authenticate: ', error);
|
|
72
|
+
return {
|
|
73
|
+
error: 'authentication_error',
|
|
74
|
+
message: 'FIDO authentication failed',
|
|
75
|
+
type: 'fido_error',
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
})), Micro.flatMap((assertion) => {
|
|
79
|
+
if (!assertion) {
|
|
80
|
+
return Micro.fail({
|
|
81
|
+
error: 'authentication_error',
|
|
82
|
+
message: 'FIDO authentication failed: No credential returned',
|
|
83
|
+
type: 'fido_error',
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
const formattedAssertion = transformAssertion(assertion);
|
|
88
|
+
return Micro.succeed(formattedAssertion);
|
|
89
|
+
}
|
|
90
|
+
}));
|
|
91
|
+
const result = await Micro.runPromiseExit(getAssertionµ);
|
|
92
|
+
if (exitIsSuccess(result)) {
|
|
93
|
+
return result.value;
|
|
94
|
+
}
|
|
95
|
+
else if (exitIsFail(result)) {
|
|
96
|
+
return result.cause.error;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
return {
|
|
100
|
+
error: 'fido_authentication_error',
|
|
101
|
+
message: result.cause.message,
|
|
102
|
+
type: 'unknown_error',
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=fido.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fido.js","sourceRoot":"","sources":["../../../../src/lib/fido/fido.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EACL,kBAAkB,EAClB,8BAA8B,EAC9B,4BAA4B,EAC5B,4BAA4B,GAC7B,MAAM,iBAAiB,CAAC;AA8BzB;;;;;GAKG;AACH,MAAM,UAAU,IAAI;IAClB,OAAO;QACL;;WAEG;QACH,QAAQ,EAAE,KAAK,UAAU,QAAQ,CAC/B,OAAgC;YAEhC,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CACpF,KAAK,CAAC,OAAO,CAAC,CAAC,kCAAkC,EAAE,EAAE,CACnD,KAAK,CAAC,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AAC,EAAE,CAAC;gBAC9B,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;YAC5B,CAAC;iBAAM,CAAC;gBACN,OAAO;oBACL,KAAK,EAAE,2BAA2B;oBAClC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;oBAC7B,IAAI,EAAE,eAAe;iBACtB,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { FidoAuthenticationInputValue, FidoRegistrationInputValue } from '../collector.types.js';
|
|
2
|
+
import type { FidoAuthenticationOptions, FidoRegistrationOptions } from '../davinci.types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Convert DaVinci registration options to PublicKeyCredentialCreationOptions
|
|
5
|
+
* @function transformRegistrationOptions
|
|
6
|
+
* @param { FidoRegistrationOptions } options - DaVinci FIDO registration options
|
|
7
|
+
* @returns { PublicKeyCredentialCreationOptions } - WebAuthn API compatible registration options
|
|
8
|
+
*/
|
|
9
|
+
export declare function transformRegistrationOptions(options: FidoRegistrationOptions): PublicKeyCredentialCreationOptions;
|
|
10
|
+
/**
|
|
11
|
+
* Format the credential to send back to DaVinci for registration
|
|
12
|
+
* @function transformPublicKeyCredential
|
|
13
|
+
* @param { PublicKeyCredential } credential - The credential returned from navigator.credentials.create()
|
|
14
|
+
* @returns { FidoRegistrationInputValue } - The formatted credential for registering with DaVinci
|
|
15
|
+
*/
|
|
16
|
+
export declare function transformPublicKeyCredential(credential: PublicKeyCredential): FidoRegistrationInputValue;
|
|
17
|
+
/**
|
|
18
|
+
* Convert DaVinci authentication options to PublicKeyCredentialRequestOptions
|
|
19
|
+
* @function transformAuthenticationOptions
|
|
20
|
+
* @param { FidoAuthenticationOptions } options - DaVinci FIDO authentication options
|
|
21
|
+
* @returns { PublicKeyCredentialRequestOptions } - WebAuthn API compatible authentication options
|
|
22
|
+
*/
|
|
23
|
+
export declare function transformAuthenticationOptions(options: FidoAuthenticationOptions): PublicKeyCredentialRequestOptions;
|
|
24
|
+
/**
|
|
25
|
+
* Format the assertion to send back to DaVinci for authentication
|
|
26
|
+
* @function transformAssertion
|
|
27
|
+
* @param { PublicKeyCredential } credential - The credential returned from navigator.credentials.get()
|
|
28
|
+
* @returns { FidoAuthenticationInputValue } - The formatted credential for authenticating with DaVinci
|
|
29
|
+
*/
|
|
30
|
+
export declare function transformAssertion(credential: PublicKeyCredential): FidoAuthenticationInputValue;
|
|
31
|
+
//# sourceMappingURL=fido.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fido.utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/fido/fido.utils.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,4BAA4B,EAC5B,0BAA0B,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAe9F;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,uBAAuB,GAC/B,kCAAkC,CAqBpC;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,mBAAmB,GAC9B,0BAA0B,CAoB5B;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,yBAAyB,GACjC,iCAAiC,CAanC;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,mBAAmB,GAAG,4BAA4B,CAyBhG"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
function convertArrayToBuffer(arr) {
|
|
2
|
+
return new Int8Array(arr).buffer;
|
|
3
|
+
}
|
|
4
|
+
function convertBufferToBase64(buffer) {
|
|
5
|
+
const byteArray = new Uint8Array(buffer);
|
|
6
|
+
let binaryString = '';
|
|
7
|
+
for (let i = 0; i < byteArray.byteLength; i++) {
|
|
8
|
+
binaryString += String.fromCharCode(byteArray[i]);
|
|
9
|
+
}
|
|
10
|
+
return btoa(binaryString);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Convert DaVinci registration options to PublicKeyCredentialCreationOptions
|
|
14
|
+
* @function transformRegistrationOptions
|
|
15
|
+
* @param { FidoRegistrationOptions } options - DaVinci FIDO registration options
|
|
16
|
+
* @returns { PublicKeyCredentialCreationOptions } - WebAuthn API compatible registration options
|
|
17
|
+
*/
|
|
18
|
+
export function transformRegistrationOptions(options) {
|
|
19
|
+
const pubKeyCredParams = options.pubKeyCredParams.map((param) => ({
|
|
20
|
+
type: param.type,
|
|
21
|
+
alg: typeof param.alg === 'string' ? parseInt(param.alg, 10) : param.alg,
|
|
22
|
+
}));
|
|
23
|
+
const excludeCredentials = options.excludeCredentials?.map((param) => ({
|
|
24
|
+
type: param.type,
|
|
25
|
+
id: convertArrayToBuffer(param.id),
|
|
26
|
+
transports: param.transports,
|
|
27
|
+
}));
|
|
28
|
+
return {
|
|
29
|
+
...options,
|
|
30
|
+
challenge: convertArrayToBuffer(options.challenge),
|
|
31
|
+
user: {
|
|
32
|
+
...options.user,
|
|
33
|
+
id: convertArrayToBuffer(options.user.id),
|
|
34
|
+
},
|
|
35
|
+
pubKeyCredParams,
|
|
36
|
+
excludeCredentials,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Format the credential to send back to DaVinci for registration
|
|
41
|
+
* @function transformPublicKeyCredential
|
|
42
|
+
* @param { PublicKeyCredential } credential - The credential returned from navigator.credentials.create()
|
|
43
|
+
* @returns { FidoRegistrationInputValue } - The formatted credential for registering with DaVinci
|
|
44
|
+
*/
|
|
45
|
+
export function transformPublicKeyCredential(credential) {
|
|
46
|
+
const credentialResponse = credential.response;
|
|
47
|
+
const clientDataJSON = convertBufferToBase64(credentialResponse.clientDataJSON);
|
|
48
|
+
const attestationObject = convertBufferToBase64(credentialResponse.attestationObject);
|
|
49
|
+
const rawId = convertBufferToBase64(credential.rawId);
|
|
50
|
+
return {
|
|
51
|
+
attestationValue: {
|
|
52
|
+
...credential,
|
|
53
|
+
id: credential.id,
|
|
54
|
+
rawId,
|
|
55
|
+
type: credential.type,
|
|
56
|
+
authenticatorAttachment: credential.authenticatorAttachment,
|
|
57
|
+
response: {
|
|
58
|
+
...credentialResponse,
|
|
59
|
+
clientDataJSON,
|
|
60
|
+
attestationObject,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Convert DaVinci authentication options to PublicKeyCredentialRequestOptions
|
|
67
|
+
* @function transformAuthenticationOptions
|
|
68
|
+
* @param { FidoAuthenticationOptions } options - DaVinci FIDO authentication options
|
|
69
|
+
* @returns { PublicKeyCredentialRequestOptions } - WebAuthn API compatible authentication options
|
|
70
|
+
*/
|
|
71
|
+
export function transformAuthenticationOptions(options) {
|
|
72
|
+
const allowCredentials = options.allowCredentials?.map((param) => ({
|
|
73
|
+
id: convertArrayToBuffer(param.id),
|
|
74
|
+
type: param.type,
|
|
75
|
+
transports: param.transports,
|
|
76
|
+
}));
|
|
77
|
+
const challenge = convertArrayToBuffer(options.challenge);
|
|
78
|
+
return {
|
|
79
|
+
...options,
|
|
80
|
+
challenge,
|
|
81
|
+
allowCredentials,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Format the assertion to send back to DaVinci for authentication
|
|
86
|
+
* @function transformAssertion
|
|
87
|
+
* @param { PublicKeyCredential } credential - The credential returned from navigator.credentials.get()
|
|
88
|
+
* @returns { FidoAuthenticationInputValue } - The formatted credential for authenticating with DaVinci
|
|
89
|
+
*/
|
|
90
|
+
export function transformAssertion(credential) {
|
|
91
|
+
const credentialResponse = credential.response;
|
|
92
|
+
const clientDataJSON = convertBufferToBase64(credentialResponse.clientDataJSON);
|
|
93
|
+
const authenticatorData = convertBufferToBase64(credentialResponse.authenticatorData);
|
|
94
|
+
const signature = convertBufferToBase64(credentialResponse.signature);
|
|
95
|
+
const userHandle = credentialResponse.userHandle
|
|
96
|
+
? convertBufferToBase64(credentialResponse.userHandle)
|
|
97
|
+
: null;
|
|
98
|
+
const rawId = convertBufferToBase64(credential.rawId);
|
|
99
|
+
return {
|
|
100
|
+
assertionValue: {
|
|
101
|
+
...credential,
|
|
102
|
+
id: credential.id,
|
|
103
|
+
rawId,
|
|
104
|
+
type: credential.type,
|
|
105
|
+
response: {
|
|
106
|
+
...credentialResponse,
|
|
107
|
+
clientDataJSON,
|
|
108
|
+
authenticatorData,
|
|
109
|
+
signature,
|
|
110
|
+
userHandle,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=fido.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fido.utils.js","sourceRoot":"","sources":["../../../../src/lib/fido/fido.utils.ts"],"names":[],"mappings":"AAYA,SAAS,oBAAoB,CAAC,GAAa;IACzC,OAAO,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;AACnC,CAAC;AAED,SAAS,qBAAqB,CAAC,MAAmB;IAChD,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACzC,IAAI,YAAY,GAAG,EAAE,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,YAAY,IAAI,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAAgC;IAEhC,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAChE,IAAI,EAAE,KAA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BACrB,cAAc;gBACd,iBAAiB;gBACjB,SAAS;gBACT,UAAU;aACX;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* This software may be modified and distributed under the terms
|
|
5
|
+
* of the MIT license. See the LICENSE file for details.
|
|
6
|
+
*/
|
|
7
|
+
import { davinci } from './client.store.js';
|
|
8
|
+
export { davinci };
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { DaVinciField } from './davinci.types.js';
|
|
2
|
+
import type { ActionCollector, MultiSelectCollector, SingleSelectCollector, FlowCollector, PasswordCollector, SingleValueCollector, IdpCollector, SubmitCollector, TextCollector, ReadOnlyCollector, ValidatedTextCollector, DeviceAuthenticationCollector, DeviceRegistrationCollector, PhoneNumberCollector, PhoneNumberInputValue, UnknownCollector, ProtectCollector, FidoRegistrationCollector, FidoAuthenticationCollector, FidoAuthenticationInputValue, FidoRegistrationInputValue } 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<{
|
|
10
|
+
fields: DaVinciField[];
|
|
11
|
+
formData: {
|
|
12
|
+
value: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
}, string>;
|
|
15
|
+
export declare const updateCollectorValues: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
16
|
+
id: string;
|
|
17
|
+
value: string | string[] | PhoneNumberInputValue | FidoRegistrationInputValue | FidoAuthenticationInputValue;
|
|
18
|
+
index?: number;
|
|
19
|
+
}, string>;
|
|
20
|
+
/**
|
|
21
|
+
* @const nodeCollectorReducer - Reducer for handling the collector values
|
|
22
|
+
* @see https://redux-toolkit.js.org/api/createReducer
|
|
23
|
+
*/
|
|
24
|
+
export declare const nodeCollectorReducer: import("@reduxjs/toolkit").Reducer<(TextCollector | SingleSelectCollector | ValidatedTextCollector | PasswordCollector | MultiSelectCollector | DeviceAuthenticationCollector | DeviceRegistrationCollector | PhoneNumberCollector | IdpCollector | SubmitCollector | FlowCollector | ReadOnlyCollector | UnknownCollector | ProtectCollector | FidoRegistrationCollector | FidoAuthenticationCollector | ActionCollector<"ActionCollector"> | SingleValueCollector<"SingleValueCollector">)[]> & {
|
|
25
|
+
getInitialState: () => (TextCollector | SingleSelectCollector | ValidatedTextCollector | PasswordCollector | MultiSelectCollector | DeviceAuthenticationCollector | DeviceRegistrationCollector | PhoneNumberCollector | IdpCollector | SubmitCollector | FlowCollector | ReadOnlyCollector | UnknownCollector | ProtectCollector | FidoRegistrationCollector | FidoAuthenticationCollector | ActionCollector<"ActionCollector"> | SingleValueCollector<"SingleValueCollector">)[];
|
|
26
|
+
};
|
|
27
|
+
//# 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":"AA+BA,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,6BAA6B,EAC7B,2BAA2B,EAC3B,oBAAoB,EACpB,qBAAqB,EAErB,gBAAgB,EAChB,gBAAgB,EAChB,yBAAyB,EACzB,2BAA2B,EAC3B,4BAA4B,EAC5B,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAE9B;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;YACtB,YAAY,EAAE;cACZ;QAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;UAC/B,CAAC;AAChB,eAAO,MAAM,qBAAqB;QAC5B,MAAM;WAEN,MAAM,GACN,MAAM,EAAE,GACR,qBAAqB,GACrB,0BAA0B,GAC1B,4BAA4B;YACxB,MAAM;UACC,CAAC;AA0BlB;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;CA2N/B,CAAC"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* This software may be modified and distributed under the terms
|
|
5
|
+
* of the MIT license. See the LICENSE file for details.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Import the required utilities from Redux Toolkit
|
|
9
|
+
*/
|
|
10
|
+
import { createAction, createReducer } from '@reduxjs/toolkit';
|
|
11
|
+
/**
|
|
12
|
+
* Import the collector utilities
|
|
13
|
+
*/
|
|
14
|
+
import { returnActionCollector, returnFlowCollector, returnPasswordCollector, returnIdpCollector, returnSubmitCollector, returnTextCollector, returnSingleSelectCollector, returnMultiSelectCollector, returnReadOnlyCollector, returnObjectSelectCollector, returnObjectValueCollector, returnProtectCollector, returnUnknownCollector, returnFidoRegistrationCollector, returnFidoAuthenticationCollector, } from './collector.utils.js';
|
|
15
|
+
/**
|
|
16
|
+
* @const nextCollectorValues - Action for setting the next collector values
|
|
17
|
+
* @see https://redux-toolkit.js.org/api/createAction
|
|
18
|
+
*
|
|
19
|
+
* This is for internal "collector" setup for handling the state of the current node
|
|
20
|
+
*/
|
|
21
|
+
export const nextCollectorValues = createAction('node/next');
|
|
22
|
+
export const updateCollectorValues = createAction('node/update');
|
|
23
|
+
/**
|
|
24
|
+
* @const initialCollectorValues - Initial state for the collector values
|
|
25
|
+
*/
|
|
26
|
+
const initialCollectorValues = [];
|
|
27
|
+
/**
|
|
28
|
+
* @const nodeCollectorReducer - Reducer for handling the collector values
|
|
29
|
+
* @see https://redux-toolkit.js.org/api/createReducer
|
|
30
|
+
*/
|
|
31
|
+
export const nodeCollectorReducer = createReducer(initialCollectorValues, (builder) => {
|
|
32
|
+
builder
|
|
33
|
+
/**
|
|
34
|
+
* Using the `nextCollectorValues` const (e.g. `'node/next'`) to add the case
|
|
35
|
+
* 'node/next' is essentially derived `createSlice` below. `node.next()` is
|
|
36
|
+
* transformed to `'node/next'` for the action type.
|
|
37
|
+
*/
|
|
38
|
+
.addCase(nextCollectorValues, (_, action) => {
|
|
39
|
+
const fields = action.payload.fields;
|
|
40
|
+
// Map the fields to the initial state with the schema of Generic Collector
|
|
41
|
+
const collectors = Array.isArray(fields)
|
|
42
|
+
? fields.map((field, idx) => {
|
|
43
|
+
/**
|
|
44
|
+
* Some collectors may not have the same properties as others;
|
|
45
|
+
* LABEL field types are one of them, so let's catch them first.
|
|
46
|
+
*/
|
|
47
|
+
if (field.type === 'LABEL') {
|
|
48
|
+
return returnReadOnlyCollector(field, idx);
|
|
49
|
+
}
|
|
50
|
+
// *Some* collectors may have default or existing data to display
|
|
51
|
+
const data = action.payload.formData &&
|
|
52
|
+
action.payload.formData.value &&
|
|
53
|
+
action.payload.formData.value[field.key];
|
|
54
|
+
// Match specific collectors
|
|
55
|
+
switch (field.type) {
|
|
56
|
+
case 'CHECKBOX':
|
|
57
|
+
case 'COMBOBOX': {
|
|
58
|
+
// Intentional fall-through
|
|
59
|
+
const strArr = data;
|
|
60
|
+
return returnMultiSelectCollector(field, idx, strArr);
|
|
61
|
+
}
|
|
62
|
+
case 'DROPDOWN':
|
|
63
|
+
case 'RADIO': {
|
|
64
|
+
// Intentional fall-through
|
|
65
|
+
const str = data;
|
|
66
|
+
return returnSingleSelectCollector(field, idx, str);
|
|
67
|
+
}
|
|
68
|
+
case 'FLOW_BUTTON':
|
|
69
|
+
case 'FLOW_LINK': {
|
|
70
|
+
// Intentional fall-through
|
|
71
|
+
// No data to send
|
|
72
|
+
return returnFlowCollector(field, idx);
|
|
73
|
+
}
|
|
74
|
+
case 'DEVICE_AUTHENTICATION':
|
|
75
|
+
case 'DEVICE_REGISTRATION': {
|
|
76
|
+
// Intentional fall-through
|
|
77
|
+
return returnObjectSelectCollector(field, idx);
|
|
78
|
+
}
|
|
79
|
+
case 'PASSWORD':
|
|
80
|
+
case 'PASSWORD_VERIFY': {
|
|
81
|
+
// No data to send
|
|
82
|
+
return returnPasswordCollector(field, idx);
|
|
83
|
+
}
|
|
84
|
+
case 'PHONE_NUMBER': {
|
|
85
|
+
const prefillData = data;
|
|
86
|
+
return returnObjectValueCollector(field, idx, prefillData);
|
|
87
|
+
}
|
|
88
|
+
case 'TEXT': {
|
|
89
|
+
const str = data;
|
|
90
|
+
return returnTextCollector(field, idx, str);
|
|
91
|
+
}
|
|
92
|
+
case 'SOCIAL_LOGIN_BUTTON': {
|
|
93
|
+
// No data to send
|
|
94
|
+
return returnIdpCollector(field, idx);
|
|
95
|
+
}
|
|
96
|
+
case 'SUBMIT_BUTTON': {
|
|
97
|
+
// No data to send
|
|
98
|
+
return returnSubmitCollector(field, idx);
|
|
99
|
+
}
|
|
100
|
+
case 'PROTECT': {
|
|
101
|
+
return returnProtectCollector(field, idx);
|
|
102
|
+
}
|
|
103
|
+
case 'FIDO2': {
|
|
104
|
+
if (field.action === 'REGISTER') {
|
|
105
|
+
return returnFidoRegistrationCollector(field, idx);
|
|
106
|
+
}
|
|
107
|
+
else if (field.action === 'AUTHENTICATE') {
|
|
108
|
+
return returnFidoAuthenticationCollector(field, idx);
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
default:
|
|
113
|
+
// Default is handled below
|
|
114
|
+
}
|
|
115
|
+
// Generic Collectors
|
|
116
|
+
if (field.type.includes('BUTTON') || field.type.includes('LINK')) {
|
|
117
|
+
// No data to send
|
|
118
|
+
return returnActionCollector(field, idx, 'ActionCollector');
|
|
119
|
+
}
|
|
120
|
+
return returnUnknownCollector(field, idx);
|
|
121
|
+
})
|
|
122
|
+
: [];
|
|
123
|
+
return collectors || [];
|
|
124
|
+
})
|
|
125
|
+
/**
|
|
126
|
+
* Using the `updateCollectorValues` const (e.g. `'node/update'`) to add the case
|
|
127
|
+
* 'node/update' is essentially derived `createSlice` below. `node.update()` is
|
|
128
|
+
* transformed to `'node/update'` for the action type.
|
|
129
|
+
*/
|
|
130
|
+
.addCase(updateCollectorValues, (state, action) => {
|
|
131
|
+
const collector = state.find((collector) => collector.id === action.payload.id);
|
|
132
|
+
if (!collector) {
|
|
133
|
+
throw new Error('No collector found to update');
|
|
134
|
+
}
|
|
135
|
+
if (collector.category === 'ActionCollector') {
|
|
136
|
+
throw new Error('ActionCollectors are read-only');
|
|
137
|
+
}
|
|
138
|
+
if (collector.category === 'NoValueCollector') {
|
|
139
|
+
throw new Error('NoValueCollectors, like ReadOnlyCollectors, are read-only');
|
|
140
|
+
}
|
|
141
|
+
if (action.payload.value === undefined) {
|
|
142
|
+
throw new Error('Value argument cannot be undefined');
|
|
143
|
+
}
|
|
144
|
+
if (collector.category === 'SingleValueCollector' ||
|
|
145
|
+
collector.category === 'ValidatedSingleValueCollector' ||
|
|
146
|
+
collector.type === 'ProtectCollector') {
|
|
147
|
+
if (typeof action.payload.value !== 'string') {
|
|
148
|
+
throw new Error('Value argument must be a string');
|
|
149
|
+
}
|
|
150
|
+
collector.input.value = action.payload.value;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (collector.category === 'MultiValueCollector') {
|
|
154
|
+
if (typeof action.payload.value !== 'string' && !Array.isArray(action.payload.value)) {
|
|
155
|
+
throw new Error('MultiValueCollector does not accept an object');
|
|
156
|
+
}
|
|
157
|
+
if (Array.isArray(action.payload.value)) {
|
|
158
|
+
collector.input.value = [...action.payload.value];
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
collector.input.value.push(action.payload.value);
|
|
162
|
+
}
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (collector.type === 'DeviceAuthenticationCollector') {
|
|
166
|
+
if (typeof action.payload.id !== 'string') {
|
|
167
|
+
throw new Error('Index argument must be a string');
|
|
168
|
+
}
|
|
169
|
+
// Iterate through the options object and find option to update
|
|
170
|
+
const option = collector.output.options.find((option) => option.value === action.payload.value);
|
|
171
|
+
if (!option) {
|
|
172
|
+
throw new Error('No option found matching value to update');
|
|
173
|
+
}
|
|
174
|
+
// Remap values back to DaVinci spec
|
|
175
|
+
collector.input.value = {
|
|
176
|
+
type: option.type,
|
|
177
|
+
id: option.value,
|
|
178
|
+
value: option.content,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
if (collector.type === 'DeviceRegistrationCollector') {
|
|
182
|
+
if (typeof action.payload.id !== 'string') {
|
|
183
|
+
throw new Error('Index argument must be a string');
|
|
184
|
+
}
|
|
185
|
+
// Iterate through the options object and find option to update
|
|
186
|
+
const option = collector.output.options.find((option) => option.value === action.payload.value);
|
|
187
|
+
if (!option) {
|
|
188
|
+
throw new Error('No option found matching value to update');
|
|
189
|
+
}
|
|
190
|
+
collector.input.value = option.type;
|
|
191
|
+
}
|
|
192
|
+
if (collector.type === 'PhoneNumberCollector') {
|
|
193
|
+
if (typeof action.payload.id !== 'string') {
|
|
194
|
+
throw new Error('Index argument must be a string');
|
|
195
|
+
}
|
|
196
|
+
if (typeof action.payload.value !== 'object') {
|
|
197
|
+
throw new Error('Value argument must be an object');
|
|
198
|
+
}
|
|
199
|
+
if (!('phoneNumber' in action.payload.value) || !('countryCode' in action.payload.value)) {
|
|
200
|
+
throw new Error('Value argument must contain a phoneNumber and countryCode property');
|
|
201
|
+
}
|
|
202
|
+
collector.input.value = action.payload.value;
|
|
203
|
+
}
|
|
204
|
+
if (collector.type === 'FidoRegistrationCollector') {
|
|
205
|
+
if (typeof action.payload.id !== 'string') {
|
|
206
|
+
throw new Error('Index argument must be a string');
|
|
207
|
+
}
|
|
208
|
+
if (typeof action.payload.value !== 'object') {
|
|
209
|
+
throw new Error('Value argument must be an object');
|
|
210
|
+
}
|
|
211
|
+
if (!('attestationValue' in action.payload.value)) {
|
|
212
|
+
throw new Error('Value argument must contain an attestationValue property');
|
|
213
|
+
}
|
|
214
|
+
collector.input.value = action.payload.value;
|
|
215
|
+
}
|
|
216
|
+
if (collector.type === 'FidoAuthenticationCollector') {
|
|
217
|
+
if (typeof action.payload.id !== 'string') {
|
|
218
|
+
throw new Error('Index argument must be a string');
|
|
219
|
+
}
|
|
220
|
+
if (typeof action.payload.value !== 'object') {
|
|
221
|
+
throw new Error('Value argument must be an object');
|
|
222
|
+
}
|
|
223
|
+
if (!('assertionValue' in action.payload.value)) {
|
|
224
|
+
throw new Error('Value argument must contain an assertionValue property');
|
|
225
|
+
}
|
|
226
|
+
collector.input.value = action.payload.value;
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
//# sourceMappingURL=node.reducer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.reducer.js","sourceRoot":"","sources":["../../../src/lib/node.reducer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE/D;;GAEG;AACH,OA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