@proveanything/smartlinks 2.1.27 → 2.1.28
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/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/wallet.d.ts +93 -0
- package/dist/api/wallet.js +86 -0
- package/dist/docs/API_SUMMARY.md +120 -1
- package/dist/docs/wallet-passes.md +87 -0
- package/dist/openapi.yaml +154 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/wallet.d.ts +92 -0
- package/dist/types/wallet.js +1 -0
- package/docs/API_SUMMARY.md +120 -1
- package/docs/wallet-passes.md +87 -0
- package/openapi.yaml +154 -0
- package/package.json +87 -87
package/dist/api/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export { jobs } from "./jobs.js";
|
|
|
27
27
|
export { segments } from "./segments.js";
|
|
28
28
|
export { userGroups } from "./userGroups.js";
|
|
29
29
|
export { conditions } from "./conditions.js";
|
|
30
|
+
export { wallet } from "./wallet.js";
|
|
30
31
|
export { operations } from "./operations.js";
|
|
31
32
|
export { journeys } from "./journeys.js";
|
|
32
33
|
export { journeysAnalytics } from "./journeysAnalytics.js";
|
package/dist/api/index.js
CHANGED
|
@@ -29,6 +29,7 @@ export { jobs } from "./jobs.js";
|
|
|
29
29
|
export { segments } from "./segments.js";
|
|
30
30
|
export { userGroups } from "./userGroups.js";
|
|
31
31
|
export { conditions } from "./conditions.js";
|
|
32
|
+
export { wallet } from "./wallet.js";
|
|
32
33
|
export { operations } from "./operations.js";
|
|
33
34
|
export { journeys } from "./journeys.js";
|
|
34
35
|
export { journeysAnalytics } from "./journeysAnalytics.js";
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { WalletPass, WalletPassRef, WalletPassSummary, WalletPassContent, IssueWalletPassRequest } from "../types/wallet.js";
|
|
2
|
+
/**
|
|
3
|
+
* Wallet passes: an event ticket, booking, membership card or loyalty card in the person's Apple Wallet or
|
|
4
|
+
* Google Wallet, branded from the site (docs/wallet-passes.md).
|
|
5
|
+
*
|
|
6
|
+
* - In a page: `wallet.addLinks(collectionId, ref)` gives the signed-in person "Add to Wallet" links for their own
|
|
7
|
+
* booking (`{ type: 'booking', id }`), their membership card (`{ type: 'contact', id: 'me' }`), or a pass your app
|
|
8
|
+
* already issued them.
|
|
9
|
+
* - In a server function: `ctx.sl.wallet.issue / update / void / message` (needs `sl:wallet:write`). Passes follow
|
|
10
|
+
* their booking: a move changes the date on the pass, a cancellation voids it.
|
|
11
|
+
* - Admin: list, look up by QR code at the door, issue, change, void, message.
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace wallet {
|
|
14
|
+
/**
|
|
15
|
+
* "Add to Wallet" links for the signed-in person's pass about `ref` (made on first ask for a booking or a
|
|
16
|
+
* membership card).
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const { pass } = await wallet.addLinks('coll_123', { type: 'booking', id: booking.id })
|
|
21
|
+
* if (pass.links.apple) appleButton.href = pass.links.apple
|
|
22
|
+
* if (pass.links.google) googleButton.href = pass.links.google
|
|
23
|
+
* ```
|
|
24
|
+
* @throws `SIGN_IN_REQUIRED`, `NOT_FOUND` (not theirs, or nothing issued yet), `WALLET_OFF`
|
|
25
|
+
*/
|
|
26
|
+
function addLinks(collectionId: string, ref: WalletPassRef): Promise<{
|
|
27
|
+
ok: true;
|
|
28
|
+
pass: WalletPassSummary;
|
|
29
|
+
}>;
|
|
30
|
+
/** The signed-in person's active passes on this site, with their links. */
|
|
31
|
+
function mine(collectionId: string): Promise<{
|
|
32
|
+
ok: true;
|
|
33
|
+
passes: WalletPassSummary[];
|
|
34
|
+
}>;
|
|
35
|
+
/** Which wallets are switched on (admin). */
|
|
36
|
+
function status(collectionId: string): Promise<{
|
|
37
|
+
ok: true;
|
|
38
|
+
google: boolean;
|
|
39
|
+
apple: boolean;
|
|
40
|
+
}>;
|
|
41
|
+
/** Passes for one thing (`refType` + `refId`) or one person (`contactId`) (admin). */
|
|
42
|
+
function list(collectionId: string, query: {
|
|
43
|
+
refType?: string;
|
|
44
|
+
refId?: string;
|
|
45
|
+
contactId?: string;
|
|
46
|
+
includeVoided?: boolean;
|
|
47
|
+
}): Promise<{
|
|
48
|
+
ok: true;
|
|
49
|
+
passes: WalletPass[];
|
|
50
|
+
}>;
|
|
51
|
+
/** One pass, with its links (admin). */
|
|
52
|
+
function get(collectionId: string, passId: string): Promise<{
|
|
53
|
+
ok: true;
|
|
54
|
+
pass: WalletPass;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* The pass whose QR this is, for checking a ticket at the door (admin). `valid` is false for a voided pass.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const { pass, valid } = await wallet.byCode('coll_123', scannedValue)
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
function byCode(collectionId: string, code: string): Promise<{
|
|
65
|
+
ok: true;
|
|
66
|
+
pass: WalletPass;
|
|
67
|
+
valid: boolean;
|
|
68
|
+
}>;
|
|
69
|
+
/** Issue a pass (admin). Issuing again for the same thing, person and kind changes the existing pass. */
|
|
70
|
+
function issue(collectionId: string, input: IssueWalletPassRequest): Promise<{
|
|
71
|
+
ok: true;
|
|
72
|
+
pass: WalletPass;
|
|
73
|
+
}>;
|
|
74
|
+
/** Change what a pass shows; both wallets follow (admin). */
|
|
75
|
+
function update(collectionId: string, passId: string, fields: Partial<Omit<WalletPassContent, "kind">>): Promise<{
|
|
76
|
+
ok: true;
|
|
77
|
+
pass: WalletPass;
|
|
78
|
+
}>;
|
|
79
|
+
/** The pass no longer counts: shown as void on the phone (admin). */
|
|
80
|
+
function voidPass(collectionId: string, passId: string, reason?: string): Promise<{
|
|
81
|
+
ok: true;
|
|
82
|
+
pass: WalletPass;
|
|
83
|
+
}>;
|
|
84
|
+
/** A lock-screen message on the pass (admin). */
|
|
85
|
+
function message(collectionId: string, passId: string, msg: {
|
|
86
|
+
header?: string;
|
|
87
|
+
body: string;
|
|
88
|
+
}): Promise<{
|
|
89
|
+
ok: true;
|
|
90
|
+
sent: boolean;
|
|
91
|
+
pass: WalletPass;
|
|
92
|
+
}>;
|
|
93
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { request, post, patch } from "../http.js";
|
|
2
|
+
/**
|
|
3
|
+
* Wallet passes: an event ticket, booking, membership card or loyalty card in the person's Apple Wallet or
|
|
4
|
+
* Google Wallet, branded from the site (docs/wallet-passes.md).
|
|
5
|
+
*
|
|
6
|
+
* - In a page: `wallet.addLinks(collectionId, ref)` gives the signed-in person "Add to Wallet" links for their own
|
|
7
|
+
* booking (`{ type: 'booking', id }`), their membership card (`{ type: 'contact', id: 'me' }`), or a pass your app
|
|
8
|
+
* already issued them.
|
|
9
|
+
* - In a server function: `ctx.sl.wallet.issue / update / void / message` (needs `sl:wallet:write`). Passes follow
|
|
10
|
+
* their booking: a move changes the date on the pass, a cancellation voids it.
|
|
11
|
+
* - Admin: list, look up by QR code at the door, issue, change, void, message.
|
|
12
|
+
*/
|
|
13
|
+
export var wallet;
|
|
14
|
+
(function (wallet) {
|
|
15
|
+
const pub = (collectionId) => `/public/collection/${encodeURIComponent(collectionId)}/wallet`;
|
|
16
|
+
const adm = (collectionId) => `/admin/collection/${encodeURIComponent(collectionId)}/wallet`;
|
|
17
|
+
/**
|
|
18
|
+
* "Add to Wallet" links for the signed-in person's pass about `ref` (made on first ask for a booking or a
|
|
19
|
+
* membership card).
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const { pass } = await wallet.addLinks('coll_123', { type: 'booking', id: booking.id })
|
|
24
|
+
* if (pass.links.apple) appleButton.href = pass.links.apple
|
|
25
|
+
* if (pass.links.google) googleButton.href = pass.links.google
|
|
26
|
+
* ```
|
|
27
|
+
* @throws `SIGN_IN_REQUIRED`, `NOT_FOUND` (not theirs, or nothing issued yet), `WALLET_OFF`
|
|
28
|
+
*/
|
|
29
|
+
async function addLinks(collectionId, ref) {
|
|
30
|
+
return post(`${pub(collectionId)}/links`, { ref });
|
|
31
|
+
}
|
|
32
|
+
wallet.addLinks = addLinks;
|
|
33
|
+
/** The signed-in person's active passes on this site, with their links. */
|
|
34
|
+
async function mine(collectionId) {
|
|
35
|
+
return request(`${pub(collectionId)}/mine`);
|
|
36
|
+
}
|
|
37
|
+
wallet.mine = mine;
|
|
38
|
+
/** Which wallets are switched on (admin). */
|
|
39
|
+
async function status(collectionId) {
|
|
40
|
+
return request(`${adm(collectionId)}/status`);
|
|
41
|
+
}
|
|
42
|
+
wallet.status = status;
|
|
43
|
+
/** Passes for one thing (`refType` + `refId`) or one person (`contactId`) (admin). */
|
|
44
|
+
async function list(collectionId, query) {
|
|
45
|
+
const qs = new URLSearchParams(Object.entries(query).filter(([, v]) => v != null).map(([k, v]) => [k, String(v)])).toString();
|
|
46
|
+
return request(`${adm(collectionId)}/passes${qs ? `?${qs}` : ""}`);
|
|
47
|
+
}
|
|
48
|
+
wallet.list = list;
|
|
49
|
+
/** One pass, with its links (admin). */
|
|
50
|
+
async function get(collectionId, passId) {
|
|
51
|
+
return request(`${adm(collectionId)}/passes/${encodeURIComponent(passId)}`);
|
|
52
|
+
}
|
|
53
|
+
wallet.get = get;
|
|
54
|
+
/**
|
|
55
|
+
* The pass whose QR this is, for checking a ticket at the door (admin). `valid` is false for a voided pass.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const { pass, valid } = await wallet.byCode('coll_123', scannedValue)
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
async function byCode(collectionId, code) {
|
|
63
|
+
return request(`${adm(collectionId)}/code/${encodeURIComponent(code)}`);
|
|
64
|
+
}
|
|
65
|
+
wallet.byCode = byCode;
|
|
66
|
+
/** Issue a pass (admin). Issuing again for the same thing, person and kind changes the existing pass. */
|
|
67
|
+
async function issue(collectionId, input) {
|
|
68
|
+
return post(`${adm(collectionId)}/passes`, input);
|
|
69
|
+
}
|
|
70
|
+
wallet.issue = issue;
|
|
71
|
+
/** Change what a pass shows; both wallets follow (admin). */
|
|
72
|
+
async function update(collectionId, passId, fields) {
|
|
73
|
+
return patch(`${adm(collectionId)}/passes/${encodeURIComponent(passId)}`, fields);
|
|
74
|
+
}
|
|
75
|
+
wallet.update = update;
|
|
76
|
+
/** The pass no longer counts: shown as void on the phone (admin). */
|
|
77
|
+
async function voidPass(collectionId, passId, reason) {
|
|
78
|
+
return post(`${adm(collectionId)}/passes/${encodeURIComponent(passId)}/void`, { reason });
|
|
79
|
+
}
|
|
80
|
+
wallet.voidPass = voidPass;
|
|
81
|
+
/** A lock-screen message on the pass (admin). */
|
|
82
|
+
async function message(collectionId, passId, msg) {
|
|
83
|
+
return post(`${adm(collectionId)}/passes/${encodeURIComponent(passId)}/message`, msg);
|
|
84
|
+
}
|
|
85
|
+
wallet.message = message;
|
|
86
|
+
})(wallet || (wallet = {}));
|
package/dist/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.28 | Generated: 2026-11-20T09:02:04.143Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -170,6 +170,7 @@ The Smartlinks SDK is organized into the following namespaces:
|
|
|
170
170
|
- **template** - Functions for template operations
|
|
171
171
|
- **translations** - Functions for translations operations
|
|
172
172
|
- **userGroups** - Functions for userGroups operations
|
|
173
|
+
- **wallet** - Functions for wallet operations
|
|
173
174
|
|
|
174
175
|
## HTTP Utilities
|
|
175
176
|
|
|
@@ -12256,6 +12257,92 @@ interface VariantUpdateRequest {
|
|
|
12256
12257
|
}
|
|
12257
12258
|
```
|
|
12258
12259
|
|
|
12260
|
+
### wallet
|
|
12261
|
+
|
|
12262
|
+
**WalletPassRef** (interface)
|
|
12263
|
+
```typescript
|
|
12264
|
+
interface WalletPassRef {
|
|
12265
|
+
type: 'booking' | 'contact' | string
|
|
12266
|
+
id: string
|
|
12267
|
+
}
|
|
12268
|
+
```
|
|
12269
|
+
|
|
12270
|
+
**WalletPassContent** (interface)
|
|
12271
|
+
```typescript
|
|
12272
|
+
interface WalletPassContent {
|
|
12273
|
+
kind: WalletPassKind
|
|
12274
|
+
title: string
|
|
12275
|
+
subtitle?: string
|
|
12276
|
+
start?: string
|
|
12277
|
+
end?: string
|
|
12278
|
+
timezone?: string
|
|
12279
|
+
venue?: { name?: string; address?: string; lat?: number; lng?: number }
|
|
12280
|
+
holder?: string
|
|
12281
|
+
number?: string
|
|
12282
|
+
level?: string
|
|
12283
|
+
points?: number
|
|
12284
|
+
validUntil?: string
|
|
12285
|
+
fields?: Array<{ label: string; value: string }>
|
|
12286
|
+
back?: Array<{ label: string; value: string }>
|
|
12287
|
+
image?: string
|
|
12288
|
+
url?: string
|
|
12289
|
+
barcode?: string
|
|
12290
|
+
}
|
|
12291
|
+
```
|
|
12292
|
+
|
|
12293
|
+
**WalletPassLinks** (interface)
|
|
12294
|
+
```typescript
|
|
12295
|
+
interface WalletPassLinks {
|
|
12296
|
+
google?: string
|
|
12297
|
+
apple?: string
|
|
12298
|
+
}
|
|
12299
|
+
```
|
|
12300
|
+
|
|
12301
|
+
**WalletPassSummary** (interface)
|
|
12302
|
+
```typescript
|
|
12303
|
+
interface WalletPassSummary {
|
|
12304
|
+
id: string
|
|
12305
|
+
kind: WalletPassKind
|
|
12306
|
+
ref: WalletPassRef
|
|
12307
|
+
title?: string
|
|
12308
|
+
start?: string
|
|
12309
|
+
links: WalletPassLinks
|
|
12310
|
+
}
|
|
12311
|
+
```
|
|
12312
|
+
|
|
12313
|
+
**WalletPass** (interface)
|
|
12314
|
+
```typescript
|
|
12315
|
+
interface WalletPass {
|
|
12316
|
+
id: string
|
|
12317
|
+
collectionId: string
|
|
12318
|
+
kind: WalletPassKind
|
|
12319
|
+
ref: WalletPassRef
|
|
12320
|
+
contactId?: string | null
|
|
12321
|
+
status: 'active' | 'voided'
|
|
12322
|
+
issuedBy?: string | null
|
|
12323
|
+
model: WalletPassContent
|
|
12324
|
+
code: string
|
|
12325
|
+
version: number
|
|
12326
|
+
notice?: { header: string; body: string; at: string }
|
|
12327
|
+
voidReason?: string | null
|
|
12328
|
+
links?: WalletPassLinks
|
|
12329
|
+
createdAt?: string
|
|
12330
|
+
updatedAt?: string
|
|
12331
|
+
}
|
|
12332
|
+
```
|
|
12333
|
+
|
|
12334
|
+
**IssueWalletPassRequest** (interface)
|
|
12335
|
+
```typescript
|
|
12336
|
+
interface IssueWalletPassRequest {
|
|
12337
|
+
ref: WalletPassRef
|
|
12338
|
+
contactId?: string
|
|
12339
|
+
appId?: string
|
|
12340
|
+
pass: WalletPassContent
|
|
12341
|
+
}
|
|
12342
|
+
```
|
|
12343
|
+
|
|
12344
|
+
**WalletPassKind** = `'event' | 'booking' | 'membership' | 'loyalty'`
|
|
12345
|
+
|
|
12259
12346
|
### widgets
|
|
12260
12347
|
|
|
12261
12348
|
**NavigationRequest** (interface)
|
|
@@ -15556,3 +15643,35 @@ Listen for voice input
|
|
|
15556
15643
|
**speak**(text: string, options?: { voice?: string; rate?: number }) → `Promise<void>`
|
|
15557
15644
|
Speak text
|
|
15558
15645
|
|
|
15646
|
+
### wallet
|
|
15647
|
+
|
|
15648
|
+
**addLinks**(collectionId: string, ref: WalletPassRef) → `Promise<`
|
|
15649
|
+
"Add to Wallet" links for the signed-in person's pass about `ref` (made on first ask for a booking or a membership card). ```typescript const { pass } = await wallet.addLinks('coll_123', { type: 'booking', id: booking.id }) if (pass.links.apple) appleButton.href = pass.links.apple if (pass.links.google) googleButton.href = pass.links.google ```
|
|
15650
|
+
|
|
15651
|
+
**mine**(collectionId: string) → `Promise<`
|
|
15652
|
+
The signed-in person's active passes on this site, with their links.
|
|
15653
|
+
|
|
15654
|
+
**status**(collectionId: string) → `Promise<`
|
|
15655
|
+
Which wallets are switched on (admin).
|
|
15656
|
+
|
|
15657
|
+
**list**(collectionId: string, query: { refType?: string; refId?: string; contactId?: string; includeVoided?: boolean }) → `Promise<`
|
|
15658
|
+
Passes for one thing (`refType` + `refId`) or one person (`contactId`) (admin).
|
|
15659
|
+
|
|
15660
|
+
**get**(collectionId: string, passId: string) → `Promise<`
|
|
15661
|
+
One pass, with its links (admin).
|
|
15662
|
+
|
|
15663
|
+
**byCode**(collectionId: string, code: string) → `Promise<`
|
|
15664
|
+
The pass whose QR this is, for checking a ticket at the door (admin). `valid` is false for a voided pass. ```typescript const { pass, valid } = await wallet.byCode('coll_123', scannedValue) ```
|
|
15665
|
+
|
|
15666
|
+
**issue**(collectionId: string, input: IssueWalletPassRequest) → `Promise<`
|
|
15667
|
+
Issue a pass (admin). Issuing again for the same thing, person and kind changes the existing pass.
|
|
15668
|
+
|
|
15669
|
+
**update**(collectionId: string, passId: string, fields: Partial<Omit<WalletPassContent, "kind">>) → `Promise<`
|
|
15670
|
+
Change what a pass shows; both wallets follow (admin).
|
|
15671
|
+
|
|
15672
|
+
**voidPass**(collectionId: string, passId: string, reason?: string) → `Promise<`
|
|
15673
|
+
The pass no longer counts: shown as void on the phone (admin).
|
|
15674
|
+
|
|
15675
|
+
**message**(collectionId: string, passId: string, msg: { header?: string; body: string }) → `Promise<`
|
|
15676
|
+
A lock-screen message on the pass (admin).
|
|
15677
|
+
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Wallet passes
|
|
2
|
+
|
|
3
|
+
Put an **event ticket**, a **booking**, a **membership card** or a **loyalty card** in the person's Apple Wallet or
|
|
4
|
+
Google Wallet. SmartLinks is the issuer and signs the passes. Each pass is branded from your site's name, logo and
|
|
5
|
+
colour, and your app decides what it says.
|
|
6
|
+
|
|
7
|
+
- **Who gets one:** only someone the business knows. A pass is issued to the signed-in owner of what it's for, or
|
|
8
|
+
by your app's own server function.
|
|
9
|
+
- **What the phone does:** the pass shows its QR code offline, appears near the time (and place, if you give
|
|
10
|
+
`venue.lat` / `lng`), and updates when you change it.
|
|
11
|
+
- **Bookings look after themselves:** when a booking is moved its pass shows the new time, and when it's cancelled
|
|
12
|
+
the pass is voided.
|
|
13
|
+
|
|
14
|
+
## In a page: "Add to Wallet"
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { wallet } from '@proveanything/smartlinks'
|
|
18
|
+
|
|
19
|
+
// The signed-in person's booking, membership card, or a pass your app issued them
|
|
20
|
+
const { pass } = await wallet.addLinks(collectionId, { type: 'booking', id: booking.id })
|
|
21
|
+
// pass.links.apple → opens the .pkpass on an iPhone
|
|
22
|
+
// pass.links.google → opens Google's "Save to Google Wallet" page
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- `{ type: 'booking', id }` and `{ type: 'contact', id: 'me' }` are made on first ask:
|
|
26
|
+
- a booking pass, from the booking's date and time
|
|
27
|
+
- a membership card, from the person's `level` and `memberUntil` fields
|
|
28
|
+
- For anything else (an event ticket with your own title, a loyalty card with points), issue the pass in your server
|
|
29
|
+
function first. `addLinks` then returns that pass for its owner.
|
|
30
|
+
- Show the official "Add to Apple Wallet" and "Add to Google Wallet" badges, and only the one that suits the
|
|
31
|
+
device. A wallet that isn't set up yet is left out of `links`.
|
|
32
|
+
- `wallet.mine(collectionId)` lists the person's passes.
|
|
33
|
+
|
|
34
|
+
## In a server function: issue, change, void, message
|
|
35
|
+
|
|
36
|
+
Declare `sl:wallet:write` in the function's capabilities.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// An event ticket
|
|
40
|
+
const pass = await ctx.sl.wallet.issue({
|
|
41
|
+
ref: { type: 'booking', id: booking.id }, // what it's for; issuing again changes the same pass
|
|
42
|
+
pass: {
|
|
43
|
+
kind: 'event',
|
|
44
|
+
title: 'Jazz on the Terrace',
|
|
45
|
+
start: '2026-12-24T19:00:00Z', end: '2026-12-24T22:00:00Z', timezone: 'Europe/London',
|
|
46
|
+
venue: { name: 'The Terrace', address: '1 High St, Bath', lat: 51.38, lng: -2.36 },
|
|
47
|
+
holder: 'Sam Lee', number: 'T-0042',
|
|
48
|
+
fields: [{ label: 'Seat', value: 'Table 6' }],
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
return { links: pass.links } // hand these to the page
|
|
52
|
+
|
|
53
|
+
// A loyalty card, kept up to date
|
|
54
|
+
await ctx.sl.wallet.issue({ ref: { type: 'loyalty', id: accountId }, pass: { kind: 'loyalty', title: 'Bloom Rewards', points: 120, holder: 'Sam' } })
|
|
55
|
+
await ctx.sl.wallet.update(passId, { points: 145 })
|
|
56
|
+
|
|
57
|
+
await ctx.sl.wallet.void(passId, 'refunded')
|
|
58
|
+
await ctx.sl.wallet.message(passId, { header: 'Doors open', body: 'Doors open at 7pm. See you soon!' })
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- **Contact:** `contactId` defaults to the caller's contact.
|
|
62
|
+
- **Reading:** `ctx.sl.wallet.get(passId)`, `forRef(ref)`, `byCode(code)` and `mine()` need only `sl:wallet:read`.
|
|
63
|
+
- **Messages:** you can also send a message to wallet with `ctx.sl.messages` and `channel: 'wallet'`. It goes to the
|
|
64
|
+
person's passes about the message's `about`, otherwise to your app's own passes for them. It's worded from the
|
|
65
|
+
template's push version.
|
|
66
|
+
|
|
67
|
+
## Checking a pass at the door
|
|
68
|
+
|
|
69
|
+
The QR holds the pass's own code, never an id. Scan it, then:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const { pass, valid } = await wallet.byCode(collectionId, scanned) // admin
|
|
73
|
+
// or in a function: await ctx.sl.wallet.byCode(scanned)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## What a pass can show
|
|
77
|
+
|
|
78
|
+
| Field | Use |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `kind` | `event`, `booking`, `membership` or `loyalty` |
|
|
81
|
+
| `title` / `subtitle` | the main line and a second line |
|
|
82
|
+
| `start` / `end` / `timezone` | when; the pass surfaces near `start` |
|
|
83
|
+
| `venue` | `name`, `address`, and `lat` / `lng` for the lock screen nearby |
|
|
84
|
+
| `holder`, `number`, `level`, `points`, `validUntil` | the person, a reference or member number, a level, a balance, an end date |
|
|
85
|
+
| `fields` (up to 4), `back` | extra lines on the front and the back |
|
|
86
|
+
| `image`, `url` | https only: a picture, a link back to your site |
|
|
87
|
+
| `barcode` | your own QR value, instead of the pass's code |
|
package/dist/openapi.yaml
CHANGED
|
@@ -37368,6 +37368,160 @@ components:
|
|
|
37368
37368
|
properties:
|
|
37369
37369
|
name:
|
|
37370
37370
|
type: string
|
|
37371
|
+
WalletPassRef:
|
|
37372
|
+
type: object
|
|
37373
|
+
properties:
|
|
37374
|
+
type:
|
|
37375
|
+
type: string
|
|
37376
|
+
enum:
|
|
37377
|
+
- booking
|
|
37378
|
+
- contact
|
|
37379
|
+
id:
|
|
37380
|
+
type: string
|
|
37381
|
+
required:
|
|
37382
|
+
- type
|
|
37383
|
+
- id
|
|
37384
|
+
WalletPassContent:
|
|
37385
|
+
type: object
|
|
37386
|
+
properties:
|
|
37387
|
+
kind:
|
|
37388
|
+
$ref: "#/components/schemas/WalletPassKind"
|
|
37389
|
+
title:
|
|
37390
|
+
type: string
|
|
37391
|
+
subtitle:
|
|
37392
|
+
type: string
|
|
37393
|
+
start:
|
|
37394
|
+
type: string
|
|
37395
|
+
end:
|
|
37396
|
+
type: string
|
|
37397
|
+
timezone:
|
|
37398
|
+
type: string
|
|
37399
|
+
venue:
|
|
37400
|
+
type: object
|
|
37401
|
+
additionalProperties: true
|
|
37402
|
+
holder:
|
|
37403
|
+
type: string
|
|
37404
|
+
number:
|
|
37405
|
+
type: string
|
|
37406
|
+
level:
|
|
37407
|
+
type: string
|
|
37408
|
+
points:
|
|
37409
|
+
type: number
|
|
37410
|
+
validUntil:
|
|
37411
|
+
type: string
|
|
37412
|
+
fields:
|
|
37413
|
+
type: array
|
|
37414
|
+
items:
|
|
37415
|
+
type: object
|
|
37416
|
+
additionalProperties: true
|
|
37417
|
+
back:
|
|
37418
|
+
type: array
|
|
37419
|
+
items:
|
|
37420
|
+
type: object
|
|
37421
|
+
additionalProperties: true
|
|
37422
|
+
image:
|
|
37423
|
+
type: string
|
|
37424
|
+
url:
|
|
37425
|
+
type: string
|
|
37426
|
+
barcode:
|
|
37427
|
+
type: string
|
|
37428
|
+
required:
|
|
37429
|
+
- kind
|
|
37430
|
+
- title
|
|
37431
|
+
WalletPassLinks:
|
|
37432
|
+
type: object
|
|
37433
|
+
properties:
|
|
37434
|
+
google:
|
|
37435
|
+
type: string
|
|
37436
|
+
apple:
|
|
37437
|
+
type: string
|
|
37438
|
+
WalletPassSummary:
|
|
37439
|
+
type: object
|
|
37440
|
+
properties:
|
|
37441
|
+
id:
|
|
37442
|
+
type: string
|
|
37443
|
+
kind:
|
|
37444
|
+
$ref: "#/components/schemas/WalletPassKind"
|
|
37445
|
+
ref:
|
|
37446
|
+
$ref: "#/components/schemas/WalletPassRef"
|
|
37447
|
+
title:
|
|
37448
|
+
type: string
|
|
37449
|
+
start:
|
|
37450
|
+
type: string
|
|
37451
|
+
links:
|
|
37452
|
+
$ref: "#/components/schemas/WalletPassLinks"
|
|
37453
|
+
required:
|
|
37454
|
+
- id
|
|
37455
|
+
- kind
|
|
37456
|
+
- ref
|
|
37457
|
+
- links
|
|
37458
|
+
WalletPass:
|
|
37459
|
+
type: object
|
|
37460
|
+
properties:
|
|
37461
|
+
id:
|
|
37462
|
+
type: string
|
|
37463
|
+
collectionId:
|
|
37464
|
+
type: string
|
|
37465
|
+
kind:
|
|
37466
|
+
$ref: "#/components/schemas/WalletPassKind"
|
|
37467
|
+
ref:
|
|
37468
|
+
$ref: "#/components/schemas/WalletPassRef"
|
|
37469
|
+
contactId:
|
|
37470
|
+
type: string
|
|
37471
|
+
status:
|
|
37472
|
+
type: string
|
|
37473
|
+
enum:
|
|
37474
|
+
- active
|
|
37475
|
+
- voided
|
|
37476
|
+
issuedBy:
|
|
37477
|
+
type: string
|
|
37478
|
+
model:
|
|
37479
|
+
$ref: "#/components/schemas/WalletPassContent"
|
|
37480
|
+
code:
|
|
37481
|
+
type: string
|
|
37482
|
+
version:
|
|
37483
|
+
type: number
|
|
37484
|
+
notice:
|
|
37485
|
+
type: object
|
|
37486
|
+
additionalProperties: true
|
|
37487
|
+
voidReason:
|
|
37488
|
+
type: string
|
|
37489
|
+
links:
|
|
37490
|
+
$ref: "#/components/schemas/WalletPassLinks"
|
|
37491
|
+
createdAt:
|
|
37492
|
+
type: string
|
|
37493
|
+
updatedAt:
|
|
37494
|
+
type: string
|
|
37495
|
+
required:
|
|
37496
|
+
- id
|
|
37497
|
+
- collectionId
|
|
37498
|
+
- kind
|
|
37499
|
+
- ref
|
|
37500
|
+
- status
|
|
37501
|
+
- model
|
|
37502
|
+
- code
|
|
37503
|
+
- version
|
|
37504
|
+
IssueWalletPassRequest:
|
|
37505
|
+
type: object
|
|
37506
|
+
properties:
|
|
37507
|
+
ref:
|
|
37508
|
+
$ref: "#/components/schemas/WalletPassRef"
|
|
37509
|
+
contactId:
|
|
37510
|
+
type: string
|
|
37511
|
+
appId:
|
|
37512
|
+
type: string
|
|
37513
|
+
pass:
|
|
37514
|
+
$ref: "#/components/schemas/WalletPassContent"
|
|
37515
|
+
required:
|
|
37516
|
+
- ref
|
|
37517
|
+
- pass
|
|
37518
|
+
WalletPassKind:
|
|
37519
|
+
type: string
|
|
37520
|
+
enum:
|
|
37521
|
+
- event
|
|
37522
|
+
- booking
|
|
37523
|
+
- membership
|
|
37524
|
+
- loyalty
|
|
37371
37525
|
NavigationRequest:
|
|
37372
37526
|
type: object
|
|
37373
37527
|
properties:
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/** Wallet passes: what a pass is and shows (docs/wallet-passes.md). */
|
|
2
|
+
export type WalletPassKind = 'event' | 'booking' | 'membership' | 'loyalty';
|
|
3
|
+
/** What the pass is for: a booking, the person ('contact'), or your own record type. */
|
|
4
|
+
export interface WalletPassRef {
|
|
5
|
+
type: 'booking' | 'contact' | string;
|
|
6
|
+
id: string;
|
|
7
|
+
}
|
|
8
|
+
/** What a pass shows. Branding (name, logo, colours) always comes from the site. */
|
|
9
|
+
export interface WalletPassContent {
|
|
10
|
+
kind: WalletPassKind;
|
|
11
|
+
/** The main line: the event, "Table for 4", "Gold member". */
|
|
12
|
+
title: string;
|
|
13
|
+
subtitle?: string;
|
|
14
|
+
/** ISO times (events and bookings); the pass surfaces near `start`. */
|
|
15
|
+
start?: string;
|
|
16
|
+
end?: string;
|
|
17
|
+
/** IANA timezone, e.g. 'Europe/London'. */
|
|
18
|
+
timezone?: string;
|
|
19
|
+
/** `lat` / `lng` make the pass appear when the person is nearby. */
|
|
20
|
+
venue?: {
|
|
21
|
+
name?: string;
|
|
22
|
+
address?: string;
|
|
23
|
+
lat?: number;
|
|
24
|
+
lng?: number;
|
|
25
|
+
};
|
|
26
|
+
holder?: string;
|
|
27
|
+
/** A booking reference or member number. */
|
|
28
|
+
number?: string;
|
|
29
|
+
level?: string;
|
|
30
|
+
/** Loyalty balance. */
|
|
31
|
+
points?: number;
|
|
32
|
+
validUntil?: string;
|
|
33
|
+
/** Up to 4 extra lines on the front. */
|
|
34
|
+
fields?: Array<{
|
|
35
|
+
label: string;
|
|
36
|
+
value: string;
|
|
37
|
+
}>;
|
|
38
|
+
/** Lines on the back. */
|
|
39
|
+
back?: Array<{
|
|
40
|
+
label: string;
|
|
41
|
+
value: string;
|
|
42
|
+
}>;
|
|
43
|
+
/** https only. */
|
|
44
|
+
image?: string;
|
|
45
|
+
url?: string;
|
|
46
|
+
/** The QR value; the pass's own code unless you give one. */
|
|
47
|
+
barcode?: string;
|
|
48
|
+
}
|
|
49
|
+
/** "Add to Wallet" links that work for this pass now (a wallet that isn't set up is left out). */
|
|
50
|
+
export interface WalletPassLinks {
|
|
51
|
+
google?: string;
|
|
52
|
+
apple?: string;
|
|
53
|
+
}
|
|
54
|
+
/** A pass as the person sees it (public calls). */
|
|
55
|
+
export interface WalletPassSummary {
|
|
56
|
+
id: string;
|
|
57
|
+
kind: WalletPassKind;
|
|
58
|
+
ref: WalletPassRef;
|
|
59
|
+
title?: string;
|
|
60
|
+
start?: string;
|
|
61
|
+
links: WalletPassLinks;
|
|
62
|
+
}
|
|
63
|
+
/** A pass as an admin or app sees it. */
|
|
64
|
+
export interface WalletPass {
|
|
65
|
+
id: string;
|
|
66
|
+
collectionId: string;
|
|
67
|
+
kind: WalletPassKind;
|
|
68
|
+
ref: WalletPassRef;
|
|
69
|
+
contactId?: string | null;
|
|
70
|
+
status: 'active' | 'voided';
|
|
71
|
+
/** The app that issued it. */
|
|
72
|
+
issuedBy?: string | null;
|
|
73
|
+
model: WalletPassContent;
|
|
74
|
+
/** The value in its QR code (check it with `wallet.byCode`). */
|
|
75
|
+
code: string;
|
|
76
|
+
version: number;
|
|
77
|
+
notice?: {
|
|
78
|
+
header: string;
|
|
79
|
+
body: string;
|
|
80
|
+
at: string;
|
|
81
|
+
};
|
|
82
|
+
voidReason?: string | null;
|
|
83
|
+
links?: WalletPassLinks;
|
|
84
|
+
createdAt?: string;
|
|
85
|
+
updatedAt?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface IssueWalletPassRequest {
|
|
88
|
+
ref: WalletPassRef;
|
|
89
|
+
contactId?: string;
|
|
90
|
+
appId?: string;
|
|
91
|
+
pass: WalletPassContent;
|
|
92
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.28 | Generated: 2026-11-20T09:02:04.143Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -170,6 +170,7 @@ The Smartlinks SDK is organized into the following namespaces:
|
|
|
170
170
|
- **template** - Functions for template operations
|
|
171
171
|
- **translations** - Functions for translations operations
|
|
172
172
|
- **userGroups** - Functions for userGroups operations
|
|
173
|
+
- **wallet** - Functions for wallet operations
|
|
173
174
|
|
|
174
175
|
## HTTP Utilities
|
|
175
176
|
|
|
@@ -12256,6 +12257,92 @@ interface VariantUpdateRequest {
|
|
|
12256
12257
|
}
|
|
12257
12258
|
```
|
|
12258
12259
|
|
|
12260
|
+
### wallet
|
|
12261
|
+
|
|
12262
|
+
**WalletPassRef** (interface)
|
|
12263
|
+
```typescript
|
|
12264
|
+
interface WalletPassRef {
|
|
12265
|
+
type: 'booking' | 'contact' | string
|
|
12266
|
+
id: string
|
|
12267
|
+
}
|
|
12268
|
+
```
|
|
12269
|
+
|
|
12270
|
+
**WalletPassContent** (interface)
|
|
12271
|
+
```typescript
|
|
12272
|
+
interface WalletPassContent {
|
|
12273
|
+
kind: WalletPassKind
|
|
12274
|
+
title: string
|
|
12275
|
+
subtitle?: string
|
|
12276
|
+
start?: string
|
|
12277
|
+
end?: string
|
|
12278
|
+
timezone?: string
|
|
12279
|
+
venue?: { name?: string; address?: string; lat?: number; lng?: number }
|
|
12280
|
+
holder?: string
|
|
12281
|
+
number?: string
|
|
12282
|
+
level?: string
|
|
12283
|
+
points?: number
|
|
12284
|
+
validUntil?: string
|
|
12285
|
+
fields?: Array<{ label: string; value: string }>
|
|
12286
|
+
back?: Array<{ label: string; value: string }>
|
|
12287
|
+
image?: string
|
|
12288
|
+
url?: string
|
|
12289
|
+
barcode?: string
|
|
12290
|
+
}
|
|
12291
|
+
```
|
|
12292
|
+
|
|
12293
|
+
**WalletPassLinks** (interface)
|
|
12294
|
+
```typescript
|
|
12295
|
+
interface WalletPassLinks {
|
|
12296
|
+
google?: string
|
|
12297
|
+
apple?: string
|
|
12298
|
+
}
|
|
12299
|
+
```
|
|
12300
|
+
|
|
12301
|
+
**WalletPassSummary** (interface)
|
|
12302
|
+
```typescript
|
|
12303
|
+
interface WalletPassSummary {
|
|
12304
|
+
id: string
|
|
12305
|
+
kind: WalletPassKind
|
|
12306
|
+
ref: WalletPassRef
|
|
12307
|
+
title?: string
|
|
12308
|
+
start?: string
|
|
12309
|
+
links: WalletPassLinks
|
|
12310
|
+
}
|
|
12311
|
+
```
|
|
12312
|
+
|
|
12313
|
+
**WalletPass** (interface)
|
|
12314
|
+
```typescript
|
|
12315
|
+
interface WalletPass {
|
|
12316
|
+
id: string
|
|
12317
|
+
collectionId: string
|
|
12318
|
+
kind: WalletPassKind
|
|
12319
|
+
ref: WalletPassRef
|
|
12320
|
+
contactId?: string | null
|
|
12321
|
+
status: 'active' | 'voided'
|
|
12322
|
+
issuedBy?: string | null
|
|
12323
|
+
model: WalletPassContent
|
|
12324
|
+
code: string
|
|
12325
|
+
version: number
|
|
12326
|
+
notice?: { header: string; body: string; at: string }
|
|
12327
|
+
voidReason?: string | null
|
|
12328
|
+
links?: WalletPassLinks
|
|
12329
|
+
createdAt?: string
|
|
12330
|
+
updatedAt?: string
|
|
12331
|
+
}
|
|
12332
|
+
```
|
|
12333
|
+
|
|
12334
|
+
**IssueWalletPassRequest** (interface)
|
|
12335
|
+
```typescript
|
|
12336
|
+
interface IssueWalletPassRequest {
|
|
12337
|
+
ref: WalletPassRef
|
|
12338
|
+
contactId?: string
|
|
12339
|
+
appId?: string
|
|
12340
|
+
pass: WalletPassContent
|
|
12341
|
+
}
|
|
12342
|
+
```
|
|
12343
|
+
|
|
12344
|
+
**WalletPassKind** = `'event' | 'booking' | 'membership' | 'loyalty'`
|
|
12345
|
+
|
|
12259
12346
|
### widgets
|
|
12260
12347
|
|
|
12261
12348
|
**NavigationRequest** (interface)
|
|
@@ -15556,3 +15643,35 @@ Listen for voice input
|
|
|
15556
15643
|
**speak**(text: string, options?: { voice?: string; rate?: number }) → `Promise<void>`
|
|
15557
15644
|
Speak text
|
|
15558
15645
|
|
|
15646
|
+
### wallet
|
|
15647
|
+
|
|
15648
|
+
**addLinks**(collectionId: string, ref: WalletPassRef) → `Promise<`
|
|
15649
|
+
"Add to Wallet" links for the signed-in person's pass about `ref` (made on first ask for a booking or a membership card). ```typescript const { pass } = await wallet.addLinks('coll_123', { type: 'booking', id: booking.id }) if (pass.links.apple) appleButton.href = pass.links.apple if (pass.links.google) googleButton.href = pass.links.google ```
|
|
15650
|
+
|
|
15651
|
+
**mine**(collectionId: string) → `Promise<`
|
|
15652
|
+
The signed-in person's active passes on this site, with their links.
|
|
15653
|
+
|
|
15654
|
+
**status**(collectionId: string) → `Promise<`
|
|
15655
|
+
Which wallets are switched on (admin).
|
|
15656
|
+
|
|
15657
|
+
**list**(collectionId: string, query: { refType?: string; refId?: string; contactId?: string; includeVoided?: boolean }) → `Promise<`
|
|
15658
|
+
Passes for one thing (`refType` + `refId`) or one person (`contactId`) (admin).
|
|
15659
|
+
|
|
15660
|
+
**get**(collectionId: string, passId: string) → `Promise<`
|
|
15661
|
+
One pass, with its links (admin).
|
|
15662
|
+
|
|
15663
|
+
**byCode**(collectionId: string, code: string) → `Promise<`
|
|
15664
|
+
The pass whose QR this is, for checking a ticket at the door (admin). `valid` is false for a voided pass. ```typescript const { pass, valid } = await wallet.byCode('coll_123', scannedValue) ```
|
|
15665
|
+
|
|
15666
|
+
**issue**(collectionId: string, input: IssueWalletPassRequest) → `Promise<`
|
|
15667
|
+
Issue a pass (admin). Issuing again for the same thing, person and kind changes the existing pass.
|
|
15668
|
+
|
|
15669
|
+
**update**(collectionId: string, passId: string, fields: Partial<Omit<WalletPassContent, "kind">>) → `Promise<`
|
|
15670
|
+
Change what a pass shows; both wallets follow (admin).
|
|
15671
|
+
|
|
15672
|
+
**voidPass**(collectionId: string, passId: string, reason?: string) → `Promise<`
|
|
15673
|
+
The pass no longer counts: shown as void on the phone (admin).
|
|
15674
|
+
|
|
15675
|
+
**message**(collectionId: string, passId: string, msg: { header?: string; body: string }) → `Promise<`
|
|
15676
|
+
A lock-screen message on the pass (admin).
|
|
15677
|
+
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Wallet passes
|
|
2
|
+
|
|
3
|
+
Put an **event ticket**, a **booking**, a **membership card** or a **loyalty card** in the person's Apple Wallet or
|
|
4
|
+
Google Wallet. SmartLinks is the issuer and signs the passes. Each pass is branded from your site's name, logo and
|
|
5
|
+
colour, and your app decides what it says.
|
|
6
|
+
|
|
7
|
+
- **Who gets one:** only someone the business knows. A pass is issued to the signed-in owner of what it's for, or
|
|
8
|
+
by your app's own server function.
|
|
9
|
+
- **What the phone does:** the pass shows its QR code offline, appears near the time (and place, if you give
|
|
10
|
+
`venue.lat` / `lng`), and updates when you change it.
|
|
11
|
+
- **Bookings look after themselves:** when a booking is moved its pass shows the new time, and when it's cancelled
|
|
12
|
+
the pass is voided.
|
|
13
|
+
|
|
14
|
+
## In a page: "Add to Wallet"
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { wallet } from '@proveanything/smartlinks'
|
|
18
|
+
|
|
19
|
+
// The signed-in person's booking, membership card, or a pass your app issued them
|
|
20
|
+
const { pass } = await wallet.addLinks(collectionId, { type: 'booking', id: booking.id })
|
|
21
|
+
// pass.links.apple → opens the .pkpass on an iPhone
|
|
22
|
+
// pass.links.google → opens Google's "Save to Google Wallet" page
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- `{ type: 'booking', id }` and `{ type: 'contact', id: 'me' }` are made on first ask:
|
|
26
|
+
- a booking pass, from the booking's date and time
|
|
27
|
+
- a membership card, from the person's `level` and `memberUntil` fields
|
|
28
|
+
- For anything else (an event ticket with your own title, a loyalty card with points), issue the pass in your server
|
|
29
|
+
function first. `addLinks` then returns that pass for its owner.
|
|
30
|
+
- Show the official "Add to Apple Wallet" and "Add to Google Wallet" badges, and only the one that suits the
|
|
31
|
+
device. A wallet that isn't set up yet is left out of `links`.
|
|
32
|
+
- `wallet.mine(collectionId)` lists the person's passes.
|
|
33
|
+
|
|
34
|
+
## In a server function: issue, change, void, message
|
|
35
|
+
|
|
36
|
+
Declare `sl:wallet:write` in the function's capabilities.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// An event ticket
|
|
40
|
+
const pass = await ctx.sl.wallet.issue({
|
|
41
|
+
ref: { type: 'booking', id: booking.id }, // what it's for; issuing again changes the same pass
|
|
42
|
+
pass: {
|
|
43
|
+
kind: 'event',
|
|
44
|
+
title: 'Jazz on the Terrace',
|
|
45
|
+
start: '2026-12-24T19:00:00Z', end: '2026-12-24T22:00:00Z', timezone: 'Europe/London',
|
|
46
|
+
venue: { name: 'The Terrace', address: '1 High St, Bath', lat: 51.38, lng: -2.36 },
|
|
47
|
+
holder: 'Sam Lee', number: 'T-0042',
|
|
48
|
+
fields: [{ label: 'Seat', value: 'Table 6' }],
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
return { links: pass.links } // hand these to the page
|
|
52
|
+
|
|
53
|
+
// A loyalty card, kept up to date
|
|
54
|
+
await ctx.sl.wallet.issue({ ref: { type: 'loyalty', id: accountId }, pass: { kind: 'loyalty', title: 'Bloom Rewards', points: 120, holder: 'Sam' } })
|
|
55
|
+
await ctx.sl.wallet.update(passId, { points: 145 })
|
|
56
|
+
|
|
57
|
+
await ctx.sl.wallet.void(passId, 'refunded')
|
|
58
|
+
await ctx.sl.wallet.message(passId, { header: 'Doors open', body: 'Doors open at 7pm. See you soon!' })
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- **Contact:** `contactId` defaults to the caller's contact.
|
|
62
|
+
- **Reading:** `ctx.sl.wallet.get(passId)`, `forRef(ref)`, `byCode(code)` and `mine()` need only `sl:wallet:read`.
|
|
63
|
+
- **Messages:** you can also send a message to wallet with `ctx.sl.messages` and `channel: 'wallet'`. It goes to the
|
|
64
|
+
person's passes about the message's `about`, otherwise to your app's own passes for them. It's worded from the
|
|
65
|
+
template's push version.
|
|
66
|
+
|
|
67
|
+
## Checking a pass at the door
|
|
68
|
+
|
|
69
|
+
The QR holds the pass's own code, never an id. Scan it, then:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const { pass, valid } = await wallet.byCode(collectionId, scanned) // admin
|
|
73
|
+
// or in a function: await ctx.sl.wallet.byCode(scanned)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## What a pass can show
|
|
77
|
+
|
|
78
|
+
| Field | Use |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `kind` | `event`, `booking`, `membership` or `loyalty` |
|
|
81
|
+
| `title` / `subtitle` | the main line and a second line |
|
|
82
|
+
| `start` / `end` / `timezone` | when; the pass surfaces near `start` |
|
|
83
|
+
| `venue` | `name`, `address`, and `lat` / `lng` for the lock screen nearby |
|
|
84
|
+
| `holder`, `number`, `level`, `points`, `validUntil` | the person, a reference or member number, a level, a balance, an end date |
|
|
85
|
+
| `fields` (up to 4), `back` | extra lines on the front and the back |
|
|
86
|
+
| `image`, `url` | https only: a picture, a link back to your site |
|
|
87
|
+
| `barcode` | your own QR value, instead of the pass's code |
|
package/openapi.yaml
CHANGED
|
@@ -37368,6 +37368,160 @@ components:
|
|
|
37368
37368
|
properties:
|
|
37369
37369
|
name:
|
|
37370
37370
|
type: string
|
|
37371
|
+
WalletPassRef:
|
|
37372
|
+
type: object
|
|
37373
|
+
properties:
|
|
37374
|
+
type:
|
|
37375
|
+
type: string
|
|
37376
|
+
enum:
|
|
37377
|
+
- booking
|
|
37378
|
+
- contact
|
|
37379
|
+
id:
|
|
37380
|
+
type: string
|
|
37381
|
+
required:
|
|
37382
|
+
- type
|
|
37383
|
+
- id
|
|
37384
|
+
WalletPassContent:
|
|
37385
|
+
type: object
|
|
37386
|
+
properties:
|
|
37387
|
+
kind:
|
|
37388
|
+
$ref: "#/components/schemas/WalletPassKind"
|
|
37389
|
+
title:
|
|
37390
|
+
type: string
|
|
37391
|
+
subtitle:
|
|
37392
|
+
type: string
|
|
37393
|
+
start:
|
|
37394
|
+
type: string
|
|
37395
|
+
end:
|
|
37396
|
+
type: string
|
|
37397
|
+
timezone:
|
|
37398
|
+
type: string
|
|
37399
|
+
venue:
|
|
37400
|
+
type: object
|
|
37401
|
+
additionalProperties: true
|
|
37402
|
+
holder:
|
|
37403
|
+
type: string
|
|
37404
|
+
number:
|
|
37405
|
+
type: string
|
|
37406
|
+
level:
|
|
37407
|
+
type: string
|
|
37408
|
+
points:
|
|
37409
|
+
type: number
|
|
37410
|
+
validUntil:
|
|
37411
|
+
type: string
|
|
37412
|
+
fields:
|
|
37413
|
+
type: array
|
|
37414
|
+
items:
|
|
37415
|
+
type: object
|
|
37416
|
+
additionalProperties: true
|
|
37417
|
+
back:
|
|
37418
|
+
type: array
|
|
37419
|
+
items:
|
|
37420
|
+
type: object
|
|
37421
|
+
additionalProperties: true
|
|
37422
|
+
image:
|
|
37423
|
+
type: string
|
|
37424
|
+
url:
|
|
37425
|
+
type: string
|
|
37426
|
+
barcode:
|
|
37427
|
+
type: string
|
|
37428
|
+
required:
|
|
37429
|
+
- kind
|
|
37430
|
+
- title
|
|
37431
|
+
WalletPassLinks:
|
|
37432
|
+
type: object
|
|
37433
|
+
properties:
|
|
37434
|
+
google:
|
|
37435
|
+
type: string
|
|
37436
|
+
apple:
|
|
37437
|
+
type: string
|
|
37438
|
+
WalletPassSummary:
|
|
37439
|
+
type: object
|
|
37440
|
+
properties:
|
|
37441
|
+
id:
|
|
37442
|
+
type: string
|
|
37443
|
+
kind:
|
|
37444
|
+
$ref: "#/components/schemas/WalletPassKind"
|
|
37445
|
+
ref:
|
|
37446
|
+
$ref: "#/components/schemas/WalletPassRef"
|
|
37447
|
+
title:
|
|
37448
|
+
type: string
|
|
37449
|
+
start:
|
|
37450
|
+
type: string
|
|
37451
|
+
links:
|
|
37452
|
+
$ref: "#/components/schemas/WalletPassLinks"
|
|
37453
|
+
required:
|
|
37454
|
+
- id
|
|
37455
|
+
- kind
|
|
37456
|
+
- ref
|
|
37457
|
+
- links
|
|
37458
|
+
WalletPass:
|
|
37459
|
+
type: object
|
|
37460
|
+
properties:
|
|
37461
|
+
id:
|
|
37462
|
+
type: string
|
|
37463
|
+
collectionId:
|
|
37464
|
+
type: string
|
|
37465
|
+
kind:
|
|
37466
|
+
$ref: "#/components/schemas/WalletPassKind"
|
|
37467
|
+
ref:
|
|
37468
|
+
$ref: "#/components/schemas/WalletPassRef"
|
|
37469
|
+
contactId:
|
|
37470
|
+
type: string
|
|
37471
|
+
status:
|
|
37472
|
+
type: string
|
|
37473
|
+
enum:
|
|
37474
|
+
- active
|
|
37475
|
+
- voided
|
|
37476
|
+
issuedBy:
|
|
37477
|
+
type: string
|
|
37478
|
+
model:
|
|
37479
|
+
$ref: "#/components/schemas/WalletPassContent"
|
|
37480
|
+
code:
|
|
37481
|
+
type: string
|
|
37482
|
+
version:
|
|
37483
|
+
type: number
|
|
37484
|
+
notice:
|
|
37485
|
+
type: object
|
|
37486
|
+
additionalProperties: true
|
|
37487
|
+
voidReason:
|
|
37488
|
+
type: string
|
|
37489
|
+
links:
|
|
37490
|
+
$ref: "#/components/schemas/WalletPassLinks"
|
|
37491
|
+
createdAt:
|
|
37492
|
+
type: string
|
|
37493
|
+
updatedAt:
|
|
37494
|
+
type: string
|
|
37495
|
+
required:
|
|
37496
|
+
- id
|
|
37497
|
+
- collectionId
|
|
37498
|
+
- kind
|
|
37499
|
+
- ref
|
|
37500
|
+
- status
|
|
37501
|
+
- model
|
|
37502
|
+
- code
|
|
37503
|
+
- version
|
|
37504
|
+
IssueWalletPassRequest:
|
|
37505
|
+
type: object
|
|
37506
|
+
properties:
|
|
37507
|
+
ref:
|
|
37508
|
+
$ref: "#/components/schemas/WalletPassRef"
|
|
37509
|
+
contactId:
|
|
37510
|
+
type: string
|
|
37511
|
+
appId:
|
|
37512
|
+
type: string
|
|
37513
|
+
pass:
|
|
37514
|
+
$ref: "#/components/schemas/WalletPassContent"
|
|
37515
|
+
required:
|
|
37516
|
+
- ref
|
|
37517
|
+
- pass
|
|
37518
|
+
WalletPassKind:
|
|
37519
|
+
type: string
|
|
37520
|
+
enum:
|
|
37521
|
+
- event
|
|
37522
|
+
- booking
|
|
37523
|
+
- membership
|
|
37524
|
+
- loyalty
|
|
37371
37525
|
NavigationRequest:
|
|
37372
37526
|
type: object
|
|
37373
37527
|
properties:
|
package/package.json
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@proveanything/smartlinks",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.js",
|
|
12
|
-
"default": "./dist/index.js"
|
|
13
|
-
},
|
|
14
|
-
"./testing": {
|
|
15
|
-
"types": "./dist/testing/index.d.ts",
|
|
16
|
-
"import": "./dist/testing/index.js",
|
|
17
|
-
"default": "./dist/testing/index.js"
|
|
18
|
-
},
|
|
19
|
-
"./*": {
|
|
20
|
-
"types": "./dist/*.d.ts",
|
|
21
|
-
"import": "./dist/*.js",
|
|
22
|
-
"default": "./dist/*.js"
|
|
23
|
-
},
|
|
24
|
-
"./baseline.css": "./dist/baseline.css",
|
|
25
|
-
"./baseline.classes.json": "./dist/baseline.classes.json",
|
|
26
|
-
"./theme.css": "./dist/theme.css",
|
|
27
|
-
"./theme-boot.js": "./dist/theme-boot.js",
|
|
28
|
-
"./package.json": "./package.json"
|
|
29
|
-
},
|
|
30
|
-
"bin": {
|
|
31
|
-
"smartlinks-register-release": "scripts/register-release.mjs",
|
|
32
|
-
"smartlinks-publish": "scripts/publish.mjs",
|
|
33
|
-
"smartlinks-doctor": "scripts/doctor.mjs",
|
|
34
|
-
"smartlinks-headless": "scripts/headless-check.mjs"
|
|
35
|
-
},
|
|
36
|
-
"files": [
|
|
37
|
-
"dist/",
|
|
38
|
-
"docs/",
|
|
39
|
-
"scripts/register-release.mjs",
|
|
40
|
-
"scripts/publish.mjs",
|
|
41
|
-
"scripts/doctor.mjs",
|
|
42
|
-
"scripts/headless-check.mjs",
|
|
43
|
-
"scripts/lib/",
|
|
44
|
-
"openapi.yaml",
|
|
45
|
-
"README.md"
|
|
46
|
-
],
|
|
47
|
-
"scripts": {
|
|
48
|
-
"test": "node test/run.cjs",
|
|
49
|
-
"build": "tsc && node scripts/fix-esm-extensions.mjs && node generate-api-summary.cjs && node generate-openapi.cjs && node scripts/copy-docs-to-dist.cjs && node scripts/build-baseline.mjs",
|
|
50
|
-
"docs": "typedoc",
|
|
51
|
-
"docs:summary": "node generate-api-summary.cjs",
|
|
52
|
-
"docs:openapi": "node generate-openapi.cjs",
|
|
53
|
-
"docs:openapi:lint": "npx --yes @redocly/cli@latest lint openapi.yaml",
|
|
54
|
-
"docs:openapi:check": "node generate-openapi.cjs && npx --yes @redocly/cli@latest lint openapi.yaml",
|
|
55
|
-
"build:docs": "tsc build-docs.ts --outDir dist && node dist/build-docs.js",
|
|
56
|
-
"prepublishOnly": "npm run build"
|
|
57
|
-
},
|
|
58
|
-
"keywords": [
|
|
59
|
-
"smartlinks",
|
|
60
|
-
"api",
|
|
61
|
-
"authentication",
|
|
62
|
-
"traceability",
|
|
63
|
-
"blockchain",
|
|
64
|
-
"typescript",
|
|
65
|
-
"sdk"
|
|
66
|
-
],
|
|
67
|
-
"author": "Glenn Shoosmith",
|
|
68
|
-
"license": "MIT",
|
|
69
|
-
"publishConfig": {
|
|
70
|
-
"access": "public"
|
|
71
|
-
},
|
|
72
|
-
"dependencies": {
|
|
73
|
-
"cross-fetch": "^3.1.5",
|
|
74
|
-
"es-module-lexer": "^1.7.0"
|
|
75
|
-
},
|
|
76
|
-
"devDependencies": {
|
|
77
|
-
"ts-node": "^10.9.1",
|
|
78
|
-
"typedoc": "^0.25.13",
|
|
79
|
-
"typedoc-plugin-markdown": "^3.17.1",
|
|
80
|
-
"typescript": "^4.9.0"
|
|
81
|
-
},
|
|
82
|
-
"repository": {
|
|
83
|
-
"type": "git",
|
|
84
|
-
"url": "https://github.com/Prove-Anything/smartlinks.git"
|
|
85
|
-
},
|
|
86
|
-
"homepage": "https://smartlinks.app"
|
|
87
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@proveanything/smartlinks",
|
|
3
|
+
"version": "2.1.28",
|
|
4
|
+
"description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./testing": {
|
|
15
|
+
"types": "./dist/testing/index.d.ts",
|
|
16
|
+
"import": "./dist/testing/index.js",
|
|
17
|
+
"default": "./dist/testing/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./*": {
|
|
20
|
+
"types": "./dist/*.d.ts",
|
|
21
|
+
"import": "./dist/*.js",
|
|
22
|
+
"default": "./dist/*.js"
|
|
23
|
+
},
|
|
24
|
+
"./baseline.css": "./dist/baseline.css",
|
|
25
|
+
"./baseline.classes.json": "./dist/baseline.classes.json",
|
|
26
|
+
"./theme.css": "./dist/theme.css",
|
|
27
|
+
"./theme-boot.js": "./dist/theme-boot.js",
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"bin": {
|
|
31
|
+
"smartlinks-register-release": "scripts/register-release.mjs",
|
|
32
|
+
"smartlinks-publish": "scripts/publish.mjs",
|
|
33
|
+
"smartlinks-doctor": "scripts/doctor.mjs",
|
|
34
|
+
"smartlinks-headless": "scripts/headless-check.mjs"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist/",
|
|
38
|
+
"docs/",
|
|
39
|
+
"scripts/register-release.mjs",
|
|
40
|
+
"scripts/publish.mjs",
|
|
41
|
+
"scripts/doctor.mjs",
|
|
42
|
+
"scripts/headless-check.mjs",
|
|
43
|
+
"scripts/lib/",
|
|
44
|
+
"openapi.yaml",
|
|
45
|
+
"README.md"
|
|
46
|
+
],
|
|
47
|
+
"scripts": {
|
|
48
|
+
"test": "node test/run.cjs",
|
|
49
|
+
"build": "tsc && node scripts/fix-esm-extensions.mjs && node generate-api-summary.cjs && node generate-openapi.cjs && node scripts/copy-docs-to-dist.cjs && node scripts/build-baseline.mjs",
|
|
50
|
+
"docs": "typedoc",
|
|
51
|
+
"docs:summary": "node generate-api-summary.cjs",
|
|
52
|
+
"docs:openapi": "node generate-openapi.cjs",
|
|
53
|
+
"docs:openapi:lint": "npx --yes @redocly/cli@latest lint openapi.yaml",
|
|
54
|
+
"docs:openapi:check": "node generate-openapi.cjs && npx --yes @redocly/cli@latest lint openapi.yaml",
|
|
55
|
+
"build:docs": "tsc build-docs.ts --outDir dist && node dist/build-docs.js",
|
|
56
|
+
"prepublishOnly": "npm run build"
|
|
57
|
+
},
|
|
58
|
+
"keywords": [
|
|
59
|
+
"smartlinks",
|
|
60
|
+
"api",
|
|
61
|
+
"authentication",
|
|
62
|
+
"traceability",
|
|
63
|
+
"blockchain",
|
|
64
|
+
"typescript",
|
|
65
|
+
"sdk"
|
|
66
|
+
],
|
|
67
|
+
"author": "Glenn Shoosmith",
|
|
68
|
+
"license": "MIT",
|
|
69
|
+
"publishConfig": {
|
|
70
|
+
"access": "public"
|
|
71
|
+
},
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"cross-fetch": "^3.1.5",
|
|
74
|
+
"es-module-lexer": "^1.7.0"
|
|
75
|
+
},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"ts-node": "^10.9.1",
|
|
78
|
+
"typedoc": "^0.25.13",
|
|
79
|
+
"typedoc-plugin-markdown": "^3.17.1",
|
|
80
|
+
"typescript": "^4.9.0"
|
|
81
|
+
},
|
|
82
|
+
"repository": {
|
|
83
|
+
"type": "git",
|
|
84
|
+
"url": "https://github.com/Prove-Anything/smartlinks.git"
|
|
85
|
+
},
|
|
86
|
+
"homepage": "https://smartlinks.app"
|
|
87
|
+
}
|