@openfort/openfort-node 0.6.78 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/Makefile +75 -0
  3. package/README.md +174 -65
  4. package/biome.json +34 -4
  5. package/dist/index.d.mts +8860 -14863
  6. package/dist/index.d.ts +8860 -14863
  7. package/dist/index.js +4967 -24180
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +4666 -23904
  10. package/dist/index.mjs.map +1 -1
  11. package/examples/.env.example +16 -0
  12. package/examples/README.md +157 -0
  13. package/examples/contracts/createContract.ts +25 -0
  14. package/examples/contracts/listContracts.ts +18 -0
  15. package/examples/evm/accounts/createAccount.ts +18 -0
  16. package/examples/evm/accounts/exportAccount.ts +39 -0
  17. package/examples/evm/accounts/getAccount.ts +30 -0
  18. package/examples/evm/accounts/importAccount.ts +31 -0
  19. package/examples/evm/accounts/listAccounts.ts +32 -0
  20. package/examples/evm/embedded/pregenerate.ts +33 -0
  21. package/examples/evm/signing/signHash.ts +28 -0
  22. package/examples/evm/signing/signMessage.ts +32 -0
  23. package/examples/evm/signing/signTransaction.ts +42 -0
  24. package/examples/evm/signing/signTypedData.ts +71 -0
  25. package/examples/exchange/createSwap.ts +49 -0
  26. package/examples/exchange/quoteSwap.ts +34 -0
  27. package/examples/iam/deleteUser.ts +22 -0
  28. package/examples/iam/getSession.ts +30 -0
  29. package/examples/iam/getUser.ts +32 -0
  30. package/examples/iam/listUsers.ts +18 -0
  31. package/examples/package.json +31 -0
  32. package/examples/pnpm-lock.yaml +1231 -0
  33. package/examples/policies/createPolicy.ts +25 -0
  34. package/examples/policies/createPolicyRule.ts +43 -0
  35. package/examples/policies/disableEnablePolicy.ts +29 -0
  36. package/examples/policies/getPolicy.ts +30 -0
  37. package/examples/policies/listPolicies.ts +17 -0
  38. package/examples/policies/listPolicyRules.ts +37 -0
  39. package/examples/policies/updatePolicy.ts +29 -0
  40. package/examples/solana/accounts/createAccount.ts +18 -0
  41. package/examples/solana/accounts/exportAccount.ts +29 -0
  42. package/examples/solana/accounts/getAccount.ts +24 -0
  43. package/examples/solana/accounts/importAccount.ts +28 -0
  44. package/examples/solana/accounts/listAccounts.ts +32 -0
  45. package/examples/solana/signing/signMessage.ts +22 -0
  46. package/examples/solana/signing/signTransaction.ts +41 -0
  47. package/examples/transactions/createTransactionIntent.ts +54 -0
  48. package/examples/transactions/estimateGas.ts +62 -0
  49. package/examples/transactions/getTransactionIntent.ts +65 -0
  50. package/examples/transactions/listTransactionIntents.ts +31 -0
  51. package/examples/tsconfig.json +15 -0
  52. package/examples/webhook/index.ts +43 -0
  53. package/openapi-auth.json +6526 -0
  54. package/openapi.json +20425 -0
  55. package/orval.config.ts +41 -0
  56. package/package.json +22 -12
  57. package/pnpm-workspace.yaml +2 -0
  58. package/tsconfig.json +1 -1
  59. package/vitest.config.ts +20 -0
  60. package/updateGeneratedCode.sh +0 -8
@@ -0,0 +1,43 @@
1
+ import express, { type Request, type Response } from "express";
2
+ import "dotenv/config";
3
+ import Openfort from "@openfort/openfort-node";
4
+
5
+ interface WebhookEvent {
6
+ type: string;
7
+ data: {
8
+ id: string;
9
+ [key: string]: unknown;
10
+ };
11
+ }
12
+
13
+ const app = express();
14
+ const port = process.env.APP_PORT || "3001";
15
+
16
+ app.post(
17
+ "/webhook/openfort",
18
+ express.raw({ type: "application/json" }),
19
+ async (req: Request, res: Response) => {
20
+ const openfort = new Openfort(process.env.OPENFORT_API_KEY!, {
21
+ basePath: process.env.OPENFORT_BASE_URL,
22
+ });
23
+ try {
24
+ const signature = req.headers["openfort-signature"];
25
+ if (typeof signature !== "string") {
26
+ throw new Error("Missing or invalid openfort-signature header");
27
+ }
28
+ const event = await openfort.constructWebhookEvent<WebhookEvent>(
29
+ req.body.toString(),
30
+ signature,
31
+ );
32
+ console.info("Received webhook event:", event.type, event.data.id);
33
+ res.status(200).send("OK");
34
+ } catch (e) {
35
+ console.error((e as Error).message);
36
+ res.status(400).send("Invalid webhook");
37
+ }
38
+ },
39
+ );
40
+
41
+ app.listen(port, () => {
42
+ console.info(`Server is running on http://localhost:${port}`);
43
+ });