@artemis-apps/contracts 0.0.0-stage → 0.1.1
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/activity.d.ts +150 -0
- package/dist/activity.js +159 -0
- package/dist/api-error.d.ts +8 -0
- package/dist/api-error.js +7 -0
- package/dist/app-protocol.d.ts +290 -0
- package/dist/app-protocol.js +357 -0
- package/dist/app-session-state.d.ts +98 -0
- package/dist/app-session-state.js +38 -0
- package/dist/core-api.d.ts +799 -0
- package/dist/core-api.js +345 -0
- package/dist/entities/account.entity.d.ts +34 -0
- package/dist/entities/account.entity.js +15 -0
- package/dist/entities/avatar.entity.d.ts +31 -0
- package/dist/entities/avatar.entity.js +30 -0
- package/dist/entities/entity-name.d.ts +3 -0
- package/dist/entities/entity-name.js +2 -0
- package/dist/entities.d.ts +350 -0
- package/dist/entities.js +200 -0
- package/dist/entity-shares.d.ts +86 -0
- package/dist/entity-shares.js +29 -0
- package/dist/entity-types.d.ts +153 -0
- package/dist/entity-types.js +248 -0
- package/dist/images.d.ts +6 -0
- package/dist/images.js +10 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +24 -0
- package/dist/marketplace.d.ts +183 -0
- package/dist/marketplace.js +162 -0
- package/dist/oidc.d.ts +25 -0
- package/dist/oidc.js +36 -0
- package/dist/permissions.d.ts +70 -0
- package/dist/permissions.js +101 -0
- package/dist/preferences.d.ts +30 -0
- package/dist/preferences.js +18 -0
- package/dist/return-path.d.ts +7 -0
- package/dist/return-path.js +21 -0
- package/dist/route-path.d.ts +5 -0
- package/dist/route-path.js +10 -0
- package/dist/storage.d.ts +43 -0
- package/dist/storage.js +39 -0
- package/dist/web-url.d.ts +7 -0
- package/dist/web-url.js +7 -0
- package/package.json +45 -3
- package/README.md +0 -3
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Severity of an event, from the least to the most severe. */
|
|
3
|
+
export declare const ACTIVITY_LEVELS: readonly ['info', 'warn', 'error'];
|
|
4
|
+
export declare const ActivityLevelSchema: z.ZodEnum<{
|
|
5
|
+
error: "error";
|
|
6
|
+
info: "info";
|
|
7
|
+
warn: "warn";
|
|
8
|
+
}>;
|
|
9
|
+
export type ActivityLevel = z.infer<typeof ActivityLevelSchema>;
|
|
10
|
+
/** `level` itself and every more severe level (a `level` filter is a minimum). */
|
|
11
|
+
export declare function activityLevelsFrom(level: ActivityLevel): ActivityLevel[];
|
|
12
|
+
export declare const ActivityActionSchema: z.ZodString;
|
|
13
|
+
/** The namespace of an action: the core's own (`account`...) or the app's (`contacts`). */
|
|
14
|
+
export declare function activityNamespace(action: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Namespaces of the core's own events. Apps never report in them: an app reports in the
|
|
17
|
+
* namespaces of the entity types it provides (`contacts:*` for `contacts.contact`).
|
|
18
|
+
*/
|
|
19
|
+
export declare const CORE_ACTIVITY_NAMESPACES: readonly ['account', 'admin', 'app', 'directory', 'entity', 'storage'];
|
|
20
|
+
export declare function isCoreActivityNamespace(namespace: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The actions known to the platform, translated for display. Apps may report other actions of
|
|
23
|
+
* their namespace: they are shown raw until added here.
|
|
24
|
+
*/
|
|
25
|
+
export declare const ACTIVITY_ACTIONS: readonly ['account:registered', 'account:signed-in', 'account:sign-in-failed', 'account:signed-out', 'account:profile-updated', 'account:password-changed', 'account:deleted', 'admin:permissions-changed', 'app:enrolled', 'app:updated', 'app:update-pending', 'app:update-approved', 'app:update-declined', 'app:revoked', 'app:consented', 'app:consent-denied', 'app:reordered', 'app:installed', 'app:uninstalled', 'admin:repository-added', 'admin:repository-updated', 'admin:repository-removed', 'admin:marketplace-updated', 'entity:shared', 'entity:unshared', 'storage:file-uploaded', 'storage:file-deleted', 'contacts:contact-created', 'contacts:contact-deleted', 'drive:file-uploaded', 'drive:item-deleted', 'drive:item-copied'];
|
|
26
|
+
export type ActivityAction = (typeof ACTIVITY_ACTIONS)[number];
|
|
27
|
+
export declare function isActivityAction(value: string): value is ActivityAction;
|
|
28
|
+
/** Largest serialized `details` the core keeps for one event. */
|
|
29
|
+
export declare const ACTIVITY_DETAILS_MAX_LENGTH = 2048;
|
|
30
|
+
/** Small context of an event (ids, changed fields...). Never secrets nor passwords. */
|
|
31
|
+
export declare const ActivityDetailsSchema: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
32
|
+
export type ActivityDetails = z.infer<typeof ActivityDetailsSchema>;
|
|
33
|
+
/** Body of an app reporting one of its own events. */
|
|
34
|
+
export declare const ActivityReportSchema: z.ZodObject<{
|
|
35
|
+
level: z.ZodEnum<{
|
|
36
|
+
error: "error";
|
|
37
|
+
info: "info";
|
|
38
|
+
warn: "warn";
|
|
39
|
+
}>;
|
|
40
|
+
action: z.ZodString;
|
|
41
|
+
accountId: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
|
|
42
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export type ActivityReport = z.input<typeof ActivityReportSchema>;
|
|
45
|
+
/** The app an event came from, for display. */
|
|
46
|
+
export declare const ActivityAppSchema: z.ZodObject<{
|
|
47
|
+
id: z.ZodString;
|
|
48
|
+
name: z.ZodString;
|
|
49
|
+
iconUrl: z.ZodURL;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
export type ActivityApp = z.infer<typeof ActivityAppSchema>;
|
|
52
|
+
/**
|
|
53
|
+
* One event, with its account and app resolved for display. Ids are kept after a deletion:
|
|
54
|
+
* `accountId` (or `appId`) set with `account` (or `app`) `null` means it no longer exists.
|
|
55
|
+
*/
|
|
56
|
+
export declare const ActivityEventSchema: z.ZodObject<{
|
|
57
|
+
id: z.ZodUUID;
|
|
58
|
+
occurredAt: z.ZodISODateTime;
|
|
59
|
+
level: z.ZodEnum<{
|
|
60
|
+
error: "error";
|
|
61
|
+
info: "info";
|
|
62
|
+
warn: "warn";
|
|
63
|
+
}>;
|
|
64
|
+
action: z.ZodString;
|
|
65
|
+
details: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
66
|
+
accountId: z.ZodNullable<z.ZodString>;
|
|
67
|
+
account: z.ZodNullable<z.ZodObject<{
|
|
68
|
+
id: z.ZodUUID;
|
|
69
|
+
email: z.ZodEmail;
|
|
70
|
+
name: z.ZodString;
|
|
71
|
+
avatar: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
72
|
+
kind: z.ZodLiteral<"generated">;
|
|
73
|
+
seed: z.ZodUUID;
|
|
74
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
75
|
+
kind: z.ZodLiteral<"file">;
|
|
76
|
+
fileId: z.ZodUUID;
|
|
77
|
+
url: z.ZodURL;
|
|
78
|
+
}, z.core.$strip>], "kind">;
|
|
79
|
+
}, z.core.$strip>>;
|
|
80
|
+
appId: z.ZodNullable<z.ZodString>;
|
|
81
|
+
app: z.ZodNullable<z.ZodObject<{
|
|
82
|
+
id: z.ZodString;
|
|
83
|
+
name: z.ZodString;
|
|
84
|
+
iconUrl: z.ZodURL;
|
|
85
|
+
}, z.core.$strip>>;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
export type ActivityEvent = z.infer<typeof ActivityEventSchema>;
|
|
88
|
+
/** Newest first. `nextCursor` fetches the older events, `null` at the end. */
|
|
89
|
+
export declare const ActivityEventPageSchema: z.ZodObject<{
|
|
90
|
+
events: z.ZodArray<z.ZodObject<{
|
|
91
|
+
id: z.ZodUUID;
|
|
92
|
+
occurredAt: z.ZodISODateTime;
|
|
93
|
+
level: z.ZodEnum<{
|
|
94
|
+
error: "error";
|
|
95
|
+
info: "info";
|
|
96
|
+
warn: "warn";
|
|
97
|
+
}>;
|
|
98
|
+
action: z.ZodString;
|
|
99
|
+
details: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
100
|
+
accountId: z.ZodNullable<z.ZodString>;
|
|
101
|
+
account: z.ZodNullable<z.ZodObject<{
|
|
102
|
+
id: z.ZodUUID;
|
|
103
|
+
email: z.ZodEmail;
|
|
104
|
+
name: z.ZodString;
|
|
105
|
+
avatar: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
106
|
+
kind: z.ZodLiteral<"generated">;
|
|
107
|
+
seed: z.ZodUUID;
|
|
108
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
109
|
+
kind: z.ZodLiteral<"file">;
|
|
110
|
+
fileId: z.ZodUUID;
|
|
111
|
+
url: z.ZodURL;
|
|
112
|
+
}, z.core.$strip>], "kind">;
|
|
113
|
+
}, z.core.$strip>>;
|
|
114
|
+
appId: z.ZodNullable<z.ZodString>;
|
|
115
|
+
app: z.ZodNullable<z.ZodObject<{
|
|
116
|
+
id: z.ZodString;
|
|
117
|
+
name: z.ZodString;
|
|
118
|
+
iconUrl: z.ZodURL;
|
|
119
|
+
}, z.core.$strip>>;
|
|
120
|
+
}, z.core.$strip>>;
|
|
121
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
122
|
+
}, z.core.$strip>;
|
|
123
|
+
export type ActivityEventPage = z.infer<typeof ActivityEventPageSchema>;
|
|
124
|
+
export declare const ACTIVITY_PAGE_SIZE = 50;
|
|
125
|
+
/** `appId` value selecting the events of the core itself. */
|
|
126
|
+
export declare const ACTIVITY_CORE_APP_ID = "core";
|
|
127
|
+
/** Query string of `GET CORE_ACTIVITY_PATHS.events`. Every filter is optional. */
|
|
128
|
+
export declare const ActivityEventQuerySchema: z.ZodObject<{
|
|
129
|
+
accountId: z.ZodOptional<z.ZodUUID>;
|
|
130
|
+
appId: z.ZodOptional<z.ZodString>;
|
|
131
|
+
level: z.ZodOptional<z.ZodEnum<{
|
|
132
|
+
error: "error";
|
|
133
|
+
info: "info";
|
|
134
|
+
warn: "warn";
|
|
135
|
+
}>>;
|
|
136
|
+
action: z.ZodOptional<z.ZodString>;
|
|
137
|
+
from: z.ZodOptional<z.ZodISODateTime>;
|
|
138
|
+
to: z.ZodOptional<z.ZodISODateTime>;
|
|
139
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
140
|
+
}, z.core.$strip>;
|
|
141
|
+
export type ActivityEventQuery = z.infer<typeof ActivityEventQuerySchema>;
|
|
142
|
+
/** The query string `ActivityEventQuerySchema` parses (without `?`). */
|
|
143
|
+
export declare function formatActivityEventQuery(query: ActivityEventQuery): string;
|
|
144
|
+
/** Route patterns of the activity log on the core. */
|
|
145
|
+
export declare const CORE_ACTIVITY_PATHS: {
|
|
146
|
+
/** GET `ActivityEventQuery` → `ActivityEventPage` (`admin:logs:read`). */
|
|
147
|
+
readonly events: '/api/activity-events';
|
|
148
|
+
/** POST `ActivityReport` → 204. App-authenticated (HTTP Basic), CSRF-exempt. */
|
|
149
|
+
readonly reports: '/api/activity-reports';
|
|
150
|
+
};
|
package/dist/activity.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { AccountSchema } from './entities/account.entity.js';
|
|
3
|
+
/*
|
|
4
|
+
* The activity log: who did what, from which app. Kept by the core, read by administrators
|
|
5
|
+
* (`admin:logs:read`). Apps report their own events server to server, with their
|
|
6
|
+
* `client_credentials` access token, like the storage.
|
|
7
|
+
*/
|
|
8
|
+
/** Severity of an event, from the least to the most severe. */
|
|
9
|
+
export const ACTIVITY_LEVELS = ['info', 'warn', 'error'];
|
|
10
|
+
export const ActivityLevelSchema = z.enum(ACTIVITY_LEVELS);
|
|
11
|
+
/** `level` itself and every more severe level (a `level` filter is a minimum). */
|
|
12
|
+
export function activityLevelsFrom(level) {
|
|
13
|
+
return ACTIVITY_LEVELS.slice(ACTIVITY_LEVELS.indexOf(level));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Action format: `<namespace>:<event>`, lowercase kebab-case, the event in the past tense
|
|
17
|
+
* (`account:signed-in`, `contacts:contact-created`). Failures say so (`account:sign-in-failed`).
|
|
18
|
+
*/
|
|
19
|
+
const ACTION_PATTERN = /^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/;
|
|
20
|
+
export const ActivityActionSchema = z
|
|
21
|
+
.string()
|
|
22
|
+
.max(80)
|
|
23
|
+
.regex(ACTION_PATTERN, 'Expected `<namespace>:<event>` in lowercase kebab-case');
|
|
24
|
+
/** The namespace of an action: the core's own (`account`...) or the app's (`contacts`). */
|
|
25
|
+
export function activityNamespace(action) {
|
|
26
|
+
return action.slice(0, action.indexOf(':'));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Namespaces of the core's own events. Apps never report in them: an app reports in the
|
|
30
|
+
* namespaces of the entity types it provides (`contacts:*` for `contacts.contact`).
|
|
31
|
+
*/
|
|
32
|
+
export const CORE_ACTIVITY_NAMESPACES = [
|
|
33
|
+
'account',
|
|
34
|
+
'admin',
|
|
35
|
+
'app',
|
|
36
|
+
'directory',
|
|
37
|
+
'entity',
|
|
38
|
+
'storage',
|
|
39
|
+
];
|
|
40
|
+
export function isCoreActivityNamespace(namespace) {
|
|
41
|
+
return CORE_ACTIVITY_NAMESPACES.includes(namespace);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The actions known to the platform, translated for display. Apps may report other actions of
|
|
45
|
+
* their namespace: they are shown raw until added here.
|
|
46
|
+
*/
|
|
47
|
+
export const ACTIVITY_ACTIONS = [
|
|
48
|
+
'account:registered',
|
|
49
|
+
'account:signed-in',
|
|
50
|
+
'account:sign-in-failed',
|
|
51
|
+
'account:signed-out',
|
|
52
|
+
'account:profile-updated',
|
|
53
|
+
'account:password-changed',
|
|
54
|
+
'account:deleted',
|
|
55
|
+
'admin:permissions-changed',
|
|
56
|
+
'app:enrolled',
|
|
57
|
+
'app:updated',
|
|
58
|
+
'app:update-pending',
|
|
59
|
+
'app:update-approved',
|
|
60
|
+
'app:update-declined',
|
|
61
|
+
'app:revoked',
|
|
62
|
+
'app:consented',
|
|
63
|
+
'app:consent-denied',
|
|
64
|
+
'app:reordered',
|
|
65
|
+
'app:installed',
|
|
66
|
+
'app:uninstalled',
|
|
67
|
+
'admin:repository-added',
|
|
68
|
+
'admin:repository-updated',
|
|
69
|
+
'admin:repository-removed',
|
|
70
|
+
'admin:marketplace-updated',
|
|
71
|
+
'entity:shared',
|
|
72
|
+
'entity:unshared',
|
|
73
|
+
'storage:file-uploaded',
|
|
74
|
+
'storage:file-deleted',
|
|
75
|
+
'contacts:contact-created',
|
|
76
|
+
'contacts:contact-deleted',
|
|
77
|
+
'drive:file-uploaded',
|
|
78
|
+
'drive:item-deleted',
|
|
79
|
+
'drive:item-copied',
|
|
80
|
+
];
|
|
81
|
+
export function isActivityAction(value) {
|
|
82
|
+
return ACTIVITY_ACTIONS.includes(value);
|
|
83
|
+
}
|
|
84
|
+
/** Largest serialized `details` the core keeps for one event. */
|
|
85
|
+
export const ACTIVITY_DETAILS_MAX_LENGTH = 2048;
|
|
86
|
+
/** Small context of an event (ids, changed fields...). Never secrets nor passwords. */
|
|
87
|
+
export const ActivityDetailsSchema = z
|
|
88
|
+
.record(z.string(), z.json())
|
|
89
|
+
.refine((details) => JSON.stringify(details).length <= ACTIVITY_DETAILS_MAX_LENGTH, {
|
|
90
|
+
message: `Details must not exceed ${ACTIVITY_DETAILS_MAX_LENGTH} characters once serialized.`,
|
|
91
|
+
});
|
|
92
|
+
/** Body of an app reporting one of its own events. */
|
|
93
|
+
export const ActivityReportSchema = z.object({
|
|
94
|
+
level: ActivityLevelSchema,
|
|
95
|
+
action: ActivityActionSchema,
|
|
96
|
+
/** The account that acted, when there is one. */
|
|
97
|
+
accountId: z.uuidv4().nullable().optional(),
|
|
98
|
+
details: ActivityDetailsSchema.optional(),
|
|
99
|
+
});
|
|
100
|
+
/** The app an event came from, for display. */
|
|
101
|
+
export const ActivityAppSchema = z.object({
|
|
102
|
+
id: z.string(),
|
|
103
|
+
name: z.string(),
|
|
104
|
+
iconUrl: z.url(),
|
|
105
|
+
});
|
|
106
|
+
/**
|
|
107
|
+
* One event, with its account and app resolved for display. Ids are kept after a deletion:
|
|
108
|
+
* `accountId` (or `appId`) set with `account` (or `app`) `null` means it no longer exists.
|
|
109
|
+
*/
|
|
110
|
+
export const ActivityEventSchema = z.object({
|
|
111
|
+
id: z.uuidv4(),
|
|
112
|
+
occurredAt: z.iso.datetime(),
|
|
113
|
+
level: ActivityLevelSchema,
|
|
114
|
+
action: z.string(),
|
|
115
|
+
details: z.record(z.string(), z.json()),
|
|
116
|
+
accountId: z.string().nullable(),
|
|
117
|
+
account: AccountSchema.nullable(),
|
|
118
|
+
/** `null`: the core itself. */
|
|
119
|
+
appId: z.string().nullable(),
|
|
120
|
+
app: ActivityAppSchema.nullable(),
|
|
121
|
+
});
|
|
122
|
+
/** Newest first. `nextCursor` fetches the older events, `null` at the end. */
|
|
123
|
+
export const ActivityEventPageSchema = z.object({
|
|
124
|
+
events: z.array(ActivityEventSchema),
|
|
125
|
+
nextCursor: z.string().nullable(),
|
|
126
|
+
});
|
|
127
|
+
export const ACTIVITY_PAGE_SIZE = 50;
|
|
128
|
+
/** `appId` value selecting the events of the core itself. */
|
|
129
|
+
export const ACTIVITY_CORE_APP_ID = 'core';
|
|
130
|
+
/** Query string of `GET CORE_ACTIVITY_PATHS.events`. Every filter is optional. */
|
|
131
|
+
export const ActivityEventQuerySchema = z.object({
|
|
132
|
+
accountId: z.uuidv4().optional(),
|
|
133
|
+
/** An enrolled app's id, or `ACTIVITY_CORE_APP_ID`. */
|
|
134
|
+
appId: z.string().min(1).max(64).optional(),
|
|
135
|
+
/** Minimum level: `warn` returns warnings and errors. */
|
|
136
|
+
level: ActivityLevelSchema.optional(),
|
|
137
|
+
action: ActivityActionSchema.optional(),
|
|
138
|
+
/** Inclusive bounds. */
|
|
139
|
+
from: z.iso.datetime({ offset: true }).optional(),
|
|
140
|
+
to: z.iso.datetime({ offset: true }).optional(),
|
|
141
|
+
/** `nextCursor` of the previous page. */
|
|
142
|
+
cursor: z.string().min(1).max(200).optional(),
|
|
143
|
+
});
|
|
144
|
+
/** The query string `ActivityEventQuerySchema` parses (without `?`). */
|
|
145
|
+
export function formatActivityEventQuery(query) {
|
|
146
|
+
const params = new URLSearchParams();
|
|
147
|
+
for (const [name, value] of Object.entries(query)) {
|
|
148
|
+
if (value !== undefined)
|
|
149
|
+
params.set(name, value);
|
|
150
|
+
}
|
|
151
|
+
return params.toString();
|
|
152
|
+
}
|
|
153
|
+
/** Route patterns of the activity log on the core. */
|
|
154
|
+
export const CORE_ACTIVITY_PATHS = {
|
|
155
|
+
/** GET `ActivityEventQuery` → `ActivityEventPage` (`admin:logs:read`). */
|
|
156
|
+
events: '/api/activity-events',
|
|
157
|
+
/** POST `ActivityReport` → 204. App-authenticated (HTTP Basic), CSRF-exempt. */
|
|
158
|
+
reports: '/api/activity-reports',
|
|
159
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Body of every non-2xx JSON response across platform APIs. */
|
|
3
|
+
export declare const ApiErrorBodySchema: z.ZodObject<{
|
|
4
|
+
error: z.ZodObject<{
|
|
5
|
+
message: z.ZodString;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type ApiErrorBody = z.infer<typeof ApiErrorBodySchema>;
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EntityTypeDefinitionSchema } from './entity-types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Conventions every app follows so that a core can enroll it without knowing it beforehand.
|
|
5
|
+
* Paths are relative to the app URL.
|
|
6
|
+
*/
|
|
7
|
+
export declare const APP_PROTOCOL_PATHS: {
|
|
8
|
+
/** GET: the app manifest (`AppManifest`), the one an administrator pastes into the core. */
|
|
9
|
+
readonly manifest: '/.well-known/artemis/app.json';
|
|
10
|
+
/** GET: the app icon (SVG), shown by the core's app switcher. */
|
|
11
|
+
readonly icon: '/.well-known/artemis/icon.svg';
|
|
12
|
+
/**
|
|
13
|
+
* POST: the core pushes security events here (RFC 8935: `Content-Type:
|
|
14
|
+
* application/secevent+jwt`, a signed Security Event Token as body, `202` once handled).
|
|
15
|
+
*/
|
|
16
|
+
readonly events: '/.well-known/artemis/events';
|
|
17
|
+
/** GET: session state for the app web client (`AppSessionState`). */
|
|
18
|
+
readonly session: '/api/platform/session';
|
|
19
|
+
/** GET: starts the OAuth sign-in flow (accepts `RETURN_TO_PARAM`). */
|
|
20
|
+
readonly signIn: '/api/platform/sign-in';
|
|
21
|
+
/** GET: the OAuth redirect URI. */
|
|
22
|
+
readonly callback: '/api/platform/callback';
|
|
23
|
+
/** POST: ends the app session (`SignOutResponse`). */
|
|
24
|
+
readonly signOut: '/api/platform/sign-out';
|
|
25
|
+
/** POST `logout_token` (form): OIDC back-channel logout, sent by the core. */
|
|
26
|
+
readonly backChannelLogout: '/api/platform/back-channel-logout';
|
|
27
|
+
/**
|
|
28
|
+
* Any method: the relay to the core's API for the app's web client. `<relay>/<path>` is
|
|
29
|
+
* forwarded to the core's `/api/<path>` with the session's access token, for the paths of
|
|
30
|
+
* `CORE_RELAYED_PATHS` only; the request and the answer pass through as they are.
|
|
31
|
+
*/
|
|
32
|
+
readonly coreRelay: '/api/core';
|
|
33
|
+
/**
|
|
34
|
+
* What the app provides (`docs/architecture/entities/`), called by the core only, with a
|
|
35
|
+
* provider token: GET (list) → `ProviderEntityList`; POST (create) → `ProviderEntity`.
|
|
36
|
+
*/
|
|
37
|
+
readonly providedEntities: '/api/platform/entities/:type';
|
|
38
|
+
/** GET (read), PATCH (update) → `ProviderEntity`; DELETE → 204. Called by the core only. */
|
|
39
|
+
readonly providedEntity: '/api/platform/entities/:type/:entityId';
|
|
40
|
+
/** Any method: one of the type's own operations; its answer passes through the core. */
|
|
41
|
+
readonly providedOperation: '/api/platform/entities/:type/:entityId/operations/:operation';
|
|
42
|
+
/**
|
|
43
|
+
* A web page of an app handling an action on entities of a type (`handles`): other apps' web
|
|
44
|
+
* clients send people there, the entity named in the query (`formatHandleQuery`).
|
|
45
|
+
*/
|
|
46
|
+
readonly handle: '/handle/:type/:action';
|
|
47
|
+
/**
|
|
48
|
+
* POST `HandledActionCall` → the action's answer (a picture, for `preview`): a `server`
|
|
49
|
+
* action of the app, called by the core only, with a token it signed for this app.
|
|
50
|
+
*/
|
|
51
|
+
readonly handledAction: '/api/platform/handlers/:type/:action';
|
|
52
|
+
};
|
|
53
|
+
export type AppProtocolPath = (typeof APP_PROTOCOL_PATHS)[keyof typeof APP_PROTOCOL_PATHS];
|
|
54
|
+
/** Conventions of the core that apps rely on. Paths are relative to the core URL. */
|
|
55
|
+
export declare const CORE_PROTOCOL_PATHS: {
|
|
56
|
+
/** Page where the signed-in account manages itself (profile, password). */
|
|
57
|
+
readonly accountPage: '/account';
|
|
58
|
+
/** OAuth / OpenID Connect issuer; discovery lives at `<issuer>/.well-known/openid-configuration`. */
|
|
59
|
+
readonly oidcIssuer: '/oidc';
|
|
60
|
+
/**
|
|
61
|
+
* RP-initiated logout (under the issuer): ends the core's OIDC session and tells every app the
|
|
62
|
+
* browser signed in to (back-channel logout).
|
|
63
|
+
*/
|
|
64
|
+
readonly endSession: '/oidc/session/end';
|
|
65
|
+
};
|
|
66
|
+
/** The OAuth issuer identifier of a core. */
|
|
67
|
+
export declare function coreIssuerUrl(coreUrl: string): string;
|
|
68
|
+
/** An app id: also its OAuth `client_id` and the owner of its cookies. */
|
|
69
|
+
export declare const AppIdSchema: z.ZodString;
|
|
70
|
+
/** The only signing algorithm of the platform's clients (`private_key_jwt`). */
|
|
71
|
+
export declare const APP_KEY_ALGORITHM = "ES256";
|
|
72
|
+
/**
|
|
73
|
+
* A public signing key of an app (JWK, EC P-256). Strict: a key carrying private parts (`d`)
|
|
74
|
+
* is refused, so a private key can never be published by mistake.
|
|
75
|
+
*/
|
|
76
|
+
export declare const AppPublicKeySchema: z.ZodObject<{
|
|
77
|
+
kty: z.ZodLiteral<"EC">;
|
|
78
|
+
crv: z.ZodLiteral<"P-256">;
|
|
79
|
+
x: z.ZodString;
|
|
80
|
+
y: z.ZodString;
|
|
81
|
+
kid: z.ZodString;
|
|
82
|
+
alg: z.ZodLiteral<"ES256">;
|
|
83
|
+
use: z.ZodLiteral<"sig">;
|
|
84
|
+
}, z.core.$strict>;
|
|
85
|
+
export type AppPublicKey = z.infer<typeof AppPublicKeySchema>;
|
|
86
|
+
/**
|
|
87
|
+
* A path from an app's root (`/icons/document.svg`): the core makes it absolute. Never `//`
|
|
88
|
+
* first: that names another host (`//internal-host/x`), which the core would then fetch.
|
|
89
|
+
*/
|
|
90
|
+
export declare const AppPathSchema: z.ZodString;
|
|
91
|
+
/**
|
|
92
|
+
* A kind of entity an app supports (`kinds` of its manifest), from its type's vocabulary: its
|
|
93
|
+
* icon, and the blank `template` new entities of the kind start from, when the app offers one.
|
|
94
|
+
* Paths are from the app's root. Office supports a `drive.item` of kind `document`: its icon is
|
|
95
|
+
* `/icons/document.svg`, a new one is a copy of `/templates/document.docx`.
|
|
96
|
+
*/
|
|
97
|
+
export declare const SupportedKindSchema: z.ZodObject<{
|
|
98
|
+
kind: z.ZodString;
|
|
99
|
+
icon: z.ZodString;
|
|
100
|
+
template: z.ZodOptional<z.ZodString>;
|
|
101
|
+
}, z.core.$strict>;
|
|
102
|
+
export type SupportedKind = z.infer<typeof SupportedKindSchema>;
|
|
103
|
+
/** What an app declares about itself in code; the platform completes it into its `AppManifest`. */
|
|
104
|
+
export declare const AppManifestDeclarationSchema: z.ZodObject<{
|
|
105
|
+
id: z.ZodString;
|
|
106
|
+
name: z.ZodString;
|
|
107
|
+
description: z.ZodOptional<z.ZodString>;
|
|
108
|
+
permissions: z.ZodArray<z.ZodType<import("./permissions.ts").DelegablePermission, string, z.core.$ZodTypeInternals<import("./permissions.ts").DelegablePermission, string>>>;
|
|
109
|
+
types: z.ZodArray<z.ZodObject<{
|
|
110
|
+
id: z.ZodString;
|
|
111
|
+
version: z.ZodInt;
|
|
112
|
+
parent: z.ZodNullable<z.ZodString>;
|
|
113
|
+
titleFields: z.ZodArray<z.ZodString>;
|
|
114
|
+
schema: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
115
|
+
permissions: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>;
|
|
116
|
+
operations: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
117
|
+
kinds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
118
|
+
actions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
119
|
+
permission: z.ZodString;
|
|
120
|
+
target: z.ZodEnum<{
|
|
121
|
+
page: "page";
|
|
122
|
+
server: "server";
|
|
123
|
+
}>;
|
|
124
|
+
}, z.core.$strict>>>;
|
|
125
|
+
messages: z.ZodRecord<z.ZodEnum<{
|
|
126
|
+
en: "en";
|
|
127
|
+
fr: "fr";
|
|
128
|
+
}> & z.core.$partial, z.ZodObject<{
|
|
129
|
+
name: z.ZodString;
|
|
130
|
+
plural: z.ZodString;
|
|
131
|
+
permissions: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
132
|
+
label: z.ZodString;
|
|
133
|
+
description: z.ZodString;
|
|
134
|
+
}, z.core.$strip>>;
|
|
135
|
+
operations: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
136
|
+
kinds: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
137
|
+
actions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
138
|
+
}, z.core.$strip>>;
|
|
139
|
+
}, z.core.$strict>>;
|
|
140
|
+
listed: z.ZodOptional<z.ZodBoolean>;
|
|
141
|
+
kinds: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
|
|
142
|
+
kind: z.ZodString;
|
|
143
|
+
icon: z.ZodString;
|
|
144
|
+
template: z.ZodOptional<z.ZodString>;
|
|
145
|
+
}, z.core.$strict>>>>;
|
|
146
|
+
handles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>>;
|
|
147
|
+
}, z.core.$strip>;
|
|
148
|
+
export type AppManifestDeclaration = z.infer<typeof AppManifestDeclarationSchema>;
|
|
149
|
+
/** What an app provides of one type: the operations it implements (`list` and `read` at least). */
|
|
150
|
+
export declare const ProvidedTypeSchema: z.ZodObject<{
|
|
151
|
+
operations: z.ZodArray<z.ZodString>;
|
|
152
|
+
}, z.core.$strict>;
|
|
153
|
+
export type ProvidedType = z.infer<typeof ProvidedTypeSchema>;
|
|
154
|
+
/** Everything a core needs to enroll an app: an administrator pastes it into the core. */
|
|
155
|
+
export declare const AppManifestSchema: z.ZodObject<{
|
|
156
|
+
id: z.ZodString;
|
|
157
|
+
name: z.ZodString;
|
|
158
|
+
description: z.ZodOptional<z.ZodString>;
|
|
159
|
+
permissions: z.ZodArray<z.ZodType<import("./permissions.ts").DelegablePermission, string, z.core.$ZodTypeInternals<import("./permissions.ts").DelegablePermission, string>>>;
|
|
160
|
+
types: z.ZodArray<z.ZodObject<{
|
|
161
|
+
id: z.ZodString;
|
|
162
|
+
version: z.ZodInt;
|
|
163
|
+
parent: z.ZodNullable<z.ZodString>;
|
|
164
|
+
titleFields: z.ZodArray<z.ZodString>;
|
|
165
|
+
schema: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
166
|
+
permissions: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>;
|
|
167
|
+
operations: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
168
|
+
kinds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
169
|
+
actions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
170
|
+
permission: z.ZodString;
|
|
171
|
+
target: z.ZodEnum<{
|
|
172
|
+
page: "page";
|
|
173
|
+
server: "server";
|
|
174
|
+
}>;
|
|
175
|
+
}, z.core.$strict>>>;
|
|
176
|
+
messages: z.ZodRecord<z.ZodEnum<{
|
|
177
|
+
en: "en";
|
|
178
|
+
fr: "fr";
|
|
179
|
+
}> & z.core.$partial, z.ZodObject<{
|
|
180
|
+
name: z.ZodString;
|
|
181
|
+
plural: z.ZodString;
|
|
182
|
+
permissions: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
183
|
+
label: z.ZodString;
|
|
184
|
+
description: z.ZodString;
|
|
185
|
+
}, z.core.$strip>>;
|
|
186
|
+
operations: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
187
|
+
kinds: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
188
|
+
actions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
189
|
+
}, z.core.$strip>>;
|
|
190
|
+
}, z.core.$strict>>;
|
|
191
|
+
listed: z.ZodOptional<z.ZodBoolean>;
|
|
192
|
+
kinds: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
|
|
193
|
+
kind: z.ZodString;
|
|
194
|
+
icon: z.ZodString;
|
|
195
|
+
template: z.ZodOptional<z.ZodString>;
|
|
196
|
+
}, z.core.$strict>>>>;
|
|
197
|
+
handles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>>;
|
|
198
|
+
url: z.ZodURL;
|
|
199
|
+
provides: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
200
|
+
operations: z.ZodArray<z.ZodString>;
|
|
201
|
+
}, z.core.$strict>>;
|
|
202
|
+
jwks: z.ZodObject<{
|
|
203
|
+
keys: z.ZodArray<z.ZodObject<{
|
|
204
|
+
kty: z.ZodLiteral<"EC">;
|
|
205
|
+
crv: z.ZodLiteral<"P-256">;
|
|
206
|
+
x: z.ZodString;
|
|
207
|
+
y: z.ZodString;
|
|
208
|
+
kid: z.ZodString;
|
|
209
|
+
alg: z.ZodLiteral<"ES256">;
|
|
210
|
+
use: z.ZodLiteral<"sig">;
|
|
211
|
+
}, z.core.$strict>>;
|
|
212
|
+
}, z.core.$strict>;
|
|
213
|
+
}, z.core.$strict>;
|
|
214
|
+
/** What makes a manifest's types, permissions and provided types inconsistent (none: valid). */
|
|
215
|
+
export declare function manifestProblems(manifest: {
|
|
216
|
+
permissions: readonly string[];
|
|
217
|
+
types: readonly z.infer<typeof EntityTypeDefinitionSchema>[];
|
|
218
|
+
provides: Record<string, ProvidedType>;
|
|
219
|
+
kinds?: Record<string, readonly SupportedKind[]>;
|
|
220
|
+
handles?: Record<string, Record<string, readonly string[]>>;
|
|
221
|
+
}): string[];
|
|
222
|
+
export type AppManifest = z.infer<typeof AppManifestSchema>;
|
|
223
|
+
/**
|
|
224
|
+
* Security events the core pushes to apps (RFC 8417 Security Event Tokens), by event type
|
|
225
|
+
* URI. Each token carries exactly one event, about its `sub`.
|
|
226
|
+
*/
|
|
227
|
+
export declare const SECURITY_EVENTS: {
|
|
228
|
+
/** `sub` is the deleted account: the app forgets it. */
|
|
229
|
+
readonly accountDeleted: 'urn:artemis:event:account-deleted';
|
|
230
|
+
/** `sub` is the app: the core revoked it, it is unenrolled. */
|
|
231
|
+
readonly appRevoked: 'urn:artemis:event:app-revoked';
|
|
232
|
+
};
|
|
233
|
+
export type SecurityEvent = (typeof SECURITY_EVENTS)[keyof typeof SECURITY_EVENTS];
|
|
234
|
+
export declare const SecurityEventSchema: z.ZodEnum<{
|
|
235
|
+
"urn:artemis:event:account-deleted": "urn:artemis:event:account-deleted";
|
|
236
|
+
"urn:artemis:event:app-revoked": "urn:artemis:event:app-revoked";
|
|
237
|
+
}>;
|
|
238
|
+
/** The JWT `typ` of Security Event Tokens (RFC 8417). */
|
|
239
|
+
export declare const SECURITY_EVENT_TOKEN_TYPE = "secevent+jwt";
|
|
240
|
+
/** The `Content-Type` of a pushed Security Event Token (RFC 8935). */
|
|
241
|
+
export declare const SECURITY_EVENT_CONTENT_TYPE = "application/secevent+jwt";
|
|
242
|
+
export declare class InvalidAppUrlError extends Error {
|
|
243
|
+
readonly name = "InvalidAppUrlError";
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* An app is identified by its URL: an origin (scheme + host + port), alone or followed by the
|
|
247
|
+
* base path it lives under (`https://example.com/apps/drive`, when a gateway serves several apps
|
|
248
|
+
* on one host). Never a trailing slash, a query or a fragment.
|
|
249
|
+
* Throws `InvalidAppUrlError` for anything else (credentials, non-http schemes...).
|
|
250
|
+
*/
|
|
251
|
+
export declare function normalizeAppUrl(input: string): string;
|
|
252
|
+
/** The base path of an app URL: `''` for an app at the root of its origin, else `/apps/drive`. */
|
|
253
|
+
export declare function appBasePath(appUrl: string): string;
|
|
254
|
+
export declare function isLoopbackUrl(url: string): boolean;
|
|
255
|
+
/**
|
|
256
|
+
* Whether `url` lies at or under the app URL `appUrl` (same origin, within its base path).
|
|
257
|
+
* `https://x.com/apps/drive` holds `https://x.com/apps/drive/api`, not `https://x.com/apps/drivex`.
|
|
258
|
+
*/
|
|
259
|
+
export declare function isWithinAppUrl(url: string, appUrl: string): boolean;
|
|
260
|
+
/**
|
|
261
|
+
* An address on the app, from a path of its root (under its base path, if any). Throws for a
|
|
262
|
+
* path leading off the app (another origin, `..` out of its base path): whatever an app declares,
|
|
263
|
+
* the core only ever calls the app itself.
|
|
264
|
+
*/
|
|
265
|
+
export declare function appEndpoint(appUrl: string, path: string): string;
|
|
266
|
+
/** Redirect URI registered for an enrolled app. Derived from the convention, never declared. */
|
|
267
|
+
export declare function appRedirectUri(appUrl: string): string;
|
|
268
|
+
/**
|
|
269
|
+
* The query of a handle page (`APP_PROTOCOL_PATHS.handle`): the entity the action is about, the
|
|
270
|
+
* share it is reached through, and its kind.
|
|
271
|
+
*/
|
|
272
|
+
export declare const HANDLE_PARAMS: {
|
|
273
|
+
readonly provider: 'provider';
|
|
274
|
+
readonly owner: 'owner';
|
|
275
|
+
readonly id: 'id';
|
|
276
|
+
/** `<type>:<id>` of the shared entity, when reached through a share. */
|
|
277
|
+
readonly via: 'via';
|
|
278
|
+
readonly kind: 'kind';
|
|
279
|
+
};
|
|
280
|
+
export interface HandleTarget {
|
|
281
|
+
providerId: string;
|
|
282
|
+
ownerId: string;
|
|
283
|
+
id: string;
|
|
284
|
+
/** `<type>:<id>`, as `formatPointer` writes it, or `null`. */
|
|
285
|
+
via: string | null;
|
|
286
|
+
kind: string;
|
|
287
|
+
}
|
|
288
|
+
export declare function formatHandleQuery({ providerId, ownerId, id, via, kind }: HandleTarget): string;
|
|
289
|
+
/** Reads a handle page's query back; `undefined` when it names no entity. */
|
|
290
|
+
export declare function parseHandleQuery(query: URLSearchParams): HandleTarget | undefined;
|