*Update builds
This commit is contained in:
parent
50ed4b92c5
commit
994ee4cd1f
|
@ -1,15 +1,13 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const index_js_1 = require("../dist/index.js");
|
import { loadTester, login } from "../dist/index.js";
|
||||||
const puppeteer_1 = require("puppeteer");
|
import puppeteer from "puppeteer";
|
||||||
let browser;
|
let browser;
|
||||||
(async () => {
|
(async () => {
|
||||||
browser = await puppeteer_1.default.launch({ headless: false, devtools: true });
|
browser = await puppeteer.launch({ headless: false, devtools: true });
|
||||||
const page = (await browser.pages()).pop();
|
const page = (await browser.pages()).pop();
|
||||||
await (0, index_js_1.login)(page);
|
await login(page);
|
||||||
await (0, index_js_1.loadTester)(page);
|
await loadTester(page);
|
||||||
})();
|
})();
|
||||||
process.on("SIGTERM", async () => {
|
process.on("SIGTERM", async () => {
|
||||||
await browser.close();
|
await browser.close();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Page } from "puppeteer";
|
import { Page } from "puppeteer";
|
||||||
import { errTuple } from "libskynet/dist";
|
import { errTuple } from "libskynet";
|
||||||
export declare const KERNEL_TEST_SUITE = "AQCPJ9WRzMpKQHIsPo8no3XJpUydcDCjw7VJy8lG1MCZ3g";
|
export declare const KERNEL_TEST_SUITE = "AQCPJ9WRzMpKQHIsPo8no3XJpUydcDCjw7VJy8lG1MCZ3g";
|
||||||
export declare const KERNEL_HELPER_MODULE = "AQCoaLP6JexdZshDDZRQaIwN3B7DqFjlY7byMikR7u1IEA";
|
export declare const KERNEL_HELPER_MODULE = "AQCoaLP6JexdZshDDZRQaIwN3B7DqFjlY7byMikR7u1IEA";
|
||||||
export declare const TEST_KERNEL_SKLINK = "AQDJDoXMJiiEMBxXodQvUV89qtQHsnXWyV1ViQ9M1pMjUg";
|
export declare const TEST_KERNEL_SKLINK = "AQDJDoXMJiiEMBxXodQvUV89qtQHsnXWyV1ViQ9M1pMjUg";
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
"use strict";
|
import { b64ToBuf, bufToHex, deriveChildSeed, dictionary, seedPhraseToSeed, taggedRegistryEntryKeys, } from "libskynet";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
import { SEED_BYTES, seedToChecksumWords } from "libskynet/dist/seed.js";
|
||||||
exports.tester = exports.loadTester = exports.login = exports.generateSeedPhrase = exports.TEST_KERNEL_SKLINK = exports.KERNEL_HELPER_MODULE = exports.KERNEL_TEST_SUITE = void 0;
|
import { DICTIONARY_UNIQUE_PREFIX } from "libskynet/dist/dictionary.js";
|
||||||
const libskynet_1 = require("libskynet");
|
import * as path from "path";
|
||||||
const seed_1 = require("libskynet/dist/seed");
|
import { overwriteRegistryEntry } from "libskynetnode";
|
||||||
const dictionary_1 = require("libskynet/dist/dictionary");
|
import * as kernel from "libkernel";
|
||||||
const path = require("path");
|
import { webcrypto } from "crypto";
|
||||||
const libskynetnode_1 = require("libskynetnode");
|
|
||||||
const kernel = require("libkernel");
|
|
||||||
const crypto_1 = require("crypto");
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const StaticServer = require("static-server");
|
import StaticServer from "static-server";
|
||||||
exports.KERNEL_TEST_SUITE = "AQCPJ9WRzMpKQHIsPo8no3XJpUydcDCjw7VJy8lG1MCZ3g";
|
import * as url from "url";
|
||||||
exports.KERNEL_HELPER_MODULE = "AQCoaLP6JexdZshDDZRQaIwN3B7DqFjlY7byMikR7u1IEA";
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
||||||
exports.TEST_KERNEL_SKLINK = "AQDJDoXMJiiEMBxXodQvUV89qtQHsnXWyV1ViQ9M1pMjUg";
|
export const KERNEL_TEST_SUITE = "AQCPJ9WRzMpKQHIsPo8no3XJpUydcDCjw7VJy8lG1MCZ3g";
|
||||||
|
export const KERNEL_HELPER_MODULE = "AQCoaLP6JexdZshDDZRQaIwN3B7DqFjlY7byMikR7u1IEA";
|
||||||
|
export const TEST_KERNEL_SKLINK = "AQDJDoXMJiiEMBxXodQvUV89qtQHsnXWyV1ViQ9M1pMjUg";
|
||||||
const SEED_ENTROPY_WORDS = 13;
|
const SEED_ENTROPY_WORDS = 13;
|
||||||
const crypto = crypto_1.webcrypto;
|
const crypto = webcrypto;
|
||||||
function generateSeedPhrase() {
|
export function generateSeedPhrase() {
|
||||||
// Get the random numbers for the seed phrase. Typically, you need to
|
// Get the random numbers for the seed phrase. Typically, you need to
|
||||||
// have code that avoids bias by checking the random results and
|
// have code that avoids bias by checking the random results and
|
||||||
// re-rolling the random numbers if the result is outside of the range
|
// re-rolling the random numbers if the result is outside of the range
|
||||||
|
@ -28,17 +27,16 @@ function generateSeedPhrase() {
|
||||||
// Generate the seed phrase from the randNums.
|
// Generate the seed phrase from the randNums.
|
||||||
let seedWords = [];
|
let seedWords = [];
|
||||||
for (let i = 0; i < SEED_ENTROPY_WORDS; i++) {
|
for (let i = 0; i < SEED_ENTROPY_WORDS; i++) {
|
||||||
let wordIndex = randNums[i] % libskynet_1.dictionary.length;
|
let wordIndex = randNums[i] % dictionary.length;
|
||||||
seedWords.push(libskynet_1.dictionary[wordIndex]);
|
seedWords.push(dictionary[wordIndex]);
|
||||||
}
|
}
|
||||||
// Convert the seedWords to a seed.
|
// Convert the seedWords to a seed.
|
||||||
let [seed] = seedWordsToSeed(seedWords);
|
let [seed] = seedWordsToSeed(seedWords);
|
||||||
// Compute the checksum.
|
// Compute the checksum.
|
||||||
let [checksumOne, checksumTwo, err2] = (0, seed_1.seedToChecksumWords)(seed);
|
let [checksumOne, checksumTwo, err2] = seedToChecksumWords(seed);
|
||||||
// Assemble the final seed phrase and set the text field.
|
// Assemble the final seed phrase and set the text field.
|
||||||
return [...seedWords, checksumOne, checksumTwo].join(" ");
|
return [...seedWords, checksumOne, checksumTwo].join(" ");
|
||||||
}
|
}
|
||||||
exports.generateSeedPhrase = generateSeedPhrase;
|
|
||||||
function seedWordsToSeed(seedWords) {
|
function seedWordsToSeed(seedWords) {
|
||||||
// Input checking.
|
// Input checking.
|
||||||
if (seedWords.length !== SEED_ENTROPY_WORDS) {
|
if (seedWords.length !== SEED_ENTROPY_WORDS) {
|
||||||
|
@ -48,15 +46,15 @@ function seedWordsToSeed(seedWords) {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
// We are getting 16 bytes of entropy.
|
// We are getting 16 bytes of entropy.
|
||||||
let bytes = new Uint8Array(seed_1.SEED_BYTES);
|
let bytes = new Uint8Array(SEED_BYTES);
|
||||||
let curByte = 0;
|
let curByte = 0;
|
||||||
let curBit = 0;
|
let curBit = 0;
|
||||||
for (let i = 0; i < SEED_ENTROPY_WORDS; i++) {
|
for (let i = 0; i < SEED_ENTROPY_WORDS; i++) {
|
||||||
// Determine which number corresponds to the next word.
|
// Determine which number corresponds to the next word.
|
||||||
let word = -1;
|
let word = -1;
|
||||||
for (let j = 0; j < libskynet_1.dictionary.length; j++) {
|
for (let j = 0; j < dictionary.length; j++) {
|
||||||
if (seedWords[i].slice(0, dictionary_1.DICTIONARY_UNIQUE_PREFIX) ===
|
if (seedWords[i].slice(0, DICTIONARY_UNIQUE_PREFIX) ===
|
||||||
libskynet_1.dictionary[j].slice(0, dictionary_1.DICTIONARY_UNIQUE_PREFIX)) {
|
dictionary[j].slice(0, DICTIONARY_UNIQUE_PREFIX)) {
|
||||||
word = j;
|
word = j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -87,21 +85,20 @@ function seedWordsToSeed(seedWords) {
|
||||||
}
|
}
|
||||||
return [bytes, null];
|
return [bytes, null];
|
||||||
}
|
}
|
||||||
async function login(page, seed = generateSeedPhrase()) {
|
export async function login(page, seed = generateSeedPhrase()) {
|
||||||
await page.goto("http://skt.us");
|
await page.goto("http://skt.us");
|
||||||
let userSeed;
|
let userSeed;
|
||||||
[userSeed] = (0, libskynet_1.seedPhraseToSeed)(seed);
|
[userSeed] = seedPhraseToSeed(seed);
|
||||||
let seedHex = (0, libskynet_1.bufToHex)(userSeed);
|
let seedHex = bufToHex(userSeed);
|
||||||
await page.evaluate((seed) => {
|
await page.evaluate((seed) => {
|
||||||
window.localStorage.setItem("v1-seed", seed);
|
window.localStorage.setItem("v1-seed", seed);
|
||||||
}, seedHex);
|
}, seedHex);
|
||||||
let kernelEntrySeed = (0, libskynet_1.deriveChildSeed)(userSeed, "userPreferredKernel2");
|
let kernelEntrySeed = deriveChildSeed(userSeed, "userPreferredKernel2");
|
||||||
// Get the registry keys.
|
// Get the registry keys.
|
||||||
let [keypair, dataKey] = (0, libskynet_1.taggedRegistryEntryKeys)(kernelEntrySeed, "user kernel");
|
let [keypair, dataKey] = taggedRegistryEntryKeys(kernelEntrySeed, "user kernel");
|
||||||
await (0, libskynetnode_1.overwriteRegistryEntry)(keypair, dataKey, (0, libskynet_1.b64ToBuf)(exports.TEST_KERNEL_SKLINK)[0]);
|
await overwriteRegistryEntry(keypair, dataKey, b64ToBuf(TEST_KERNEL_SKLINK)[0]);
|
||||||
}
|
}
|
||||||
exports.login = login;
|
export async function loadTester(page, port = 8080) {
|
||||||
async function loadTester(page, port = 8080) {
|
|
||||||
const server = new StaticServer({
|
const server = new StaticServer({
|
||||||
rootPath: path.resolve(__dirname, "..", "public"),
|
rootPath: path.resolve(__dirname, "..", "public"),
|
||||||
port,
|
port,
|
||||||
|
@ -118,7 +115,6 @@ async function loadTester(page, port = 8080) {
|
||||||
return kernel.init();
|
return kernel.init();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.loadTester = loadTester;
|
|
||||||
class Tester {
|
class Tester {
|
||||||
page;
|
page;
|
||||||
constructor(page) {
|
constructor(page) {
|
||||||
|
@ -130,5 +126,4 @@ class Tester {
|
||||||
}, id, method, data);
|
}, id, method, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const tester = (page) => new Tester(page);
|
export const tester = (page) => new Tester(page);
|
||||||
exports.tester = tester;
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
export {};
|
992
public/tester.js
992
public/tester.js
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue