@velion-la/onboarding-sdk-react-native 1.2.0-beta.6 → 1.2.0-beta.8
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/README.md +32 -4
- package/lib/commonjs/steps/DocumentsOcrStep.js +138 -18
- package/lib/commonjs/steps/DocumentsOcrStep.js.map +1 -1
- package/lib/commonjs/steps/LivenessMatchStep.js +26 -14
- package/lib/commonjs/steps/LivenessMatchStep.js.map +1 -1
- package/lib/commonjs/ui/icons/StepIcon.js +8 -3
- package/lib/commonjs/ui/icons/StepIcon.js.map +1 -1
- package/lib/commonjs/utils/jpegFromUri.js +54 -14
- package/lib/commonjs/utils/jpegFromUri.js.map +1 -1
- package/lib/module/steps/DocumentsOcrStep.js +138 -18
- package/lib/module/steps/DocumentsOcrStep.js.map +1 -1
- package/lib/module/steps/LivenessMatchStep.js +27 -15
- package/lib/module/steps/LivenessMatchStep.js.map +1 -1
- package/lib/module/ui/icons/StepIcon.js +8 -3
- package/lib/module/ui/icons/StepIcon.js.map +1 -1
- package/lib/module/utils/jpegFromUri.js +52 -14
- package/lib/module/utils/jpegFromUri.js.map +1 -1
- package/lib/typescript/steps/DocumentsOcrStep.d.ts.map +1 -1
- package/lib/typescript/ui/icons/StepIcon.d.ts +7 -2
- package/lib/typescript/ui/icons/StepIcon.d.ts.map +1 -1
- package/lib/typescript/utils/jpegFromUri.d.ts +31 -10
- package/lib/typescript/utils/jpegFromUri.d.ts.map +1 -1
- package/package.json +5 -1
- package/src/steps/DocumentsOcrStep.tsx +158 -16
- package/src/steps/LivenessMatchStep.tsx +30 -16
- package/src/ui/icons/StepIcon.tsx +9 -3
- package/src/utils/jpegFromUri.ts +54 -16
|
@@ -49,6 +49,7 @@ import { useTheme, mixHex } from '../ui/theme';
|
|
|
49
49
|
import { getStrings } from '../i18n';
|
|
50
50
|
import { resolveCaptureModeFromStepConfig } from '../utils/stepConfig';
|
|
51
51
|
import { log } from '../utils/log';
|
|
52
|
+
import { byteLengthOfUri, readBytesFromUri } from '../utils/jpegFromUri';
|
|
52
53
|
import { DocumentCapture, type CaptureGuide } from '../camera/DocumentCapture';
|
|
53
54
|
import {
|
|
54
55
|
computeGuideCropRect,
|
|
@@ -170,7 +171,24 @@ function DocumentsOcrView({
|
|
|
170
171
|
const handleCaptured = useCallback(
|
|
171
172
|
async (photo: PhotoFile, side: DocumentSide, guide: CaptureGuide) => {
|
|
172
173
|
try {
|
|
174
|
+
// Size of the raw capture BEFORE any processing. Logged next to the
|
|
175
|
+
// compressed size so a 0-byte upload can be traced to the stage that
|
|
176
|
+
// lost it — the capture itself, the crop/compress, or the upload
|
|
177
|
+
// (OSDKR-22).
|
|
178
|
+
const sourceBytes = byteLengthOfUri(photo.filePath);
|
|
173
179
|
const compressed = await compressJpeg(photo.filePath, guide);
|
|
180
|
+
log.info('[DocumentsOCR] side processed', {
|
|
181
|
+
side,
|
|
182
|
+
sourceBytes,
|
|
183
|
+
compressedBytes: compressed.byteLength,
|
|
184
|
+
width: compressed.width,
|
|
185
|
+
height: compressed.height,
|
|
186
|
+
});
|
|
187
|
+
if (compressed.byteLength === 0) {
|
|
188
|
+
throw new Error(
|
|
189
|
+
`Processed ${side} image is 0 bytes (source was ${sourceBytes} bytes).`,
|
|
190
|
+
);
|
|
191
|
+
}
|
|
174
192
|
if (compressed.byteLength > MAX_BYTES) {
|
|
175
193
|
setBannerError(t.documents_ocr.fileTooLarge);
|
|
176
194
|
// Stay on the capture phase so the user can retake immediately.
|
|
@@ -205,10 +223,18 @@ function DocumentsOcrView({
|
|
|
205
223
|
}
|
|
206
224
|
|
|
207
225
|
setBusyLabel(t.documents_ocr.uploadingFront);
|
|
208
|
-
await uploadJpeg(
|
|
226
|
+
await uploadJpeg(
|
|
227
|
+
front.uri,
|
|
228
|
+
init.front_side_upload_url,
|
|
229
|
+
init.max_file_size_bytes,
|
|
230
|
+
);
|
|
209
231
|
|
|
210
232
|
setBusyLabel(t.documents_ocr.uploadingBack);
|
|
211
|
-
await uploadJpeg(
|
|
233
|
+
await uploadJpeg(
|
|
234
|
+
back.uri,
|
|
235
|
+
init.back_side_upload_url,
|
|
236
|
+
init.max_file_size_bytes,
|
|
237
|
+
);
|
|
212
238
|
|
|
213
239
|
setBusyLabel(t.documents_ocr.verifying);
|
|
214
240
|
await api.post(`/sessions/${sessionId}/documents-verify`, {});
|
|
@@ -502,7 +528,7 @@ async function compressJpeg(
|
|
|
502
528
|
compress: COMPRESS_QUALITY,
|
|
503
529
|
format: SaveFormat.JPEG,
|
|
504
530
|
});
|
|
505
|
-
const byteLength =
|
|
531
|
+
const byteLength = byteLengthOfUri(result.uri);
|
|
506
532
|
return {
|
|
507
533
|
uri: result.uri,
|
|
508
534
|
width: result.width,
|
|
@@ -519,27 +545,143 @@ async function compressJpeg(
|
|
|
519
545
|
}
|
|
520
546
|
}
|
|
521
547
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
548
|
+
/**
|
|
549
|
+
* Uploads a captured JPEG to its signed URL.
|
|
550
|
+
*
|
|
551
|
+
* The bytes are read with `expo-file-system`, NOT with `fetch(uri)`. Since
|
|
552
|
+
* Expo SDK 57 the global `fetch` is Expo's native HTTP client, which does not
|
|
553
|
+
* handle the `file://` scheme and answers with an empty body rather than
|
|
554
|
+
* failing — so reading a capture through it uploaded a 0-byte object while
|
|
555
|
+
* every status code said success (OSDKR-22).
|
|
556
|
+
*
|
|
557
|
+
* Expo's `fetch` normalises any `ArrayBuffer.isView` into the request body, so
|
|
558
|
+
* a `Uint8Array` is a valid body here.
|
|
559
|
+
*/
|
|
560
|
+
async function uploadJpeg(
|
|
561
|
+
uri: string,
|
|
562
|
+
signedUrl: string,
|
|
563
|
+
maxFileSizeBytes: number | undefined,
|
|
564
|
+
): Promise<void> {
|
|
565
|
+
const bytes = await readBytesFromUri(uri);
|
|
566
|
+
// Never PUT an empty body: the bucket accepts it, the step reports success,
|
|
567
|
+
// and the failure only surfaces later as an unexplained backend rejection.
|
|
568
|
+
if (bytes.byteLength === 0) {
|
|
569
|
+
throw new Error('Captured photo read back as 0 bytes — refusing to upload it.');
|
|
570
|
+
}
|
|
571
|
+
// The CDN signs the URL with an `x-goog-content-length-range` extension
|
|
572
|
+
// header, and GCS rejects the PUT unless every signed header is present in
|
|
573
|
+
// the request — with `MalformedSecurityHeader`, not with a size error, so it
|
|
574
|
+
// reads like a signature problem (OSDKR-22).
|
|
575
|
+
//
|
|
576
|
+
// The value has to match what was signed byte for byte. The CDN builds it as
|
|
577
|
+
// `"0," + maxUploadBytes` and returns that same number as the
|
|
578
|
+
// `max_file_size_bytes` of `documents-init`, so the number below is the one
|
|
579
|
+
// that went into the signature, not a guess.
|
|
580
|
+
const headers: Record<string, string> = { 'Content-Type': 'image/jpeg' };
|
|
581
|
+
if (typeof maxFileSizeBytes === 'number') {
|
|
582
|
+
headers['x-goog-content-length-range'] = `0,${maxFileSizeBytes}`;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// Reject oversize captures here rather than letting GCS do it: past the
|
|
586
|
+
// signed ceiling the bucket answers with the same opaque 400.
|
|
587
|
+
if (typeof maxFileSizeBytes === 'number' && bytes.byteLength > maxFileSizeBytes) {
|
|
588
|
+
throw new Error(
|
|
589
|
+
`Captured image is ${bytes.byteLength} bytes, over the ${maxFileSizeBytes}-byte limit the upload URL was signed for.`,
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// If the signature covers the range header but `documents-init` did not give
|
|
594
|
+
// us the number, the PUT cannot succeed and the reason is a contract gap, not
|
|
595
|
+
// a client bug. Say so before failing, so it is not diagnosed as a signature
|
|
596
|
+
// problem again.
|
|
597
|
+
const required = describeSignedUrl(signedUrl).signedHeaders ?? '';
|
|
598
|
+
if (
|
|
599
|
+
required.includes('x-goog-content-length-range') &&
|
|
600
|
+
typeof maxFileSizeBytes !== 'number'
|
|
601
|
+
) {
|
|
602
|
+
log.warn(
|
|
603
|
+
'[DocumentsOCR] upload URL is signed over x-goog-content-length-range but ' +
|
|
604
|
+
'documents-init returned no max_file_size_bytes — the PUT will be rejected ' +
|
|
605
|
+
'with MalformedSecurityHeader.',
|
|
606
|
+
);
|
|
526
607
|
}
|
|
527
|
-
|
|
608
|
+
|
|
609
|
+
log.info('[DocumentsOCR] uploading side', {
|
|
610
|
+
bytes: bytes.byteLength,
|
|
611
|
+
maxFileSizeBytes: maxFileSizeBytes ?? null,
|
|
612
|
+
sentHeaders: Object.keys(headers),
|
|
613
|
+
});
|
|
614
|
+
const startedAt = Date.now();
|
|
528
615
|
const put = await fetch(signedUrl, {
|
|
529
616
|
method: 'PUT',
|
|
530
|
-
headers
|
|
531
|
-
body:
|
|
617
|
+
headers,
|
|
618
|
+
body: bytes,
|
|
619
|
+
});
|
|
620
|
+
// The bucket echoes back what it stored. `etag` is a checksum of the stored
|
|
621
|
+
// object, so a constant etag across two different captures means nothing
|
|
622
|
+
// reached it — the symptom that took a full manual run to notice before.
|
|
623
|
+
// The signed URL is never logged: it carries the V4 signature.
|
|
624
|
+
log.info('[DocumentsOCR] side uploaded', {
|
|
625
|
+
sentBytes: bytes.byteLength,
|
|
626
|
+
status: put.status,
|
|
627
|
+
etag: put.headers.get('etag'),
|
|
628
|
+
elapsedMs: Date.now() - startedAt,
|
|
532
629
|
});
|
|
533
630
|
if (!put.ok) {
|
|
534
|
-
|
|
631
|
+
// A signed-URL rejection is never self-explanatory from the status alone:
|
|
632
|
+
// 400 covers a stale signature, an expired URL and a Content-Type that
|
|
633
|
+
// does not match what was signed. GCS puts the actual reason in an XML
|
|
634
|
+
// body, so read it before throwing (OSDKR-22).
|
|
635
|
+
let reason = '';
|
|
636
|
+
let body = '';
|
|
637
|
+
try {
|
|
638
|
+
body = (await put.text()).slice(0, 400);
|
|
639
|
+
reason = body.match(/<Code>([^<]+)<\/Code>/)?.[1] ?? '';
|
|
640
|
+
} catch {
|
|
641
|
+
/* body not readable; the status and the signed-URL shape are the signal */
|
|
642
|
+
}
|
|
643
|
+
log.warn('[DocumentsOCR] side upload rejected', {
|
|
644
|
+
status: put.status,
|
|
645
|
+
reason,
|
|
646
|
+
sentBytes: bytes.byteLength,
|
|
647
|
+
sentHeaders: Object.keys(headers),
|
|
648
|
+
// Describes the signed URL without ever exposing its signature. The
|
|
649
|
+
// decisive field is usually `signedHeaders`: it lists the headers the
|
|
650
|
+
// signature covers, so a mismatch with what we actually sent shows up
|
|
651
|
+
// here immediately.
|
|
652
|
+
signedUrl: describeSignedUrl(signedUrl),
|
|
653
|
+
body,
|
|
654
|
+
});
|
|
655
|
+
throw new Error(
|
|
656
|
+
`Signed URL upload failed: HTTP ${put.status}${reason ? ` (${reason})` : ''}`,
|
|
657
|
+
);
|
|
535
658
|
}
|
|
536
659
|
}
|
|
537
660
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
661
|
+
/**
|
|
662
|
+
* Summarises a signed URL for logging — host, path and the signing parameters
|
|
663
|
+
* that explain a rejection — while deliberately omitting `X-Goog-Signature`.
|
|
664
|
+
*
|
|
665
|
+
* `signedHeaders` and `expires` are what actually diagnose a 400: the first
|
|
666
|
+
* says which headers the signature covers, the second whether the URL simply
|
|
667
|
+
* aged out between `documents-init` and the upload.
|
|
668
|
+
*/
|
|
669
|
+
function describeSignedUrl(signedUrl: string): Record<string, string | null> {
|
|
670
|
+
try {
|
|
671
|
+
const url = new URL(signedUrl);
|
|
672
|
+
const q = url.searchParams;
|
|
673
|
+
return {
|
|
674
|
+
host: url.host,
|
|
675
|
+
path: url.pathname,
|
|
676
|
+
algorithm: q.get('X-Goog-Algorithm'),
|
|
677
|
+
date: q.get('X-Goog-Date'),
|
|
678
|
+
expiresIn: q.get('X-Goog-Expires'),
|
|
679
|
+
signedHeaders: q.get('X-Goog-SignedHeaders'),
|
|
680
|
+
hasSignature: q.has('X-Goog-Signature') ? 'yes' : 'no',
|
|
681
|
+
};
|
|
682
|
+
} catch {
|
|
683
|
+
return { parseError: 'could not parse signed URL' };
|
|
684
|
+
}
|
|
543
685
|
}
|
|
544
686
|
|
|
545
687
|
/**
|
|
@@ -41,7 +41,7 @@ import { StepIcon } from '../ui/icons/StepIcon';
|
|
|
41
41
|
import { mixHex, useTheme } from '../ui/theme';
|
|
42
42
|
import { getStrings } from '../i18n';
|
|
43
43
|
import { log } from '../utils/log';
|
|
44
|
-
import { readJpegFromUri } from '../utils/jpegFromUri';
|
|
44
|
+
import { readBytesFromUri, readJpegFromUri } from '../utils/jpegFromUri';
|
|
45
45
|
import {
|
|
46
46
|
buildSignedFrameEnvelope,
|
|
47
47
|
importHmacKey,
|
|
@@ -342,29 +342,43 @@ function LivenessMatchView({
|
|
|
342
342
|
});
|
|
343
343
|
const t0 = Date.now();
|
|
344
344
|
try {
|
|
345
|
-
//
|
|
346
|
-
//
|
|
347
|
-
//
|
|
348
|
-
//
|
|
349
|
-
//
|
|
350
|
-
//
|
|
351
|
-
//
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
345
|
+
// Read the bytes with `expo-file-system`, NOT with `fetch(fileUri)`.
|
|
346
|
+
//
|
|
347
|
+
// This reverses what this code used to do, so it is worth spelling
|
|
348
|
+
// out. Under React Native's `fetch` the native Blob was the reliable
|
|
349
|
+
// body and passing bytes sent an empty one. Since Expo SDK 57 the
|
|
350
|
+
// global `fetch` is Expo's native HTTP client
|
|
351
|
+
// (`expo/src/winter/runtime.native.ts` → `install('fetch', ...)`),
|
|
352
|
+
// which does not handle the `file://` scheme: it answers with an empty
|
|
353
|
+
// body instead of failing, so reading the recording through it
|
|
354
|
+
// uploaded a 0-byte object while every status code reported success
|
|
355
|
+
// (OSDKR-22). Expo's `fetch` does accept any `ArrayBuffer.isView` as a
|
|
356
|
+
// request body, so the bytes go up directly.
|
|
357
|
+
const videoBytes = await readBytesFromUri(video.path);
|
|
356
358
|
log.info('[Liveness] video upload body prepared', {
|
|
357
|
-
|
|
358
|
-
blobType: nativeBlob.type,
|
|
359
|
+
bytes: videoBytes.byteLength,
|
|
359
360
|
});
|
|
361
|
+
if (videoBytes.byteLength === 0) {
|
|
362
|
+
throw new Error('Recorded video read back as 0 bytes.');
|
|
363
|
+
}
|
|
360
364
|
const result = await fetch(target.upload_url, {
|
|
361
365
|
method: 'PUT',
|
|
362
366
|
headers: { 'Content-Type': VIDEO_CONTENT_TYPE },
|
|
363
|
-
body:
|
|
367
|
+
body: videoBytes,
|
|
364
368
|
});
|
|
365
369
|
const elapsedMs = Date.now() - t0;
|
|
366
370
|
if (result.ok) {
|
|
367
|
-
|
|
371
|
+
// `sentBytes` is what we actually put on the wire; `sizeBytes` is
|
|
372
|
+
// the file size stat'd before reading. They must match — a mismatch,
|
|
373
|
+
// or an etag that repeats across sessions, means the body never
|
|
374
|
+
// reached the bucket (OSDKR-22).
|
|
375
|
+
log.info('[Liveness] video upload ok', {
|
|
376
|
+
status: result.status,
|
|
377
|
+
sentBytes: videoBytes.byteLength,
|
|
378
|
+
sizeBytes,
|
|
379
|
+
etag: result.headers.get('etag'),
|
|
380
|
+
elapsedMs,
|
|
381
|
+
});
|
|
368
382
|
videoOutcomeRef.current = 'uploaded';
|
|
369
383
|
videoMetaRef.current = {
|
|
370
384
|
content_type: VIDEO_CONTENT_TYPE,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview StepIcon — small wrapper around `MaterialIcons
|
|
3
|
-
* `@expo/vector-icons
|
|
2
|
+
* @fileoverview StepIcon — small wrapper around `MaterialIcons`, shipped with
|
|
3
|
+
* `@expo/vector-icons`.
|
|
4
|
+
*
|
|
5
|
+
* That package is an OPTIONAL peer dependency the host installs itself. It
|
|
6
|
+
* used to arrive for free because `expo` depended on it, but `expo@57` dropped
|
|
7
|
+
* that dependency, so relying on it silently blanked every step icon
|
|
8
|
+
* (OSDKR-21). Nothing here assumes it is present.
|
|
4
9
|
*
|
|
5
10
|
* Steps pass an icon by name (e.g. `<StepIcon name="badge" />`) and the
|
|
6
11
|
* shell renders it inside the colored circle next to the title. When the
|
|
@@ -46,7 +51,8 @@ try {
|
|
|
46
51
|
} catch {
|
|
47
52
|
log.warn(
|
|
48
53
|
'[StepIcon] @expo/vector-icons is not installed — step header icons will be hidden. ' +
|
|
49
|
-
'
|
|
54
|
+
'Install it (`npx expo install @expo/vector-icons`) or set VelionTheme.hideStepIcons=true. ' +
|
|
55
|
+
'Note it is no longer bundled with expo: since SDK 57 the host has to add it explicitly.',
|
|
50
56
|
);
|
|
51
57
|
}
|
|
52
58
|
|
package/src/utils/jpegFromUri.ts
CHANGED
|
@@ -5,14 +5,23 @@
|
|
|
5
5
|
* path into either base64 (for the Iris HMAC envelope) or raw bytes (for
|
|
6
6
|
* binary WebSocket frames + direct PUT to signed URLs).
|
|
7
7
|
*
|
|
8
|
-
* Why not `fetch(uri)
|
|
8
|
+
* Why not `fetch(uri)`?
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
10
|
+
* Two independent reasons, and the second one is the load-bearing one now:
|
|
11
|
+
*
|
|
12
|
+
* 1. React Native's Blob polyfill does NOT implement `Blob.arrayBuffer()`
|
|
13
|
+
* (it's web-only) — calling it throws `blob.arrayBuffer is not a
|
|
14
|
+
* function`.
|
|
15
|
+
* 2. **`fetch` cannot read local files at all since Expo SDK 57.** Expo now
|
|
16
|
+
* replaces the global `fetch` (`expo/src/winter/runtime.native.ts`:
|
|
17
|
+
* `install('fetch', ...)`) with a native HTTP client, and that client does
|
|
18
|
+
* not handle the `file://` scheme. It answers with an empty body instead
|
|
19
|
+
* of failing, so anything reading a capture through `fetch` silently
|
|
20
|
+
* uploads 0 bytes (OSDKR-22). SDK 54 did not install it, which is why the
|
|
21
|
+
* old code worked.
|
|
22
|
+
*
|
|
23
|
+
* `File.arrayBuffer()` from `expo-file-system` reads straight from disk and is
|
|
24
|
+
* unaffected by either.
|
|
16
25
|
*/
|
|
17
26
|
|
|
18
27
|
import { File } from 'expo-file-system';
|
|
@@ -25,18 +34,47 @@ export interface JpegFromUri {
|
|
|
25
34
|
}
|
|
26
35
|
|
|
27
36
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* Accepts both forms vision-camera returns (`/var/mobile/...` without a
|
|
31
|
-
* scheme on iOS; `file:///data/...` on Android). Normalises to `file://`.
|
|
37
|
+
* Normalises the path forms vision-camera returns (`/var/mobile/...` without a
|
|
38
|
+
* scheme on iOS; `file:///data/...` on Android) to a `file://` URI.
|
|
32
39
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
function normalise(uri: string): string {
|
|
41
|
+
return uri.startsWith('file://') || uri.startsWith('http')
|
|
35
42
|
? uri
|
|
36
43
|
: `file://${uri}`;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Reads a local file into raw bytes.
|
|
48
|
+
*
|
|
49
|
+
* Prefer this over `readJpegFromUri` when the caller only needs the bytes —
|
|
50
|
+
* uploads, for instance. It skips the base64 encoding, which is pure waste for
|
|
51
|
+
* a multi-megabyte video.
|
|
52
|
+
*/
|
|
53
|
+
export async function readBytesFromUri(uri: string): Promise<Uint8Array> {
|
|
54
|
+
const buf = await new File(normalise(uri)).arrayBuffer();
|
|
55
|
+
return new Uint8Array(buf);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Size of a local file in bytes, or `0` when it cannot be read.
|
|
60
|
+
*
|
|
61
|
+
* Reads the filesystem metadata instead of loading the contents, so it stays
|
|
62
|
+
* cheap enough to call before an upload.
|
|
63
|
+
*/
|
|
64
|
+
export function byteLengthOfUri(uri: string): number {
|
|
65
|
+
try {
|
|
66
|
+
const size = new File(normalise(uri)).size;
|
|
67
|
+
return typeof size === 'number' ? size : 0;
|
|
68
|
+
} catch {
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Reads a `file://` URI into JPEG bytes + base64 representation.
|
|
75
|
+
*/
|
|
76
|
+
export async function readJpegFromUri(uri: string): Promise<JpegFromUri> {
|
|
77
|
+
const bytes = await readBytesFromUri(uri);
|
|
40
78
|
const base64 = bytesToBase64(bytes);
|
|
41
79
|
return { bytes, base64, byteLength: bytes.byteLength };
|
|
42
80
|
}
|