Compare commits
No commits in common. "8a9f53102be5dedd3f2bacb9e8f04fe1353d668b" and "c8b8a8fc03996a3b08a9cf6bb2ffdff7006c8b06" have entirely different histories.
8a9f53102b
...
c8b8a8fc03
@ -144,8 +144,6 @@ function socket(request, response, client) {
|
||||
JSON.stringify({
|
||||
action: 'session',
|
||||
credentials: credentials,
|
||||
identities: await ssb.getIdentities(credentials?.session?.name),
|
||||
identity: await core.getActiveIdentity(credentials?.session?.name, packageOwner, packageName),
|
||||
parentApp: parentApp,
|
||||
id: blobId,
|
||||
}),
|
||||
@ -212,10 +210,6 @@ function socket(request, response, client) {
|
||||
if (process) {
|
||||
process.resetPermission(message.permission);
|
||||
}
|
||||
} else if (message.action == 'setActiveIdentity') {
|
||||
process.setActiveIdentity(message.identity);
|
||||
} else if (message.action == 'createIdentity') {
|
||||
process.createIdentity();
|
||||
} else if (message.message == 'tfrpc') {
|
||||
if (message.id && g_calls[message.id]) {
|
||||
if (message.error !== undefined) {
|
||||
|
@ -56,8 +56,6 @@ class TfNavigationElement extends LitElement {
|
||||
spark_lines: {type: Object},
|
||||
version: {type: Object},
|
||||
show_version: {type: Boolean},
|
||||
identity: {type: String},
|
||||
identities: {type: Array},
|
||||
};
|
||||
}
|
||||
|
||||
@ -67,7 +65,6 @@ class TfNavigationElement extends LitElement {
|
||||
this.show_permissions = false;
|
||||
this.status = {};
|
||||
this.spark_lines = {};
|
||||
this.identities = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,37 +128,6 @@ class TfNavigationElement extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
set_active_identity(event) {
|
||||
send({action: 'setActiveIdentity', identity: event.srcElement.value});
|
||||
}
|
||||
|
||||
create_identity(event) {
|
||||
send({action: 'createIdentity'});
|
||||
}
|
||||
|
||||
render_identity() {
|
||||
if (this.identities?.length) {
|
||||
return html`
|
||||
<link type="text/css" rel="stylesheet" href="/static/w3.css" />
|
||||
<select
|
||||
@change=${this.set_active_identity}
|
||||
class="w3-input w3-cyan"
|
||||
style="flex: 0 1 auto; width: auto; display: inline-blocktext-overflow: ellipsis; overflow: hidden; white-space: nowrap">
|
||||
${this.identities.map(x => html`<option ?selected=${x === this.identity}>${x}</option>`)}
|
||||
</select>
|
||||
`;
|
||||
} else {
|
||||
return html`
|
||||
<link type="text/css" rel="stylesheet" href="/static/w3.css" />
|
||||
<button
|
||||
@click=${this.create_identity}
|
||||
class="w3-button w3-blue">
|
||||
Create an Identity
|
||||
</button>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @returns
|
||||
@ -291,7 +257,6 @@ class TfNavigationElement extends LitElement {
|
||||
x,
|
||||
])}</span
|
||||
>
|
||||
${this.render_identity()}
|
||||
<span style="flex: 0 0; white-space: nowrap"
|
||||
>${this.render_login()}</span
|
||||
>
|
||||
@ -1160,17 +1125,11 @@ function api_setHash(hash) {
|
||||
function _receive_websocket_message(message) {
|
||||
if (message && message.action == 'session') {
|
||||
setStatusMessage('🟢 Executing...', kStatusColor);
|
||||
let navigation = document.getElementsByTagName('tf-navigation')[0];
|
||||
navigation.credentials = message.credentials;
|
||||
navigation.identities = message.identities;
|
||||
navigation.identity = message.identity;
|
||||
document.getElementsByTagName('tf-navigation')[0].credentials =
|
||||
message.credentials;
|
||||
} else if (message && message.action == 'permissions') {
|
||||
let navigation = document.getElementsByTagName('tf-navigation')[0];
|
||||
navigation.permissions = message.permissions ?? {};
|
||||
} else if (message && message.action == 'identities') {
|
||||
let navigation = document.getElementsByTagName('tf-navigation')[0];
|
||||
navigation.identities = message.identities;
|
||||
navigation.identity = message.identity;
|
||||
document.getElementsByTagName('tf-navigation')[0].permissions =
|
||||
message.permissions ?? {};
|
||||
} else if (message && message.action == 'ready') {
|
||||
setStatusMessage(null);
|
||||
if (window.location.hash) {
|
||||
|
51
core/core.js
51
core/core.js
@ -508,30 +508,6 @@ async function getProcessBlob(blobId, key, options) {
|
||||
url: options?.url,
|
||||
},
|
||||
};
|
||||
process.sendIdentities = async function() {
|
||||
process.app.send({
|
||||
action: 'identities',
|
||||
identities: await ssb.getIdentities(process?.credentials?.session?.name),
|
||||
identity: await getActiveIdentity(process?.credentials?.session?.name, options.packageOwner, options.packageName),
|
||||
});
|
||||
};
|
||||
process.setActiveIdentity = async function(identity) {
|
||||
if (process?.credentials?.session?.name && options.packageOwner && options.packageName) {
|
||||
await new Database(process?.credentials?.session?.name).set(`id:${options.packageOwner}:${options.packageName}`, identity);
|
||||
}
|
||||
process.sendIdentities();
|
||||
};
|
||||
process.createIdentity = async function() {
|
||||
if (
|
||||
process.credentials &&
|
||||
process.credentials.session &&
|
||||
process.credentials.session.name
|
||||
) {
|
||||
let id = ssb.createIdentity(process.credentials.session.name);
|
||||
await process.sendIdentities();
|
||||
return id;
|
||||
}
|
||||
}
|
||||
if (process.credentials?.permissions?.administration) {
|
||||
imports.core.globalSettingsDescriptions = function () {
|
||||
let settings = Object.assign({}, k_global_settings);
|
||||
@ -602,7 +578,15 @@ async function getProcessBlob(blobId, key, options) {
|
||||
Object.keys(ssb).map((key) => [key, ssb[key].bind(ssb)])
|
||||
);
|
||||
imports.ssb.port = tildefriends.ssb_port;
|
||||
imports.ssb.createIdentity = () => process.createIdentity();
|
||||
imports.ssb.createIdentity = function () {
|
||||
if (
|
||||
process.credentials &&
|
||||
process.credentials.session &&
|
||||
process.credentials.session.name
|
||||
) {
|
||||
return ssb.createIdentity(process.credentials.session.name);
|
||||
}
|
||||
};
|
||||
imports.ssb.addIdentity = function (id) {
|
||||
if (
|
||||
process.credentials &&
|
||||
@ -629,8 +613,6 @@ async function getProcessBlob(blobId, key, options) {
|
||||
});
|
||||
}
|
||||
};
|
||||
imports.ssb.setActiveIdentity = id => process.setActiveIdentity(id);
|
||||
imports.ssb.getActiveIdentity = () => getActiveIdentity(process.credentials?.session?.name, options.packageOwner, options.packageName);
|
||||
imports.ssb.getOwnerIdentities = function () {
|
||||
if (options.packageOwner) {
|
||||
return ssb.getIdentities(options.packageOwner);
|
||||
@ -1476,25 +1458,10 @@ function storePermission(user, packageOwner, packageName, permission, allow) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function getActiveIdentity(user, packageOwner, packageName) {
|
||||
if (user && packageOwner && packageName) {
|
||||
let id = await new Database(user).get(`id:${packageOwner}:${packageName}`);
|
||||
if (!id) {
|
||||
let ids = await ssb.getIdentities(user);
|
||||
if (ids) {
|
||||
id = ids[0];
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
gGlobalSettings as globalSettings,
|
||||
setGlobalSettings,
|
||||
enableStats,
|
||||
invoke,
|
||||
getSessionProcessBlob,
|
||||
getActiveIdentity,
|
||||
};
|
||||
|
@ -474,7 +474,7 @@ static JSValue _httpd_auth_query(JSContext* context, JSValueConst this_val, int
|
||||
JSValue settings_value = settings ? JS_ParseJSON(context, settings, strlen(settings), NULL) : JS_UNDEFINED;
|
||||
JSValue permissions = JS_GetPropertyStr(context, settings_value, "permissions");
|
||||
JSValue user_permissions = JS_GetPropertyStr(context, permissions, name_string);
|
||||
int length = !JS_IsUndefined(user_permissions) ? tf_util_get_length(context, user_permissions) : 0 ;
|
||||
int length = tf_util_get_length(context, user_permissions);
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
JSValue permission = JS_GetPropertyUint32(context, user_permissions, i);
|
||||
|
Loading…
Reference in New Issue
Block a user