wip
This commit is contained in:
@@ -2341,7 +2341,113 @@ export const endpoints = {
|
||||
$ref: 'https://misskey-hub.net/api/schemas/App',
|
||||
},
|
||||
}],
|
||||
}
|
||||
},
|
||||
//#endregion
|
||||
|
||||
//#region auth
|
||||
'auth/session/genrate': {
|
||||
tags: ['auth'],
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
errors: {
|
||||
noSuchApp: {
|
||||
message: 'No such app.',
|
||||
code: 'NO_SUCH_APP',
|
||||
id: '92f93e63-428e-4f2f-a5a4-39e1407fe998',
|
||||
},
|
||||
},
|
||||
|
||||
defines: [{
|
||||
req: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
appSecret: { type: 'string' },
|
||||
},
|
||||
required: ['appSecret'],
|
||||
},
|
||||
res: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
token: { type: 'string' },
|
||||
url: { type: 'string', format: 'url' },
|
||||
},
|
||||
required: ['token', 'url'],
|
||||
},
|
||||
}],
|
||||
},
|
||||
'auth/session/show': {
|
||||
tags: ['auth'],
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
errors: {
|
||||
noSuchSession: {
|
||||
message: 'No such session.',
|
||||
code: 'NO_SUCH_SESSION',
|
||||
id: 'bd72c97d-eba7-4adb-a467-f171b8847250',
|
||||
},
|
||||
},
|
||||
|
||||
defines: [{
|
||||
req: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
token: { type: 'string' },
|
||||
},
|
||||
required: ['token'],
|
||||
},
|
||||
res: {
|
||||
$ref: 'https://misskey-hub.net/api/schemas/AuthSession',
|
||||
},
|
||||
}],
|
||||
},
|
||||
'auth/session/userkey': {
|
||||
tags: ['auth'],
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
errors: {
|
||||
noSuchApp: {
|
||||
message: 'No such app.',
|
||||
code: 'NO_SUCH_APP',
|
||||
id: 'fcab192a-2c5a-43b7-8ad8-9b7054d8d40d',
|
||||
},
|
||||
|
||||
noSuchSession: {
|
||||
message: 'No such session.',
|
||||
code: 'NO_SUCH_SESSION',
|
||||
id: '5b5a1503-8bc8-4bd0-8054-dc189e8cdcb3',
|
||||
},
|
||||
|
||||
pendingSession: {
|
||||
message: 'This session is not completed yet.',
|
||||
code: 'PENDING_SESSION',
|
||||
id: '8c8a4145-02cc-4cca-8e66-29ba60445a8e',
|
||||
},
|
||||
},
|
||||
|
||||
defines: [{
|
||||
req: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
appSecret: { type: 'string' },
|
||||
token: { type: 'string' },
|
||||
},
|
||||
required: ['appSecret', 'token'],
|
||||
},
|
||||
res: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
accessToken: { type: 'string' },
|
||||
user: {
|
||||
$ref: 'https://misskey-hub.net/api/schemas/UserDetailedNotMe',
|
||||
}
|
||||
},
|
||||
required: ['accessToken', 'user'],
|
||||
}
|
||||
}],
|
||||
},
|
||||
//#endregion
|
||||
} as const satisfies { [x: string]: IEndpointMeta; };
|
||||
|
||||
|
@@ -119,11 +119,7 @@ export type Stats = {
|
||||
driveUsageRemote: number;
|
||||
};
|
||||
|
||||
export type AuthSession = {
|
||||
id: ID;
|
||||
app: App;
|
||||
token: string;
|
||||
};
|
||||
export type AuthSession = Serialized<Packed<'AuthSession'>>;
|
||||
|
||||
export type FollowRequest = {
|
||||
id: ID;
|
||||
|
@@ -56,6 +56,7 @@ import {
|
||||
SignInSchema,
|
||||
} from './schemas/sign-in.js';
|
||||
import { packedModerationLogSchema } from './schemas/moderation-log.js';
|
||||
import { packedAuthSessionSchema } from './schemas/auth-session.js';
|
||||
import { Error, ApiError } from './schemas/error.js';
|
||||
import type { JSONSchema7, JSONSchema7Definition, GetDef, GetRefs, GetKeys, UnionToArray } from 'schema-type';
|
||||
|
||||
@@ -109,6 +110,7 @@ export const refs = {
|
||||
ServerInfoAdmin: ServerInfoAdminSchema,
|
||||
ModerationLog: packedModerationLogSchema,
|
||||
SignIn: SignInSchema,
|
||||
AuthSession: packedAuthSessionSchema,
|
||||
|
||||
Error: Error,
|
||||
ApiError: ApiError,
|
||||
|
19
packages/misskey-js/src/schemas/auth-session.ts
Normal file
19
packages/misskey-js/src/schemas/auth-session.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { JSONSchema7Definition } from 'schema-type';
|
||||
|
||||
export const packedAuthSessionSchema = {
|
||||
$id: 'https://misskey-hub.net/api/schemas/AuthSession',
|
||||
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { $ref: 'https://misskey-hub.net/api/schemas/Id' },
|
||||
app: { $ref: 'https://misskey-hub.net/api/schemas/App' },
|
||||
token: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: [
|
||||
'id',
|
||||
'app',
|
||||
'token',
|
||||
],
|
||||
} as const satisfies JSONSchema7Definition;
|
@@ -1,3 +1,4 @@
|
||||
import { test } from 'node:test';
|
||||
import { Packed, Def } from '../src/schemas';
|
||||
import { expectType } from 'tsd';
|
||||
|
||||
@@ -122,6 +123,9 @@ describe('schemas', () => {
|
||||
test('moderation log', () => {
|
||||
type ModerationLog = Packed<'ModerationLog'>;
|
||||
});
|
||||
test('auth session', () => {
|
||||
type AuthSession = Packed<'AuthSession'>;
|
||||
});
|
||||
test('error', () => {
|
||||
type Error = Packed<'Error'>;
|
||||
type ApiError = Packed<'ApiError'>;
|
||||
|
Reference in New Issue
Block a user