@proveanything/smartlinks 1.15.16 → 1.15.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.
- package/dist/api/navigation.js +3 -2
- package/dist/api/proof.d.ts +19 -1
- package/dist/api/proof.js +44 -0
- package/dist/docs/API_SUMMARY.md +79 -1
- package/dist/http.d.ts +19 -0
- package/dist/http.js +49 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/openapi.yaml +158 -0
- package/dist/types/navigation.d.ts +5 -0
- package/dist/types/proof.d.ts +55 -0
- package/docs/API_SUMMARY.md +79 -1
- package/openapi.yaml +158 -0
- package/package.json +1 -1
package/dist/api/navigation.js
CHANGED
|
@@ -122,7 +122,7 @@ export var navigation;
|
|
|
122
122
|
type: 'smartlinks-navigate',
|
|
123
123
|
appId: link.appId,
|
|
124
124
|
path: link.kind === 'deep' ? deepPath(link.deepLinkId) : '/',
|
|
125
|
-
params: link.kind === 'deep' ? ((_b = link.params) !== null && _b !== void 0 ? _b : {}) : {},
|
|
125
|
+
params: (link.kind === 'deep' || link.kind === 'app') ? ((_b = link.params) !== null && _b !== void 0 ? _b : {}) : {},
|
|
126
126
|
target: (_c = link.target) !== null && _c !== void 0 ? _c : '_self',
|
|
127
127
|
}, '*');
|
|
128
128
|
return;
|
|
@@ -134,7 +134,8 @@ export var navigation;
|
|
|
134
134
|
const hash = link.kind === 'deep'
|
|
135
135
|
? `#${deepPath(link.deepLinkId)}${qs(link.params)}`
|
|
136
136
|
: `#/`;
|
|
137
|
-
const
|
|
137
|
+
const appParams = link.kind === 'app' && link.params ? qs(link.params).replace(/^\?/, '&') : '';
|
|
138
|
+
const url = `${win.location.pathname}?appId=${encodeURIComponent(link.appId)}${appParams}${hash}`;
|
|
138
139
|
if (link.target === '_blank') {
|
|
139
140
|
win.open(url, '_blank', windowFeatures());
|
|
140
141
|
}
|
package/dist/api/proof.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProofResponse, ProofCreateRequest, ProofUpdateRequest, ProofClaimRequest } from "../types/proof";
|
|
1
|
+
import { ProofResponse, ProofCreateRequest, ProofUpdateRequest, ProofClaimRequest, ProofGrant, CreateGrantOptions, RedeemGrantOptions, RedeemGrantResult } from "../types/proof";
|
|
2
2
|
export declare namespace proof {
|
|
3
3
|
/**
|
|
4
4
|
* Retrieves a single Proof by Collection ID, Product ID, and Proof ID.
|
|
@@ -104,4 +104,22 @@ export declare namespace proof {
|
|
|
104
104
|
data: {
|
|
105
105
|
targetProductId: string;
|
|
106
106
|
}): Promise<ProofResponse>;
|
|
107
|
+
/**
|
|
108
|
+
* Create a share grant on a proof (owner / collection admin only). The returned
|
|
109
|
+
* grant includes `token` — the opaque bearer secret, available ONLY on this
|
|
110
|
+
* response. Embed it in a share link and hand recipients {@link redeemGrant} /
|
|
111
|
+
* {@link setGrantToken}.
|
|
112
|
+
*/
|
|
113
|
+
function createGrant(collectionId: string, productId: string, proofId: string, options: CreateGrantOptions): Promise<ProofGrant>;
|
|
114
|
+
/** List the active + past grants on a proof (owner / collection admin only). Tokens are never returned here. */
|
|
115
|
+
function listGrants(collectionId: string, productId: string, proofId: string): Promise<ProofGrant[]>;
|
|
116
|
+
/** Revoke a grant by id (owner / collection admin only). Takes effect immediately. */
|
|
117
|
+
function revokeGrant(collectionId: string, productId: string, proofId: string, grantId: string): Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* Redeem a grant token (anonymous or signed-in). Records the redemption and
|
|
120
|
+
* returns the granted scope, or — for a `verify_owner` grant — an ownership
|
|
121
|
+
* assertion (never the account). After redeeming, call
|
|
122
|
+
* {@link setGrantToken} so subsequent data requests carry the token.
|
|
123
|
+
*/
|
|
124
|
+
function redeemGrant(collectionId: string, productId: string, proofId: string, token: string, options?: RedeemGrantOptions): Promise<RedeemGrantResult>;
|
|
107
125
|
}
|
package/dist/api/proof.js
CHANGED
|
@@ -156,4 +156,48 @@ export var proof;
|
|
|
156
156
|
return post(path, data);
|
|
157
157
|
}
|
|
158
158
|
proof.migrate = migrate;
|
|
159
|
+
// ---------------------------------------------------------------------------
|
|
160
|
+
// Share grants — delegated, scoped, revocable bearer access to this proof
|
|
161
|
+
// ---------------------------------------------------------------------------
|
|
162
|
+
function grantBase(collectionId, productId, proofId) {
|
|
163
|
+
return `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/grant`;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Create a share grant on a proof (owner / collection admin only). The returned
|
|
167
|
+
* grant includes `token` — the opaque bearer secret, available ONLY on this
|
|
168
|
+
* response. Embed it in a share link and hand recipients {@link redeemGrant} /
|
|
169
|
+
* {@link setGrantToken}.
|
|
170
|
+
*/
|
|
171
|
+
async function createGrant(collectionId, productId, proofId, options) {
|
|
172
|
+
const body = { scope: options.scope };
|
|
173
|
+
if (options.audience)
|
|
174
|
+
body.audience = options.audience;
|
|
175
|
+
if (options.expiresAt)
|
|
176
|
+
body.expiresAt = options.expiresAt instanceof Date ? options.expiresAt.toISOString() : options.expiresAt;
|
|
177
|
+
return post(grantBase(collectionId, productId, proofId), body);
|
|
178
|
+
}
|
|
179
|
+
proof.createGrant = createGrant;
|
|
180
|
+
/** List the active + past grants on a proof (owner / collection admin only). Tokens are never returned here. */
|
|
181
|
+
async function listGrants(collectionId, productId, proofId) {
|
|
182
|
+
return request(grantBase(collectionId, productId, proofId));
|
|
183
|
+
}
|
|
184
|
+
proof.listGrants = listGrants;
|
|
185
|
+
/** Revoke a grant by id (owner / collection admin only). Takes effect immediately. */
|
|
186
|
+
async function revokeGrant(collectionId, productId, proofId, grantId) {
|
|
187
|
+
return del(`${grantBase(collectionId, productId, proofId)}/${encodeURIComponent(grantId)}`);
|
|
188
|
+
}
|
|
189
|
+
proof.revokeGrant = revokeGrant;
|
|
190
|
+
/**
|
|
191
|
+
* Redeem a grant token (anonymous or signed-in). Records the redemption and
|
|
192
|
+
* returns the granted scope, or — for a `verify_owner` grant — an ownership
|
|
193
|
+
* assertion (never the account). After redeeming, call
|
|
194
|
+
* {@link setGrantToken} so subsequent data requests carry the token.
|
|
195
|
+
*/
|
|
196
|
+
async function redeemGrant(collectionId, productId, proofId, token, options) {
|
|
197
|
+
const body = { token };
|
|
198
|
+
if (options === null || options === void 0 ? void 0 : options.guestName)
|
|
199
|
+
body.guestName = options.guestName;
|
|
200
|
+
return post(`${grantBase(collectionId, productId, proofId)}/redeem`, body);
|
|
201
|
+
}
|
|
202
|
+
proof.redeemGrant = redeemGrant;
|
|
159
203
|
})(proof || (proof = {}));
|
package/dist/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 1.15.
|
|
3
|
+
Version: 1.15.17 | Generated: 2026-08-18T08:10:50.608Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -170,6 +170,12 @@ Replace or augment globally applied custom headers.
|
|
|
170
170
|
**setBearerToken**(token: string | undefined) → `void`
|
|
171
171
|
Allows setting the bearerToken at runtime (e.g. after login/logout). Clears the HTTP cache whenever the token actually changes so that stale user-scoped responses (e.g. /account/profile) are not served after a login or logout event.
|
|
172
172
|
|
|
173
|
+
**setGrantToken**(token: string | undefined) → `void`
|
|
174
|
+
Set (or clear) the per-proof share-grant token. When set, it is attached as the `X-Grant-Token` header on every request, so a recipient who has opened a shared link can read/comment on the granted proof's data. Pass `undefined` to clear it. The server re-checks the grant against the database on every request, so calling `revokeGrant` invalidates an in-flight token immediately. Clears the GET cache on change so grant-tier responses are not served after the token changes. ```ts // On opening ?proofId=…&shareToken=abc setGrantToken(shareToken) const { attestations } = await proof.get(...) // now sees owner-tier memories ```
|
|
175
|
+
|
|
176
|
+
**getGrantToken**() → `string | undefined`
|
|
177
|
+
Returns the currently-set share-grant token, or `undefined`.
|
|
178
|
+
|
|
173
179
|
**getBearerToken**() → `string | undefined`
|
|
174
180
|
Returns the bearer token currently held by the SDK, or `undefined` if none is set. In proxy mode, credentials are held by the parent frame, not the local SDK, so this returns `undefined` even when the caller is authenticated.
|
|
175
181
|
|
|
@@ -7287,6 +7293,50 @@ interface ProofFieldsConfig {
|
|
|
7287
7293
|
}
|
|
7288
7294
|
```
|
|
7289
7295
|
|
|
7296
|
+
**GrantAudience** (interface)
|
|
7297
|
+
```typescript
|
|
7298
|
+
interface GrantAudience {
|
|
7299
|
+
kind: 'public_link' | 'named'
|
|
7300
|
+
email?: string
|
|
7301
|
+
userId?: string
|
|
7302
|
+
}
|
|
7303
|
+
```
|
|
7304
|
+
|
|
7305
|
+
**ProofGrant** (interface)
|
|
7306
|
+
```typescript
|
|
7307
|
+
interface ProofGrant {
|
|
7308
|
+
grantId: string
|
|
7309
|
+
proofId: string
|
|
7310
|
+
productId?: string | null
|
|
7311
|
+
scope: GrantScope[]
|
|
7312
|
+
audience: GrantAudience
|
|
7313
|
+
createdBy: string
|
|
7314
|
+
expiresAt?: string | null
|
|
7315
|
+
revokedAt?: string | null
|
|
7316
|
+
redeemedBy?: { userId?: string; guestName?: string; redeemedAt: string }
|
|
7317
|
+
redeemCount: number
|
|
7318
|
+
createdAt: string
|
|
7319
|
+
updatedAt: string
|
|
7320
|
+
token?: string
|
|
7321
|
+
}
|
|
7322
|
+
```
|
|
7323
|
+
|
|
7324
|
+
**CreateGrantOptions** (interface)
|
|
7325
|
+
```typescript
|
|
7326
|
+
interface CreateGrantOptions {
|
|
7327
|
+
scope: GrantScope[]
|
|
7328
|
+
audience?: GrantAudience
|
|
7329
|
+
expiresAt?: Date | string
|
|
7330
|
+
}
|
|
7331
|
+
```
|
|
7332
|
+
|
|
7333
|
+
**RedeemGrantOptions** (interface)
|
|
7334
|
+
```typescript
|
|
7335
|
+
interface RedeemGrantOptions {
|
|
7336
|
+
guestName?: string
|
|
7337
|
+
}
|
|
7338
|
+
```
|
|
7339
|
+
|
|
7290
7340
|
**ProofResponse** = `Proof`
|
|
7291
7341
|
|
|
7292
7342
|
**ProofUpdateRequest** = `Partial<ProofCreateRequest>`
|
|
@@ -7297,6 +7347,10 @@ interface ProofFieldsConfig {
|
|
|
7297
7347
|
|
|
7298
7348
|
**ProofFieldDef** = `ScopedFieldDef & { scope?: ProofFieldScope }`
|
|
7299
7349
|
|
|
7350
|
+
**GrantScope** = `'read' | 'comment' | 'admin' | 'verify_owner'`
|
|
7351
|
+
|
|
7352
|
+
**RedeemGrantResult** = ``
|
|
7353
|
+
|
|
7300
7354
|
### qr
|
|
7301
7355
|
|
|
7302
7356
|
**QrShortCodeLookupResponse** (interface)
|
|
@@ -9937,6 +9991,30 @@ Get proofs for a batch (admin only). GET /admin/collection/:collectionId/product
|
|
|
9937
9991
|
data: { targetProductId: string }) → `Promise<ProofResponse>`
|
|
9938
9992
|
Migrate a proof to a different product within the same collection (admin only). Because the Firestore ledger document ID is `{productId}-{proofId}`, a proof cannot simply be re-assigned to another product by updating a field — the document must be re-keyed. This endpoint handles that atomically: 1. Reads the source ledger document (`{sourceProductId}-{proofId}`). 2. Writes a new document (`{targetProductId}-{proofId}`) with `productId` and `proofGroup` updated. The short `proofId` (nanoid) is unchanged. 3. Writes a migration history entry to the new document's `history` subcollection (snapshot of the original proof + migration metadata). 4. Copies all subcollections — `assets`, `attestations`, `history` — from the old document to the new one. 5. Deletes the old subcollections and then the old document. Repeated migrations are safe — each one appends a history record; no migration metadata is stored on the proof document itself. ```typescript const migrated = await proof.migrate('coll_123', 'prod_old', 'proof_abc', { targetProductId: 'prod_new', }) console.log(migrated.productId) // 'prod_new' ```
|
|
9939
9993
|
|
|
9994
|
+
**createGrant**(collectionId: string,
|
|
9995
|
+
productId: string,
|
|
9996
|
+
proofId: string,
|
|
9997
|
+
options: CreateGrantOptions) → `Promise<ProofGrant>`
|
|
9998
|
+
Create a share grant on a proof (owner / collection admin only). The returned grant includes `token` — the opaque bearer secret, available ONLY on this response. Embed it in a share link and hand recipients {@link redeemGrant} / {@link setGrantToken}.
|
|
9999
|
+
|
|
10000
|
+
**listGrants**(collectionId: string,
|
|
10001
|
+
productId: string,
|
|
10002
|
+
proofId: string) → `Promise<ProofGrant[]>`
|
|
10003
|
+
List the active + past grants on a proof (owner / collection admin only). Tokens are never returned here.
|
|
10004
|
+
|
|
10005
|
+
**revokeGrant**(collectionId: string,
|
|
10006
|
+
productId: string,
|
|
10007
|
+
proofId: string,
|
|
10008
|
+
grantId: string) → `Promise<void>`
|
|
10009
|
+
Revoke a grant by id (owner / collection admin only). Takes effect immediately.
|
|
10010
|
+
|
|
10011
|
+
**redeemGrant**(collectionId: string,
|
|
10012
|
+
productId: string,
|
|
10013
|
+
proofId: string,
|
|
10014
|
+
token: string,
|
|
10015
|
+
options?: RedeemGrantOptions) → `Promise<RedeemGrantResult>`
|
|
10016
|
+
Redeem a grant token (anonymous or signed-in). Records the redemption and returns the granted scope, or — for a `verify_owner` grant — an ownership assertion (never the account). After redeeming, call {@link setGrantToken} so subsequent data requests carry the token.
|
|
10017
|
+
|
|
9940
10018
|
### publicClient
|
|
9941
10019
|
|
|
9942
10020
|
**chat**(collectionId: string,
|
package/dist/http.d.ts
CHANGED
|
@@ -49,6 +49,25 @@ export declare function setExtraHeaders(headers: Record<string, string>): void;
|
|
|
49
49
|
* login or logout event.
|
|
50
50
|
*/
|
|
51
51
|
export declare function setBearerToken(token: string | undefined): void;
|
|
52
|
+
/**
|
|
53
|
+
* Set (or clear) the per-proof share-grant token. When set, it is attached as the
|
|
54
|
+
* `X-Grant-Token` header on every request, so a recipient who has opened a shared
|
|
55
|
+
* link can read/comment on the granted proof's data. Pass `undefined` to clear it.
|
|
56
|
+
*
|
|
57
|
+
* The server re-checks the grant against the database on every request, so calling
|
|
58
|
+
* `revokeGrant` invalidates an in-flight token immediately. Clears the GET cache on
|
|
59
|
+
* change so grant-tier responses are not served after the token changes.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* // On opening ?proofId=…&shareToken=abc
|
|
64
|
+
* setGrantToken(shareToken)
|
|
65
|
+
* const { attestations } = await proof.get(...) // now sees owner-tier memories
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function setGrantToken(token: string | undefined): void;
|
|
69
|
+
/** Returns the currently-set share-grant token, or `undefined`. */
|
|
70
|
+
export declare function getGrantToken(): string | undefined;
|
|
52
71
|
/**
|
|
53
72
|
* Returns the bearer token currently held by the SDK, or `undefined` if none is set.
|
|
54
73
|
* In proxy mode, credentials are held by the parent frame, not the local SDK,
|
package/dist/http.js
CHANGED
|
@@ -39,6 +39,12 @@ let extraHeadersGlobal = {};
|
|
|
39
39
|
* issue refresh tokens and short-lived access tokens. Undefined → web behaviour.
|
|
40
40
|
*/
|
|
41
41
|
let clientPlatform = undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Per-proof share-grant bearer token. When set (via setGrantToken), it is attached
|
|
44
|
+
* as `X-Grant-Token` on every request so the server can evaluate the grant on any
|
|
45
|
+
* data call that touches the granted proof (attestations, threads, app data).
|
|
46
|
+
*/
|
|
47
|
+
let grantToken = undefined;
|
|
42
48
|
/** Whether initializeApi has been successfully called at least once. */
|
|
43
49
|
let initialized = false;
|
|
44
50
|
/** Safely returns the current browser hostname, or an empty string in non-browser / Node environments. */
|
|
@@ -466,6 +472,34 @@ export function setBearerToken(token) {
|
|
|
466
472
|
if (cachePersistence !== 'none')
|
|
467
473
|
idbClear().catch(() => { });
|
|
468
474
|
}
|
|
475
|
+
/**
|
|
476
|
+
* Set (or clear) the per-proof share-grant token. When set, it is attached as the
|
|
477
|
+
* `X-Grant-Token` header on every request, so a recipient who has opened a shared
|
|
478
|
+
* link can read/comment on the granted proof's data. Pass `undefined` to clear it.
|
|
479
|
+
*
|
|
480
|
+
* The server re-checks the grant against the database on every request, so calling
|
|
481
|
+
* `revokeGrant` invalidates an in-flight token immediately. Clears the GET cache on
|
|
482
|
+
* change so grant-tier responses are not served after the token changes.
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* ```ts
|
|
486
|
+
* // On opening ?proofId=…&shareToken=abc
|
|
487
|
+
* setGrantToken(shareToken)
|
|
488
|
+
* const { attestations } = await proof.get(...) // now sees owner-tier memories
|
|
489
|
+
* ```
|
|
490
|
+
*/
|
|
491
|
+
export function setGrantToken(token) {
|
|
492
|
+
if (token === grantToken)
|
|
493
|
+
return;
|
|
494
|
+
grantToken = token;
|
|
495
|
+
httpCache.clear();
|
|
496
|
+
if (cachePersistence !== 'none')
|
|
497
|
+
idbClear().catch(() => { });
|
|
498
|
+
}
|
|
499
|
+
/** Returns the currently-set share-grant token, or `undefined`. */
|
|
500
|
+
export function getGrantToken() {
|
|
501
|
+
return grantToken;
|
|
502
|
+
}
|
|
469
503
|
/**
|
|
470
504
|
* Returns the bearer token currently held by the SDK, or `undefined` if none is set.
|
|
471
505
|
* In proxy mode, credentials are held by the parent frame, not the local SDK,
|
|
@@ -1107,6 +1141,10 @@ export async function request(path) {
|
|
|
1107
1141
|
headers["AUTHORIZATION"] = `Bearer ${bearerToken}`;
|
|
1108
1142
|
if (clientPlatform)
|
|
1109
1143
|
headers["X-Client-Platform"] = clientPlatform;
|
|
1144
|
+
if (grantToken)
|
|
1145
|
+
headers["X-Grant-Token"] = grantToken;
|
|
1146
|
+
if (grantToken)
|
|
1147
|
+
headers["X-Grant-Token"] = grantToken;
|
|
1110
1148
|
if (ngrokSkipBrowserWarning)
|
|
1111
1149
|
headers["ngrok-skip-browser-warning"] = "true";
|
|
1112
1150
|
const _getDomain = getSourceDomain();
|
|
@@ -1182,6 +1220,8 @@ export async function post(path, body, extraHeaders) {
|
|
|
1182
1220
|
headers["AUTHORIZATION"] = `Bearer ${bearerToken}`;
|
|
1183
1221
|
if (clientPlatform)
|
|
1184
1222
|
headers["X-Client-Platform"] = clientPlatform;
|
|
1223
|
+
if (grantToken)
|
|
1224
|
+
headers["X-Grant-Token"] = grantToken;
|
|
1185
1225
|
if (ngrokSkipBrowserWarning)
|
|
1186
1226
|
headers["ngrok-skip-browser-warning"] = "true";
|
|
1187
1227
|
const _postDomain = getSourceDomain();
|
|
@@ -1241,6 +1281,8 @@ export async function put(path, body, extraHeaders) {
|
|
|
1241
1281
|
headers["AUTHORIZATION"] = `Bearer ${bearerToken}`;
|
|
1242
1282
|
if (clientPlatform)
|
|
1243
1283
|
headers["X-Client-Platform"] = clientPlatform;
|
|
1284
|
+
if (grantToken)
|
|
1285
|
+
headers["X-Grant-Token"] = grantToken;
|
|
1244
1286
|
if (ngrokSkipBrowserWarning)
|
|
1245
1287
|
headers["ngrok-skip-browser-warning"] = "true";
|
|
1246
1288
|
const _putDomain = getSourceDomain();
|
|
@@ -1300,6 +1342,8 @@ export async function patch(path, body, extraHeaders) {
|
|
|
1300
1342
|
headers["AUTHORIZATION"] = `Bearer ${bearerToken}`;
|
|
1301
1343
|
if (clientPlatform)
|
|
1302
1344
|
headers["X-Client-Platform"] = clientPlatform;
|
|
1345
|
+
if (grantToken)
|
|
1346
|
+
headers["X-Grant-Token"] = grantToken;
|
|
1303
1347
|
if (ngrokSkipBrowserWarning)
|
|
1304
1348
|
headers["ngrok-skip-browser-warning"] = "true";
|
|
1305
1349
|
const _patchDomain = getSourceDomain();
|
|
@@ -1404,7 +1448,7 @@ export async function requestWithOptions(path, options) {
|
|
|
1404
1448
|
}
|
|
1405
1449
|
}
|
|
1406
1450
|
const _rwoDomain = getSourceDomain();
|
|
1407
|
-
const headers = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ "Content-Type": "application/json" }, (apiKey ? { "X-API-Key": apiKey } : {})), (bearerToken ? { "AUTHORIZATION": `Bearer ${bearerToken}` } : {})), (clientPlatform ? { "X-Client-Platform": clientPlatform } : {})), (ngrokSkipBrowserWarning ? { "ngrok-skip-browser-warning": "true" } : {})), (_rwoDomain ? { "X-Source-Domain": _rwoDomain } : {})), extraHeaders);
|
|
1451
|
+
const headers = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ "Content-Type": "application/json" }, (apiKey ? { "X-API-Key": apiKey } : {})), (bearerToken ? { "AUTHORIZATION": `Bearer ${bearerToken}` } : {})), (clientPlatform ? { "X-Client-Platform": clientPlatform } : {})), (grantToken ? { "X-Grant-Token": grantToken } : {})), (ngrokSkipBrowserWarning ? { "ngrok-skip-browser-warning": "true" } : {})), (_rwoDomain ? { "X-Source-Domain": _rwoDomain } : {})), extraHeaders);
|
|
1408
1452
|
// Merge global custom headers (do not override existing keys from options.headers)
|
|
1409
1453
|
for (const [k, v] of Object.entries(extraHeadersGlobal))
|
|
1410
1454
|
if (!(k in headers))
|
|
@@ -1510,6 +1554,8 @@ export async function del(path, extraHeaders) {
|
|
|
1510
1554
|
headers["AUTHORIZATION"] = `Bearer ${bearerToken}`;
|
|
1511
1555
|
if (clientPlatform)
|
|
1512
1556
|
headers["X-Client-Platform"] = clientPlatform;
|
|
1557
|
+
if (grantToken)
|
|
1558
|
+
headers["X-Grant-Token"] = grantToken;
|
|
1513
1559
|
if (ngrokSkipBrowserWarning)
|
|
1514
1560
|
headers["ngrok-skip-browser-warning"] = "true";
|
|
1515
1561
|
const _delDomain = getSourceDomain();
|
|
@@ -1552,6 +1598,8 @@ export function getApiHeaders() {
|
|
|
1552
1598
|
headers["AUTHORIZATION"] = `Bearer ${bearerToken}`;
|
|
1553
1599
|
if (clientPlatform)
|
|
1554
1600
|
headers["X-Client-Platform"] = clientPlatform;
|
|
1601
|
+
if (grantToken)
|
|
1602
|
+
headers["X-Grant-Token"] = grantToken;
|
|
1555
1603
|
if (ngrokSkipBrowserWarning)
|
|
1556
1604
|
headers["ngrok-skip-browser-warning"] = "true";
|
|
1557
1605
|
const sourceDomain = getSourceDomain();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { initializeApi, isInitialized, hasAuthCredentials, configureSdkCache, invalidateCache, request, post, put, patch, del, sendCustomProxyMessage, getApiHeaders, isProxyEnabled, setBearerToken, getBearerToken } from "./http";
|
|
1
|
+
export { initializeApi, isInitialized, hasAuthCredentials, configureSdkCache, invalidateCache, request, post, put, patch, del, sendCustomProxyMessage, getApiHeaders, isProxyEnabled, setBearerToken, getBearerToken, setGrantToken, getGrantToken } from "./http";
|
|
2
2
|
export * from "./api";
|
|
3
3
|
export * from "./types";
|
|
4
4
|
export { iframe } from "./iframe";
|
|
@@ -17,7 +17,7 @@ export type { AdditionalGtin, ISODateString, JsonPrimitive, JsonValue, ProductCr
|
|
|
17
17
|
export type { TranslationLookupMode, TranslationContentType, TranslationQuality, TranslationItemStatus, TranslationContextValue, TranslationContext, TranslationLookupRequestBase, TranslationLookupSingleRequest, TranslationLookupBatchRequest, TranslationLookupRequest, TranslationLookupItem, TranslationLookupResponse, ResolvedTranslationItem, ResolvedTranslationResponse, TranslationHashOptions, TranslationResolveOptions, TranslationRecord, TranslationListParams, TranslationListResponse, TranslationUpdateRequest, } from "./types/translations";
|
|
18
18
|
export type { FacetBucket, FacetDefinition, FacetDefinitionWriteInput, FacetGetParams, FacetListParams, FacetListResponse, FacetNamespaceListResponse, FacetQueryRequest, FacetQueryResponse, FacetValue, FacetValueDefinition, FacetValueGetParams, FacetValueListParams, FacetValueListResponse, FacetValueResponse, FacetValueWriteInput, PublicFacetListParams, } from "./types/facets";
|
|
19
19
|
export type { Collection, CollectionResponse, CollectionCreateRequest, CollectionUpdateRequest, DomainTarget, HubAvailabilityResponse, } from "./types/collection";
|
|
20
|
-
export type { Proof, ProofResponse, ProofCreateRequest, ProofUpdateRequest, ProofClaimRequest, } from "./types/proof";
|
|
20
|
+
export type { Proof, ProofResponse, ProofCreateRequest, ProofUpdateRequest, ProofClaimRequest, ProofGrant, GrantScope, GrantAudience, CreateGrantOptions, RedeemGrantOptions, RedeemGrantResult, } from "./types/proof";
|
|
21
21
|
export type { QrShortCodeLookupResponse, } from "./types/qr";
|
|
22
22
|
export type { ReverseTagLookupParams, ReverseTagLookupResponse, } from "./types/tags";
|
|
23
23
|
export type { AdminMobileCapability, ActionableCapability, AdminMobileHostId, AdminMobileEvent, AdminMobileEventCallback, AdminMobileEventSubscriber, ScannerEventSubscriber, // @deprecated — use AdminMobileEventCallback
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
// Top-level entrypoint of the npm package. Re-export initializeApi + all namespaces.
|
|
3
|
-
export { initializeApi, isInitialized, hasAuthCredentials, configureSdkCache, invalidateCache, request, post, put, patch, del, sendCustomProxyMessage, getApiHeaders, isProxyEnabled, setBearerToken, getBearerToken } from "./http";
|
|
3
|
+
export { initializeApi, isInitialized, hasAuthCredentials, configureSdkCache, invalidateCache, request, post, put, patch, del, sendCustomProxyMessage, getApiHeaders, isProxyEnabled, setBearerToken, getBearerToken, setGrantToken, getGrantToken } from "./http";
|
|
4
4
|
export * from "./api";
|
|
5
5
|
export * from "./types";
|
|
6
6
|
// Iframe namespace
|
package/dist/openapi.yaml
CHANGED
|
@@ -12183,6 +12183,90 @@ paths:
|
|
|
12183
12183
|
application/json:
|
|
12184
12184
|
schema:
|
|
12185
12185
|
$ref: "#/components/schemas/ProofClaimRequest"
|
|
12186
|
+
/public/collection/{collectionId}/product/{productId}/proof/{proofId}/grant/redeem:
|
|
12187
|
+
post:
|
|
12188
|
+
tags:
|
|
12189
|
+
- proof
|
|
12190
|
+
summary: Redeem a grant token (anonymous or signed-in).
|
|
12191
|
+
operationId: proof_redeemGrant
|
|
12192
|
+
security: []
|
|
12193
|
+
parameters:
|
|
12194
|
+
- name: collectionId
|
|
12195
|
+
in: path
|
|
12196
|
+
required: true
|
|
12197
|
+
schema:
|
|
12198
|
+
type: string
|
|
12199
|
+
- name: productId
|
|
12200
|
+
in: path
|
|
12201
|
+
required: true
|
|
12202
|
+
schema:
|
|
12203
|
+
type: string
|
|
12204
|
+
- name: proofId
|
|
12205
|
+
in: path
|
|
12206
|
+
required: true
|
|
12207
|
+
schema:
|
|
12208
|
+
type: string
|
|
12209
|
+
responses:
|
|
12210
|
+
200:
|
|
12211
|
+
description: Success
|
|
12212
|
+
content:
|
|
12213
|
+
application/json:
|
|
12214
|
+
schema:
|
|
12215
|
+
$ref: "#/components/schemas/RedeemGrantResult"
|
|
12216
|
+
400:
|
|
12217
|
+
description: Bad request
|
|
12218
|
+
401:
|
|
12219
|
+
description: Unauthorized
|
|
12220
|
+
404:
|
|
12221
|
+
description: Not found
|
|
12222
|
+
requestBody:
|
|
12223
|
+
required: true
|
|
12224
|
+
content:
|
|
12225
|
+
application/json:
|
|
12226
|
+
schema:
|
|
12227
|
+
$ref: "#/components/schemas/RedeemGrantOptions"
|
|
12228
|
+
/public/collection/{collectionId}/product/{productId}/proof/{proofId}/grant/{grantId}:
|
|
12229
|
+
delete:
|
|
12230
|
+
tags:
|
|
12231
|
+
- proof
|
|
12232
|
+
summary: Revoke a grant by id (owner / collection admin only).
|
|
12233
|
+
operationId: proof_revokeGrant
|
|
12234
|
+
security: []
|
|
12235
|
+
parameters:
|
|
12236
|
+
- name: collectionId
|
|
12237
|
+
in: path
|
|
12238
|
+
required: true
|
|
12239
|
+
schema:
|
|
12240
|
+
type: string
|
|
12241
|
+
- name: productId
|
|
12242
|
+
in: path
|
|
12243
|
+
required: true
|
|
12244
|
+
schema:
|
|
12245
|
+
type: string
|
|
12246
|
+
- name: proofId
|
|
12247
|
+
in: path
|
|
12248
|
+
required: true
|
|
12249
|
+
schema:
|
|
12250
|
+
type: string
|
|
12251
|
+
- name: grantId
|
|
12252
|
+
in: path
|
|
12253
|
+
required: true
|
|
12254
|
+
schema:
|
|
12255
|
+
type: string
|
|
12256
|
+
responses:
|
|
12257
|
+
200:
|
|
12258
|
+
description: Success
|
|
12259
|
+
content:
|
|
12260
|
+
application/json:
|
|
12261
|
+
schema:
|
|
12262
|
+
type: object
|
|
12263
|
+
additionalProperties: true
|
|
12264
|
+
400:
|
|
12265
|
+
description: Bad request
|
|
12266
|
+
401:
|
|
12267
|
+
description: Unauthorized
|
|
12268
|
+
404:
|
|
12269
|
+
description: Not found
|
|
12186
12270
|
/public/collection/{collectionId}/products/{productId}/createClaim:
|
|
12187
12271
|
post:
|
|
12188
12272
|
tags:
|
|
@@ -24865,6 +24949,80 @@ components:
|
|
|
24865
24949
|
$ref: "#/components/schemas/ProofFieldDef"
|
|
24866
24950
|
required:
|
|
24867
24951
|
- fields
|
|
24952
|
+
GrantAudience:
|
|
24953
|
+
type: object
|
|
24954
|
+
properties:
|
|
24955
|
+
kind:
|
|
24956
|
+
type: string
|
|
24957
|
+
enum:
|
|
24958
|
+
- public_link
|
|
24959
|
+
- named
|
|
24960
|
+
email:
|
|
24961
|
+
type: string
|
|
24962
|
+
userId:
|
|
24963
|
+
type: string
|
|
24964
|
+
required:
|
|
24965
|
+
- kind
|
|
24966
|
+
ProofGrant:
|
|
24967
|
+
type: object
|
|
24968
|
+
properties:
|
|
24969
|
+
grantId:
|
|
24970
|
+
type: string
|
|
24971
|
+
proofId:
|
|
24972
|
+
type: string
|
|
24973
|
+
productId:
|
|
24974
|
+
type: string
|
|
24975
|
+
scope:
|
|
24976
|
+
type: array
|
|
24977
|
+
items:
|
|
24978
|
+
$ref: "#/components/schemas/GrantScope"
|
|
24979
|
+
audience:
|
|
24980
|
+
$ref: "#/components/schemas/GrantAudience"
|
|
24981
|
+
createdBy:
|
|
24982
|
+
type: string
|
|
24983
|
+
expiresAt:
|
|
24984
|
+
type: string
|
|
24985
|
+
revokedAt:
|
|
24986
|
+
type: string
|
|
24987
|
+
redeemedBy:
|
|
24988
|
+
type: object
|
|
24989
|
+
additionalProperties: true
|
|
24990
|
+
redeemCount:
|
|
24991
|
+
type: number
|
|
24992
|
+
createdAt:
|
|
24993
|
+
type: string
|
|
24994
|
+
updatedAt:
|
|
24995
|
+
type: string
|
|
24996
|
+
token:
|
|
24997
|
+
type: string
|
|
24998
|
+
required:
|
|
24999
|
+
- grantId
|
|
25000
|
+
- proofId
|
|
25001
|
+
- scope
|
|
25002
|
+
- audience
|
|
25003
|
+
- createdBy
|
|
25004
|
+
- redeemCount
|
|
25005
|
+
- createdAt
|
|
25006
|
+
- updatedAt
|
|
25007
|
+
CreateGrantOptions:
|
|
25008
|
+
type: object
|
|
25009
|
+
properties:
|
|
25010
|
+
scope:
|
|
25011
|
+
type: array
|
|
25012
|
+
items:
|
|
25013
|
+
$ref: "#/components/schemas/GrantScope"
|
|
25014
|
+
audience:
|
|
25015
|
+
$ref: "#/components/schemas/GrantAudience"
|
|
25016
|
+
expiresAt:
|
|
25017
|
+
type: object
|
|
25018
|
+
additionalProperties: true
|
|
25019
|
+
required:
|
|
25020
|
+
- scope
|
|
25021
|
+
RedeemGrantOptions:
|
|
25022
|
+
type: object
|
|
25023
|
+
properties:
|
|
25024
|
+
guestName:
|
|
25025
|
+
type: string
|
|
24868
25026
|
ProofResponse:
|
|
24869
25027
|
type: object
|
|
24870
25028
|
additionalProperties: true
|
|
@@ -37,6 +37,11 @@ export type LinkTarget = {
|
|
|
37
37
|
kind: 'app';
|
|
38
38
|
/** The target app's `appId`. */
|
|
39
39
|
appId: string;
|
|
40
|
+
/**
|
|
41
|
+
* App-specific query params (e.g. `{ proofId, shareToken }` for a share link).
|
|
42
|
+
* Platform context params are injected automatically.
|
|
43
|
+
*/
|
|
44
|
+
params?: Record<string, string>;
|
|
40
45
|
target?: LinkOpenTarget;
|
|
41
46
|
} | {
|
|
42
47
|
kind: 'deep';
|
package/dist/types/proof.d.ts
CHANGED
|
@@ -65,3 +65,58 @@ export type ProofFieldDef = ScopedFieldDef & {
|
|
|
65
65
|
export interface ProofFieldsConfig {
|
|
66
66
|
fields: ProofFieldDef[];
|
|
67
67
|
}
|
|
68
|
+
/** What a grant authorises the bearer to do on the proof. */
|
|
69
|
+
export type GrantScope = 'read' | 'comment' | 'admin' | 'verify_owner';
|
|
70
|
+
/** Who may redeem a grant. */
|
|
71
|
+
export interface GrantAudience {
|
|
72
|
+
kind: 'public_link' | 'named';
|
|
73
|
+
email?: string;
|
|
74
|
+
userId?: string;
|
|
75
|
+
}
|
|
76
|
+
/** A share grant issued on a proof. */
|
|
77
|
+
export interface ProofGrant {
|
|
78
|
+
grantId: string;
|
|
79
|
+
proofId: string;
|
|
80
|
+
productId?: string | null;
|
|
81
|
+
scope: GrantScope[];
|
|
82
|
+
audience: GrantAudience;
|
|
83
|
+
createdBy: string;
|
|
84
|
+
expiresAt?: string | null;
|
|
85
|
+
revokedAt?: string | null;
|
|
86
|
+
redeemedBy?: {
|
|
87
|
+
userId?: string;
|
|
88
|
+
guestName?: string;
|
|
89
|
+
redeemedAt: string;
|
|
90
|
+
};
|
|
91
|
+
redeemCount: number;
|
|
92
|
+
createdAt: string;
|
|
93
|
+
updatedAt: string;
|
|
94
|
+
/** The opaque bearer token — present ONLY on the `createGrant` response, never on `listGrants`. */
|
|
95
|
+
token?: string;
|
|
96
|
+
}
|
|
97
|
+
export interface CreateGrantOptions {
|
|
98
|
+
/** At least one scope is required. */
|
|
99
|
+
scope: GrantScope[];
|
|
100
|
+
/** Defaults to `{ kind: 'public_link' }`. */
|
|
101
|
+
audience?: GrantAudience;
|
|
102
|
+
/** Optional expiry — a `Date` or ISO string. */
|
|
103
|
+
expiresAt?: Date | string;
|
|
104
|
+
}
|
|
105
|
+
export interface RedeemGrantOptions {
|
|
106
|
+
/** Display name to stamp on guest activity when the redeemer is not signed in. */
|
|
107
|
+
guestName?: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Result of redeeming a grant. For read/comment/admin grants this is the granted
|
|
111
|
+
* scope; for a `verify_owner` grant it is an ownership assertion (never the account).
|
|
112
|
+
*/
|
|
113
|
+
export type RedeemGrantResult = {
|
|
114
|
+
scope: GrantScope[];
|
|
115
|
+
redeemedAt: string;
|
|
116
|
+
} | {
|
|
117
|
+
proofId: string;
|
|
118
|
+
assertsOwnership: true;
|
|
119
|
+
ownerDisplayName?: string;
|
|
120
|
+
issuedAt?: string;
|
|
121
|
+
expiresAt?: string;
|
|
122
|
+
};
|
package/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 1.15.
|
|
3
|
+
Version: 1.15.17 | Generated: 2026-08-18T08:10:50.608Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -170,6 +170,12 @@ Replace or augment globally applied custom headers.
|
|
|
170
170
|
**setBearerToken**(token: string | undefined) → `void`
|
|
171
171
|
Allows setting the bearerToken at runtime (e.g. after login/logout). Clears the HTTP cache whenever the token actually changes so that stale user-scoped responses (e.g. /account/profile) are not served after a login or logout event.
|
|
172
172
|
|
|
173
|
+
**setGrantToken**(token: string | undefined) → `void`
|
|
174
|
+
Set (or clear) the per-proof share-grant token. When set, it is attached as the `X-Grant-Token` header on every request, so a recipient who has opened a shared link can read/comment on the granted proof's data. Pass `undefined` to clear it. The server re-checks the grant against the database on every request, so calling `revokeGrant` invalidates an in-flight token immediately. Clears the GET cache on change so grant-tier responses are not served after the token changes. ```ts // On opening ?proofId=…&shareToken=abc setGrantToken(shareToken) const { attestations } = await proof.get(...) // now sees owner-tier memories ```
|
|
175
|
+
|
|
176
|
+
**getGrantToken**() → `string | undefined`
|
|
177
|
+
Returns the currently-set share-grant token, or `undefined`.
|
|
178
|
+
|
|
173
179
|
**getBearerToken**() → `string | undefined`
|
|
174
180
|
Returns the bearer token currently held by the SDK, or `undefined` if none is set. In proxy mode, credentials are held by the parent frame, not the local SDK, so this returns `undefined` even when the caller is authenticated.
|
|
175
181
|
|
|
@@ -7287,6 +7293,50 @@ interface ProofFieldsConfig {
|
|
|
7287
7293
|
}
|
|
7288
7294
|
```
|
|
7289
7295
|
|
|
7296
|
+
**GrantAudience** (interface)
|
|
7297
|
+
```typescript
|
|
7298
|
+
interface GrantAudience {
|
|
7299
|
+
kind: 'public_link' | 'named'
|
|
7300
|
+
email?: string
|
|
7301
|
+
userId?: string
|
|
7302
|
+
}
|
|
7303
|
+
```
|
|
7304
|
+
|
|
7305
|
+
**ProofGrant** (interface)
|
|
7306
|
+
```typescript
|
|
7307
|
+
interface ProofGrant {
|
|
7308
|
+
grantId: string
|
|
7309
|
+
proofId: string
|
|
7310
|
+
productId?: string | null
|
|
7311
|
+
scope: GrantScope[]
|
|
7312
|
+
audience: GrantAudience
|
|
7313
|
+
createdBy: string
|
|
7314
|
+
expiresAt?: string | null
|
|
7315
|
+
revokedAt?: string | null
|
|
7316
|
+
redeemedBy?: { userId?: string; guestName?: string; redeemedAt: string }
|
|
7317
|
+
redeemCount: number
|
|
7318
|
+
createdAt: string
|
|
7319
|
+
updatedAt: string
|
|
7320
|
+
token?: string
|
|
7321
|
+
}
|
|
7322
|
+
```
|
|
7323
|
+
|
|
7324
|
+
**CreateGrantOptions** (interface)
|
|
7325
|
+
```typescript
|
|
7326
|
+
interface CreateGrantOptions {
|
|
7327
|
+
scope: GrantScope[]
|
|
7328
|
+
audience?: GrantAudience
|
|
7329
|
+
expiresAt?: Date | string
|
|
7330
|
+
}
|
|
7331
|
+
```
|
|
7332
|
+
|
|
7333
|
+
**RedeemGrantOptions** (interface)
|
|
7334
|
+
```typescript
|
|
7335
|
+
interface RedeemGrantOptions {
|
|
7336
|
+
guestName?: string
|
|
7337
|
+
}
|
|
7338
|
+
```
|
|
7339
|
+
|
|
7290
7340
|
**ProofResponse** = `Proof`
|
|
7291
7341
|
|
|
7292
7342
|
**ProofUpdateRequest** = `Partial<ProofCreateRequest>`
|
|
@@ -7297,6 +7347,10 @@ interface ProofFieldsConfig {
|
|
|
7297
7347
|
|
|
7298
7348
|
**ProofFieldDef** = `ScopedFieldDef & { scope?: ProofFieldScope }`
|
|
7299
7349
|
|
|
7350
|
+
**GrantScope** = `'read' | 'comment' | 'admin' | 'verify_owner'`
|
|
7351
|
+
|
|
7352
|
+
**RedeemGrantResult** = ``
|
|
7353
|
+
|
|
7300
7354
|
### qr
|
|
7301
7355
|
|
|
7302
7356
|
**QrShortCodeLookupResponse** (interface)
|
|
@@ -9937,6 +9991,30 @@ Get proofs for a batch (admin only). GET /admin/collection/:collectionId/product
|
|
|
9937
9991
|
data: { targetProductId: string }) → `Promise<ProofResponse>`
|
|
9938
9992
|
Migrate a proof to a different product within the same collection (admin only). Because the Firestore ledger document ID is `{productId}-{proofId}`, a proof cannot simply be re-assigned to another product by updating a field — the document must be re-keyed. This endpoint handles that atomically: 1. Reads the source ledger document (`{sourceProductId}-{proofId}`). 2. Writes a new document (`{targetProductId}-{proofId}`) with `productId` and `proofGroup` updated. The short `proofId` (nanoid) is unchanged. 3. Writes a migration history entry to the new document's `history` subcollection (snapshot of the original proof + migration metadata). 4. Copies all subcollections — `assets`, `attestations`, `history` — from the old document to the new one. 5. Deletes the old subcollections and then the old document. Repeated migrations are safe — each one appends a history record; no migration metadata is stored on the proof document itself. ```typescript const migrated = await proof.migrate('coll_123', 'prod_old', 'proof_abc', { targetProductId: 'prod_new', }) console.log(migrated.productId) // 'prod_new' ```
|
|
9939
9993
|
|
|
9994
|
+
**createGrant**(collectionId: string,
|
|
9995
|
+
productId: string,
|
|
9996
|
+
proofId: string,
|
|
9997
|
+
options: CreateGrantOptions) → `Promise<ProofGrant>`
|
|
9998
|
+
Create a share grant on a proof (owner / collection admin only). The returned grant includes `token` — the opaque bearer secret, available ONLY on this response. Embed it in a share link and hand recipients {@link redeemGrant} / {@link setGrantToken}.
|
|
9999
|
+
|
|
10000
|
+
**listGrants**(collectionId: string,
|
|
10001
|
+
productId: string,
|
|
10002
|
+
proofId: string) → `Promise<ProofGrant[]>`
|
|
10003
|
+
List the active + past grants on a proof (owner / collection admin only). Tokens are never returned here.
|
|
10004
|
+
|
|
10005
|
+
**revokeGrant**(collectionId: string,
|
|
10006
|
+
productId: string,
|
|
10007
|
+
proofId: string,
|
|
10008
|
+
grantId: string) → `Promise<void>`
|
|
10009
|
+
Revoke a grant by id (owner / collection admin only). Takes effect immediately.
|
|
10010
|
+
|
|
10011
|
+
**redeemGrant**(collectionId: string,
|
|
10012
|
+
productId: string,
|
|
10013
|
+
proofId: string,
|
|
10014
|
+
token: string,
|
|
10015
|
+
options?: RedeemGrantOptions) → `Promise<RedeemGrantResult>`
|
|
10016
|
+
Redeem a grant token (anonymous or signed-in). Records the redemption and returns the granted scope, or — for a `verify_owner` grant — an ownership assertion (never the account). After redeeming, call {@link setGrantToken} so subsequent data requests carry the token.
|
|
10017
|
+
|
|
9940
10018
|
### publicClient
|
|
9941
10019
|
|
|
9942
10020
|
**chat**(collectionId: string,
|
package/openapi.yaml
CHANGED
|
@@ -12183,6 +12183,90 @@ paths:
|
|
|
12183
12183
|
application/json:
|
|
12184
12184
|
schema:
|
|
12185
12185
|
$ref: "#/components/schemas/ProofClaimRequest"
|
|
12186
|
+
/public/collection/{collectionId}/product/{productId}/proof/{proofId}/grant/redeem:
|
|
12187
|
+
post:
|
|
12188
|
+
tags:
|
|
12189
|
+
- proof
|
|
12190
|
+
summary: Redeem a grant token (anonymous or signed-in).
|
|
12191
|
+
operationId: proof_redeemGrant
|
|
12192
|
+
security: []
|
|
12193
|
+
parameters:
|
|
12194
|
+
- name: collectionId
|
|
12195
|
+
in: path
|
|
12196
|
+
required: true
|
|
12197
|
+
schema:
|
|
12198
|
+
type: string
|
|
12199
|
+
- name: productId
|
|
12200
|
+
in: path
|
|
12201
|
+
required: true
|
|
12202
|
+
schema:
|
|
12203
|
+
type: string
|
|
12204
|
+
- name: proofId
|
|
12205
|
+
in: path
|
|
12206
|
+
required: true
|
|
12207
|
+
schema:
|
|
12208
|
+
type: string
|
|
12209
|
+
responses:
|
|
12210
|
+
200:
|
|
12211
|
+
description: Success
|
|
12212
|
+
content:
|
|
12213
|
+
application/json:
|
|
12214
|
+
schema:
|
|
12215
|
+
$ref: "#/components/schemas/RedeemGrantResult"
|
|
12216
|
+
400:
|
|
12217
|
+
description: Bad request
|
|
12218
|
+
401:
|
|
12219
|
+
description: Unauthorized
|
|
12220
|
+
404:
|
|
12221
|
+
description: Not found
|
|
12222
|
+
requestBody:
|
|
12223
|
+
required: true
|
|
12224
|
+
content:
|
|
12225
|
+
application/json:
|
|
12226
|
+
schema:
|
|
12227
|
+
$ref: "#/components/schemas/RedeemGrantOptions"
|
|
12228
|
+
/public/collection/{collectionId}/product/{productId}/proof/{proofId}/grant/{grantId}:
|
|
12229
|
+
delete:
|
|
12230
|
+
tags:
|
|
12231
|
+
- proof
|
|
12232
|
+
summary: Revoke a grant by id (owner / collection admin only).
|
|
12233
|
+
operationId: proof_revokeGrant
|
|
12234
|
+
security: []
|
|
12235
|
+
parameters:
|
|
12236
|
+
- name: collectionId
|
|
12237
|
+
in: path
|
|
12238
|
+
required: true
|
|
12239
|
+
schema:
|
|
12240
|
+
type: string
|
|
12241
|
+
- name: productId
|
|
12242
|
+
in: path
|
|
12243
|
+
required: true
|
|
12244
|
+
schema:
|
|
12245
|
+
type: string
|
|
12246
|
+
- name: proofId
|
|
12247
|
+
in: path
|
|
12248
|
+
required: true
|
|
12249
|
+
schema:
|
|
12250
|
+
type: string
|
|
12251
|
+
- name: grantId
|
|
12252
|
+
in: path
|
|
12253
|
+
required: true
|
|
12254
|
+
schema:
|
|
12255
|
+
type: string
|
|
12256
|
+
responses:
|
|
12257
|
+
200:
|
|
12258
|
+
description: Success
|
|
12259
|
+
content:
|
|
12260
|
+
application/json:
|
|
12261
|
+
schema:
|
|
12262
|
+
type: object
|
|
12263
|
+
additionalProperties: true
|
|
12264
|
+
400:
|
|
12265
|
+
description: Bad request
|
|
12266
|
+
401:
|
|
12267
|
+
description: Unauthorized
|
|
12268
|
+
404:
|
|
12269
|
+
description: Not found
|
|
12186
12270
|
/public/collection/{collectionId}/products/{productId}/createClaim:
|
|
12187
12271
|
post:
|
|
12188
12272
|
tags:
|
|
@@ -24865,6 +24949,80 @@ components:
|
|
|
24865
24949
|
$ref: "#/components/schemas/ProofFieldDef"
|
|
24866
24950
|
required:
|
|
24867
24951
|
- fields
|
|
24952
|
+
GrantAudience:
|
|
24953
|
+
type: object
|
|
24954
|
+
properties:
|
|
24955
|
+
kind:
|
|
24956
|
+
type: string
|
|
24957
|
+
enum:
|
|
24958
|
+
- public_link
|
|
24959
|
+
- named
|
|
24960
|
+
email:
|
|
24961
|
+
type: string
|
|
24962
|
+
userId:
|
|
24963
|
+
type: string
|
|
24964
|
+
required:
|
|
24965
|
+
- kind
|
|
24966
|
+
ProofGrant:
|
|
24967
|
+
type: object
|
|
24968
|
+
properties:
|
|
24969
|
+
grantId:
|
|
24970
|
+
type: string
|
|
24971
|
+
proofId:
|
|
24972
|
+
type: string
|
|
24973
|
+
productId:
|
|
24974
|
+
type: string
|
|
24975
|
+
scope:
|
|
24976
|
+
type: array
|
|
24977
|
+
items:
|
|
24978
|
+
$ref: "#/components/schemas/GrantScope"
|
|
24979
|
+
audience:
|
|
24980
|
+
$ref: "#/components/schemas/GrantAudience"
|
|
24981
|
+
createdBy:
|
|
24982
|
+
type: string
|
|
24983
|
+
expiresAt:
|
|
24984
|
+
type: string
|
|
24985
|
+
revokedAt:
|
|
24986
|
+
type: string
|
|
24987
|
+
redeemedBy:
|
|
24988
|
+
type: object
|
|
24989
|
+
additionalProperties: true
|
|
24990
|
+
redeemCount:
|
|
24991
|
+
type: number
|
|
24992
|
+
createdAt:
|
|
24993
|
+
type: string
|
|
24994
|
+
updatedAt:
|
|
24995
|
+
type: string
|
|
24996
|
+
token:
|
|
24997
|
+
type: string
|
|
24998
|
+
required:
|
|
24999
|
+
- grantId
|
|
25000
|
+
- proofId
|
|
25001
|
+
- scope
|
|
25002
|
+
- audience
|
|
25003
|
+
- createdBy
|
|
25004
|
+
- redeemCount
|
|
25005
|
+
- createdAt
|
|
25006
|
+
- updatedAt
|
|
25007
|
+
CreateGrantOptions:
|
|
25008
|
+
type: object
|
|
25009
|
+
properties:
|
|
25010
|
+
scope:
|
|
25011
|
+
type: array
|
|
25012
|
+
items:
|
|
25013
|
+
$ref: "#/components/schemas/GrantScope"
|
|
25014
|
+
audience:
|
|
25015
|
+
$ref: "#/components/schemas/GrantAudience"
|
|
25016
|
+
expiresAt:
|
|
25017
|
+
type: object
|
|
25018
|
+
additionalProperties: true
|
|
25019
|
+
required:
|
|
25020
|
+
- scope
|
|
25021
|
+
RedeemGrantOptions:
|
|
25022
|
+
type: object
|
|
25023
|
+
properties:
|
|
25024
|
+
guestName:
|
|
25025
|
+
type: string
|
|
24868
25026
|
ProofResponse:
|
|
24869
25027
|
type: object
|
|
24870
25028
|
additionalProperties: true
|