Via
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
import { TwoFactorAuthorizationResponse } from "ente-accounts/services/user";
|
||||
import { clientPackageName } from "ente-base/app";
|
||||
import {
|
||||
fromB64URLSafeNoPadding,
|
||||
toB64URLSafeNoPadding,
|
||||
} from "ente-base/crypto/libsodium";
|
||||
import { toB64URLSafeNoPadding, fromB64URLSafeNoPadding } from "ente-base/crypto";
|
||||
import { isDevBuild } from "ente-base/env";
|
||||
import { ensureOk, HTTPError, publicRequestHeaders } from "ente-base/http";
|
||||
import { apiURL } from "ente-base/origins";
|
||||
|
||||
@@ -6,8 +6,10 @@ import * as libsodium from "./libsodium";
|
||||
// See: [Note: Using libsodium in worker thread]
|
||||
|
||||
export const _toB64 = libsodium.toB64;
|
||||
export const _toB64URLSafe = libsodium.toB64URLSafe;
|
||||
export const _fromB64 = libsodium.fromB64;
|
||||
export const _toB64URLSafe = libsodium.toB64URLSafe;
|
||||
export const _toB64URLSafeNoPadding = libsodium.toB64URLSafeNoPadding;
|
||||
export const _fromB64URLSafeNoPadding = libsodium.fromB64URLSafeNoPadding;
|
||||
export const _toHex = libsodium.toHex;
|
||||
export const _fromHex = libsodium.fromHex;
|
||||
export const _generateKey = libsodium.generateKey;
|
||||
|
||||
@@ -150,6 +150,25 @@ export const toB64URLSafe = (bytes: Uint8Array): Promise<string> =>
|
||||
? ei._toB64URLSafe(bytes)
|
||||
: sharedWorker().then((w) => w.toB64URLSafe(bytes));
|
||||
|
||||
/**
|
||||
* URL safe variant of {@link toB64} that does not add any padding ("="
|
||||
* characters).
|
||||
*/
|
||||
export const toB64URLSafeNoPadding = (bytes: Uint8Array): Promise<string> =>
|
||||
inWorker()
|
||||
? ei._toB64URLSafeNoPadding(bytes)
|
||||
: sharedWorker().then((w) => w.toB64URLSafeNoPadding(bytes));
|
||||
|
||||
/**
|
||||
* URL safe unpadded variant of {@link fromB64}.
|
||||
*/
|
||||
export const fromB64URLSafeNoPadding = (
|
||||
b64String: string,
|
||||
): Promise<Uint8Array> =>
|
||||
inWorker()
|
||||
? ei._fromB64URLSafeNoPadding(b64String)
|
||||
: sharedWorker().then((w) => w.fromB64URLSafeNoPadding(b64String));
|
||||
|
||||
/**
|
||||
* Convert a base64 string to the hex representation of the underlying bytes.
|
||||
*/
|
||||
|
||||
@@ -13,8 +13,10 @@ import * as ei from "./ente-impl";
|
||||
*/
|
||||
export class CryptoWorker {
|
||||
toB64 = ei._toB64;
|
||||
toB64URLSafe = ei._toB64URLSafe;
|
||||
fromB64 = ei._fromB64;
|
||||
toB64URLSafe = ei._toB64URLSafe;
|
||||
toB64URLSafeNoPadding = ei._toB64URLSafeNoPadding;
|
||||
fromB64URLSafeNoPadding = ei._fromB64URLSafeNoPadding;
|
||||
toHex = ei._toHex;
|
||||
fromHex = ei._fromHex;
|
||||
generateKey = ei._generateKey;
|
||||
|
||||
Reference in New Issue
Block a user