|
@ -4,7 +4,11 @@ import { sha256 } from "ethereum-cryptography/sha256"; |
|
|
import { LRUCache } from "lru-cache"; |
|
|
import { LRUCache } from "lru-cache"; |
|
|
import * as R from "ramda"; |
|
|
import * as R from "ramda"; |
|
|
|
|
|
|
|
|
import { DEFAULT_IMAGE_API_SERVER, NotificationIface } from "../constants/app"; |
|
|
import { |
|
|
|
|
|
DEFAULT_IMAGE_API_SERVER, |
|
|
|
|
|
NotificationIface, |
|
|
|
|
|
APP_SERVER, |
|
|
|
|
|
} from "../constants/app"; |
|
|
import { Contact } from "../db/tables/contacts"; |
|
|
import { Contact } from "../db/tables/contacts"; |
|
|
import { accessToken, deriveAddress, nextDerivationPath } from "../libs/crypto"; |
|
|
import { accessToken, deriveAddress, nextDerivationPath } from "../libs/crypto"; |
|
|
import { logConsoleAndDb, NonsensitiveDexie } from "../db/index"; |
|
|
import { logConsoleAndDb, NonsensitiveDexie } from "../db/index"; |
|
@ -16,7 +20,6 @@ import { |
|
|
GiverReceiverInputInfo, |
|
|
GiverReceiverInputInfo, |
|
|
} from "../libs/util"; |
|
|
} from "../libs/util"; |
|
|
import { createEndorserJwtForKey, KeyMeta } from "../libs/crypto/vc"; |
|
|
import { createEndorserJwtForKey, KeyMeta } from "../libs/crypto/vc"; |
|
|
import { Account } from "../db/tables/accounts"; |
|
|
|
|
|
|
|
|
|
|
|
export const SCHEMA_ORG_CONTEXT = "https://schema.org"; |
|
|
export const SCHEMA_ORG_CONTEXT = "https://schema.org"; |
|
|
// the object in RegisterAction claims
|
|
|
// the object in RegisterAction claims
|
|
@ -1110,12 +1113,11 @@ export async function createAndSubmitClaim( |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export async function generateEndorserJwtUrlForAccount( |
|
|
export async function generateEndorserJwtUrlForAccount( |
|
|
account: Account, |
|
|
account: KeyMeta, |
|
|
isRegistered?: boolean, |
|
|
isRegistered: boolean, |
|
|
name?: string, |
|
|
givenName: string, |
|
|
profileImageUrl?: string, |
|
|
profileImageUrl: string, |
|
|
// note that including the next key pushes QR codes to the next resolution smaller
|
|
|
isContact: boolean, |
|
|
includeNextKeyIfDerived?: boolean, |
|
|
|
|
|
) { |
|
|
) { |
|
|
const publicKeyHex = account.publicKeyHex; |
|
|
const publicKeyHex = account.publicKeyHex; |
|
|
const publicEncKey = Buffer.from(publicKeyHex, "hex").toString("base64"); |
|
|
const publicEncKey = Buffer.from(publicKeyHex, "hex").toString("base64"); |
|
@ -1125,7 +1127,7 @@ export async function generateEndorserJwtUrlForAccount( |
|
|
iss: account.did, |
|
|
iss: account.did, |
|
|
own: { |
|
|
own: { |
|
|
did: account.did, |
|
|
did: account.did, |
|
|
name: name ?? "", |
|
|
name: givenName ?? "", |
|
|
publicEncKey, |
|
|
publicEncKey, |
|
|
registered: !!isRegistered, |
|
|
registered: !!isRegistered, |
|
|
} as UserInfo, |
|
|
} as UserInfo, |
|
@ -1135,7 +1137,7 @@ export async function generateEndorserJwtUrlForAccount( |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Add the next key -- not recommended for the QR code for such a high resolution
|
|
|
// Add the next key -- not recommended for the QR code for such a high resolution
|
|
|
if (includeNextKeyIfDerived && account?.mnemonic && account?.derivationPath) { |
|
|
if (isContact && account?.mnemonic && account?.derivationPath) { |
|
|
const newDerivPath = nextDerivationPath(account.derivationPath as string); |
|
|
const newDerivPath = nextDerivationPath(account.derivationPath as string); |
|
|
const nextPublicHex = deriveAddress( |
|
|
const nextPublicHex = deriveAddress( |
|
|
account.mnemonic as string, |
|
|
account.mnemonic as string, |
|
|