@proveanything/smartlinks 2.0.68 → 2.0.70
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/authKit.d.ts +28 -4
- package/dist/api/authKit.js +35 -1
- package/dist/docs/API_SUMMARY.md +73 -11
- package/dist/docs/auth-kit.md +46 -5
- package/dist/docs/deploying-apps.md +9 -0
- package/dist/docs/members.md +182 -0
- package/dist/docs/overview.md +476 -475
- package/dist/docs/server-functions.md +4 -1
- package/dist/openapi.yaml +201 -20
- package/dist/testing/index.js +1 -1
- package/dist/types/appManifest.d.ts +16 -4
- package/dist/types/authKit.d.ts +58 -7
- package/docs/API_SUMMARY.md +73 -11
- package/docs/auth-kit.md +46 -5
- package/docs/deploying-apps.md +9 -0
- package/docs/members.md +182 -0
- package/docs/overview.md +476 -475
- package/docs/server-functions.md +4 -1
- package/openapi.yaml +201 -20
- package/package.json +1 -1
- package/scripts/publish.mjs +185 -147
|
@@ -587,7 +587,10 @@ Key records to the returned canonical `id`, and refuse `null` — otherwise anyo
|
|
|
587
587
|
empty fields** — it never overwrites a name or field the contact already has, because a visitor's typed
|
|
588
588
|
details are unverified. It's race-safe: two simultaneous entries with one email end on one contact.
|
|
589
589
|
Returns `{ contactId, created }`. `forCaller()` is the signed-in caller's own contact (`null` when
|
|
590
|
-
anonymous)
|
|
590
|
+
anonymous): `{ contactId, email, phone, firstName, lastName, displayName, tags, customFields }`. Use it
|
|
591
|
+
to check what a member is before returning member-only content — a level the staff set
|
|
592
|
+
(`customFields.level`), a tag. It includes staff-only fields, so return only what the caller may see
|
|
593
|
+
(see members.md). **Never return contact ids to public callers** — keep them on your records.
|
|
591
594
|
|
|
592
595
|
This is not consent. A ticked "keep me updated" box is evidence you can record (below); subscribing
|
|
593
596
|
someone to marketing is the double opt-in flow (`comms.signup`, see comms.md).
|
package/dist/openapi.yaml
CHANGED
|
@@ -2116,6 +2116,44 @@ paths:
|
|
|
2116
2116
|
schema:
|
|
2117
2117
|
type: object
|
|
2118
2118
|
additionalProperties: true
|
|
2119
|
+
/admin/collection/{collectionId}/authKit/{authKitId}/invite:
|
|
2120
|
+
post:
|
|
2121
|
+
tags:
|
|
2122
|
+
- authKit
|
|
2123
|
+
summary: Invite someone to be a member of a site with its own logins (admin).
|
|
2124
|
+
operationId: authKit_invite
|
|
2125
|
+
security:
|
|
2126
|
+
- bearerAuth: []
|
|
2127
|
+
parameters:
|
|
2128
|
+
- name: collectionId
|
|
2129
|
+
in: path
|
|
2130
|
+
required: true
|
|
2131
|
+
schema:
|
|
2132
|
+
type: string
|
|
2133
|
+
- name: authKitId
|
|
2134
|
+
in: path
|
|
2135
|
+
required: true
|
|
2136
|
+
schema:
|
|
2137
|
+
type: string
|
|
2138
|
+
responses:
|
|
2139
|
+
200:
|
|
2140
|
+
description: Success
|
|
2141
|
+
content:
|
|
2142
|
+
application/json:
|
|
2143
|
+
schema:
|
|
2144
|
+
$ref: "#/components/schemas/AuthKitInviteResponse"
|
|
2145
|
+
400:
|
|
2146
|
+
description: Bad request
|
|
2147
|
+
401:
|
|
2148
|
+
description: Unauthorized
|
|
2149
|
+
404:
|
|
2150
|
+
description: Not found
|
|
2151
|
+
requestBody:
|
|
2152
|
+
required: true
|
|
2153
|
+
content:
|
|
2154
|
+
application/json:
|
|
2155
|
+
schema:
|
|
2156
|
+
$ref: "#/components/schemas/AuthKitInviteRequest"
|
|
2119
2157
|
/admin/collection/{collectionId}/batch:
|
|
2120
2158
|
get:
|
|
2121
2159
|
tags:
|
|
@@ -9898,10 +9936,7 @@ paths:
|
|
|
9898
9936
|
content:
|
|
9899
9937
|
application/json:
|
|
9900
9938
|
schema:
|
|
9901
|
-
|
|
9902
|
-
enum:
|
|
9903
|
-
- email
|
|
9904
|
-
- sms
|
|
9939
|
+
$ref: "#/components/schemas/MfaFactor"
|
|
9905
9940
|
/authkit/{clientId}/mfa/challenge/verify:
|
|
9906
9941
|
post:
|
|
9907
9942
|
tags:
|
|
@@ -10058,6 +10093,58 @@ paths:
|
|
|
10058
10093
|
description: Unauthorized
|
|
10059
10094
|
404:
|
|
10060
10095
|
description: Not found
|
|
10096
|
+
/authkit/{clientId}/mfa/factors/totp/confirm:
|
|
10097
|
+
post:
|
|
10098
|
+
tags:
|
|
10099
|
+
- authKit
|
|
10100
|
+
summary: Confirm authenticator-app enrollment with the 6-digit code the app shows (authenticated).
|
|
10101
|
+
operationId: authKit_confirmTotpMfa
|
|
10102
|
+
security: []
|
|
10103
|
+
parameters:
|
|
10104
|
+
- name: clientId
|
|
10105
|
+
in: path
|
|
10106
|
+
required: true
|
|
10107
|
+
schema:
|
|
10108
|
+
type: string
|
|
10109
|
+
responses:
|
|
10110
|
+
200:
|
|
10111
|
+
description: Success
|
|
10112
|
+
content:
|
|
10113
|
+
application/json:
|
|
10114
|
+
schema:
|
|
10115
|
+
$ref: "#/components/schemas/MfaEnrolledResponse"
|
|
10116
|
+
400:
|
|
10117
|
+
description: Bad request
|
|
10118
|
+
401:
|
|
10119
|
+
description: Unauthorized
|
|
10120
|
+
404:
|
|
10121
|
+
description: Not found
|
|
10122
|
+
/authkit/{clientId}/mfa/factors/totp/enroll:
|
|
10123
|
+
post:
|
|
10124
|
+
tags:
|
|
10125
|
+
- authKit
|
|
10126
|
+
summary: "Begin authenticator-app enrollment (authenticated): a new secret for Google Authenticator, Microsoft Authenticator, 1Password and the like."
|
|
10127
|
+
operationId: authKit_enrollTotpMfa
|
|
10128
|
+
security: []
|
|
10129
|
+
parameters:
|
|
10130
|
+
- name: clientId
|
|
10131
|
+
in: path
|
|
10132
|
+
required: true
|
|
10133
|
+
schema:
|
|
10134
|
+
type: string
|
|
10135
|
+
responses:
|
|
10136
|
+
200:
|
|
10137
|
+
description: Success
|
|
10138
|
+
content:
|
|
10139
|
+
application/json:
|
|
10140
|
+
schema:
|
|
10141
|
+
$ref: "#/components/schemas/MfaTotpEnrollResponse"
|
|
10142
|
+
400:
|
|
10143
|
+
description: Bad request
|
|
10144
|
+
401:
|
|
10145
|
+
description: Unauthorized
|
|
10146
|
+
404:
|
|
10147
|
+
description: Not found
|
|
10061
10148
|
/authkit/{clientId}/mfa/factors/{factor}:
|
|
10062
10149
|
get:
|
|
10063
10150
|
tags:
|
|
@@ -19790,6 +19877,37 @@ components:
|
|
|
19790
19877
|
- userId
|
|
19791
19878
|
- anonymous
|
|
19792
19879
|
- via
|
|
19880
|
+
CallerContact:
|
|
19881
|
+
type: object
|
|
19882
|
+
properties:
|
|
19883
|
+
contactId:
|
|
19884
|
+
type: string
|
|
19885
|
+
email:
|
|
19886
|
+
type: string
|
|
19887
|
+
phone:
|
|
19888
|
+
type: string
|
|
19889
|
+
firstName:
|
|
19890
|
+
type: string
|
|
19891
|
+
lastName:
|
|
19892
|
+
type: string
|
|
19893
|
+
displayName:
|
|
19894
|
+
type: string
|
|
19895
|
+
tags:
|
|
19896
|
+
type: array
|
|
19897
|
+
items:
|
|
19898
|
+
type: string
|
|
19899
|
+
customFields:
|
|
19900
|
+
type: object
|
|
19901
|
+
additionalProperties: true
|
|
19902
|
+
required:
|
|
19903
|
+
- contactId
|
|
19904
|
+
- email
|
|
19905
|
+
- phone
|
|
19906
|
+
- firstName
|
|
19907
|
+
- lastName
|
|
19908
|
+
- displayName
|
|
19909
|
+
- tags
|
|
19910
|
+
- customFields
|
|
19793
19911
|
ServerFunctionContext:
|
|
19794
19912
|
type: object
|
|
19795
19913
|
properties:
|
|
@@ -22894,15 +23012,9 @@ components:
|
|
|
22894
23012
|
availableFactors:
|
|
22895
23013
|
type: array
|
|
22896
23014
|
items:
|
|
22897
|
-
|
|
22898
|
-
enum:
|
|
22899
|
-
- email
|
|
22900
|
-
- sms
|
|
23015
|
+
$ref: "#/components/schemas/MfaFactor"
|
|
22901
23016
|
preferredFactor:
|
|
22902
|
-
|
|
22903
|
-
enum:
|
|
22904
|
-
- email
|
|
22905
|
-
- sms
|
|
23017
|
+
$ref: "#/components/schemas/MfaFactor"
|
|
22906
23018
|
maskedDestinations:
|
|
22907
23019
|
type: object
|
|
22908
23020
|
additionalProperties: true
|
|
@@ -22918,10 +23030,7 @@ components:
|
|
|
22918
23030
|
type: object
|
|
22919
23031
|
additionalProperties: true
|
|
22920
23032
|
factor:
|
|
22921
|
-
|
|
22922
|
-
enum:
|
|
22923
|
-
- email
|
|
22924
|
-
- sms
|
|
23033
|
+
$ref: "#/components/schemas/MfaFactor"
|
|
22925
23034
|
destination:
|
|
22926
23035
|
type: string
|
|
22927
23036
|
expiresAt:
|
|
@@ -22951,6 +23060,28 @@ components:
|
|
|
22951
23060
|
- mfaSessionToken
|
|
22952
23061
|
- destination
|
|
22953
23062
|
- expiresAt
|
|
23063
|
+
MfaTotpEnrollResponse:
|
|
23064
|
+
type: object
|
|
23065
|
+
properties:
|
|
23066
|
+
mfaSessionToken:
|
|
23067
|
+
type: string
|
|
23068
|
+
secret:
|
|
23069
|
+
type: string
|
|
23070
|
+
otpauthUri:
|
|
23071
|
+
type: string
|
|
23072
|
+
issuer:
|
|
23073
|
+
type: string
|
|
23074
|
+
account:
|
|
23075
|
+
type: string
|
|
23076
|
+
expiresAt:
|
|
23077
|
+
type: string
|
|
23078
|
+
required:
|
|
23079
|
+
- mfaSessionToken
|
|
23080
|
+
- secret
|
|
23081
|
+
- otpauthUri
|
|
23082
|
+
- issuer
|
|
23083
|
+
- account
|
|
23084
|
+
- expiresAt
|
|
22954
23085
|
MfaEnrolledResponse:
|
|
22955
23086
|
type: object
|
|
22956
23087
|
properties:
|
|
@@ -22958,10 +23089,7 @@ components:
|
|
|
22958
23089
|
type: object
|
|
22959
23090
|
additionalProperties: true
|
|
22960
23091
|
factor:
|
|
22961
|
-
|
|
22962
|
-
enum:
|
|
22963
|
-
- email
|
|
22964
|
-
- sms
|
|
23092
|
+
$ref: "#/components/schemas/MfaFactor"
|
|
22965
23093
|
required:
|
|
22966
23094
|
- enrolled
|
|
22967
23095
|
- factor
|
|
@@ -22977,6 +23105,9 @@ components:
|
|
|
22977
23105
|
sms:
|
|
22978
23106
|
type: object
|
|
22979
23107
|
additionalProperties: true
|
|
23108
|
+
totp:
|
|
23109
|
+
type: object
|
|
23110
|
+
additionalProperties: true
|
|
22980
23111
|
recoveryCodesRemaining:
|
|
22981
23112
|
type: number
|
|
22982
23113
|
mfaEnabledForClient:
|
|
@@ -23372,8 +23503,51 @@ components:
|
|
|
23372
23503
|
type: string
|
|
23373
23504
|
identity:
|
|
23374
23505
|
$ref: "#/components/schemas/AuthKitIdentity"
|
|
23506
|
+
signUp:
|
|
23507
|
+
type: string
|
|
23508
|
+
enum:
|
|
23509
|
+
- open
|
|
23510
|
+
- invite
|
|
23375
23511
|
required:
|
|
23376
23512
|
- id
|
|
23513
|
+
AuthKitInviteRequest:
|
|
23514
|
+
type: object
|
|
23515
|
+
properties:
|
|
23516
|
+
email:
|
|
23517
|
+
type: string
|
|
23518
|
+
firstName:
|
|
23519
|
+
type: string
|
|
23520
|
+
lastName:
|
|
23521
|
+
type: string
|
|
23522
|
+
displayName:
|
|
23523
|
+
type: string
|
|
23524
|
+
customFields:
|
|
23525
|
+
type: object
|
|
23526
|
+
additionalProperties: true
|
|
23527
|
+
redirectUrl:
|
|
23528
|
+
type: string
|
|
23529
|
+
required:
|
|
23530
|
+
- email
|
|
23531
|
+
AuthKitInviteResponse:
|
|
23532
|
+
type: object
|
|
23533
|
+
properties:
|
|
23534
|
+
ok:
|
|
23535
|
+
type: object
|
|
23536
|
+
additionalProperties: true
|
|
23537
|
+
userId:
|
|
23538
|
+
type: string
|
|
23539
|
+
contactId:
|
|
23540
|
+
type: string
|
|
23541
|
+
created:
|
|
23542
|
+
type: boolean
|
|
23543
|
+
expiresAt:
|
|
23544
|
+
type: string
|
|
23545
|
+
required:
|
|
23546
|
+
- ok
|
|
23547
|
+
- userId
|
|
23548
|
+
- contactId
|
|
23549
|
+
- created
|
|
23550
|
+
- expiresAt
|
|
23377
23551
|
AuthKitIdentity:
|
|
23378
23552
|
type: object
|
|
23379
23553
|
properties:
|
|
@@ -23465,6 +23639,13 @@ components:
|
|
|
23465
23639
|
- INVALID_APPLE_TOKEN
|
|
23466
23640
|
- ACCOUNT_EXISTS_UNVERIFIED
|
|
23467
23641
|
- APPLE_AUTH_FAILED
|
|
23642
|
+
- SIGN_UP_CLOSED
|
|
23643
|
+
MfaFactor:
|
|
23644
|
+
type: string
|
|
23645
|
+
enum:
|
|
23646
|
+
- email
|
|
23647
|
+
- sms
|
|
23648
|
+
- totp
|
|
23468
23649
|
MfaErrorCode:
|
|
23469
23650
|
type: string
|
|
23470
23651
|
enum:
|
package/dist/testing/index.js
CHANGED
|
@@ -241,7 +241,7 @@ export function createFunctionTestContext(opts) {
|
|
|
241
241
|
mem.contacts.push(Object.assign(Object.assign({}, d), { email, phone, contactId }));
|
|
242
242
|
return { contactId, created: true };
|
|
243
243
|
}), 'contacts.upsert'),
|
|
244
|
-
forCaller: gated('contacts', 'write', ct.forCaller ? ct.forCaller.bind(ct) : (async () => (opts.caller && opts.caller.userId ? { contactId: `contact-of-${opts.caller.userId}
|
|
244
|
+
forCaller: gated('contacts', 'write', ct.forCaller ? ct.forCaller.bind(ct) : (async () => (opts.caller && opts.caller.userId ? { contactId: `contact-of-${opts.caller.userId}`, email: null, phone: null, firstName: null, lastName: null, displayName: null, tags: [], customFields: {} } : null)), 'contacts.forCaller'),
|
|
245
245
|
};
|
|
246
246
|
const it = impl.interactions || {};
|
|
247
247
|
sl.interactions = {
|
|
@@ -437,16 +437,16 @@ export interface ServerFunctionSl {
|
|
|
437
437
|
/**
|
|
438
438
|
* Contacts (`sl:contacts:write`). `upsert` finds by email/phone or creates, and only FILLS EMPTY
|
|
439
439
|
* fields — never overwrites (details typed by a visitor are unverified). `forCaller` is the signed-in
|
|
440
|
-
* caller's own contact (null when anonymous)
|
|
440
|
+
* caller's own contact with its tags and custom fields (null when anonymous) — check a member's level
|
|
441
|
+
* (`customFields.level`) here before returning member-only content. It includes staff-only fields:
|
|
442
|
+
* return only what the caller may see. Never return contact ids to public callers.
|
|
441
443
|
*/
|
|
442
444
|
contacts: {
|
|
443
445
|
upsert(details: ContactUpsertDetails): Promise<{
|
|
444
446
|
contactId: string;
|
|
445
447
|
created: boolean;
|
|
446
448
|
}>;
|
|
447
|
-
forCaller(): Promise<
|
|
448
|
-
contactId: string;
|
|
449
|
-
} | null>;
|
|
449
|
+
forCaller(): Promise<CallerContact | null>;
|
|
450
450
|
};
|
|
451
451
|
/**
|
|
452
452
|
* Interactions (`sl:interactions:write`). `record` stores an event of one of THIS app's interaction
|
|
@@ -502,6 +502,18 @@ export interface ServerFunctionCaller {
|
|
|
502
502
|
/** How the function was triggered. */
|
|
503
503
|
via: AppFunctionTriggerType;
|
|
504
504
|
}
|
|
505
|
+
/** The signed-in caller's own contact, as a server function sees it (`ctx.sl.contacts.forCaller()`). */
|
|
506
|
+
export interface CallerContact {
|
|
507
|
+
contactId: string;
|
|
508
|
+
email: string | null;
|
|
509
|
+
phone: string | null;
|
|
510
|
+
firstName: string | null;
|
|
511
|
+
lastName: string | null;
|
|
512
|
+
displayName: string | null;
|
|
513
|
+
tags: string[];
|
|
514
|
+
/** The collection's custom contact fields — including staff-only ones (a member's level, a paid-until date). */
|
|
515
|
+
customFields: Record<string, unknown>;
|
|
516
|
+
}
|
|
505
517
|
/**
|
|
506
518
|
* The context handed to every SmartLinks server function. The platform builds a
|
|
507
519
|
* fresh one per invocation and pre-scopes each handle to the function's declared
|
package/dist/types/authKit.d.ts
CHANGED
|
@@ -128,7 +128,9 @@ export interface AppleLoginOptions {
|
|
|
128
128
|
* `ACCOUNT_EXISTS_UNVERIFIED` case also carries `requiresEmailVerification: true`
|
|
129
129
|
* in `SmartlinksApiError.details`.
|
|
130
130
|
*/
|
|
131
|
-
export type AuthKitErrorCode = 'MISSING_APPLE_TOKEN' | 'APPLE_AUTH_NOT_CONFIGURED' | 'INVALID_APPLE_TOKEN' | 'ACCOUNT_EXISTS_UNVERIFIED' | 'APPLE_AUTH_FAILED';
|
|
131
|
+
export type AuthKitErrorCode = 'MISSING_APPLE_TOKEN' | 'APPLE_AUTH_NOT_CONFIGURED' | 'INVALID_APPLE_TOKEN' | 'ACCOUNT_EXISTS_UNVERIFIED' | 'APPLE_AUTH_FAILED' | 'SIGN_UP_CLOSED';
|
|
132
|
+
/** A second-step method: a code by email or text message, or from an authenticator app. */
|
|
133
|
+
export type MfaFactor = 'email' | 'sms' | 'totp';
|
|
132
134
|
/**
|
|
133
135
|
* Details carried on the `MFA_REQUIRED` error thrown by any session-issuing login method
|
|
134
136
|
* (see the gate list above) when the client's MFA policy requires a step-up. Surfaced as
|
|
@@ -139,18 +141,20 @@ export interface MfaRequiredDetails {
|
|
|
139
141
|
/** Short-lived (10 min) and single-use. Pass it to every challenge/finalize call below. */
|
|
140
142
|
mfaSessionToken: string;
|
|
141
143
|
/** Only factors the user actually enrolled. */
|
|
142
|
-
availableFactors:
|
|
143
|
-
/** `
|
|
144
|
-
preferredFactor:
|
|
144
|
+
availableFactors: MfaFactor[];
|
|
145
|
+
/** `totp`, then `sms`, then `email`: the first one the user enrolled. */
|
|
146
|
+
preferredFactor: MfaFactor;
|
|
147
|
+
/** `totp` is "your authenticator app" (nothing is sent for it). */
|
|
145
148
|
maskedDestinations: {
|
|
146
149
|
email?: string;
|
|
147
150
|
sms?: string;
|
|
151
|
+
totp?: string;
|
|
148
152
|
};
|
|
149
153
|
}
|
|
150
154
|
/** Response from {@link authKit.mfaChallengeSend}. */
|
|
151
155
|
export interface MfaChallengeSendResponse {
|
|
152
156
|
success: true;
|
|
153
|
-
factor:
|
|
157
|
+
factor: MfaFactor;
|
|
154
158
|
/** Masked, e.g. `"j***@x.com"` or `"+1******1234"`. */
|
|
155
159
|
destination: string;
|
|
156
160
|
/** ISO timestamp, 10 minutes from send. */
|
|
@@ -179,10 +183,22 @@ export interface MfaEnrollSendResponse {
|
|
|
179
183
|
destination: string;
|
|
180
184
|
expiresAt: string;
|
|
181
185
|
}
|
|
182
|
-
/** Response from {@link authKit.
|
|
186
|
+
/** Response from {@link authKit.enrollTotpMfa}: show `otpauthUri` as a QR code, and `secret` for typing in. */
|
|
187
|
+
export interface MfaTotpEnrollResponse {
|
|
188
|
+
mfaSessionToken: string;
|
|
189
|
+
/** Base32, for people who type it into their app instead of scanning. Returned only here. */
|
|
190
|
+
secret: string;
|
|
191
|
+
/** `otpauth://totp/…` — render it as a QR code for the app to scan. */
|
|
192
|
+
otpauthUri: string;
|
|
193
|
+
/** What the app shows the entry as: the site, and the account. */
|
|
194
|
+
issuer: string;
|
|
195
|
+
account: string;
|
|
196
|
+
expiresAt: string;
|
|
197
|
+
}
|
|
198
|
+
/** Response from {@link authKit.confirmEmailMfa} / {@link authKit.confirmSmsMfa} / {@link authKit.confirmTotpMfa}. */
|
|
183
199
|
export interface MfaEnrolledResponse {
|
|
184
200
|
enrolled: true;
|
|
185
|
-
factor:
|
|
201
|
+
factor: MfaFactor;
|
|
186
202
|
}
|
|
187
203
|
/** Response from {@link authKit.getMfaFactors}. */
|
|
188
204
|
export interface MfaFactorsResponse {
|
|
@@ -195,6 +211,11 @@ export interface MfaFactorsResponse {
|
|
|
195
211
|
enrolledAt: string;
|
|
196
212
|
destination: string;
|
|
197
213
|
};
|
|
214
|
+
/** `destination` is "Authenticator app". */
|
|
215
|
+
totp?: {
|
|
216
|
+
enrolledAt: string;
|
|
217
|
+
destination: string;
|
|
218
|
+
};
|
|
198
219
|
};
|
|
199
220
|
recoveryCodesRemaining: number;
|
|
200
221
|
mfaEnabledForClient: boolean;
|
|
@@ -415,6 +436,36 @@ export interface AuthKitConfig {
|
|
|
415
436
|
* site, its own passwords). Switch with {@link authKit.setIdentity}; never via create/update.
|
|
416
437
|
*/
|
|
417
438
|
identity?: AuthKitIdentity;
|
|
439
|
+
/**
|
|
440
|
+
* Who may join a site with its own logins. `open` (default): anyone can create an account.
|
|
441
|
+
* `invite`: only people the site's admins invite ({@link authKit.invite}). Every way of signing up
|
|
442
|
+
* (password, magic link, phone, Google, Apple, LinkedIn, WhatsApp) then refuses anyone else with
|
|
443
|
+
* `SIGN_UP_CLOSED` (403), and "send me a link / a code" answers as if sent without sending anything,
|
|
444
|
+
* so nobody can find out who is a member. Hide your "Create an account" option when it's `invite`.
|
|
445
|
+
* Setting `invite` needs own logins first (`OWN_LOGINS_REQUIRED`, 409).
|
|
446
|
+
*/
|
|
447
|
+
signUp?: 'open' | 'invite';
|
|
448
|
+
}
|
|
449
|
+
/** Body of {@link authKit.invite}. */
|
|
450
|
+
export interface AuthKitInviteRequest {
|
|
451
|
+
email: string;
|
|
452
|
+
firstName?: string;
|
|
453
|
+
lastName?: string;
|
|
454
|
+
displayName?: string;
|
|
455
|
+
/** Set on their contact in this collection, e.g. `{ level: 'member' }` (staff-only and visible fields alike). */
|
|
456
|
+
customFields?: Record<string, unknown>;
|
|
457
|
+
/** Where the emailed link opens: the site's sign-in page (one of its own addresses). Default: the kit's `redirectUrl`. */
|
|
458
|
+
redirectUrl?: string;
|
|
459
|
+
}
|
|
460
|
+
/** Result of {@link authKit.invite}. The sign-in link itself only goes to their inbox. */
|
|
461
|
+
export interface AuthKitInviteResponse {
|
|
462
|
+
ok: true;
|
|
463
|
+
userId: string;
|
|
464
|
+
contactId: string;
|
|
465
|
+
/** true when their account was made by this invite; false when they had one (they got a new link). */
|
|
466
|
+
created: boolean;
|
|
467
|
+
/** When the emailed link stops working (it works once). */
|
|
468
|
+
expiresAt: string;
|
|
418
469
|
}
|
|
419
470
|
/** An AuthKit's member pool. */
|
|
420
471
|
export interface AuthKitIdentity {
|
package/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.70 | Generated: 2026-10-24T08:16:51.896Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -2808,7 +2808,7 @@ interface ServerFunctionSl {
|
|
|
2808
2808
|
tags: { resolve(id: string): Promise<ResolvedTag | null> };
|
|
2809
2809
|
contacts: {
|
|
2810
2810
|
upsert(details: ContactUpsertDetails): Promise<{ contactId: string; created: boolean }>;
|
|
2811
|
-
forCaller(): Promise<
|
|
2811
|
+
forCaller(): Promise<CallerContact | null>;
|
|
2812
2812
|
};
|
|
2813
2813
|
interactions: { record(event: ServerFunctionInteractionEvent): Promise<{ eventId: string }> };
|
|
2814
2814
|
tools: { run<T = any>(name: string, args?: Record<string, any>): Promise<T> };
|
|
@@ -2830,6 +2830,20 @@ interface ServerFunctionCaller {
|
|
|
2830
2830
|
}
|
|
2831
2831
|
```
|
|
2832
2832
|
|
|
2833
|
+
**CallerContact** (interface)
|
|
2834
|
+
```typescript
|
|
2835
|
+
interface CallerContact {
|
|
2836
|
+
contactId: string;
|
|
2837
|
+
email: string | null;
|
|
2838
|
+
phone: string | null;
|
|
2839
|
+
firstName: string | null;
|
|
2840
|
+
lastName: string | null;
|
|
2841
|
+
displayName: string | null;
|
|
2842
|
+
tags: string[];
|
|
2843
|
+
customFields: Record<string, unknown>;
|
|
2844
|
+
}
|
|
2845
|
+
```
|
|
2846
|
+
|
|
2833
2847
|
**ServerFunctionContext** (interface)
|
|
2834
2848
|
```typescript
|
|
2835
2849
|
interface ServerFunctionContext {
|
|
@@ -4565,9 +4579,9 @@ interface AppleLoginOptions {
|
|
|
4565
4579
|
```typescript
|
|
4566
4580
|
interface MfaRequiredDetails {
|
|
4567
4581
|
mfaSessionToken: string
|
|
4568
|
-
availableFactors:
|
|
4569
|
-
preferredFactor:
|
|
4570
|
-
maskedDestinations: { email?: string; sms?: string }
|
|
4582
|
+
availableFactors: MfaFactor[]
|
|
4583
|
+
preferredFactor: MfaFactor
|
|
4584
|
+
maskedDestinations: { email?: string; sms?: string; totp?: string }
|
|
4571
4585
|
}
|
|
4572
4586
|
```
|
|
4573
4587
|
|
|
@@ -4575,7 +4589,7 @@ interface MfaRequiredDetails {
|
|
|
4575
4589
|
```typescript
|
|
4576
4590
|
interface MfaChallengeSendResponse {
|
|
4577
4591
|
success: true
|
|
4578
|
-
factor:
|
|
4592
|
+
factor: MfaFactor
|
|
4579
4593
|
destination: string
|
|
4580
4594
|
expiresAt: string
|
|
4581
4595
|
}
|
|
@@ -4590,11 +4604,23 @@ interface MfaEnrollSendResponse {
|
|
|
4590
4604
|
}
|
|
4591
4605
|
```
|
|
4592
4606
|
|
|
4607
|
+
**MfaTotpEnrollResponse** (interface)
|
|
4608
|
+
```typescript
|
|
4609
|
+
interface MfaTotpEnrollResponse {
|
|
4610
|
+
mfaSessionToken: string
|
|
4611
|
+
secret: string
|
|
4612
|
+
otpauthUri: string
|
|
4613
|
+
issuer: string
|
|
4614
|
+
account: string
|
|
4615
|
+
expiresAt: string
|
|
4616
|
+
}
|
|
4617
|
+
```
|
|
4618
|
+
|
|
4593
4619
|
**MfaEnrolledResponse** (interface)
|
|
4594
4620
|
```typescript
|
|
4595
4621
|
interface MfaEnrolledResponse {
|
|
4596
4622
|
enrolled: true
|
|
4597
|
-
factor:
|
|
4623
|
+
factor: MfaFactor
|
|
4598
4624
|
}
|
|
4599
4625
|
```
|
|
4600
4626
|
|
|
@@ -4604,6 +4630,7 @@ interface MfaFactorsResponse {
|
|
|
4604
4630
|
enrolledFactors: {
|
|
4605
4631
|
email?: { enrolledAt: string; destination: string }
|
|
4606
4632
|
sms?: { enrolledAt: string; destination: string }
|
|
4633
|
+
totp?: { enrolledAt: string; destination: string }
|
|
4607
4634
|
}
|
|
4608
4635
|
recoveryCodesRemaining: number
|
|
4609
4636
|
mfaEnabledForClient: boolean
|
|
@@ -4866,6 +4893,30 @@ interface AuthKitConfig {
|
|
|
4866
4893
|
security?: AuthKitSecurityConfig
|
|
4867
4894
|
collectionIds?: string[]
|
|
4868
4895
|
identity?: AuthKitIdentity
|
|
4896
|
+
signUp?: 'open' | 'invite'
|
|
4897
|
+
}
|
|
4898
|
+
```
|
|
4899
|
+
|
|
4900
|
+
**AuthKitInviteRequest** (interface)
|
|
4901
|
+
```typescript
|
|
4902
|
+
interface AuthKitInviteRequest {
|
|
4903
|
+
email: string
|
|
4904
|
+
firstName?: string
|
|
4905
|
+
lastName?: string
|
|
4906
|
+
displayName?: string
|
|
4907
|
+
customFields?: Record<string, unknown>
|
|
4908
|
+
redirectUrl?: string
|
|
4909
|
+
}
|
|
4910
|
+
```
|
|
4911
|
+
|
|
4912
|
+
**AuthKitInviteResponse** (interface)
|
|
4913
|
+
```typescript
|
|
4914
|
+
interface AuthKitInviteResponse {
|
|
4915
|
+
ok: true
|
|
4916
|
+
userId: string
|
|
4917
|
+
contactId: string
|
|
4918
|
+
created: boolean
|
|
4919
|
+
expiresAt: string
|
|
4869
4920
|
}
|
|
4870
4921
|
```
|
|
4871
4922
|
|
|
@@ -4934,6 +4985,8 @@ interface AuthKitLockoutPolicy {
|
|
|
4934
4985
|
|
|
4935
4986
|
**AuthKitErrorCode** = ``
|
|
4936
4987
|
|
|
4988
|
+
**MfaFactor** = `'email' | 'sms' | 'totp'`
|
|
4989
|
+
|
|
4937
4990
|
**MfaErrorCode** = ``
|
|
4938
4991
|
|
|
4939
4992
|
**VerifyStatus** = `'pending' | 'verified' | 'failed' | 'expired' | 'unknown'`
|
|
@@ -11291,8 +11344,8 @@ Update the authenticated user's profile and replace the bearer token when refres
|
|
|
11291
11344
|
**deleteAccount**(clientId: string, password: string, confirmText: string) → `Promise<SuccessResponse>`
|
|
11292
11345
|
Update the authenticated user's profile and replace the bearer token when refreshed claims are returned.
|
|
11293
11346
|
|
|
11294
|
-
**mfaChallengeSend**(clientId: string, mfaSessionToken: string, factor:
|
|
11295
|
-
Send (or resend) an MFA challenge code to the given factor (public).
|
|
11347
|
+
**mfaChallengeSend**(clientId: string, mfaSessionToken: string, factor: MfaFactor) → `Promise<MfaChallengeSendResponse>`
|
|
11348
|
+
Send (or resend) an MFA challenge code to the given factor (public). For `totp` nothing is sent — it tells the server the code will come from their authenticator app; then {@link mfaChallengeVerify}.
|
|
11296
11349
|
|
|
11297
11350
|
**mfaChallengeVerify**(clientId: string, mfaSessionToken: string, code: string, trustDevice?: boolean, deviceLabel?: string) → `Promise<MfaFinalizeResponse>`
|
|
11298
11351
|
Verify an MFA challenge code and finalize the login (public). On success this behaves like {@link login} — the bearer token is adopted and the cache invalidated. it and pass it to future {@link login} calls to skip the challenge on this device.
|
|
@@ -11315,10 +11368,16 @@ Begin SMS-factor enrollment; sends a code to the given phone number (authenticat
|
|
|
11315
11368
|
**confirmSmsMfa**(clientId: string, mfaSessionToken: string, code: string) → `Promise<MfaEnrolledResponse>`
|
|
11316
11369
|
Confirm SMS-factor enrollment with the code sent by {@link enrollSmsMfa} (authenticated).
|
|
11317
11370
|
|
|
11371
|
+
**enrollTotpMfa**(clientId: string) → `Promise<MfaTotpEnrollResponse>`
|
|
11372
|
+
Begin authenticator-app enrollment (authenticated): a new secret for Google Authenticator, Microsoft Authenticator, 1Password and the like. Show `otpauthUri` as a QR code (and `secret` for typing in), then {@link confirmTotpMfa} with the code the app shows. Nothing is kept until then; setting up again replaces the previous app once confirmed.
|
|
11373
|
+
|
|
11374
|
+
**confirmTotpMfa**(clientId: string, mfaSessionToken: string, code: string) → `Promise<MfaEnrolledResponse>`
|
|
11375
|
+
Confirm authenticator-app enrollment with the 6-digit code the app shows (authenticated).
|
|
11376
|
+
|
|
11318
11377
|
**generateMfaRecoveryCodes**(clientId: string, password: string) → `Promise<`
|
|
11319
11378
|
Generate a fresh set of recovery codes, invalidating any previous set (authenticated). Returned **in plaintext, exactly once** — nothing else in the API ever returns them again, so the caller must display/export them immediately.
|
|
11320
11379
|
|
|
11321
|
-
**removeMfaFactor**(clientId: string, factor:
|
|
11380
|
+
**removeMfaFactor**(clientId: string, factor: MfaFactor, password: string) → `Promise<SuccessResponse>`
|
|
11322
11381
|
Remove an enrolled MFA factor (authenticated). Server route is DELETE with a body.
|
|
11323
11382
|
|
|
11324
11383
|
**listTrustedDevices**(clientId: string) → `Promise<`
|
|
@@ -11345,8 +11404,11 @@ Update an AuthKit client config (admin). This is how the account **security poli
|
|
|
11345
11404
|
**setIdentity**(collectionId: string, authKitId: string, body: { mode: 'own' }) → `Promise<AuthKitSetIdentityResponse>`
|
|
11346
11405
|
Give this AuthKit its **own logins** (admin): its members become accounts of this site only — the same email can be a separate account, with its own password, on another site — rather than SmartLinks accounts shared across sites. One way: a site with its own members can't go back to the shared pool. Members who signed up before keep their SmartLinks account until moved across. Errors: `MEMBER_POOL_CONFLICT` (409) when another AuthKit already gives one of its collections its own logins (one per collection); `PERMISSION_DENIED` (403) unless you administer every collection it serves.
|
|
11347
11406
|
|
|
11407
|
+
**invite**(collectionId: string, authKitId: string, body: AuthKitInviteRequest) → `Promise<AuthKitInviteResponse>`
|
|
11408
|
+
Invite someone to be a member of a site with its own logins (admin). Makes their account if they have none (the only way in when the site is invitation only — `signUp: 'invite'`), finds or creates their contact in this collection with the `customFields` you pass (their level), links the two, and emails them a sign-in link to the site (`redirectUrl`, default the kit's) that works once for 7 days. The page it opens handles it like any magic link: `mode=magicLink&token=…` → {@link verifyMagicLink}. Inviting someone again sends a fresh link. Errors: `OWN_LOGINS_REQUIRED` (409), `INVALID_EMAIL` (400), `INVALID_REDIRECT_URL` (400, not one of this site's addresses), `TOO_MANY_INVITES` (429, 5 an hour per address).
|
|
11409
|
+
|
|
11348
11410
|
**remove**(collectionId: string, authKitId: string) → `Promise<void>`
|
|
11349
|
-
|
|
11411
|
+
Invite someone to be a member of a site with its own logins (admin). Makes their account if they have none (the only way in when the site is invitation only — `signUp: 'invite'`), finds or creates their contact in this collection with the `customFields` you pass (their level), links the two, and emails them a sign-in link to the site (`redirectUrl`, default the kit's) that works once for 7 days. The page it opens handles it like any magic link: `mode=magicLink&token=…` → {@link verifyMagicLink}. Inviting someone again sends a fresh link. Errors: `OWN_LOGINS_REQUIRED` (409), `INVALID_EMAIL` (400), `INVALID_REDIRECT_URL` (400, not one of this site's addresses), `TOO_MANY_INVITES` (429, 5 an hour per address).
|
|
11350
11412
|
|
|
11351
11413
|
### batch
|
|
11352
11414
|
|