@proveanything/smartlinks 1.0.31 → 1.0.33

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.
@@ -13,8 +13,6 @@ export type VerifyTokenResponse = {
13
13
  account?: Record<string, any>;
14
14
  };
15
15
  export type AccountInfoResponse = {
16
- jwtToken: string;
17
- jwtExpiry: number;
18
16
  accessType: string;
19
17
  analyticsCode: string;
20
18
  analyticsId: string;
@@ -66,12 +64,12 @@ export declare namespace auth {
66
64
  * Requests an admin JWT for the current user and a specific collection
67
65
  * Returns JWT if valid.
68
66
  */
69
- function requestAdminJWT(collectionId: string): Promise<VerifyTokenResponse>;
67
+ function requestAdminJWT(collectionId: string): Promise<string>;
70
68
  /**
71
69
  * Requests a JWT for the current user and a specific collection/product/proof
72
70
  * Validates if the user has access to the resource, and returns a JWT
73
71
  */
74
- function requestPublicJWT(collectionId: string, productId: string, proofId: string): Promise<VerifyTokenResponse>;
72
+ function requestPublicJWT(collectionId: string, productId: string, proofId: string): Promise<string>;
75
73
  /**
76
74
  * Gets current account information for the logged in user.
77
75
  * Returns user, owner, account, and location objects.
@@ -1,15 +1,42 @@
1
1
  import { ProofResponse } from "../types/proof";
2
2
  export declare namespace proof {
3
3
  /**
4
- * Retrieves a single Proof by Collection ID and Proof ID.
5
- * @param collectionId Identifier of the parent collection
6
- * @param proofId – Identifier of the proof
7
- * @returns Promise resolving to a ProofResponse object
8
- * @throws ErrorResponse if the request fails
4
+ * Retrieves a single Proof by Collection ID, Product ID, and Proof ID.
5
+ * Both public and admin endpoints now include productId in the path.
9
6
  */
10
- function get(collectionId: string, proofId: string): Promise<ProofResponse>;
7
+ function get(collectionId: string, productId: string, proofId: string, admin?: boolean): Promise<ProofResponse>;
11
8
  /**
12
9
  * List all Proofs for a Collection.
13
10
  */
14
11
  function list(collectionId: string): Promise<ProofResponse[]>;
12
+ /**
13
+ * Create a proof for a product (admin only).
14
+ * POST /admin/collection/:collectionId/product/:productId/proof
15
+ */
16
+ function create(collectionId: string, productId: string, values: any): Promise<ProofResponse>;
17
+ /**
18
+ * Update a proof for a product (admin only).
19
+ * PUT /admin/collection/:collectionId/product/:productId/proof/:proofId
20
+ */
21
+ function update(collectionId: string, productId: string, proofId: string, values: any): Promise<ProofResponse>;
22
+ /**
23
+ * Get proofs for a user in a collection (admin only).
24
+ * GET /admin/collection/:collectionId/proof/findByUser/:userId
25
+ */
26
+ function getByUser(collectionId: string, userId: string): Promise<ProofResponse[]>;
27
+ /**
28
+ * Get proofs for a product (admin only).
29
+ * GET /admin/collection/:collectionId/product/:productId/proof
30
+ */
31
+ function getByProduct(collectionId: string, productId: string): Promise<ProofResponse[]>;
32
+ /**
33
+ * Find proofs for a product (admin only).
34
+ * POST /admin/collection/:collectionId/product/:productId/proof/find
35
+ */
36
+ function findByProduct(collectionId: string, productId: string, query: any): Promise<ProofResponse[]>;
37
+ /**
38
+ * Get proofs for a batch (admin only).
39
+ * GET /admin/collection/:collectionId/product/:productId/batch/:batchId/proof
40
+ */
41
+ function getByBatch(collectionId: string, productId: string, batchId: string): Promise<ProofResponse[]>;
15
42
  }
package/dist/api/proof.js CHANGED
@@ -1,16 +1,14 @@
1
1
  // src/api/proof.ts
2
- import { request } from "../http";
2
+ import { request, post, put } from "../http";
3
3
  export var proof;
4
4
  (function (proof) {
5
5
  /**
6
- * Retrieves a single Proof by Collection ID and Proof ID.
7
- * @param collectionId Identifier of the parent collection
8
- * @param proofId – Identifier of the proof
9
- * @returns Promise resolving to a ProofResponse object
10
- * @throws ErrorResponse if the request fails
6
+ * Retrieves a single Proof by Collection ID, Product ID, and Proof ID.
7
+ * Both public and admin endpoints now include productId in the path.
11
8
  */
12
- async function get(collectionId, proofId) {
13
- const path = `/public/collection/${encodeURIComponent(collectionId)}/proof/${encodeURIComponent(proofId)}`;
9
+ async function get(collectionId, productId, proofId, admin) {
10
+ const base = admin ? '/admin' : '/public';
11
+ const path = `${base}/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}`;
14
12
  return request(path);
15
13
  }
16
14
  proof.get = get;
@@ -22,4 +20,59 @@ export var proof;
22
20
  return request(path);
23
21
  }
24
22
  proof.list = list;
23
+ // -------------------- Admin functions (legacy parity) --------------------
24
+ /**
25
+ * Create a proof for a product (admin only).
26
+ * POST /admin/collection/:collectionId/product/:productId/proof
27
+ */
28
+ async function create(collectionId, productId, values) {
29
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof`;
30
+ return post(path, values);
31
+ }
32
+ proof.create = create;
33
+ /**
34
+ * Update a proof for a product (admin only).
35
+ * PUT /admin/collection/:collectionId/product/:productId/proof/:proofId
36
+ */
37
+ async function update(collectionId, productId, proofId, values) {
38
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}`;
39
+ return put(path, values);
40
+ }
41
+ proof.update = update;
42
+ /**
43
+ * Get proofs for a user in a collection (admin only).
44
+ * GET /admin/collection/:collectionId/proof/findByUser/:userId
45
+ */
46
+ async function getByUser(collectionId, userId) {
47
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/proof/findByUser/${encodeURIComponent(userId)}`;
48
+ return request(path);
49
+ }
50
+ proof.getByUser = getByUser;
51
+ /**
52
+ * Get proofs for a product (admin only).
53
+ * GET /admin/collection/:collectionId/product/:productId/proof
54
+ */
55
+ async function getByProduct(collectionId, productId) {
56
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof`;
57
+ return request(path);
58
+ }
59
+ proof.getByProduct = getByProduct;
60
+ /**
61
+ * Find proofs for a product (admin only).
62
+ * POST /admin/collection/:collectionId/product/:productId/proof/find
63
+ */
64
+ async function findByProduct(collectionId, productId, query) {
65
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/find`;
66
+ return post(path, query);
67
+ }
68
+ proof.findByProduct = findByProduct;
69
+ /**
70
+ * Get proofs for a batch (admin only).
71
+ * GET /admin/collection/:collectionId/product/:productId/batch/:batchId/proof
72
+ */
73
+ async function getByBatch(collectionId, productId, batchId) {
74
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/batch/${encodeURIComponent(batchId)}/proof`;
75
+ return request(path);
76
+ }
77
+ proof.getByBatch = getByBatch;
25
78
  })(proof || (proof = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",