@proveanything/smartlinks 1.0.60 → 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 +99 -92
- package/dist/http.js +4 -4
- package/dist/iframe.d.ts +26 -24
- package/dist/iframe.js +118 -108
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/types/attestation.d.ts +11 -0
- package/dist/types/auth.d.ts +7 -0
- package/dist/types/claimSet.d.ts +22 -0
- package/dist/types/collection.d.ts +14 -0
- package/dist/types/comms.d.ts +29 -0
- package/dist/types/product.d.ts +8 -0
- package/dist/types/proof.d.ts +11 -2
- package/package.json +1 -1
package/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 1.0.
|
|
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
|
|
112
|
-
createdAt: string
|
|
113
|
-
updatedAt: string
|
|
114
|
-
public: Record<string, any>
|
|
115
|
-
private: Record<string, any>
|
|
116
|
-
proof: Record<string, any>
|
|
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>
|
|
124
|
-
private: Record<string, any>
|
|
125
|
-
proof: Record<string, any>
|
|
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
|
|
133
|
-
data?: Record<string, any>
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
|
324
|
-
claimId: string
|
|
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>
|
|
332
|
-
codes: ClaimCodeRef[]
|
|
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
|
|
340
|
-
collectionId: string
|
|
341
|
-
productId: string
|
|
342
|
-
batchId?: string
|
|
343
|
-
start?: number
|
|
344
|
-
end?: number
|
|
345
|
-
codeId?: string
|
|
346
|
-
data?: Record<string, any>
|
|
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
|
|
356
|
-
title: string
|
|
357
|
-
description: string
|
|
362
|
+
id: string
|
|
363
|
+
title: string
|
|
364
|
+
description: string
|
|
358
365
|
headerImage?: {
|
|
359
|
-
url: string
|
|
360
|
-
thumbnails: {
|
|
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
|
|
368
|
-
thumbnails: {
|
|
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
|
|
376
|
-
name: string
|
|
377
|
-
type: string
|
|
378
|
-
url: string
|
|
382
|
+
overwriteName: string
|
|
383
|
+
name: string
|
|
384
|
+
type: string
|
|
385
|
+
url: string
|
|
379
386
|
}
|
|
380
387
|
languages?: {
|
|
381
|
-
code: string
|
|
382
|
-
lang: string
|
|
383
|
-
supported: boolean
|
|
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'
|
|
401
|
-
id: string
|
|
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
|
|
409
|
-
body: string
|
|
410
|
-
icon?: string
|
|
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
|
|
418
|
-
body: string
|
|
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
|
|
427
|
-
header: string
|
|
428
|
-
body: string
|
|
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
|
|
437
|
-
email?: EmailNotificationTemplate
|
|
438
|
-
walletUpdate?: WalletUpdateTemplate
|
|
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[]
|
|
446
|
-
severity: 'low' | 'normal' | 'important' | 'critical'
|
|
447
|
-
mode: 'preferred' | 'all'
|
|
448
|
-
channels : ("push" | "email" | "wallet")[]
|
|
449
|
-
template: NotificationTemplate
|
|
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
|
|
457
|
-
notificationId: string
|
|
458
|
-
counts: {
|
|
463
|
+
ok: boolean
|
|
464
|
+
notificationId: string
|
|
465
|
+
counts: {
|
|
459
466
|
contacts: number
|
|
460
467
|
attempts: number
|
|
461
468
|
}
|
|
462
|
-
status: {
|
|
469
|
+
status: {
|
|
463
470
|
notification: {
|
|
464
|
-
notificationId: string
|
|
465
|
-
state: 'queued' | 'sent' | 'failed' | 'confirmed' | string
|
|
466
|
-
subjectTargets: NotificationSubjectTarget[]
|
|
467
|
-
severity: 'low' | 'normal' | 'important' | 'critical' | string
|
|
468
|
-
channelsOverride: Record<string, any>
|
|
469
|
-
template: NotificationTemplate
|
|
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: {
|
|
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
|
|
556
|
-
name: string
|
|
557
|
-
collectionId: string
|
|
558
|
-
description: string
|
|
559
|
-
gtin?: string
|
|
560
|
-
type?: string
|
|
562
|
+
id: string
|
|
563
|
+
name: string
|
|
564
|
+
collectionId: string
|
|
565
|
+
description: string
|
|
566
|
+
gtin?: string
|
|
567
|
+
type?: string
|
|
561
568
|
heroImage: {
|
|
562
|
-
url: string
|
|
563
|
-
thumbnails: {
|
|
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
|
|
588
|
-
createdAt: string
|
|
589
|
-
id: string
|
|
590
|
-
productId: string
|
|
591
|
-
tokenId: string
|
|
592
|
-
userId: string
|
|
593
|
-
claimable
|
|
594
|
-
transient
|
|
595
|
-
values: Record<string, any>
|
|
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
|
|
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 {
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
let
|
|
8
|
-
let
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
23
|
-
|
|
15
|
+
function inIframe() {
|
|
16
|
+
return isBrowser() && window.parent && window.parent !== window;
|
|
24
17
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
@@ -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
|
}
|
package/dist/types/auth.d.ts
CHANGED
|
@@ -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
|
};
|
package/dist/types/claimSet.d.ts
CHANGED
|
@@ -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 */
|
package/dist/types/comms.d.ts
CHANGED
|
@@ -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;
|
package/dist/types/product.d.ts
CHANGED
|
@@ -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;
|
package/dist/types/proof.d.ts
CHANGED
|
@@ -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
|
-
|
|
12
|
-
|
|
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
|
}
|