@ledewire/browser 0.6.1 → 0.7.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/dist/index.d.ts +290 -7
- package/dist/index.js +132 -41
- package/dist/index.js.map +1 -1
- package/dist/ledewire.min.js +1 -1
- package/dist/ledewire.min.js.map +1 -1
- package/llms.txt +24 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -50,6 +50,9 @@ export declare class AuthError extends LedewireError {
|
|
|
50
50
|
/** Request body for API key authentication (seller). */
|
|
51
51
|
declare type AuthLoginApiKeyRequest = components['schemas']['AuthLoginApiKeyRequest'];
|
|
52
52
|
|
|
53
|
+
/** Request body for authenticating as a buyer using a named API key + secret. */
|
|
54
|
+
declare type AuthLoginBuyerApiKeyRequest = components['schemas']['AuthLoginBuyerApiKeyRequest'];
|
|
55
|
+
|
|
53
56
|
/** Request body for buyer email/password login. */
|
|
54
57
|
declare type AuthLoginEmailRequest = components['schemas']['AuthLoginEmailRequest'];
|
|
55
58
|
|
|
@@ -130,6 +133,26 @@ declare class BrowserAuthNamespace {
|
|
|
130
133
|
* @returns The authentication token response.
|
|
131
134
|
*/
|
|
132
135
|
loginWithGoogle(body: AuthLoginOAuthRequest): Promise<AuthenticationResponse>;
|
|
136
|
+
/**
|
|
137
|
+
* Log in using a buyer API key and secret.
|
|
138
|
+
* Returns a buyer-scoped JWT, stored automatically after successful authentication.
|
|
139
|
+
*
|
|
140
|
+
* Primarily useful when building buyer-facing dashboards where the user
|
|
141
|
+
* has created a named API key and wishes to authenticate with it programmatically,
|
|
142
|
+
* or for agent workflows running inside a browser context.
|
|
143
|
+
*
|
|
144
|
+
* @param body - The buyer API key and secret.
|
|
145
|
+
* @returns The authentication token response.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts
|
|
149
|
+
* await lw.auth.loginWithBuyerApiKey({
|
|
150
|
+
* key: 'bktst_abc123',
|
|
151
|
+
* secret: 'deadbeef...',
|
|
152
|
+
* })
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
loginWithBuyerApiKey(body: AuthLoginBuyerApiKeyRequest): Promise<AuthenticationResponse>;
|
|
133
156
|
/**
|
|
134
157
|
* Request a password reset code to be sent to the buyer's email address.
|
|
135
158
|
*
|
|
@@ -192,6 +215,8 @@ declare class BrowserClient {
|
|
|
192
215
|
readonly content: BrowserContentNamespace;
|
|
193
216
|
/** Seller operations: API key login, content list/search/get */
|
|
194
217
|
readonly seller: BrowserSellerNamespace;
|
|
218
|
+
/** Authenticated buyer account: API key management */
|
|
219
|
+
readonly user: UserNamespace;
|
|
195
220
|
/* Excluded from this release type: __constructor */
|
|
196
221
|
}
|
|
197
222
|
|
|
@@ -646,6 +671,40 @@ declare interface components {
|
|
|
646
671
|
key: string;
|
|
647
672
|
secret?: string;
|
|
648
673
|
};
|
|
674
|
+
AuthLoginBuyerApiKeyRequest: {
|
|
675
|
+
/** @description Structured buyer API key (e.g. bktst_abc123) */
|
|
676
|
+
key: string;
|
|
677
|
+
/** @description 64-char hex secret, shown once at creation */
|
|
678
|
+
secret: string;
|
|
679
|
+
};
|
|
680
|
+
UserApiKey: {
|
|
681
|
+
/** Format: uuid */
|
|
682
|
+
id: string;
|
|
683
|
+
name: string;
|
|
684
|
+
/** @description Structured public identifier (e.g. bktst_abc123) */
|
|
685
|
+
key: string;
|
|
686
|
+
/** Format: date-time */
|
|
687
|
+
last_used_at?: string | null;
|
|
688
|
+
/** @description Maximum cumulative spend in cents. null = no limit. */
|
|
689
|
+
spending_limit_cents?: number | null;
|
|
690
|
+
/** Format: date-time */
|
|
691
|
+
created_at: string;
|
|
692
|
+
};
|
|
693
|
+
UserApiKeyCreateRequest: {
|
|
694
|
+
/** @description Human-readable label for the key */
|
|
695
|
+
name: string;
|
|
696
|
+
/** @description Optional spend ceiling in cents */
|
|
697
|
+
spending_limit_cents?: number | null;
|
|
698
|
+
};
|
|
699
|
+
/** @description Returned once only at creation. The secret is not stored and cannot be retrieved again. */
|
|
700
|
+
UserApiKeyCreateResponse: {
|
|
701
|
+
/** Format: uuid */
|
|
702
|
+
id: string;
|
|
703
|
+
/** @description Structured public identifier (e.g. bktst_abc123) */
|
|
704
|
+
key: string;
|
|
705
|
+
/** @description 64-char hex authentication secret. Store immediately — shown once only. */
|
|
706
|
+
secret: string;
|
|
707
|
+
};
|
|
649
708
|
AuthTokenRefreshRequest: {
|
|
650
709
|
refresh_token?: string;
|
|
651
710
|
};
|
|
@@ -789,7 +848,7 @@ declare interface components {
|
|
|
789
848
|
title?: string;
|
|
790
849
|
/**
|
|
791
850
|
* Format: byte
|
|
792
|
-
* @description Full article body in markdown, base64 encoded. For `markdown` content only.
|
|
851
|
+
* @description Full article body in markdown, base64 encoded. For `markdown` content only. Must be base64-encoded before sending (e.g. `btoa(markdownText)`).
|
|
793
852
|
*/
|
|
794
853
|
content_body?: string;
|
|
795
854
|
/**
|
|
@@ -804,7 +863,7 @@ declare interface components {
|
|
|
804
863
|
external_identifier?: string | null;
|
|
805
864
|
/**
|
|
806
865
|
* Format: byte
|
|
807
|
-
* @description Content teaser, base64 encoded
|
|
866
|
+
* @description Content teaser, base64 encoded. Must be base64-encoded before sending (e.g. `btoa(teaserText)`)
|
|
808
867
|
*/
|
|
809
868
|
teaser?: string;
|
|
810
869
|
/** @description Price in cents (must be greater than 0) */
|
|
@@ -1036,7 +1095,7 @@ declare interface components {
|
|
|
1036
1095
|
title: string;
|
|
1037
1096
|
/**
|
|
1038
1097
|
* Format: byte
|
|
1039
|
-
* @description Full article body in markdown, base64 encoded. Required when `content_type` is `markdown`.
|
|
1098
|
+
* @description Full article body in markdown, base64 encoded. Required when `content_type` is `markdown`. Must be base64-encoded before sending (e.g. `btoa(markdownText)`).
|
|
1040
1099
|
*/
|
|
1041
1100
|
content_body?: string;
|
|
1042
1101
|
/**
|
|
@@ -1051,7 +1110,7 @@ declare interface components {
|
|
|
1051
1110
|
external_identifier?: string;
|
|
1052
1111
|
/**
|
|
1053
1112
|
* Format: byte
|
|
1054
|
-
* @description (Optional) Article teaser, written in markdown and base64 encoded.
|
|
1113
|
+
* @description (Optional) Article teaser, written in markdown and base64 encoded. Must be base64-encoded before sending (e.g. `btoa(teaserText)`).
|
|
1055
1114
|
*/
|
|
1056
1115
|
teaser?: string;
|
|
1057
1116
|
/** @description Price for the content in cents. */
|
|
@@ -1083,7 +1142,7 @@ declare interface components {
|
|
|
1083
1142
|
title: string;
|
|
1084
1143
|
/**
|
|
1085
1144
|
* Format: byte
|
|
1086
|
-
* @description Full article body in markdown, base64 encoded. Present when `content_type` is `markdown`.
|
|
1145
|
+
* @description Full article body in markdown, base64 encoded. Present when `content_type` is `markdown`. Must be base64-decoded before rendering (e.g. `atob(content.content_body ?? '')`).
|
|
1087
1146
|
*/
|
|
1088
1147
|
content_body?: string | null;
|
|
1089
1148
|
/**
|
|
@@ -1096,9 +1155,11 @@ declare interface components {
|
|
|
1096
1155
|
* @example vimeo:123456789
|
|
1097
1156
|
*/
|
|
1098
1157
|
external_identifier?: string | null;
|
|
1158
|
+
/** @description Canonical URL of this content on its origin site. Used by the x402 verify-origin endpoint to bind a third-party page to a Ledewire content record. */
|
|
1159
|
+
resource_url?: string | null;
|
|
1099
1160
|
/**
|
|
1100
1161
|
* Format: byte
|
|
1101
|
-
* @description Article teaser, base64 encoded.
|
|
1162
|
+
* @description Article teaser, base64 encoded. Must be base64-decoded before rendering (e.g. `atob(content.teaser ?? '')`).
|
|
1102
1163
|
*/
|
|
1103
1164
|
teaser: string;
|
|
1104
1165
|
/** @description Price for the content in cents. */
|
|
@@ -1194,7 +1255,7 @@ declare interface components {
|
|
|
1194
1255
|
price_cents: number;
|
|
1195
1256
|
/**
|
|
1196
1257
|
* Format: byte
|
|
1197
|
-
* @description Article teaser, base64 encoded. Null when not set.
|
|
1258
|
+
* @description Article teaser, base64 encoded. Null when not set. Must be base64-decoded before rendering (e.g. `atob(item.teaser ?? '')`).
|
|
1198
1259
|
*/
|
|
1199
1260
|
teaser: string | null;
|
|
1200
1261
|
/** @enum {string} */
|
|
@@ -1205,6 +1266,8 @@ declare interface components {
|
|
|
1205
1266
|
content_uri: string | null;
|
|
1206
1267
|
/** @description Namespaced platform ID for `external_ref` content. Null for other types. */
|
|
1207
1268
|
external_identifier?: string | null;
|
|
1269
|
+
/** @description Canonical URL of this content on its origin site. Used by the x402 verify-origin endpoint. */
|
|
1270
|
+
resource_url?: string | null;
|
|
1208
1271
|
};
|
|
1209
1272
|
/**
|
|
1210
1273
|
* @description Full content detail plus real-time access and wallet context for a specific user. Returned by the buyer-facing `GET /v1/content/:id/with-access` endpoint.
|
|
@@ -1329,6 +1392,126 @@ declare interface components {
|
|
|
1329
1392
|
};
|
|
1330
1393
|
};
|
|
1331
1394
|
};
|
|
1395
|
+
/** @description Response body returned by the x402 content endpoint on a successful `200`. Delivers the purchased content directly in the settlement response. `content_body` is present when `content_type` is `markdown`; `content_uri` is present when `content_type` is `external_ref`. `purchase_id` is the UUID of the settled Purchase record (null for free content). */
|
|
1396
|
+
X402ContentResponse: {
|
|
1397
|
+
id: string;
|
|
1398
|
+
/** @enum {string} */
|
|
1399
|
+
content_type: 'markdown' | 'external_ref';
|
|
1400
|
+
title: string;
|
|
1401
|
+
price_cents: number;
|
|
1402
|
+
/** Format: byte */
|
|
1403
|
+
teaser: string;
|
|
1404
|
+
/** @enum {string} */
|
|
1405
|
+
visibility: 'public' | 'unlisted' | 'private';
|
|
1406
|
+
metadata?: {
|
|
1407
|
+
[key: string]: unknown;
|
|
1408
|
+
};
|
|
1409
|
+
external_identifier?: string | null;
|
|
1410
|
+
/** @description UUID of the settled Purchase record. Null for free content. */
|
|
1411
|
+
purchase_id?: string | null;
|
|
1412
|
+
/** @description Canonical URL of this content on its origin site. Set when content was registered via a pricing rule or manual resource_url assignment. */
|
|
1413
|
+
resource_url?: string | null;
|
|
1414
|
+
/**
|
|
1415
|
+
* Format: byte
|
|
1416
|
+
* @description Full article body in markdown. Present when content_type is markdown.
|
|
1417
|
+
*/
|
|
1418
|
+
content_body?: string | null;
|
|
1419
|
+
/** @description URI of the external resource. Present when content_type is external_ref. */
|
|
1420
|
+
content_uri?: string | null;
|
|
1421
|
+
};
|
|
1422
|
+
/** @description Returned when the URL matches a registered Ledewire content item. */
|
|
1423
|
+
VerifyOriginVerified: {
|
|
1424
|
+
/** @enum {boolean} */
|
|
1425
|
+
verified: true;
|
|
1426
|
+
/** @description UUID of the matching Content record. */
|
|
1427
|
+
content_id: string;
|
|
1428
|
+
/** @description UUID of the store that owns this content. */
|
|
1429
|
+
store_id: string;
|
|
1430
|
+
/** @description Price in cents as a string (e.g. "10" = $0.10). */
|
|
1431
|
+
amount: string;
|
|
1432
|
+
/** @description Content title. */
|
|
1433
|
+
title: string;
|
|
1434
|
+
};
|
|
1435
|
+
/** @description Returned when the URL is not registered or the URL is invalid. */
|
|
1436
|
+
VerifyOriginUnverified: {
|
|
1437
|
+
/** @enum {boolean} */
|
|
1438
|
+
verified: false;
|
|
1439
|
+
};
|
|
1440
|
+
/** @description JSON Web Key Set (RFC 7517) containing the RS256 public key for x402 accessToken verification. */
|
|
1441
|
+
JwksResponse: {
|
|
1442
|
+
keys: {
|
|
1443
|
+
/** @enum {string} */
|
|
1444
|
+
kty: 'RSA';
|
|
1445
|
+
/** @enum {string} */
|
|
1446
|
+
use: 'sig';
|
|
1447
|
+
/** @enum {string} */
|
|
1448
|
+
alg: 'RS256';
|
|
1449
|
+
/** @description Key ID. Matches the `kid` header claim in minted access tokens. */
|
|
1450
|
+
kid: string;
|
|
1451
|
+
/** @description RSA modulus (Base64url-encoded). */
|
|
1452
|
+
n: string;
|
|
1453
|
+
/** @description RSA public exponent (Base64url-encoded). */
|
|
1454
|
+
e: string;
|
|
1455
|
+
}[];
|
|
1456
|
+
};
|
|
1457
|
+
/** @description x402 v2 settlement result. Base64-encoded JSON returned in the `PAYMENT-RESPONSE` header on a successful `200`. `accessToken` is present when an RS256 signing key is configured; omitted in environments without credentials. */
|
|
1458
|
+
SettlementResponse: {
|
|
1459
|
+
/** @enum {boolean} */
|
|
1460
|
+
success: true;
|
|
1461
|
+
/** @description UUID of the settled Purchase record. */
|
|
1462
|
+
transaction: string;
|
|
1463
|
+
/** @enum {string} */
|
|
1464
|
+
network: 'ledewire:v1';
|
|
1465
|
+
/** @description UUID of the buying user. */
|
|
1466
|
+
payer: string;
|
|
1467
|
+
/** @description Short-lived RS256-signed JWT for offline entitlement verification. Verifiable via `/.well-known/x402-jwks.json`. Omitted if signing key is not configured. */
|
|
1468
|
+
accessToken?: string | null;
|
|
1469
|
+
};
|
|
1470
|
+
MerchantPricingRule: {
|
|
1471
|
+
/** @description UUID of the pricing rule. */
|
|
1472
|
+
id: string;
|
|
1473
|
+
/** @description UUID of the owning store. */
|
|
1474
|
+
store_id: string;
|
|
1475
|
+
/** @description Glob URL pattern (supports * and ** wildcards). Must start with http:// or https://. */
|
|
1476
|
+
url_pattern: string;
|
|
1477
|
+
/** @description Price in cents applied to content matching this pattern. */
|
|
1478
|
+
price_cents: number;
|
|
1479
|
+
/** @description Whether the rule is currently active. Inactive rules are ignored during URL matching. */
|
|
1480
|
+
active: boolean;
|
|
1481
|
+
/** Format: date-time */
|
|
1482
|
+
created_at: string;
|
|
1483
|
+
/** Format: date-time */
|
|
1484
|
+
updated_at: string;
|
|
1485
|
+
};
|
|
1486
|
+
MerchantDomainVerification: {
|
|
1487
|
+
/** @description UUID of the domain verification record. */
|
|
1488
|
+
id: string;
|
|
1489
|
+
/** @description UUID of the owning store. */
|
|
1490
|
+
store_id: string;
|
|
1491
|
+
/** @description The verified domain (www. prefix is stripped on creation). */
|
|
1492
|
+
domain: string;
|
|
1493
|
+
/**
|
|
1494
|
+
* @description Verification status updated by DomainVerifyJob.
|
|
1495
|
+
* @enum {string}
|
|
1496
|
+
*/
|
|
1497
|
+
status: 'pending' | 'verified' | 'failed';
|
|
1498
|
+
/** @description DNS TXT record name the merchant must add (e.g. _ledewire-verify.example.com). */
|
|
1499
|
+
txt_record_name: string;
|
|
1500
|
+
/** @description DNS TXT record value the merchant must set. */
|
|
1501
|
+
txt_record_value: string;
|
|
1502
|
+
/**
|
|
1503
|
+
* Format: date-time
|
|
1504
|
+
* @description Timestamp of successful verification. Null until verified.
|
|
1505
|
+
*/
|
|
1506
|
+
verified_at?: string | null;
|
|
1507
|
+
/**
|
|
1508
|
+
* Format: date-time
|
|
1509
|
+
* @description Timestamp of the most recent verification check (success or failure).
|
|
1510
|
+
*/
|
|
1511
|
+
checked_at?: string | null;
|
|
1512
|
+
/** Format: date-time */
|
|
1513
|
+
created_at: string;
|
|
1514
|
+
};
|
|
1332
1515
|
};
|
|
1333
1516
|
responses: never;
|
|
1334
1517
|
parameters: never;
|
|
@@ -1765,6 +1948,106 @@ export declare interface TokenStorage {
|
|
|
1765
1948
|
clearTokens(): void | Promise<void>;
|
|
1766
1949
|
}
|
|
1767
1950
|
|
|
1951
|
+
/** A buyer API key record (secret is never included after creation). */
|
|
1952
|
+
declare type UserApiKey = components['schemas']['UserApiKey'];
|
|
1953
|
+
|
|
1954
|
+
/** Request body for creating a new buyer API key. */
|
|
1955
|
+
declare type UserApiKeyCreateRequest = components['schemas']['UserApiKeyCreateRequest'];
|
|
1956
|
+
|
|
1957
|
+
/**
|
|
1958
|
+
* Response returned once when a buyer API key is created.
|
|
1959
|
+
* The `secret` is shown exactly once and cannot be retrieved again.
|
|
1960
|
+
* Store it immediately in a secrets manager.
|
|
1961
|
+
*/
|
|
1962
|
+
declare type UserApiKeyCreateResponse = components['schemas']['UserApiKeyCreateResponse'];
|
|
1963
|
+
|
|
1964
|
+
/**
|
|
1965
|
+
* Manage buyer API keys for the authenticated user.
|
|
1966
|
+
*
|
|
1967
|
+
* Buyer API keys are the authentication credential for autonomous agents — they
|
|
1968
|
+
* allow an agent to obtain a buyer JWT via `auth.loginWithBuyerApiKey()` without
|
|
1969
|
+
* requiring a username and password. Each key is named, independently revocable,
|
|
1970
|
+
* and can carry an optional `spending_limit_cents` ceiling.
|
|
1971
|
+
*
|
|
1972
|
+
* **Secret handling:** `create()` returns the `secret` exactly once. It is never
|
|
1973
|
+
* retrievable again after the response is received — store it immediately in a
|
|
1974
|
+
* secrets manager (e.g. environment variable, Vault, AWS Secrets Manager).
|
|
1975
|
+
*
|
|
1976
|
+
* Obtain via `client.user.apiKeys` — do not construct directly.
|
|
1977
|
+
*
|
|
1978
|
+
* @example
|
|
1979
|
+
* ```ts
|
|
1980
|
+
* // Create a key for an agent, with a $10 spend ceiling
|
|
1981
|
+
* const { key, secret } = await client.user.apiKeys.create({
|
|
1982
|
+
* name: 'my-rag-agent',
|
|
1983
|
+
* spending_limit_cents: 1000,
|
|
1984
|
+
* })
|
|
1985
|
+
* // Store secret immediately — it cannot be retrieved again
|
|
1986
|
+
* await secretsManager.put('LEDEWIRE_BUYER_SECRET', secret)
|
|
1987
|
+
*
|
|
1988
|
+
* // List all keys (secrets never included)
|
|
1989
|
+
* const keys = await client.user.apiKeys.list()
|
|
1990
|
+
*
|
|
1991
|
+
* // Revoke a compromised key
|
|
1992
|
+
* await client.user.apiKeys.revoke(keys[0].id)
|
|
1993
|
+
* ```
|
|
1994
|
+
*/
|
|
1995
|
+
declare class UserApiKeysNamespace {
|
|
1996
|
+
private readonly http;
|
|
1997
|
+
/* Excluded from this release type: __constructor */
|
|
1998
|
+
/**
|
|
1999
|
+
* Returns all buyer API keys for the authenticated user.
|
|
2000
|
+
* The `secret` is never included in list responses.
|
|
2001
|
+
*
|
|
2002
|
+
* @returns Array of API key records.
|
|
2003
|
+
*/
|
|
2004
|
+
list(): Promise<UserApiKey[]>;
|
|
2005
|
+
/**
|
|
2006
|
+
* Creates a new buyer API key.
|
|
2007
|
+
*
|
|
2008
|
+
* The `secret` in the response is shown exactly once and cannot be retrieved
|
|
2009
|
+
* again. Store it immediately in a secrets manager before discarding the
|
|
2010
|
+
* response object.
|
|
2011
|
+
*
|
|
2012
|
+
* @param body - Name and optional spend ceiling for the new key.
|
|
2013
|
+
* @returns The new key's public identifier and one-time secret.
|
|
2014
|
+
*
|
|
2015
|
+
* @example
|
|
2016
|
+
* ```ts
|
|
2017
|
+
* const { key, secret } = await client.user.apiKeys.create({
|
|
2018
|
+
* name: 'production-agent',
|
|
2019
|
+
* spending_limit_cents: 5000, // $50 cap
|
|
2020
|
+
* })
|
|
2021
|
+
* // ⚠️ Store secret NOW — it is shown once only
|
|
2022
|
+
* process.env.LEDEWIRE_BUYER_SECRET = secret
|
|
2023
|
+
* ```
|
|
2024
|
+
*/
|
|
2025
|
+
create(body: UserApiKeyCreateRequest): Promise<UserApiKeyCreateResponse>;
|
|
2026
|
+
/**
|
|
2027
|
+
* Revokes (permanently deletes) a buyer API key by ID.
|
|
2028
|
+
*
|
|
2029
|
+
* Any agent currently using this key will receive `401` on its next
|
|
2030
|
+
* token refresh. Revocation takes effect immediately.
|
|
2031
|
+
*
|
|
2032
|
+
* @param id - UUID of the API key to revoke.
|
|
2033
|
+
*/
|
|
2034
|
+
revoke(id: string): Promise<void>;
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
/**
|
|
2038
|
+
* Authenticated buyer account operations.
|
|
2039
|
+
*
|
|
2040
|
+
* Obtain via `client.user` — do not construct directly.
|
|
2041
|
+
*/
|
|
2042
|
+
declare class UserNamespace {
|
|
2043
|
+
/**
|
|
2044
|
+
* Buyer API key management: create, list, and revoke named API keys.
|
|
2045
|
+
* Keys are used by autonomous agents to authenticate without a username/password.
|
|
2046
|
+
*/
|
|
2047
|
+
readonly apiKeys: UserApiKeysNamespace;
|
|
2048
|
+
/* Excluded from this release type: __constructor */
|
|
2049
|
+
}
|
|
2050
|
+
|
|
1768
2051
|
/** Current wallet balance for the authenticated buyer. */
|
|
1769
2052
|
export declare type WalletBalanceResponse = components['schemas']['WalletBalanceResponse'];
|
|
1770
2053
|
|