2025-11-21 08:31:02 +01:00
|
|
|
import { z } from "zod";
|
2025-02-05 22:49:07 +01:00
|
|
|
|
2025-03-24 15:25:40 +01:00
|
|
|
export const Application = z
|
|
|
|
|
.object({
|
|
|
|
|
name: z
|
|
|
|
|
.string()
|
|
|
|
|
.trim()
|
|
|
|
|
.min(1)
|
|
|
|
|
.max(200)
|
2025-07-07 03:42:35 +02:00
|
|
|
.meta({
|
2025-03-24 15:25:40 +01:00
|
|
|
description: "The name of your application.",
|
|
|
|
|
example: "Test Application",
|
|
|
|
|
externalDocs: {
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/Application/#name",
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
website: z
|
|
|
|
|
.string()
|
|
|
|
|
.nullable()
|
2025-07-07 03:42:35 +02:00
|
|
|
.meta({
|
2025-03-24 15:25:40 +01:00
|
|
|
description: "The website associated with your application.",
|
|
|
|
|
example: "https://app.example",
|
|
|
|
|
externalDocs: {
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/Application/#website",
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
scopes: z
|
|
|
|
|
.array(z.string())
|
|
|
|
|
.default(["read"])
|
2025-07-07 03:42:35 +02:00
|
|
|
.meta({
|
2025-03-24 15:25:40 +01:00
|
|
|
description:
|
|
|
|
|
"The scopes for your application. This is the registered scopes string split on whitespace.",
|
|
|
|
|
example: ["read", "write", "push"],
|
|
|
|
|
externalDocs: {
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/Application/#scopes",
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
redirect_uris: z
|
|
|
|
|
.array(
|
2025-07-07 03:42:35 +02:00
|
|
|
z.url().or(z.literal("urn:ietf:wg:oauth:2.0:oob")).meta({
|
|
|
|
|
description: "URL or 'urn:ietf:wg:oauth:2.0:oob'",
|
|
|
|
|
}),
|
2025-03-24 15:25:40 +01:00
|
|
|
)
|
2025-07-07 03:42:35 +02:00
|
|
|
.meta({
|
2025-03-24 15:25:40 +01:00
|
|
|
description:
|
|
|
|
|
"The registered redirection URI(s) for your application.",
|
|
|
|
|
externalDocs: {
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/Application/#redirect_uris",
|
|
|
|
|
},
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
redirect_uri: z.string().meta({
|
2025-03-24 15:25:40 +01:00
|
|
|
deprecated: true,
|
2025-02-05 22:49:07 +01:00
|
|
|
description:
|
2025-03-24 15:25:40 +01:00
|
|
|
"The registered redirection URI(s) for your application. May contain \\n characters when multiple redirect URIs are registered.",
|
2025-02-05 22:49:07 +01:00
|
|
|
externalDocs: {
|
2025-03-24 15:25:40 +01:00
|
|
|
url: "https://docs.joinmastodon.org/entities/Application/#redirect_uri",
|
2025-02-05 22:49:07 +01:00
|
|
|
},
|
|
|
|
|
}),
|
2025-03-24 15:25:40 +01:00
|
|
|
})
|
2025-07-07 03:42:35 +02:00
|
|
|
.meta({
|
|
|
|
|
id: "Application",
|
2025-03-29 03:30:06 +01:00
|
|
|
});
|
2025-02-05 22:49:07 +01:00
|
|
|
|
|
|
|
|
export const CredentialApplication = Application.extend({
|
2025-07-07 03:42:35 +02:00
|
|
|
client_id: z.string().meta({
|
2025-02-05 22:49:07 +01:00
|
|
|
description: "Client ID key, to be used for obtaining OAuth tokens",
|
|
|
|
|
externalDocs: {
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/CredentialApplication/#client_id",
|
|
|
|
|
},
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
client_secret: z.string().meta({
|
2025-02-05 22:49:07 +01:00
|
|
|
description: "Client secret key, to be used for obtaining OAuth tokens",
|
|
|
|
|
externalDocs: {
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/CredentialApplication/#client_secret",
|
|
|
|
|
},
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
client_secret_expires_at: z.string().meta({
|
2025-02-05 22:49:07 +01:00
|
|
|
description:
|
|
|
|
|
"When the client secret key will expire at, presently this always returns 0 indicating that OAuth Clients do not expire",
|
|
|
|
|
externalDocs: {
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/CredentialApplication/#client_secret_expires_at",
|
|
|
|
|
},
|
|
|
|
|
}),
|
2025-07-07 03:42:35 +02:00
|
|
|
}).meta({
|
|
|
|
|
id: "CredentialApplication",
|
2025-03-29 03:30:06 +01:00
|
|
|
});
|