getPublicAccounts -> getChannels
Login won't give LBRY accounts, it'll give channels
This commit is contained in:
parent
439ce26e0f
commit
d0583e540a
9 changed files with 43 additions and 42 deletions
|
@ -1,7 +1,7 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {CryptoService} from './crypto.service';
|
||||
import {GlobalVarsService} from './global-vars.service';
|
||||
import {AccessLevel, PrivateAccountInfo, PublicAccountInfo} from '../types/identity';
|
||||
import {AccessLevel, PrivateAccountInfo, PublicChannelInfo} from '../types/identity';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
@ -16,45 +16,46 @@ export class AccountService {
|
|||
|
||||
// Public Getters
|
||||
|
||||
getAccountNames(): any {
|
||||
// TODO - maybe write this in a safer, more future-perfect way since it's converting
|
||||
// private to public
|
||||
return Object.keys(this.getWalletAccounts());
|
||||
}
|
||||
|
||||
// TODO - As of this writing, we want to share channel claim ids with the
|
||||
// account on login, and spending addresses on request (probably with
|
||||
// explicit permission)
|
||||
//
|
||||
// This is in a state in between what DeSo had and what
|
||||
// we want ultimately for LBRY.
|
||||
getPublicAccounts(): {[key: string]: PublicAccountInfo} {
|
||||
const hostname = this.globalVars.hostname;
|
||||
getChannels(): {[key: string]: PublicChannelInfo} {
|
||||
// TODO - will want for accessLevel stuff
|
||||
// const hostname = this.globalVars.hostname;
|
||||
|
||||
const privateAccounts = this.getWalletAccounts();
|
||||
const publicAccounts: {[key: string]: PublicAccountInfo} = {};
|
||||
const channels: {[key: string]: PublicChannelInfo} = {};
|
||||
|
||||
for (const name of Object.keys(privateAccounts)) {
|
||||
const privateAccount = privateAccounts[name];
|
||||
const accessLevel = this.getAccessLevel(name, hostname);
|
||||
if (accessLevel === AccessLevel.None) {
|
||||
continue;
|
||||
for (const channelPubKeyAddress of Object.keys(privateAccount.certificates)) {
|
||||
// TODO - For LBRY's purposes, not only will we want per-channel access
|
||||
// levels, we'll want per channel per hostname per action access levels.
|
||||
|
||||
// TODO - finish when we have accessLevel stuff
|
||||
/*
|
||||
const accessLevel = this.getAccessLevel(name, hostname);
|
||||
if (accessLevel === AccessLevel.None) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO - Implement the hmac properly
|
||||
// TODO - why do we even have hmac if everything's in local storage anyway?
|
||||
const accessLevelHmac = this.cryptoService.accessLevelHmac(accessLevel, privateAccount.seed);
|
||||
*/
|
||||
|
||||
channels[channelPubKeyAddress] = {
|
||||
pubKeyAddress: channelPubKeyAddress,
|
||||
network: privateAccount.ledger,
|
||||
|
||||
// TODO - fill in when we have accessLevel stuff
|
||||
accessLevel: 0,
|
||||
accessLevelHmac: "",
|
||||
};
|
||||
}
|
||||
|
||||
// TODO
|
||||
throw 'Implement the hmac properly'
|
||||
|
||||
// TODO - why do we even have hmac if everything's in local storage anyway?
|
||||
const accessLevelHmac = this.cryptoService.accessLevelHmac(accessLevel, privateAccount.seed);
|
||||
|
||||
publicAccounts[name] = {
|
||||
name,
|
||||
network: privateAccount.ledger,
|
||||
accessLevel,
|
||||
accessLevelHmac,
|
||||
};
|
||||
}
|
||||
|
||||
return publicAccounts;
|
||||
return channels;
|
||||
}
|
||||
|
||||
// TODO - Need to confirm that this works I think
|
||||
|
|
|
@ -86,7 +86,7 @@ export class ApproveComponent implements OnInit {
|
|||
|
||||
finishFlow(signedTransactionHex?: string): void {
|
||||
this.identityService.login({
|
||||
accounts: this.accountService.getPublicAccounts(),
|
||||
channels: this.accountService.getChannels(),
|
||||
signedTransactionHex,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Observable, Subject} from 'rxjs';
|
||||
import {v4 as uuid} from 'uuid';
|
||||
import {AccessLevel, PublicAccountInfo} from '../types/identity';
|
||||
import {AccessLevel, PublicChannelInfo} from '../types/identity';
|
||||
import {CryptoService} from './crypto.service';
|
||||
import {GlobalVarsService} from './global-vars.service';
|
||||
import {CookieService} from 'ngx-cookie';
|
||||
|
@ -41,7 +41,7 @@ export class IdentityService {
|
|||
}
|
||||
|
||||
login(payload: {
|
||||
accounts: {[key: string]: PublicAccountInfo}, // Channel ids
|
||||
channels: {[key: string]: PublicChannelInfo},
|
||||
accountNameAdded?: string, // Which channel id was just authorized. the app may allow the user to switch between them, but this determines which is on now.
|
||||
signedUp?: boolean
|
||||
signedTransactionHex?: string,
|
||||
|
|
|
@ -18,14 +18,14 @@ export class LogInAppComponent implements OnInit {
|
|||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
// TODO - Will be channel claim IDs
|
||||
this.allAccountNames = this.accountService.getAccountNames();
|
||||
// TODO - Will hopefully be channel claim IDs but I don't know what will be available in reality
|
||||
// this.allAccountNames = ...
|
||||
}
|
||||
|
||||
selectAccount(accountName: string): void {
|
||||
this.accountService.setAccessLevel(accountName, this.globalVars.hostname, this.globalVars.accessLevelRequest);
|
||||
this.identityService.login({
|
||||
accounts: this.accountService.getPublicAccounts(),
|
||||
channels: this.accountService.getChannels(),
|
||||
accountNameAdded: accountName,
|
||||
signedUp: false
|
||||
});
|
||||
|
|
|
@ -43,7 +43,7 @@ export class LogoutComponent implements OnInit {
|
|||
|
||||
finishFlow(): void {
|
||||
this.identityService.login({
|
||||
accounts: this.accountService.getPublicAccounts(),
|
||||
channels: this.accountService.getChannels(),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ export class SignUpComponent implements OnInit, OnDestroy {
|
|||
|
||||
login(): void {
|
||||
this.identityService.login({
|
||||
accounts: this.accountService.getPublicAccounts(),
|
||||
channels: this.accountService.getChannels(),
|
||||
accountNameAdded: this.accountNameAdded,
|
||||
signedUp: true,
|
||||
});
|
||||
|
|
|
@ -41,7 +41,7 @@ export class TestSignTransactionComponent implements OnInit {
|
|||
|
||||
finishFlow(signedTransactionHex?: string): void {
|
||||
this.identityService.login({
|
||||
accounts: this.accountService.getPublicAccounts(),
|
||||
channels: this.accountService.getChannels(),
|
||||
signedTransactionHex,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ export class TestSignComponent implements OnInit {
|
|||
|
||||
finishFlow(signatureHex?: string): void {
|
||||
this.identityService.login({
|
||||
accounts: this.accountService.getPublicAccounts(),
|
||||
channels: this.accountService.getChannels(),
|
||||
signatureHex,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -36,9 +36,9 @@ export interface PrivateAccountInfo {
|
|||
}
|
||||
|
||||
// can be sent to the app
|
||||
export interface PublicAccountInfo {
|
||||
export interface PublicChannelInfo {
|
||||
// TODO - add more useful stuff
|
||||
name: string;
|
||||
pubKeyAddress: string;
|
||||
network: Network;
|
||||
accessLevel: AccessLevel;
|
||||
accessLevelHmac: string;
|
||||
|
|
Loading…
Reference in a new issue