22
33import forge from 'node-forge' ;
44
5- import {
6- WS_DB_RELAYER ,
7- WS_DB_RELAYER_STAGING ,
8- } from '@selfxyz/common/constants' ;
9- import type { EndpointType } from '@selfxyz/common/utils' ;
10- import { initElliptic } from '@selfxyz/common/utils' ;
5+ import { WS_DB_RELAYER , WS_DB_RELAYER_STAGING } from '../constants/index.js' ;
6+ import { initElliptic } from '../utils/certificate_parsing/elliptic.js' ;
7+ import type { EndpointType } from './appType.js' ;
118
129const elliptic = initElliptic ( ) ;
1310const { ec : EC } = elliptic ;
@@ -32,28 +29,24 @@ export type TEEPayloadDisclose = TEEPayloadBase & {
3229 version : number ;
3330} ;
3431
32+ // // eslint-disable-next-line -- ec must be created first
3533export const ec = new EC ( 'p256' ) ;
36-
34+ // eslint-disable-next-line -- clientKey is created from ec so must be second
3735export const clientKey = ec . genKeyPair ( ) ;
3836
3937type RegisterSuffixes = '' | '_id' ;
4038type DscSuffixes = '' | '_id' ;
4139type DiscloseSuffixes = '' | '_id' ;
4240type ProofTypes = 'register' | 'dsc' | 'disclose' ;
43- type RegisterProofType =
44- `${Extract < ProofTypes , 'register' > } ${RegisterSuffixes } `;
41+ type RegisterProofType = `${Extract < ProofTypes , 'register' > } ${RegisterSuffixes } `;
4542type DscProofType = `${Extract < ProofTypes , 'dsc' > } ${DscSuffixes } `;
46- type DiscloseProofType =
47- `${Extract < ProofTypes , 'disclose' > } ${DiscloseSuffixes } `;
43+ type DiscloseProofType = `${Extract < ProofTypes , 'disclose' > } ${DiscloseSuffixes } `;
4844
4945export const clientPublicKeyHex =
5046 clientKey . getPublic ( ) . getX ( ) . toString ( 'hex' ) . padStart ( 64 , '0' ) +
5147 clientKey . getPublic ( ) . getY ( ) . toString ( 'hex' ) . padStart ( 64 , '0' ) ;
5248
53- export function encryptAES256GCM (
54- plaintext : string ,
55- key : forge . util . ByteStringBuffer ,
56- ) {
49+ export function encryptAES256GCM ( plaintext : string , key : forge . util . ByteStringBuffer ) {
5750 const iv = forge . random . getBytesSync ( 12 ) ;
5851 const cipher = forge . cipher . createCipher ( 'AES-GCM' , key ) ;
5952 cipher . start ( { iv : iv , tagLength : 128 } ) ;
@@ -75,7 +68,7 @@ export function getPayload(
7568 endpointType : EndpointType ,
7669 endpoint : string ,
7770 version : number = 1 ,
78- userDefinedData : string = '' ,
71+ userDefinedData : string = ''
7972) {
8073 if ( circuitType === 'disclose' ) {
8174 const payload : TEEPayloadDisclose = {
0 commit comments