@outseta/node-sdk 0.2.1 → 0.2.2

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 (2) hide show
  1. package/dist/index.js +24 -3
  2. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -1,6 +1,27 @@
1
- // src/index.ts
2
- import { createClient } from "@outseta/api-client";
3
-
1
+ // ../api-client/src/client.ts
2
+ function getAuthorization(creds) {
3
+ if ("accessToken" in creds) {
4
+ return `Bearer ${creds.accessToken}`;
5
+ }
6
+ return `Outseta ${creds.apiKey}:${creds.apiSecret}`;
7
+ }
8
+ function getRequestUrl(subdomain, path) {
9
+ if (/^https?:\/\//.test(path)) {
10
+ return path;
11
+ }
12
+ const normalizedPath = path.startsWith("/api/v1/") ? path : `/api/v1/${path.replace(/^\/+/, "")}`;
13
+ return new URL(normalizedPath, `https://${subdomain}.outseta.com`).toString();
14
+ }
15
+ function createClient(creds) {
16
+ return (path, init = {}) => {
17
+ const headers = new Headers(init.headers);
18
+ headers.set("Authorization", getAuthorization(creds));
19
+ return fetch(getRequestUrl(creds.subdomain, path), {
20
+ ...init,
21
+ headers
22
+ });
23
+ };
24
+ }
4
25
  // src/verify-webhook.ts
5
26
  import { createHmac, timingSafeEqual } from "node:crypto";
6
27
  function verifyWebhookSignature(signature, body, signingKey) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outseta/node-sdk",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Node.js SDK for the Outseta API",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -17,14 +17,9 @@
17
17
  "import": "./dist/index.js"
18
18
  }
19
19
  },
20
- "scripts": {
21
- "build": "rimraf dist && bun build src/index.ts --outdir dist --target node --format esm --packages external",
22
- "typecheck": "tsc --noEmit",
23
- "lint": "eslint src"
24
- },
25
20
  "dependencies": {
26
- "@outseta/api-client": "*",
27
- "jose": "^6.2.1"
21
+ "jose": "^6.2.1",
22
+ "@outseta/api-client": "0.2.4"
28
23
  },
29
24
  "devDependencies": {
30
25
  "typescript": "^5.7.0"
@@ -36,5 +31,10 @@
36
31
  "publishConfig": {
37
32
  "access": "public",
38
33
  "provenance": true
34
+ },
35
+ "scripts": {
36
+ "build": "rimraf dist && bun build src/index.ts --outdir dist --target node --format esm --packages external",
37
+ "typecheck": "tsc --noEmit",
38
+ "lint": "eslint src"
39
39
  }
40
- }
40
+ }