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 {Injectable} from '@angular/core';
|
||||||
import {CryptoService} from './crypto.service';
|
import {CryptoService} from './crypto.service';
|
||||||
import {GlobalVarsService} from './global-vars.service';
|
import {GlobalVarsService} from './global-vars.service';
|
||||||
import {AccessLevel, PrivateAccountInfo, PublicAccountInfo} from '../types/identity';
|
import {AccessLevel, PrivateAccountInfo, PublicChannelInfo} from '../types/identity';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
@ -16,45 +16,46 @@ export class AccountService {
|
||||||
|
|
||||||
// Public Getters
|
// 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
|
// TODO - As of this writing, we want to share channel claim ids with the
|
||||||
// account on login, and spending addresses on request (probably with
|
// account on login, and spending addresses on request (probably with
|
||||||
// explicit permission)
|
// explicit permission)
|
||||||
//
|
getChannels(): {[key: string]: PublicChannelInfo} {
|
||||||
// This is in a state in between what DeSo had and what
|
// TODO - will want for accessLevel stuff
|
||||||
// we want ultimately for LBRY.
|
// const hostname = this.globalVars.hostname;
|
||||||
getPublicAccounts(): {[key: string]: PublicAccountInfo} {
|
|
||||||
const hostname = this.globalVars.hostname;
|
|
||||||
const privateAccounts = this.getWalletAccounts();
|
const privateAccounts = this.getWalletAccounts();
|
||||||
const publicAccounts: {[key: string]: PublicAccountInfo} = {};
|
const channels: {[key: string]: PublicChannelInfo} = {};
|
||||||
|
|
||||||
for (const name of Object.keys(privateAccounts)) {
|
for (const name of Object.keys(privateAccounts)) {
|
||||||
const privateAccount = privateAccounts[name];
|
const privateAccount = privateAccounts[name];
|
||||||
const accessLevel = this.getAccessLevel(name, hostname);
|
for (const channelPubKeyAddress of Object.keys(privateAccount.certificates)) {
|
||||||
if (accessLevel === AccessLevel.None) {
|
// TODO - For LBRY's purposes, not only will we want per-channel access
|
||||||
continue;
|
// 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
|
// TODO - Need to confirm that this works I think
|
||||||
|
|
|
@ -86,7 +86,7 @@ export class ApproveComponent implements OnInit {
|
||||||
|
|
||||||
finishFlow(signedTransactionHex?: string): void {
|
finishFlow(signedTransactionHex?: string): void {
|
||||||
this.identityService.login({
|
this.identityService.login({
|
||||||
accounts: this.accountService.getPublicAccounts(),
|
channels: this.accountService.getChannels(),
|
||||||
signedTransactionHex,
|
signedTransactionHex,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {Observable, Subject} from 'rxjs';
|
import {Observable, Subject} from 'rxjs';
|
||||||
import {v4 as uuid} from 'uuid';
|
import {v4 as uuid} from 'uuid';
|
||||||
import {AccessLevel, PublicAccountInfo} from '../types/identity';
|
import {AccessLevel, PublicChannelInfo} from '../types/identity';
|
||||||
import {CryptoService} from './crypto.service';
|
import {CryptoService} from './crypto.service';
|
||||||
import {GlobalVarsService} from './global-vars.service';
|
import {GlobalVarsService} from './global-vars.service';
|
||||||
import {CookieService} from 'ngx-cookie';
|
import {CookieService} from 'ngx-cookie';
|
||||||
|
@ -41,7 +41,7 @@ export class IdentityService {
|
||||||
}
|
}
|
||||||
|
|
||||||
login(payload: {
|
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.
|
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
|
signedUp?: boolean
|
||||||
signedTransactionHex?: string,
|
signedTransactionHex?: string,
|
||||||
|
|
|
@ -18,14 +18,14 @@ export class LogInAppComponent implements OnInit {
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
// TODO - Will be channel claim IDs
|
// TODO - Will hopefully be channel claim IDs but I don't know what will be available in reality
|
||||||
this.allAccountNames = this.accountService.getAccountNames();
|
// this.allAccountNames = ...
|
||||||
}
|
}
|
||||||
|
|
||||||
selectAccount(accountName: string): void {
|
selectAccount(accountName: string): void {
|
||||||
this.accountService.setAccessLevel(accountName, this.globalVars.hostname, this.globalVars.accessLevelRequest);
|
this.accountService.setAccessLevel(accountName, this.globalVars.hostname, this.globalVars.accessLevelRequest);
|
||||||
this.identityService.login({
|
this.identityService.login({
|
||||||
accounts: this.accountService.getPublicAccounts(),
|
channels: this.accountService.getChannels(),
|
||||||
accountNameAdded: accountName,
|
accountNameAdded: accountName,
|
||||||
signedUp: false
|
signedUp: false
|
||||||
});
|
});
|
||||||
|
|
|
@ -43,7 +43,7 @@ export class LogoutComponent implements OnInit {
|
||||||
|
|
||||||
finishFlow(): void {
|
finishFlow(): void {
|
||||||
this.identityService.login({
|
this.identityService.login({
|
||||||
accounts: this.accountService.getPublicAccounts(),
|
channels: this.accountService.getChannels(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ export class SignUpComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
login(): void {
|
login(): void {
|
||||||
this.identityService.login({
|
this.identityService.login({
|
||||||
accounts: this.accountService.getPublicAccounts(),
|
channels: this.accountService.getChannels(),
|
||||||
accountNameAdded: this.accountNameAdded,
|
accountNameAdded: this.accountNameAdded,
|
||||||
signedUp: true,
|
signedUp: true,
|
||||||
});
|
});
|
||||||
|
|
|
@ -41,7 +41,7 @@ export class TestSignTransactionComponent implements OnInit {
|
||||||
|
|
||||||
finishFlow(signedTransactionHex?: string): void {
|
finishFlow(signedTransactionHex?: string): void {
|
||||||
this.identityService.login({
|
this.identityService.login({
|
||||||
accounts: this.accountService.getPublicAccounts(),
|
channels: this.accountService.getChannels(),
|
||||||
signedTransactionHex,
|
signedTransactionHex,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ export class TestSignComponent implements OnInit {
|
||||||
|
|
||||||
finishFlow(signatureHex?: string): void {
|
finishFlow(signatureHex?: string): void {
|
||||||
this.identityService.login({
|
this.identityService.login({
|
||||||
accounts: this.accountService.getPublicAccounts(),
|
channels: this.accountService.getChannels(),
|
||||||
signatureHex,
|
signatureHex,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,9 @@ export interface PrivateAccountInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
// can be sent to the app
|
// can be sent to the app
|
||||||
export interface PublicAccountInfo {
|
export interface PublicChannelInfo {
|
||||||
// TODO - add more useful stuff
|
// TODO - add more useful stuff
|
||||||
name: string;
|
pubKeyAddress: string;
|
||||||
network: Network;
|
network: Network;
|
||||||
accessLevel: AccessLevel;
|
accessLevel: AccessLevel;
|
||||||
accessLevelHmac: string;
|
accessLevelHmac: string;
|
||||||
|
|
Loading…
Reference in a new issue