@veruna/api-contracts 22.3.0 → 22.6.0
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/build/locales/en.d.ts +1 -1
- package/build/locales/en.js +1 -1
- package/build/locales/en.js.map +1 -1
- package/build/locales/index.d.ts +2 -2
- package/build/locales/ru.d.ts +1 -1
- package/build/locales/ru.js +1 -1
- package/build/locales/ru.js.map +1 -1
- package/build/locales/validation.d.ts +0 -2
- package/build/locales/validation.js +0 -2
- package/build/locales/validation.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/v1/client-file/client-file-extensions.d.ts +21 -0
- package/build/v1/client-file/client-file-extensions.js +194 -0
- package/build/v1/client-file/client-file-extensions.js.map +1 -0
- package/build/v1/client-file/index.d.ts +1 -0
- package/build/v1/client-file/index.js +1 -0
- package/build/v1/client-file/index.js.map +1 -1
- package/build/v1/client-file/schemas/upload-magic-type.enum.d.ts +3 -0
- package/build/v1/client-file/schemas/upload-magic-type.enum.js +3 -0
- package/build/v1/client-file/schemas/upload-magic-type.enum.js.map +1 -1
- package/build/v1/client-file/upload-magic-bytes.d.ts +15 -23
- package/build/v1/client-file/upload-magic-bytes.js +75 -37
- package/build/v1/client-file/upload-magic-bytes.js.map +1 -1
- package/build/v1/message/schemas/create-message-request.schema.js +2 -4
- package/build/v1/message/schemas/create-message-request.schema.js.map +1 -1
- package/build/v1/s2s/commands/upload-ai-file.command.d.ts +1 -0
- package/build/v1/s2s/schemas/s2s-upload-ai-file-response.schema.d.ts +1 -0
- package/build/v1/s2s/schemas/s2s-upload-ai-file-response.schema.js +1 -0
- package/build/v1/s2s/schemas/s2s-upload-ai-file-response.schema.js.map +1 -1
- package/build-esm/.tsbuildinfo +1 -1
- package/build-esm/locales/en.js +1 -1
- package/build-esm/locales/en.js.map +1 -1
- package/build-esm/locales/ru.js +1 -1
- package/build-esm/locales/ru.js.map +1 -1
- package/build-esm/locales/validation.js +0 -2
- package/build-esm/locales/validation.js.map +1 -1
- package/build-esm/v1/client-file/client-file-extensions.js +189 -0
- package/build-esm/v1/client-file/client-file-extensions.js.map +1 -0
- package/build-esm/v1/client-file/index.js +1 -0
- package/build-esm/v1/client-file/index.js.map +1 -1
- package/build-esm/v1/client-file/schemas/upload-magic-type.enum.js +3 -0
- package/build-esm/v1/client-file/schemas/upload-magic-type.enum.js.map +1 -1
- package/build-esm/v1/client-file/upload-magic-bytes.js +74 -36
- package/build-esm/v1/client-file/upload-magic-bytes.js.map +1 -1
- package/build-esm/v1/message/schemas/create-message-request.schema.js +2 -4
- package/build-esm/v1/message/schemas/create-message-request.schema.js.map +1 -1
- package/build-esm/v1/s2s/schemas/s2s-upload-ai-file-response.schema.js +1 -0
- package/build-esm/v1/s2s/schemas/s2s-upload-ai-file-response.schema.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ClientFileDocMimeType, ClientFileImageMimeType } from './schemas/client-file-mime-types';
|
|
2
|
+
/** A content type the upload allowlist admits. */
|
|
3
|
+
export type ClientFileAcceptedMimeType = ClientFileImageMimeType | ClientFileDocMimeType;
|
|
4
|
+
/** Every extension we recognise (lowercase, no dot) and the type a file with it is admitted as. */
|
|
5
|
+
export declare const CLIENT_FILE_CONTENT_TYPE_BY_EXTENSION: Readonly<Record<string, ClientFileAcceptedMimeType>>;
|
|
6
|
+
/** The type a file name stands for, or null when we do not know the name. */
|
|
7
|
+
export declare function resolveClientFileContentTypeByName(filename: string): ClientFileAcceptedMimeType | null;
|
|
8
|
+
/**
|
|
9
|
+
* Pick the type to verify an upload against. The declared type is a browser's guess from the OS
|
|
10
|
+
* registry: empty, `application/octet-stream`, `video/mp2t` for a `.ts`, `application/xml` for a
|
|
11
|
+
* `.svg`. When it is such a guess the name decides; when it is a specific type we accept, it stands
|
|
12
|
+
* (the caller may still prefer the name when the bytes contradict that type).
|
|
13
|
+
*
|
|
14
|
+
* `text/plain` is the one generic type that may only become another TEXT type. A text file named
|
|
15
|
+
* `.docx` is still a text file, and sending it to a document converter on the strength of its name
|
|
16
|
+
* would reject something that was fine as it was.
|
|
17
|
+
*
|
|
18
|
+
* Nothing here admits anything by itself: the result goes through the same signature check as a
|
|
19
|
+
* declared type, so a name cannot smuggle a format past the bytes.
|
|
20
|
+
*/
|
|
21
|
+
export declare function reconcileClientFileContentTypeByName(declaredContentType: string, filename: string): string;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLIENT_FILE_CONTENT_TYPE_BY_EXTENSION = void 0;
|
|
4
|
+
exports.resolveClientFileContentTypeByName = resolveClientFileContentTypeByName;
|
|
5
|
+
exports.reconcileClientFileContentTypeByName = reconcileClientFileContentTypeByName;
|
|
6
|
+
const client_file_mime_types_1 = require("./schemas/client-file-mime-types");
|
|
7
|
+
/**
|
|
8
|
+
* Source and config formats that have no MIME type of their own anywhere browsers or servers agree on.
|
|
9
|
+
* They are admitted as `text/plain`: the bytes are checked like any text, and nothing about them is
|
|
10
|
+
* ever rendered. Markup (XML, SVG) belongs here on purpose — a browser draws it as a page or a picture
|
|
11
|
+
* when it is served under its own type, and plain text is never drawn.
|
|
12
|
+
*/
|
|
13
|
+
const PLAIN_TEXT_EXTENSIONS = [
|
|
14
|
+
'txt',
|
|
15
|
+
'text',
|
|
16
|
+
'log',
|
|
17
|
+
'xml',
|
|
18
|
+
'svg',
|
|
19
|
+
'jsx',
|
|
20
|
+
'tsx',
|
|
21
|
+
'scss',
|
|
22
|
+
'sass',
|
|
23
|
+
'less',
|
|
24
|
+
'vue',
|
|
25
|
+
'svelte',
|
|
26
|
+
'toml',
|
|
27
|
+
'ini',
|
|
28
|
+
'cfg',
|
|
29
|
+
'conf',
|
|
30
|
+
'env',
|
|
31
|
+
'properties',
|
|
32
|
+
'gradle',
|
|
33
|
+
'lua',
|
|
34
|
+
'r',
|
|
35
|
+
'pl',
|
|
36
|
+
'dart',
|
|
37
|
+
'ex',
|
|
38
|
+
'exs',
|
|
39
|
+
'hs',
|
|
40
|
+
'tf',
|
|
41
|
+
'graphql',
|
|
42
|
+
'gql',
|
|
43
|
+
'proto',
|
|
44
|
+
'mk',
|
|
45
|
+
'bat',
|
|
46
|
+
'ps1',
|
|
47
|
+
'tex',
|
|
48
|
+
'diff',
|
|
49
|
+
'patch',
|
|
50
|
+
'srt',
|
|
51
|
+
'vtt',
|
|
52
|
+
'ass',
|
|
53
|
+
'ssa',
|
|
54
|
+
'dockerfile',
|
|
55
|
+
'pas',
|
|
56
|
+
'xsd',
|
|
57
|
+
'xsl',
|
|
58
|
+
'xslt',
|
|
59
|
+
'ipynb',
|
|
60
|
+
'jsonl',
|
|
61
|
+
'ndjson',
|
|
62
|
+
'rst',
|
|
63
|
+
'adoc',
|
|
64
|
+
];
|
|
65
|
+
/** Every extension we recognise (lowercase, no dot) and the type a file with it is admitted as. */
|
|
66
|
+
exports.CLIENT_FILE_CONTENT_TYPE_BY_EXTENSION = {
|
|
67
|
+
...Object.fromEntries(PLAIN_TEXT_EXTENSIONS.map((extension) => [extension, 'text/plain'])),
|
|
68
|
+
html: 'text/html',
|
|
69
|
+
htm: 'text/html',
|
|
70
|
+
md: 'text/markdown',
|
|
71
|
+
markdown: 'text/markdown',
|
|
72
|
+
csv: 'text/csv',
|
|
73
|
+
tsv: 'text/tab-separated-values',
|
|
74
|
+
json: 'application/json',
|
|
75
|
+
yaml: 'text/yaml',
|
|
76
|
+
yml: 'text/yaml',
|
|
77
|
+
css: 'text/css',
|
|
78
|
+
js: 'text/javascript',
|
|
79
|
+
mjs: 'text/javascript',
|
|
80
|
+
cjs: 'text/javascript',
|
|
81
|
+
ts: 'text/x-typescript',
|
|
82
|
+
mts: 'text/x-typescript',
|
|
83
|
+
cts: 'text/x-typescript',
|
|
84
|
+
py: 'text/x-python',
|
|
85
|
+
java: 'text/x-java-source',
|
|
86
|
+
c: 'text/x-c',
|
|
87
|
+
h: 'text/x-c',
|
|
88
|
+
cpp: 'text/x-c++src',
|
|
89
|
+
cc: 'text/x-c++src',
|
|
90
|
+
cxx: 'text/x-c++src',
|
|
91
|
+
hpp: 'text/x-c++src',
|
|
92
|
+
cs: 'text/x-csharp',
|
|
93
|
+
go: 'text/x-go',
|
|
94
|
+
rs: 'text/x-rust',
|
|
95
|
+
rb: 'text/x-ruby',
|
|
96
|
+
php: 'text/x-php',
|
|
97
|
+
swift: 'text/x-swift',
|
|
98
|
+
kt: 'text/x-kotlin',
|
|
99
|
+
kts: 'text/x-kotlin',
|
|
100
|
+
scala: 'text/x-scala',
|
|
101
|
+
sql: 'text/x-sql',
|
|
102
|
+
sh: 'text/x-shellscript',
|
|
103
|
+
bash: 'text/x-shellscript',
|
|
104
|
+
zsh: 'text/x-shellscript',
|
|
105
|
+
pdf: 'application/pdf',
|
|
106
|
+
png: 'image/png',
|
|
107
|
+
jpg: 'image/jpeg',
|
|
108
|
+
jpeg: 'image/jpeg',
|
|
109
|
+
webp: 'image/webp',
|
|
110
|
+
doc: 'application/msword',
|
|
111
|
+
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
112
|
+
rtf: 'application/rtf',
|
|
113
|
+
odt: 'application/vnd.oasis.opendocument.text',
|
|
114
|
+
odp: 'application/vnd.oasis.opendocument.presentation',
|
|
115
|
+
ods: 'application/vnd.oasis.opendocument.spreadsheet',
|
|
116
|
+
xls: 'application/vnd.ms-excel',
|
|
117
|
+
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
118
|
+
ppt: 'application/vnd.ms-powerpoint',
|
|
119
|
+
pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
120
|
+
};
|
|
121
|
+
/** Files known by their whole name: they have no extension, or the dot is part of the name. */
|
|
122
|
+
const CONTENT_TYPE_BY_BASENAME = {
|
|
123
|
+
dockerfile: 'text/plain',
|
|
124
|
+
makefile: 'text/plain',
|
|
125
|
+
gnumakefile: 'text/plain',
|
|
126
|
+
rakefile: 'text/plain',
|
|
127
|
+
gemfile: 'text/plain',
|
|
128
|
+
procfile: 'text/plain',
|
|
129
|
+
'.gitignore': 'text/plain',
|
|
130
|
+
'.dockerignore': 'text/plain',
|
|
131
|
+
'.editorconfig': 'text/plain',
|
|
132
|
+
readme: 'text/plain',
|
|
133
|
+
license: 'text/plain',
|
|
134
|
+
jenkinsfile: 'text/plain',
|
|
135
|
+
vagrantfile: 'text/plain',
|
|
136
|
+
};
|
|
137
|
+
/** `.env.local`, `Dockerfile.dev`: the part after the dot is the environment, not the format. */
|
|
138
|
+
const TEXT_NAME_PREFIXES = ['.env.', 'dockerfile.'];
|
|
139
|
+
const PLAIN_TEXT = 'text/plain';
|
|
140
|
+
const TEXT_NATIVE_TYPES = new Set(client_file_mime_types_1.CLIENT_FILE_TEXT_NATIVE_MIME_TYPES);
|
|
141
|
+
const ACCEPTED_TYPES = new Set([
|
|
142
|
+
...client_file_mime_types_1.CLIENT_FILE_IMAGE_MIME_TYPES,
|
|
143
|
+
...client_file_mime_types_1.CLIENT_FILE_DOC_MIME_TYPES,
|
|
144
|
+
]);
|
|
145
|
+
function lookup(table, key) {
|
|
146
|
+
// `Object.hasOwn`: the name comes off the wire, and `constructor` must not resolve to a member.
|
|
147
|
+
return Object.hasOwn(table, key) ? table[key] : null;
|
|
148
|
+
}
|
|
149
|
+
/** The type a file name stands for, or null when we do not know the name. */
|
|
150
|
+
function resolveClientFileContentTypeByName(filename) {
|
|
151
|
+
const basename = (filename.split(/[\\/]/).pop() ?? '').trim().toLowerCase();
|
|
152
|
+
const byName = lookup(CONTENT_TYPE_BY_BASENAME, basename);
|
|
153
|
+
if (byName !== null) {
|
|
154
|
+
return byName;
|
|
155
|
+
}
|
|
156
|
+
if (TEXT_NAME_PREFIXES.some((prefix) => basename.startsWith(prefix))) {
|
|
157
|
+
return PLAIN_TEXT;
|
|
158
|
+
}
|
|
159
|
+
const dot = basename.lastIndexOf('.');
|
|
160
|
+
return dot === -1
|
|
161
|
+
? null
|
|
162
|
+
: lookup(exports.CLIENT_FILE_CONTENT_TYPE_BY_EXTENSION, basename.slice(dot + 1));
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Pick the type to verify an upload against. The declared type is a browser's guess from the OS
|
|
166
|
+
* registry: empty, `application/octet-stream`, `video/mp2t` for a `.ts`, `application/xml` for a
|
|
167
|
+
* `.svg`. When it is such a guess the name decides; when it is a specific type we accept, it stands
|
|
168
|
+
* (the caller may still prefer the name when the bytes contradict that type).
|
|
169
|
+
*
|
|
170
|
+
* `text/plain` is the one generic type that may only become another TEXT type. A text file named
|
|
171
|
+
* `.docx` is still a text file, and sending it to a document converter on the strength of its name
|
|
172
|
+
* would reject something that was fine as it was.
|
|
173
|
+
*
|
|
174
|
+
* Nothing here admits anything by itself: the result goes through the same signature check as a
|
|
175
|
+
* declared type, so a name cannot smuggle a format past the bytes.
|
|
176
|
+
*/
|
|
177
|
+
function reconcileClientFileContentTypeByName(declaredContentType, filename) {
|
|
178
|
+
const named = resolveClientFileContentTypeByName(filename);
|
|
179
|
+
if (named === null) {
|
|
180
|
+
return declaredContentType;
|
|
181
|
+
}
|
|
182
|
+
// `text/plain` is what browsers put on source files they do not recognise, so it is no evidence.
|
|
183
|
+
if (declaredContentType !== PLAIN_TEXT && ACCEPTED_TYPES.has(declaredContentType)) {
|
|
184
|
+
return declaredContentType;
|
|
185
|
+
}
|
|
186
|
+
if (declaredContentType === PLAIN_TEXT && !isClientFileTextNativeMimeType(named)) {
|
|
187
|
+
return declaredContentType;
|
|
188
|
+
}
|
|
189
|
+
return named;
|
|
190
|
+
}
|
|
191
|
+
function isClientFileTextNativeMimeType(value) {
|
|
192
|
+
return TEXT_NATIVE_TYPES.has(value);
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=client-file-extensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-file-extensions.js","sourceRoot":"","sources":["../../../v1/client-file/client-file-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M,CAAC,6CAAqC,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AACjF,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,oCAAoC,CAChD,mBAA2B,EAC3B,QAAgB;IAEhB,MAAM,KAAK,GAAG,kCAAkC,CAAC,QAAQ,CAAC,CAAC;IAC3D,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACjB,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IACD,iGAAiG;IACjG,IAAI,mBAAmB,KAAK,UAAU,IAAI,cAAc,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAChF,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IACD,IAAI,mBAAmB,KAAK,UAAU,IAAI,CAAC,8BAA8B,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/E,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,8BAA8B,CAAC,KAAa;IACjD,OAAO,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -6,5 +6,6 @@ export * from './upload-magic-bytes';
|
|
|
6
6
|
export * from './attachment-coverage';
|
|
7
7
|
export * from './attachment-coverage.types';
|
|
8
8
|
export * from './client-file-content-kind';
|
|
9
|
+
export * from './client-file-extensions';
|
|
9
10
|
export * from './ai-file-policy.constants';
|
|
10
11
|
export * from './client-document.constants';
|
|
@@ -22,6 +22,7 @@ __exportStar(require("./upload-magic-bytes"), exports);
|
|
|
22
22
|
__exportStar(require("./attachment-coverage"), exports);
|
|
23
23
|
__exportStar(require("./attachment-coverage.types"), exports);
|
|
24
24
|
__exportStar(require("./client-file-content-kind"), exports);
|
|
25
|
+
__exportStar(require("./client-file-extensions"), exports);
|
|
25
26
|
__exportStar(require("./ai-file-policy.constants"), exports);
|
|
26
27
|
__exportStar(require("./client-document.constants"), exports);
|
|
27
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../v1/client-file/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B;AAC1B,8DAA4C;AAC5C,uDAAqC;AACrC,wDAAsC;AACtC,8DAA4C;AAC5C,6DAA2C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../v1/client-file/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B;AAC1B,8DAA4C;AAC5C,uDAAqC;AACrC,wDAAsC;AACtC,8DAA4C;AAC5C,6DAA2C;AAC3C,2DAAyC;AAEzC,6DAA2C;AAE3C,8DAA4C"}
|
|
@@ -3,6 +3,9 @@ export declare enum UploadMagicType {
|
|
|
3
3
|
JPEG = "JPEG",
|
|
4
4
|
GIF = "GIF",
|
|
5
5
|
WEBP = "WEBP",
|
|
6
|
+
/** HEIC/HEIF — iPhone photos. Recognised for the diagnostic log only; not accepted. */
|
|
7
|
+
HEIF = "HEIF",
|
|
8
|
+
AVIF = "AVIF",
|
|
6
9
|
PDF = "PDF",
|
|
7
10
|
/** ZIP container. Every OOXML document (docx/xlsx/pptx) is one. */
|
|
8
11
|
ZIP = "ZIP",
|
|
@@ -7,6 +7,9 @@ var UploadMagicType;
|
|
|
7
7
|
UploadMagicType["JPEG"] = "JPEG";
|
|
8
8
|
UploadMagicType["GIF"] = "GIF";
|
|
9
9
|
UploadMagicType["WEBP"] = "WEBP";
|
|
10
|
+
/** HEIC/HEIF — iPhone photos. Recognised for the diagnostic log only; not accepted. */
|
|
11
|
+
UploadMagicType["HEIF"] = "HEIF";
|
|
12
|
+
UploadMagicType["AVIF"] = "AVIF";
|
|
10
13
|
UploadMagicType["PDF"] = "PDF";
|
|
11
14
|
/** ZIP container. Every OOXML document (docx/xlsx/pptx) is one. */
|
|
12
15
|
UploadMagicType["ZIP"] = "ZIP";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-magic-type.enum.js","sourceRoot":"","sources":["../../../../v1/client-file/schemas/upload-magic-type.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"upload-magic-type.enum.js","sourceRoot":"","sources":["../../../../v1/client-file/schemas/upload-magic-type.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAkBX;AAlBD,WAAY,eAAe;IACvB,8BAAW,CAAA;IACX,gCAAa,CAAA;IACb,8BAAW,CAAA;IACX,gCAAa,CAAA;IACb,uFAAuF;IACvF,gCAAa,CAAA;IACb,gCAAa,CAAA;IACb,8BAAW,CAAA;IACX,mEAAmE;IACnE,8BAAW,CAAA;IACX,kDAAkD;IAClD,gCAAa,CAAA;IACb,8BAAW,CAAA;IACX,sEAAsE;IACtE,4CAAyB,CAAA;IACzB,qFAAqF;IACrF,sCAAmB,CAAA;AACvB,CAAC,EAlBW,eAAe,+BAAf,eAAe,QAkB1B"}
|
|
@@ -35,33 +35,25 @@ export declare function detectUploadMagicType(bytes: Uint8Array): UploadMagicTyp
|
|
|
35
35
|
*/
|
|
36
36
|
export declare const EXPECTED_MAGIC_BY_CONTENT_TYPE: Readonly<Record<string, readonly UploadMagicType[]>>;
|
|
37
37
|
/**
|
|
38
|
-
* Let the BYTES name the type — but only inside
|
|
39
|
-
*
|
|
38
|
+
* Let the BYTES name the type — but only inside a family (see above), and only between types we
|
|
39
|
+
* already accept.
|
|
40
40
|
*
|
|
41
|
-
* The case this exists for came from our own pipeline. A KIE CDN served a
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* `.png` URL, which browsers do constantly.
|
|
41
|
+
* The case this exists for came from our own pipeline. A KIE CDN served a generated picture as
|
|
42
|
+
* `Content-Type: image/png` with a WebP body; the downloader trusted the header, so the object was
|
|
43
|
+
* stored under a `.png` name and handed to the person that way. Re-uploading it — our own
|
|
44
|
+
* artifact — failed, because the sniffer correctly saw WebP where PNG was declared. The same thing
|
|
45
|
+
* happens to a Word file saved under `.doc` that is a docx inside: a perfectly ordinary file that
|
|
46
|
+
* a strict reading of the declaration would turn away.
|
|
48
47
|
*
|
|
49
|
-
* Why this is not the "trust the payload" mistake the module warns about: it
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* An uploader gains nothing either — they could declare `image/webp` outright.
|
|
48
|
+
* Why this is not the "trust the payload" mistake the module warns about: it re-routes NOTHING
|
|
49
|
+
* that the uploader could not have declared outright. Everything else keeps the old rule. A ZIP
|
|
50
|
+
* announced as `text/plain` still contradicts its declaration, and cross-family correction is
|
|
51
|
+
* exactly where honouring content over declaration WOULD hand someone a pipeline of their choosing.
|
|
54
52
|
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* honouring content over declaration WOULD hand someone a pipeline of their
|
|
58
|
-
* choosing — the converter that resolves what a document points at.
|
|
59
|
-
*
|
|
60
|
-
* Returns the content type the caller should proceed with: the detected one
|
|
61
|
-
* when both it and the declaration are accepted image types, otherwise the
|
|
62
|
-
* declaration untouched.
|
|
53
|
+
* Returns the content type the caller should proceed with: the detected one when the declaration
|
|
54
|
+
* belongs to a family that has a type for these bytes, otherwise the declaration untouched.
|
|
63
55
|
*/
|
|
64
|
-
export declare function
|
|
56
|
+
export declare function reconcileContentTypeFamily(declaredContentType: string, bytes: Uint8Array): string;
|
|
65
57
|
export { MagicVerdict } from './schemas/magic-verdict.enum';
|
|
66
58
|
/**
|
|
67
59
|
* Does the content agree with what the uploader claimed it is.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MagicVerdict = exports.EXPECTED_MAGIC_BY_CONTENT_TYPE = exports.UPLOAD_MAGIC_PROBE_BYTES = exports.UploadMagicType = void 0;
|
|
4
4
|
exports.detectUploadMagicType = detectUploadMagicType;
|
|
5
|
-
exports.
|
|
5
|
+
exports.reconcileContentTypeFamily = reconcileContentTypeFamily;
|
|
6
6
|
exports.verifyDeclaredContentType = verifyDeclaredContentType;
|
|
7
7
|
const upload_magic_type_enum_1 = require("./schemas/upload-magic-type.enum");
|
|
8
8
|
const magic_verdict_enum_1 = require("./schemas/magic-verdict.enum");
|
|
@@ -68,6 +68,26 @@ function isWebp(bytes) {
|
|
|
68
68
|
bytes[10] === 0x42 &&
|
|
69
69
|
bytes[11] === 0x50);
|
|
70
70
|
}
|
|
71
|
+
/** ISO base media file: `ftyp` at offset 4, the brand naming the image format right after it. */
|
|
72
|
+
const FTYP_BOX_OFFSET = 4;
|
|
73
|
+
const FTYP_BRAND_OFFSET = 8;
|
|
74
|
+
const FTYP_BRAND_LENGTH = 4;
|
|
75
|
+
const FTYP_TAG = 'ftyp';
|
|
76
|
+
const IMAGE_BRANDS = [
|
|
77
|
+
{ type: upload_magic_type_enum_1.UploadMagicType.HEIF, brands: ['heic', 'heix', 'hevc', 'hevx', 'mif1', 'msf1'] },
|
|
78
|
+
{ type: upload_magic_type_enum_1.UploadMagicType.AVIF, brands: ['avif', 'avis'] },
|
|
79
|
+
];
|
|
80
|
+
function asciiAt(bytes, offset, length) {
|
|
81
|
+
return String.fromCharCode(...bytes.subarray(offset, offset + length));
|
|
82
|
+
}
|
|
83
|
+
function detectIsoImage(bytes) {
|
|
84
|
+
if (bytes.length < FTYP_BRAND_OFFSET + FTYP_BRAND_LENGTH ||
|
|
85
|
+
asciiAt(bytes, FTYP_BOX_OFFSET, FTYP_TAG.length) !== FTYP_TAG) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const brand = asciiAt(bytes, FTYP_BRAND_OFFSET, FTYP_BRAND_LENGTH);
|
|
89
|
+
return IMAGE_BRANDS.find(({ brands }) => brands.includes(brand))?.type ?? null;
|
|
90
|
+
}
|
|
71
91
|
/**
|
|
72
92
|
* Classify a byte prefix. Never guesses: anything unrecognised is UNKNOWN, and
|
|
73
93
|
* the caller decides what that means for the declared type.
|
|
@@ -81,7 +101,7 @@ function detectUploadMagicType(bytes) {
|
|
|
81
101
|
return type;
|
|
82
102
|
}
|
|
83
103
|
}
|
|
84
|
-
return upload_magic_type_enum_1.UploadMagicType.UNKNOWN;
|
|
104
|
+
return detectIsoImage(bytes) ?? upload_magic_type_enum_1.UploadMagicType.UNKNOWN;
|
|
85
105
|
}
|
|
86
106
|
/**
|
|
87
107
|
* Signatures a declared content type is allowed to carry.
|
|
@@ -116,52 +136,70 @@ exports.EXPECTED_MAGIC_BY_CONTENT_TYPE = {
|
|
|
116
136
|
],
|
|
117
137
|
};
|
|
118
138
|
/**
|
|
119
|
-
*
|
|
139
|
+
* Content types that one file can legitimately be sold under by mistake, keyed by what the bytes
|
|
140
|
+
* say. Choosing between the members of a family gives the uploader no pipeline they could not have
|
|
141
|
+
* got by declaring that member outright.
|
|
142
|
+
*
|
|
143
|
+
* - Images: all three go through one image branch.
|
|
144
|
+
* - Word: a `.doc` that is really a docx (ZIP) or an RTF is what Word, Google Docs and phones
|
|
145
|
+
* produce; the converter gets the canonical extension of whatever we settle on.
|
|
146
|
+
* - Excel and PowerPoint: the same legacy-vs-OOXML mix-up.
|
|
120
147
|
*
|
|
121
|
-
*
|
|
122
|
-
* but do not accept (GIF) is deliberately absent: recognising it is how we
|
|
148
|
+
* A signature we detect but do not accept (GIF) is deliberately absent: recognising it is how we
|
|
123
149
|
* reject it, not a step towards letting it in.
|
|
124
150
|
*/
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
151
|
+
const CONTENT_TYPE_FAMILIES = [
|
|
152
|
+
{
|
|
153
|
+
[upload_magic_type_enum_1.UploadMagicType.PNG]: 'image/png',
|
|
154
|
+
[upload_magic_type_enum_1.UploadMagicType.JPEG]: 'image/jpeg',
|
|
155
|
+
[upload_magic_type_enum_1.UploadMagicType.WEBP]: 'image/webp',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
[upload_magic_type_enum_1.UploadMagicType.ZIP]: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
159
|
+
[upload_magic_type_enum_1.UploadMagicType.OLE2]: 'application/msword',
|
|
160
|
+
[upload_magic_type_enum_1.UploadMagicType.RTF]: 'application/rtf',
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
[upload_magic_type_enum_1.UploadMagicType.ZIP]: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
164
|
+
[upload_magic_type_enum_1.UploadMagicType.OLE2]: 'application/vnd.ms-excel',
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
[upload_magic_type_enum_1.UploadMagicType.ZIP]: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
168
|
+
[upload_magic_type_enum_1.UploadMagicType.OLE2]: 'application/vnd.ms-powerpoint',
|
|
169
|
+
},
|
|
170
|
+
];
|
|
171
|
+
/** Browsers announce an RTF as `text/rtf` too; it belongs to the same family as `application/rtf`. */
|
|
172
|
+
const RTF_ALIASES = { 'text/rtf': 'application/rtf' };
|
|
130
173
|
/**
|
|
131
|
-
* Let the BYTES name the type — but only inside
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* The case this exists for came from our own pipeline. A KIE CDN served a
|
|
135
|
-
* generated picture as `Content-Type: image/png` with a WebP body; the
|
|
136
|
-
* downloader trusted the header, so the object was stored under a `.png` name
|
|
137
|
-
* and handed to the person that way. Re-uploading it — our own artifact —
|
|
138
|
-
* failed, because the sniffer correctly saw WebP where PNG was declared. The
|
|
139
|
-
* same thing happens to any file saved from a site that serves WebP behind a
|
|
140
|
-
* `.png` URL, which browsers do constantly.
|
|
174
|
+
* Let the BYTES name the type — but only inside a family (see above), and only between types we
|
|
175
|
+
* already accept.
|
|
141
176
|
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
177
|
+
* The case this exists for came from our own pipeline. A KIE CDN served a generated picture as
|
|
178
|
+
* `Content-Type: image/png` with a WebP body; the downloader trusted the header, so the object was
|
|
179
|
+
* stored under a `.png` name and handed to the person that way. Re-uploading it — our own
|
|
180
|
+
* artifact — failed, because the sniffer correctly saw WebP where PNG was declared. The same thing
|
|
181
|
+
* happens to a Word file saved under `.doc` that is a docx inside: a perfectly ordinary file that
|
|
182
|
+
* a strict reading of the declaration would turn away.
|
|
147
183
|
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
184
|
+
* Why this is not the "trust the payload" mistake the module warns about: it re-routes NOTHING
|
|
185
|
+
* that the uploader could not have declared outright. Everything else keeps the old rule. A ZIP
|
|
186
|
+
* announced as `text/plain` still contradicts its declaration, and cross-family correction is
|
|
187
|
+
* exactly where honouring content over declaration WOULD hand someone a pipeline of their choosing.
|
|
152
188
|
*
|
|
153
|
-
* Returns the content type the caller should proceed with: the detected one
|
|
154
|
-
*
|
|
155
|
-
* declaration untouched.
|
|
189
|
+
* Returns the content type the caller should proceed with: the detected one when the declaration
|
|
190
|
+
* belongs to a family that has a type for these bytes, otherwise the declaration untouched.
|
|
156
191
|
*/
|
|
157
|
-
function
|
|
192
|
+
function reconcileContentTypeFamily(declaredContentType, bytes) {
|
|
158
193
|
const declared = declaredContentType.toLowerCase();
|
|
159
|
-
const
|
|
160
|
-
|
|
194
|
+
const detected = detectUploadMagicType(bytes);
|
|
195
|
+
const expected = Object.hasOwn(exports.EXPECTED_MAGIC_BY_CONTENT_TYPE, declared)
|
|
196
|
+
? exports.EXPECTED_MAGIC_BY_CONTENT_TYPE[declared]
|
|
197
|
+
: undefined;
|
|
198
|
+
if (expected?.includes(detected)) {
|
|
161
199
|
return declaredContentType;
|
|
162
200
|
}
|
|
163
|
-
const
|
|
164
|
-
return detected
|
|
201
|
+
const family = CONTENT_TYPE_FAMILIES.find((members) => Object.values(members).includes(RTF_ALIASES[declared] ?? declared));
|
|
202
|
+
return family?.[detected] ?? declaredContentType;
|
|
165
203
|
}
|
|
166
204
|
var magic_verdict_enum_2 = require("./schemas/magic-verdict.enum");
|
|
167
205
|
Object.defineProperty(exports, "MagicVerdict", { enumerable: true, get: function () { return magic_verdict_enum_2.MagicVerdict; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-magic-bytes.js","sourceRoot":"","sources":["../../../v1/client-file/upload-magic-bytes.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"upload-magic-bytes.js","sourceRoot":"","sources":["../../../v1/client-file/upload-magic-bytes.ts"],"names":[],"mappings":";;;AAmGA,sDAYC;AA8FD,gEAgBC;AAYD,8DA0BC;AAnQD,6EAAmE;AACnE,qEAA4D;AAC5D;;;;;;;;;;;;;;;GAeG;AACH,2EAAmE;AAA1D,yHAAA,eAAe,OAAA;AAExB,yEAAyE;AAC5D,QAAA,wBAAwB,GAAG,EAAE,CAAC;AAE3C,SAAS,UAAU,CAAC,KAAiB,EAAE,SAA4B;IAC/D,IAAI,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,GAAuE;IACnF,EAAE,IAAI,EAAE,wCAAe,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE;IACtF,EAAE,IAAI,EAAE,wCAAe,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE;IACzD,EAAE,IA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2B,EAC3B,KAAiB;IAEjB,MAAM,QAAQ,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAE9C,IAAI,QAAQ,KAAK,wCAAe,CAAC,UAAU,EAAE,CAAC;QAC1C,OAAO,iCAAY,CAAC,UAAU,CAAC;IACnC,CAAC;IAED,2EAA2E;IAC3E,4EAA4E;IAC5E,0EAA0E;IAC1E,6BAA6B;IAC7B,MAAM,GAAG,GAAG,mBAAmB,CAAC,WAAW,EAAE,CAAC;IAC9C,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,sCAA8B,EAAE,GAAG,CAAC;QAC/D,CAAC,CAAC,sCAA8B,CAAC,GAAG,CAAC;QACrC,CAAC,CAAC,SAAS,CAAC;IAEhB,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QACzB,uEAAuE;QACvE,yDAAyD;QACzD,OAAO,QAAQ,KAAK,wCAAe,CAAC,OAAO,CAAC,CAAC,CAAC,iCAAY,CAAC,EAAE,CAAC,CAAC,CAAC,iCAAY,CAAC,QAAQ,CAAC;IAC1F,CAAC;IAED,OAAO,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,iCAAY,CAAC,EAAE,CAAC,CAAC,CAAC,iCAAY,CAAC,QAAQ,CAAC;AACjF,CAAC"}
|
|
@@ -14,9 +14,9 @@ exports.CreateMessageRequestSchema = zod_1.z.object({
|
|
|
14
14
|
aiModelId: zod_1.z
|
|
15
15
|
.string({ error: 'CreateMessageRequest.aiModelId.required' })
|
|
16
16
|
.uuid({ message: 'CreateMessageRequest.aiModelId.invalid' }),
|
|
17
|
+
/** Может быть пустым, если к сообщению прикреплены файлы: пустое сообщение без файлов отклоняет API. */
|
|
17
18
|
text: zod_1.z
|
|
18
19
|
.string({ error: 'CreateMessageRequest.text.required' })
|
|
19
|
-
.min(1, { message: 'CreateMessageRequest.text.min' })
|
|
20
20
|
.max(shared_1.MESSAGE_TEXT_MAX_LENGTH, { message: 'CreateMessageRequest.text.max' }),
|
|
21
21
|
plugins: plugins_types_1.PluginRequestArraySchema.optional(),
|
|
22
22
|
tools: tool_types_1.ToolSelectionArraySchema.optional(),
|
|
@@ -38,9 +38,7 @@ exports.CreateMessageRequestSchema = zod_1.z.object({
|
|
|
38
38
|
* conversation continuation can actually be measured. Absent means
|
|
39
39
|
* "typed by hand"; clients that do not send it simply never attribute.
|
|
40
40
|
*/
|
|
41
|
-
fromSuggestion: zod_1.z
|
|
42
|
-
.boolean({ error: 'CreateMessageRequest.fromSuggestion.invalid' })
|
|
43
|
-
.optional(),
|
|
41
|
+
fromSuggestion: zod_1.z.boolean({ error: 'CreateMessageRequest.fromSuggestion.invalid' }).optional(),
|
|
44
42
|
/**
|
|
45
43
|
* Статья блога, из которой пришёл вопрос (кнопка «пересказать пост»).
|
|
46
44
|
* Текст статьи с клиента НЕ передаётся: бэкенд сам достаёт опубликованный
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-message-request.schema.js","sourceRoot":"","sources":["../../../../v1/message/schemas/create-message-request.schema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,4CAA0D;AAC1D,0DAAkE;AAClE,oDAA+D;AAC/D,mGAAmG;AAEnG;;;GAGG;AACU,QAAA,0BAA0B,GAAG,OAAC,CAAC,MAAM,CAAC;IAC/C,SAAS,EAAE,OAAC;SACP,MAAM,CAAC,EAAE,KAAK,EAAE,yCAAyC,EAAE,CAAC;SAC5D,IAAI,CAAC,EAAE,OAAO,EAAE,wCAAwC,EAAE,CAAC;IAChE,IAAI,EAAE,OAAC;SACF,MAAM,CAAC,EAAE,KAAK,EAAE,oCAAoC,EAAE,CAAC;SACvD,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"create-message-request.schema.js","sourceRoot":"","sources":["../../../../v1/message/schemas/create-message-request.schema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,4CAA0D;AAC1D,0DAAkE;AAClE,oDAA+D;AAC/D,mGAAmG;A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
exports.S2SUploadAiFileResponseSchema = zod_1.z.object({
|
|
6
|
+
fileId: zod_1.z.uuid(),
|
|
6
7
|
key: zod_1.z.string().min(1),
|
|
7
8
|
contentType: zod_1.z.string().min(1),
|
|
8
9
|
size: zod_1.z.number().int().nonnegative(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s2s-upload-ai-file-response.schema.js","sourceRoot":"","sources":["../../../../v1/s2s/schemas/s2s-upload-ai-file-response.schema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,6BAA6B,GAAG,OAAC,CAAC,MAAM,CAAC;IAClD,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACpC,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;CACvC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"s2s-upload-ai-file-response.schema.js","sourceRoot":"","sources":["../../../../v1/s2s/schemas/s2s-upload-ai-file-response.schema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,6BAA6B,GAAG,OAAC,CAAC,MAAM,CAAC;IAClD,MAAM,EAAE,OAAC,CAAC,IAAI,EAAE;IAChB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACpC,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;CACvC,CAAC,CAAC"}
|