mirror of
https://github.com/zhigang1992/connect.git
synced 2026-04-29 09:55:41 +08:00
feat: publish public key, #357
This commit is contained in:
committed by
Hank Stoever
parent
42da3f1c0c
commit
7c0a1bb0a6
@@ -67,9 +67,12 @@ export class Identity {
|
||||
profile.apps = {};
|
||||
}
|
||||
const challengeSigner = ECPair.fromPrivateKey(Buffer.from(appPrivateKey, 'hex'));
|
||||
profile.apps[appDomain] = `${hubInfo.read_url_prefix}${await ecPairToAddress(
|
||||
challengeSigner
|
||||
)}`;
|
||||
const storageUrl = `${hubInfo.read_url_prefix}${await ecPairToAddress(challengeSigner)}`;
|
||||
profile.apps[appDomain] = storageUrl;
|
||||
if (!profile.appsMeta) {
|
||||
profile.appsMeta = {};
|
||||
}
|
||||
profile.appsMeta[appDomain] = { storage: storageUrl, publicKey: this.keyPair.keyID };
|
||||
const gaiaHubConfig = await connectToGaiaHubWithConfig({
|
||||
hubInfo,
|
||||
privateKey: this.keyPair.key,
|
||||
|
||||
@@ -24,6 +24,12 @@ export interface Profile {
|
||||
apps?: {
|
||||
[origin: string]: string;
|
||||
};
|
||||
appsMeta?: {
|
||||
[origin: string]: {
|
||||
publicKey: string;
|
||||
storage: string;
|
||||
};
|
||||
};
|
||||
name?: string;
|
||||
image?: ProfileImage[];
|
||||
[key: string]: any;
|
||||
|
||||
@@ -56,7 +56,7 @@ test('adds to apps in profile if publish_data scope', async () => {
|
||||
const { payload } = decoded as Decoded;
|
||||
expect(payload.profile.apps['https://banter.pub']).not.toBeFalsy();
|
||||
const profile = JSON.parse(fetchMock.mock.calls[7][1].body);
|
||||
const { apps } = profile[0].decodedToken.payload.claim;
|
||||
const { apps, appsMeta } = profile[0].decodedToken.payload.claim;
|
||||
expect(apps[appDomain]).not.toBeFalsy();
|
||||
const appPrivateKey = await decryptPrivateKey(transitPrivateKey, payload.private_key);
|
||||
const challengeSigner = ECPair.fromPrivateKey(Buffer.from(appPrivateKey as string, 'hex'));
|
||||
@@ -64,6 +64,9 @@ test('adds to apps in profile if publish_data scope', async () => {
|
||||
challengeSigner
|
||||
)}`;
|
||||
expect(apps[appDomain]).toEqual(expectedDomain);
|
||||
expect(appsMeta[appDomain]).not.toBeFalsy();
|
||||
expect(appsMeta[appDomain].storage).toEqual(expectedDomain);
|
||||
expect(appsMeta[appDomain].publicKey).toEqual(challengeSigner.publicKey.toString('hex'));
|
||||
});
|
||||
|
||||
test('generates an app private key', async () => {
|
||||
|
||||
Reference in New Issue
Block a user