@proveanything/smartlinks 1.0.16 → 1.0.18

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 (121) hide show
  1. package/README.md +7795 -93
  2. package/build-docs.ts +41 -0
  3. package/dist/api/claimSet.d.ts +14 -0
  4. package/dist/api/claimSet.js +24 -0
  5. package/dist/api/collection.d.ts +9 -1
  6. package/dist/api/collection.js +16 -2
  7. package/dist/api/crate.d.ts +22 -0
  8. package/dist/api/crate.js +44 -0
  9. package/dist/api/form.d.ts +34 -0
  10. package/dist/api/form.js +58 -0
  11. package/dist/api/index.d.ts +3 -0
  12. package/dist/api/index.js +3 -0
  13. package/dist/build-docs.js +35 -0
  14. package/dist/http.d.ts +7 -0
  15. package/dist/http.js +24 -0
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.js +1 -1
  18. package/docs/README.md +7898 -89
  19. package/docs/assets/highlight.css +12 -33
  20. package/docs/assets/navigation.js +1 -1
  21. package/docs/assets/search.js +1 -1
  22. package/docs/documentation.json +2626 -1178
  23. package/docs/functions/appConfiguration.deleteConfig.html +1 -1
  24. package/docs/functions/appConfiguration.deleteDataItem.html +1 -1
  25. package/docs/functions/appConfiguration.getConfig.html +1 -1
  26. package/docs/functions/appConfiguration.getData.html +1 -1
  27. package/docs/functions/appConfiguration.getDataItem.html +1 -1
  28. package/docs/functions/appConfiguration.setConfig.html +1 -1
  29. package/docs/functions/appConfiguration.setDataItem.html +1 -1
  30. package/docs/functions/asset.getForCollection.html +1 -1
  31. package/docs/functions/asset.getForProduct.html +1 -1
  32. package/docs/functions/asset.getForProof.html +1 -1
  33. package/docs/functions/asset.listForCollection.html +1 -1
  34. package/docs/functions/asset.listForProduct.html +1 -1
  35. package/docs/functions/asset.listForProof.html +1 -1
  36. package/docs/functions/asset.uploadAsset.html +1 -1
  37. package/docs/functions/attestation.create.html +1 -1
  38. package/docs/functions/attestation.get.html +1 -1
  39. package/docs/functions/attestation.list.html +1 -1
  40. package/docs/functions/attestation.remove.html +1 -1
  41. package/docs/functions/attestation.update.html +1 -1
  42. package/docs/functions/auth.getAccount.html +1 -1
  43. package/docs/functions/auth.login.html +1 -1
  44. package/docs/functions/auth.logout.html +1 -1
  45. package/docs/functions/auth.verifyToken.html +1 -1
  46. package/docs/functions/claimSet.assignClaims.html +4 -0
  47. package/docs/functions/claimSet.updateClaimData.html +4 -0
  48. package/docs/functions/collection.get.html +3 -2
  49. package/docs/functions/collection.list.html +5 -0
  50. package/docs/functions/crate.create.html +2 -0
  51. package/docs/functions/crate.get.html +2 -0
  52. package/docs/functions/crate.list.html +2 -0
  53. package/docs/functions/crate.remove.html +2 -0
  54. package/docs/functions/crate.update.html +2 -0
  55. package/docs/functions/form.create.html +4 -0
  56. package/docs/functions/form.get.html +5 -0
  57. package/docs/functions/form.list.html +4 -0
  58. package/docs/functions/form.remove.html +4 -0
  59. package/docs/functions/form.update.html +5 -0
  60. package/docs/functions/initializeApi.html +1 -1
  61. package/docs/functions/product.get.html +1 -1
  62. package/docs/functions/product.list.html +1 -1
  63. package/docs/functions/proof.get.html +1 -1
  64. package/docs/functions/proof.list.html +1 -1
  65. package/docs/functions/request.html +1 -1
  66. package/docs/functions/sendCustomProxyMessage.html +5 -0
  67. package/docs/index.html +4 -112
  68. package/docs/interfaces/AppConfigurationResponse.html +4 -4
  69. package/docs/interfaces/AssetResponse.html +2 -2
  70. package/docs/interfaces/AttestationCreateRequest.html +2 -2
  71. package/docs/interfaces/AttestationResponse.html +2 -2
  72. package/docs/interfaces/AttestationUpdateRequest.html +2 -2
  73. package/docs/interfaces/CollectionResponse.html +5 -5
  74. package/docs/interfaces/ErrorResponse.html +3 -3
  75. package/docs/interfaces/ProductResponse.html +5 -5
  76. package/docs/interfaces/ProofResponse.html +8 -8
  77. package/docs/modules/appConfiguration.html +1 -1
  78. package/docs/modules/asset.html +1 -1
  79. package/docs/modules/attestation.html +1 -1
  80. package/docs/modules/auth.html +1 -1
  81. package/docs/modules/claimSet.html +3 -0
  82. package/docs/modules/collection.html +2 -1
  83. package/docs/modules/crate.html +6 -0
  84. package/docs/modules/form.html +6 -0
  85. package/docs/modules/product.html +1 -1
  86. package/docs/modules/proof.html +1 -1
  87. package/docs/modules.html +4 -0
  88. package/docs/types/AccountInfoResponse.html +1 -1
  89. package/docs/types/AppConfigOptions.html +1 -1
  90. package/docs/types/LoginResponse.html +1 -1
  91. package/docs/types/VerifyTokenResponse.html +1 -1
  92. package/package.json +3 -2
  93. package/scripts/copy-docs.js +11 -0
  94. package/src/api/claimSet.ts +23 -0
  95. package/src/api/collection.ts +17 -3
  96. package/src/api/crate.ts +43 -0
  97. package/src/api/form.ts +57 -0
  98. package/src/api/index.ts +3 -0
  99. package/src/http.ts +25 -0
  100. package/src/index.ts +1 -1
  101. package/temp-docs/README.md +7867 -93
  102. package/temp-docs/interfaces/AppConfigurationResponse.md +3 -3
  103. package/temp-docs/interfaces/AssetResponse.md +3 -3
  104. package/temp-docs/interfaces/AttestationCreateRequest.md +3 -3
  105. package/temp-docs/interfaces/AttestationResponse.md +6 -6
  106. package/temp-docs/interfaces/AttestationUpdateRequest.md +2 -2
  107. package/temp-docs/interfaces/CollectionResponse.md +4 -4
  108. package/temp-docs/interfaces/ErrorResponse.md +2 -2
  109. package/temp-docs/interfaces/ProductResponse.md +4 -4
  110. package/temp-docs/interfaces/ProofResponse.md +7 -7
  111. package/temp-docs/modules/appConfiguration.md +7 -7
  112. package/temp-docs/modules/asset.md +7 -7
  113. package/temp-docs/modules/attestation.md +5 -5
  114. package/temp-docs/modules/auth.md +4 -4
  115. package/temp-docs/modules/claimSet.md +52 -0
  116. package/temp-docs/modules/collection.md +32 -2
  117. package/temp-docs/modules/crate.md +124 -0
  118. package/temp-docs/modules/form.md +126 -0
  119. package/temp-docs/modules/product.md +2 -2
  120. package/temp-docs/modules/proof.md +2 -2
  121. package/temp-docs/modules.md +41 -6
package/build-docs.ts CHANGED
@@ -26,3 +26,44 @@ for (const file of files) {
26
26
 
27
27
  writeFileSync(outPath, content)
28
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();
@@ -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,22 @@
1
+ export declare namespace crate {
2
+ /**
3
+ * Get a single crate by ID for a collection (admin only).
4
+ */
5
+ function get(collectionId: string, crateId: string): Promise<any>;
6
+ /**
7
+ * List all crates for a collection (admin only).
8
+ */
9
+ function list(collectionId: string): Promise<any[]>;
10
+ /**
11
+ * Create a new crate for a collection (admin only).
12
+ */
13
+ function create(collectionId: string, data: any): Promise<any>;
14
+ /**
15
+ * Update a crate for a collection (admin only).
16
+ */
17
+ function update(collectionId: string, crateId: string, data: any): Promise<any>;
18
+ /**
19
+ * Delete a crate for a collection (admin only).
20
+ */
21
+ function remove(collectionId: string, crateId: string): Promise<void>;
22
+ }
@@ -0,0 +1,44 @@
1
+ import { request, post, put, del } from "../http";
2
+ export var crate;
3
+ (function (crate) {
4
+ /**
5
+ * Get a single crate by ID for a collection (admin only).
6
+ */
7
+ async function get(collectionId, crateId) {
8
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/crate/${encodeURIComponent(crateId)}`;
9
+ return request(path);
10
+ }
11
+ crate.get = get;
12
+ /**
13
+ * List all crates for a collection (admin only).
14
+ */
15
+ async function list(collectionId) {
16
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/crate`;
17
+ return request(path);
18
+ }
19
+ crate.list = list;
20
+ /**
21
+ * Create a new crate for a collection (admin only).
22
+ */
23
+ async function create(collectionId, data) {
24
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/crate`;
25
+ return post(path, data);
26
+ }
27
+ crate.create = create;
28
+ /**
29
+ * Update a crate for a collection (admin only).
30
+ */
31
+ async function update(collectionId, crateId, data) {
32
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/crate/${encodeURIComponent(crateId)}`;
33
+ return put(path, data);
34
+ }
35
+ crate.update = update;
36
+ /**
37
+ * Delete a crate for a collection (admin only).
38
+ */
39
+ async function remove(collectionId, crateId) {
40
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/crate/${encodeURIComponent(crateId)}`;
41
+ return del(path);
42
+ }
43
+ crate.remove = remove;
44
+ })(crate || (crate = {}));
@@ -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,6 @@ 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";
10
+ export { crate } from "./crate";
package/dist/api/index.js CHANGED
@@ -7,3 +7,6 @@ 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";
12
+ export { crate } from "./crate";
@@ -24,3 +24,38 @@ for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
24
24
  }
25
25
  (0, fs_1.writeFileSync)(outPath, content);
26
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
@@ -53,3 +53,10 @@ export declare function del<T>(path: string, extraHeaders?: Record<string, strin
53
53
  * Returns the common headers used for API requests, including apiKey and bearerToken if set.
54
54
  */
55
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
@@ -278,3 +278,27 @@ export function getApiHeaders() {
278
278
  headers["AUTHORIZATION"] = `Bearer ${bearerToken}`;
279
279
  return headers;
280
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,4 +1,4 @@
1
- export { initializeApi, request } from "./http";
1
+ export { initializeApi, request, sendCustomProxyMessage } from "./http";
2
2
  export * from "./api";
3
3
  export * from "./types";
4
4
  export type { LoginResponse, VerifyTokenResponse, AccountInfoResponse, } from "./api/auth";
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";