Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/fido-error-codes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@forgerock/davinci-client': patch
---

Add WebAuthn error code propagation for FIDO operations

- FIDO registration and authentication errors now include the WebAuthn error code in the `code` field of `GenericError`
- Supported error codes: `NotAllowedError`, `AbortError`, `InvalidStateError`, `NotSupportedError`, `SecurityError`, `TimeoutError`, `UnknownError`
- Added optional `FidoClientConfig` parameter to `fido()` for logger configuration
- Replaced `console.error` with SDK logger
- Added `formData: {}` to `transformActionRequest()` for API contract consistency

Consumers can propagate FIDO errors to DaVinci using `client.flow({ action: result.code })()`.
27 changes: 27 additions & 0 deletions packages/davinci-client/src/lib/davinci.utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,40 @@ describe('transformActionRequest', () => {
eventType: 'action',
data: {
actionKey: 'TEST_ACTION',
formData: {},
},
},
};

const result = transformActionRequest(node, action, logger({ level: 'none' }));
expect(result).toEqual(expectedRequest);
});

it('should include empty formData for FIDO error codes', () => {
const node: ContinueNode = {
cache: { key: '123' },
client: {
action: 'SIGNON',
collectors: [],
status: 'continue' as const,
},
error: null,
httpStatus: 200,
server: {
id: '123',
eventName: 'click',
interactionId: '456',
status: 'continue' as const,
},
status: 'continue' as const,
};

const result = transformActionRequest(node, 'NotAllowedError', logger({ level: 'none' }));

expect(result.parameters.eventType).toBe('action');
expect(result.parameters.data.actionKey).toBe('NotAllowedError');
expect(result.parameters.data.formData).toEqual({});
});
});

describe('handleResponse', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/davinci-client/src/lib/davinci.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export function transformActionRequest(
eventType: 'action',
data: {
actionKey: action,
formData: {},
},
},
};
Expand Down
Loading
Loading