@proveanything/smartlinks 2.1.27 → 2.1.29
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 +124 -10
- package/dist/docs/wallet-passes.md +87 -0
- package/dist/openapi.yaml +154 -8
- package/dist/types/broadcasts.d.ts +2 -4
- package/dist/types/comms.d.ts +1 -4
- package/dist/types/contact.d.ts +0 -1
- 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 +124 -10
- package/docs/wallet-passes.md +87 -0
- package/openapi.yaml +154 -8
- 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.29 | Generated: 2026-11-20T10:17:06.171Z
|
|
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
|
|
|
@@ -6040,7 +6041,7 @@ interface BroadcastAppendBulkBody {
|
|
|
6040
6041
|
}
|
|
6041
6042
|
```
|
|
6042
6043
|
|
|
6043
|
-
**BroadcastChannel** = `'email' | 'push' | 'sms'
|
|
6044
|
+
**BroadcastChannel** = `'email' | 'push' | 'sms'`
|
|
6044
6045
|
|
|
6045
6046
|
**BroadcastPreviewResponse** = ``
|
|
6046
6047
|
|
|
@@ -6931,7 +6932,7 @@ interface RegisterMethodResponse {
|
|
|
6931
6932
|
```typescript
|
|
6932
6933
|
interface SubscriptionsResolveRequest {
|
|
6933
6934
|
subject: { type: SubjectType; id: string; productId?: string }
|
|
6934
|
-
hints: { userId?: string; pushEndpoint?: string; email?: string
|
|
6935
|
+
hints: { userId?: string; pushEndpoint?: string; email?: string }
|
|
6935
6936
|
}
|
|
6936
6937
|
```
|
|
6937
6938
|
|
|
@@ -6944,11 +6945,9 @@ interface SubscriptionsResolveResponse {
|
|
|
6944
6945
|
contactId: string
|
|
6945
6946
|
subscribed: boolean
|
|
6946
6947
|
channels?: Partial<Record<BroadcastChannel, boolean>>
|
|
6947
|
-
walletForSubject?: boolean
|
|
6948
6948
|
}>
|
|
6949
6949
|
anySubscribed: boolean
|
|
6950
6950
|
anyMethods: boolean
|
|
6951
|
-
anyWalletForSubject: boolean
|
|
6952
6951
|
}
|
|
6953
6952
|
```
|
|
6954
6953
|
|
|
@@ -7292,7 +7291,7 @@ export interface RegisterMethodResponse { ok: true; contactId: string }
|
|
|
7292
7291
|
|
|
7293
7292
|
export interface SubscriptionsResolveRequest {
|
|
7294
7293
|
subject: { type: SubjectType; id: string; productId?: string }
|
|
7295
|
-
hints: { userId?: string; pushEndpoint?: string; email?: string
|
|
7294
|
+
hints: { userId?: string; pushEndpoint?: string; email?: string }
|
|
7296
7295
|
}
|
|
7297
7296
|
export interface SubscriptionsResolveResponse {
|
|
7298
7297
|
ok: true
|
|
@@ -7301,11 +7300,9 @@ export interface SubscriptionsResolveResponse {
|
|
|
7301
7300
|
contactId: string
|
|
7302
7301
|
subscribed: boolean
|
|
7303
7302
|
channels?: Partial<Record<BroadcastChannel, boolean>>
|
|
7304
|
-
walletForSubject?: boolean
|
|
7305
7303
|
}>
|
|
7306
7304
|
anySubscribed: boolean
|
|
7307
7305
|
anyMethods: boolean
|
|
7308
|
-
anyWalletForSubject: boolean
|
|
7309
7306
|
}
|
|
7310
7307
|
|
|
7311
7308
|
// Transactional send (single-contact, single-message)
|
|
@@ -7433,7 +7430,7 @@ export interface TransactionalSendError {
|
|
|
7433
7430
|
* - `transactional.phone_missing`
|
|
7434
7431
|
* - `transactional.whatsapp_missing`
|
|
7435
7432
|
* - `transactional.no_push_methods`
|
|
7436
|
-
* - `transactional.
|
|
7433
|
+
* - `transactional.no_wallet_passes` (`channel: 'wallet'`: the person has no wallet passes from this app)
|
|
7437
7434
|
* - `transactional.opted_out` (category `'service'`: the person turned that channel off, or the email is suppressed)
|
|
7438
7435
|
* - `transactional.template_or_message` / `transactional.message_invalid` / `transactional.about_invalid`
|
|
7439
7436
|
*/
|
|
@@ -7692,7 +7689,6 @@ interface CommMethodMeta {
|
|
|
7692
7689
|
auth?: string
|
|
7693
7690
|
phone?: string
|
|
7694
7691
|
email?: string
|
|
7695
|
-
walletObjectId?: string
|
|
7696
7692
|
subjectType?: SubjectType
|
|
7697
7693
|
subjectId?: string
|
|
7698
7694
|
productId?: string
|
|
@@ -12256,6 +12252,92 @@ interface VariantUpdateRequest {
|
|
|
12256
12252
|
}
|
|
12257
12253
|
```
|
|
12258
12254
|
|
|
12255
|
+
### wallet
|
|
12256
|
+
|
|
12257
|
+
**WalletPassRef** (interface)
|
|
12258
|
+
```typescript
|
|
12259
|
+
interface WalletPassRef {
|
|
12260
|
+
type: 'booking' | 'contact' | string
|
|
12261
|
+
id: string
|
|
12262
|
+
}
|
|
12263
|
+
```
|
|
12264
|
+
|
|
12265
|
+
**WalletPassContent** (interface)
|
|
12266
|
+
```typescript
|
|
12267
|
+
interface WalletPassContent {
|
|
12268
|
+
kind: WalletPassKind
|
|
12269
|
+
title: string
|
|
12270
|
+
subtitle?: string
|
|
12271
|
+
start?: string
|
|
12272
|
+
end?: string
|
|
12273
|
+
timezone?: string
|
|
12274
|
+
venue?: { name?: string; address?: string; lat?: number; lng?: number }
|
|
12275
|
+
holder?: string
|
|
12276
|
+
number?: string
|
|
12277
|
+
level?: string
|
|
12278
|
+
points?: number
|
|
12279
|
+
validUntil?: string
|
|
12280
|
+
fields?: Array<{ label: string; value: string }>
|
|
12281
|
+
back?: Array<{ label: string; value: string }>
|
|
12282
|
+
image?: string
|
|
12283
|
+
url?: string
|
|
12284
|
+
barcode?: string
|
|
12285
|
+
}
|
|
12286
|
+
```
|
|
12287
|
+
|
|
12288
|
+
**WalletPassLinks** (interface)
|
|
12289
|
+
```typescript
|
|
12290
|
+
interface WalletPassLinks {
|
|
12291
|
+
google?: string
|
|
12292
|
+
apple?: string
|
|
12293
|
+
}
|
|
12294
|
+
```
|
|
12295
|
+
|
|
12296
|
+
**WalletPassSummary** (interface)
|
|
12297
|
+
```typescript
|
|
12298
|
+
interface WalletPassSummary {
|
|
12299
|
+
id: string
|
|
12300
|
+
kind: WalletPassKind
|
|
12301
|
+
ref: WalletPassRef
|
|
12302
|
+
title?: string
|
|
12303
|
+
start?: string
|
|
12304
|
+
links: WalletPassLinks
|
|
12305
|
+
}
|
|
12306
|
+
```
|
|
12307
|
+
|
|
12308
|
+
**WalletPass** (interface)
|
|
12309
|
+
```typescript
|
|
12310
|
+
interface WalletPass {
|
|
12311
|
+
id: string
|
|
12312
|
+
collectionId: string
|
|
12313
|
+
kind: WalletPassKind
|
|
12314
|
+
ref: WalletPassRef
|
|
12315
|
+
contactId?: string | null
|
|
12316
|
+
status: 'active' | 'voided'
|
|
12317
|
+
issuedBy?: string | null
|
|
12318
|
+
model: WalletPassContent
|
|
12319
|
+
code: string
|
|
12320
|
+
version: number
|
|
12321
|
+
notice?: { header: string; body: string; at: string }
|
|
12322
|
+
voidReason?: string | null
|
|
12323
|
+
links?: WalletPassLinks
|
|
12324
|
+
createdAt?: string
|
|
12325
|
+
updatedAt?: string
|
|
12326
|
+
}
|
|
12327
|
+
```
|
|
12328
|
+
|
|
12329
|
+
**IssueWalletPassRequest** (interface)
|
|
12330
|
+
```typescript
|
|
12331
|
+
interface IssueWalletPassRequest {
|
|
12332
|
+
ref: WalletPassRef
|
|
12333
|
+
contactId?: string
|
|
12334
|
+
appId?: string
|
|
12335
|
+
pass: WalletPassContent
|
|
12336
|
+
}
|
|
12337
|
+
```
|
|
12338
|
+
|
|
12339
|
+
**WalletPassKind** = `'event' | 'booking' | 'membership' | 'loyalty'`
|
|
12340
|
+
|
|
12259
12341
|
### widgets
|
|
12260
12342
|
|
|
12261
12343
|
**NavigationRequest** (interface)
|
|
@@ -15556,3 +15638,35 @@ Listen for voice input
|
|
|
15556
15638
|
**speak**(text: string, options?: { voice?: string; rate?: number }) → `Promise<void>`
|
|
15557
15639
|
Speak text
|
|
15558
15640
|
|
|
15641
|
+
### wallet
|
|
15642
|
+
|
|
15643
|
+
**addLinks**(collectionId: string, ref: WalletPassRef) → `Promise<`
|
|
15644
|
+
"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 ```
|
|
15645
|
+
|
|
15646
|
+
**mine**(collectionId: string) → `Promise<`
|
|
15647
|
+
The signed-in person's active passes on this site, with their links.
|
|
15648
|
+
|
|
15649
|
+
**status**(collectionId: string) → `Promise<`
|
|
15650
|
+
Which wallets are switched on (admin).
|
|
15651
|
+
|
|
15652
|
+
**list**(collectionId: string, query: { refType?: string; refId?: string; contactId?: string; includeVoided?: boolean }) → `Promise<`
|
|
15653
|
+
Passes for one thing (`refType` + `refId`) or one person (`contactId`) (admin).
|
|
15654
|
+
|
|
15655
|
+
**get**(collectionId: string, passId: string) → `Promise<`
|
|
15656
|
+
One pass, with its links (admin).
|
|
15657
|
+
|
|
15658
|
+
**byCode**(collectionId: string, code: string) → `Promise<`
|
|
15659
|
+
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) ```
|
|
15660
|
+
|
|
15661
|
+
**issue**(collectionId: string, input: IssueWalletPassRequest) → `Promise<`
|
|
15662
|
+
Issue a pass (admin). Issuing again for the same thing, person and kind changes the existing pass.
|
|
15663
|
+
|
|
15664
|
+
**update**(collectionId: string, passId: string, fields: Partial<Omit<WalletPassContent, "kind">>) → `Promise<`
|
|
15665
|
+
Change what a pass shows; both wallets follow (admin).
|
|
15666
|
+
|
|
15667
|
+
**voidPass**(collectionId: string, passId: string, reason?: string) → `Promise<`
|
|
15668
|
+
The pass no longer counts: shown as void on the phone (admin).
|
|
15669
|
+
|
|
15670
|
+
**message**(collectionId: string, passId: string, msg: { header?: string; body: string }) → `Promise<`
|
|
15671
|
+
A lock-screen message on the pass (admin).
|
|
15672
|
+
|
|
@@ -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
|
@@ -27248,7 +27248,6 @@ components:
|
|
|
27248
27248
|
- email
|
|
27249
27249
|
- push
|
|
27250
27250
|
- sms
|
|
27251
|
-
- wallet
|
|
27252
27251
|
BroadcastPreviewResponse:
|
|
27253
27252
|
type: object
|
|
27254
27253
|
additionalProperties: true
|
|
@@ -28797,14 +28796,10 @@ components:
|
|
|
28797
28796
|
type: boolean
|
|
28798
28797
|
channels:
|
|
28799
28798
|
$ref: "#/components/schemas/BroadcastChannel"
|
|
28800
|
-
walletForSubject:
|
|
28801
|
-
type: boolean
|
|
28802
28799
|
anySubscribed:
|
|
28803
28800
|
type: boolean
|
|
28804
28801
|
anyMethods:
|
|
28805
28802
|
type: boolean
|
|
28806
|
-
anyWalletForSubject:
|
|
28807
|
-
type: boolean
|
|
28808
28803
|
required:
|
|
28809
28804
|
- ok
|
|
28810
28805
|
- subject
|
|
@@ -28813,7 +28808,6 @@ components:
|
|
|
28813
28808
|
- subscribed
|
|
28814
28809
|
- anySubscribed
|
|
28815
28810
|
- anyMethods
|
|
28816
|
-
- anyWalletForSubject
|
|
28817
28811
|
TransactionalSendRequest:
|
|
28818
28812
|
type: object
|
|
28819
28813
|
properties:
|
|
@@ -29420,8 +29414,6 @@ components:
|
|
|
29420
29414
|
type: string
|
|
29421
29415
|
email:
|
|
29422
29416
|
type: string
|
|
29423
|
-
walletObjectId:
|
|
29424
|
-
type: string
|
|
29425
29417
|
subjectType:
|
|
29426
29418
|
$ref: "#/components/schemas/SubjectType"
|
|
29427
29419
|
subjectId:
|
|
@@ -37368,6 +37360,160 @@ components:
|
|
|
37368
37360
|
properties:
|
|
37369
37361
|
name:
|
|
37370
37362
|
type: string
|
|
37363
|
+
WalletPassRef:
|
|
37364
|
+
type: object
|
|
37365
|
+
properties:
|
|
37366
|
+
type:
|
|
37367
|
+
type: string
|
|
37368
|
+
enum:
|
|
37369
|
+
- booking
|
|
37370
|
+
- contact
|
|
37371
|
+
id:
|
|
37372
|
+
type: string
|
|
37373
|
+
required:
|
|
37374
|
+
- type
|
|
37375
|
+
- id
|
|
37376
|
+
WalletPassContent:
|
|
37377
|
+
type: object
|
|
37378
|
+
properties:
|
|
37379
|
+
kind:
|
|
37380
|
+
$ref: "#/components/schemas/WalletPassKind"
|
|
37381
|
+
title:
|
|
37382
|
+
type: string
|
|
37383
|
+
subtitle:
|
|
37384
|
+
type: string
|
|
37385
|
+
start:
|
|
37386
|
+
type: string
|
|
37387
|
+
end:
|
|
37388
|
+
type: string
|
|
37389
|
+
timezone:
|
|
37390
|
+
type: string
|
|
37391
|
+
venue:
|
|
37392
|
+
type: object
|
|
37393
|
+
additionalProperties: true
|
|
37394
|
+
holder:
|
|
37395
|
+
type: string
|
|
37396
|
+
number:
|
|
37397
|
+
type: string
|
|
37398
|
+
level:
|
|
37399
|
+
type: string
|
|
37400
|
+
points:
|
|
37401
|
+
type: number
|
|
37402
|
+
validUntil:
|
|
37403
|
+
type: string
|
|
37404
|
+
fields:
|
|
37405
|
+
type: array
|
|
37406
|
+
items:
|
|
37407
|
+
type: object
|
|
37408
|
+
additionalProperties: true
|
|
37409
|
+
back:
|
|
37410
|
+
type: array
|
|
37411
|
+
items:
|
|
37412
|
+
type: object
|
|
37413
|
+
additionalProperties: true
|
|
37414
|
+
image:
|
|
37415
|
+
type: string
|
|
37416
|
+
url:
|
|
37417
|
+
type: string
|
|
37418
|
+
barcode:
|
|
37419
|
+
type: string
|
|
37420
|
+
required:
|
|
37421
|
+
- kind
|
|
37422
|
+
- title
|
|
37423
|
+
WalletPassLinks:
|
|
37424
|
+
type: object
|
|
37425
|
+
properties:
|
|
37426
|
+
google:
|
|
37427
|
+
type: string
|
|
37428
|
+
apple:
|
|
37429
|
+
type: string
|
|
37430
|
+
WalletPassSummary:
|
|
37431
|
+
type: object
|
|
37432
|
+
properties:
|
|
37433
|
+
id:
|
|
37434
|
+
type: string
|
|
37435
|
+
kind:
|
|
37436
|
+
$ref: "#/components/schemas/WalletPassKind"
|
|
37437
|
+
ref:
|
|
37438
|
+
$ref: "#/components/schemas/WalletPassRef"
|
|
37439
|
+
title:
|
|
37440
|
+
type: string
|
|
37441
|
+
start:
|
|
37442
|
+
type: string
|
|
37443
|
+
links:
|
|
37444
|
+
$ref: "#/components/schemas/WalletPassLinks"
|
|
37445
|
+
required:
|
|
37446
|
+
- id
|
|
37447
|
+
- kind
|
|
37448
|
+
- ref
|
|
37449
|
+
- links
|
|
37450
|
+
WalletPass:
|
|
37451
|
+
type: object
|
|
37452
|
+
properties:
|
|
37453
|
+
id:
|
|
37454
|
+
type: string
|
|
37455
|
+
collectionId:
|
|
37456
|
+
type: string
|
|
37457
|
+
kind:
|
|
37458
|
+
$ref: "#/components/schemas/WalletPassKind"
|
|
37459
|
+
ref:
|
|
37460
|
+
$ref: "#/components/schemas/WalletPassRef"
|
|
37461
|
+
contactId:
|
|
37462
|
+
type: string
|
|
37463
|
+
status:
|
|
37464
|
+
type: string
|
|
37465
|
+
enum:
|
|
37466
|
+
- active
|
|
37467
|
+
- voided
|
|
37468
|
+
issuedBy:
|
|
37469
|
+
type: string
|
|
37470
|
+
model:
|
|
37471
|
+
$ref: "#/components/schemas/WalletPassContent"
|
|
37472
|
+
code:
|
|
37473
|
+
type: string
|
|
37474
|
+
version:
|
|
37475
|
+
type: number
|
|
37476
|
+
notice:
|
|
37477
|
+
type: object
|
|
37478
|
+
additionalProperties: true
|
|
37479
|
+
voidReason:
|
|
37480
|
+
type: string
|
|
37481
|
+
links:
|
|
37482
|
+
$ref: "#/components/schemas/WalletPassLinks"
|
|
37483
|
+
createdAt:
|
|
37484
|
+
type: string
|
|
37485
|
+
updatedAt:
|
|
37486
|
+
type: string
|
|
37487
|
+
required:
|
|
37488
|
+
- id
|
|
37489
|
+
- collectionId
|
|
37490
|
+
- kind
|
|
37491
|
+
- ref
|
|
37492
|
+
- status
|
|
37493
|
+
- model
|
|
37494
|
+
- code
|
|
37495
|
+
- version
|
|
37496
|
+
IssueWalletPassRequest:
|
|
37497
|
+
type: object
|
|
37498
|
+
properties:
|
|
37499
|
+
ref:
|
|
37500
|
+
$ref: "#/components/schemas/WalletPassRef"
|
|
37501
|
+
contactId:
|
|
37502
|
+
type: string
|
|
37503
|
+
appId:
|
|
37504
|
+
type: string
|
|
37505
|
+
pass:
|
|
37506
|
+
$ref: "#/components/schemas/WalletPassContent"
|
|
37507
|
+
required:
|
|
37508
|
+
- ref
|
|
37509
|
+
- pass
|
|
37510
|
+
WalletPassKind:
|
|
37511
|
+
type: string
|
|
37512
|
+
enum:
|
|
37513
|
+
- event
|
|
37514
|
+
- booking
|
|
37515
|
+
- membership
|
|
37516
|
+
- loyalty
|
|
37371
37517
|
NavigationRequest:
|
|
37372
37518
|
type: object
|
|
37373
37519
|
properties:
|