@proveanything/smartlinks 1.0.14 → 1.0.17

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 (117) hide show
  1. package/README.md +7341 -230
  2. package/build-docs.ts +69 -0
  3. package/dist/api/appConfiguration.d.ts +20 -9
  4. package/dist/api/appConfiguration.js +85 -11
  5. package/dist/api/auth.d.ts +3 -4
  6. package/dist/api/claimSet.d.ts +14 -0
  7. package/dist/api/claimSet.js +24 -0
  8. package/dist/api/collection.d.ts +9 -1
  9. package/dist/api/collection.js +16 -2
  10. package/dist/api/form.d.ts +34 -0
  11. package/dist/api/form.js +58 -0
  12. package/dist/api/index.d.ts +2 -0
  13. package/dist/api/index.js +2 -0
  14. package/dist/build-docs.js +61 -0
  15. package/dist/http.d.ts +12 -3
  16. package/dist/http.js +29 -3
  17. package/dist/index.d.ts +4 -1
  18. package/dist/index.js +1 -1
  19. package/docs/README.md +7469 -0
  20. package/docs/assets/highlight.css +12 -33
  21. package/docs/assets/navigation.js +1 -1
  22. package/docs/assets/search.js +1 -1
  23. package/docs/documentation.json +4719 -1986
  24. package/docs/functions/appConfiguration.deleteConfig.html +1 -0
  25. package/docs/functions/appConfiguration.deleteDataItem.html +1 -0
  26. package/docs/functions/appConfiguration.getConfig.html +1 -0
  27. package/docs/functions/appConfiguration.getData.html +1 -0
  28. package/docs/functions/appConfiguration.getDataItem.html +1 -0
  29. package/docs/functions/appConfiguration.setConfig.html +1 -0
  30. package/docs/functions/appConfiguration.setDataItem.html +1 -0
  31. package/docs/functions/asset.getForCollection.html +1 -1
  32. package/docs/functions/asset.getForProduct.html +1 -1
  33. package/docs/functions/asset.getForProof.html +1 -1
  34. package/docs/functions/asset.listForCollection.html +1 -1
  35. package/docs/functions/asset.listForProduct.html +1 -1
  36. package/docs/functions/asset.listForProof.html +1 -1
  37. package/docs/functions/asset.uploadAsset.html +1 -1
  38. package/docs/functions/attestation.create.html +2 -2
  39. package/docs/functions/attestation.get.html +2 -2
  40. package/docs/functions/attestation.list.html +2 -2
  41. package/docs/functions/attestation.remove.html +1 -1
  42. package/docs/functions/attestation.update.html +2 -2
  43. package/docs/functions/auth.getAccount.html +2 -2
  44. package/docs/functions/auth.login.html +2 -2
  45. package/docs/functions/auth.logout.html +1 -1
  46. package/docs/functions/auth.verifyToken.html +2 -2
  47. package/docs/functions/claimSet.assignClaims.html +4 -0
  48. package/docs/functions/claimSet.updateClaimData.html +4 -0
  49. package/docs/functions/collection.get.html +3 -2
  50. package/docs/functions/collection.list.html +5 -0
  51. package/docs/functions/form.create.html +4 -0
  52. package/docs/functions/form.get.html +5 -0
  53. package/docs/functions/form.list.html +4 -0
  54. package/docs/functions/form.remove.html +4 -0
  55. package/docs/functions/form.update.html +5 -0
  56. package/docs/functions/initializeApi.html +2 -4
  57. package/docs/functions/product.get.html +1 -1
  58. package/docs/functions/product.list.html +1 -1
  59. package/docs/functions/proof.get.html +1 -1
  60. package/docs/functions/proof.list.html +1 -1
  61. package/docs/functions/request.html +1 -1
  62. package/docs/functions/sendCustomProxyMessage.html +5 -0
  63. package/docs/index.html +4 -112
  64. package/docs/interfaces/AppConfigurationResponse.html +4 -4
  65. package/docs/interfaces/AssetResponse.html +2 -2
  66. package/docs/interfaces/AttestationCreateRequest.html +4 -0
  67. package/docs/interfaces/AttestationResponse.html +7 -0
  68. package/docs/interfaces/AttestationUpdateRequest.html +3 -0
  69. package/docs/interfaces/CollectionResponse.html +5 -5
  70. package/docs/interfaces/ErrorResponse.html +3 -3
  71. package/docs/interfaces/ProductResponse.html +5 -5
  72. package/docs/interfaces/ProofResponse.html +8 -8
  73. package/docs/modules/appConfiguration.html +7 -1
  74. package/docs/modules/asset.html +1 -1
  75. package/docs/modules/attestation.html +1 -1
  76. package/docs/modules/auth.html +1 -1
  77. package/docs/modules/claimSet.html +3 -0
  78. package/docs/modules/collection.html +2 -1
  79. package/docs/modules/form.html +6 -0
  80. package/docs/modules/product.html +1 -1
  81. package/docs/modules/proof.html +1 -1
  82. package/docs/modules.html +10 -0
  83. package/docs/types/AccountInfoResponse.html +1 -0
  84. package/docs/types/AppConfigOptions.html +1 -0
  85. package/docs/types/LoginResponse.html +1 -0
  86. package/docs/types/VerifyTokenResponse.html +1 -0
  87. package/package.json +5 -2
  88. package/src/api/appConfiguration.ts +99 -17
  89. package/src/api/auth.ts +3 -3
  90. package/src/api/claimSet.ts +23 -0
  91. package/src/api/collection.ts +17 -3
  92. package/src/api/form.ts +57 -0
  93. package/src/api/index.ts +2 -0
  94. package/src/http.ts +32 -5
  95. package/src/index.ts +14 -1
  96. package/temp-docs/.nojekyll +1 -0
  97. package/temp-docs/README.md +7254 -0
  98. package/temp-docs/interfaces/AppConfigurationResponse.md +45 -0
  99. package/temp-docs/interfaces/AssetResponse.md +39 -0
  100. package/temp-docs/interfaces/AttestationCreateRequest.md +37 -0
  101. package/temp-docs/interfaces/AttestationResponse.md +70 -0
  102. package/temp-docs/interfaces/AttestationUpdateRequest.md +26 -0
  103. package/temp-docs/interfaces/CollectionResponse.md +58 -0
  104. package/temp-docs/interfaces/ErrorResponse.md +32 -0
  105. package/temp-docs/interfaces/ProductResponse.md +58 -0
  106. package/temp-docs/interfaces/ProofResponse.md +97 -0
  107. package/temp-docs/modules/appConfiguration.md +151 -0
  108. package/temp-docs/modules/asset.md +171 -0
  109. package/temp-docs/modules/attestation.md +134 -0
  110. package/temp-docs/modules/auth.md +88 -0
  111. package/temp-docs/modules/claimSet.md +52 -0
  112. package/temp-docs/modules/collection.md +63 -0
  113. package/temp-docs/modules/form.md +126 -0
  114. package/temp-docs/modules/product.md +63 -0
  115. package/temp-docs/modules/proof.md +57 -0
  116. package/temp-docs/modules.md +210 -0
  117. package/docs/functions/appConfiguration.get.html +0 -6
package/build-docs.ts ADDED
@@ -0,0 +1,69 @@
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")
29
+
30
+ import * as fs from "fs";
31
+ import * as path from "path";
32
+
33
+ // Use process.cwd() to ensure relative to project root
34
+ const docsJsonPath = path.join(process.cwd(), "docs", "documentation.json");
35
+ const readmePath = path.join(process.cwd(), "README.md");
36
+
37
+ function extractFullApiDocs(json: any): string {
38
+ // This is a minimal implementation. For a full-featured generator,
39
+ // parse all namespaces, functions, and types from the TypeDoc JSON.
40
+ // Here, we just dump the JSON for demonstration.
41
+ // Replace this with a real markdown generator as needed.
42
+ return [
43
+ "# @proveanything/smartlinks",
44
+ "",
45
+ "This README is auto-generated from the TypeScript API documentation.",
46
+ "",
47
+ "## API Reference",
48
+ "",
49
+ "```json",
50
+ JSON.stringify(json, null, 2),
51
+ "```",
52
+ "",
53
+ "_Replace this with a full markdown generator for production use._"
54
+ ].join("\n");
55
+ }
56
+
57
+ function main() {
58
+ console.log("Looking for docs JSON at:", docsJsonPath);
59
+
60
+ if (!fs.existsSync(docsJsonPath)) {
61
+ throw new Error("documentation.json not found. Run `npm run docs` first.");
62
+ }
63
+ const json = JSON.parse(fs.readFileSync(docsJsonPath, "utf-8"));
64
+ const markdown = extractFullApiDocs(json);
65
+ fs.writeFileSync(readmePath, markdown, "utf-8");
66
+ console.log("README.md generated from API documentation.");
67
+ }
68
+
69
+ main();
@@ -1,11 +1,22 @@
1
- import { AppConfigurationResponse } from "../types/appConfiguration";
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
- * Retrieves a single App Configuration by Collection ID and App ID.
5
- * @param collectionId – Identifier of the parent collection
6
- * @param appId – Identifier of the app configuration
7
- * @returns Promise resolving to an AppConfigurationResponse object
8
- * @throws ErrorResponse if the request fails
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
- * Retrieves a single App Configuration by Collection ID and App ID.
7
- * @param collectionId Identifier of the parent collection
8
- * @param appId Identifier of the app configuration
9
- * @returns Promise resolving to an AppConfigurationResponse object
10
- * @throws ErrorResponse if the request fails
11
- */
12
- async function get(collectionId, appId) {
13
- const path = `/public/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}`;
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.get = get;
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 = {}));
@@ -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 {};
@@ -0,0 +1,14 @@
1
+ export declare namespace claimSet {
2
+ /**
3
+ * Assign claims to a claim set.
4
+ * @param collectionId – The collection identifier
5
+ * @param data – The claims data to assign
6
+ */
7
+ function assignClaims(collectionId: string, data: any): Promise<any>;
8
+ /**
9
+ * Update claim data for a collection.
10
+ * @param collectionId – The collection identifier
11
+ * @param data – The claim data to update
12
+ */
13
+ function updateClaimData(collectionId: string, data: any): Promise<any>;
14
+ }
@@ -0,0 +1,24 @@
1
+ import { post } from "../http";
2
+ export var claimSet;
3
+ (function (claimSet) {
4
+ /**
5
+ * Assign claims to a claim set.
6
+ * @param collectionId – The collection identifier
7
+ * @param data – The claims data to assign
8
+ */
9
+ async function assignClaims(collectionId, data) {
10
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/claimSet/${encodeURIComponent(data.id)}/assignClaims`;
11
+ return post(path, data);
12
+ }
13
+ claimSet.assignClaims = assignClaims;
14
+ /**
15
+ * Update claim data for a collection.
16
+ * @param collectionId – The collection identifier
17
+ * @param data – The claim data to update
18
+ */
19
+ async function updateClaimData(collectionId, data) {
20
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/claimSet/updateClaimData`;
21
+ return post(path, data);
22
+ }
23
+ claimSet.updateClaimData = updateClaimData;
24
+ })(claimSet || (claimSet = {}));
@@ -3,8 +3,16 @@ export declare namespace collection {
3
3
  /**
4
4
  * Retrieves a single Collection by its ID.
5
5
  * @param collectionId – Identifier of the collection
6
+ * @param admin – If true, fetches from the admin endpoint
6
7
  * @returns Promise resolving to a CollectionResponse object
7
8
  * @throws ErrorResponse if the request fails
8
9
  */
9
- function get(collectionId: string): Promise<CollectionResponse>;
10
+ function get(collectionId: string, admin?: boolean): Promise<CollectionResponse>;
11
+ /**
12
+ * Retrieves all Collections.
13
+ * @param admin – If true, fetches from the admin endpoint
14
+ * @returns Promise resolving to an array of CollectionResponse objects
15
+ * @throws ErrorResponse if the request fails
16
+ */
17
+ function list(admin?: boolean): Promise<CollectionResponse[]>;
10
18
  }
@@ -5,12 +5,26 @@ export var collection;
5
5
  /**
6
6
  * Retrieves a single Collection by its ID.
7
7
  * @param collectionId – Identifier of the collection
8
+ * @param admin – If true, fetches from the admin endpoint
8
9
  * @returns Promise resolving to a CollectionResponse object
9
10
  * @throws ErrorResponse if the request fails
10
11
  */
11
- async function get(collectionId) {
12
- const path = `/public/collection/${encodeURIComponent(collectionId)}`;
12
+ async function get(collectionId, admin) {
13
+ const base = admin ? '/admin/collection' : '/public/collection';
14
+ const path = `${base}/${encodeURIComponent(collectionId)}`;
13
15
  return request(path);
14
16
  }
15
17
  collection.get = get;
18
+ /**
19
+ * Retrieves all Collections.
20
+ * @param admin – If true, fetches from the admin endpoint
21
+ * @returns Promise resolving to an array of CollectionResponse objects
22
+ * @throws ErrorResponse if the request fails
23
+ */
24
+ async function list(admin) {
25
+ const base = admin ? '/admin/collection' : '/public/collection';
26
+ const path = `${base}`;
27
+ return request(path);
28
+ }
29
+ collection.list = list;
16
30
  })(collection || (collection = {}));
@@ -0,0 +1,34 @@
1
+ export declare namespace form {
2
+ /**
3
+ * Get a single form by ID for a collection.
4
+ * @param collectionId – The collection identifier
5
+ * @param formId – The form identifier
6
+ * @param admin – If true, use admin endpoint; otherwise, use public
7
+ */
8
+ function get(collectionId: string, formId: string, admin?: boolean): Promise<any>;
9
+ /**
10
+ * List all forms for a collection.
11
+ * @param collectionId – The collection identifier
12
+ * @param admin – If true, use admin endpoint; otherwise, use public
13
+ */
14
+ function list(collectionId: string, admin?: boolean): Promise<any[]>;
15
+ /**
16
+ * Create a new form for a collection (admin only).
17
+ * @param collectionId – The collection identifier
18
+ * @param data – The form data
19
+ */
20
+ function create(collectionId: string, data: any): Promise<any>;
21
+ /**
22
+ * Update a form for a collection (admin only).
23
+ * @param collectionId – The collection identifier
24
+ * @param formId – The form identifier
25
+ * @param data – The form data
26
+ */
27
+ function update(collectionId: string, formId: string, data: any): Promise<any>;
28
+ /**
29
+ * Delete a form for a collection (admin only).
30
+ * @param collectionId – The collection identifier
31
+ * @param formId – The form identifier
32
+ */
33
+ function remove(collectionId: string, formId: string): Promise<void>;
34
+ }
@@ -0,0 +1,58 @@
1
+ import { request, post, put, del } from "../http";
2
+ export var form;
3
+ (function (form) {
4
+ /**
5
+ * Get a single form by ID for a collection.
6
+ * @param collectionId – The collection identifier
7
+ * @param formId – The form identifier
8
+ * @param admin – If true, use admin endpoint; otherwise, use public
9
+ */
10
+ async function get(collectionId, formId, admin) {
11
+ const base = admin ? '/admin' : '/public';
12
+ const path = `${base}/${encodeURIComponent(collectionId)}/form/${encodeURIComponent(formId)}`;
13
+ return request(path);
14
+ }
15
+ form.get = get;
16
+ /**
17
+ * List all forms for a collection.
18
+ * @param collectionId – The collection identifier
19
+ * @param admin – If true, use admin endpoint; otherwise, use public
20
+ */
21
+ async function list(collectionId, admin) {
22
+ const base = admin ? '/admin' : '/public';
23
+ const path = `${base}/${encodeURIComponent(collectionId)}/form`;
24
+ return request(path);
25
+ }
26
+ form.list = list;
27
+ /**
28
+ * Create a new form for a collection (admin only).
29
+ * @param collectionId – The collection identifier
30
+ * @param data – The form data
31
+ */
32
+ async function create(collectionId, data) {
33
+ const path = `/admin/${encodeURIComponent(collectionId)}/form`;
34
+ return post(path, data);
35
+ }
36
+ form.create = create;
37
+ /**
38
+ * Update a form for a collection (admin only).
39
+ * @param collectionId – The collection identifier
40
+ * @param formId – The form identifier
41
+ * @param data – The form data
42
+ */
43
+ async function update(collectionId, formId, data) {
44
+ const path = `/admin/${encodeURIComponent(collectionId)}/form/${encodeURIComponent(formId)}`;
45
+ return put(path, data);
46
+ }
47
+ form.update = update;
48
+ /**
49
+ * Delete a form for a collection (admin only).
50
+ * @param collectionId – The collection identifier
51
+ * @param formId – The form identifier
52
+ */
53
+ async function remove(collectionId, formId) {
54
+ const path = `/admin/${encodeURIComponent(collectionId)}/form/${encodeURIComponent(formId)}`;
55
+ return del(path);
56
+ }
57
+ form.remove = remove;
58
+ })(form || (form = {}));
@@ -5,3 +5,5 @@ export { appConfiguration } from "./appConfiguration";
5
5
  export { asset } from "./asset";
6
6
  export { attestation } from "./attestation";
7
7
  export { auth } from "./auth";
8
+ export { form } from "./form";
9
+ export { claimSet } from "./claimSet";
package/dist/api/index.js CHANGED
@@ -7,3 +7,5 @@ export { appConfiguration } from "./appConfiguration";
7
7
  export { asset } from "./asset";
8
8
  export { attestation } from "./attestation";
9
9
  export { auth } from "./auth";
10
+ export { form } from "./form";
11
+ export { claimSet } from "./claimSet";
@@ -0,0 +1,61 @@
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");
27
+ var fs = require("fs");
28
+ var path = require("path");
29
+ // Use process.cwd() to ensure relative to project root
30
+ var docsJsonPath = path.join(process.cwd(), "docs", "documentation.json");
31
+ var readmePath = path.join(process.cwd(), "README.md");
32
+ function extractFullApiDocs(json) {
33
+ // This is a minimal implementation. For a full-featured generator,
34
+ // parse all namespaces, functions, and types from the TypeDoc JSON.
35
+ // Here, we just dump the JSON for demonstration.
36
+ // Replace this with a real markdown generator as needed.
37
+ return [
38
+ "# @proveanything/smartlinks",
39
+ "",
40
+ "This README is auto-generated from the TypeScript API documentation.",
41
+ "",
42
+ "## API Reference",
43
+ "",
44
+ "```json",
45
+ JSON.stringify(json, null, 2),
46
+ "```",
47
+ "",
48
+ "_Replace this with a full markdown generator for production use._"
49
+ ].join("\n");
50
+ }
51
+ function main() {
52
+ console.log("Looking for docs JSON at:", docsJsonPath);
53
+ if (!fs.existsSync(docsJsonPath)) {
54
+ throw new Error("documentation.json not found. Run `npm run docs` first.");
55
+ }
56
+ var json = JSON.parse(fs.readFileSync(docsJsonPath, "utf-8"));
57
+ var markdown = extractFullApiDocs(json);
58
+ fs.writeFileSync(readmePath, markdown, "utf-8");
59
+ console.log("README.md generated from API documentation.");
60
+ }
61
+ main();
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.baseURL - The root URL of the Smartlinks API (e.g. "https://smartlinks.app/api/v1")
5
- * @param options.apiKey - (Optional) API key for X-API-Key header
6
- * @param options.bearerToken - (Optional) Bearer token for AUTHORIZATION header
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;
@@ -51,3 +53,10 @@ export declare function del<T>(path: string, extraHeaders?: Record<string, strin
51
53
  * Returns the common headers used for API requests, including apiKey and bearerToken if set.
52
54
  */
53
55
  export declare function getApiHeaders(): Record<string, string>;
56
+ /**
57
+ * Sends a custom proxy message in proxyMode and waits for a matching reply.
58
+ * @param request - The request type string
59
+ * @param params - The parameters object
60
+ * @returns The data from the proxy response
61
+ */
62
+ export declare function sendCustomProxyMessage<T = any>(request: string, params: any): Promise<T>;
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.baseURL - The root URL of the Smartlinks API (e.g. "https://smartlinks.app/api/v1")
13
- * @param options.apiKey - (Optional) API key for X-API-Key header
14
- * @param options.bearerToken - (Optional) Bearer token for AUTHORIZATION header
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
@@ -276,3 +278,27 @@ export function getApiHeaders() {
276
278
  headers["AUTHORIZATION"] = `Bearer ${bearerToken}`;
277
279
  return headers;
278
280
  }
281
+ /**
282
+ * Sends a custom proxy message in proxyMode and waits for a matching reply.
283
+ * @param request - The request type string
284
+ * @param params - The parameters object
285
+ * @returns The data from the proxy response
286
+ */
287
+ export async function sendCustomProxyMessage(request, params) {
288
+ if (!proxyMode) {
289
+ throw new Error("sendCustomProxyMessage can only be used in proxyMode");
290
+ }
291
+ ensureProxyListener();
292
+ const id = generateProxyId();
293
+ const msg = {
294
+ _smartlinksCustomProxyRequest: true,
295
+ id,
296
+ request,
297
+ params,
298
+ };
299
+ return new Promise((resolve, reject) => {
300
+ proxyPending[id] = { resolve, reject };
301
+ window.parent.postMessage(msg, "*");
302
+ // Optionally: add a timeout here to reject if no response
303
+ });
304
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
- export { initializeApi, request } from "./http";
1
+ export { initializeApi, request, sendCustomProxyMessage } 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";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
2
  // Top-level entrypoint of the npm package. Re-export initializeApi + all namespaces.
3
- export { initializeApi, request } from "./http";
3
+ export { initializeApi, request, sendCustomProxyMessage } from "./http";
4
4
  export * from "./api";
5
5
  export * from "./types";