Address Obsidian plugin scanner warnings.

This commit is contained in:
Andrew Beal 2026-06-28 15:31:07 +01:00
parent 78644a0958
commit 2131ad0edd
4 changed files with 9 additions and 7 deletions

View file

@ -114,8 +114,8 @@ export abstract class BaseAIFileService implements IAIFileService {
return `----FormBoundary${Date.now()}${Math.random().toString(36).substring(2)}`;
}
protected createFormData(displayName: string | undefined, mimeType: string, boundary: string, bytes: Uint8Array<ArrayBuffer>, additionalFields?: Record<string, string>): ArrayBuffer {
const parts: Uint8Array<ArrayBuffer>[] = [];
protected createFormData(displayName: string | undefined, mimeType: string, boundary: string, bytes: Uint8Array, additionalFields?: Record<string, string>): ArrayBuffer {
const parts: Uint8Array[] = [];
const encoder = new TextEncoder();
// Add the file field
@ -156,8 +156,8 @@ export abstract class BaseAIFileService implements IAIFileService {
return this.bytesToBuffer(result);
}
protected bytesToBuffer(bytes: Uint8Array<ArrayBuffer>): ArrayBuffer {
return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
protected bytesToBuffer(bytes: Uint8Array): ArrayBuffer {
return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength) as ArrayBuffer;
}
protected getHeader(headerName: string, headers: Record<string, string>): string | undefined {

View file

@ -77,7 +77,7 @@ export abstract class StringTools {
return btoa(binary);
}
public static toBytes(input: string): Uint8Array<ArrayBuffer> {
public static toBytes(input: string): Uint8Array {
const binaryString = atob(input);
const bytes = new Uint8Array(new ArrayBuffer(binaryString.length));
for (let i = 0; i < binaryString.length; i++) {
@ -88,7 +88,8 @@ export abstract class StringTools {
public static async computeSHA256Hash(base64: string): Promise<string> {
const bytes = this.toBytes(base64);
const hashBuffer = await crypto.subtle.digest('SHA-256', bytes);
const buffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength) as ArrayBuffer;
const hashBuffer = await crypto.subtle.digest('SHA-256', buffer);
const hashArray = Array.from(new Uint8Array(hashBuffer));
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
}

View file

@ -230,7 +230,7 @@ export class ConversationFileSystemService {
}
const bytes = StringTools.toBytes(attachment.base64);
const arrayBuffer = bytes.buffer;
const arrayBuffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength) as ArrayBuffer;
const result = await this.fileSystemService.writeBinaryFile(filePath, arrayBuffer, true);

View file

@ -14,6 +14,7 @@
"strictNullChecks": true,
"lib": [
"DOM",
"DOM.Iterable",
"ES2022"
],
"paths": {