Socket
Socket
Sign inDemoInstall

@signalapp/mock-server

Package Overview
Dependencies
Maintainers
6
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@signalapp/mock-server - npm Package Compare versions

Comparing version 6.5.0 to 6.6.0

2

package.json
{
"name": "@signalapp/mock-server",
"version": "6.5.0",
"version": "6.6.0",
"description": "Mock Signal Server for writing tests",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -1,2 +0,1 @@

/// <reference types="node" />
import z from 'zod';

@@ -7,3 +6,3 @@ import { AciString, DeviceId, PniString, RegistrationId } from '../types';

export declare const PniSchema: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, PniString, string>;
export declare const ServiceIdSchema: z.ZodEffects<z.ZodString, PniString | AciString, string>;
export declare const ServiceIdSchema: z.ZodEffects<z.ZodString, AciString | PniString, string>;
export declare const RegistrationIdSchema: z.ZodEffects<z.ZodNumber, RegistrationId, number>;

@@ -15,7 +14,7 @@ export declare const DeviceIdSchema: z.ZodEffects<z.ZodNumber, DeviceId, number>;

}, "strip", z.ZodTypeAny, {
publicKey: string;
keyId: number;
}, {
publicKey: string;
}, {
keyId: number;
publicKey: string;
}>;

@@ -28,8 +27,8 @@ export type ServerPreKey = z.infer<typeof PreKeySchema>;

}, "strip", z.ZodTypeAny, {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
}, {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;

@@ -43,7 +42,7 @@ }>;

}, "strip", z.ZodTypeAny, {
publicKey: string;
keyId: number;
}, {
publicKey: string;
}, {
keyId: number;
publicKey: string;
}>, "many">;

@@ -55,8 +54,8 @@ pqPreKeys: z.ZodOptional<z.ZodArray<z.ZodObject<{

}, "strip", z.ZodTypeAny, {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
}, {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;

@@ -69,8 +68,8 @@ }>, "many">>;

}, "strip", z.ZodTypeAny, {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
}, {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;

@@ -83,8 +82,8 @@ }>>;

}, "strip", z.ZodTypeAny, {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
}, {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;

@@ -94,18 +93,18 @@ }>>;

preKeys: {
publicKey: string;
keyId: number;
publicKey: string;
}[];
pqPreKeys?: {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
}[] | undefined;
pqLastResortPreKey?: {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
} | undefined;
signedPreKey?: {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;

@@ -115,18 +114,18 @@ } | undefined;

preKeys: {
publicKey: string;
keyId: number;
publicKey: string;
}[];
pqPreKeys?: {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
}[] | undefined;
pqLastResortPreKey?: {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
} | undefined;
signedPreKey?: {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;

@@ -143,3 +142,2 @@ } | undefined;

type: number;
content: string;
destinationDeviceId: number & {

@@ -151,7 +149,8 @@ __device_id: never;

};
content: string;
}, {
type: number;
content: string;
destinationDeviceId: number;
destinationRegistrationId: number;
content: string;
}>;

@@ -167,3 +166,2 @@ export type Message = z.infer<typeof MessageSchema>;

type: number;
content: string;
destinationDeviceId: number & {

@@ -175,14 +173,13 @@ __device_id: never;

};
content: string;
}, {
type: number;
content: string;
destinationDeviceId: number;
destinationRegistrationId: number;
content: string;
}>, "many">;
timestamp: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
timestamp: number;
messages: {
type: number;
content: string;
destinationDeviceId: number & {

@@ -194,11 +191,13 @@ __device_id: never;

};
content: string;
}[];
timestamp: number;
}, {
timestamp: number;
messages: {
type: number;
content: string;
destinationDeviceId: number;
destinationRegistrationId: number;
content: string;
}[];
timestamp: number;
}>;

@@ -214,15 +213,15 @@ export type MessageList = z.infer<typeof MessageListSchema>;

}, "strip", z.ZodTypeAny, {
pniRegistrationId: number & {
registrationId: number & {
__reg_id: never;
};
registrationId: number & {
pniRegistrationId: number & {
__reg_id: never;
};
name: string;
fetchesMessages: boolean;
name: string;
}, {
registrationId: number;
pniRegistrationId: number;
registrationId: number;
name: string;
fetchesMessages: boolean;
name: string;
}>;

@@ -234,8 +233,8 @@ aciSignedPreKey: z.ZodObject<{

}, "strip", z.ZodTypeAny, {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
}, {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;

@@ -248,8 +247,8 @@ }>;

}, "strip", z.ZodTypeAny, {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
}, {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;

@@ -262,8 +261,8 @@ }>;

}, "strip", z.ZodTypeAny, {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
}, {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;

@@ -276,8 +275,8 @@ }>;

}, "strip", z.ZodTypeAny, {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
}, {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;

@@ -288,29 +287,29 @@ }>;

accountAttributes: {
pniRegistrationId: number & {
registrationId: number & {
__reg_id: never;
};
registrationId: number & {
pniRegistrationId: number & {
__reg_id: never;
};
name: string;
fetchesMessages: boolean;
name: string;
};
aciSignedPreKey: {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
};
pniSignedPreKey: {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
};
aciPqLastResortPreKey: {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
};
pniPqLastResortPreKey: {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;

@@ -321,25 +320,25 @@ };

accountAttributes: {
registrationId: number;
pniRegistrationId: number;
registrationId: number;
name: string;
fetchesMessages: boolean;
name: string;
};
aciSignedPreKey: {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
};
pniSignedPreKey: {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
};
aciPqLastResortPreKey: {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;
};
pniPqLastResortPreKey: {
publicKey: string;
keyId: number;
publicKey: string;
signature: string;

@@ -414,2 +413,46 @@ };

export type PutUsernameLink = z.infer<typeof PutUsernameLinkSchema>;
export declare const CreateCallLinkAuthSchema: z.ZodObject<{
createCallLinkCredentialRequest: z.ZodEffects<z.ZodString, Buffer, string>;
}, "strip", z.ZodTypeAny, {
createCallLinkCredentialRequest: Buffer;
}, {
createCallLinkCredentialRequest: string;
}>;
export type CreateCallLinkAuth = z.infer<typeof CreateCallLinkAuthSchema>;
export declare const CreateCallLinkSchema: z.ZodObject<{
adminPasskey: z.ZodEffects<z.ZodString, Buffer, string>;
zkparams: z.ZodEffects<z.ZodString, Buffer, string>;
}, "strip", z.ZodTypeAny, {
adminPasskey: Buffer;
zkparams: Buffer;
}, {
adminPasskey: string;
zkparams: string;
}>;
export type CreateCallLink = z.infer<typeof CreateCallLinkSchema>;
export declare const UpdateCallLinkSchema: z.ZodObject<{
adminPasskey: z.ZodEffects<z.ZodString, Buffer, string>;
name: z.ZodOptional<z.ZodString>;
restrictions: z.ZodOptional<z.ZodEnum<["none", "adminApproval"]>>;
revoked: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
adminPasskey: Buffer;
name?: string | undefined;
restrictions?: "none" | "adminApproval" | undefined;
revoked?: boolean | undefined;
}, {
adminPasskey: string;
name?: string | undefined;
restrictions?: "none" | "adminApproval" | undefined;
revoked?: boolean | undefined;
}>;
export type UpdateCallLink = z.infer<typeof UpdateCallLinkSchema>;
export declare const DeleteCallLinkSchema: z.ZodObject<{
adminPasskey: z.ZodEffects<z.ZodString, Buffer, string>;
}, "strip", z.ZodTypeAny, {
adminPasskey: Buffer;
}, {
adminPasskey: string;
}>;
export type DeleteCallLink = z.infer<typeof DeleteCallLinkSchema>;
export {};

@@ -8,3 +8,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.PutUsernameLinkSchema = exports.UsernameConfirmationSchema = exports.UsernameReservationSchema = exports.GroupStateSchema = exports.AtomicLinkingDataSchema = exports.MessageListSchema = exports.MessageSchema = exports.DeviceKeysSchema = exports.DeviceIdSchema = exports.RegistrationIdSchema = exports.ServiceIdSchema = exports.PniSchema = exports.AciSchema = exports.PositiveInt = void 0;
exports.DeleteCallLinkSchema = exports.UpdateCallLinkSchema = exports.CreateCallLinkSchema = exports.CreateCallLinkAuthSchema = exports.PutUsernameLinkSchema = exports.UsernameConfirmationSchema = exports.UsernameReservationSchema = exports.GroupStateSchema = exports.AtomicLinkingDataSchema = exports.MessageListSchema = exports.MessageSchema = exports.DeviceKeysSchema = exports.DeviceIdSchema = exports.RegistrationIdSchema = exports.ServiceIdSchema = exports.PniSchema = exports.AciSchema = exports.PositiveInt = void 0;
const zod_1 = __importDefault(require("zod"));

@@ -81,1 +81,17 @@ const util_1 = require("../util");

});
exports.CreateCallLinkAuthSchema = zod_1.default.object({
createCallLinkCredentialRequest: zod_1.default.string().transform(util_1.fromBase64),
});
exports.CreateCallLinkSchema = zod_1.default.object({
adminPasskey: zod_1.default.string().transform(util_1.fromBase64),
zkparams: zod_1.default.string().transform(util_1.fromBase64),
});
exports.UpdateCallLinkSchema = zod_1.default.object({
adminPasskey: zod_1.default.string().transform(util_1.fromBase64),
name: zod_1.default.string().optional(),
restrictions: zod_1.default.enum(['none', 'adminApproval']).optional(),
revoked: zod_1.default.boolean().optional(),
});
exports.DeleteCallLinkSchema = zod_1.default.object({
adminPasskey: zod_1.default.string().transform(util_1.fromBase64),
});
/// <reference types="node" />
import { SenderCertificate } from '@signalapp/libsignal-client';
import { AuthCredentialPresentation, CreateCallLinkCredentialRequest, CreateCallLinkCredentialResponse, GenericServerSecretParams, ProfileKeyCredentialRequest, ServerSecretParams } from '@signalapp/libsignal-client/zkgroup';
import Long from 'long';
import { SenderCertificate } from '@signalapp/libsignal-client';
import { AuthCredentialPresentation, GenericServerSecretParams, ProfileKeyCredentialRequest, ServerSecretParams } from '@signalapp/libsignal-client/zkgroup';
import { signalservice as Proto } from '../../protos/compiled';
import { ServerCertificate } from '../crypto';
import { ChangeNumberOptions, Device, DeviceKeys } from '../data/device';
import { CreateCallLink, DeleteCallLink, Message, UpdateCallLink, UsernameConfirmation, UsernameReservation } from '../data/schemas';
import { AciString, AttachmentId, DeviceId, PniString, ProvisionIdString, ProvisioningCode, RegistrationId, ServiceIdKind, ServiceIdString } from '../types';
import { Message, UsernameConfirmation, UsernameReservation } from '../data/schemas';
import { ModifyGroupResult, ServerGroup } from './group';

@@ -107,2 +107,9 @@ export declare enum EnvelopeType {

}
export type CallLinkEntry = Readonly<{
adminPasskey: Buffer;
encryptedName: string;
restrictions: 'none' | 'adminApproval';
revoked: boolean;
expiration: number;
}>;
export declare abstract class Server {

@@ -130,2 +137,3 @@ private readonly devices;

private readonly usernameLinkById;
private readonly callLinksByRoomId;
protected privCertificate: ServerCertificate | undefined;

@@ -179,2 +187,8 @@ protected privZKSecret: ServerSecretParams | undefined;

setUsernameLink(aci: AciString, username: string): Promise<SetUsernameLinkResult>;
createCallLinkAuth(device: Device, request: CreateCallLinkCredentialRequest): Promise<CreateCallLinkCredentialResponse>;
hasCallLink(roomId: string): boolean;
createCallLink(roomId: string, { adminPasskey }: CreateCallLink): Promise<CallLinkEntry>;
getCallLink(roomId: string): Promise<CallLinkEntry | undefined>;
updateCallLink(roomId: string, { adminPasskey, name, restrictions, revoked }: UpdateCallLink): Promise<CallLinkEntry>;
deleteCallLink(roomId: string, { adminPasskey }: DeleteCallLink): Promise<void>;
getDevice(number: string, deviceId: DeviceId): Promise<Device | undefined>;

@@ -181,0 +195,0 @@ getDeviceByServiceId(serviceId: ServiceIdString, deviceId?: DeviceId): Promise<Device | undefined>;

@@ -9,12 +9,12 @@ "use strict";

exports.Server = exports.EnvelopeType = void 0;
const libsignal_client_1 = require("@signalapp/libsignal-client");
const zkgroup_1 = require("@signalapp/libsignal-client/zkgroup");
const assert_1 = __importDefault(require("assert"));
const crypto_1 = __importDefault(require("crypto"));
const debug_1 = __importDefault(require("debug"));
const uuid_1 = require("uuid");
const debug_1 = __importDefault(require("debug"));
const libsignal_client_1 = require("@signalapp/libsignal-client");
const zkgroup_1 = require("@signalapp/libsignal-client/zkgroup");
const compiled_1 = require("../../protos/compiled");
const constants_1 = require("../constants");
const crypto_2 = require("../crypto");
const device_1 = require("../data/device");
const constants_1 = require("../constants");
const types_1 = require("../types");

@@ -54,2 +54,3 @@ const util_1 = require("../util");

usernameLinkById = new Map();
callLinksByRoomId = new Map();
privCertificate;

@@ -610,2 +611,53 @@ privZKSecret;

//
// Call Links
//
async createCallLinkAuth(device, request) {
return request.issueCredential(libsignal_client_1.Aci.parseFromServiceIdString(device.aci), (0, util_1.getTodayInSeconds)(), this.genericServerSecret);
}
hasCallLink(roomId) {
return this.callLinksByRoomId.has(roomId);
}
async createCallLink(roomId, { adminPasskey }) {
const callLink = {
adminPasskey,
encryptedName: '',
restrictions: 'none',
revoked: false,
expiration: new Date('2101-01-01').getTime(),
};
this.callLinksByRoomId.set(roomId, callLink);
return callLink;
}
async getCallLink(roomId) {
return this.callLinksByRoomId.get(roomId);
}
async updateCallLink(roomId, { adminPasskey, name, restrictions, revoked }) {
const callLink = this.callLinksByRoomId.get(roomId);
if (!callLink) {
throw new Error('Call link not found');
}
if (!callLink.adminPasskey.equals(adminPasskey)) {
throw new Error('Invalid admin passkey');
}
const newCallLink = {
adminPasskey,
encryptedName: name ?? callLink.encryptedName,
restrictions: restrictions ?? callLink.restrictions,
revoked: revoked ?? callLink.revoked,
expiration: callLink.expiration,
};
this.callLinksByRoomId.set(roomId, newCallLink);
return newCallLink;
}
async deleteCallLink(roomId, { adminPasskey }) {
const callLink = this.callLinksByRoomId.get(roomId);
if (!callLink) {
throw new Error('Call link not found');
}
if (!callLink.adminPasskey.equals(adminPasskey)) {
throw new Error('Invalid admin passkey');
}
this.callLinksByRoomId.delete(roomId);
}
//
// Utils

@@ -612,0 +664,0 @@ //

@@ -9,15 +9,14 @@ "use strict";

exports.ServerGroup = void 0;
const zkgroup_1 = require("@signalapp/libsignal-client/zkgroup");
const assert_1 = __importDefault(require("assert"));
const long_1 = __importDefault(require("long"));
const zkgroup_1 = require("@signalapp/libsignal-client/zkgroup");
const compiled_1 = require("../../protos/compiled");
const group_1 = require("../data/group");
const schemas_1 = require("../data/schemas");
const util_1 = require("../util");
const { AccessRequired } = compiled_1.signalservice.AccessControl;
const { Role } = compiled_1.signalservice.Member;
const SECONDS_PER_DAY = 86400;
function getTodaysKey(zkSecret) {
const now = Math.floor(Date.now() / 1000);
const startOfDay = now - (now % SECONDS_PER_DAY);
const expiration = startOfDay + 2 * SECONDS_PER_DAY;
const startOfDay = (0, util_1.getTodayInSeconds)();
const expiration = startOfDay + (0, util_1.daysToSeconds)(2);
return zkgroup_1.GroupSendDerivedKeyPair.forExpiration(new Date(1000 * expiration), zkSecret);

@@ -24,0 +23,0 @@ }

@@ -9,13 +9,14 @@ "use strict";

exports.createHandler = void 0;
const zkgroup_1 = require("@signalapp/libsignal-client/zkgroup");
const assert_1 = __importDefault(require("assert"));
const buffer_1 = require("buffer");
const debug_1 = __importDefault(require("debug"));
const long_1 = __importDefault(require("long"));
const buffer_1 = require("buffer");
const micro_1 = require("micro");
const microrouter_1 = require("microrouter");
const debug_1 = __importDefault(require("debug"));
const compiled_1 = require("../../protos/compiled");
const crypto_1 = require("../crypto");
const util_1 = require("../util");
const schemas_1 = require("../data/schemas");
const types_1 = require("../types");
const compiled_1 = require("../../protos/compiled");
const util_1 = require("../util");
const debug = (0, debug_1.default)('mock:http');

@@ -111,2 +112,50 @@ const parsePassword = (req) => {

//
// Calling
//
function toCallLinkResponse(callLink) {
return {
name: callLink.encryptedName,
restrictions: String(callLink.restrictions),
revoked: callLink.revoked,
expiration: Math.floor(callLink.expiration / 1000), // unix
};
}
const getCallLink = (0, microrouter_1.get)('/v1/call-link/', async (req, res) => {
const roomId = req.headers['x-room-id'];
if (typeof roomId !== 'string') {
return (0, micro_1.send)(res, 400, { error: 'Missing room ID' });
}
const callLink = await server.getCallLink(roomId);
if (!callLink) {
return (0, micro_1.send)(res, 404, { error: 'Call link not found' });
}
return toCallLinkResponse(callLink);
});
const createOrUpdateCallLink = (0, microrouter_1.put)('/v1/call-link', async (req, res) => {
const roomId = req.headers['x-room-id'];
if (typeof roomId !== 'string') {
return (0, micro_1.send)(res, 400, { error: 'Missing room ID' });
}
const body = await (0, micro_1.json)(req);
let callLink;
if (!server.hasCallLink(roomId)) {
const createParams = schemas_1.CreateCallLinkSchema.parse(body);
callLink = await server.createCallLink(roomId, createParams);
}
else {
const updateParams = schemas_1.UpdateCallLinkSchema.parse(body);
callLink = await server.updateCallLink(roomId, updateParams);
}
return toCallLinkResponse(callLink);
});
const deleteCallLink = (0, microrouter_1.del)('/v1/call-link', async (req, res) => {
const roomId = req.headers['x-room-id'];
if (typeof roomId !== 'string') {
return (0, micro_1.send)(res, 400, { error: 'Missing room ID' });
}
const deleteParams = schemas_1.DeleteCallLinkSchema.parse(await (0, micro_1.json)(req));
await server.deleteCallLink(roomId, deleteParams);
return null;
});
//
// Authorized requests

@@ -297,2 +346,18 @@ //

//
// Call links
//
const createCallLinkAuth = (0, microrouter_1.post)('/v1/call-link/create-auth', async (req, res) => {
const device = await auth(req, res);
if (!device) {
return;
}
const body = schemas_1.CreateCallLinkAuthSchema.parse(await (0, micro_1.json)(req));
const request = new zkgroup_1.CreateCallLinkCredentialRequest(body.createCallLinkCredentialRequest);
const response = await server.createCallLinkAuth(device, request);
return {
redemptionTime: -Date.now(),
credential: (0, util_1.toBase64)(response.serialize()),
};
});
//
// Captcha

@@ -570,5 +635,5 @@ //

// TODO(indutny): support nameless devices? They use different route
getDeviceKeys, getAllDeviceKeys, getAttachment, getStickerPack, getSticker, putKeys, getKeys, whoami, reserveUsername, confirmUsername, deleteUsername, lookupByUsernameHash, lookupByUsernameLink, replaceUsernameLink, putChallenge,
getDeviceKeys, getAllDeviceKeys, getAttachment, getStickerPack, getSticker, putKeys, getKeys, whoami, reserveUsername, confirmUsername, deleteUsername, lookupByUsernameHash, lookupByUsernameLink, replaceUsernameLink, createCallLinkAuth, putChallenge,
// Technically these should live on a separate server, but who cares
getGroupV1, getGroup, getGroupVersion, getGroupLogsV1, getGroupLogs, createGroupV1, createGroup, modifyGroupV1, modifyGroup, getStorageManifest, getStorageManifestByVersion, putStorage, putStorageRead,
getGroupV1, getGroup, getGroupVersion, getGroupLogsV1, getGroupLogs, createGroupV1, createGroup, modifyGroupV1, modifyGroup, getStorageManifest, getStorageManifestByVersion, putStorage, putStorageRead, getCallLink, createOrUpdateCallLink, deleteCallLink,
// TODO(indutny): support this

@@ -575,0 +640,0 @@ (0, microrouter_1.get)('/v1/groups/token', notFound), (0, microrouter_1.get)('/stickers/', notFound), (0, microrouter_1.get)('/*', notFoundAfterAuth), (0, microrouter_1.put)('/*', notFoundAfterAuth));

@@ -29,4 +29,7 @@ /// <reference types="node" />

export declare function getTodayInSeconds(): number;
export declare function daysToSeconds(days: number): number;
export declare function generateRegistrationId(): RegistrationId;
export declare function toBase64(buf: Uint8Array): string;
export declare function toURLSafeBase64(buf: Uint8Array): string;
export declare function fromBase64(base64: string): Buffer;
export declare function fromURLSafeBase64(base64: string): Buffer;

@@ -8,3 +8,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.fromURLSafeBase64 = exports.toURLSafeBase64 = exports.generateRegistrationId = exports.getTodayInSeconds = exports.addressToString = exports.PromiseQueue = exports.parseAuthHeader = exports.generateRandomE164 = void 0;
exports.fromURLSafeBase64 = exports.fromBase64 = exports.toURLSafeBase64 = exports.toBase64 = exports.generateRegistrationId = exports.daysToSeconds = exports.getTodayInSeconds = exports.addressToString = exports.PromiseQueue = exports.parseAuthHeader = exports.generateRandomE164 = void 0;
const assert_1 = __importDefault(require("assert"));

@@ -141,2 +141,6 @@ const constants_1 = require("./constants");

exports.getTodayInSeconds = getTodayInSeconds;
function daysToSeconds(days) {
return days * constants_1.DAY_IN_SECONDS;
}
exports.daysToSeconds = daysToSeconds;
function generateRegistrationId() {

@@ -146,5 +150,8 @@ return Math.max(1, (Math.random() * 0x4000) | 0);

exports.generateRegistrationId = generateRegistrationId;
function toBase64(buf) {
return Buffer.from(buf).toString('base64');
}
exports.toBase64 = toBase64;
function toURLSafeBase64(buf) {
return Buffer.from(buf)
.toString('base64')
return toBase64(buf)
.replace(/\+/g, '-')

@@ -155,2 +162,6 @@ .replace(/\//g, '_')

exports.toURLSafeBase64 = toURLSafeBase64;
function fromBase64(base64) {
return Buffer.from(base64, 'base64');
}
exports.fromBase64 = fromBase64;
function fromURLSafeBase64(base64) {

@@ -160,4 +171,4 @@ const source = base64.replace(/-/g, '+').replace(/_/g, '/');

// restore it.
return Buffer.from(source, 'base64');
return fromBase64(source);
}
exports.fromURLSafeBase64 = fromURLSafeBase64;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc