@lu71/sdk 0.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.
@@ -0,0 +1,69 @@
1
+ export interface Lu71Config {
2
+ apiKey: string;
3
+ baseUrl?: string;
4
+ }
5
+
6
+ export interface CaptureIntentParams {
7
+ agentId?: string;
8
+ description: string;
9
+ merchant?: string;
10
+ maxAmount: number;
11
+ currency?: string;
12
+ constraints?: Record<string, string>;
13
+ }
14
+
15
+ export interface CaptureIntentResponse {
16
+ intentId: string;
17
+ signature: string;
18
+ createdAt: string;
19
+ }
20
+
21
+ export interface FileDisputeParams {
22
+ agentId?: string;
23
+ intentId: string;
24
+ intentSignature: string;
25
+ transactionId: string;
26
+ reason: "not_received" | "not_as_described" | "duplicate" | "unauthorized" | "cancelled" | "service_not_rendered" | "other";
27
+ amount?: number;
28
+ description: string;
29
+ evidence?: {
30
+ whatWasReceived: string;
31
+ explanation?: string;
32
+ expectedAt?: string;
33
+ receivedAt?: string;
34
+ canceledAt?: string;
35
+ returnedAt?: string;
36
+ returnStatus?: "merchant_rejected" | "successful" | "not_applicable";
37
+ returnDescription?: string;
38
+ cancellationReason?: string;
39
+ productDescription?: string;
40
+ productType?: "merchandise" | "service" | "digital_goods";
41
+ originalTransactionId?: string;
42
+ supportingDocs?: string[];
43
+ additionalContext?: string;
44
+ };
45
+ }
46
+
47
+ export interface FileDisputeResponse {
48
+ disputeId: string;
49
+ status: string;
50
+ platformDisputeId: string;
51
+ }
52
+
53
+ export declare class Lu71 {
54
+ constructor(config: Lu71Config);
55
+ captureIntent(params: CaptureIntentParams): Promise<CaptureIntentResponse>;
56
+ fileDispute(params: FileDisputeParams): Promise<FileDisputeResponse>;
57
+ getDispute(disputeId: string): Promise<any>;
58
+ listDisputes(): Promise<any[]>;
59
+ getStripeConnectUrl(): Promise<{ url: string }>;
60
+ connectLithic(apiKey: string): Promise<{ message: string }>;
61
+ configureWebhook(url: string): Promise<{ webhookUrl: string; webhookSecret: string; events: string[] }>;
62
+ disconnect(platform: string): Promise<{ message: string }>;
63
+ }
64
+
65
+ export declare class Lu71Error extends Error {
66
+ status: number;
67
+ details?: unknown;
68
+ constructor(message: string, status: number, details?: unknown);
69
+ }
package/dist/index.js ADDED
@@ -0,0 +1,79 @@
1
+ import { createRequire } from "node:module";
2
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
+
4
+ // src/index.ts
5
+ class Lu71 {
6
+ apiKey;
7
+ baseUrl;
8
+ constructor(config) {
9
+ this.apiKey = config.apiKey;
10
+ this.baseUrl = config.baseUrl || "https://api.getlu71.com";
11
+ }
12
+ async request(path, opts = {}) {
13
+ const res = await fetch(`${this.baseUrl}${path}`, {
14
+ ...opts,
15
+ headers: {
16
+ "x-api-key": this.apiKey,
17
+ "Content-Type": "application/json",
18
+ ...opts.headers
19
+ }
20
+ });
21
+ const data = await res.json();
22
+ if (!res.ok)
23
+ throw new Lu71Error(data.message || "Request failed", res.status, data.details);
24
+ return data;
25
+ }
26
+ async getStripeConnectUrl() {
27
+ return this.request("/v1/connect/stripe/authorize");
28
+ }
29
+ async connectLithic(apiKey) {
30
+ return this.request("/v1/connect/lithic", { method: "POST", body: JSON.stringify({ apiKey }) });
31
+ }
32
+ async listConnections() {
33
+ return this.request("/v1/connect");
34
+ }
35
+ async disconnect(platform) {
36
+ return this.request(`/v1/connect/${platform}`, { method: "DELETE" });
37
+ }
38
+ async configureWebhook(url) {
39
+ return this.request("/v1/connect/webhooks", { method: "POST", body: JSON.stringify({ url }) });
40
+ }
41
+ static verifyWebhook(body, signature, secret) {
42
+ const { createHmac } = __require("crypto");
43
+ const expected = createHmac("sha256", secret).update(body).digest("hex");
44
+ return signature === expected;
45
+ }
46
+ async captureIntent(params) {
47
+ return this.request("/v1/intents", { method: "POST", body: JSON.stringify(params) });
48
+ }
49
+ async fileDispute(params) {
50
+ return this.request("/v1/disputes", { method: "POST", body: JSON.stringify(params) });
51
+ }
52
+ async getDispute(disputeId) {
53
+ return this.request(`/v1/disputes/${disputeId}`);
54
+ }
55
+ async listDisputes(agentId) {
56
+ const query = agentId ? `?agentId=${agentId}` : "";
57
+ return this.request(`/v1/disputes${query}`);
58
+ }
59
+ async registerAgent(params) {
60
+ return this.request("/v1/agents", { method: "POST", body: JSON.stringify(params) });
61
+ }
62
+ }
63
+
64
+ class Lu71Error extends Error {
65
+ status;
66
+ details;
67
+ constructor(message, status, details) {
68
+ super(message);
69
+ this.name = "Lu71Error";
70
+ this.status = status;
71
+ this.details = details;
72
+ }
73
+ }
74
+ var src_default = Lu71;
75
+ export {
76
+ src_default as default,
77
+ Lu71Error,
78
+ Lu71
79
+ };
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@lu71/sdk",
3
+ "version": "0.1.0",
4
+ "description": "Lu71 — Agent purchase protection SDK",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "files": ["dist"],
8
+ "scripts": {
9
+ "build": "bun build src/index.ts --outdir=dist --target=node && bun x tsc --declaration --emitDeclarationOnly --outDir dist"
10
+ },
11
+ "license": "MIT",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/TusharPardhe/lu71"
15
+ }
16
+ }