Skip to content

Commit

Permalink
Moved OdinBlob to each individual file;
Browse files Browse the repository at this point in the history
  • Loading branch information
stef-coenen committed Dec 15, 2023
1 parent ecec422 commit 47f1559
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 39 deletions.
3 changes: 2 additions & 1 deletion packages/js-lib/src/core/DriveData/SecurityHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
mergeByteArrays,
} from '../../helpers/DataUtil';
import { EncryptedKeyHeader, FileMetadata, KeyHeader } from './File/DriveFileTypes';
import { OdinBlob } from '../OdinBlob';
const OdinBlob: typeof Blob =
(typeof window !== 'undefined' && (window as any)?.CustomBlob) || Blob;

/// Encryption
export const encryptKeyHeader = async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
} from './UploadHelpers';
import { getFileHeader, getPayloadBytes, getThumbBytes } from '../File/DriveFileProvider';
import { getRandom16ByteArray } from '../../../helpers/DataUtil';
import { OdinBlob } from '../../OdinBlob';
const OdinBlob: typeof Blob =
(typeof window !== 'undefined' && (window as any)?.CustomBlob) || Blob;

const isDebug = hasDebugFlag();

Expand Down
4 changes: 3 additions & 1 deletion packages/js-lib/src/core/DriveData/Upload/UploadHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import {
getRandom16ByteArray,
} from '../../../helpers/DataUtil';
import { ThumbnailFile, SystemFileType, PayloadFile, KeyHeader } from '../File/DriveFileTypes';
import { OdinBlob } from '../../OdinBlob';

const OdinBlob: typeof Blob =
(typeof window !== 'undefined' && (window as any)?.CustomBlob) || Blob;

const EMPTY_KEY_HEADER: KeyHeader = {
iv: new Uint8Array(Array(16).fill(0)),
Expand Down
2 changes: 0 additions & 2 deletions packages/js-lib/src/core/OdinBlob.ts

This file was deleted.

23 changes: 0 additions & 23 deletions packages/js-lib/src/global.d.ts

This file was deleted.

3 changes: 2 additions & 1 deletion packages/js-lib/src/helpers/DataUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { Guid } from 'guid-typescript';

import md5 from './md5/md5';
import { AccessControlList, EncryptedKeyHeader, PayloadDescriptor } from '../core/core';
import { OdinBlob } from '../core/OdinBlob';
const OdinBlob: typeof Blob =
(typeof window !== 'undefined' && (window as any)?.CustomBlob) || Blob;

export const getRandom16ByteArray = (): Uint8Array => {
return crypto.getRandomValues(new Uint8Array(16));
Expand Down
3 changes: 2 additions & 1 deletion packages/js-lib/src/helpers/ImageMerger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { base64ToUint8Array, uint8ArrayToBase64 } from './DataUtil';
import { EmbeddedThumb } from '../core/DriveData/File/DriveFileTypes';
import { OdinBlob } from '../core/OdinBlob';
const OdinBlob: typeof Blob =
(typeof window !== 'undefined' && (window as any)?.CustomBlob) || Blob;

const GRID_PIXEL_SIZE = 40;
const IMAGE_SIZE = GRID_PIXEL_SIZE / 2;
Expand Down
3 changes: 2 additions & 1 deletion packages/js-lib/src/media/Video/VideoSegmenter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { OdinBlob } from '../../core/OdinBlob';
const OdinBlob: typeof Blob =
(typeof window !== 'undefined' && (window as any)?.CustomBlob) || Blob;
import { mergeByteArrays } from '../../helpers/helpers';
import { SegmentedVideoMetadata } from '../MediaTypes';

Expand Down
3 changes: 2 additions & 1 deletion packages/js-lib/src/media/VideoProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import {
} from '../core/core';
import { PlainVideoMetadata, SegmentedVideoMetadata, VideoUploadResult } from './MediaTypes';
import { createThumbnails } from './Thumbs/ThumbnailProvider';
import { OdinBlob } from '../core/OdinBlob';
const OdinBlob: typeof Blob =
(typeof window !== 'undefined' && (window as any)?.CustomBlob) || Blob;

export type VideoContentType = 'video/mp4';

Expand Down
3 changes: 2 additions & 1 deletion packages/js-lib/src/peer/peerData/ExternalVideoProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { OdinBlob } from '../../core/OdinBlob';
const OdinBlob: typeof Blob =
(typeof window !== 'undefined' && (window as any)?.CustomBlob) || Blob;
import { DotYouClient } from '../../core/DotYouClient';
import { SystemFileType, TargetDrive } from '../../core/core';
import { stringifyToQueryParams, tryJsonParse } from '../../helpers/helpers';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { OdinBlob } from '../../core/OdinBlob';
const OdinBlob: typeof Blob =
(typeof window !== 'undefined' && (window as any)?.CustomBlob) || Blob;
import { DotYouClient } from '../../core/DotYouClient';
import { DEFAULT_PAYLOAD_KEY } from '../../core/DriveData/Upload/UploadHelpers';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { OdinBlob } from '../../core/OdinBlob';
const OdinBlob: typeof Blob =
(typeof window !== 'undefined' && (window as any)?.CustomBlob) || Blob;
import { DotYouClient } from '../../core/DotYouClient';
import { DEFAULT_PAYLOAD_KEY } from '../../core/DriveData/Upload/UploadHelpers';
import {
Expand Down
3 changes: 2 additions & 1 deletion packages/js-lib/src/public/file/ProfileCardProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { OdinBlob } from '../../core/OdinBlob';
const OdinBlob: typeof Blob =
(typeof window !== 'undefined' && (window as any)?.CustomBlob) || Blob;
import { DotYouClient } from '../../core/DotYouClient';
import { DriveSearchResult, SecurityGroupType } from '../../core/DriveData/File/DriveFileTypes';
import { getDecryptedImageData } from '../../media/ImageProvider';
Expand Down
3 changes: 2 additions & 1 deletion packages/js-lib/src/public/posts/PostDefinitionProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { OdinBlob } from '../../core/OdinBlob';
const OdinBlob: typeof Blob =
(typeof window !== 'undefined' && (window as any)?.CustomBlob) || Blob;
import { DotYouClient } from '../../core/DotYouClient';
import { DEFAULT_PAYLOAD_KEY } from '../../core/DriveData/Upload/UploadHelpers';
import {
Expand Down
3 changes: 2 additions & 1 deletion packages/js-lib/src/public/posts/PostReactionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import { uploadFileOverPeer } from '../../peer/peerData/Upload/PeerUploadProvide
import { deleteFileOverPeer } from '../../peer/peerData/File/PeerFileManageProvider';
import { queryBatchOverPeer } from '../../peer/peerData/Query/PeerDriveQueryProvider';
import { getContentFromHeaderOrPayloadOverPeer } from '../../peer/peerData/File/PeerFileProvider';
import { OdinBlob } from '../../core/OdinBlob';
const OdinBlob: typeof Blob =
(typeof window !== 'undefined' && (window as any)?.CustomBlob) || Blob;

const COMMENT_MEDIA_PAYLOAD = 'cmmnt_md';

Expand Down
3 changes: 2 additions & 1 deletion packages/js-lib/src/public/posts/PostUploadProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ import {
import { makeGrid } from '../../helpers/ImageMerger';
import { processVideoFile } from '../../media/Video/VideoProcessor';
import { createThumbnails } from '../../media/media';
import { OdinBlob } from '../../core/OdinBlob';
const OdinBlob: typeof Blob =
(typeof window !== 'undefined' && (window as any)?.CustomBlob) || Blob;

const POST_MEDIA_PAYLOAD_KEY = 'pst_mdi';

Expand Down

0 comments on commit 47f1559

Please sign in to comment.