@secondlayer/sdk 16.0.0 → 16.1.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 +5 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -1
- package/dist/index.js.map +3 -3
- package/dist/streams/index.js +5 -1
- package/dist/streams/index.js.map +3 -3
- package/dist/subgraphs/index.js +5 -1
- package/dist/subgraphs/index.js.map +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,13 +15,13 @@ import { SecondLayer } from "@secondlayer/sdk";
|
|
|
15
15
|
|
|
16
16
|
const sl = new SecondLayer({
|
|
17
17
|
apiKey: process.env.INSTANCE_TOKEN, // from secondlayer init; read from the env when omitted
|
|
18
|
-
// default baseUrl: http://127.0.0.1:3800
|
|
18
|
+
// default baseUrl: SECONDLAYER_API_URL, else http://127.0.0.1:3800
|
|
19
19
|
});
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
Hosted:
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
Hosted: set `SECONDLAYER_API_KEY` (`sk-sl_*`) and the client uses
|
|
23
|
+
`https://api.secondlayer.tools`. Self-host: use `INSTANCE_TOKEN` as below, which
|
|
24
|
+
keeps the client on your instance even with an account key set. The key follows the host.
|
|
25
25
|
|
|
26
26
|
Auth, once (self-hosted instance): `sl.index`, `sl.streams`, `sl.subgraphs.rows`, and the typed
|
|
27
27
|
`subscribe` read `/v1`, which is open on loopback and needs `INSTANCE_TOKEN`
|
|
@@ -585,7 +585,7 @@ Every delivery, any `format`, also carries a universal authenticity
|
|
|
585
585
|
signature you can verify with one published key, no per-webhook secret. The
|
|
586
586
|
headers are `webhook-id`, `x-secondlayer-signature`, and
|
|
587
587
|
`x-secondlayer-signature-keyid`; the signed content is `` `${webhook-id}.${rawBody}` ``
|
|
588
|
-
(ed25519). Fetch the public key from `GET /
|
|
588
|
+
(ed25519). Fetch the public key from `GET /api/webhooks/signing-key`, which takes your account key.
|
|
589
589
|
|
|
590
590
|
```typescript
|
|
591
591
|
import { verifySecondlayerSignature } from "@secondlayer/sdk";
|
package/dist/index.d.ts
CHANGED
|
@@ -298,8 +298,8 @@ type RequestOptions = {
|
|
|
298
298
|
* signal's reason, an `AbortError` by default, never an `ApiError`. */
|
|
299
299
|
signal?: AbortSignal;
|
|
300
300
|
};
|
|
301
|
-
/**
|
|
302
|
-
* `SECONDLAYER_API_URL`. */
|
|
301
|
+
/** Default when nothing points at the hosted API: the local one-box API.
|
|
302
|
+
* Override with `baseUrl` or `SECONDLAYER_API_URL`. */
|
|
303
303
|
declare const LOCAL_API_URL = "http://127.0.0.1:3800";
|
|
304
304
|
/** Instance credential. `secondlayer init` writes this. */
|
|
305
305
|
declare const INSTANCE_TOKEN_ENV = "INSTANCE_TOKEN";
|
package/dist/index.js
CHANGED
|
@@ -214,6 +214,7 @@ function raceAbort(promise, signal) {
|
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
var LOCAL_API_URL = "http://127.0.0.1:3800";
|
|
217
|
+
var HOSTED_API_URL = "https://api.secondlayer.tools";
|
|
217
218
|
var INSTANCE_TOKEN_ENV = "INSTANCE_TOKEN";
|
|
218
219
|
var ACCOUNT_KEY_ENV = "SECONDLAYER_API_KEY";
|
|
219
220
|
function resolveBaseUrl(explicit) {
|
|
@@ -223,6 +224,9 @@ function resolveBaseUrl(explicit) {
|
|
|
223
224
|
const primary = process.env?.SECONDLAYER_API_URL || undefined;
|
|
224
225
|
if (primary)
|
|
225
226
|
return primary.replace(/\/+$/, "");
|
|
227
|
+
if (process.env?.[ACCOUNT_KEY_ENV]?.startsWith("sk-sl_") && !process.env?.[INSTANCE_TOKEN_ENV]) {
|
|
228
|
+
return HOSTED_API_URL;
|
|
229
|
+
}
|
|
226
230
|
}
|
|
227
231
|
return LOCAL_API_URL;
|
|
228
232
|
}
|
|
@@ -3418,5 +3422,5 @@ export {
|
|
|
3418
3422
|
verifyWebhookSignature
|
|
3419
3423
|
};
|
|
3420
3424
|
|
|
3421
|
-
//# debugId=
|
|
3425
|
+
//# debugId=8E37F0B7E094194F64756E2164756E21
|
|
3422
3426
|
//# sourceMappingURL=index.js.map
|