@zyphe-sdk/core 0.1.6 → 0.1.7
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.
- package/.turbo/turbo-build.log +2 -2
- package/README.md +68 -8
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @zyphe-sdk/core@0.1.
|
|
3
|
+
> @zyphe-sdk/core@0.1.7 build /Users/mtumiati/dev/zyphe/zyphe-sdk/packages/core
|
|
4
4
|
> tsup
|
|
5
5
|
|
|
6
6
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -17,6 +17,6 @@
|
|
|
17
17
|
[32mCJS[39m [1mdist/index.cjs.map [22m[32m9.63 KB[39m
|
|
18
18
|
[32mCJS[39m ⚡️ Build success in 13ms
|
|
19
19
|
DTS Build start
|
|
20
|
-
DTS ⚡️ Build success in
|
|
20
|
+
DTS ⚡️ Build success in 609ms
|
|
21
21
|
DTS dist/index.d.ts 61.70 KB
|
|
22
22
|
DTS dist/index.d.cts 61.70 KB
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Zyphe SDK – Core
|
|
1
|
+
# Zyphe SDK – Core
|
|
2
2
|
|
|
3
|
-
This is the core SDK package for Zyphe. It contains utilities to interact with Zyphe platform.
|
|
3
|
+
This is the core SDK package for Zyphe. It contains utilities to interact with the Zyphe platform, including webhook signature verification and verification session management.
|
|
4
4
|
|
|
5
5
|
## Installing package
|
|
6
6
|
|
|
@@ -12,14 +12,13 @@ pnpm install @zyphe-sdk/core
|
|
|
12
12
|
|
|
13
13
|
Then import and use the package in your project as described in the Usage section.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
---
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
This package provides the core webhook signature verification logic for Zyphe. It enables secure verification of incoming webhook requests in both Node.js and browser environments using HMAC-SHA256 signatures.
|
|
17
|
+
## 1. Webhook Signature Verification
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
This package provides the core webhook signature verification logic for Zyphe. It enables secure verification of incoming webhook requests in both Node.js and browser environments using HMAC-SHA256 signatures.
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
### Basic Usage
|
|
23
22
|
|
|
24
23
|
```ts
|
|
25
24
|
import { verifyWebhookSignature } from "@zyphe-sdk/core";
|
|
@@ -41,8 +40,69 @@ if (isValid) {
|
|
|
41
40
|
- `signatureHeader`: The signature header string, e.g. `t=1234567890,v0=abcdef...`.
|
|
42
41
|
- Returns: A Promise that resolves to `true` if the signature is valid, or `false` otherwise.
|
|
43
42
|
|
|
44
|
-
|
|
43
|
+
#### Advanced Utilities
|
|
44
|
+
- `parseSignatureHeader(signatureHeader)` – Parse the signature header into timestamp and signature.
|
|
45
|
+
- `hexToBytes(hex)` / `bufferToHex(buffer)` – Convert between hex and bytes.
|
|
46
|
+
- `timingSafeEqual(a, b)` – Constant-time string comparison.
|
|
47
|
+
- Error codes/messages for robust error handling.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 2. Verification Session Management
|
|
52
|
+
|
|
53
|
+
You can programmatically create verification sessions and construct user-facing URLs for onboarding flows.
|
|
54
|
+
|
|
55
|
+
### Create a Verification Session
|
|
56
|
+
```ts
|
|
57
|
+
import { createVerificationSession } from "@zyphe-sdk/core";
|
|
58
|
+
|
|
59
|
+
const response = await createVerificationSession(
|
|
60
|
+
"user@example.com", // email
|
|
61
|
+
"<flowId>", // flowId
|
|
62
|
+
"<flowStepId>", // flowStepId
|
|
63
|
+
false, // isSandbox
|
|
64
|
+
{
|
|
65
|
+
apiKey: "<your-api-key>",
|
|
66
|
+
environment: "staging", // or "production", "local"
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Construct a Verification Session URL
|
|
72
|
+
```ts
|
|
73
|
+
import { constructVerificationSessionUrl } from "@zyphe-sdk/core";
|
|
74
|
+
|
|
75
|
+
const url = constructVerificationSessionUrl({
|
|
76
|
+
flowParams: {
|
|
77
|
+
flowId: "...",
|
|
78
|
+
flowStepId: "...",
|
|
79
|
+
email: "user@example.com",
|
|
80
|
+
product: "kyc",
|
|
81
|
+
isSandbox: false,
|
|
82
|
+
},
|
|
83
|
+
verificationSession: response.data, // from createVerificationSession
|
|
84
|
+
opts: {
|
|
85
|
+
apiKey: "<your-api-key>",
|
|
86
|
+
environment: "staging",
|
|
87
|
+
handoffBaseUrl: "https://your-app.com",
|
|
88
|
+
primaryColor: "#000000",
|
|
89
|
+
secondaryColor: "#ffffff",
|
|
90
|
+
isFullscreen: true,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 3. Types and Configuration
|
|
98
|
+
|
|
99
|
+
- `InitializeZypheFlowParams`, `SDKOptions`, `SdkCreateVerificationRequestResponse` – for type-safe integration.
|
|
100
|
+
- `Environments`, `EnvironmentConfigs`, `API_KEY_HEADER` – for environment and API configuration.
|
|
101
|
+
|
|
102
|
+
---
|
|
45
103
|
|
|
104
|
+
## Resources
|
|
105
|
+
- See the dedicated middleware packages for Express, Fastify, Hono, and NestJS for webhook signature verification in those frameworks.
|
|
46
106
|
|
|
47
107
|
---
|
|
48
108
|
Made with ❤️ by Zyphe Inc
|
package/package.json
CHANGED