Skip to content

Conversation

@sufyankhanrao
Copy link
Collaborator

What

  • Added framework-agnostic request snapshot model for verifiers and event parsing.
  • Implemented a configurable generic HMAC verifier supporting headers, ordering, delimiter, encoder, and hash algorithm.
  • Introduced JSON Pointer–based parsing templates for flexible event payload extraction.
  • Wrote unit tests for verifier configurations, JSON Pointer resolution, event parsing, and request immutability.
  • Updated documentation to include setup and usage guidance.

Why

To establish a solid foundation for Webhooks and Callbacks in the Python core library.
These additions provide secure, consistent handling of webhook events across SDKs while ensuring extensibility for future enhancements.

Closes #104

Type of change

Select multiple if applicable.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause a breaking change)
  • Tests (adds or updates tests)
  • Documentation (adds or updates documentation)
  • Refactor (style improvements, performance improvements, code refactoring)
  • Revert (reverts a commit)
  • CI/Build (adds or updates a script, change in external dependencies)

Dependency Change

If a new dependency is being added, please ensure that it adheres to the following guideline https://github.com/apimatic/apimatic-codegen/wiki/Policy-of-adding-new-dependencies-in-the-core-libraries

Breaking change

If the PR is introducing a breaking change, please ensure that it adheres to the following guideline https://github.com/apimatic/apimatic-codegen/wiki/Guidelines-for-maintaining-core-libraries

Testing

List the steps that were taken to test the changes

Checklist

  • My code follows the coding conventions
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added new unit tests

@sufyankhanrao sufyankhanrao self-assigned this Sep 1, 2025
@sufyankhanrao sufyankhanrao added the enhancement New feature or request label Sep 1, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive webhook and callback support to the Python core library by introducing a templating system for flexible message construction and an HMAC signature verification system. The implementation provides a framework-agnostic approach to handling webhook events with secure signature verification capabilities.

  • Introduces a template engine with JSON Pointer support for flexible message construction from HTTP requests
  • Implements configurable HMAC signature verification with multiple hash algorithms and encoding options
  • Adds comprehensive test coverage for all new components including edge cases and error handling

Reviewed Changes

Copilot reviewed 16 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
apimatic_core/templating/template_engine.py Core templating engine for parsing and rendering message templates with runtime expressions
apimatic_core/templating/template_resolver.py Built-in resolvers for extracting HTTP method, URL, headers, query params, and JSON body data
apimatic_core/templating/json_pointer_resolver.py RFC 6901 JSON Pointer implementation for extracting values from JSON request bodies
apimatic_core/security/hmac_signature_verifier.py HMAC signature verification with configurable templates, hash algorithms, and encoders
apimatic_core/security/encoders.py Digest encoding implementations (hex, base64, base64url)
apimatic_core/exceptions/signature_verification_error.py Custom exception for signature verification failures
tests/ Comprehensive test suites covering all new functionality with edge cases
setup.py Version bump to 0.2.22
README.md Updated documentation with new templating and security features

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@sufyankhanrao sufyankhanrao changed the title Webhooks support feat(webhooks & callbacks): add contracts for generic HMAC implementation Sep 1, 2025
@sufyankhanrao sufyankhanrao force-pushed the webhooks-support branch 2 times, most recently from 6142f23 to 9b78914 Compare September 5, 2025 13:33
@sufyankhanrao sufyankhanrao force-pushed the webhooks-support branch 3 times, most recently from b391792 to db79796 Compare September 8, 2025 19:34
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 3, 2025

@asadali214 asadali214 merged commit b24fb51 into main Oct 3, 2025
9 checks passed
@asadali214 asadali214 deleted the webhooks-support branch October 3, 2025 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Webhooks & Callbacks Support

3 participants