@proveanything/smartlinks 1.0.58 → 1.0.61

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/API_SUMMARY.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.0.58 | Generated: 2025-12-10T12:43:07.554Z
3
+ Version: 1.0.61 | Generated: 2025-12-11T14:28:56.705Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -108,29 +108,29 @@ interface AssetResponse {
108
108
  **AttestationResponse** (interface)
109
109
  ```typescript
110
110
  interface AttestationResponse {
111
- id: string // Attestation id
112
- createdAt: string // Creation timestamp
113
- updatedAt: string // Last updated timestamp
114
- public: Record<string, any> // Public attestation data
115
- private: Record<string, any> // Private attestation data
116
- proof: Record<string, any> // Associated proof reference/data
111
+ id: string
112
+ createdAt: string
113
+ updatedAt: string
114
+ public: Record<string, any>
115
+ private: Record<string, any>
116
+ proof: Record<string, any>
117
117
  }
118
118
  ```
119
119
 
120
120
  **AttestationCreateRequest** (interface)
121
121
  ```typescript
122
122
  interface AttestationCreateRequest {
123
- public: Record<string, any> // Public attestation payload
124
- private: Record<string, any> // Private attestation payload
125
- proof: Record<string, any> // Proof linkage or payload
123
+ public: Record<string, any>
124
+ private: Record<string, any>
125
+ proof: Record<string, any>
126
126
  }
127
127
  ```
128
128
 
129
129
  **AttestationUpdateRequest** (interface)
130
130
  ```typescript
131
131
  interface AttestationUpdateRequest {
132
- type?: string // Update operation/type
133
- data?: Record<string, any> // Partial attestation data
132
+ type?: string
133
+ data?: Record<string, any>
134
134
  }
135
135
  ```
136
136
 
@@ -138,14 +138,21 @@ interface AttestationUpdateRequest {
138
138
 
139
139
  **UserAccountRegistrationRequest** (type)
140
140
  ```typescript
141
- type UserAccountRegistrationRequest = {
142
- name: string // User's display name
143
- email?: string // Optional user email
144
- phone?: string // Optional user phone number
145
- password?: string // Optional password for email login
146
- sendAccountConfirmation?: boolean // Send confirmation email after registration
147
- collectionId?: string, // Optional collection context for registration
148
- tokenType?: 'bearer' | 'firebase' // Desired token type returned
141
+ type UserAccountRegistrationRequest = {
142
+ /** User's display name */
143
+ name: string
144
+ /** Optional user email */
145
+ email?: string
146
+ /** Optional user phone number */
147
+ phone?: string
148
+ /** Optional password for email login */
149
+ password?: string
150
+ /** Send confirmation email after registration */
151
+ sendAccountConfirmation?: boolean
152
+ /** Optional collection context for registration */
153
+ collectionId?: string,
154
+ /** Desired token type returned */
155
+ tokenType?: 'bearer' | 'firebase'
149
156
  }
150
157
  ```
151
158
 
@@ -320,30 +327,30 @@ interface AuthKitConfig {
320
327
  **ClaimCodeRef** (interface)
321
328
  ```typescript
322
329
  interface ClaimCodeRef {
323
- codeId: string // Identifier of the code (e.g., tag or QR code)
324
- claimId: string // Identifier of the claim within the claim set
330
+ codeId: string
331
+ claimId: string
325
332
  }
326
333
  ```
327
334
 
328
335
  **UpdateClaimDataRequest** (interface)
329
336
  ```typescript
330
337
  interface UpdateClaimDataRequest {
331
- data: Record<string, any> // Arbitrary key/value pairs for the claim data update
332
- codes: ClaimCodeRef[] // Array of code+claim references affected by this update
338
+ data: Record<string, any>
339
+ codes: ClaimCodeRef[]
333
340
  }
334
341
  ```
335
342
 
336
343
  **AssignClaimsRequest** (interface)
337
344
  ```typescript
338
345
  interface AssignClaimsRequest {
339
- id: string // The claim set ID (required)
340
- collectionId: string // The collection ID (required)
341
- productId: string // The product ID (required)
342
- batchId?: string // Optional batch identifier
343
- start?: number // Optional start index for bulk assignment
344
- end?: number // Optional end index for bulk assignment
345
- codeId?: string // Optional single code identifier for single assignment
346
- data?: Record<string, any> // Optional key/value pairs to set on the claim
346
+ id: string
347
+ collectionId: string
348
+ productId: string
349
+ batchId?: string
350
+ start?: number
351
+ end?: number
352
+ codeId?: string
353
+ data?: Record<string, any>
347
354
  }
348
355
  ```
349
356
 
@@ -352,35 +359,35 @@ interface AssignClaimsRequest {
352
359
  **CollectionResponse** (interface)
353
360
  ```typescript
354
361
  interface CollectionResponse {
355
- id: string // Unique identifier for the collection
356
- title: string // Human-readable title of the collection
357
- description: string // Description of collection
362
+ id: string
363
+ title: string
364
+ description: string
358
365
  headerImage?: {
359
- url: string // URL to the asset
360
- thumbnails: { // Thumbnail URLs in different sizes
366
+ url: string
367
+ thumbnails: {
361
368
  x100: string
362
369
  x200: string
363
370
  x512: string
364
371
  }
365
372
  }
366
373
  logoImage?: {
367
- url: string // URL to the asset
368
- thumbnails: { // Thumbnail URLs in different sizes
374
+ url: string
375
+ thumbnails: {
369
376
  x100: string
370
377
  x200: string
371
378
  x512: string
372
379
  }
373
380
  }
374
381
  loaderImage?: {
375
- overwriteName: string // Override name for the file
376
- name: string // Name of the asset
377
- type: string // File type/extension
378
- url: string // URL to the asset
382
+ overwriteName: string
383
+ name: string
384
+ type: string
385
+ url: string
379
386
  }
380
387
  languages?: {
381
- code: string // Language code (e.g., "fr", "it", "es")
382
- lang: string // Human-readable language name (e.g., "French", "Italian")
383
- supported: boolean // Whether this language is supported
388
+ code: string
389
+ lang: string
390
+ supported: boolean
384
391
  }[],
385
392
  roles: {
386
393
  [userId: string]: string
@@ -397,25 +404,25 @@ interface CollectionResponse {
397
404
  **NotificationSubjectTarget** (interface)
398
405
  ```typescript
399
406
  interface NotificationSubjectTarget {
400
- type: 'product' | 'collection' | 'user' | 'batch' | 'proof' // Type of target entity
401
- id: string // ID of the target entity
407
+ type: 'product' | 'collection' | 'user' | 'batch' | 'proof'
408
+ id: string
402
409
  }
403
410
  ```
404
411
 
405
412
  **PushNotificationTemplate** (interface)
406
413
  ```typescript
407
414
  interface PushNotificationTemplate {
408
- title: string // Notification title
409
- body: string // Notification body text
410
- icon?: string // Optional icon URL for the notification
415
+ title: string
416
+ body: string
417
+ icon?: string
411
418
  }
412
419
  ```
413
420
 
414
421
  **EmailNotificationTemplate** (interface)
415
422
  ```typescript
416
423
  interface EmailNotificationTemplate {
417
- subject: string // Email subject line
418
- body: string // Email body content (plain text or HTML)
424
+ subject: string
425
+ body: string
419
426
  }
420
427
  ```
421
428
 
@@ -423,9 +430,9 @@ interface EmailNotificationTemplate {
423
430
  ```typescript
424
431
  interface WalletUpdateTemplate {
425
432
  textModulesData?: Array<{
426
- id: string // Module ID
427
- header: string // Module header text
428
- body: string // Module body text
433
+ id: string
434
+ header: string
435
+ body: string
429
436
  }>
430
437
  }
431
438
  ```
@@ -433,42 +440,42 @@ interface WalletUpdateTemplate {
433
440
  **NotificationTemplate** (interface)
434
441
  ```typescript
435
442
  interface NotificationTemplate {
436
- push?: PushNotificationTemplate // Push notification content
437
- email?: EmailNotificationTemplate // Email notification content
438
- walletUpdate?: WalletUpdateTemplate // Wallet pass update content
443
+ push?: PushNotificationTemplate
444
+ email?: EmailNotificationTemplate
445
+ walletUpdate?: WalletUpdateTemplate
439
446
  }
440
447
  ```
441
448
 
442
449
  **SendNotificationRequest** (interface)
443
450
  ```typescript
444
451
  interface SendNotificationRequest {
445
- subjectTargets: NotificationSubjectTarget[] // Target subjects that should receive the notification
446
- severity: 'low' | 'normal' | 'important' | 'critical' // Severity level of the notification
447
- mode: 'preferred' | 'all' // Delivery channel mode preference
448
- channels : ("push" | "email" | "wallet")[] // Specific channels to use for delivery
449
- template: NotificationTemplate // Notification content templates for different delivery methods
452
+ subjectTargets: NotificationSubjectTarget[]
453
+ severity: 'low' | 'normal' | 'important' | 'critical'
454
+ mode: 'preferred' | 'all'
455
+ channels : ("push" | "email" | "wallet")[]
456
+ template: NotificationTemplate
450
457
  }
451
458
  ```
452
459
 
453
460
  **SendNotificationResponse** (interface)
454
461
  ```typescript
455
462
  interface SendNotificationResponse {
456
- ok: boolean // Whether the request was accepted
457
- notificationId: string // Unique ID for this notification
458
- counts: { // Basic counts for contacts and attempts
463
+ ok: boolean
464
+ notificationId: string
465
+ counts: {
459
466
  contacts: number
460
467
  attempts: number
461
468
  }
462
- status: { // Detailed status for the notification
469
+ status: {
463
470
  notification: {
464
- notificationId: string // The notification ID (repeated for convenience)
465
- state: 'queued' | 'sent' | 'failed' | 'confirmed' | string // Current processing state
466
- subjectTargets: NotificationSubjectTarget[] // Targets this notification refers to
467
- severity: 'low' | 'normal' | 'important' | 'critical' | string // Severity of this notification
468
- channelsOverride: Record<string, any> // Optional channel overrides used when sending
469
- template: NotificationTemplate // The effective template used
471
+ notificationId: string
472
+ state: 'queued' | 'sent' | 'failed' | 'confirmed' | string
473
+ subjectTargets: NotificationSubjectTarget[]
474
+ severity: 'low' | 'normal' | 'important' | 'critical' | string
475
+ channelsOverride: Record<string, any>
476
+ template: NotificationTemplate
470
477
  }
471
- totals: { // Totals across all contacts
478
+ totals: {
472
479
  queued: number
473
480
  sent: number
474
481
  failed: number
@@ -552,15 +559,15 @@ interface NfcClaimTagRequest {
552
559
  **ProductResponse** (interface)
553
560
  ```typescript
554
561
  interface ProductResponse {
555
- id: string // Unique identifier for the product
556
- name: string // Name of the product
557
- collectionId: string // Unique identifier for the product's collection
558
- description: string // Detailed description of the product
559
- gtin?: string // A product GTIN (Global Trade Item Number)
560
- type?: string // An optional product type from the standard smartlinks types
562
+ id: string
563
+ name: string
564
+ collectionId: string
565
+ description: string
566
+ gtin?: string
567
+ type?: string
561
568
  heroImage: {
562
- url: string // URL to the asset
563
- thumbnails: { // Thumbnail URLs in different sizes
569
+ url: string
570
+ thumbnails: {
564
571
  x100: string
565
572
  x200: string
566
573
  x512: string
@@ -584,15 +591,15 @@ interface ProductResponse {
584
591
  **ProofResponse** (interface)
585
592
  ```typescript
586
593
  interface ProofResponse {
587
- collectionId: string // Unique identifier for the collection
588
- createdAt: string // Creation timestamp
589
- id: string // Unique identifier for the proof
590
- productId: string // Unique identifier for the product
591
- tokenId: string // Unique identifier for the token
592
- userId: string // Unique identifier for the user
593
- claimable: boolean // Is this proof available to be claimed
594
- transient: boolean // Is this proof transient
595
- values: Record<string, any> // Arbitrary key-value pairs for proof values
594
+ collectionId: string
595
+ createdAt: string
596
+ id: string
597
+ productId: string
598
+ tokenId: string
599
+ userId: string
600
+ claimable?: boolean
601
+ transient?: boolean
602
+ values: Record<string, any>
596
603
  }
597
604
  ```
598
605
 
@@ -1116,6 +1123,17 @@ Update a form for a collection (admin only).
1116
1123
  **remove**(collectionId: string, formId: string) → `Promise<void>`
1117
1124
  Delete a form for a collection (admin only).
1118
1125
 
1126
+ ### nfc
1127
+
1128
+ **claimTag**(data: NfcClaimTagRequest) → `Promise<NfcTagInfo>`
1129
+ Claim an NFC tag (public). POST /public/nfc/claimTag
1130
+
1131
+ **validate**(data: NfcValidateRequest) → `Promise<NfcValidateResponse>`
1132
+ Validate an NFC tag payload (public). POST /public/nfc/validate
1133
+
1134
+ **lookupTag**(tagId: string) → `Promise<NfcTagInfo[]>`
1135
+ Lookup a tag by its ID (public). GET /public/nfc/findByTag/:tagId
1136
+
1119
1137
  ### product
1120
1138
 
1121
1139
  **get**(collectionId: string,
package/dist/api/nfc.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  import type { NfcValidateRequest, NfcValidateResponse, NfcTagInfo, NfcClaimTagRequest } from "../types/nfc";
2
- export declare const nfc: {
2
+ export declare namespace nfc {
3
3
  /**
4
4
  * Claim an NFC tag (public).
5
- * POST /api/va/public/nfc/claimTag
5
+ * POST /public/nfc/claimTag
6
6
  */
7
- claimTag(data: NfcClaimTagRequest): Promise<NfcTagInfo>;
7
+ function claimTag(data: NfcClaimTagRequest): Promise<NfcTagInfo>;
8
8
  /**
9
9
  * Validate an NFC tag payload (public).
10
10
  * POST /public/nfc/validate
11
11
  */
12
- validate(data: NfcValidateRequest): Promise<NfcValidateResponse>;
12
+ function validate(data: NfcValidateRequest): Promise<NfcValidateResponse>;
13
13
  /**
14
14
  * Lookup a tag by its ID (public).
15
15
  * GET /public/nfc/findByTag/:tagId
16
16
  */
17
- lookupTag(tagId: string): Promise<NfcTagInfo[]>;
18
- };
17
+ function lookupTag(tagId: string): Promise<NfcTagInfo[]>;
18
+ }
package/dist/api/nfc.js CHANGED
@@ -1,25 +1,29 @@
1
1
  // src/api/nfc.ts
2
2
  import { post, request } from "../http";
3
- export const nfc = {
3
+ export var nfc;
4
+ (function (nfc) {
4
5
  /**
5
6
  * Claim an NFC tag (public).
6
- * POST /api/va/public/nfc/claimTag
7
+ * POST /public/nfc/claimTag
7
8
  */
8
- async claimTag(data) {
9
+ async function claimTag(data) {
9
10
  return post("/public/nfc/claimTag", data);
10
- },
11
+ }
12
+ nfc.claimTag = claimTag;
11
13
  /**
12
14
  * Validate an NFC tag payload (public).
13
15
  * POST /public/nfc/validate
14
16
  */
15
- async validate(data) {
17
+ async function validate(data) {
16
18
  return post("/public/nfc/validate", data);
17
- },
19
+ }
20
+ nfc.validate = validate;
18
21
  /**
19
22
  * Lookup a tag by its ID (public).
20
23
  * GET /public/nfc/findByTag/:tagId
21
24
  */
22
- async lookupTag(tagId) {
25
+ async function lookupTag(tagId) {
23
26
  return request(`/public/nfc/findByTag/${encodeURIComponent(tagId)}`);
24
- },
25
- };
27
+ }
28
+ nfc.lookupTag = lookupTag;
29
+ })(nfc || (nfc = {}));
package/dist/api/proof.js CHANGED
@@ -46,7 +46,7 @@ export var proof;
46
46
  * PUT /public/collection/:collectionId/product/:productId/proof/:proofId
47
47
  */
48
48
  async function claim(collectionId, productId, proofId, values) {
49
- const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}`;
49
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/claim`;
50
50
  return put(path, values);
51
51
  }
52
52
  proof.claim = claim;
package/dist/http.js CHANGED
@@ -68,7 +68,7 @@ function safeBodyPreview(body) {
68
68
  * @property {string} [options.bearerToken] - (Optional) Bearer token for AUTHORIZATION header
69
69
  * @property {boolean} [options.proxyMode] - (Optional) Tells the API that it is running in an iframe via parent proxy
70
70
  */
71
- import { enableAutoIframeResize, isIframe } from './iframe';
71
+ import { iframe } from './iframe';
72
72
  export function initializeApi(options) {
73
73
  // Normalize baseURL by removing trailing slashes.
74
74
  baseURL = options.baseURL.replace(/\/+$/g, "");
@@ -83,8 +83,8 @@ export function initializeApi(options) {
83
83
  : inferredNgrok;
84
84
  extraHeadersGlobal = options.extraHeaders ? Object.assign({}, options.extraHeaders) : {};
85
85
  // Auto-enable iframe resize unless explicitly disabled
86
- if (isIframe() && options.iframeAutoResize !== false) {
87
- enableAutoIframeResize();
86
+ if (iframe.isIframe() && options.iframeAutoResize !== false) {
87
+ iframe.enableAutoIframeResize();
88
88
  }
89
89
  logger = options.logger;
90
90
  logDebug('[smartlinks] initializeApi', {
@@ -93,7 +93,7 @@ export function initializeApi(options) {
93
93
  inferredNgrok,
94
94
  ngrokSkipBrowserWarning,
95
95
  extraHeaders: Object.keys(extraHeadersGlobal),
96
- iframeAutoResizeEnabled: isIframe() && options.iframeAutoResize !== false,
96
+ iframeAutoResizeEnabled: iframe.isIframe() && options.iframeAutoResize !== false,
97
97
  });
98
98
  }
99
99
  /** Enable/disable automatic "ngrok-skip-browser-warning" header. */
package/dist/iframe.d.ts CHANGED
@@ -1,25 +1,27 @@
1
- interface IframeResizeOptions {
2
- /** Minimum ms between height postMessages (default 100). */
3
- intervalMs?: number;
4
- /** Post even if height unchanged (default false). */
5
- alwaysSend?: boolean;
6
- /** Additional payload properties to include with each resize message. */
7
- extra?: Record<string, any>;
8
- /** Custom message type name (default 'smartlinks:resize'). */
9
- messageType?: string;
1
+ export declare namespace iframe {
2
+ interface IframeResizeOptions {
3
+ /** Minimum ms between height postMessages (default 100). */
4
+ intervalMs?: number;
5
+ /** Post even if height unchanged (default false). */
6
+ alwaysSend?: boolean;
7
+ /** Additional payload properties to include with each resize message. */
8
+ extra?: Record<string, any>;
9
+ /** Custom message type name (default 'smartlinks:resize'). */
10
+ messageType?: string;
11
+ }
12
+ /** Redirect parent window to a URL (if in iframe). */
13
+ export function redirectParent(url: string): void;
14
+ /** Request parent to adjust iframe height to current content height. */
15
+ export function sendHeight(height?: number, extra?: Record<string, any>): void;
16
+ /** Enable automatic height reporting to parent iframe. */
17
+ export function enableAutoIframeResize(options?: IframeResizeOptions): void;
18
+ /** Disable automatic height reporting. */
19
+ export function disableAutoIframeResize(): void;
20
+ /** Send a custom message to parent (browser-only). */
21
+ export function sendParentCustom(type: string, payload: Record<string, any>): void;
22
+ /** Returns true if running inside an iframe (browser). */
23
+ export function isIframe(): boolean;
24
+ /** Returns true if ResizeObserver is supported in current environment. */
25
+ export function supportsResizeObserver(): boolean;
26
+ export {};
10
27
  }
11
- /** Redirect parent window to a URL (if in iframe). */
12
- export declare function redirectParent(url: string): void;
13
- /** Request parent to adjust iframe height to current content height. */
14
- export declare function sendHeight(height?: number, extra?: Record<string, any>): void;
15
- /** Enable automatic height reporting to parent iframe. */
16
- export declare function enableAutoIframeResize(options?: IframeResizeOptions): void;
17
- /** Disable automatic height reporting. */
18
- export declare function disableAutoIframeResize(): void;
19
- /** Send a custom message to parent (browser-only). */
20
- export declare function sendParentCustom(type: string, payload: Record<string, any>): void;
21
- /** Returns true if running inside an iframe (browser). */
22
- export declare function isIframe(): boolean;
23
- /** Returns true if ResizeObserver is supported in current environment. */
24
- export declare function supportsResizeObserver(): boolean;
25
- export {};
package/dist/iframe.js CHANGED
@@ -2,122 +2,132 @@
2
2
  // Utilities to communicate with parent window when running inside an iframe.
3
3
  // These helpers are optional and safe in non-browser / Node environments.
4
4
  // They build on the existing proxyMode infrastructure but can also be used standalone.
5
- let autoResizeTimer;
6
- let lastHeight = 0;
7
- let resizeOptions;
8
- let resizeObserver;
9
- let mutationObserver;
10
- function isBrowser() {
11
- return typeof window !== 'undefined' && typeof document !== 'undefined';
12
- }
13
- function inIframe() {
14
- return isBrowser() && window.parent && window.parent !== window;
15
- }
16
- function postParentMessage(type, payload) {
17
- if (!inIframe())
18
- return;
19
- try {
20
- window.parent.postMessage({ _smartlinksIframeMessage: true, type, payload }, '*');
5
+ export var iframe;
6
+ (function (iframe) {
7
+ let autoResizeTimer;
8
+ let lastHeight = 0;
9
+ let resizeOptions;
10
+ let resizeObserver;
11
+ let mutationObserver;
12
+ function isBrowser() {
13
+ return typeof window !== 'undefined' && typeof document !== 'undefined';
21
14
  }
22
- catch (_a) {
23
- // swallow errors silently
15
+ function inIframe() {
16
+ return isBrowser() && window.parent && window.parent !== window;
24
17
  }
25
- }
26
- /** Redirect parent window to a URL (if in iframe). */
27
- export function redirectParent(url) {
28
- postParentMessage('smartlinks:redirect', { url });
29
- }
30
- /** Request parent to adjust iframe height to current content height. */
31
- export function sendHeight(height, extra) {
32
- if (!inIframe())
33
- return;
34
- const h = height !== null && height !== void 0 ? height : document.documentElement.scrollHeight;
35
- postParentMessage((resizeOptions === null || resizeOptions === void 0 ? void 0 : resizeOptions.messageType) || 'smartlinks:resize', Object.assign(Object.assign({ height: h }, resizeOptions === null || resizeOptions === void 0 ? void 0 : resizeOptions.extra), extra));
36
- }
37
- function measureHeight() {
38
- if (!isBrowser())
39
- return 0;
40
- const doc = document.documentElement;
41
- // Use max of several properties for robustness
42
- return Math.max(doc.scrollHeight, doc.offsetHeight, doc.clientHeight, document.body ? document.body.scrollHeight : 0, document.body ? document.body.offsetHeight : 0);
43
- }
44
- function scheduleManualPolling() {
45
- var _a;
46
- if (!isBrowser())
47
- return;
48
- clearInterval(autoResizeTimer);
49
- const interval = (_a = resizeOptions === null || resizeOptions === void 0 ? void 0 : resizeOptions.intervalMs) !== null && _a !== void 0 ? _a : 100;
50
- autoResizeTimer = window.setInterval(() => {
51
- const h = measureHeight();
52
- if ((resizeOptions === null || resizeOptions === void 0 ? void 0 : resizeOptions.alwaysSend) || h !== lastHeight) {
53
- lastHeight = h;
54
- sendHeight(h);
18
+ function postParentMessage(type, payload) {
19
+ if (!inIframe())
20
+ return;
21
+ try {
22
+ window.parent.postMessage({ _smartlinksIframeMessage: true, type, payload }, '*');
55
23
  }
56
- }, interval);
57
- }
58
- function setupObservers() {
59
- if (!isBrowser())
60
- return;
61
- // Prefer ResizeObserver for layout changes
62
- if (typeof ResizeObserver !== 'undefined') {
63
- resizeObserver = new ResizeObserver(() => {
64
- const h = measureHeight();
65
- if ((resizeOptions === null || resizeOptions === void 0 ? void 0 : resizeOptions.alwaysSend) || h !== lastHeight) {
66
- lastHeight = h;
67
- sendHeight(h);
68
- }
69
- });
70
- resizeObserver.observe(document.body);
24
+ catch (_a) {
25
+ // swallow errors silently
26
+ }
27
+ }
28
+ /** Redirect parent window to a URL (if in iframe). */
29
+ function redirectParent(url) {
30
+ postParentMessage('smartlinks:redirect', { url });
31
+ }
32
+ iframe.redirectParent = redirectParent;
33
+ /** Request parent to adjust iframe height to current content height. */
34
+ function sendHeight(height, extra) {
35
+ if (!inIframe())
36
+ return;
37
+ const h = height !== null && height !== void 0 ? height : document.documentElement.scrollHeight;
38
+ postParentMessage((resizeOptions === null || resizeOptions === void 0 ? void 0 : resizeOptions.messageType) || 'smartlinks:resize', Object.assign(Object.assign({ height: h }, resizeOptions === null || resizeOptions === void 0 ? void 0 : resizeOptions.extra), extra));
71
39
  }
72
- else {
73
- // Fallback: MutationObserver for DOM changes
74
- mutationObserver = new MutationObserver(() => {
40
+ iframe.sendHeight = sendHeight;
41
+ function measureHeight() {
42
+ if (!isBrowser())
43
+ return 0;
44
+ const doc = document.documentElement;
45
+ // Use max of several properties for robustness
46
+ return Math.max(doc.scrollHeight, doc.offsetHeight, doc.clientHeight, document.body ? document.body.scrollHeight : 0, document.body ? document.body.offsetHeight : 0);
47
+ }
48
+ function scheduleManualPolling() {
49
+ var _a;
50
+ if (!isBrowser())
51
+ return;
52
+ clearInterval(autoResizeTimer);
53
+ const interval = (_a = resizeOptions === null || resizeOptions === void 0 ? void 0 : resizeOptions.intervalMs) !== null && _a !== void 0 ? _a : 100;
54
+ autoResizeTimer = window.setInterval(() => {
75
55
  const h = measureHeight();
76
56
  if ((resizeOptions === null || resizeOptions === void 0 ? void 0 : resizeOptions.alwaysSend) || h !== lastHeight) {
77
57
  lastHeight = h;
78
58
  sendHeight(h);
79
59
  }
80
- });
81
- mutationObserver.observe(document.body, { childList: true, subtree: true, attributes: true });
82
- // Manual polling as additional safeguard
83
- scheduleManualPolling();
60
+ }, interval);
84
61
  }
85
- }
86
- /** Enable automatic height reporting to parent iframe. */
87
- export function enableAutoIframeResize(options) {
88
- if (!inIframe())
89
- return;
90
- resizeOptions = options || {};
91
- lastHeight = measureHeight();
92
- sendHeight(lastHeight);
93
- setupObservers();
94
- if (!resizeObserver) {
95
- // If no ResizeObserver, MutationObserver is active and we also poll
96
- scheduleManualPolling();
62
+ function setupObservers() {
63
+ if (!isBrowser())
64
+ return;
65
+ // Prefer ResizeObserver for layout changes
66
+ if (typeof ResizeObserver !== 'undefined') {
67
+ resizeObserver = new ResizeObserver(() => {
68
+ const h = measureHeight();
69
+ if ((resizeOptions === null || resizeOptions === void 0 ? void 0 : resizeOptions.alwaysSend) || h !== lastHeight) {
70
+ lastHeight = h;
71
+ sendHeight(h);
72
+ }
73
+ });
74
+ resizeObserver.observe(document.body);
75
+ }
76
+ else {
77
+ // Fallback: MutationObserver for DOM changes
78
+ mutationObserver = new MutationObserver(() => {
79
+ const h = measureHeight();
80
+ if ((resizeOptions === null || resizeOptions === void 0 ? void 0 : resizeOptions.alwaysSend) || h !== lastHeight) {
81
+ lastHeight = h;
82
+ sendHeight(h);
83
+ }
84
+ });
85
+ mutationObserver.observe(document.body, { childList: true, subtree: true, attributes: true });
86
+ // Manual polling as additional safeguard
87
+ scheduleManualPolling();
88
+ }
97
89
  }
98
- }
99
- /** Disable automatic height reporting. */
100
- export function disableAutoIframeResize() {
101
- if (resizeObserver)
102
- resizeObserver.disconnect();
103
- if (mutationObserver)
104
- mutationObserver.disconnect();
105
- if (isBrowser())
106
- clearInterval(autoResizeTimer);
107
- resizeObserver = undefined;
108
- mutationObserver = undefined;
109
- autoResizeTimer = undefined;
110
- resizeOptions = undefined;
111
- }
112
- /** Send a custom message to parent (browser-only). */
113
- export function sendParentCustom(type, payload) {
114
- postParentMessage(type, payload);
115
- }
116
- /** Returns true if running inside an iframe (browser). */
117
- export function isIframe() {
118
- return inIframe();
119
- }
120
- /** Returns true if ResizeObserver is supported in current environment. */
121
- export function supportsResizeObserver() {
122
- return typeof ResizeObserver !== 'undefined';
123
- }
90
+ /** Enable automatic height reporting to parent iframe. */
91
+ function enableAutoIframeResize(options) {
92
+ if (!inIframe())
93
+ return;
94
+ resizeOptions = options || {};
95
+ lastHeight = measureHeight();
96
+ sendHeight(lastHeight);
97
+ setupObservers();
98
+ if (!resizeObserver) {
99
+ // If no ResizeObserver, MutationObserver is active and we also poll
100
+ scheduleManualPolling();
101
+ }
102
+ }
103
+ iframe.enableAutoIframeResize = enableAutoIframeResize;
104
+ /** Disable automatic height reporting. */
105
+ function disableAutoIframeResize() {
106
+ if (resizeObserver)
107
+ resizeObserver.disconnect();
108
+ if (mutationObserver)
109
+ mutationObserver.disconnect();
110
+ if (isBrowser())
111
+ clearInterval(autoResizeTimer);
112
+ resizeObserver = undefined;
113
+ mutationObserver = undefined;
114
+ autoResizeTimer = undefined;
115
+ resizeOptions = undefined;
116
+ }
117
+ iframe.disableAutoIframeResize = disableAutoIframeResize;
118
+ /** Send a custom message to parent (browser-only). */
119
+ function sendParentCustom(type, payload) {
120
+ postParentMessage(type, payload);
121
+ }
122
+ iframe.sendParentCustom = sendParentCustom;
123
+ /** Returns true if running inside an iframe (browser). */
124
+ function isIframe() {
125
+ return inIframe();
126
+ }
127
+ iframe.isIframe = isIframe;
128
+ /** Returns true if ResizeObserver is supported in current environment. */
129
+ function supportsResizeObserver() {
130
+ return typeof ResizeObserver !== 'undefined';
131
+ }
132
+ iframe.supportsResizeObserver = supportsResizeObserver;
133
+ })(iframe || (iframe = {}));
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { initializeApi, request, sendCustomProxyMessage } from "./http";
2
2
  export * from "./api";
3
3
  export * from "./types";
4
+ export { iframe } from "./iframe";
4
5
  export type { LoginResponse, VerifyTokenResponse, AccountInfoResponse, } from "./api/auth";
5
6
  export type { UserAccountRegistrationRequest, } from "./types/auth";
6
7
  export type { SendNotificationRequest, SendNotificationResponse, NotificationSubjectTarget, NotificationTemplate, PushNotificationTemplate, EmailNotificationTemplate, WalletUpdateTemplate, } from "./types/comms";
package/dist/index.js CHANGED
@@ -3,3 +3,5 @@
3
3
  export { initializeApi, request, sendCustomProxyMessage } from "./http";
4
4
  export * from "./api";
5
5
  export * from "./types";
6
+ // Iframe namespace
7
+ export { iframe } from "./iframe";
@@ -1,17 +1,28 @@
1
1
  export interface AttestationResponse {
2
+ /** Attestation id */
2
3
  id: string;
4
+ /** Creation timestamp */
3
5
  createdAt: string;
6
+ /** Last updated timestamp */
4
7
  updatedAt: string;
8
+ /** Public attestation data */
5
9
  public: Record<string, any>;
10
+ /** Private attestation data */
6
11
  private: Record<string, any>;
12
+ /** Associated proof reference/data */
7
13
  proof: Record<string, any>;
8
14
  }
9
15
  export interface AttestationCreateRequest {
16
+ /** Public attestation payload */
10
17
  public: Record<string, any>;
18
+ /** Private attestation payload */
11
19
  private: Record<string, any>;
20
+ /** Proof linkage or payload */
12
21
  proof: Record<string, any>;
13
22
  }
14
23
  export interface AttestationUpdateRequest {
24
+ /** Update operation/type */
15
25
  type?: string;
26
+ /** Partial attestation data */
16
27
  data?: Record<string, any>;
17
28
  }
@@ -1,9 +1,16 @@
1
1
  export type UserAccountRegistrationRequest = {
2
+ /** User's display name */
2
3
  name: string;
4
+ /** Optional user email */
3
5
  email?: string;
6
+ /** Optional user phone number */
4
7
  phone?: string;
8
+ /** Optional password for email login */
5
9
  password?: string;
10
+ /** Send confirmation email after registration */
6
11
  sendAccountConfirmation?: boolean;
12
+ /** Optional collection context for registration */
7
13
  collectionId?: string;
14
+ /** Desired token type returned */
8
15
  tokenType?: 'bearer' | 'firebase';
9
16
  };
@@ -1,18 +1,40 @@
1
+ /**
2
+ * Reference to a specific claim attached to a code/tag.
3
+ */
1
4
  export interface ClaimCodeRef {
5
+ /** Identifier of the code (e.g., tag or QR code) */
2
6
  codeId: string;
7
+ /** Identifier of the claim within the claim set */
3
8
  claimId: string;
4
9
  }
10
+ /**
11
+ * Request body for updating claim data on a claim set.
12
+ * Contains arbitrary key/value pairs and a list of code+claim references to update.
13
+ */
5
14
  export interface UpdateClaimDataRequest {
15
+ /** Arbitrary key/value pairs for the claim data update */
6
16
  data: Record<string, any>;
17
+ /** Array of code+claim references affected by this update */
7
18
  codes: ClaimCodeRef[];
8
19
  }
20
+ /**
21
+ * Request body for assigning claims to codes or ranges within a collection.
22
+ */
9
23
  export interface AssignClaimsRequest {
24
+ /** The claim set ID (required) */
10
25
  id: string;
26
+ /** The collection ID (required) */
11
27
  collectionId: string;
28
+ /** The product ID (required) */
12
29
  productId: string;
30
+ /** Optional batch identifier */
13
31
  batchId?: string;
32
+ /** Optional start index for bulk assignment */
14
33
  start?: number;
34
+ /** Optional end index for bulk assignment */
15
35
  end?: number;
36
+ /** Optional single code identifier for single assignment */
16
37
  codeId?: string;
38
+ /** Optional key/value pairs to set on the claim */
17
39
  data?: Record<string, any>;
18
40
  }
@@ -2,12 +2,17 @@
2
2
  * Represents a Collection object.
3
3
  */
4
4
  export interface CollectionResponse {
5
+ /** Unique identifier for the collection */
5
6
  id: string;
7
+ /** Human-readable title of the collection */
6
8
  title: string;
9
+ /** Description of collection */
7
10
  description: string;
8
11
  /** URL to the collection's larger header/hero image */
9
12
  headerImage?: {
13
+ /** URL to the asset */
10
14
  url: string;
15
+ /** Thumbnail URLs in different sizes */
11
16
  thumbnails: {
12
17
  x100: string;
13
18
  x200: string;
@@ -16,7 +21,9 @@ export interface CollectionResponse {
16
21
  };
17
22
  /** URL to the collection's logo image */
18
23
  logoImage?: {
24
+ /** URL to the asset */
19
25
  url: string;
26
+ /** Thumbnail URLs in different sizes */
20
27
  thumbnails: {
21
28
  x100: string;
22
29
  x200: string;
@@ -25,15 +32,22 @@ export interface CollectionResponse {
25
32
  };
26
33
  /** Collection's loader image */
27
34
  loaderImage?: {
35
+ /** Override name for the file */
28
36
  overwriteName: string;
37
+ /** Name of the asset */
29
38
  name: string;
39
+ /** File type/extension */
30
40
  type: string;
41
+ /** URL to the asset */
31
42
  url: string;
32
43
  };
33
44
  /** Array of supported languages */
34
45
  languages?: {
46
+ /** Language code (e.g., "fr", "it", "es") */
35
47
  code: string;
48
+ /** Human-readable language name (e.g., "French", "Italian") */
36
49
  lang: string;
50
+ /** Whether this language is supported */
37
51
  supported: boolean;
38
52
  }[];
39
53
  /** User roles mapping with user IDs as keys and role names as values */
@@ -2,22 +2,29 @@
2
2
  * Target subject for notifications (product, collection, etc.)
3
3
  */
4
4
  export interface NotificationSubjectTarget {
5
+ /** Type of target entity */
5
6
  type: 'product' | 'collection' | 'user' | 'batch' | 'proof';
7
+ /** ID of the target entity */
6
8
  id: string;
7
9
  }
8
10
  /**
9
11
  * Push notification template content
10
12
  */
11
13
  export interface PushNotificationTemplate {
14
+ /** Notification title */
12
15
  title: string;
16
+ /** Notification body text */
13
17
  body: string;
18
+ /** Optional icon URL for the notification */
14
19
  icon?: string;
15
20
  }
16
21
  /**
17
22
  * Email notification template content
18
23
  */
19
24
  export interface EmailNotificationTemplate {
25
+ /** Email subject line */
20
26
  subject: string;
27
+ /** Email body content (plain text or HTML) */
21
28
  body: string;
22
29
  }
23
30
  /**
@@ -25,8 +32,11 @@ export interface EmailNotificationTemplate {
25
32
  */
26
33
  export interface WalletUpdateTemplate {
27
34
  textModulesData?: Array<{
35
+ /** Module ID */
28
36
  id: string;
37
+ /** Module header text */
29
38
  header: string;
39
+ /** Module body text */
30
40
  body: string;
31
41
  }>;
32
42
  }
@@ -34,39 +44,58 @@ export interface WalletUpdateTemplate {
34
44
  * Notification template containing different delivery methods
35
45
  */
36
46
  export interface NotificationTemplate {
47
+ /** Push notification content */
37
48
  push?: PushNotificationTemplate;
49
+ /** Email notification content */
38
50
  email?: EmailNotificationTemplate;
51
+ /** Wallet pass update content */
39
52
  walletUpdate?: WalletUpdateTemplate;
40
53
  }
41
54
  /**
42
55
  * Request payload for sending notifications
43
56
  */
44
57
  export interface SendNotificationRequest {
58
+ /** Target subjects that should receive the notification */
45
59
  subjectTargets: NotificationSubjectTarget[];
60
+ /** Severity level of the notification */
46
61
  severity: 'low' | 'normal' | 'important' | 'critical';
62
+ /** Delivery channel mode preference */
47
63
  mode: 'preferred' | 'all';
64
+ /** Specific channels to use for delivery */
48
65
  channels: ("push" | "email" | "wallet")[];
66
+ /** Notification content templates for different delivery methods */
49
67
  template: NotificationTemplate;
50
68
  }
51
69
  /**
52
70
  * Response from sending notifications
53
71
  */
54
72
  export interface SendNotificationResponse {
73
+ /** Whether the request was accepted */
55
74
  ok: boolean;
75
+ /** Unique ID for this notification */
56
76
  notificationId: string;
77
+ /** Basic counts for contacts and attempts */
57
78
  counts: {
58
79
  contacts: number;
59
80
  attempts: number;
60
81
  };
82
+ /** Detailed status for the notification */
61
83
  status: {
62
84
  notification: {
85
+ /** The notification ID (repeated for convenience) */
63
86
  notificationId: string;
87
+ /** Current processing state */
64
88
  state: 'queued' | 'sent' | 'failed' | 'confirmed' | string;
89
+ /** Targets this notification refers to */
65
90
  subjectTargets: NotificationSubjectTarget[];
91
+ /** Severity of this notification */
66
92
  severity: 'low' | 'normal' | 'important' | 'critical' | string;
93
+ /** Optional channel overrides used when sending */
67
94
  channelsOverride: Record<string, any>;
95
+ /** The effective template used */
68
96
  template: NotificationTemplate;
69
97
  };
98
+ /** Totals across all contacts */
70
99
  totals: {
71
100
  queued: number;
72
101
  sent: number;
@@ -2,15 +2,23 @@
2
2
  * Represents a Product Item object.
3
3
  */
4
4
  export interface ProductResponse {
5
+ /** Unique identifier for the product */
5
6
  id: string;
7
+ /** Name of the product */
6
8
  name: string;
9
+ /** Unique identifier for the product's collection */
7
10
  collectionId: string;
11
+ /** Detailed description of the product */
8
12
  description: string;
13
+ /** A product GTIN (Global Trade Item Number) */
9
14
  gtin?: string;
15
+ /** An optional product type from the standard smartlinks types */
10
16
  type?: string;
11
17
  /** Hero image asset object */
12
18
  heroImage: {
19
+ /** URL to the asset */
13
20
  url: string;
21
+ /** Thumbnail URLs in different sizes */
14
22
  thumbnails: {
15
23
  x100: string;
16
24
  x200: string;
@@ -2,13 +2,22 @@
2
2
  * Represents a Proof object.
3
3
  */
4
4
  export interface ProofResponse {
5
+ /** Unique identifier for the collection */
5
6
  collectionId: string;
7
+ /** Creation timestamp */
6
8
  createdAt: string;
9
+ /** Unique identifier for the proof */
7
10
  id: string;
11
+ /** Unique identifier for the product */
8
12
  productId: string;
13
+ /** Unique identifier for the token */
9
14
  tokenId: string;
15
+ /** Unique identifier for the user */
10
16
  userId: string;
11
- claimable: boolean;
12
- transient: boolean;
17
+ /** Is this proof available to be claimed */
18
+ claimable?: boolean;
19
+ /** Is this proof transient */
20
+ transient?: boolean;
21
+ /** Arbitrary key-value pairs for proof values */
13
22
  values: Record<string, any>;
14
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "1.0.58",
3
+ "version": "1.0.61",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",