@proveanything/smartlinks 1.0.13 → 1.0.16
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 +12 -150
- package/build-docs.ts +28 -0
- package/dist/api/appConfiguration.d.ts +20 -9
- package/dist/api/appConfiguration.js +85 -11
- package/dist/api/auth.d.ts +3 -4
- package/dist/api/auth.js +2 -2
- package/dist/build-docs.js +26 -0
- package/dist/http.d.ts +5 -3
- package/dist/http.js +5 -3
- package/dist/index.d.ts +3 -0
- package/docs/README.md +282 -0
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/documentation.json +3380 -1454
- package/docs/functions/appConfiguration.deleteConfig.html +1 -0
- package/docs/functions/appConfiguration.deleteDataItem.html +1 -0
- package/docs/functions/appConfiguration.getConfig.html +1 -0
- package/docs/functions/appConfiguration.getData.html +1 -0
- package/docs/functions/appConfiguration.getDataItem.html +1 -0
- package/docs/functions/appConfiguration.setConfig.html +1 -0
- package/docs/functions/appConfiguration.setDataItem.html +1 -0
- package/docs/functions/asset.getForCollection.html +1 -1
- package/docs/functions/asset.getForProduct.html +1 -1
- package/docs/functions/asset.getForProof.html +1 -1
- package/docs/functions/asset.listForCollection.html +1 -1
- package/docs/functions/asset.listForProduct.html +1 -1
- package/docs/functions/asset.listForProof.html +1 -1
- package/docs/functions/asset.uploadAsset.html +1 -1
- package/docs/functions/attestation.create.html +2 -2
- package/docs/functions/attestation.get.html +2 -2
- package/docs/functions/attestation.list.html +2 -2
- package/docs/functions/attestation.remove.html +1 -1
- package/docs/functions/attestation.update.html +2 -2
- package/docs/functions/auth.getAccount.html +3 -0
- package/docs/functions/auth.login.html +2 -2
- package/docs/functions/auth.logout.html +1 -1
- package/docs/functions/auth.verifyToken.html +3 -0
- package/docs/functions/collection.get.html +1 -1
- package/docs/functions/initializeApi.html +2 -4
- package/docs/functions/product.get.html +1 -1
- package/docs/functions/product.list.html +1 -1
- package/docs/functions/proof.get.html +1 -1
- package/docs/functions/proof.list.html +1 -1
- package/docs/functions/request.html +1 -1
- package/docs/interfaces/AppConfigurationResponse.html +4 -4
- package/docs/interfaces/AssetResponse.html +2 -2
- package/docs/interfaces/AttestationCreateRequest.html +4 -0
- package/docs/interfaces/AttestationResponse.html +7 -0
- package/docs/interfaces/AttestationUpdateRequest.html +3 -0
- package/docs/interfaces/CollectionResponse.html +5 -5
- package/docs/interfaces/ErrorResponse.html +3 -3
- package/docs/interfaces/ProductResponse.html +5 -5
- package/docs/interfaces/ProofResponse.html +8 -8
- package/docs/modules/appConfiguration.html +7 -1
- package/docs/modules/asset.html +1 -1
- package/docs/modules/attestation.html +1 -1
- package/docs/modules/auth.html +3 -1
- package/docs/modules/collection.html +1 -1
- package/docs/modules/product.html +1 -1
- package/docs/modules/proof.html +1 -1
- package/docs/modules.html +7 -0
- package/docs/types/AccountInfoResponse.html +1 -0
- package/docs/types/AppConfigOptions.html +1 -0
- package/docs/types/LoginResponse.html +1 -0
- package/docs/types/VerifyTokenResponse.html +1 -0
- package/package.json +5 -2
- package/src/api/appConfiguration.ts +99 -17
- package/src/api/auth.ts +5 -5
- package/src/http.ts +7 -5
- package/src/index.ts +13 -0
- package/temp-docs/.nojekyll +1 -0
- package/temp-docs/README.md +101 -0
- package/temp-docs/interfaces/AppConfigurationResponse.md +45 -0
- package/temp-docs/interfaces/AssetResponse.md +39 -0
- package/temp-docs/interfaces/AttestationCreateRequest.md +37 -0
- package/temp-docs/interfaces/AttestationResponse.md +70 -0
- package/temp-docs/interfaces/AttestationUpdateRequest.md +26 -0
- package/temp-docs/interfaces/CollectionResponse.md +58 -0
- package/temp-docs/interfaces/ErrorResponse.md +32 -0
- package/temp-docs/interfaces/ProductResponse.md +58 -0
- package/temp-docs/interfaces/ProofResponse.md +97 -0
- package/temp-docs/modules/appConfiguration.md +151 -0
- package/temp-docs/modules/asset.md +171 -0
- package/temp-docs/modules/attestation.md +134 -0
- package/temp-docs/modules/auth.md +88 -0
- package/temp-docs/modules/collection.md +33 -0
- package/temp-docs/modules/product.md +63 -0
- package/temp-docs/modules/proof.md +57 -0
- package/temp-docs/modules.md +176 -0
- package/docs/functions/appConfiguration.get.html +0 -6
package/README.md
CHANGED
|
@@ -22,11 +22,12 @@ import {
|
|
|
22
22
|
} from "@proveanything/smartlinks";
|
|
23
23
|
|
|
24
24
|
async function main() {
|
|
25
|
-
// Initialize once (provide base URL and optional API key
|
|
25
|
+
// Initialize once (provide base URL and optional API key, bearer token, or proxyMode)
|
|
26
26
|
initializeApi({
|
|
27
27
|
baseURL: "https://smartlinks.app/api/v1",
|
|
28
28
|
apiKey: "YOUR_API_KEY_HERE", // optional
|
|
29
29
|
bearerToken: "YOUR_BEARER_TOKEN", // optional
|
|
30
|
+
proxyMode: false // optional, set true if running in iframe via parent proxy
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
try {
|
|
@@ -58,168 +59,29 @@ main();
|
|
|
58
59
|
### Initialization
|
|
59
60
|
|
|
60
61
|
```ts
|
|
61
|
-
initializeApi(options: { baseURL: string; apiKey?: string; bearerToken?: string }): void
|
|
62
|
+
initializeApi(options: { baseURL: string; apiKey?: string; bearerToken?: string; proxyMode?: boolean }): void
|
|
62
63
|
```
|
|
63
64
|
|
|
64
65
|
- **Parameters:**
|
|
65
66
|
- `baseURL` (`string`, required): The root URL of the Smartlinks API, e.g. `https://smartlinks.app/api/v1`.
|
|
66
67
|
- `apiKey` (`string`, optional): Your API key for the `X-API-Key` header.
|
|
67
|
-
- `bearerToken` (`string`, optional): Your Bearer token for the `
|
|
68
|
+
- `bearerToken` (`string`, optional): Your Bearer token for the `Authorization` header.
|
|
69
|
+
- `proxyMode` (`boolean`, optional): Set to `true` if running in an iframe and using a parent proxy for requests.
|
|
68
70
|
|
|
69
71
|
All subsequent calls to the API functions will use these settings.
|
|
70
72
|
|
|
71
73
|
---
|
|
72
74
|
|
|
73
|
-
###
|
|
75
|
+
### Namespaced Modules
|
|
74
76
|
|
|
75
|
-
|
|
77
|
+
Each namespace provides a `get` method for fetching data:
|
|
76
78
|
|
|
77
|
-
|
|
79
|
+
- **collection.get(collectionId: string): Promise<Collection>**
|
|
80
|
+
- **product.get(collectionId: string, productId: string): Promise<Product>**
|
|
81
|
+
- **proof.get(collectionId: string, proofId: string): Promise<Proof>**
|
|
82
|
+
- **appConfiguration.get(collectionId: string, appId: string): Promise<AppConfiguration>**
|
|
78
83
|
|
|
79
|
-
|
|
80
|
-
- `collectionId` (`string`, required): The unique identifier of the collection to fetch.
|
|
81
|
-
- **Returns:**
|
|
82
|
-
A `Promise` that resolves to a `CollectionResponse` object:
|
|
83
|
-
|
|
84
|
-
```ts
|
|
85
|
-
export interface CollectionResponse {
|
|
86
|
-
id: string;
|
|
87
|
-
name: string;
|
|
88
|
-
title: string;
|
|
89
|
-
logoImage: string;
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
- **Example:**
|
|
94
|
-
```ts
|
|
95
|
-
const coll = await collection.get("abc123");
|
|
96
|
-
console.log("Fetched collection:", coll.title);
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
---
|
|
100
|
-
|
|
101
|
-
### Namespace: `product`
|
|
102
|
-
|
|
103
|
-
#### `product.get(collectionId: string, productId: string): Promise<ProductResponse>`
|
|
104
|
-
|
|
105
|
-
Fetches a single product item within a collection.
|
|
106
|
-
|
|
107
|
-
- **Parameters:**
|
|
108
|
-
- `collectionId` (`string`, required): The parent collection’s ID.
|
|
109
|
-
- `productId` (`string`, required): The product item’s ID.
|
|
110
|
-
- **Returns:**
|
|
111
|
-
A `Promise` that resolves to a `ProductResponse` object:
|
|
112
|
-
|
|
113
|
-
```ts
|
|
114
|
-
export interface ProductResponse {
|
|
115
|
-
id: string;
|
|
116
|
-
name: string;
|
|
117
|
-
description: string;
|
|
118
|
-
heroImage: string;
|
|
119
|
-
}
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
- **Example:**
|
|
123
|
-
```ts
|
|
124
|
-
const prod = await product.get("abc123", "prod789");
|
|
125
|
-
console.log("Fetched product:", prod.name);
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
130
|
-
### Namespace: `proof`
|
|
131
|
-
|
|
132
|
-
#### `proof.get(collectionId: string, proofId: string): Promise<ProofResponse>`
|
|
133
|
-
|
|
134
|
-
Fetches a single proof by collection ID and proof ID.
|
|
135
|
-
|
|
136
|
-
- **Parameters:**
|
|
137
|
-
- `collectionId` (`string`, required): The parent collection’s ID.
|
|
138
|
-
- `proofId` (`string`, required): The proof’s ID.
|
|
139
|
-
- **Returns:**
|
|
140
|
-
A `Promise` that resolves to a `ProofResponse` object:
|
|
141
|
-
|
|
142
|
-
```ts
|
|
143
|
-
export interface ProofResponse {
|
|
144
|
-
collectionId: string;
|
|
145
|
-
createdAt: string;
|
|
146
|
-
id: string;
|
|
147
|
-
productId: string;
|
|
148
|
-
tokenId: string;
|
|
149
|
-
userId: string;
|
|
150
|
-
values: Record<string, any>;
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
- **Example:**
|
|
155
|
-
```ts
|
|
156
|
-
const prf = await proof.get("abc123", "proof456");
|
|
157
|
-
console.log("Fetched proof:", prf.id);
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
### Namespace: `appConfiguration`
|
|
163
|
-
|
|
164
|
-
#### `appConfiguration.get(collectionId: string, appId: string): Promise<AppConfigurationResponse>`
|
|
165
|
-
|
|
166
|
-
Fetches a single app configuration by collection ID and app ID.
|
|
167
|
-
|
|
168
|
-
- **Parameters:**
|
|
169
|
-
- `collectionId` (`string`, required): The parent collection’s ID.
|
|
170
|
-
- `appId` (`string`, required): The app configuration’s ID.
|
|
171
|
-
- **Returns:**
|
|
172
|
-
A `Promise` that resolves to an `AppConfigurationResponse` object:
|
|
173
|
-
|
|
174
|
-
```ts
|
|
175
|
-
export interface AppConfigurationResponse {
|
|
176
|
-
id: string;
|
|
177
|
-
name: string;
|
|
178
|
-
settings?: Record<string, any>;
|
|
179
|
-
}
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
- **Example:**
|
|
183
|
-
```ts
|
|
184
|
-
const cfg = await appConfiguration.get("abc123", "app789");
|
|
185
|
-
console.log("Fetched app configuration:", cfg.name);
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
---
|
|
189
|
-
|
|
190
|
-
## Error Handling
|
|
191
|
-
|
|
192
|
-
All methods throw an `Error` when the server responds with a non-2xx status. The thrown error message will include the numeric error code and message from the API. Example:
|
|
193
|
-
|
|
194
|
-
```ts
|
|
195
|
-
import { product } from "@proveanything/smartlinks";
|
|
196
|
-
|
|
197
|
-
async function fetchProduct() {
|
|
198
|
-
try {
|
|
199
|
-
await product.get("abc123", "invalidProdId");
|
|
200
|
-
} catch (err) {
|
|
201
|
-
// err.message might be: "Error 404: Not Found"
|
|
202
|
-
console.error("Request failed:", err);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
fetchProduct();
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
---
|
|
210
|
-
|
|
211
|
-
## Types
|
|
212
|
-
|
|
213
|
-
You can import any of the response interfaces directly:
|
|
214
|
-
|
|
215
|
-
```ts
|
|
216
|
-
import {
|
|
217
|
-
CollectionResponse,
|
|
218
|
-
ProductResponse,
|
|
219
|
-
ProofResponse,
|
|
220
|
-
AppConfigurationResponse,
|
|
221
|
-
} from "@proveanything/smartlinks/types";
|
|
222
|
-
```
|
|
84
|
+
All methods return a Promise resolving to the corresponding object, or throw an `Error` on failure.
|
|
223
85
|
|
|
224
86
|
---
|
|
225
87
|
|
package/build-docs.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { execSync } from "child_process"
|
|
2
|
+
import { readdirSync, readFileSync, writeFileSync, existsSync, mkdirSync } from "fs"
|
|
3
|
+
import { join, extname } from "path"
|
|
4
|
+
|
|
5
|
+
// Run TypeDoc to generate markdown docs in temp-docs
|
|
6
|
+
execSync("npx typedoc --out temp-docs --plugin typedoc-plugin-markdown --entryPoints src/index.ts --excludePrivate --excludeInternal --hideBreadcrumbs --hidePageTitle", { stdio: "inherit" })
|
|
7
|
+
|
|
8
|
+
const tempDocsDir = join(__dirname, "..", "temp-docs")
|
|
9
|
+
const docsDir = join(__dirname, "..", "docs")
|
|
10
|
+
const outPath = join(docsDir, "README.md")
|
|
11
|
+
|
|
12
|
+
if (!existsSync(docsDir)) mkdirSync(docsDir)
|
|
13
|
+
|
|
14
|
+
const files = readdirSync(tempDocsDir)
|
|
15
|
+
.filter(f => extname(f) === ".md")
|
|
16
|
+
.sort((a, b) => a === "modules.md" ? -1 : a.localeCompare(b)) // modules.md first
|
|
17
|
+
|
|
18
|
+
let content = "# Smartlinks SDK Documentation\n\n"
|
|
19
|
+
for (const file of files) {
|
|
20
|
+
const fileContent = readFileSync(join(tempDocsDir, file), "utf-8")
|
|
21
|
+
// Remove redundant titles (except for the first file)
|
|
22
|
+
content += file === "modules.md"
|
|
23
|
+
? fileContent + "\n\n"
|
|
24
|
+
: fileContent.replace(/^# .*\n/, "") + "\n\n"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
writeFileSync(outPath, content)
|
|
28
|
+
console.log("Documentation built at docs/README.md")
|
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
export type AppConfigOptions = {
|
|
2
|
+
appId: string;
|
|
3
|
+
collectionId?: string;
|
|
4
|
+
productId?: string;
|
|
5
|
+
variantId?: string;
|
|
6
|
+
batchId?: string;
|
|
7
|
+
itemId?: string;
|
|
8
|
+
user?: boolean;
|
|
9
|
+
userData?: boolean;
|
|
10
|
+
admin?: boolean;
|
|
11
|
+
config?: any;
|
|
12
|
+
data?: any;
|
|
13
|
+
};
|
|
2
14
|
export declare namespace appConfiguration {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function get(collectionId: string, appId: string): Promise<AppConfigurationResponse>;
|
|
15
|
+
function getConfig(opts: AppConfigOptions): Promise<any>;
|
|
16
|
+
function setConfig(opts: AppConfigOptions): Promise<any>;
|
|
17
|
+
function deleteConfig(opts: AppConfigOptions): Promise<void>;
|
|
18
|
+
function getData(opts: AppConfigOptions): Promise<any[]>;
|
|
19
|
+
function getDataItem(opts: AppConfigOptions): Promise<any>;
|
|
20
|
+
function setDataItem(opts: AppConfigOptions): Promise<any>;
|
|
21
|
+
function deleteDataItem(opts: AppConfigOptions): Promise<void>;
|
|
11
22
|
}
|
|
@@ -1,17 +1,91 @@
|
|
|
1
1
|
// src/api/appConfiguration.ts
|
|
2
|
-
import { request } from "../http";
|
|
2
|
+
import { request, post, del } from "../http";
|
|
3
|
+
function buildAppPath(opts, type) {
|
|
4
|
+
if (opts.user) {
|
|
5
|
+
// /public/auth/app/:appId
|
|
6
|
+
let path = `/public/auth/app/${encodeURIComponent(opts.appId)}`;
|
|
7
|
+
if (type === "data")
|
|
8
|
+
path += "/data";
|
|
9
|
+
if (type === "dataItem" && opts.itemId)
|
|
10
|
+
path += `/data/${encodeURIComponent(opts.itemId)}`;
|
|
11
|
+
return path;
|
|
12
|
+
}
|
|
13
|
+
if (opts.userData) {
|
|
14
|
+
// /public/auth/app/:appId/data or /public/auth/app/:appId/data/:itemId
|
|
15
|
+
let path = `/public/auth/app/${encodeURIComponent(opts.appId)}/data`;
|
|
16
|
+
if (type === "dataItem" && opts.itemId)
|
|
17
|
+
path += `/${encodeURIComponent(opts.itemId)}`;
|
|
18
|
+
return path;
|
|
19
|
+
}
|
|
20
|
+
const base = opts.admin ? "admin" : "public";
|
|
21
|
+
let path = `/${base}`;
|
|
22
|
+
if (opts.collectionId) {
|
|
23
|
+
path += `/collection/${encodeURIComponent(opts.collectionId)}`;
|
|
24
|
+
if (opts.productId) {
|
|
25
|
+
path += `/product/${encodeURIComponent(opts.productId)}`;
|
|
26
|
+
if (opts.variantId) {
|
|
27
|
+
path += `/variant/${encodeURIComponent(opts.variantId)}`;
|
|
28
|
+
}
|
|
29
|
+
else if (opts.batchId) {
|
|
30
|
+
path += `/batch/${encodeURIComponent(opts.batchId)}`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
path += `/app/${encodeURIComponent(opts.appId)}`;
|
|
35
|
+
if (type === "data" || type === "dataItem") {
|
|
36
|
+
path += "/data";
|
|
37
|
+
if (type === "dataItem" && opts.itemId) {
|
|
38
|
+
path += `/${encodeURIComponent(opts.itemId)}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return path;
|
|
42
|
+
}
|
|
3
43
|
export var appConfiguration;
|
|
4
44
|
(function (appConfiguration) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
async function
|
|
13
|
-
const path =
|
|
45
|
+
// Get config (app, collection, product, variant, batch, user)
|
|
46
|
+
async function getConfig(opts) {
|
|
47
|
+
const path = buildAppPath(opts, "config");
|
|
48
|
+
return request(path);
|
|
49
|
+
}
|
|
50
|
+
appConfiguration.getConfig = getConfig;
|
|
51
|
+
// Set config (app, collection, product, variant, batch, user)
|
|
52
|
+
async function setConfig(opts) {
|
|
53
|
+
const path = buildAppPath(opts, "config");
|
|
54
|
+
return post(path, opts.config);
|
|
55
|
+
}
|
|
56
|
+
appConfiguration.setConfig = setConfig;
|
|
57
|
+
// Delete config (user only)
|
|
58
|
+
async function deleteConfig(opts) {
|
|
59
|
+
const path = buildAppPath(opts, "config");
|
|
60
|
+
return del(path);
|
|
61
|
+
}
|
|
62
|
+
appConfiguration.deleteConfig = deleteConfig;
|
|
63
|
+
// Get all data items (app, collection, product, variant, batch, userData)
|
|
64
|
+
async function getData(opts) {
|
|
65
|
+
const path = buildAppPath(opts, "data");
|
|
66
|
+
return request(path);
|
|
67
|
+
}
|
|
68
|
+
appConfiguration.getData = getData;
|
|
69
|
+
// Get a single data item (app, collection, product, variant, batch, userData)
|
|
70
|
+
async function getDataItem(opts) {
|
|
71
|
+
if (!opts.itemId)
|
|
72
|
+
throw new Error("itemId is required for getDataItem");
|
|
73
|
+
const path = buildAppPath(opts, "dataItem");
|
|
14
74
|
return request(path);
|
|
15
75
|
}
|
|
16
|
-
appConfiguration.
|
|
76
|
+
appConfiguration.getDataItem = getDataItem;
|
|
77
|
+
// Set a data item (app, collection, product, variant, batch, userData)
|
|
78
|
+
async function setDataItem(opts) {
|
|
79
|
+
const path = buildAppPath(opts, "data");
|
|
80
|
+
return post(path, opts.data);
|
|
81
|
+
}
|
|
82
|
+
appConfiguration.setDataItem = setDataItem;
|
|
83
|
+
// Delete a data item (app, collection, product, variant, batch, userData)
|
|
84
|
+
async function deleteDataItem(opts) {
|
|
85
|
+
if (!opts.itemId)
|
|
86
|
+
throw new Error("itemId is required for deleteDataItem");
|
|
87
|
+
const path = buildAppPath(opts, "dataItem");
|
|
88
|
+
return del(path);
|
|
89
|
+
}
|
|
90
|
+
appConfiguration.deleteDataItem = deleteDataItem;
|
|
17
91
|
})(appConfiguration || (appConfiguration = {}));
|
package/dist/api/auth.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
type LoginResponse = {
|
|
1
|
+
export type LoginResponse = {
|
|
2
2
|
id: string;
|
|
3
3
|
name: string;
|
|
4
4
|
email: string;
|
|
5
5
|
bearerToken: string;
|
|
6
6
|
account: Record<string, any>;
|
|
7
7
|
};
|
|
8
|
-
type VerifyTokenResponse = {
|
|
8
|
+
export type VerifyTokenResponse = {
|
|
9
9
|
valid: boolean;
|
|
10
10
|
id?: string;
|
|
11
11
|
name?: string;
|
|
12
12
|
email?: string;
|
|
13
13
|
account?: Record<string, any>;
|
|
14
14
|
};
|
|
15
|
-
type AccountInfoResponse = {
|
|
15
|
+
export type AccountInfoResponse = {
|
|
16
16
|
user: Record<string, any>;
|
|
17
17
|
owner: Record<string, any>;
|
|
18
18
|
account: Record<string, any>;
|
|
@@ -39,4 +39,3 @@ export declare namespace auth {
|
|
|
39
39
|
*/
|
|
40
40
|
function getAccount(): Promise<AccountInfoResponse>;
|
|
41
41
|
}
|
|
42
|
-
export {};
|
package/dist/api/auth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { post, setBearerToken, getApiHeaders } from "../http";
|
|
1
|
+
import { post, request, setBearerToken, getApiHeaders } from "../http";
|
|
2
2
|
export var auth;
|
|
3
3
|
(function (auth) {
|
|
4
4
|
/**
|
|
@@ -40,7 +40,7 @@ export var auth;
|
|
|
40
40
|
* Returns user, owner, account, and location objects.
|
|
41
41
|
*/
|
|
42
42
|
async function getAccount() {
|
|
43
|
-
return
|
|
43
|
+
return request("/public/auth/account");
|
|
44
44
|
}
|
|
45
45
|
auth.getAccount = getAccount;
|
|
46
46
|
})(auth || (auth = {}));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
var child_process_1 = require("child_process");
|
|
4
|
+
var fs_1 = require("fs");
|
|
5
|
+
var path_1 = require("path");
|
|
6
|
+
// Run TypeDoc to generate markdown docs in temp-docs
|
|
7
|
+
(0, child_process_1.execSync)("npx typedoc --out temp-docs --plugin typedoc-plugin-markdown --entryPoints src/index.ts --excludePrivate --excludeInternal --hideBreadcrumbs --hidePageTitle", { stdio: "inherit" });
|
|
8
|
+
var tempDocsDir = (0, path_1.join)(__dirname, "..", "temp-docs");
|
|
9
|
+
var docsDir = (0, path_1.join)(__dirname, "..", "docs");
|
|
10
|
+
var outPath = (0, path_1.join)(docsDir, "README.md");
|
|
11
|
+
if (!(0, fs_1.existsSync)(docsDir))
|
|
12
|
+
(0, fs_1.mkdirSync)(docsDir);
|
|
13
|
+
var files = (0, fs_1.readdirSync)(tempDocsDir)
|
|
14
|
+
.filter(function (f) { return (0, path_1.extname)(f) === ".md"; })
|
|
15
|
+
.sort(function (a, b) { return a === "modules.md" ? -1 : a.localeCompare(b); }); // modules.md first
|
|
16
|
+
var content = "# Smartlinks SDK Documentation\n\n";
|
|
17
|
+
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
|
|
18
|
+
var file = files_1[_i];
|
|
19
|
+
var fileContent = (0, fs_1.readFileSync)((0, path_1.join)(tempDocsDir, file), "utf-8");
|
|
20
|
+
// Remove redundant titles (except for the first file)
|
|
21
|
+
content += file === "modules.md"
|
|
22
|
+
? fileContent + "\n\n"
|
|
23
|
+
: fileContent.replace(/^# .*\n/, "") + "\n\n";
|
|
24
|
+
}
|
|
25
|
+
(0, fs_1.writeFileSync)(outPath, content);
|
|
26
|
+
console.log("Documentation built at docs/README.md");
|
package/dist/http.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Call this once (e.g. at app startup) to configure baseURL/auth.
|
|
3
3
|
*
|
|
4
|
-
* @param options
|
|
5
|
-
* @
|
|
6
|
-
* @
|
|
4
|
+
* @param options - Configuration options
|
|
5
|
+
* @property {string} options.baseURL - The root URL of the Smartlinks API (e.g. "https://smartlinks.app/api/v1")
|
|
6
|
+
* @property {string} [options.apiKey] - (Optional) API key for X-API-Key header
|
|
7
|
+
* @property {string} [options.bearerToken] - (Optional) Bearer token for AUTHORIZATION header
|
|
8
|
+
* @property {boolean} [options.proxyMode] - (Optional) Tells the API that it is running in an iframe via parent proxy
|
|
7
9
|
*/
|
|
8
10
|
export declare function initializeApi(options: {
|
|
9
11
|
baseURL: string;
|
package/dist/http.js
CHANGED
|
@@ -9,9 +9,11 @@ let proxyMode = false;
|
|
|
9
9
|
/**
|
|
10
10
|
* Call this once (e.g. at app startup) to configure baseURL/auth.
|
|
11
11
|
*
|
|
12
|
-
* @param options
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
12
|
+
* @param options - Configuration options
|
|
13
|
+
* @property {string} options.baseURL - The root URL of the Smartlinks API (e.g. "https://smartlinks.app/api/v1")
|
|
14
|
+
* @property {string} [options.apiKey] - (Optional) API key for X-API-Key header
|
|
15
|
+
* @property {string} [options.bearerToken] - (Optional) Bearer token for AUTHORIZATION header
|
|
16
|
+
* @property {boolean} [options.proxyMode] - (Optional) Tells the API that it is running in an iframe via parent proxy
|
|
15
17
|
*/
|
|
16
18
|
export function initializeApi(options) {
|
|
17
19
|
baseURL = options.baseURL.replace(/\/+\$/, ""); // trim trailing slash
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { initializeApi, request } from "./http";
|
|
2
2
|
export * from "./api";
|
|
3
3
|
export * from "./types";
|
|
4
|
+
export type { LoginResponse, VerifyTokenResponse, AccountInfoResponse, } from "./api/auth";
|
|
5
|
+
export type { AttestationResponse, AttestationCreateRequest, AttestationUpdateRequest, } from "./types/attestation";
|
|
6
|
+
export type { AppConfigOptions } from "./api/appConfiguration";
|