@proveanything/smartlinks 2.1.45 → 2.1.46
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/serviceAccounts.d.ts +22 -5
- package/dist/api/serviceAccounts.js +35 -8
- package/dist/docs/API_SUMMARY.md +31 -5
- package/dist/docs/service-accounts.md +25 -4
- package/dist/openapi.yaml +33 -0
- package/dist/types/serviceAccounts.d.ts +24 -1
- package/docs/API_SUMMARY.md +31 -5
- package/docs/service-accounts.md +25 -4
- package/openapi.yaml +33 -0
- package/package.json +1 -1
|
@@ -1,17 +1,34 @@
|
|
|
1
|
-
import type { ServiceAccount, ServiceAccountList, CreateServiceAccountInput, CreateServiceAccountResult, UpdateServiceAccountInput, ServiceAccountKeyResult } from "../types/serviceAccounts.js";
|
|
1
|
+
import type { ServiceAccount, ServiceAccountList, CreateServiceAccountInput, CreateServiceAccountResult, UpdateServiceAccountInput, ServiceAccountKeyResult, AddServiceAccountToCollectionInput } from "../types/serviceAccounts.js";
|
|
2
2
|
export declare namespace serviceAccounts {
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* The service accounts that work on this collection — its own (`home: true`, with `alsoOn`) and other
|
|
5
|
+
* collections' (`home: false`, with `homeCollection`) — never their keys, and the access levels that can be
|
|
6
|
+
* given. GET /service-accounts
|
|
7
|
+
*/
|
|
4
8
|
function list(collectionId: string): Promise<ServiceAccountList>;
|
|
5
9
|
/**
|
|
6
10
|
* Make a service account → `{ serviceAccount, key }`. Show the key once — it can't be read again. You can't
|
|
7
11
|
* give it more access than you have. POST /service-accounts
|
|
8
12
|
*/
|
|
9
13
|
function create(collectionId: string, input: CreateServiceAccountInput): Promise<CreateServiceAccountResult>;
|
|
10
|
-
/** Rename it and/or change its access. PUT /service-accounts/:id */
|
|
14
|
+
/** Rename it (home collection only) and/or change its access on this collection. PUT /service-accounts/:id */
|
|
11
15
|
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 */
|
|
16
|
+
/** Give it a new key → `{ key }` (shown once; home collection only); the old key stops working within a minute. POST /service-accounts/:id/key */
|
|
13
17
|
function newKey(collectionId: string, id: string): Promise<ServiceAccountKeyResult>;
|
|
14
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Let it work on another collection too, or change its access there. Call on its home collection; you must
|
|
20
|
+
* be an admin of `input.collectionId` as well, and can't give more access than you have there.
|
|
21
|
+
* POST /service-accounts/:id/collections
|
|
22
|
+
*/
|
|
23
|
+
function addTo(collectionId: string, id: string, input: AddServiceAccountToCollectionInput): Promise<ServiceAccount>;
|
|
24
|
+
/** Stop it working on `otherCollectionId` (call on its home collection). DELETE /service-accounts/:id/collections/:otherId */
|
|
25
|
+
function removeFrom(collectionId: string, id: string, otherCollectionId: string): Promise<{
|
|
26
|
+
ok: true;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* On its home collection: delete it — its key stops working and its access is removed everywhere. On another
|
|
30
|
+
* collection it works on: remove it from that collection only. DELETE /service-accounts/:id
|
|
31
|
+
*/
|
|
15
32
|
function remove(collectionId: string, id: string): Promise<{
|
|
16
33
|
ok: true;
|
|
17
34
|
}>;
|
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
//
|
|
3
3
|
// A collection's service accounts: identities for the systems that work with it (an ERP, a warehouse
|
|
4
4
|
// system, an agency's integration), each with its own key and access level. A service account is a member of
|
|
5
|
-
//
|
|
6
|
-
//
|
|
5
|
+
// its HOME collection, like a person on the team, and optionally of other collections too ("also works on"),
|
|
6
|
+
// each with its own access. It belongs to its home collection — not to whoever made it — so it keeps working
|
|
7
|
+
// when people leave. (A personal API key is different: it IS its person, with everything they can do.) Use its key as the bearer (`initializeApi({ bearerToken: key })` or an
|
|
7
8
|
// `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
|
|
9
|
+
// it works on only. It can't invite people, change anyone's access, make keys or other service accounts, make
|
|
10
|
+
// collections or hand a collection over.
|
|
11
|
+
//
|
|
12
|
+
// Only the home collection renames it, gives it a new key, deletes it (everywhere) or adds it to another
|
|
13
|
+
// collection — and adding needs you to be an admin of that collection too. A collection it also works on can
|
|
14
|
+
// change its access there or remove it from there.
|
|
10
15
|
//
|
|
11
16
|
// Managed by the collection's admins (Studio → Team → Service accounts). The key is shown ONCE, when the
|
|
12
17
|
// account is made or given a new key; only its hash is kept.
|
|
@@ -17,7 +22,11 @@ function enc(v) { return encodeURIComponent(v); }
|
|
|
17
22
|
export var serviceAccounts;
|
|
18
23
|
(function (serviceAccounts) {
|
|
19
24
|
const base = (collectionId) => `/admin/collection/${enc(collectionId)}/service-accounts`;
|
|
20
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* The service accounts that work on this collection — its own (`home: true`, with `alsoOn`) and other
|
|
27
|
+
* collections' (`home: false`, with `homeCollection`) — never their keys, and the access levels that can be
|
|
28
|
+
* given. GET /service-accounts
|
|
29
|
+
*/
|
|
21
30
|
async function list(collectionId) {
|
|
22
31
|
return request(base(collectionId));
|
|
23
32
|
}
|
|
@@ -30,18 +39,36 @@ export var serviceAccounts;
|
|
|
30
39
|
return post(base(collectionId), input);
|
|
31
40
|
}
|
|
32
41
|
serviceAccounts.create = create;
|
|
33
|
-
/** Rename it and/or change its access. PUT /service-accounts/:id */
|
|
42
|
+
/** Rename it (home collection only) and/or change its access on this collection. PUT /service-accounts/:id */
|
|
34
43
|
async function update(collectionId, id, input) {
|
|
35
44
|
const out = await put(`${base(collectionId)}/${enc(id)}`, input);
|
|
36
45
|
return out.serviceAccount;
|
|
37
46
|
}
|
|
38
47
|
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 */
|
|
48
|
+
/** Give it a new key → `{ key }` (shown once; home collection only); the old key stops working within a minute. POST /service-accounts/:id/key */
|
|
40
49
|
async function newKey(collectionId, id) {
|
|
41
50
|
return post(`${base(collectionId)}/${enc(id)}/key`, {});
|
|
42
51
|
}
|
|
43
52
|
serviceAccounts.newKey = newKey;
|
|
44
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Let it work on another collection too, or change its access there. Call on its home collection; you must
|
|
55
|
+
* be an admin of `input.collectionId` as well, and can't give more access than you have there.
|
|
56
|
+
* POST /service-accounts/:id/collections
|
|
57
|
+
*/
|
|
58
|
+
async function addTo(collectionId, id, input) {
|
|
59
|
+
const out = await post(`${base(collectionId)}/${enc(id)}/collections`, input);
|
|
60
|
+
return out.serviceAccount;
|
|
61
|
+
}
|
|
62
|
+
serviceAccounts.addTo = addTo;
|
|
63
|
+
/** Stop it working on `otherCollectionId` (call on its home collection). DELETE /service-accounts/:id/collections/:otherId */
|
|
64
|
+
async function removeFrom(collectionId, id, otherCollectionId) {
|
|
65
|
+
return del(`${base(collectionId)}/${enc(id)}/collections/${enc(otherCollectionId)}`);
|
|
66
|
+
}
|
|
67
|
+
serviceAccounts.removeFrom = removeFrom;
|
|
68
|
+
/**
|
|
69
|
+
* On its home collection: delete it — its key stops working and its access is removed everywhere. On another
|
|
70
|
+
* collection it works on: remove it from that collection only. DELETE /service-accounts/:id
|
|
71
|
+
*/
|
|
45
72
|
async function remove(collectionId, id) {
|
|
46
73
|
return del(`${base(collectionId)}/${enc(id)}`);
|
|
47
74
|
}
|
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.46 | Generated: 2026-11-23T13:55:15.125Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -11959,6 +11959,9 @@ interface ServiceAccount {
|
|
|
11959
11959
|
name: string
|
|
11960
11960
|
access: ServiceAccountAccess | null
|
|
11961
11961
|
active: boolean
|
|
11962
|
+
home: boolean
|
|
11963
|
+
alsoOn?: ServiceAccountCollection[]
|
|
11964
|
+
homeCollection?: { collectionId: string; title: string }
|
|
11962
11965
|
createdAt: string
|
|
11963
11966
|
createdBy: string | null
|
|
11964
11967
|
lastUsedAt: string | null
|
|
@@ -11967,6 +11970,23 @@ interface ServiceAccount {
|
|
|
11967
11970
|
}
|
|
11968
11971
|
```
|
|
11969
11972
|
|
|
11973
|
+
**ServiceAccountCollection** (interface)
|
|
11974
|
+
```typescript
|
|
11975
|
+
interface ServiceAccountCollection {
|
|
11976
|
+
collectionId: string
|
|
11977
|
+
title: string
|
|
11978
|
+
access: ServiceAccountAccess | null
|
|
11979
|
+
}
|
|
11980
|
+
```
|
|
11981
|
+
|
|
11982
|
+
**AddServiceAccountToCollectionInput** (interface)
|
|
11983
|
+
```typescript
|
|
11984
|
+
interface AddServiceAccountToCollectionInput {
|
|
11985
|
+
collectionId: string
|
|
11986
|
+
access: ServiceAccountAccess
|
|
11987
|
+
}
|
|
11988
|
+
```
|
|
11989
|
+
|
|
11970
11990
|
**ServiceAccountList** (interface)
|
|
11971
11991
|
```typescript
|
|
11972
11992
|
interface ServiceAccountList {
|
|
@@ -16273,19 +16293,25 @@ Soft-delete a secret. DELETE /secrets/:ref
|
|
|
16273
16293
|
### serviceAccounts
|
|
16274
16294
|
|
|
16275
16295
|
**list**(collectionId: string) → `Promise<ServiceAccountList>`
|
|
16276
|
-
The collection'
|
|
16296
|
+
The service accounts that work on this collection — its own (`home: true`, with `alsoOn`) and other collections' (`home: false`, with `homeCollection`) — never their keys, and the access levels that can be given. GET /service-accounts
|
|
16277
16297
|
|
|
16278
16298
|
**create**(collectionId: string, input: CreateServiceAccountInput) → `Promise<CreateServiceAccountResult>`
|
|
16279
16299
|
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
16300
|
|
|
16281
16301
|
**update**(collectionId: string, id: string, input: UpdateServiceAccountInput) → `Promise<ServiceAccount>`
|
|
16282
|
-
Rename it and/or change its access. PUT /service-accounts/:id
|
|
16302
|
+
Rename it (home collection only) and/or change its access on this collection. PUT /service-accounts/:id
|
|
16283
16303
|
|
|
16284
16304
|
**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
|
|
16305
|
+
Give it a new key → `{ key }` (shown once; home collection only); the old key stops working within a minute. POST /service-accounts/:id/key
|
|
16306
|
+
|
|
16307
|
+
**addTo**(collectionId: string, id: string, input: AddServiceAccountToCollectionInput) → `Promise<ServiceAccount>`
|
|
16308
|
+
Let it work on another collection too, or change its access there. Call on its home collection; you must be an admin of `input.collectionId` as well, and can't give more access than you have there. POST /service-accounts/:id/collections
|
|
16309
|
+
|
|
16310
|
+
**removeFrom**(collectionId: string, id: string, otherCollectionId: string) → `Promise<`
|
|
16311
|
+
Stop it working on `otherCollectionId` (call on its home collection). DELETE /service-accounts/:id/collections/:otherId
|
|
16286
16312
|
|
|
16287
16313
|
**remove**(collectionId: string, id: string) → `Promise<`
|
|
16288
|
-
|
|
16314
|
+
On its home collection: delete it — its key stops working and its access is removed everywhere. On another collection it works on: remove it from that collection only. DELETE /service-accounts/:id
|
|
16289
16315
|
|
|
16290
16316
|
### sessions
|
|
16291
16317
|
|
|
@@ -4,10 +4,10 @@ A **service account** is how another system works with a collection: an ERP send
|
|
|
4
4
|
warehouse system recording shipments, an agency's integration. It's an identity of its own, with its own key
|
|
5
5
|
and access level. It is **not** a person's API key.
|
|
6
6
|
|
|
7
|
-
- It's a member of **
|
|
8
|
-
like a person on the team
|
|
9
|
-
It can reach nothing else.
|
|
10
|
-
- It belongs to
|
|
7
|
+
- It's a member of its **home** collection with an access level (`User`, `Reporter`, `Assigner` or `Admin`),
|
|
8
|
+
just like a person on the team, and can **also work on** other collections, each with its own access.
|
|
9
|
+
Everything a person with that access can do on those collections, it can do. It can reach nothing else.
|
|
10
|
+
- It belongs to its home collection, not to whoever made it, so it keeps working when people leave the team.
|
|
11
11
|
- Its key (`slsvc_<id>.<secret>`) is shown **once**, when it's made or given a new key. Only a hash is kept.
|
|
12
12
|
- It **can't** invite people or change anyone's access. It can't make API keys or other service accounts,
|
|
13
13
|
make collections, or hand the collection over. A leaked key can't leave a way back in once it's deleted.
|
|
@@ -28,6 +28,27 @@ await serviceAccounts.remove(collectionId, serviceAccount.id)
|
|
|
28
28
|
|
|
29
29
|
You can't give a service account more access than you have yourself, and never `Owner`.
|
|
30
30
|
|
|
31
|
+
## More than one collection
|
|
32
|
+
|
|
33
|
+
One system working across several collections (say, a brand's three ranges) uses one service account:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
// On its home collection; you must be an admin of the other collection too.
|
|
37
|
+
await serviceAccounts.addTo(collectionId, serviceAccount.id, { collectionId: otherCollectionId, access: "Reporter" })
|
|
38
|
+
await serviceAccounts.removeFrom(collectionId, serviceAccount.id, otherCollectionId)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Same key everywhere; each request names the collection it's for. Only the home collection renames it, gives
|
|
42
|
+
it a new key or deletes it (deleting removes it everywhere). The other collection lists it with
|
|
43
|
+
`home: false` and `homeCollection`, and its admins can change its access there (`update`) or take it off
|
|
44
|
+
(`remove`, which there removes it from that collection only).
|
|
45
|
+
|
|
46
|
+
## Personal API keys are different
|
|
47
|
+
|
|
48
|
+
A personal API key **is** you: everything you can do, on every collection you can, and it gains or loses
|
|
49
|
+
access as you do. Use one for your own scripts. Use a service account for another system, so it doesn't
|
|
50
|
+
depend on any one person.
|
|
51
|
+
|
|
31
52
|
## Using the key
|
|
32
53
|
|
|
33
54
|
The other system sends the key as its bearer token:
|
package/dist/openapi.yaml
CHANGED
|
@@ -36992,6 +36992,15 @@ components:
|
|
|
36992
36992
|
$ref: "#/components/schemas/ServiceAccountAccess"
|
|
36993
36993
|
active:
|
|
36994
36994
|
type: boolean
|
|
36995
|
+
home:
|
|
36996
|
+
type: boolean
|
|
36997
|
+
alsoOn:
|
|
36998
|
+
type: array
|
|
36999
|
+
items:
|
|
37000
|
+
$ref: "#/components/schemas/ServiceAccountCollection"
|
|
37001
|
+
homeCollection:
|
|
37002
|
+
type: object
|
|
37003
|
+
additionalProperties: true
|
|
36995
37004
|
createdAt:
|
|
36996
37005
|
type: string
|
|
36997
37006
|
createdBy:
|
|
@@ -37007,11 +37016,35 @@ components:
|
|
|
37007
37016
|
- name
|
|
37008
37017
|
- access
|
|
37009
37018
|
- active
|
|
37019
|
+
- home
|
|
37010
37020
|
- createdAt
|
|
37011
37021
|
- createdBy
|
|
37012
37022
|
- lastUsedAt
|
|
37013
37023
|
- keyCreatedAt
|
|
37014
37024
|
- keyHint
|
|
37025
|
+
ServiceAccountCollection:
|
|
37026
|
+
type: object
|
|
37027
|
+
properties:
|
|
37028
|
+
collectionId:
|
|
37029
|
+
type: string
|
|
37030
|
+
title:
|
|
37031
|
+
type: string
|
|
37032
|
+
access:
|
|
37033
|
+
$ref: "#/components/schemas/ServiceAccountAccess"
|
|
37034
|
+
required:
|
|
37035
|
+
- collectionId
|
|
37036
|
+
- title
|
|
37037
|
+
- access
|
|
37038
|
+
AddServiceAccountToCollectionInput:
|
|
37039
|
+
type: object
|
|
37040
|
+
properties:
|
|
37041
|
+
collectionId:
|
|
37042
|
+
type: string
|
|
37043
|
+
access:
|
|
37044
|
+
$ref: "#/components/schemas/ServiceAccountAccess"
|
|
37045
|
+
required:
|
|
37046
|
+
- collectionId
|
|
37047
|
+
- access
|
|
37015
37048
|
ServiceAccountList:
|
|
37016
37049
|
type: object
|
|
37017
37050
|
properties:
|
|
@@ -6,10 +6,22 @@ export interface ServiceAccount {
|
|
|
6
6
|
id: string;
|
|
7
7
|
/** What uses it, e.g. "Warehouse system". */
|
|
8
8
|
name: string;
|
|
9
|
-
/** Its access on the collection (null if it was removed from the
|
|
9
|
+
/** Its access on the collection you asked about (null if it was removed from the members another way). */
|
|
10
10
|
access: ServiceAccountAccess | null;
|
|
11
11
|
/** false once its key has been switched off. */
|
|
12
12
|
active: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* true when it belongs to the collection you asked about (its home): only there can it be renamed, given a
|
|
15
|
+
* new key, deleted, or added to other collections.
|
|
16
|
+
*/
|
|
17
|
+
home: boolean;
|
|
18
|
+
/** Home only: the other collections it also works on, each with its access there. */
|
|
19
|
+
alsoOn?: ServiceAccountCollection[];
|
|
20
|
+
/** Not home: the collection it belongs to. */
|
|
21
|
+
homeCollection?: {
|
|
22
|
+
collectionId: string;
|
|
23
|
+
title: string;
|
|
24
|
+
};
|
|
13
25
|
createdAt: string;
|
|
14
26
|
/** The user id of the person who made it. */
|
|
15
27
|
createdBy: string | null;
|
|
@@ -20,6 +32,17 @@ export interface ServiceAccount {
|
|
|
20
32
|
/** How its key starts ("slsvc_sa-….…"), to recognise it — never the secret. */
|
|
21
33
|
keyHint: string;
|
|
22
34
|
}
|
|
35
|
+
/** Another collection a service account works on. */
|
|
36
|
+
export interface ServiceAccountCollection {
|
|
37
|
+
collectionId: string;
|
|
38
|
+
title: string;
|
|
39
|
+
access: ServiceAccountAccess | null;
|
|
40
|
+
}
|
|
41
|
+
/** Let a service account work on another collection too (or change its access there). */
|
|
42
|
+
export interface AddServiceAccountToCollectionInput {
|
|
43
|
+
collectionId: string;
|
|
44
|
+
access: ServiceAccountAccess;
|
|
45
|
+
}
|
|
23
46
|
export interface ServiceAccountList {
|
|
24
47
|
serviceAccounts: ServiceAccount[];
|
|
25
48
|
/** The access levels that can be given. */
|
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.46 | Generated: 2026-11-23T13:55:15.125Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -11959,6 +11959,9 @@ interface ServiceAccount {
|
|
|
11959
11959
|
name: string
|
|
11960
11960
|
access: ServiceAccountAccess | null
|
|
11961
11961
|
active: boolean
|
|
11962
|
+
home: boolean
|
|
11963
|
+
alsoOn?: ServiceAccountCollection[]
|
|
11964
|
+
homeCollection?: { collectionId: string; title: string }
|
|
11962
11965
|
createdAt: string
|
|
11963
11966
|
createdBy: string | null
|
|
11964
11967
|
lastUsedAt: string | null
|
|
@@ -11967,6 +11970,23 @@ interface ServiceAccount {
|
|
|
11967
11970
|
}
|
|
11968
11971
|
```
|
|
11969
11972
|
|
|
11973
|
+
**ServiceAccountCollection** (interface)
|
|
11974
|
+
```typescript
|
|
11975
|
+
interface ServiceAccountCollection {
|
|
11976
|
+
collectionId: string
|
|
11977
|
+
title: string
|
|
11978
|
+
access: ServiceAccountAccess | null
|
|
11979
|
+
}
|
|
11980
|
+
```
|
|
11981
|
+
|
|
11982
|
+
**AddServiceAccountToCollectionInput** (interface)
|
|
11983
|
+
```typescript
|
|
11984
|
+
interface AddServiceAccountToCollectionInput {
|
|
11985
|
+
collectionId: string
|
|
11986
|
+
access: ServiceAccountAccess
|
|
11987
|
+
}
|
|
11988
|
+
```
|
|
11989
|
+
|
|
11970
11990
|
**ServiceAccountList** (interface)
|
|
11971
11991
|
```typescript
|
|
11972
11992
|
interface ServiceAccountList {
|
|
@@ -16273,19 +16293,25 @@ Soft-delete a secret. DELETE /secrets/:ref
|
|
|
16273
16293
|
### serviceAccounts
|
|
16274
16294
|
|
|
16275
16295
|
**list**(collectionId: string) → `Promise<ServiceAccountList>`
|
|
16276
|
-
The collection'
|
|
16296
|
+
The service accounts that work on this collection — its own (`home: true`, with `alsoOn`) and other collections' (`home: false`, with `homeCollection`) — never their keys, and the access levels that can be given. GET /service-accounts
|
|
16277
16297
|
|
|
16278
16298
|
**create**(collectionId: string, input: CreateServiceAccountInput) → `Promise<CreateServiceAccountResult>`
|
|
16279
16299
|
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
16300
|
|
|
16281
16301
|
**update**(collectionId: string, id: string, input: UpdateServiceAccountInput) → `Promise<ServiceAccount>`
|
|
16282
|
-
Rename it and/or change its access. PUT /service-accounts/:id
|
|
16302
|
+
Rename it (home collection only) and/or change its access on this collection. PUT /service-accounts/:id
|
|
16283
16303
|
|
|
16284
16304
|
**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
|
|
16305
|
+
Give it a new key → `{ key }` (shown once; home collection only); the old key stops working within a minute. POST /service-accounts/:id/key
|
|
16306
|
+
|
|
16307
|
+
**addTo**(collectionId: string, id: string, input: AddServiceAccountToCollectionInput) → `Promise<ServiceAccount>`
|
|
16308
|
+
Let it work on another collection too, or change its access there. Call on its home collection; you must be an admin of `input.collectionId` as well, and can't give more access than you have there. POST /service-accounts/:id/collections
|
|
16309
|
+
|
|
16310
|
+
**removeFrom**(collectionId: string, id: string, otherCollectionId: string) → `Promise<`
|
|
16311
|
+
Stop it working on `otherCollectionId` (call on its home collection). DELETE /service-accounts/:id/collections/:otherId
|
|
16286
16312
|
|
|
16287
16313
|
**remove**(collectionId: string, id: string) → `Promise<`
|
|
16288
|
-
|
|
16314
|
+
On its home collection: delete it — its key stops working and its access is removed everywhere. On another collection it works on: remove it from that collection only. DELETE /service-accounts/:id
|
|
16289
16315
|
|
|
16290
16316
|
### sessions
|
|
16291
16317
|
|
package/docs/service-accounts.md
CHANGED
|
@@ -4,10 +4,10 @@ A **service account** is how another system works with a collection: an ERP send
|
|
|
4
4
|
warehouse system recording shipments, an agency's integration. It's an identity of its own, with its own key
|
|
5
5
|
and access level. It is **not** a person's API key.
|
|
6
6
|
|
|
7
|
-
- It's a member of **
|
|
8
|
-
like a person on the team
|
|
9
|
-
It can reach nothing else.
|
|
10
|
-
- It belongs to
|
|
7
|
+
- It's a member of its **home** collection with an access level (`User`, `Reporter`, `Assigner` or `Admin`),
|
|
8
|
+
just like a person on the team, and can **also work on** other collections, each with its own access.
|
|
9
|
+
Everything a person with that access can do on those collections, it can do. It can reach nothing else.
|
|
10
|
+
- It belongs to its home collection, not to whoever made it, so it keeps working when people leave the team.
|
|
11
11
|
- Its key (`slsvc_<id>.<secret>`) is shown **once**, when it's made or given a new key. Only a hash is kept.
|
|
12
12
|
- It **can't** invite people or change anyone's access. It can't make API keys or other service accounts,
|
|
13
13
|
make collections, or hand the collection over. A leaked key can't leave a way back in once it's deleted.
|
|
@@ -28,6 +28,27 @@ await serviceAccounts.remove(collectionId, serviceAccount.id)
|
|
|
28
28
|
|
|
29
29
|
You can't give a service account more access than you have yourself, and never `Owner`.
|
|
30
30
|
|
|
31
|
+
## More than one collection
|
|
32
|
+
|
|
33
|
+
One system working across several collections (say, a brand's three ranges) uses one service account:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
// On its home collection; you must be an admin of the other collection too.
|
|
37
|
+
await serviceAccounts.addTo(collectionId, serviceAccount.id, { collectionId: otherCollectionId, access: "Reporter" })
|
|
38
|
+
await serviceAccounts.removeFrom(collectionId, serviceAccount.id, otherCollectionId)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Same key everywhere; each request names the collection it's for. Only the home collection renames it, gives
|
|
42
|
+
it a new key or deletes it (deleting removes it everywhere). The other collection lists it with
|
|
43
|
+
`home: false` and `homeCollection`, and its admins can change its access there (`update`) or take it off
|
|
44
|
+
(`remove`, which there removes it from that collection only).
|
|
45
|
+
|
|
46
|
+
## Personal API keys are different
|
|
47
|
+
|
|
48
|
+
A personal API key **is** you: everything you can do, on every collection you can, and it gains or loses
|
|
49
|
+
access as you do. Use one for your own scripts. Use a service account for another system, so it doesn't
|
|
50
|
+
depend on any one person.
|
|
51
|
+
|
|
31
52
|
## Using the key
|
|
32
53
|
|
|
33
54
|
The other system sends the key as its bearer token:
|
package/openapi.yaml
CHANGED
|
@@ -36992,6 +36992,15 @@ components:
|
|
|
36992
36992
|
$ref: "#/components/schemas/ServiceAccountAccess"
|
|
36993
36993
|
active:
|
|
36994
36994
|
type: boolean
|
|
36995
|
+
home:
|
|
36996
|
+
type: boolean
|
|
36997
|
+
alsoOn:
|
|
36998
|
+
type: array
|
|
36999
|
+
items:
|
|
37000
|
+
$ref: "#/components/schemas/ServiceAccountCollection"
|
|
37001
|
+
homeCollection:
|
|
37002
|
+
type: object
|
|
37003
|
+
additionalProperties: true
|
|
36995
37004
|
createdAt:
|
|
36996
37005
|
type: string
|
|
36997
37006
|
createdBy:
|
|
@@ -37007,11 +37016,35 @@ components:
|
|
|
37007
37016
|
- name
|
|
37008
37017
|
- access
|
|
37009
37018
|
- active
|
|
37019
|
+
- home
|
|
37010
37020
|
- createdAt
|
|
37011
37021
|
- createdBy
|
|
37012
37022
|
- lastUsedAt
|
|
37013
37023
|
- keyCreatedAt
|
|
37014
37024
|
- keyHint
|
|
37025
|
+
ServiceAccountCollection:
|
|
37026
|
+
type: object
|
|
37027
|
+
properties:
|
|
37028
|
+
collectionId:
|
|
37029
|
+
type: string
|
|
37030
|
+
title:
|
|
37031
|
+
type: string
|
|
37032
|
+
access:
|
|
37033
|
+
$ref: "#/components/schemas/ServiceAccountAccess"
|
|
37034
|
+
required:
|
|
37035
|
+
- collectionId
|
|
37036
|
+
- title
|
|
37037
|
+
- access
|
|
37038
|
+
AddServiceAccountToCollectionInput:
|
|
37039
|
+
type: object
|
|
37040
|
+
properties:
|
|
37041
|
+
collectionId:
|
|
37042
|
+
type: string
|
|
37043
|
+
access:
|
|
37044
|
+
$ref: "#/components/schemas/ServiceAccountAccess"
|
|
37045
|
+
required:
|
|
37046
|
+
- collectionId
|
|
37047
|
+
- access
|
|
37015
37048
|
ServiceAccountList:
|
|
37016
37049
|
type: object
|
|
37017
37050
|
properties:
|