@proveanything/smartlinks 2.1.44 → 2.1.45
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/serviceAccounts.d.ts +18 -0
- package/dist/api/serviceAccounts.js +49 -0
- package/dist/docs/API_SUMMARY.md +77 -1
- package/dist/docs/overview.md +1 -0
- package/dist/docs/service-accounts.md +43 -0
- package/dist/openapi.yaml +82 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/serviceAccounts.d.ts +44 -0
- package/dist/types/serviceAccounts.js +2 -0
- package/docs/API_SUMMARY.md +77 -1
- package/docs/overview.md +1 -0
- package/docs/service-accounts.md +43 -0
- package/openapi.yaml +82 -0
- package/package.json +1 -1
package/dist/api/index.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ export { loyalty } from "./loyalty.js";
|
|
|
55
55
|
export { translations } from "./translations.js";
|
|
56
56
|
export { integrations } from "./integrations.js";
|
|
57
57
|
export { secrets } from "./secrets.js";
|
|
58
|
+
export { serviceAccounts } from "./serviceAccounts.js";
|
|
58
59
|
export { research } from "./research.js";
|
|
59
60
|
export { config } from "./config.js";
|
|
60
61
|
export { http } from "./http.js";
|
package/dist/api/index.js
CHANGED
|
@@ -58,6 +58,7 @@ export { loyalty } from "./loyalty.js";
|
|
|
58
58
|
export { translations } from "./translations.js";
|
|
59
59
|
export { integrations } from "./integrations.js";
|
|
60
60
|
export { secrets } from "./secrets.js";
|
|
61
|
+
export { serviceAccounts } from "./serviceAccounts.js";
|
|
61
62
|
export { research } from "./research.js";
|
|
62
63
|
export { config } from "./config.js";
|
|
63
64
|
export { http } from "./http.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ServiceAccount, ServiceAccountList, CreateServiceAccountInput, CreateServiceAccountResult, UpdateServiceAccountInput, ServiceAccountKeyResult } from "../types/serviceAccounts.js";
|
|
2
|
+
export declare namespace serviceAccounts {
|
|
3
|
+
/** The collection's service accounts (never their keys) and the access levels that can be given. GET /service-accounts */
|
|
4
|
+
function list(collectionId: string): Promise<ServiceAccountList>;
|
|
5
|
+
/**
|
|
6
|
+
* Make a service account → `{ serviceAccount, key }`. Show the key once — it can't be read again. You can't
|
|
7
|
+
* give it more access than you have. POST /service-accounts
|
|
8
|
+
*/
|
|
9
|
+
function create(collectionId: string, input: CreateServiceAccountInput): Promise<CreateServiceAccountResult>;
|
|
10
|
+
/** Rename it and/or change its access. PUT /service-accounts/:id */
|
|
11
|
+
function update(collectionId: string, id: string, input: UpdateServiceAccountInput): Promise<ServiceAccount>;
|
|
12
|
+
/** Give it a new key → `{ key }` (shown once); the old key stops working within a minute. POST /service-accounts/:id/key */
|
|
13
|
+
function newKey(collectionId: string, id: string): Promise<ServiceAccountKeyResult>;
|
|
14
|
+
/** Delete it: its key stops working and its access is removed. DELETE /service-accounts/:id */
|
|
15
|
+
function remove(collectionId: string, id: string): Promise<{
|
|
16
|
+
ok: true;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/api/serviceAccounts.ts
|
|
2
|
+
//
|
|
3
|
+
// A collection's service accounts: identities for the systems that work with it (an ERP, a warehouse
|
|
4
|
+
// system, an agency's integration), each with its own key and access level. A service account is a member of
|
|
5
|
+
// ONE collection, like a person on the team, and belongs to the collection — not to whoever made it — so it
|
|
6
|
+
// keeps working when people leave. Use its key as the bearer (`initializeApi({ bearerToken: key })` or an
|
|
7
|
+
// `Authorization: Bearer <key>` header); it can do what a person with the same access can on that collection
|
|
8
|
+
// only. It can't invite people, change anyone's access, make keys or other service accounts, make
|
|
9
|
+
// collections or hand the collection over.
|
|
10
|
+
//
|
|
11
|
+
// Managed by the collection's admins (Studio → Team → Service accounts). The key is shown ONCE, when the
|
|
12
|
+
// account is made or given a new key; only its hash is kept.
|
|
13
|
+
//
|
|
14
|
+
// Endpoints: /admin/collection/:collectionId/service-accounts
|
|
15
|
+
import { request, post, put, del } from "../http.js";
|
|
16
|
+
function enc(v) { return encodeURIComponent(v); }
|
|
17
|
+
export var serviceAccounts;
|
|
18
|
+
(function (serviceAccounts) {
|
|
19
|
+
const base = (collectionId) => `/admin/collection/${enc(collectionId)}/service-accounts`;
|
|
20
|
+
/** The collection's service accounts (never their keys) and the access levels that can be given. GET /service-accounts */
|
|
21
|
+
async function list(collectionId) {
|
|
22
|
+
return request(base(collectionId));
|
|
23
|
+
}
|
|
24
|
+
serviceAccounts.list = list;
|
|
25
|
+
/**
|
|
26
|
+
* Make a service account → `{ serviceAccount, key }`. Show the key once — it can't be read again. You can't
|
|
27
|
+
* give it more access than you have. POST /service-accounts
|
|
28
|
+
*/
|
|
29
|
+
async function create(collectionId, input) {
|
|
30
|
+
return post(base(collectionId), input);
|
|
31
|
+
}
|
|
32
|
+
serviceAccounts.create = create;
|
|
33
|
+
/** Rename it and/or change its access. PUT /service-accounts/:id */
|
|
34
|
+
async function update(collectionId, id, input) {
|
|
35
|
+
const out = await put(`${base(collectionId)}/${enc(id)}`, input);
|
|
36
|
+
return out.serviceAccount;
|
|
37
|
+
}
|
|
38
|
+
serviceAccounts.update = update;
|
|
39
|
+
/** Give it a new key → `{ key }` (shown once); the old key stops working within a minute. POST /service-accounts/:id/key */
|
|
40
|
+
async function newKey(collectionId, id) {
|
|
41
|
+
return post(`${base(collectionId)}/${enc(id)}/key`, {});
|
|
42
|
+
}
|
|
43
|
+
serviceAccounts.newKey = newKey;
|
|
44
|
+
/** Delete it: its key stops working and its access is removed. DELETE /service-accounts/:id */
|
|
45
|
+
async function remove(collectionId, id) {
|
|
46
|
+
return del(`${base(collectionId)}/${enc(id)}`);
|
|
47
|
+
}
|
|
48
|
+
serviceAccounts.remove = remove;
|
|
49
|
+
})(serviceAccounts || (serviceAccounts = {}));
|
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.45 | Generated: 2026-11-23T13:14:33.772Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -168,6 +168,7 @@ The Smartlinks SDK is organized into the following namespaces:
|
|
|
168
168
|
- **realtime** - Functions for realtime operations
|
|
169
169
|
- **research** - Functions for research operations
|
|
170
170
|
- **secrets** - Functions for secrets operations
|
|
171
|
+
- **serviceAccounts** - Functions for serviceAccounts operations
|
|
171
172
|
- **shop** - Functions for shop operations
|
|
172
173
|
- **subscriptions** - Functions for subscriptions operations
|
|
173
174
|
- **tagCodes** - Functions for tagCodes operations
|
|
@@ -11949,6 +11950,64 @@ interface SegmentRecipientsResponse {
|
|
|
11949
11950
|
|
|
11950
11951
|
**SegmentFilterRule** = ``
|
|
11951
11952
|
|
|
11953
|
+
### serviceAccounts
|
|
11954
|
+
|
|
11955
|
+
**ServiceAccount** (interface)
|
|
11956
|
+
```typescript
|
|
11957
|
+
interface ServiceAccount {
|
|
11958
|
+
id: string
|
|
11959
|
+
name: string
|
|
11960
|
+
access: ServiceAccountAccess | null
|
|
11961
|
+
active: boolean
|
|
11962
|
+
createdAt: string
|
|
11963
|
+
createdBy: string | null
|
|
11964
|
+
lastUsedAt: string | null
|
|
11965
|
+
keyCreatedAt: string
|
|
11966
|
+
keyHint: string
|
|
11967
|
+
}
|
|
11968
|
+
```
|
|
11969
|
+
|
|
11970
|
+
**ServiceAccountList** (interface)
|
|
11971
|
+
```typescript
|
|
11972
|
+
interface ServiceAccountList {
|
|
11973
|
+
serviceAccounts: ServiceAccount[]
|
|
11974
|
+
access: ServiceAccountAccess[]
|
|
11975
|
+
}
|
|
11976
|
+
```
|
|
11977
|
+
|
|
11978
|
+
**CreateServiceAccountInput** (interface)
|
|
11979
|
+
```typescript
|
|
11980
|
+
interface CreateServiceAccountInput {
|
|
11981
|
+
name: string
|
|
11982
|
+
access: ServiceAccountAccess
|
|
11983
|
+
}
|
|
11984
|
+
```
|
|
11985
|
+
|
|
11986
|
+
**UpdateServiceAccountInput** (interface)
|
|
11987
|
+
```typescript
|
|
11988
|
+
interface UpdateServiceAccountInput {
|
|
11989
|
+
name?: string
|
|
11990
|
+
access?: ServiceAccountAccess
|
|
11991
|
+
}
|
|
11992
|
+
```
|
|
11993
|
+
|
|
11994
|
+
**CreateServiceAccountResult** (interface)
|
|
11995
|
+
```typescript
|
|
11996
|
+
interface CreateServiceAccountResult {
|
|
11997
|
+
serviceAccount: ServiceAccount
|
|
11998
|
+
key: string
|
|
11999
|
+
}
|
|
12000
|
+
```
|
|
12001
|
+
|
|
12002
|
+
**ServiceAccountKeyResult** (interface)
|
|
12003
|
+
```typescript
|
|
12004
|
+
interface ServiceAccountKeyResult {
|
|
12005
|
+
key: string
|
|
12006
|
+
}
|
|
12007
|
+
```
|
|
12008
|
+
|
|
12009
|
+
**ServiceAccountAccess** = `"User" | "Reporter" | "Assigner" | "Admin"`
|
|
12010
|
+
|
|
11952
12011
|
### shop
|
|
11953
12012
|
|
|
11954
12013
|
**ShopPrice** (interface)
|
|
@@ -16211,6 +16270,23 @@ Soft-delete a secret. DELETE /secrets/:ref
|
|
|
16211
16270
|
id: string,
|
|
16212
16271
|
query: { limit?: number; offset?: number } = {}) → `Promise<SegmentRecipientsResponse>`
|
|
16213
16272
|
|
|
16273
|
+
### serviceAccounts
|
|
16274
|
+
|
|
16275
|
+
**list**(collectionId: string) → `Promise<ServiceAccountList>`
|
|
16276
|
+
The collection's service accounts (never their keys) and the access levels that can be given. GET /service-accounts
|
|
16277
|
+
|
|
16278
|
+
**create**(collectionId: string, input: CreateServiceAccountInput) → `Promise<CreateServiceAccountResult>`
|
|
16279
|
+
Make a service account → `{ serviceAccount, key }`. Show the key once — it can't be read again. You can't give it more access than you have. POST /service-accounts
|
|
16280
|
+
|
|
16281
|
+
**update**(collectionId: string, id: string, input: UpdateServiceAccountInput) → `Promise<ServiceAccount>`
|
|
16282
|
+
Rename it and/or change its access. PUT /service-accounts/:id
|
|
16283
|
+
|
|
16284
|
+
**newKey**(collectionId: string, id: string) → `Promise<ServiceAccountKeyResult>`
|
|
16285
|
+
Give it a new key → `{ key }` (shown once); the old key stops working within a minute. POST /service-accounts/:id/key
|
|
16286
|
+
|
|
16287
|
+
**remove**(collectionId: string, id: string) → `Promise<`
|
|
16288
|
+
Delete it: its key stops working and its access is removed. DELETE /service-accounts/:id
|
|
16289
|
+
|
|
16214
16290
|
### sessions
|
|
16215
16291
|
|
|
16216
16292
|
**stats**(collectionId: string) → `Promise<SessionStatistics>`
|
package/dist/docs/overview.md
CHANGED
|
@@ -78,6 +78,7 @@ The SmartLinks SDK (`@proveanything/smartlinks`) includes comprehensive document
|
|
|
78
78
|
| **AI Guide Template** | `docs/ai-guide-template.md` | Template for creating `public/ai-guide.md` — customise per app |
|
|
79
79
|
| **Forms** | `docs/forms.md` | Form definitions, schema-driven rendering, submission patterns |
|
|
80
80
|
| **Auth Kit** | `docs/auth-kit.md` | End-user sign-in: email/password, magic links, phone OTP, Google OAuth |
|
|
81
|
+
| **Service accounts** | `docs/service-accounts.md` | Identities for other systems (an ERP, a warehouse system) to work with one collection: own key, own access level, made and removed by the collection's admins |
|
|
81
82
|
| **Members** | `docs/members.md` | Signed-in members with a level (clubs, leagues, members' areas): the level field, members-only functions, joining rules |
|
|
82
83
|
| **Portal Request Login** | `docs/portal-request-login.md` | How sub-apps ask the portal to authenticate the user; hook and iframe postMessage contracts |
|
|
83
84
|
| **Portal Auth Broadcast** | `docs/portal-auth-broadcast.md` | Publishing custom auth flows to the portal; syncing sessions across containers and iframes |
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Service accounts
|
|
2
|
+
|
|
3
|
+
A **service account** is how another system works with a collection: an ERP sending stock levels, a
|
|
4
|
+
warehouse system recording shipments, an agency's integration. It's an identity of its own, with its own key
|
|
5
|
+
and access level. It is **not** a person's API key.
|
|
6
|
+
|
|
7
|
+
- It's a member of **one** collection with an access level (`User`, `Reporter`, `Assigner` or `Admin`), just
|
|
8
|
+
like a person on the team. Everything a person with that access can do on that collection, it can do.
|
|
9
|
+
It can reach nothing else.
|
|
10
|
+
- It belongs to the collection, not to whoever made it, so it keeps working when people leave the team.
|
|
11
|
+
- Its key (`slsvc_<id>.<secret>`) is shown **once**, when it's made or given a new key. Only a hash is kept.
|
|
12
|
+
- It **can't** invite people or change anyone's access. It can't make API keys or other service accounts,
|
|
13
|
+
make collections, or hand the collection over. A leaked key can't leave a way back in once it's deleted.
|
|
14
|
+
|
|
15
|
+
Collection admins manage them in **Studio → Team → Service accounts**, or with `serviceAccounts.*`:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { serviceAccounts } from "@proveanything/smartlinks"
|
|
19
|
+
|
|
20
|
+
// Make one: show the key once, then it's gone.
|
|
21
|
+
const { serviceAccount, key } = await serviceAccounts.create(collectionId, { name: "Warehouse system", access: "Assigner" })
|
|
22
|
+
|
|
23
|
+
await serviceAccounts.list(collectionId) // { serviceAccounts: [...], access: ["User", "Reporter", "Assigner", "Admin"] }
|
|
24
|
+
await serviceAccounts.update(collectionId, serviceAccount.id, { access: "Reporter" })
|
|
25
|
+
const { key: replacement } = await serviceAccounts.newKey(collectionId, serviceAccount.id) // the old key stops within a minute
|
|
26
|
+
await serviceAccounts.remove(collectionId, serviceAccount.id) // key stops, access removed
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
You can't give a service account more access than you have yourself, and never `Owner`.
|
|
30
|
+
|
|
31
|
+
## Using the key
|
|
32
|
+
|
|
33
|
+
The other system sends the key as its bearer token:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { initializeApi } from "@proveanything/smartlinks"
|
|
37
|
+
initializeApi({ baseURL: "https://smartlinks.app/api/v1", bearerToken: process.env.SMARTLINKS_KEY })
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
or, without the SDK, `Authorization: Bearer slsvc_…` on each request. Keep it in a secret store. To retire
|
|
41
|
+
a key, give the account a new one; delete the account when the system no longer needs it.
|
|
42
|
+
|
|
43
|
+
A list shows `lastUsedAt` (to within a few minutes) so you can see which accounts are still in use.
|
package/dist/openapi.yaml
CHANGED
|
@@ -36981,6 +36981,88 @@ components:
|
|
|
36981
36981
|
SegmentFilterRule:
|
|
36982
36982
|
type: object
|
|
36983
36983
|
additionalProperties: true
|
|
36984
|
+
ServiceAccount:
|
|
36985
|
+
type: object
|
|
36986
|
+
properties:
|
|
36987
|
+
id:
|
|
36988
|
+
type: string
|
|
36989
|
+
name:
|
|
36990
|
+
type: string
|
|
36991
|
+
access:
|
|
36992
|
+
$ref: "#/components/schemas/ServiceAccountAccess"
|
|
36993
|
+
active:
|
|
36994
|
+
type: boolean
|
|
36995
|
+
createdAt:
|
|
36996
|
+
type: string
|
|
36997
|
+
createdBy:
|
|
36998
|
+
type: string
|
|
36999
|
+
lastUsedAt:
|
|
37000
|
+
type: string
|
|
37001
|
+
keyCreatedAt:
|
|
37002
|
+
type: string
|
|
37003
|
+
keyHint:
|
|
37004
|
+
type: string
|
|
37005
|
+
required:
|
|
37006
|
+
- id
|
|
37007
|
+
- name
|
|
37008
|
+
- access
|
|
37009
|
+
- active
|
|
37010
|
+
- createdAt
|
|
37011
|
+
- createdBy
|
|
37012
|
+
- lastUsedAt
|
|
37013
|
+
- keyCreatedAt
|
|
37014
|
+
- keyHint
|
|
37015
|
+
ServiceAccountList:
|
|
37016
|
+
type: object
|
|
37017
|
+
properties:
|
|
37018
|
+
serviceAccounts:
|
|
37019
|
+
type: array
|
|
37020
|
+
items:
|
|
37021
|
+
$ref: "#/components/schemas/ServiceAccount"
|
|
37022
|
+
access:
|
|
37023
|
+
type: array
|
|
37024
|
+
items:
|
|
37025
|
+
$ref: "#/components/schemas/ServiceAccountAccess"
|
|
37026
|
+
required:
|
|
37027
|
+
- serviceAccounts
|
|
37028
|
+
- access
|
|
37029
|
+
CreateServiceAccountInput:
|
|
37030
|
+
type: object
|
|
37031
|
+
properties:
|
|
37032
|
+
name:
|
|
37033
|
+
type: string
|
|
37034
|
+
access:
|
|
37035
|
+
$ref: "#/components/schemas/ServiceAccountAccess"
|
|
37036
|
+
required:
|
|
37037
|
+
- name
|
|
37038
|
+
- access
|
|
37039
|
+
UpdateServiceAccountInput:
|
|
37040
|
+
type: object
|
|
37041
|
+
properties:
|
|
37042
|
+
name:
|
|
37043
|
+
type: string
|
|
37044
|
+
access:
|
|
37045
|
+
$ref: "#/components/schemas/ServiceAccountAccess"
|
|
37046
|
+
CreateServiceAccountResult:
|
|
37047
|
+
type: object
|
|
37048
|
+
properties:
|
|
37049
|
+
serviceAccount:
|
|
37050
|
+
$ref: "#/components/schemas/ServiceAccount"
|
|
37051
|
+
key:
|
|
37052
|
+
type: string
|
|
37053
|
+
required:
|
|
37054
|
+
- serviceAccount
|
|
37055
|
+
- key
|
|
37056
|
+
ServiceAccountKeyResult:
|
|
37057
|
+
type: object
|
|
37058
|
+
properties:
|
|
37059
|
+
key:
|
|
37060
|
+
type: string
|
|
37061
|
+
required:
|
|
37062
|
+
- key
|
|
37063
|
+
ServiceAccountAccess:
|
|
37064
|
+
type: object
|
|
37065
|
+
additionalProperties: true
|
|
36984
37066
|
ShopPrice:
|
|
36985
37067
|
type: object
|
|
36986
37068
|
properties:
|
package/dist/types/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from "./contact.js";
|
|
|
16
16
|
export * from "./broadcasts.js";
|
|
17
17
|
export * from "./segments.js";
|
|
18
18
|
export * from "./userGroups.js";
|
|
19
|
+
export * from "./serviceAccounts.js";
|
|
19
20
|
export * from "./operations.js";
|
|
20
21
|
export * from "./common.js";
|
|
21
22
|
export * from "./query.js";
|
package/dist/types/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./contact.js";
|
|
|
18
18
|
export * from "./broadcasts.js";
|
|
19
19
|
export * from "./segments.js";
|
|
20
20
|
export * from "./userGroups.js";
|
|
21
|
+
export * from "./serviceAccounts.js";
|
|
21
22
|
export * from "./operations.js";
|
|
22
23
|
export * from "./common.js";
|
|
23
24
|
export * from "./query.js";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** The access a service account can have on its collection (never Owner). */
|
|
2
|
+
export type ServiceAccountAccess = "User" | "Reporter" | "Assigner" | "Admin";
|
|
3
|
+
/** One of a collection's service accounts. The key itself is never listed (only shown when made or replaced). */
|
|
4
|
+
export interface ServiceAccount {
|
|
5
|
+
/** e.g. "sa-3f9c0a1b2d4e"; its user id on the collection is "svc:" + id. */
|
|
6
|
+
id: string;
|
|
7
|
+
/** What uses it, e.g. "Warehouse system". */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Its access on the collection (null if it was removed from the collection's members another way). */
|
|
10
|
+
access: ServiceAccountAccess | null;
|
|
11
|
+
/** false once its key has been switched off. */
|
|
12
|
+
active: boolean;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
/** The user id of the person who made it. */
|
|
15
|
+
createdBy: string | null;
|
|
16
|
+
/** When its key was last used (to within a few minutes), or null if never. */
|
|
17
|
+
lastUsedAt: string | null;
|
|
18
|
+
/** When its current key was made. */
|
|
19
|
+
keyCreatedAt: string;
|
|
20
|
+
/** How its key starts ("slsvc_sa-….…"), to recognise it — never the secret. */
|
|
21
|
+
keyHint: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ServiceAccountList {
|
|
24
|
+
serviceAccounts: ServiceAccount[];
|
|
25
|
+
/** The access levels that can be given. */
|
|
26
|
+
access: ServiceAccountAccess[];
|
|
27
|
+
}
|
|
28
|
+
export interface CreateServiceAccountInput {
|
|
29
|
+
name: string;
|
|
30
|
+
access: ServiceAccountAccess;
|
|
31
|
+
}
|
|
32
|
+
export interface UpdateServiceAccountInput {
|
|
33
|
+
name?: string;
|
|
34
|
+
access?: ServiceAccountAccess;
|
|
35
|
+
}
|
|
36
|
+
/** A new service account and its key. Show the key once: it can't be read again (make a new one instead). */
|
|
37
|
+
export interface CreateServiceAccountResult {
|
|
38
|
+
serviceAccount: ServiceAccount;
|
|
39
|
+
key: string;
|
|
40
|
+
}
|
|
41
|
+
/** A replacement key; the old one stops working (within a minute everywhere). */
|
|
42
|
+
export interface ServiceAccountKeyResult {
|
|
43
|
+
key: string;
|
|
44
|
+
}
|
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.45 | Generated: 2026-11-23T13:14:33.772Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -168,6 +168,7 @@ The Smartlinks SDK is organized into the following namespaces:
|
|
|
168
168
|
- **realtime** - Functions for realtime operations
|
|
169
169
|
- **research** - Functions for research operations
|
|
170
170
|
- **secrets** - Functions for secrets operations
|
|
171
|
+
- **serviceAccounts** - Functions for serviceAccounts operations
|
|
171
172
|
- **shop** - Functions for shop operations
|
|
172
173
|
- **subscriptions** - Functions for subscriptions operations
|
|
173
174
|
- **tagCodes** - Functions for tagCodes operations
|
|
@@ -11949,6 +11950,64 @@ interface SegmentRecipientsResponse {
|
|
|
11949
11950
|
|
|
11950
11951
|
**SegmentFilterRule** = ``
|
|
11951
11952
|
|
|
11953
|
+
### serviceAccounts
|
|
11954
|
+
|
|
11955
|
+
**ServiceAccount** (interface)
|
|
11956
|
+
```typescript
|
|
11957
|
+
interface ServiceAccount {
|
|
11958
|
+
id: string
|
|
11959
|
+
name: string
|
|
11960
|
+
access: ServiceAccountAccess | null
|
|
11961
|
+
active: boolean
|
|
11962
|
+
createdAt: string
|
|
11963
|
+
createdBy: string | null
|
|
11964
|
+
lastUsedAt: string | null
|
|
11965
|
+
keyCreatedAt: string
|
|
11966
|
+
keyHint: string
|
|
11967
|
+
}
|
|
11968
|
+
```
|
|
11969
|
+
|
|
11970
|
+
**ServiceAccountList** (interface)
|
|
11971
|
+
```typescript
|
|
11972
|
+
interface ServiceAccountList {
|
|
11973
|
+
serviceAccounts: ServiceAccount[]
|
|
11974
|
+
access: ServiceAccountAccess[]
|
|
11975
|
+
}
|
|
11976
|
+
```
|
|
11977
|
+
|
|
11978
|
+
**CreateServiceAccountInput** (interface)
|
|
11979
|
+
```typescript
|
|
11980
|
+
interface CreateServiceAccountInput {
|
|
11981
|
+
name: string
|
|
11982
|
+
access: ServiceAccountAccess
|
|
11983
|
+
}
|
|
11984
|
+
```
|
|
11985
|
+
|
|
11986
|
+
**UpdateServiceAccountInput** (interface)
|
|
11987
|
+
```typescript
|
|
11988
|
+
interface UpdateServiceAccountInput {
|
|
11989
|
+
name?: string
|
|
11990
|
+
access?: ServiceAccountAccess
|
|
11991
|
+
}
|
|
11992
|
+
```
|
|
11993
|
+
|
|
11994
|
+
**CreateServiceAccountResult** (interface)
|
|
11995
|
+
```typescript
|
|
11996
|
+
interface CreateServiceAccountResult {
|
|
11997
|
+
serviceAccount: ServiceAccount
|
|
11998
|
+
key: string
|
|
11999
|
+
}
|
|
12000
|
+
```
|
|
12001
|
+
|
|
12002
|
+
**ServiceAccountKeyResult** (interface)
|
|
12003
|
+
```typescript
|
|
12004
|
+
interface ServiceAccountKeyResult {
|
|
12005
|
+
key: string
|
|
12006
|
+
}
|
|
12007
|
+
```
|
|
12008
|
+
|
|
12009
|
+
**ServiceAccountAccess** = `"User" | "Reporter" | "Assigner" | "Admin"`
|
|
12010
|
+
|
|
11952
12011
|
### shop
|
|
11953
12012
|
|
|
11954
12013
|
**ShopPrice** (interface)
|
|
@@ -16211,6 +16270,23 @@ Soft-delete a secret. DELETE /secrets/:ref
|
|
|
16211
16270
|
id: string,
|
|
16212
16271
|
query: { limit?: number; offset?: number } = {}) → `Promise<SegmentRecipientsResponse>`
|
|
16213
16272
|
|
|
16273
|
+
### serviceAccounts
|
|
16274
|
+
|
|
16275
|
+
**list**(collectionId: string) → `Promise<ServiceAccountList>`
|
|
16276
|
+
The collection's service accounts (never their keys) and the access levels that can be given. GET /service-accounts
|
|
16277
|
+
|
|
16278
|
+
**create**(collectionId: string, input: CreateServiceAccountInput) → `Promise<CreateServiceAccountResult>`
|
|
16279
|
+
Make a service account → `{ serviceAccount, key }`. Show the key once — it can't be read again. You can't give it more access than you have. POST /service-accounts
|
|
16280
|
+
|
|
16281
|
+
**update**(collectionId: string, id: string, input: UpdateServiceAccountInput) → `Promise<ServiceAccount>`
|
|
16282
|
+
Rename it and/or change its access. PUT /service-accounts/:id
|
|
16283
|
+
|
|
16284
|
+
**newKey**(collectionId: string, id: string) → `Promise<ServiceAccountKeyResult>`
|
|
16285
|
+
Give it a new key → `{ key }` (shown once); the old key stops working within a minute. POST /service-accounts/:id/key
|
|
16286
|
+
|
|
16287
|
+
**remove**(collectionId: string, id: string) → `Promise<`
|
|
16288
|
+
Delete it: its key stops working and its access is removed. DELETE /service-accounts/:id
|
|
16289
|
+
|
|
16214
16290
|
### sessions
|
|
16215
16291
|
|
|
16216
16292
|
**stats**(collectionId: string) → `Promise<SessionStatistics>`
|
package/docs/overview.md
CHANGED
|
@@ -78,6 +78,7 @@ The SmartLinks SDK (`@proveanything/smartlinks`) includes comprehensive document
|
|
|
78
78
|
| **AI Guide Template** | `docs/ai-guide-template.md` | Template for creating `public/ai-guide.md` — customise per app |
|
|
79
79
|
| **Forms** | `docs/forms.md` | Form definitions, schema-driven rendering, submission patterns |
|
|
80
80
|
| **Auth Kit** | `docs/auth-kit.md` | End-user sign-in: email/password, magic links, phone OTP, Google OAuth |
|
|
81
|
+
| **Service accounts** | `docs/service-accounts.md` | Identities for other systems (an ERP, a warehouse system) to work with one collection: own key, own access level, made and removed by the collection's admins |
|
|
81
82
|
| **Members** | `docs/members.md` | Signed-in members with a level (clubs, leagues, members' areas): the level field, members-only functions, joining rules |
|
|
82
83
|
| **Portal Request Login** | `docs/portal-request-login.md` | How sub-apps ask the portal to authenticate the user; hook and iframe postMessage contracts |
|
|
83
84
|
| **Portal Auth Broadcast** | `docs/portal-auth-broadcast.md` | Publishing custom auth flows to the portal; syncing sessions across containers and iframes |
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Service accounts
|
|
2
|
+
|
|
3
|
+
A **service account** is how another system works with a collection: an ERP sending stock levels, a
|
|
4
|
+
warehouse system recording shipments, an agency's integration. It's an identity of its own, with its own key
|
|
5
|
+
and access level. It is **not** a person's API key.
|
|
6
|
+
|
|
7
|
+
- It's a member of **one** collection with an access level (`User`, `Reporter`, `Assigner` or `Admin`), just
|
|
8
|
+
like a person on the team. Everything a person with that access can do on that collection, it can do.
|
|
9
|
+
It can reach nothing else.
|
|
10
|
+
- It belongs to the collection, not to whoever made it, so it keeps working when people leave the team.
|
|
11
|
+
- Its key (`slsvc_<id>.<secret>`) is shown **once**, when it's made or given a new key. Only a hash is kept.
|
|
12
|
+
- It **can't** invite people or change anyone's access. It can't make API keys or other service accounts,
|
|
13
|
+
make collections, or hand the collection over. A leaked key can't leave a way back in once it's deleted.
|
|
14
|
+
|
|
15
|
+
Collection admins manage them in **Studio → Team → Service accounts**, or with `serviceAccounts.*`:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { serviceAccounts } from "@proveanything/smartlinks"
|
|
19
|
+
|
|
20
|
+
// Make one: show the key once, then it's gone.
|
|
21
|
+
const { serviceAccount, key } = await serviceAccounts.create(collectionId, { name: "Warehouse system", access: "Assigner" })
|
|
22
|
+
|
|
23
|
+
await serviceAccounts.list(collectionId) // { serviceAccounts: [...], access: ["User", "Reporter", "Assigner", "Admin"] }
|
|
24
|
+
await serviceAccounts.update(collectionId, serviceAccount.id, { access: "Reporter" })
|
|
25
|
+
const { key: replacement } = await serviceAccounts.newKey(collectionId, serviceAccount.id) // the old key stops within a minute
|
|
26
|
+
await serviceAccounts.remove(collectionId, serviceAccount.id) // key stops, access removed
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
You can't give a service account more access than you have yourself, and never `Owner`.
|
|
30
|
+
|
|
31
|
+
## Using the key
|
|
32
|
+
|
|
33
|
+
The other system sends the key as its bearer token:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { initializeApi } from "@proveanything/smartlinks"
|
|
37
|
+
initializeApi({ baseURL: "https://smartlinks.app/api/v1", bearerToken: process.env.SMARTLINKS_KEY })
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
or, without the SDK, `Authorization: Bearer slsvc_…` on each request. Keep it in a secret store. To retire
|
|
41
|
+
a key, give the account a new one; delete the account when the system no longer needs it.
|
|
42
|
+
|
|
43
|
+
A list shows `lastUsedAt` (to within a few minutes) so you can see which accounts are still in use.
|
package/openapi.yaml
CHANGED
|
@@ -36981,6 +36981,88 @@ components:
|
|
|
36981
36981
|
SegmentFilterRule:
|
|
36982
36982
|
type: object
|
|
36983
36983
|
additionalProperties: true
|
|
36984
|
+
ServiceAccount:
|
|
36985
|
+
type: object
|
|
36986
|
+
properties:
|
|
36987
|
+
id:
|
|
36988
|
+
type: string
|
|
36989
|
+
name:
|
|
36990
|
+
type: string
|
|
36991
|
+
access:
|
|
36992
|
+
$ref: "#/components/schemas/ServiceAccountAccess"
|
|
36993
|
+
active:
|
|
36994
|
+
type: boolean
|
|
36995
|
+
createdAt:
|
|
36996
|
+
type: string
|
|
36997
|
+
createdBy:
|
|
36998
|
+
type: string
|
|
36999
|
+
lastUsedAt:
|
|
37000
|
+
type: string
|
|
37001
|
+
keyCreatedAt:
|
|
37002
|
+
type: string
|
|
37003
|
+
keyHint:
|
|
37004
|
+
type: string
|
|
37005
|
+
required:
|
|
37006
|
+
- id
|
|
37007
|
+
- name
|
|
37008
|
+
- access
|
|
37009
|
+
- active
|
|
37010
|
+
- createdAt
|
|
37011
|
+
- createdBy
|
|
37012
|
+
- lastUsedAt
|
|
37013
|
+
- keyCreatedAt
|
|
37014
|
+
- keyHint
|
|
37015
|
+
ServiceAccountList:
|
|
37016
|
+
type: object
|
|
37017
|
+
properties:
|
|
37018
|
+
serviceAccounts:
|
|
37019
|
+
type: array
|
|
37020
|
+
items:
|
|
37021
|
+
$ref: "#/components/schemas/ServiceAccount"
|
|
37022
|
+
access:
|
|
37023
|
+
type: array
|
|
37024
|
+
items:
|
|
37025
|
+
$ref: "#/components/schemas/ServiceAccountAccess"
|
|
37026
|
+
required:
|
|
37027
|
+
- serviceAccounts
|
|
37028
|
+
- access
|
|
37029
|
+
CreateServiceAccountInput:
|
|
37030
|
+
type: object
|
|
37031
|
+
properties:
|
|
37032
|
+
name:
|
|
37033
|
+
type: string
|
|
37034
|
+
access:
|
|
37035
|
+
$ref: "#/components/schemas/ServiceAccountAccess"
|
|
37036
|
+
required:
|
|
37037
|
+
- name
|
|
37038
|
+
- access
|
|
37039
|
+
UpdateServiceAccountInput:
|
|
37040
|
+
type: object
|
|
37041
|
+
properties:
|
|
37042
|
+
name:
|
|
37043
|
+
type: string
|
|
37044
|
+
access:
|
|
37045
|
+
$ref: "#/components/schemas/ServiceAccountAccess"
|
|
37046
|
+
CreateServiceAccountResult:
|
|
37047
|
+
type: object
|
|
37048
|
+
properties:
|
|
37049
|
+
serviceAccount:
|
|
37050
|
+
$ref: "#/components/schemas/ServiceAccount"
|
|
37051
|
+
key:
|
|
37052
|
+
type: string
|
|
37053
|
+
required:
|
|
37054
|
+
- serviceAccount
|
|
37055
|
+
- key
|
|
37056
|
+
ServiceAccountKeyResult:
|
|
37057
|
+
type: object
|
|
37058
|
+
properties:
|
|
37059
|
+
key:
|
|
37060
|
+
type: string
|
|
37061
|
+
required:
|
|
37062
|
+
- key
|
|
37063
|
+
ServiceAccountAccess:
|
|
37064
|
+
type: object
|
|
37065
|
+
additionalProperties: true
|
|
36984
37066
|
ShopPrice:
|
|
36985
37067
|
type: object
|
|
36986
37068
|
properties:
|