mirror of
https://github.com/selfxyz/self.git
synced 2026-01-13 16:47:57 -05:00
* chore: centralize license header scripts * chore: run license header checks from root * add header to other files * add header to bundle * add migration script and update check license headers * convert license to mobile sdk * migrate license headers * remove headers from common; convert remaining * fix headers * add license header checks
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
// SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.
|
|
|
|
// Level 2 Granular Import Example - Optimal Tree Shaking
|
|
// This demonstrates the new file-based imports for maximum optimization
|
|
|
|
// Import only core constants (no country data, vkey, etc.)
|
|
import {
|
|
API_URL,
|
|
PASSPORT_ATTESTATION_ID,
|
|
} from '@selfxyz/common/constants/core';
|
|
// Import only passport types (no app types, certificate types, etc.)
|
|
import type { PassportData } from '@selfxyz/common/types/passport';
|
|
// Import only hash utilities (no bytes, trees, circuits, etc.)
|
|
import { hash } from '@selfxyz/common/utils/hash';
|
|
|
|
export function optimalLevel2Example(data: PassportData) {
|
|
// This will result in the smallest possible bundle
|
|
// Only the specific functions and constants we use are included
|
|
console.log('Using API:', API_URL);
|
|
|
|
console.log('Attestation ID:', PASSPORT_ATTESTATION_ID);
|
|
|
|
const hashedData = hash(JSON.stringify(data));
|
|
|
|
console.log('Hashed passport data:', hashedData);
|
|
|
|
return {
|
|
api: API_URL,
|
|
attestationId: PASSPORT_ATTESTATION_ID,
|
|
hash: hashedData,
|
|
};
|
|
}
|