{"id":18328381,"url":"https://github.com/thorstenhans/spin-compose","last_synced_at":"2025-09-10T07:46:20.700Z","repository":{"id":224601267,"uuid":"763711316","full_name":"ThorstenHans/spin-compose","owner":"ThorstenHans","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-05T14:57:23.000Z","size":2751,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T16:57:18.730Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThorstenHans.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-26T19:33:37.000Z","updated_at":"2024-02-29T15:33:24.000Z","dependencies_parsed_at":"2024-12-23T12:31:52.624Z","dependency_job_id":"313fa05d-5721-411d-8817-8ef008dbff18","html_url":"https://github.com/ThorstenHans/spin-compose","commit_stats":null,"previous_names":["thorstenhans/spin-compose"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ThorstenHans/spin-compose","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThorstenHans%2Fspin-compose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThorstenHans%2Fspin-compose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThorstenHans%2Fspin-compose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThorstenHans%2Fspin-compose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThorstenHans","download_url":"https://codeload.github.com/ThorstenHans/spin-compose/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThorstenHans%2Fspin-compose/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259935061,"owners_count":22934338,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T19:13:56.160Z","updated_at":"2025-06-15T06:39:28.738Z","avatar_url":"https://github.com/ThorstenHans.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Composition Example\n\nThis sample demonstrates how to use WebAssembly Components within a Spin application.\n\n## Apps\n\n- [API](./api/) - a HTTP API that can be used to register for webhooks and fire them\n- [Consumer](./consumer/) - a sample webhook consumer\n\n## Middlewares\n\n- [hmac](./hmac/) - provides capabilities to `sign` data and `verify` those signatures\n\n## Prerequisites\n\n- [Rust](https://rust-lang.org) with `wasm32-wasi` target must be installed\n- [Cargo Component](https://github.com/bytecodealliance/cargo-component) must be installed\n- [Wasm Tools](https://github.com/bytecodealliance/wasm-tools) must be installed\n- [Spin](https://developer.fermyon.com/spin) must be installed\n\n## Building the sample\n\nUse the [build.sh](./build.sh) script to compile and compose all necessary Wasm Components.\n\n## Running the sample\n\n- In a dedicated terminal instance invoke `cd api \u0026\u0026 spin up --sqlite @migration.sql`\n- In a dedicated terminal instance invoke `cd consumer \u0026\u0026 spin up --listen 127.0.0.1:3001 --sqlite @migration.sql`\n\n## Using the sample with `tests.restbook`\n\nYou can use [`tests.restbook`](./tests.restbook) for using the sample. To do so, install the `tanhakabir.rest-book` extension first, and follow the instructions mentioned in the notebook.\n\n## Using the sample\n\nRegister the webhook consumer as shown here:\n\n```\ncurl -X POST http://localhost:3000/register \\\n -H 'Content-Type:application/json' \\\n -d '{ \"url\": \"http://localhost:3001/target\", \"event\": \"sample_event\"}'\n```\n\n- The request above is handled by the [api](./api/), the consumer is stored in the sqlite database.\n- [api](./api/) generates unique key data for the consumer\n- [api](./api/) invokes `http://localhost:3001/target?handshake=true` via `POST` and sends the key data as payload (`{\"keyData\": \"\"}`)\n- [consumer](./consumer/) stores key data in its database (dedicated sqlite database)\n- [consumer](./consumer/) must respond with `200` otherwise registration fails\n- [api](./api) returns `201` if succeeded\n\nDemonstrate webhook firing\n\n```bash\ncurl -X POST http://localhost:3000/fire\n```\n\n- The request above is handled by [api](./api/)\n- All webhook registrations are loaded from sqlite\n- A sample payload is created\n- for every registration\n  - payload is singed with the registration specific key data using `hmac` (implemented in [hmac](./hmac/) (dedicated Wasm component))\n  - signature is set as HTTP header `X-Signature`\n  - outbound http request is sent via `POST` to the url of the registration\n  - [consumer](./consumer/) endpoint is invoked\n    - the key data is loaded from consumer's database\n    - signature is read from incoming HTTP header `X-Signature`\n    - data is read from request body\n    - `hmac` is verified (implemented in [hmac](./hmac/) (dedicated Wasm component))\n    - if signature is **valid** `200` is returned\n    - if signature is **invalid** `500` is returned\n  - HTTP response code of the consumer is logged to `stdout`\n- [api](./api/) returns with `200`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthorstenhans%2Fspin-compose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthorstenhans%2Fspin-compose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthorstenhans%2Fspin-compose/lists"}