zeno.id 0.7.0 → 0.8.0
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/README.md +95 -113
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +24 -37
- package/dist/index.d.ts +24 -37
- package/dist/index.js +2 -2
- package/dist/server/index.cjs +1 -2
- package/dist/server/index.d.cts +159 -90
- package/dist/server/index.d.ts +159 -90
- package/dist/server/index.js +1 -2
- package/package.json +1 -14
- package/dist/server/node.cjs +0 -1
- package/dist/server/node.d.cts +0 -21
- package/dist/server/node.d.ts +0 -21
- package/dist/server/node.js +0 -1
- package/dist/server/proxy-CUZ-Jwgy.d.cts +0 -36
- package/dist/server/proxy-CUZ-Jwgy.d.ts +0 -36
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
//#region src/server/util.d.ts
|
|
2
|
-
/** The project's API key, `sk_...`, from your server's environment: `process.env.ZENO_API_KEY`. */
|
|
3
|
-
type ApiKey = string | undefined;
|
|
4
|
-
/** Options both createClient and createProxy take. */
|
|
5
|
-
type ApiOptions = {
|
|
6
|
-
/** The Zeno API's http(s) origin, for staging or a local Zeno. Zeno's own API by default. */
|
|
7
|
-
apiUrl?: string | undefined;
|
|
8
|
-
};
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/server/proxy.d.ts
|
|
11
|
-
type ProxyOptions = ApiOptions & {
|
|
12
|
-
/**
|
|
13
|
-
* The visitor id cookie's path: the path the browser calls the route on, by default the request's own. Set it when
|
|
14
|
-
* something in front of the handler rewrites the path (the site's `/zeno` handled at `/api/proxy`), else the
|
|
15
|
-
* browser keeps the cookie for a path it never calls and every visit is a new one.
|
|
16
|
-
*/
|
|
17
|
-
cookiePath?: string | undefined;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* The route's handler, `zeno(request, ip)`: a web `Request` in, a `Response` out. `ip` is the IP address the request
|
|
21
|
-
* came from, your framework's client IP; behind a proxy of your own, turn on your framework's trust-proxy setting so
|
|
22
|
-
* it's the visitor's. An identification without it answers `500`. Answer `GET` and `POST` on one path with it.
|
|
23
|
-
*/
|
|
24
|
-
type ProxyHandler = (request: Request, ip: string | null | undefined) => Promise<Response>;
|
|
25
|
-
/**
|
|
26
|
-
* The proxy route: a route on your own site between the browser SDK and the Zeno API. It serves the script's code,
|
|
27
|
-
* forwards its identifications with your API key and the visitor's ip, and keeps the visitor id in a first-party
|
|
28
|
-
* HttpOnly cookie. Answer `GET` and `POST` on one path of your choice (the one the browser's `start()` takes, `/zeno`
|
|
29
|
-
* by default) with what it returns, `zeno(request, ip)` with the IP address the request came from (`nodeHandler(zeno)`
|
|
30
|
-
* from `zeno.id/server/node` on Node's `(req, res)`). The `apiKey` (from your server's environment, undefined accepted)
|
|
31
|
-
* is checked on each request, so a module that makes it at load builds without the environment (as Next.js does when it
|
|
32
|
-
* collects page data); a request without it answers `500` and logs it.
|
|
33
|
-
*/
|
|
34
|
-
declare const createProxy: (apiKey: ApiKey, options?: ProxyOptions) => ProxyHandler;
|
|
35
|
-
//#endregion
|
|
36
|
-
export { ApiOptions as a, ApiKey as i, ProxyOptions as n, createProxy as r, ProxyHandler as t };
|