{"id":26086897,"url":"https://github.com/pspdfkit/pspdfkit-web-cloudhsm-signing-example","last_synced_at":"2026-04-22T10:33:34.594Z","repository":{"id":194823429,"uuid":"602664004","full_name":"PSPDFKit/pspdfkit-web-cloudhsm-signing-example","owner":"PSPDFKit","description":"Example that shows how to integrate AWS CloudHSM to produce signatures for PSPDFKit for Web","archived":false,"fork":false,"pushed_at":"2023-03-24T13:57:51.000Z","size":15,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-03-09T07:18:59.534Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/PSPDFKit.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}},"created_at":"2023-02-16T17:26:45.000Z","updated_at":"2024-03-07T22:58:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"f5a4d2eb-b1b1-444d-9c3b-fb75edae0fc6","html_url":"https://github.com/PSPDFKit/pspdfkit-web-cloudhsm-signing-example","commit_stats":null,"previous_names":["pspdfkit/pspdfkit-web-cloudhsm-signing-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PSPDFKit/pspdfkit-web-cloudhsm-signing-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSPDFKit%2Fpspdfkit-web-cloudhsm-signing-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSPDFKit%2Fpspdfkit-web-cloudhsm-signing-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSPDFKit%2Fpspdfkit-web-cloudhsm-signing-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSPDFKit%2Fpspdfkit-web-cloudhsm-signing-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PSPDFKit","download_url":"https://codeload.github.com/PSPDFKit/pspdfkit-web-cloudhsm-signing-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSPDFKit%2Fpspdfkit-web-cloudhsm-signing-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32132478,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T08:34:57.708Z","status":"ssl_error","status_checked_at":"2026-04-22T08:34:55.583Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2025-03-09T07:18:50.428Z","updated_at":"2026-04-22T10:33:34.578Z","avatar_url":"https://github.com/PSPDFKit.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PSPDFKit for Web + AWS CloudHSM Signing example\n\nThis Node application is a Web Server that implements a digital signing service that performs the signing via a [HSM](https://en.wikipedia.org/wiki/Hardware_security_module) exposed via the AWS CloudHSM service.\n\n## Setup\n\n* Install depedencies with `npm install`.\n* If you'd like to run the example using a self-signed CA certificate, follow the instructions in `ca-sign/README.md` or simply go to that directory and run the `generate-certificate.sh` script.\n* Start the server via  `PIN=\u003cmy-login-credentials\u003e node index.js`, where `\u003cmy-login-credentials\u003e` needs to be replaced with the credentials of a valid [Crypto user](https://docs.aws.amazon.com/cloudhsm/latest/userguide/manage-hsm-users.html#crypto-user) of the HSM. These crendetials need to be provided in a `user:password` syntax.\n\ne.g.:\n\n```\nPIN=user:pass node index.js\n```\n\n* On PSPDFKit for Web Standalone, you can implement a logic similar to perform the HTTP calls to perform the signing:\n\n```js\nasync function generatePKCS7({ fileContents, hash }) {\n  const encodedContents = btoa(String.fromCharCode.apply(null, new Uint8Array(fileContents)));\n\n  const response = await fetch(\"http://\u003cyour-url\u003e/sign?mode=ca\", {\n    method: \"POST\",\n    body: JSON.stringify({\n      hash,\n      encodedContents\n    }),\n    headers: {\n      \"Content-Type\": \"application/json\"\n    }\n  });\n  const json = await response.json();\n\n  const arrayBuffer = base64ToArrayBuffer(json.p7);\n\n  return arrayBuffer;\n}\n\nfunction base64ToArrayBuffer(base64) {\n  var binary_string = window.atob(base64);\n  var len = binary_string.length;\n  var bytes = new Uint8Array(len);\n\n  for (var i = 0; i \u003c len; i++) {\n    bytes[i] = binary_string.charCodeAt(i);\n  }\n\n  return bytes.buffer;\n}\n```\n\nWhere `\u003cyour-url\u003e` needs to be replaced with a valid URL pointing to this running Node.js HTTP Server.\n\nNote the presence of a `?mode=ca` query parameter in the URL. You can remove it to use a self-signed certificate instead.\n\nHere's how one would use the PSPDFKit for Web API to start the signing:\n\n```js\ninstance.signDocument(null, generatePKCS7);\n```\n\n## Related resources\n\n* [AWS CloudHSM Getting Started Guide](https://docs.aws.amazon.com/cloudhsm/latest/userguide/getting-started.html)\n* [How to create new Crypto Users in the HSM](https://docs.aws.amazon.com/cloudhsm/latest/userguide/cli-users.html)\n* [How to setup PKCS#11 support in the EC2 instance](https://docs.aws.amazon.com/cloudhsm/latest/userguide/pkcs11-library-install.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpspdfkit%2Fpspdfkit-web-cloudhsm-signing-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpspdfkit%2Fpspdfkit-web-cloudhsm-signing-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpspdfkit%2Fpspdfkit-web-cloudhsm-signing-example/lists"}