Updated
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
/**
|
||||
* Name: Ğ1 Wallet
|
||||
* Description: Self-sovereign Ğ1 wallet for SASE-verified participants. Key derivation and signing in the browser. The platform never touches your keys.
|
||||
* Version: 0.1.0
|
||||
* Version: 0.2.0
|
||||
* MinVersion: 11.0
|
||||
* MaxVersion: 12.0
|
||||
*/
|
||||
@@ -36,9 +36,9 @@ function g1wallet_load_pdl(&$b) {
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// HELPERS
|
||||
// ----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
function g1wallet_h($value) {
|
||||
// HTML-escapes a value for safe output.
|
||||
@@ -53,9 +53,9 @@ function g1wallet_load_config() {
|
||||
return (json_last_error() === JSON_ERROR_NONE) ? $cfg : [];
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// ACCESS
|
||||
// ----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
function g1wallet_access_state() {
|
||||
// Returns operator, participant, or public.
|
||||
@@ -80,13 +80,13 @@ function g1wallet_access_state() {
|
||||
$associations = $cfg['associations'] ?? [];
|
||||
if (empty($associations)) return 'public';
|
||||
|
||||
// Direct pgrp_member query — works for guest tokens.
|
||||
// Direct pggrp_member query — works for guest tokens.
|
||||
foreach ($associations as $slug => $assoc) {
|
||||
$groups = $assoc['groups'] ?? [];
|
||||
foreach (['corpus_builder', 'sase_participant', 'civic_professional'] as $group_key) {
|
||||
$gid = intval($groups[$group_key] ?? 0);
|
||||
if ($gid) {
|
||||
$r = q("SELECT xchan FROM pgrp_member WHERE gid = %d AND xchan = '%s' LIMIT 1",
|
||||
$r = q("SELECT xchan FROM pggrp_member WHERE gid = %d AND xchan = '%s' LIMIT 1",
|
||||
intval($gid),
|
||||
dbesc($observer)
|
||||
);
|
||||
@@ -98,17 +98,22 @@ function g1wallet_access_state() {
|
||||
return 'public';
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// CONTENT ROUTER
|
||||
// ----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
function g1wallet_content() {
|
||||
if (function_exists('head_add_css')) {
|
||||
head_add_css('/addon/g1wallet/view/css/g1wallet.css');
|
||||
}
|
||||
if (function_exists('head_add_js')) {
|
||||
// bip39 must load before g1wallet.js (g1wallet.js calls window.bip39).
|
||||
head_add_js('/addon/g1wallet/vendor/bip39-3.1.0.min.js');
|
||||
head_add_js('/addon/g1wallet/view/js/g1wallet.js');
|
||||
// Note: vendor/scrypt-js-3.0.1.min.js is NOT loaded.
|
||||
// scrypt is the obsolete Cesium1 / Duniter v1 derivation algorithm.
|
||||
// Duniter v2 / Ğecko uses entropy-as-seed (no KDF). The file is
|
||||
// retained in vendor/ for reference but is not wired anywhere.
|
||||
}
|
||||
|
||||
$access = g1wallet_access_state();
|
||||
@@ -136,7 +141,7 @@ function g1wallet_content() {
|
||||
return g1wallet_handle_broadcast_post();
|
||||
|
||||
case 'pubkey':
|
||||
// POST: store participant's public key in channel settings after unlock.
|
||||
// POST: store public key in channel settings after unlock.
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
return g1wallet_render_error('POST required.');
|
||||
}
|
||||
@@ -151,9 +156,9 @@ function g1wallet_content() {
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// CSRF
|
||||
// ----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
function g1wallet_csrf_token() {
|
||||
// Generates and stores a CSRF token for the current session.
|
||||
|
||||
Reference in New Issue
Block a user