Merge pull request #395 from selfxyz/feat/mock-passport

add staging proving flow
This commit is contained in:
turnoffthiscomputer
2025-03-09 14:24:17 -04:00
committed by GitHub
12 changed files with 411 additions and 354 deletions

View File

@@ -7,10 +7,12 @@ export const DEFAULT_USER_ID_TYPE = 'uuid';
export const REDIRECT_URL = 'https://redirect.self.xyz';
export const WS_RPC_URL_VC_AND_DISCLOSE = "ws://disclose.proving.self.xyz:8888/";
export const WS_DB_RELAYER = 'wss://websocket.self.xyz';
export const WS_DB_RELAYER_STAGING = 'wss://websocket.staging.self.xyz';
export const API_URL = 'https://api.self.xyz';
export const CSCA_TREE_URL = 'https://tree.self.xyz/csca';
export const DSC_TREE_URL = 'https://tree.self.xyz/dsc';
export const CSCA_TREE_URL_STAGING = 'https://tree.staging.self.xyz/csca';
export const DSC_TREE_URL_STAGING = 'https://tree.staging.self.xyz/dsc';
export const IDENTITY_TREE_URL = 'https://tree.self.xyz/identity';
export const PASSPORT_ATTESTATION_ID = '1'; //"8518753152044246090169372947057357973469996808638122125210848696986717482788"

View File

@@ -1,7 +1,7 @@
import { UserIdType, validateUserId } from "./circuits/uuid";
export type Mode = 'register' | 'dsc' | 'vc_and_disclose';
export type EndpointType = 'https' | 'celo';
export type EndpointType = 'https' | 'celo' | 'staging_celo';
import { v4 } from 'uuid';
import { Country3LetterCode } from "../constants/constants";
@@ -68,10 +68,10 @@ export class SelfAppBuilder {
}
this.config = {
sessionId : v4(),
userIdType : 'uuid',
devMode : false,
endpointType : 'https',
sessionId: v4(),
userIdType: 'uuid',
devMode: false,
endpointType: 'https',
header: "",
logoBase64: "",
disclosures: {},

View File

@@ -8,7 +8,7 @@ import {
import { PassportData } from '../types';
import { LeanIMT } from '@openpassport/zk-kit-lean-imt';
import { getCountryLeaf, getNameDobLeaf, getPassportNumberAndNationalityLeaf, getLeafCscaTree, getLeafDscTree, getNameYobLeaf } from '../trees';
import { getCSCATree, getCscaTreeInclusionProof, getDSCTree, getDscTreeInclusionProof } from '../trees';
import { getCscaTreeInclusionProof, getDscTreeInclusionProof } from '../trees';
import { SMT } from '@openpassport/zk-kit-smt';
import {
extractSignatureFromDSC,

View File

@@ -259,6 +259,7 @@ export function genMockPassportData(
eContent: eContent,
signedAttr: signedAttr,
encryptedDigest: signatureBytes,
documentType: "mock_passport"
});
}

View File

@@ -8,17 +8,19 @@ import {
import { packBytesAndPoseidon } from './hash';
import { DscCertificateMetaData, parseDscCertificateData } from './passports/passport_parsing/parseDscCertificateData';
import { parseCertificateSimple } from './certificate_parsing/parseCertificateSimple';
import { CSCA_TREE_DEPTH, DSC_TREE_DEPTH, IDENTITY_TREE_URL, max_csca_bytes, OFAC_TREE_LEVELS } from '../constants/constants';
import { CSCA_TREE_DEPTH, CSCA_TREE_URL_STAGING, DSC_TREE_DEPTH, DSC_TREE_URL_STAGING, IDENTITY_TREE_URL, max_csca_bytes, OFAC_TREE_LEVELS } from '../constants/constants';
import { CSCA_TREE_URL, DSC_TREE_URL } from '../constants/constants';
import { max_dsc_bytes } from '../constants/constants';
import { IMT } from '@openpassport/zk-kit-imt';
import { pad } from './passports/passport';
import countries from "i18n-iso-countries";
import en from "i18n-iso-countries/langs/en.json";
import { EndpointType } from './appType';
countries.registerLocale(en);
export async function getCSCATree(): Promise<string[][]> {
const response = await fetch(CSCA_TREE_URL);
export async function getCSCATree(endpointType: EndpointType): Promise<string[][]> {
const cscaTreeUrl = (endpointType === 'celo' || endpointType === 'https') ? CSCA_TREE_URL : CSCA_TREE_URL_STAGING
const response = await fetch(cscaTreeUrl);
const data = await response.json();
const status = data.status ? data.status : data;
if (status === 'error') {
@@ -30,8 +32,9 @@ export async function getCSCATree(): Promise<string[][]> {
return tree;
}
export async function getDSCTree(): Promise<string> {
const response = await fetch(DSC_TREE_URL);
export async function getDSCTree(endpointType: EndpointType): Promise<string> {
const dscTreeUrl = (endpointType === 'celo' || endpointType === 'https') ? DSC_TREE_URL : DSC_TREE_URL_STAGING
const response = await fetch(dscTreeUrl);
const data = await response.json();
const status = data.status ? data.status : data;
if (status === 'error') {

View File

@@ -13,8 +13,11 @@ export type PassportData = {
passportMetadata?: PassportMetadata;
dsc_parsed?: CertificateData;
csca_parsed?: CertificateData;
documentType: DocumentType;
};
export type DocumentType = "passport" | "mock_passport";
// Define the signature algorithm in "algorithm_hashfunction_domainPapameter_keyLength"
export type SignatureAlgorithm =
| 'rsa_sha1_65537_2048'