[wip] jr model
This commit is contained in:
Vendored
-4
@@ -20,7 +20,6 @@ async function main() {
|
||||
*/
|
||||
async function detuctable() {
|
||||
let ati = await active_tab_id();
|
||||
// @ts-ignore browser api unknown
|
||||
browser.tabs.sendMessage(ati, // active tab
|
||||
'mk-detectable'); // message
|
||||
// @ts-ignore disabled exists on this
|
||||
@@ -31,7 +30,6 @@ async function detuctable() {
|
||||
* gets the id of the current tab
|
||||
*/
|
||||
async function active_tab_id() {
|
||||
// @ts-ignore browser api unkown
|
||||
let active_tabs = await browser.tabs.query({ active: true, currentWindow: true });
|
||||
return active_tabs[0].id;
|
||||
}
|
||||
@@ -44,7 +42,6 @@ async function relist_keypairs() {
|
||||
// delete all list items
|
||||
pfizer(document.getElementById('keypairs'));
|
||||
// look for keypairs then relist
|
||||
// @ts-ignore browser api
|
||||
let obj = await browser.storage.local.get('keypairs');
|
||||
await handle_keypairs(obj);
|
||||
}
|
||||
@@ -117,7 +114,6 @@ function no_keypairs() {
|
||||
*/
|
||||
async function generate_keypair() {
|
||||
logln('generating a keypair');
|
||||
// @ts-ignore namespace nacl
|
||||
let keypair = nacl.sign.keyPair();
|
||||
// @ts-ignore changing type
|
||||
keypair.name = "Untitled Keypair 1";
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Impure storage API
|
||||
*
|
||||
* This code is responsible for
|
||||
*
|
||||
* - fetching the program state from storage
|
||||
* - putting the program state into storage
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Impure storage API
|
||||
*
|
||||
* This code is responsible for
|
||||
*
|
||||
* - fetching the program state from storage
|
||||
* - putting the program state into storage
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
//export {
|
||||
// fetch_,
|
||||
// fetch_migrate
|
||||
//};
|
||||
//# sourceMappingURL=impure.js.map
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"impure.js","sourceRoot":"","sources":["../../src/storage/impure.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;AAEH,UAAU;AACV,aAAa;AACb,mBAAmB;AACnB,IAAI"}
|
||||
Vendored
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
/* idea: versioned state
|
||||
*
|
||||
* there is a version 0 state
|
||||
*
|
||||
* each state migration contains a migration from the previous version to the
|
||||
* new version
|
||||
*
|
||||
* laws:
|
||||
*
|
||||
* - all version N states must map to valid version N+1 states
|
||||
*
|
||||
*/
|
||||
//export {
|
||||
// jr_version,
|
||||
// jr_state
|
||||
//};
|
||||
//
|
||||
//let jr_version = 0;
|
||||
//
|
||||
///**
|
||||
// * current state type for current version
|
||||
// */
|
||||
//type jr_state = jr_0_state;
|
||||
//
|
||||
///**
|
||||
// * All jr state types, historically
|
||||
// */
|
||||
//type jr_n_state
|
||||
// = jr_0_state;
|
||||
//
|
||||
///**
|
||||
// * This is the version 0 state
|
||||
// */
|
||||
//type jr_0_state
|
||||
// = {version : 0,
|
||||
// keypair : keypair};
|
||||
//
|
||||
//type keypair
|
||||
// = {secretKey: Uint8Array
|
||||
//# sourceMappingURL=model.js.map
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/storage/model.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;AAEH,UAAU;AACV,iBAAiB;AACjB,cAAc;AACd,IAAI;AACJ,EAAE;AACF,qBAAqB;AACrB,EAAE;AACF,KAAK;AACL,2CAA2C;AAC3C,KAAK;AACL,6BAA6B;AAC7B,EAAE;AACF,KAAK;AACL,qCAAqC;AACrC,KAAK;AACL,iBAAiB;AACjB,mBAAmB;AACnB,EAAE;AACF,KAAK;AACL,gCAAgC;AAChC,KAAK;AACL,iBAAiB;AACjB,qBAAqB;AACrB,4BAA4B;AAC5B,EAAE;AACF,cAAc;AACd,8BAA8B"}
|
||||
@@ -10,3 +10,22 @@ content.js
|
||||
- this is basically a process that
|
||||
|
||||
background script
|
||||
|
||||
|
||||
------------------------------------------------
|
||||
|
||||
-> background
|
||||
-> controller
|
||||
-> "impure component"
|
||||
-> fetching data
|
||||
-> writing to disk
|
||||
-> "pure component"
|
||||
-> business logic
|
||||
-> migrating data from version N to version N+1
|
||||
-> all allowable mutations to the data within a specific version
|
||||
-> content script
|
||||
- talking to page scripts
|
||||
- intermediary between the background script and a page script
|
||||
- raseev requests
|
||||
- send responses back to page
|
||||
-
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* JR Controller
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
|
||||
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
let detect_msg =
|
||||
{id : "urmom",
|
||||
let detect_msg
|
||||
= {id : "urmom",
|
||||
name : "JR",
|
||||
networkId : "ae_uat",
|
||||
origin : "ur dads balls",
|
||||
type : "extension"};
|
||||
|
||||
let detect_awcp_msg =
|
||||
{type: "to_aepp",
|
||||
let detect_awcp_msg
|
||||
= {type : "to_aepp",
|
||||
data : {jsonrpc : "2.0",
|
||||
method : "connection.announcePresence",
|
||||
params : detect_msg}};
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/* idea: versioned state
|
||||
*
|
||||
* there is a version 0 state
|
||||
*
|
||||
* each state migration contains a migration from the previous version to the
|
||||
* new version
|
||||
*
|
||||
* laws:
|
||||
*
|
||||
* - all version N states must map to valid version N+1 states
|
||||
*
|
||||
*/
|
||||
|
||||
export {
|
||||
jr_version,
|
||||
jr_state
|
||||
};
|
||||
|
||||
let jr_version = 0;
|
||||
|
||||
/**
|
||||
* current state type for current version
|
||||
*/
|
||||
type jr_state = jr_0_state;
|
||||
|
||||
/**
|
||||
* All jr state types, historically
|
||||
*/
|
||||
type jr_n_state
|
||||
= jr_0_state;
|
||||
|
||||
/**
|
||||
* This is the version 0 state
|
||||
*/
|
||||
type jr_0_state
|
||||
= {version : 0,
|
||||
keypair : keypair};
|
||||
|
||||
type keypair
|
||||
= {secretKey: Uint8Array
|
||||
@@ -34,7 +34,6 @@ detuctable
|
||||
: Promise<void>
|
||||
{
|
||||
let ati = await active_tab_id();
|
||||
// @ts-ignore browser api unknown
|
||||
browser.tabs.sendMessage(ati, // active tab
|
||||
'mk-detectable'); // message
|
||||
// @ts-ignore disabled exists on this
|
||||
@@ -51,7 +50,6 @@ active_tab_id
|
||||
()
|
||||
: Promise<number>
|
||||
{
|
||||
// @ts-ignore browser api unkown
|
||||
let active_tabs = await browser.tabs.query({active: true, currentWindow: true});
|
||||
return active_tabs[0].id;
|
||||
}
|
||||
@@ -70,7 +68,6 @@ relist_keypairs
|
||||
// delete all list items
|
||||
pfizer(document.getElementById('keypairs')!);
|
||||
// look for keypairs then relist
|
||||
// @ts-ignore browser api
|
||||
let obj = await browser.storage.local.get('keypairs');
|
||||
await handle_keypairs(obj);
|
||||
}
|
||||
@@ -174,7 +171,6 @@ generate_keypair
|
||||
: Promise<void>
|
||||
{
|
||||
logln('generating a keypair');
|
||||
// @ts-ignore namespace nacl
|
||||
let keypair : keypair = nacl.sign.keyPair();
|
||||
// @ts-ignore changing type
|
||||
keypair.name = "Untitled Keypair 1";
|
||||
|
||||
+9264
File diff suppressed because it is too large
Load Diff
Vendored
+98
@@ -0,0 +1,98 @@
|
||||
// Type definitions for TweetNaCl.js
|
||||
|
||||
export as namespace nacl;
|
||||
|
||||
declare var nacl: nacl;
|
||||
export = nacl;
|
||||
|
||||
declare namespace nacl {
|
||||
export interface BoxKeyPair {
|
||||
publicKey: Uint8Array;
|
||||
secretKey: Uint8Array;
|
||||
}
|
||||
|
||||
export interface SignKeyPair {
|
||||
publicKey: Uint8Array;
|
||||
secretKey: Uint8Array;
|
||||
}
|
||||
|
||||
export interface secretbox {
|
||||
(msg: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array;
|
||||
open(box: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array | null;
|
||||
readonly keyLength: number;
|
||||
readonly nonceLength: number;
|
||||
readonly overheadLength: number;
|
||||
}
|
||||
|
||||
export interface scalarMult {
|
||||
(n: Uint8Array, p: Uint8Array): Uint8Array;
|
||||
base(n: Uint8Array): Uint8Array;
|
||||
readonly scalarLength: number;
|
||||
readonly groupElementLength: number;
|
||||
}
|
||||
|
||||
namespace boxProps {
|
||||
export interface open {
|
||||
(msg: Uint8Array, nonce: Uint8Array, publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array | null;
|
||||
after(box: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array | null;
|
||||
}
|
||||
|
||||
export interface keyPair {
|
||||
(): BoxKeyPair;
|
||||
fromSecretKey(secretKey: Uint8Array): BoxKeyPair;
|
||||
}
|
||||
}
|
||||
|
||||
export interface box {
|
||||
(msg: Uint8Array, nonce: Uint8Array, publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array;
|
||||
before(publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array;
|
||||
after(msg: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array;
|
||||
open: boxProps.open;
|
||||
keyPair: boxProps.keyPair;
|
||||
readonly publicKeyLength: number;
|
||||
readonly secretKeyLength: number;
|
||||
readonly sharedKeyLength: number;
|
||||
readonly nonceLength: number;
|
||||
readonly overheadLength: number;
|
||||
}
|
||||
|
||||
namespace signProps {
|
||||
export interface detached {
|
||||
(msg: Uint8Array, secretKey: Uint8Array): Uint8Array;
|
||||
verify(msg: Uint8Array, sig: Uint8Array, publicKey: Uint8Array): boolean;
|
||||
}
|
||||
|
||||
export interface keyPair {
|
||||
(): SignKeyPair;
|
||||
fromSecretKey(secretKey: Uint8Array): SignKeyPair;
|
||||
fromSeed(secretKey: Uint8Array): SignKeyPair;
|
||||
}
|
||||
}
|
||||
|
||||
export interface sign {
|
||||
(msg: Uint8Array, secretKey: Uint8Array): Uint8Array;
|
||||
open(signedMsg: Uint8Array, publicKey: Uint8Array): Uint8Array | null;
|
||||
detached: signProps.detached;
|
||||
keyPair: signProps.keyPair;
|
||||
readonly publicKeyLength: number;
|
||||
readonly secretKeyLength: number;
|
||||
readonly seedLength: number;
|
||||
readonly signatureLength: number;
|
||||
}
|
||||
|
||||
export interface hash {
|
||||
(msg: Uint8Array): Uint8Array;
|
||||
readonly hashLength: number;
|
||||
}
|
||||
}
|
||||
|
||||
declare interface nacl {
|
||||
randomBytes(n: number): Uint8Array;
|
||||
secretbox: nacl.secretbox;
|
||||
scalarMult: nacl.scalarMult;
|
||||
box: nacl.box;
|
||||
sign: nacl.sign;
|
||||
hash: nacl.hash;
|
||||
verify(x: Uint8Array, y: Uint8Array): boolean;
|
||||
setPRNG(fn: (x: Uint8Array, n: number) => void): void;
|
||||
}
|
||||
Reference in New Issue
Block a user