Skip to content

Commit 9198a76

Browse files
committed
fix: fido-errors
1 parent b6d3630 commit 9198a76

8 files changed

Lines changed: 710 additions & 37 deletions

File tree

.changeset/fido-error-codes.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@forgerock/davinci-client': patch
3+
---
4+
5+
Add WebAuthn error code propagation for FIDO operations
6+
7+
- FIDO registration and authentication errors now include the WebAuthn error code in the `code` field of `GenericError`
8+
- Supported error codes: `NotAllowedError`, `AbortError`, `InvalidStateError`, `NotSupportedError`, `SecurityError`, `TimeoutError`, `UnknownError`
9+
- Added optional `FidoClientConfig` parameter to `fido()` for logger configuration
10+
- Replaced `console.error` with SDK logger
11+
- Added `formData: {}` to `transformActionRequest()` for API contract consistency
12+
13+
Consumers can propagate FIDO errors to DaVinci using `client.flow({ action: result.code })()`.

packages/davinci-client/src/lib/davinci.utils.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,40 @@ describe('transformActionRequest', () => {
147147
eventType: 'action',
148148
data: {
149149
actionKey: 'TEST_ACTION',
150+
formData: {},
150151
},
151152
},
152153
};
153154

154155
const result = transformActionRequest(node, action, logger({ level: 'none' }));
155156
expect(result).toEqual(expectedRequest);
156157
});
158+
159+
it('should include empty formData for FIDO error codes', () => {
160+
const node: ContinueNode = {
161+
cache: { key: '123' },
162+
client: {
163+
action: 'SIGNON',
164+
collectors: [],
165+
status: 'continue' as const,
166+
},
167+
error: null,
168+
httpStatus: 200,
169+
server: {
170+
id: '123',
171+
eventName: 'click',
172+
interactionId: '456',
173+
status: 'continue' as const,
174+
},
175+
status: 'continue' as const,
176+
};
177+
178+
const result = transformActionRequest(node, 'NotAllowedError', logger({ level: 'none' }));
179+
180+
expect(result.parameters.eventType).toBe('action');
181+
expect(result.parameters.data.actionKey).toBe('NotAllowedError');
182+
expect(result.parameters.data.formData).toEqual({});
183+
});
157184
});
158185

159186
describe('handleResponse', () => {

packages/davinci-client/src/lib/davinci.utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export function transformActionRequest(
9898
eventType: 'action',
9999
data: {
100100
actionKey: action,
101+
formData: {},
101102
},
102103
},
103104
};

0 commit comments

Comments
 (0)