Edge Extension, packaging: The site URL is not a valid URL - microsoft-edge

I am trying to package my Edge extension using the tutorial here https://learn.microsoft.com/en-us/microsoft-edge/extensions/guides/packaging/using-manifoldjs-to-package-extensions
I have created the extension (ported from Chrome) and tested it by loading it in Edge. It works great. Now I want to package it.
I run
manifoldjs -l debug -p edgeextension -f edgeextension -m path\manifest.json
and get the error:
[error] manifoldjs : The site URL is not a valid URL.
I don't know what it is referring to. I get the same error if content_script.js is blank. This is my manifest file:
{
"author": "My name",
"name": "My name",
"version": "1.0.0",
"background": {
"page": "background.html",
"persistent": true
},
"browser_specific_settings": {
"edge": {
"browser_action_next_to_addressbar": true
}
},
"browser_action": {
"default_title": "My name",
"default_icon": {
"20": "icon_20.png",
"25": "icon_25.png",
"30": "icon_30.png",
"40": "icon_40.png"
}
},
"content_security_policy": "default-src 'none'; script-src 'self'",
"icons": {
"48": "icon48.png",
"128": "icon128.png"
},
"permissions": [
"*://*/*"
],
"-ms-preload": {
"backgroundScript": "backgroundScriptsAPIBridge.js",
"contentScript": "contentScriptsAPIBridge.js"
}
}

Seems you have to define the correct path to manifest.json
manifoldjs -l debug -p edgeextension -f edgeextension -m [changeThisToYourPath]/manifest.json

Related

Serilog not creating log file on production server

I've created a C# .net5.0 console application and during testing Serilog has been working without incident, logging to Console and File (same folder; path="log.txt"). However, when I run on the application on our server, neither Console nor File logging sinks are working! I assume now that the issue is not the sinks themselves but Serilog not actually working.
I've tried enabling the self log:
Serilog.Debugging.SelfLog.Enable(msg =>
Console.WriteLine(msg)
);
but even running in the debugger in my dev environment, the Console.WriteLine(msg) line is never called!
My appsettings.json is as follows:
{
"Serilog": {
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Information",
"System": "Information"
}
},
"WriteTo": [
{
"Name": "Console",
"Args": {
"theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console",
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} {NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "log.txt",
"rollingInterval": "Infinite",
"outputTemplate": "{Timestamp:HH:mm:ss.fff} [{Level:u3}] {Message:lj}{NewLine}{Exception}",
"shared": false
}
}
],
"Enrich": [ "FromLogContext" ]
},
"Database": {
"Server": "(local)",
"Database": "ActivbaseLive"
},
"Email": {
"SmtpHost": "localhost",
"SmtpPort": 25,
"SmtpSecurityOption": "None",
"SmtpUsername": null,
"SmtpPassword": null,
"SmtpSender": "\"Activbase Learning Platform\" <noreply#activbase.net>"
}
}
I've tried absolute paths (using double backslashes in appsettings.json).
I've tried pre-creating the log file (e.g. log.txt and log200428.txt) and setting permissions to Everyone Full Control but neither of these changes fix the problem and they don't explain why the Console sink doesn't write either.
Here is how Serilog is being configured during start-up which is where I suspect the problem is (even through it works in dev environment):
return Host.CreateDefaultBuilder()
.ConfigureLogging(logging =>
{
logging.ClearProviders();
})
.UseSerilog((hostContext, loggerConfiguration) =>
{
loggerConfiguration.ReadFrom.Configuration(hostContext.Configuration);
})
.ConfigureAppConfiguration((hostContext, builder) =>
{
builder.AddEnvironmentVariables();
})
.ConfigureServices(services =>
{
services.AddHostedService<Worker>();
...
});
}
Any ideas why Serilog isn't working in production?
The Path you provide should be absolute.
Some thing like this:
"path": "E:/wwwroot/QA/BackgroundWorkerService/Logs/logFile_.log"
Even I had the same issue, the above fix worked fine for me...
For my api application running in IIS: I had to assign the following permissions to the log folder for the IIS_IUSRS. I didn't need an absolute path!

Symfony flex (3.4) throws autowire issue with php based configuration in service and routes

My team working on symfony flex project. Its bit new to us. My composer file :
{
"type": "project",
"license": "proprietary",
"minimum-stability": "dev",
"require": {
"php": "^7.1",
"symfony/console": "^3.4",
"symfony/flex": "^1.0",
"symfony/framework-bundle": "^3.4",
"symfony/lts": "^3",
"symfony/yaml": "^3.4",
"guzzlehttp/guzzle": "~6.0",
"league/flysystem-aws-s3-v3": "^1.0",
"oneup/flysystem-bundle": "^2.0",
"php-amqplib/rabbitmq-bundle": "^1.13"
},
"require-dev": {
"symfony/dotenv": "^3.4",
"behat/behat": "^3.4",
"behat/symfony2-extension": "^2.1",
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^6.4"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd"
},
"post-install-cmd": [
"#auto-scripts"
],
"post-update-cmd": [
"#auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"id": "01BY8F14MYNYFXEQV8P8QRJQHS",
"allow-contrib": false
}
}
}
When I run composer install I got below error:
Script cache:clear returned with error code 1
!! PHP Warning: Module 'apcu' already loaded in Unknown on line 0
!!
!! In DefinitionErrorExceptionPass.php line 37:
!!
!! Cannot autowire service "App\Services\ApiRequestValidator": argument "$secr
!! et" of method "__construct()" must have a type-hint or be given a value exp
!! licitly.
!!
!!
!!
While doing composer install we observed the symfony creates service.yaml file inside the config folder. Where as we wanted to use only php based configurations as defined at PHP-based configuration for services and routes.
If I delete the service.yaml files and run again the composer install it works well.
I am not sure why symfony creates explicitly service.yaml file when I have already php based service configuration inside my config folder.
This blocks me to up my docker container as well.

registering custom protocol at installation process in electron app

Hi I am new to electron and was wondering how i can register a custom protocol for the app at the time of installation process of the app.
I am using electron-builder for building the app. Here is the build build code
"build": {
"appId": "com.test.testapp",
"productName": "testapp",
"asar": true,
"protocols": [{
"name": "testapp",
"schemes": [ "testapp" ]
}],
"nsis": {
"oneClick": false,
"perMachine": true,
"allowToChangeInstallationDirectory": true,
"runAfterFinish": false,
"createDesktopShortcut": true
},
"squirrelWindows": {
"msi": true
},
"directories": {
"output": "distribution"
}
I know that by adding the below line registers the custom protocol
app.setAsDefaultProtocolClient("testapp");
but it only does if i run the app at least the first time.
Which i don't want there is no guarantee that the user will launch the app after installation.
So is there a way that i can register the custom protocol in the installation process using electron-builder
I'm still new to Electron and electron-builder but solved this problem for NSIS-target already. First of all I should note that app.setAsDefaultProtocolClient used to handle custom protocols inside the application as far as I do understand. You need to register this custom protocol using electron-builder itself.
Secondly I need to choose between NSIS and squirrelWindows. NSIS is the preferable as long I understand because Squirrel is less supported and has some problems. Again I'm not an expert but I read something about it. So squirrelWindows section is redundant. You don't specify win.target and it is "nsis" by default.
There is a problem with the custom protocol registration for NSIS target. You can read more here: Protocol (scheme) for windows but there is a workaround. You need to create a file named installer.nsh in your build folder with such a content:
!macro customInstall
DetailPrint "Register evehq-ng URI Handler"
DeleteRegKey HKCR "evehq-ng"
WriteRegStr HKCR "evehq-ng" "" "URL:evehq-ng"
WriteRegStr HKCR "evehq-ng" "EveHQ NG SSO authentication Protocol" ""
WriteRegStr HKCR "evehq-ng\DefaultIcon" "" "$INSTDIR\${APP_EXECUTABLE_FILENAME}"
WriteRegStr HKCR "evehq-ng\shell" "" ""
WriteRegStr HKCR "evehq-ng\shell\Open" "" ""
WriteRegStr HKCR "evehq-ng\shell\Open\command" "" "$INSTDIR\${APP_EXECUTABLE_FILENAME} %1"
!macroend
Replace evehq-ng with your protocol string and EveHQ NG SSO authentication Protocol with your protocol description.
After that you have to set nsis.perMachine to true.
I haven't yet solved this problem for Linux but work in this direction. You can see my code in my proof of concepts project here: EveHQ-NG proof of concepts application.
If you will solve this problem for Linux and MacOS write me a message somehow here or on GitHub.
Hope it helps.
Since you are using electron-builder you can do the following:
"build": {
... other top level electron-builder keys ...
"protocols": [
{
"name": "Custom Protocol Name",
"schemes": [
"customProtocol"
]
}
]
}
In case you wanted to handle customProtocol://some-link with your application.
More details:
https://www.electron.build/configuration/configuration
(Search for protocols; as of now, the documentaion is a little mis-formatted. It's supposed to be the same top-level key as the fileAssociations key above it.)
custom protocol is still opening only after opening the electron application. And I also added installer.nsh inside build folder. I don't know what's the problem.
package.json
{
"name": "electron-project",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "electron .",
"pack": "build --dir",
"dist": "build"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"electron": "^3.0.8",
"electron-builder": "^20.38.5"
},
"dependencies": {
"axios": "^0.18.0"
},
"build": {
"win": {
"target": "nsis"
},
"nsis": {
"oneClick" : false ,
"allowToChangeInstallationDirectory": true,
"include" : "dist/installer.nsh" ,
"perMachine" : true
},
"protocols": [{
"name": "electron-deep-linking",
"schemes": [
"test"
]
}],
"mac": {
"category": "public.app-category.Reference"
}
}
}
main.js
const { app, BrowserWindow } = require('electron')
const path = require('path')
const url = require('url')
let mainWindow
function createWindow() {
mainWindow = new BrowserWindow({ width: 800, height: 600 })
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}))
mainWindow.on('closed', function () {
mainWindow = null
})
}
app.setAsDefaultProtocolClient('test')
app.on('ready', createWindow)
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
if (mainWindow === null) {
createWindow()
}
})
Electron providing a very simple way to registering custom protocol URL in client machine(Windows, Mac)
so this way we can register and remove our own custom protocol in machine
const {app} = require('electron')
app.on('ready', onReady)
function onReady() {
.... // write other code
if(!app.isDefaultProtocolClient('quickstart')) {
app.setAsDefaultProtocolClient("quickstart", 'C:\\Users\\karthi\\electron-quick-start\\electron-quick-start-win32-x64\\electron-quick-start.exe');
}
}
this code will register the custom protocol in machine, then you can open your app using browser like quickstart://params
for removing the custom protocol in machine
app.removeAsDefaultProtocolClient("quickstart", 'C:\\Users\\karthi\\electron-quick-start\\electron-quick-start-win32-x64\\electron-quick-start.exe');
here i used electron quick start app and i used electron-packager npm for building my app
For more information custom protocol electron-protocol

Can I use "router" in roadhog's "proxy" prop?

When I config my .roadhogrc, roadhog's doc said I can set "proxy" prop same as webpack-dev-server#proxy.
I add a "router" prop, then my page can not load, due to the "index.css" timeout.
So, how to use "proxy" in .roadhogrc?
or any way to change the api to test env in localhost?
I can't find "dva" or "roadhog" tag, so sorry to use "antd" tag.
{
"entry": "src/index.js",
"env": {
"development": {
"extraBabelPlugins": [
"dva-hmr",
"transform-runtime",
["import", { "libraryName": "antd", "style": "css" }]
],
"proxy":{
"router":{
"http://api.eshop.corploft.com" : "http://test.corploft.com"
}
}
},
"production": {
"extraBabelPlugins": [
"transform-runtime",
["import", { "libraryName": "antd", "style": "css" }]
],
"outputPath":"build/yijiayi"
}
}
}
Maybe I told a joke...
All the proxy and mock settings are acting on localhost network, so I can only change the requests to local server. If I want to change a request to other servers, all above settings has no help.
SwitchyOmega (in Chrome App Store) or ihosts can help.

browser.runtime.connect api not working as expected with Firefox for android?

I am developing an extension for Firefox for Android, but since tabs APIs are not supported on Firefox(Android), I am using the following code. It is working fine on Firefox but when porting it to Firefox Android(52 version), background script messages are not being passed to content script listener.
//Content script code
var myPort = browser.runtime.connect({name:"port-from-cs"});
myPort.postMessage({greeting: "hello from content script"});
myPort.onMessage.addListener(function(m) {
console.log("In content script, received message from background script: ");
console.log(m.greeting);
});
// background script
var portFromCS;
function connected(p) {
portFromCS = p;
portFromCS.postMessage({greeting: "hi there content script!"});
portFromCS.onMessage.addListener(function(m) {
console.log("In background script, received message from content script")
console.log(m.greeting);
portFromCS.postMessage({greeting: "hi there content script!"});
});
}
browser.runtime.onConnect.addListener(connected);
//manifest
{
"version": "0.1.5",
"content_scripts": [
{
"js": [
"js/myContentScript.js",
"js/lib/jquery-1.9.1.min.js"
],
"matches": [
"<all_urls>"
],
"run_at": "document_start"
}
],
"description": "xxx",
"manifest_version": 2,
"name": "xx",
"applications": {
"gecko": {
"id": "vpt#mozilla.org"
}
},
"permissions": [
"webRequest",
"notifications",
"http://*/",
"https://*/",
"storage",
"webRequestBlocking"
],
"background": {
"scripts": [
"js/background.js"
]
},
"web_accessible_resources": [
"xxx.js"
]
}
content script is passing the message to background script, but background script messages are caught by portFromCS.onMessage listener. Is my approach correct?

Resources