@open-pencil/cloud 0.0.0-stage → 0.17.0-beta.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/LICENSE +202 -0
- package/LICENSE-MIT +21 -0
- package/NOTICE +7 -0
- package/README.md +37 -2
- package/dist/bin/ai-relay.d.mts +1 -0
- package/dist/bin/ai-relay.mjs +31 -0
- package/dist/bin/ai-relay.mjs.map +1 -0
- package/dist/bin/server.d.mts +1 -0
- package/dist/bin/server.mjs +29 -0
- package/dist/bin/server.mjs.map +1 -0
- package/dist/client.d.ts +1520 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +1917 -0
- package/dist/client.js.map +1 -0
- package/dist/contract.d.ts +2 -0
- package/dist/contract.js +2 -0
- package/dist/contract2.js +1453 -0
- package/dist/contract2.js.map +1 -0
- package/dist/email.d.ts +169 -0
- package/dist/email.d.ts.map +1 -0
- package/dist/email.js +670 -0
- package/dist/email.js.map +1 -0
- package/dist/index.d.ts +1755 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/listen.mjs +1881 -0
- package/dist/listen.mjs.map +1 -0
- package/dist/runtime-node.d.mts +10040 -0
- package/dist/runtime-node.d.mts.map +1 -0
- package/dist/runtime-node.mjs +32 -0
- package/dist/runtime-node.mjs.map +1 -0
- package/dist/server.d.ts +12792 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +8475 -0
- package/dist/server.js.map +1 -0
- package/dist/server.mjs +8324 -0
- package/dist/server.mjs.map +1 -0
- package/dist/server2.mjs +505 -0
- package/dist/server2.mjs.map +1 -0
- package/package.json +124 -4
- package/src/admin/api/routes.ts +223 -0
- package/src/admin/api/security.ts +12 -0
- package/src/admin/audit/service.ts +138 -0
- package/src/admin/email/service.ts +140 -0
- package/src/admin/enrollment/email.ts +77 -0
- package/src/admin/enrollment/service.ts +308 -0
- package/src/admin/errors.ts +20 -0
- package/src/admin/index.ts +19 -0
- package/src/admin/list.ts +61 -0
- package/src/admin/operations/service.ts +70 -0
- package/src/admin/schema.ts +28 -0
- package/src/admin/users/service.ts +369 -0
- package/src/ai-relay/app.ts +251 -0
- package/src/ai-relay/config.ts +120 -0
- package/src/ai-relay/db/index.ts +10 -0
- package/src/ai-relay/db/migrate.ts +32 -0
- package/src/ai-relay/db/migrations/001_usage.ts +26 -0
- package/src/ai-relay/db/schema.ts +20 -0
- package/src/ai-relay/index.ts +18 -0
- package/src/ai-relay/metering.ts +68 -0
- package/src/ai-relay/usage.ts +115 -0
- package/src/client/ai.ts +96 -0
- package/src/client/api.ts +528 -0
- package/src/client/auth/client.ts +188 -0
- package/src/client/auth/failure.ts +54 -0
- package/src/client/auth/navigation.ts +45 -0
- package/src/client/device-authorization.ts +134 -0
- package/src/client/discovery.ts +105 -0
- package/src/client/images.ts +81 -0
- package/src/client/index.ts +53 -0
- package/src/client/portal/account.ts +183 -0
- package/src/client/portal/administration.ts +130 -0
- package/src/client/portal/client.ts +18 -0
- package/src/client/portal/request.ts +115 -0
- package/src/client/response.ts +51 -0
- package/src/client/workspaces.ts +142 -0
- package/src/contract/account.ts +204 -0
- package/src/contract/admin/index.ts +187 -0
- package/src/contract/ai.ts +150 -0
- package/src/contract/collaboration.ts +45 -0
- package/src/contract/discovery.ts +81 -0
- package/src/contract/documents.ts +265 -0
- package/src/contract/entitlements.ts +28 -0
- package/src/contract/index.ts +204 -0
- package/src/contract/links.ts +87 -0
- package/src/contract/portal.ts +11 -0
- package/src/contract/relay.ts +368 -0
- package/src/contract/sharing.ts +191 -0
- package/src/contract/versions.ts +87 -0
- package/src/contract/workspaces.ts +100 -0
- package/src/email/index.ts +14 -0
- package/src/email/render.ts +276 -0
- package/src/email/schema.ts +144 -0
- package/src/email/templates/brand.ts +105 -0
- package/src/email/templates/document-invitation.ts +35 -0
- package/src/email/templates/enrollment.ts +27 -0
- package/src/email/templates/layout.ts +18 -0
- package/src/runtime/cloudflare/email.ts +70 -0
- package/src/runtime/cloudflare/environment.ts +57 -0
- package/src/runtime/cloudflare/index.ts +3 -0
- package/src/runtime/cloudflare/relay.ts +136 -0
- package/src/runtime/cloudflare/site.ts +13 -0
- package/src/runtime/cloudflare/tsconfig.json +21 -0
- package/src/runtime/cloudflare/worker.ts +160 -0
- package/src/runtime/node/admin.ts +59 -0
- package/src/runtime/node/ai-relay/main.ts +35 -0
- package/src/runtime/node/ai-relay/server.ts +63 -0
- package/src/runtime/node/application.ts +50 -0
- package/src/runtime/node/bootstrap.ts +22 -0
- package/src/runtime/node/cleanup.ts +24 -0
- package/src/runtime/node/command.ts +17 -0
- package/src/runtime/node/config.ts +16 -0
- package/src/runtime/node/email/runtime.ts +43 -0
- package/src/runtime/node/email/transport.ts +112 -0
- package/src/runtime/node/entitlements/main.ts +41 -0
- package/src/runtime/node/entitlements/refusal.ts +15 -0
- package/src/runtime/node/index.ts +25 -0
- package/src/runtime/node/listen.ts +35 -0
- package/src/runtime/node/main.ts +29 -0
- package/src/runtime/node/migrate.ts +13 -0
- package/src/runtime/node/quota-reconcile.ts +9 -0
- package/src/runtime/node/relay.ts +54 -0
- package/src/runtime/node/server.ts +121 -0
- package/src/runtime/node/site.ts +64 -0
- package/src/runtime/postgres/database.ts +19 -0
- package/src/runtime/s3/objects.ts +244 -0
- package/src/runtime/site/server.ts +82 -0
- package/src/server/account/actions.ts +66 -0
- package/src/server/account/routes.ts +300 -0
- package/src/server/ai/errors.ts +7 -0
- package/src/server/ai/index.ts +4 -0
- package/src/server/ai/keys.ts +43 -0
- package/src/server/ai/routes.ts +43 -0
- package/src/server/ai/service.ts +70 -0
- package/src/server/api/index.ts +8 -0
- package/src/server/api/router.ts +117 -0
- package/src/server/api/types.ts +7 -0
- package/src/server/app.ts +375 -0
- package/src/server/auth/account.ts +73 -0
- package/src/server/auth/activity.ts +213 -0
- package/src/server/auth/adapter.ts +79 -0
- package/src/server/auth/email.ts +125 -0
- package/src/server/auth/endpoints.ts +57 -0
- package/src/server/auth/factory.ts +583 -0
- package/src/server/auth/index.ts +17 -0
- package/src/server/auth/mfa-assurance.ts +55 -0
- package/src/server/auth/runtime.ts +26 -0
- package/src/server/auth/session.ts +19 -0
- package/src/server/auth/social-providers.ts +55 -0
- package/src/server/auth/user-agent.ts +16 -0
- package/src/server/auth/workspace-access.ts +23 -0
- package/src/server/cleanup/configured.ts +38 -0
- package/src/server/cleanup/documents.ts +231 -0
- package/src/server/cleanup/index.ts +29 -0
- package/src/server/cleanup/objects.ts +27 -0
- package/src/server/cleanup/revisions.ts +232 -0
- package/src/server/cleanup/uploads.ts +129 -0
- package/src/server/cleanup/worker.ts +79 -0
- package/src/server/collaboration/index.ts +28 -0
- package/src/server/collaboration/relay/authorize.ts +53 -0
- package/src/server/collaboration/relay/awareness.ts +104 -0
- package/src/server/collaboration/relay/documents.ts +39 -0
- package/src/server/collaboration/relay/hub.ts +524 -0
- package/src/server/collaboration/relay/index.ts +15 -0
- package/src/server/collaboration/relay/persistence.ts +48 -0
- package/src/server/collaboration/routes.ts +77 -0
- package/src/server/collaboration/service.ts +188 -0
- package/src/server/config/deployment.ts +178 -0
- package/src/server/config/index.ts +20 -0
- package/src/server/config/limits.ts +8 -0
- package/src/server/config/public.ts +66 -0
- package/src/server/config/schema.ts +512 -0
- package/src/server/db/database.ts +15 -0
- package/src/server/db/expressions.ts +13 -0
- package/src/server/db/index.ts +21 -0
- package/src/server/db/migrate.ts +177 -0
- package/src/server/db/migrations/001_foundation.ts +164 -0
- package/src/server/db/migrations/002_upload_cleanup_claims.ts +34 -0
- package/src/server/db/migrations/003_document_cleanup_claims.ts +23 -0
- package/src/server/db/migrations/004_document_sharing.ts +82 -0
- package/src/server/db/migrations/005_document_collaboration_epoch.ts +13 -0
- package/src/server/db/migrations/006_invitation_continuation.ts +27 -0
- package/src/server/db/migrations/007_collaboration_state.ts +25 -0
- package/src/server/db/migrations/008_storage_reservations.ts +37 -0
- package/src/server/db/migrations/009_workspace_entitlements.ts +22 -0
- package/src/server/db/migrations/010_upload_finalization.ts +22 -0
- package/src/server/db/migrations/011_upload_finalization_lease.ts +12 -0
- package/src/server/db/migrations/012_transactional_email.ts +48 -0
- package/src/server/db/migrations/013_admin_enrollment.ts +54 -0
- package/src/server/db/migrations/014_enrollment_email_kinds.ts +30 -0
- package/src/server/db/migrations/015_cloud_rate_limit.ts +22 -0
- package/src/server/db/migrations/016_auth_schema.ts +16 -0
- package/src/server/db/migrations/017_authentication_email_kinds.ts +32 -0
- package/src/server/db/migrations/018_authentication_mfa.ts +78 -0
- package/src/server/db/migrations/019_better_auth_account_issuer.ts +42 -0
- package/src/server/db/migrations/020_workspace_invitations.ts +57 -0
- package/src/server/db/migrations/021_document_versions.ts +66 -0
- package/src/server/db/migrations/022_entitlement_external_version.ts +17 -0
- package/src/server/db/migrations/023_document_images.ts +61 -0
- package/src/server/db/migrations/024_account_activity.ts +66 -0
- package/src/server/db/migrations/025_table_names.ts +58 -0
- package/src/server/db/migrations/026_user_picture.ts +30 -0
- package/src/server/db/migrations/027_document_kind.ts +19 -0
- package/src/server/db/migrations/helpers.ts +78 -0
- package/src/server/db/tables.ts +394 -0
- package/src/server/documents/access.ts +103 -0
- package/src/server/documents/errors.ts +16 -0
- package/src/server/documents/images.ts +407 -0
- package/src/server/documents/index.ts +14 -0
- package/src/server/documents/limits.ts +57 -0
- package/src/server/documents/repository.ts +141 -0
- package/src/server/documents/routes.ts +239 -0
- package/src/server/documents/service.ts +597 -0
- package/src/server/documents/summary.ts +37 -0
- package/src/server/documents/types.ts +14 -0
- package/src/server/documents/versions/checkpoint.ts +98 -0
- package/src/server/documents/versions/history.ts +25 -0
- package/src/server/documents/versions/index.ts +4 -0
- package/src/server/documents/versions/routes.ts +112 -0
- package/src/server/documents/versions/service.ts +397 -0
- package/src/server/email/crypto.ts +57 -0
- package/src/server/email/index.ts +18 -0
- package/src/server/email/invitations.ts +30 -0
- package/src/server/email/service.ts +245 -0
- package/src/server/email/types.ts +56 -0
- package/src/server/email/worker.ts +33 -0
- package/src/server/index.ts +279 -0
- package/src/server/internal/index.ts +8 -0
- package/src/server/internal/routes.ts +41 -0
- package/src/server/internal/schema.ts +10 -0
- package/src/server/internal/service.ts +44 -0
- package/src/server/invitations/index.ts +6 -0
- package/src/server/invitations/types.ts +30 -0
- package/src/server/objects/index.ts +16 -0
- package/src/server/objects/types.ts +81 -0
- package/src/server/pictures/index.ts +9 -0
- package/src/server/pictures/provider.ts +61 -0
- package/src/server/pictures/routes.ts +21 -0
- package/src/server/pictures/service.ts +235 -0
- package/src/server/policy/configured.ts +23 -0
- package/src/server/policy/database.ts +108 -0
- package/src/server/policy/entitlements.ts +29 -0
- package/src/server/policy/index.ts +17 -0
- package/src/server/policy/keys.ts +23 -0
- package/src/server/policy/policy.ts +117 -0
- package/src/server/policy/provider.ts +67 -0
- package/src/server/policy/schema.ts +69 -0
- package/src/server/policy/service.ts +85 -0
- package/src/server/policy/static.ts +62 -0
- package/src/server/quota/index.ts +7 -0
- package/src/server/quota/reconcile.ts +61 -0
- package/src/server/quota/storage.ts +165 -0
- package/src/server/rate-limit/cleanup.ts +16 -0
- package/src/server/rate-limit/index.ts +12 -0
- package/src/server/rate-limit/keys.ts +38 -0
- package/src/server/rate-limit/middleware.ts +137 -0
- package/src/server/rate-limit/postgres.ts +79 -0
- package/src/server/sharing/access.ts +29 -0
- package/src/server/sharing/actor.ts +12 -0
- package/src/server/sharing/capabilities/service.ts +262 -0
- package/src/server/sharing/continuation.ts +85 -0
- package/src/server/sharing/contracts.ts +80 -0
- package/src/server/sharing/crypto.ts +48 -0
- package/src/server/sharing/document-routes.ts +41 -0
- package/src/server/sharing/errors.ts +12 -0
- package/src/server/sharing/grants/service.ts +79 -0
- package/src/server/sharing/http.ts +41 -0
- package/src/server/sharing/index.ts +39 -0
- package/src/server/sharing/invitations/service.ts +315 -0
- package/src/server/sharing/policy.ts +44 -0
- package/src/server/sharing/routes.ts +251 -0
- package/src/server/sharing/service.ts +117 -0
- package/src/server/validation.ts +24 -0
- package/src/server/worker/interval.ts +23 -0
- package/src/server/worker/periodic.ts +42 -0
- package/src/server/workspaces/index.ts +16 -0
- package/src/server/workspaces/members.ts +502 -0
- package/src/server/workspaces/repository.ts +91 -0
- package/src/server/workspaces/routes.ts +198 -0
- package/src/server/workspaces/service.ts +84 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import * as v from 'valibot'
|
|
2
|
+
|
|
3
|
+
export const CLOUD_PROTOCOL_MAX_UPLOAD_BYTES = 1024 * 1024 * 1024
|
|
4
|
+
|
|
5
|
+
const checksumSchema = v.pipe(v.string(), v.regex(/^[A-Za-z0-9+/]{43}=$/))
|
|
6
|
+
|
|
7
|
+
/** Whether a value is a SHA-256 checksum as the server names stored objects, base64 encoded. */
|
|
8
|
+
export function isCloudChecksum(value: string): boolean {
|
|
9
|
+
return v.is(checksumSchema, value)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** The most images one revision, or one request for image uploads, may name. */
|
|
13
|
+
export const CLOUD_MAX_DOCUMENT_IMAGES = 10_000
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* An image's name inside a `.fig` file that Cloud stores apart from it: the SHA-1 Figma names it
|
|
17
|
+
* by, or an older plain name. A client leaves images under other names inside the file.
|
|
18
|
+
*/
|
|
19
|
+
export const CLOUD_IMAGE_NAME_PATTERN = /^[A-Za-z0-9._-]{1,128}$/
|
|
20
|
+
const imageNameSchema = v.pipe(v.string(), v.regex(CLOUD_IMAGE_NAME_PATTERN))
|
|
21
|
+
|
|
22
|
+
const objectDownloadSchema = v.object({
|
|
23
|
+
url: v.pipe(v.string(), v.url()),
|
|
24
|
+
method: v.literal('GET'),
|
|
25
|
+
headers: v.record(v.string(), v.string()),
|
|
26
|
+
expiresAt: v.string()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
/** An image a stored revision uses, where to download it, and what to check it against. */
|
|
30
|
+
export const documentImageDownloadSchema = v.object({
|
|
31
|
+
name: imageNameSchema,
|
|
32
|
+
checksum: checksumSchema,
|
|
33
|
+
byteSize: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
34
|
+
download: objectDownloadSchema
|
|
35
|
+
})
|
|
36
|
+
export type DocumentImageDownload = v.InferOutput<typeof documentImageDownloadSchema>
|
|
37
|
+
|
|
38
|
+
/** Where to download an image a document uses, found by its checksum. */
|
|
39
|
+
export const documentImageLinkSchema = v.object({
|
|
40
|
+
checksum: checksumSchema,
|
|
41
|
+
byteSize: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
42
|
+
download: objectDownloadSchema
|
|
43
|
+
})
|
|
44
|
+
export type DocumentImageLink = v.InferOutput<typeof documentImageLinkSchema>
|
|
45
|
+
|
|
46
|
+
/** The images a live room names, by checksum, that a peer needs links for. */
|
|
47
|
+
export const requestImageLinksSchema = v.object({
|
|
48
|
+
checksums: v.pipe(v.array(checksumSchema), v.minLength(1), v.maxLength(CLOUD_MAX_DOCUMENT_IMAGES))
|
|
49
|
+
})
|
|
50
|
+
export type RequestImageLinksInput = v.InferOutput<typeof requestImageLinksSchema>
|
|
51
|
+
|
|
52
|
+
export const documentPermissionSchema = v.picklist(['view', 'edit'])
|
|
53
|
+
export type DocumentPermission = v.InferOutput<typeof documentPermissionSchema>
|
|
54
|
+
|
|
55
|
+
export const documentAccessSourceSchema = v.picklist(['owner', 'workspace', 'direct-grant'])
|
|
56
|
+
export type DocumentAccessSource = v.InferOutput<typeof documentAccessSourceSchema>
|
|
57
|
+
|
|
58
|
+
export const documentAccessSchema = v.object({
|
|
59
|
+
permission: documentPermissionSchema,
|
|
60
|
+
canManageSharing: v.boolean(),
|
|
61
|
+
sources: v.array(documentAccessSourceSchema)
|
|
62
|
+
})
|
|
63
|
+
export type DocumentAccess = v.InferOutput<typeof documentAccessSchema>
|
|
64
|
+
|
|
65
|
+
/** What a document is: a Figma design or a FigJam board, which the file it stores says too. */
|
|
66
|
+
export const documentKindSchema = v.picklist(['design', 'board'])
|
|
67
|
+
export type CloudDocumentKind = v.InferOutput<typeof documentKindSchema>
|
|
68
|
+
|
|
69
|
+
export const documentSummarySchema = v.object({
|
|
70
|
+
id: v.pipe(v.string(), v.uuid()),
|
|
71
|
+
workspaceId: v.pipe(v.string(), v.uuid()),
|
|
72
|
+
name: v.string(),
|
|
73
|
+
/** A design unless said otherwise; servers from before boards list no kind. */
|
|
74
|
+
kind: v.optional(documentKindSchema, 'design'),
|
|
75
|
+
currentRevisionId: v.nullable(v.pipe(v.string(), v.uuid())),
|
|
76
|
+
version: v.number(),
|
|
77
|
+
createdAt: v.string(),
|
|
78
|
+
updatedAt: v.string()
|
|
79
|
+
})
|
|
80
|
+
export type DocumentSummary = v.InferOutput<typeof documentSummarySchema>
|
|
81
|
+
|
|
82
|
+
/** A document someone granted the person directly, in a workspace they are not a member of. */
|
|
83
|
+
export const sharedDocumentSchema = v.object({
|
|
84
|
+
...documentSummarySchema.entries,
|
|
85
|
+
workspaceName: v.string(),
|
|
86
|
+
permission: documentPermissionSchema,
|
|
87
|
+
sharedBy: v.nullable(v.object({ name: v.string() })),
|
|
88
|
+
sharedAt: v.string()
|
|
89
|
+
})
|
|
90
|
+
export type SharedDocument = v.InferOutput<typeof sharedDocumentSchema>
|
|
91
|
+
|
|
92
|
+
export const documentDownloadSchema = v.object({
|
|
93
|
+
document: documentSummarySchema,
|
|
94
|
+
revisionId: v.pipe(v.string(), v.uuid()),
|
|
95
|
+
byteSize: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
96
|
+
checksum: checksumSchema,
|
|
97
|
+
contentType: v.string(),
|
|
98
|
+
download: objectDownloadSchema,
|
|
99
|
+
/** The images the stored file leaves out, which a client puts back under their names. */
|
|
100
|
+
images: v.pipe(v.array(documentImageDownloadSchema), v.maxLength(CLOUD_MAX_DOCUMENT_IMAGES))
|
|
101
|
+
})
|
|
102
|
+
export type DocumentDownload = v.InferOutput<typeof documentDownloadSchema>
|
|
103
|
+
|
|
104
|
+
export const cloudActorSchema = v.object({
|
|
105
|
+
userId: v.string(),
|
|
106
|
+
email: v.pipe(v.string(), v.email()),
|
|
107
|
+
name: v.string()
|
|
108
|
+
})
|
|
109
|
+
export type CloudActorContract = v.InferOutput<typeof cloudActorSchema>
|
|
110
|
+
|
|
111
|
+
export const cloudSessionSchema = v.object({ user: cloudActorSchema })
|
|
112
|
+
export type CloudSession = v.InferOutput<typeof cloudSessionSchema>
|
|
113
|
+
|
|
114
|
+
export const workspaceUsageSchema = v.object({
|
|
115
|
+
bytesUsed: v.pipe(v.number(), v.integer(), v.minValue(0)),
|
|
116
|
+
objectCount: v.pipe(v.number(), v.integer(), v.minValue(0)),
|
|
117
|
+
documentCount: v.pipe(v.number(), v.integer(), v.minValue(0))
|
|
118
|
+
})
|
|
119
|
+
export type WorkspaceUsage = v.InferOutput<typeof workspaceUsageSchema>
|
|
120
|
+
|
|
121
|
+
export const CLOUD_DOCUMENT_NAME_MAX_LENGTH = 255
|
|
122
|
+
|
|
123
|
+
export const createDocumentSchema = v.object({
|
|
124
|
+
id: v.optional(v.pipe(v.string(), v.uuid())),
|
|
125
|
+
name: v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(CLOUD_DOCUMENT_NAME_MAX_LENGTH)),
|
|
126
|
+
/** A design unless said otherwise; older clients create only designs. */
|
|
127
|
+
kind: v.optional(documentKindSchema, 'design')
|
|
128
|
+
})
|
|
129
|
+
export type CreateDocumentInput = v.InferOutput<typeof createDocumentSchema>
|
|
130
|
+
/** A new document as a client sends it, which may leave out its kind to make a design. */
|
|
131
|
+
export type CreateDocumentRequest = v.InferInput<typeof createDocumentSchema>
|
|
132
|
+
|
|
133
|
+
export const createUploadSchema = v.object({
|
|
134
|
+
baseRevisionId: v.nullable(v.pipe(v.string(), v.uuid())),
|
|
135
|
+
byteSize: v.pipe(
|
|
136
|
+
v.number(),
|
|
137
|
+
v.integer(),
|
|
138
|
+
v.minValue(1),
|
|
139
|
+
v.maxValue(CLOUD_PROTOCOL_MAX_UPLOAD_BYTES)
|
|
140
|
+
),
|
|
141
|
+
checksum: checksumSchema,
|
|
142
|
+
contentType: v.literal('application/octet-stream')
|
|
143
|
+
})
|
|
144
|
+
export type CreateUploadInput = v.InferOutput<typeof createUploadSchema>
|
|
145
|
+
|
|
146
|
+
const imageSizeSchema = v.pipe(
|
|
147
|
+
v.number(),
|
|
148
|
+
v.integer(),
|
|
149
|
+
v.minValue(1),
|
|
150
|
+
v.maxValue(CLOUD_PROTOCOL_MAX_UPLOAD_BYTES)
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
/** Where a client puts an object: one presigned PUT, or the parts of a multipart upload. */
|
|
154
|
+
export const objectUploadSchema = v.variant('kind', [
|
|
155
|
+
v.object({
|
|
156
|
+
kind: v.literal('single'),
|
|
157
|
+
url: v.pipe(v.string(), v.url()),
|
|
158
|
+
method: v.literal('PUT'),
|
|
159
|
+
headers: v.record(v.string(), v.string()),
|
|
160
|
+
expiresAt: v.string()
|
|
161
|
+
}),
|
|
162
|
+
v.object({
|
|
163
|
+
kind: v.literal('multipart'),
|
|
164
|
+
uploadId: v.string(),
|
|
165
|
+
partSize: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
166
|
+
parts: v.array(
|
|
167
|
+
v.object({
|
|
168
|
+
partNumber: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
169
|
+
url: v.pipe(v.string(), v.url()),
|
|
170
|
+
method: v.literal('PUT'),
|
|
171
|
+
headers: v.record(v.string(), v.string())
|
|
172
|
+
})
|
|
173
|
+
),
|
|
174
|
+
expiresAt: v.string()
|
|
175
|
+
})
|
|
176
|
+
])
|
|
177
|
+
export type ObjectUploadTarget = v.InferOutput<typeof objectUploadSchema>
|
|
178
|
+
|
|
179
|
+
/** An upload the server offers for an image the workspace lacks. */
|
|
180
|
+
export const imageUploadOfferSchema = v.object({
|
|
181
|
+
checksum: checksumSchema,
|
|
182
|
+
uploadId: v.pipe(v.string(), v.uuid()),
|
|
183
|
+
upload: objectUploadSchema
|
|
184
|
+
})
|
|
185
|
+
export type ImageUploadOffer = v.InferOutput<typeof imageUploadOfferSchema>
|
|
186
|
+
|
|
187
|
+
/** The images a save will refer to; the server answers with uploads for those it lacks. */
|
|
188
|
+
export const requestImageUploadsSchema = v.object({
|
|
189
|
+
images: v.pipe(
|
|
190
|
+
v.array(v.object({ checksum: checksumSchema, byteSize: imageSizeSchema })),
|
|
191
|
+
v.minLength(1),
|
|
192
|
+
v.maxLength(CLOUD_MAX_DOCUMENT_IMAGES)
|
|
193
|
+
)
|
|
194
|
+
})
|
|
195
|
+
export type RequestImageUploadsInput = v.InferOutput<typeof requestImageUploadsSchema>
|
|
196
|
+
|
|
197
|
+
export const completedUploadPartSchema = v.object({
|
|
198
|
+
partNumber: v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(10_000)),
|
|
199
|
+
etag: v.pipe(v.string(), v.minLength(1), v.maxLength(255))
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
export const commitUploadSchema = v.object({
|
|
203
|
+
checksum: checksumSchema,
|
|
204
|
+
/** The document title captured with this revision; omitted by older clients. */
|
|
205
|
+
name: v.optional(createDocumentSchema.entries.name),
|
|
206
|
+
/** What the uploaded file is, which the document takes; omitted by older clients. */
|
|
207
|
+
kind: v.optional(documentKindSchema),
|
|
208
|
+
multipart: v.optional(
|
|
209
|
+
v.object({
|
|
210
|
+
uploadId: v.pipe(v.string(), v.minLength(1)),
|
|
211
|
+
parts: v.pipe(v.array(completedUploadPartSchema), v.minLength(1), v.maxLength(10_000))
|
|
212
|
+
})
|
|
213
|
+
),
|
|
214
|
+
/** The images the uploaded file leaves out, each stored in the workspace or uploaded before. */
|
|
215
|
+
images: v.optional(
|
|
216
|
+
v.pipe(
|
|
217
|
+
v.array(v.object({ name: imageNameSchema, checksum: checksumSchema })),
|
|
218
|
+
v.maxLength(CLOUD_MAX_DOCUMENT_IMAGES)
|
|
219
|
+
),
|
|
220
|
+
[]
|
|
221
|
+
)
|
|
222
|
+
})
|
|
223
|
+
export type CommitUploadInput = v.InferOutput<typeof commitUploadSchema>
|
|
224
|
+
|
|
225
|
+
/** The image uploads a save asked for, committed together once their bytes are in place. */
|
|
226
|
+
export const commitImageUploadsSchema = v.object({
|
|
227
|
+
uploads: v.pipe(
|
|
228
|
+
v.array(
|
|
229
|
+
v.object({
|
|
230
|
+
uploadId: v.pipe(v.string(), v.uuid()),
|
|
231
|
+
checksum: checksumSchema,
|
|
232
|
+
multipart: commitUploadSchema.entries.multipart
|
|
233
|
+
})
|
|
234
|
+
),
|
|
235
|
+
v.minLength(1),
|
|
236
|
+
v.maxLength(CLOUD_MAX_DOCUMENT_IMAGES)
|
|
237
|
+
)
|
|
238
|
+
})
|
|
239
|
+
export type CommitImageUploadsInput = v.InferOutput<typeof commitImageUploadsSchema>
|
|
240
|
+
/** A commit as a client sends it, which may leave out the images a whole file holds itself. */
|
|
241
|
+
export type CommitUploadRequest = v.InferInput<typeof commitUploadSchema>
|
|
242
|
+
|
|
243
|
+
export function parseCreateDocument(input: unknown): CreateDocumentInput {
|
|
244
|
+
return v.parse(createDocumentSchema, input)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function parseCreateUpload(input: unknown): CreateUploadInput {
|
|
248
|
+
return v.parse(createUploadSchema, input)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export function parseRequestImageUploads(input: unknown): RequestImageUploadsInput {
|
|
252
|
+
return v.parse(requestImageUploadsSchema, input)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export function parseCommitImageUploads(input: unknown): CommitImageUploadsInput {
|
|
256
|
+
return v.parse(commitImageUploadsSchema, input)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export function parseRequestImageLinks(input: unknown): RequestImageLinksInput {
|
|
260
|
+
return v.parse(requestImageLinksSchema, input)
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export function parseCommitUpload(input: unknown): CommitUploadInput {
|
|
264
|
+
return v.parse(commitUploadSchema, input)
|
|
265
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as v from 'valibot'
|
|
2
|
+
|
|
3
|
+
export const workspaceEntitlementsSchema = v.object({
|
|
4
|
+
features: v.object({
|
|
5
|
+
links: v.boolean(),
|
|
6
|
+
guestView: v.boolean(),
|
|
7
|
+
guestEdit: v.boolean(),
|
|
8
|
+
guestPresence: v.boolean(),
|
|
9
|
+
collaboration: v.boolean(),
|
|
10
|
+
revisionHistory: v.boolean(),
|
|
11
|
+
// Optional so editors keep reading servers released before the AI service.
|
|
12
|
+
cloudAI: v.optional(v.boolean(), false)
|
|
13
|
+
}),
|
|
14
|
+
limits: v.object({
|
|
15
|
+
maximumFileBytes: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
16
|
+
maximumStorageBytes: v.nullable(v.pipe(v.number(), v.integer(), v.minValue(1))),
|
|
17
|
+
maximumParticipants: v.nullable(v.pipe(v.number(), v.integer(), v.minValue(1))),
|
|
18
|
+
monthlyCreditAllowance: v.optional(
|
|
19
|
+
v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0))),
|
|
20
|
+
null
|
|
21
|
+
)
|
|
22
|
+
}),
|
|
23
|
+
usage: v.object({
|
|
24
|
+
committedStorageBytes: v.pipe(v.number(), v.integer(), v.minValue(0)),
|
|
25
|
+
reservedStorageBytes: v.pipe(v.number(), v.integer(), v.minValue(0))
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
export type WorkspaceEntitlements = v.InferOutput<typeof workspaceEntitlementsSchema>
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
export * from './account'
|
|
2
|
+
export {
|
|
3
|
+
AI_ERROR_STATUS,
|
|
4
|
+
aiCatalogSchema,
|
|
5
|
+
aiCreditBucketSchema,
|
|
6
|
+
aiErrorCodeSchema,
|
|
7
|
+
aiErrorSchema,
|
|
8
|
+
aiModelSchema,
|
|
9
|
+
aiTokenClaimsSchema,
|
|
10
|
+
aiTokenSchema,
|
|
11
|
+
aiUsageEntrySchema,
|
|
12
|
+
aiUsagePageSchema,
|
|
13
|
+
aiUsageQuerySchema,
|
|
14
|
+
aiWalletSchema,
|
|
15
|
+
CLOUD_AI_API_PATHS,
|
|
16
|
+
CLOUD_AI_CONTRACT_VERSION,
|
|
17
|
+
CLOUD_AI_JWKS_PATH,
|
|
18
|
+
CLOUD_AI_TOKEN_AUDIENCE,
|
|
19
|
+
cloudAIDiscoverySchema,
|
|
20
|
+
cloudBillingDiscoverySchema,
|
|
21
|
+
createAITokenSchema,
|
|
22
|
+
parseAIUsageQuery,
|
|
23
|
+
parseCreateAIToken,
|
|
24
|
+
type AICatalog,
|
|
25
|
+
type AICreditBucket,
|
|
26
|
+
type AIError,
|
|
27
|
+
type AIErrorCode,
|
|
28
|
+
type AIModel,
|
|
29
|
+
type AIToken,
|
|
30
|
+
type AITokenClaims,
|
|
31
|
+
type AIUsageEntry,
|
|
32
|
+
type AIUsagePage,
|
|
33
|
+
type AIUsageQuery,
|
|
34
|
+
type AIWallet,
|
|
35
|
+
type CloudAIDiscovery,
|
|
36
|
+
type CloudBillingDiscovery,
|
|
37
|
+
type CreateAITokenInput
|
|
38
|
+
} from './ai'
|
|
39
|
+
export * from './admin'
|
|
40
|
+
export {
|
|
41
|
+
cloudPresenceSchema,
|
|
42
|
+
collaborationPrincipalSchema,
|
|
43
|
+
collaborationTicketSchema,
|
|
44
|
+
type CloudPresence,
|
|
45
|
+
type CollaborationPrincipal,
|
|
46
|
+
type CollaborationTicket
|
|
47
|
+
} from './collaboration'
|
|
48
|
+
export * from './relay'
|
|
49
|
+
export { workspaceEntitlementsSchema, type WorkspaceEntitlements } from './entitlements'
|
|
50
|
+
export {
|
|
51
|
+
CLOUD_DISCOVERY_PATH,
|
|
52
|
+
CLOUD_PROTOCOL_VERSION,
|
|
53
|
+
cloudAuthenticationSchema,
|
|
54
|
+
cloudCapabilitiesSchema,
|
|
55
|
+
cloudDeploymentSchema,
|
|
56
|
+
cloudDiscoverySchema,
|
|
57
|
+
cloudEditorVersionSchema,
|
|
58
|
+
cloudListingSchema,
|
|
59
|
+
cloudServerOrigin,
|
|
60
|
+
parseCloudDiscovery,
|
|
61
|
+
type CloudAuthentication,
|
|
62
|
+
type CloudCapabilities,
|
|
63
|
+
type CloudDeployment,
|
|
64
|
+
type CloudDiscovery,
|
|
65
|
+
type CloudListing
|
|
66
|
+
} from './discovery'
|
|
67
|
+
export {
|
|
68
|
+
CLOUD_DOCUMENT_NAME_MAX_LENGTH,
|
|
69
|
+
CLOUD_IMAGE_NAME_PATTERN,
|
|
70
|
+
CLOUD_MAX_DOCUMENT_IMAGES,
|
|
71
|
+
CLOUD_PROTOCOL_MAX_UPLOAD_BYTES,
|
|
72
|
+
cloudActorSchema,
|
|
73
|
+
cloudSessionSchema,
|
|
74
|
+
commitImageUploadsSchema,
|
|
75
|
+
commitUploadSchema,
|
|
76
|
+
createDocumentSchema,
|
|
77
|
+
createUploadSchema,
|
|
78
|
+
documentAccessSchema,
|
|
79
|
+
documentAccessSourceSchema,
|
|
80
|
+
documentDownloadSchema,
|
|
81
|
+
documentImageDownloadSchema,
|
|
82
|
+
documentImageLinkSchema,
|
|
83
|
+
documentPermissionSchema,
|
|
84
|
+
imageUploadOfferSchema,
|
|
85
|
+
objectUploadSchema,
|
|
86
|
+
documentSummarySchema,
|
|
87
|
+
sharedDocumentSchema,
|
|
88
|
+
type SharedDocument,
|
|
89
|
+
workspaceUsageSchema,
|
|
90
|
+
isCloudChecksum,
|
|
91
|
+
parseCommitImageUploads,
|
|
92
|
+
parseCommitUpload,
|
|
93
|
+
parseCreateDocument,
|
|
94
|
+
parseCreateUpload,
|
|
95
|
+
parseRequestImageLinks,
|
|
96
|
+
parseRequestImageUploads,
|
|
97
|
+
requestImageLinksSchema,
|
|
98
|
+
requestImageUploadsSchema,
|
|
99
|
+
type CloudActorContract,
|
|
100
|
+
type CloudSession,
|
|
101
|
+
type CommitImageUploadsInput,
|
|
102
|
+
type CommitUploadInput,
|
|
103
|
+
type CommitUploadRequest,
|
|
104
|
+
type CreateDocumentRequest,
|
|
105
|
+
type CreateDocumentInput,
|
|
106
|
+
type CreateUploadInput,
|
|
107
|
+
type DocumentAccess,
|
|
108
|
+
type DocumentAccessSource,
|
|
109
|
+
type DocumentDownload,
|
|
110
|
+
type DocumentImageDownload,
|
|
111
|
+
type DocumentImageLink,
|
|
112
|
+
type DocumentPermission,
|
|
113
|
+
type DocumentSummary,
|
|
114
|
+
type RequestImageLinksInput,
|
|
115
|
+
type ImageUploadOffer,
|
|
116
|
+
type ObjectUploadTarget,
|
|
117
|
+
type RequestImageUploadsInput,
|
|
118
|
+
type WorkspaceUsage
|
|
119
|
+
} from './documents'
|
|
120
|
+
export {
|
|
121
|
+
acceptDocumentInvitationSchema,
|
|
122
|
+
cloudUserProfileSchema,
|
|
123
|
+
createInvitationContinuationSchema,
|
|
124
|
+
createDocumentInvitationSchema,
|
|
125
|
+
createDocumentShareSchema,
|
|
126
|
+
acceptedInvitationSchema,
|
|
127
|
+
documentGrantSchema,
|
|
128
|
+
documentInvitationSchema,
|
|
129
|
+
documentShareSchema,
|
|
130
|
+
invitationContinuationSchema,
|
|
131
|
+
invitationPreviewSchema,
|
|
132
|
+
lookupCloudUserSchema,
|
|
133
|
+
parseAcceptDocumentInvitation,
|
|
134
|
+
parseCreateInvitationContinuation,
|
|
135
|
+
parseCreateDocumentInvitation,
|
|
136
|
+
parseCreateDocumentShare,
|
|
137
|
+
parseLookupCloudUser,
|
|
138
|
+
parsePutDocumentGrant,
|
|
139
|
+
parseRequestSharedImageLinks,
|
|
140
|
+
parseResolveDocumentShare,
|
|
141
|
+
parseUpdateDocumentShare,
|
|
142
|
+
putDocumentGrantSchema,
|
|
143
|
+
requestSharedImageLinksSchema,
|
|
144
|
+
resolveDocumentShareSchema,
|
|
145
|
+
resolvedDocumentShareSchema,
|
|
146
|
+
updateDocumentShareSchema,
|
|
147
|
+
type AcceptDocumentInvitationInput,
|
|
148
|
+
type CloudUserProfile,
|
|
149
|
+
type CreateInvitationContinuationInput,
|
|
150
|
+
type CreateDocumentInvitationInput,
|
|
151
|
+
type CreateDocumentShareInput,
|
|
152
|
+
type AcceptedInvitation,
|
|
153
|
+
type DocumentGrant,
|
|
154
|
+
type DocumentInvitation,
|
|
155
|
+
type DocumentShare,
|
|
156
|
+
type InvitationContinuation,
|
|
157
|
+
type InvitationPreview,
|
|
158
|
+
type LookupCloudUserInput,
|
|
159
|
+
type PutDocumentGrantInput,
|
|
160
|
+
type RequestSharedImageLinksInput,
|
|
161
|
+
type ResolveDocumentShareInput,
|
|
162
|
+
type ResolvedDocumentShare,
|
|
163
|
+
type UpdateDocumentShareInput
|
|
164
|
+
} from './sharing'
|
|
165
|
+
export {
|
|
166
|
+
createWorkspaceInvitationSchema,
|
|
167
|
+
createWorkspaceSchema,
|
|
168
|
+
createdWorkspaceInvitationSchema,
|
|
169
|
+
parseCreateWorkspace,
|
|
170
|
+
parseCreateWorkspaceInvitation,
|
|
171
|
+
parseUpdateWorkspace,
|
|
172
|
+
parseUpdateWorkspaceMember,
|
|
173
|
+
updateWorkspaceMemberSchema,
|
|
174
|
+
updateWorkspaceSchema,
|
|
175
|
+
workspaceInvitationSchema,
|
|
176
|
+
workspaceListSchema,
|
|
177
|
+
workspaceMemberSchema,
|
|
178
|
+
workspaceMembersSchema,
|
|
179
|
+
workspaceRoleSchema,
|
|
180
|
+
workspaceSummarySchema,
|
|
181
|
+
type CreateWorkspaceInput,
|
|
182
|
+
type CreateWorkspaceInvitationInput,
|
|
183
|
+
type CreatedWorkspaceInvitation,
|
|
184
|
+
type UpdateWorkspaceInput,
|
|
185
|
+
type UpdateWorkspaceMemberInput,
|
|
186
|
+
type WorkspaceInvitation,
|
|
187
|
+
type WorkspaceList,
|
|
188
|
+
type WorkspaceMember,
|
|
189
|
+
type WorkspaceMembers,
|
|
190
|
+
type WorkspaceRole,
|
|
191
|
+
type WorkspaceSummary
|
|
192
|
+
} from './workspaces'
|
|
193
|
+
export {
|
|
194
|
+
cloudDesktopLinkURL,
|
|
195
|
+
cloudDocumentPath,
|
|
196
|
+
cloudDocumentURL,
|
|
197
|
+
cloudInvitationURL,
|
|
198
|
+
cloudShareURL,
|
|
199
|
+
parseCloudLinkPath,
|
|
200
|
+
type CloudLinkKind,
|
|
201
|
+
type CloudLinkPathKind
|
|
202
|
+
} from './links'
|
|
203
|
+
export { CLOUD_PORTAL_PAGE_ROOTS, isCloudPortalPage } from './portal'
|
|
204
|
+
export * from './versions'
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { encodeParam, parseURL, withFragment, withQuery } from 'ufo'
|
|
2
|
+
|
|
3
|
+
/** The two kinds of Cloud link that carry a secret: invitations and documents shared by link. */
|
|
4
|
+
export type CloudLinkKind = 'invitations' | 'share'
|
|
5
|
+
|
|
6
|
+
/** Every kind of Cloud link: those that carry a secret, and a document's address for members. */
|
|
7
|
+
export type CloudLinkPathKind = CloudLinkKind | 'documents'
|
|
8
|
+
|
|
9
|
+
const CLOUD_LINK_PATH = /^\/(invitations|share|documents)\/([^/]+)$/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A link on the server's own editor. The server is the link's own address, so the link needs
|
|
13
|
+
* nothing else to name it; a secret travels in the fragment, so it never reaches access logs or
|
|
14
|
+
* `Referer` headers.
|
|
15
|
+
*/
|
|
16
|
+
function serverLink(
|
|
17
|
+
serverURL: string,
|
|
18
|
+
path: string,
|
|
19
|
+
query: Record<string, string | undefined> = {},
|
|
20
|
+
secret?: string
|
|
21
|
+
): string {
|
|
22
|
+
const { protocol, host } = parseURL(serverURL)
|
|
23
|
+
if (protocol !== 'https:' && protocol !== 'http:') {
|
|
24
|
+
throw new Error('A Cloud server address must use HTTP or HTTPS')
|
|
25
|
+
}
|
|
26
|
+
const link = withQuery(`${protocol}//${host}${path}`, query)
|
|
27
|
+
return secret ? withFragment(link, secret) : link
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** An invitation to a document or a workspace, `/invitations/:id#token`. */
|
|
31
|
+
export function cloudInvitationURL(serverURL: string, invitationId: string, token: string): string {
|
|
32
|
+
return serverLink(serverURL, `/invitations/${encodeParam(invitationId)}`, {}, token)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** A document shared by link, `/share/:id#secret`. */
|
|
36
|
+
export function cloudShareURL(serverURL: string, shareId: string, secret: string): string {
|
|
37
|
+
return serverLink(serverURL, `/share/${encodeParam(shareId)}`, {}, secret)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A document's address for its members, `/documents/:id`, or one of its versions with
|
|
42
|
+
* `?version=…`. It carries no secret: whoever opens it signs in, and the server decides.
|
|
43
|
+
*/
|
|
44
|
+
export function cloudDocumentURL(
|
|
45
|
+
serverURL: string,
|
|
46
|
+
documentId: string,
|
|
47
|
+
versionId: string | null = null
|
|
48
|
+
): string {
|
|
49
|
+
return serverLink(serverURL, cloudDocumentPath(documentId), {
|
|
50
|
+
version: versionId ?? undefined
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function cloudDocumentPath(documentId: string): string {
|
|
55
|
+
return `/documents/${encodeParam(documentId)}`
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The kind and ID of a Cloud link's path, or null for any other path. The ID is decoded; a broken
|
|
60
|
+
* escape such as `%E0` is no link.
|
|
61
|
+
*/
|
|
62
|
+
export function parseCloudLinkPath(
|
|
63
|
+
pathname: string
|
|
64
|
+
): { kind: CloudLinkPathKind; id: string } | null {
|
|
65
|
+
const [, kind, id] = pathname.match(CLOUD_LINK_PATH) ?? []
|
|
66
|
+
if ((kind !== 'invitations' && kind !== 'share' && kind !== 'documents') || !id) return null
|
|
67
|
+
try {
|
|
68
|
+
return { kind, id: decodeURIComponent(id) }
|
|
69
|
+
} catch {
|
|
70
|
+
return null
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The desktop app's form of a Cloud link, `openpencil://cloud?url=<link>#secret`: the web link,
|
|
76
|
+
* whose address names the server, with its secret kept in the fragment.
|
|
77
|
+
* `desktop/src/launch/links.rs` validates it before the editor sees it.
|
|
78
|
+
*/
|
|
79
|
+
export function cloudDesktopLinkURL(
|
|
80
|
+
kind: CloudLinkKind,
|
|
81
|
+
id: string,
|
|
82
|
+
serverURL: string,
|
|
83
|
+
secret: string
|
|
84
|
+
): string {
|
|
85
|
+
const link = serverLink(serverURL, `/${kind}/${encodeParam(id)}`)
|
|
86
|
+
return withFragment(withQuery('openpencil://cloud', { url: link }), secret)
|
|
87
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pages a Cloud server shows on its own address, apart from the editor: the welcome page for
|
|
3
|
+
* visitors who are not signed in, sign-in and desktop sign-in approval, account settings, and the
|
|
4
|
+
* administration console. Every runtime serves the portal's `cloud.html` at and below these
|
|
5
|
+
* paths, and the editor's `index.html` at the root and at any other page the API does not answer.
|
|
6
|
+
*/
|
|
7
|
+
export const CLOUD_PORTAL_PAGE_ROOTS = ['/welcome', '/auth', '/account', '/admin'] as const
|
|
8
|
+
|
|
9
|
+
export function isCloudPortalPage(path: string): boolean {
|
|
10
|
+
return CLOUD_PORTAL_PAGE_ROOTS.some((root) => path === root || path.startsWith(`${root}/`))
|
|
11
|
+
}
|