Electron: crypto not defined - electron

Hello – my electron app has one user experiencing the error below. He's on Windows 10, and has reproduced it on two separate machines. I can't reproduce, nor have any other users reported this issue. The electron app is signed for Windows using a Comodo CA certificate. Originally, it occurred for him only when using electron's built-in autoupdate feature. Now that he's on the latest version, it occurs at launch – again, on two machines.
UPDATE: I have a second user reporting this now, though I still can't reproduce myself.
I can't seem to find anyone else posting with this error exactly, though I've tried changing the webpack require fallbacks, setting "browser": { "crypto": false }, and a few other things for similar errors (from Module not found: Error: Can't resolve 'crypto').
I'd love some direction to figure out what's going on here and what the fix should be.

Related

Got TLS error trying to find package cupertino_icons at https://pub.dartlang.org

I am getting below error-
Got TLS error trying to find package cupertino_icons at https://pub.dartlang.org.
pub upgrade failed (69) -- attempting retry 2 in 2 seconds...
My understanding is I am on office network(VPN) thats why I am getting this error. I have tried multiple options and I have seen multiple multiple post but no post shows the exact way of doing things. So I will post my all questions here, if anyone help it will be really helpful for all persons who are going to start work on flutter
1) How to set and create a self-signed certificate?
Do we need to create a self signed certificate for pub.dartlang.org domain?
have tried to create a certificate by using this (https://www.akadia.com/services/ssh_test_certificate.html) use domain as pub.dartlang.org, is this a correct way or how to do it?
2)I have put DART_VM_OPTIONS=--root-certs-file=C:\Users\dev\certs\chrome.cer as my certificate but still issue not resolved.
3)If I have to set https_proxy? What are the values for hostname and port in VPN? How can i find these values?
Flutter app behind corporate firewall throws TLS error during packages get
4) To solve this issue I have seen the reference of this comment
https://github.com/dart-lang/pub/issues/1882#issuecomment-415588527
How to implement this?
I have tried multiple things, if anyone can help how to bypass this error that will help many persons, I think.
I have same error on MACbook when running Flutter Create. When I opened the web-browser to access pub.dartlang.org, there is an error message that says: Your Clock is set incorrectly.
Somehow my date was set to a week ago. Fixing the date resolve the TLS issue.
It can be a network error or some kind of permission issue. I was facing same issue. In my case it was due to network permissions in our organisation. I tried with some another network which has full access and my issue was resolved.
It might be problem with restricted network.
You can set proxy
systemProp.http.proxyPort=PortNumber
systemProp.https.proxyPort=PortNumber
systemProp.http.proxyUser=User
systemProp.https.proxyUser=User
systemProp.http.proxyPassword=Password
systemProp.https.proxyPassword=Password
systemProp.https.proxyHost=YourHost
systemProp.http.proxyHost=YourHost
systemProp.http.nonProxyHosts=YourNonHost
systemProp.https.nonProxyHosts=YourNonHost
It might be a problem with the restricted environment variables sequence. You can set bash_profile:
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PUB_HOSTED_URL=https://pub.flutter-io.cn
keynote:
"FLUTTER_STORAGE_BASE_URL" is in front of "PUB_HOSTED_URL"
I was also getting the same error, after upgrading my flutter. I was connected to the internet but my clock was not on correct time. After I have corrected the time on my pc, the error was solved.

Start electron app with admin privileges as default

I created an electron app which can only be started as admin, because it needs it for various command executions. Now it prompts that it must be started as admin.
This question was very helpful.
Now I want to start it with admin privileges right away so windows asks for the acception. It shouldn't be able to start the app without admin privileges.
I tried adding --win32metadata.requested-execution-level=requireAdministrator, but then it writes an error on startup (always):
The application has failed to start because the side by side configuration is incorrect.
How can I achive this with the electron packager?
Your electron-packager code looks fine, and the switch works for me.
This can happen if you are missing Visual C++ Runtimes, or if they're corrupted. Try installing them from here and try again.
If that doesn't help, then you should dig into the Event Viewer, which should come installed on your machine, and see what the specific error is. This page has some additional tips on troubleshooting this issue.

React-Native ios App crashes without report

I'm building an iOS app using React Native and trying to get it testable on phones.
If I plug my phone into the computer and "build" directly to the phone, the app is built correctly and opens/operates correctly, no problem.
But if I try to archive it and send it to phones using iTunes Connect's TestFlight or Fabric with Crashlytics, the app crashes immediately upon opening. It briefly shows the launch screen, but no more.
Moreover, there are no crash reports -- in TestFlight, in Crashlytics, or in XCode, once I plug the phone back in. So I'm operating in the dark here, without any information on what's breaking. Haven't been able to find a similar issue online, so I figured I'd just ask. Any ideas what could be going wrong?
Please let me know if there's any code or other data you might need to see. Some of it's confidential, but I'll try to post an approximate version.
As Chris Geirman suggested, the problem was a JavaScript error. I'm not sure people with similar problems will find this thread, but in case they do, here is the weird error that was occurring.
I had created a simple ORM system, with a BaseModel and a bunch of models that inherited from it. The BaseModel constructor looked like this:
constructor(props = {}, relations = {}) {
Object.keys(props).forEach((k) => {
// Save props to object
this[k] = props[k];
});
this.relations = relations;
this.className = this.constructor.name;
}
That last line was the problem. On my local simulator and if I build the app to my phone by plugging it in, this works fine. As in, if a Message model inherits from BaseModel, calling var msg = new Message(data, relations); msg.className returns Message.
But something about bundling/archiving/sending the app through TestFlight or Fabric.io minifies and uglifies the JavaScript, such that the class names are changed. So instead, if I do this -- var msg = new Message(data, relations); msg.className -- I'll get back a random variable name, something like 't'.
This was a problem in my app, because my home page contained a switch statement that worked off of the className:
iconContent() {
return {
Message: {
icon: <Image style={styles.feedItemIconImage} source={ require('../assets/img/icon_message.png') } />,
color: c.grass
}, ...
}[this.props.className] // from the model item
}
But 'Message' wasn't, as expected, the value of this.props.className -- 't' was. And so, if I were to try to tunnel into, say, the color value, I'd hit an error, because I was trying to access the color property of null.
Why that didn't report, I don't know (I followed Chris's suggestions and installed Sentry, but it still seemed not to report that error).
But that's what was going on. Minification/uglification occurred only when I installed the app on a phone via TestFlight/Fabric, and that's why the app only crashed in those conditions.
Hope this saves anyone running into a similar bug from tearing out their hair.
I'd like to share my own experience of production stage crash, whereas everything worked fine in development stage.
I had the similar problem which caused by the Reactotron logger. Since I'm not bundling it in production stage, a single line of console.tron.log crashed my app with full stealth. (Its kinda my fault, since I didn't give a damn about my linter with 'no-console' setting)
Here's the code snippet I introduce in my root level file, root.js.
if (__DEV__) {
...
console.tron = Reactotron;
...
}
Hope somebody finds this before wasting time figuring out what's wrong.
Not sure if you still have this problem - but if you do, I'd recommend checking out Bugsnag for react native error reporting - which reports crashes in both the JavaScript layer as well as the native layers (java/cocoa).
One of the harder problems to solve in react native crash reporting (as Sasha mentioned) is restoring the original stack traces when using minification and/or obfuscation - this is handled in Bugsnag by providing full support for JS source maps, as well as iOS symbolication and Android Proguard support at the native layers.
Let me know if this helps - I'm a founder # Bugsnag

access trouble when controlling remote mac with AppleScript

I'm new to all this programming stuff, but trying to learn. I've had moderate success, but feel like it's more accidental than intentional. I'd appreciate help learning and understanding AppleScript in particular and networking, automation and programing in general.
Here's the environment: Almost all Apple with two Minis, a couple of laptops and various iOS devices including an AppleTV. The network consists of an Apple Airport Extreme, and an older D-Link switch I rescued (with permission) from the recycle bin at work. There are three Foscam wi-fi cameras as well. One of the Mini's (named Dora) is acting as a file server running Yosemite and the OS X Server application with a growing RAID 1 array for media storage.
What I’d like to be able to do is to run a single AppleScript from my laptop (Adam’s Macbook) that does the following:
Launch the application iCamSource on Adam’s Macbook
Change “Require Password to Wake” to true on Adam’s Macbook
Quit iTunes on Adam’s Macbook if it’s running
Start the current ScreenSaver locking Adam’s Macbook
Quit iTunes on Dora if it’s running
Start the current ScreenSaver on Dora if it’s not already running thereby locking Dora
I’d also like to have a single script on Adam’s Macbook that reverses these actions.
I have been able to launch iCamSource, set “Require Password to Wake” to true and start the ScreenSaver on Adam’s Macbook with a lot of Google-Fu, much trial and error, and quite a bit of frustration. I’ve not yet tried to quit iTunes if it’s running. That’s a new idea/requirement, but I think it should be pretty simple to add to the functioning script.
Where I’m running into trouble is controlling Dora from a script on Adam’s Macbook. I run into access errors (905 and 927 generally) about half to two thirds of the time I run the script. I’ve tried every syntax option and many combinations of syntax that I found via Google searches, but this is the one that has the most (but still inconsistent) success.
set remoteMachine to "eppc://remoteMachineadam:slajdlll#10.0.1.2"
tell application "iTunes" of machine remoteMachine
quit
end tell
When reading various articles explaining how to do this, sometimes the scripts use eppc, others use epps and I’ve not seen a consistent result with either one. Some of the articles use the actual IP address of the remote machine, others use password#name.local, so that syntax would be slajdlll#dora.local. That change also seems inconsistent in its results.
This seems to be a pretty basic task, and I’ve found lots of articles that do this very thing, but their methods don’t work in my environment. Many of the articles I’ve read are quite old, so the syntax may be out of date. I’m kind of at my wits end, but feel I should be able to make this work. Any help y’all could provide would be VERY appreciated.
Update - I had the scripts working last night in all regards except controlling the remote machine. This morning, I tried to open the "Away" script to again tackle the remote control issue and I get a Syntax Error Unable To Authenticate User message and the script won't compile. Here's the code:
tell application "System Events"
try
tell application "iTunes" to quit
end try
try
tell application "iTunes" of machine "eppc://Dora.local" to quit
end try
tell security preferences
set require password to wake to true
tell application "iCamSource" to activate
tell application "System Events" to start current screen saver
end tell
end tell
Both "Away" and "Home" scripts run from the AppleScript menu. When I unlock the ScreenSaver after running the "Away" script I get a dialog box stating "There was a problem connecting to the server "Dora's Airport Extreme. The share does not exist on the server. Please check the share name, and then try again." I'm beginning to think I may have a Permissions error on one or more of the machines, or if there's another problem that's making the scripts act inconsistently.
Thanks for all the help so far!
UPDATE Ok, it seems that there was a problem with iPhoto and Screen Saver interacting with the files on the networked hard drive. Opening iPhoto and slowly opening each image and re-linking those that had lost their location seems to have solved that problem. I am still encountering the access error code 905. In order to troubleshoot this process, I'm stripping the script down to one task, to quit iTunes on the remote machine named "Dora" Here's the code:
set Dora to "epps://adam:slajdlll#10.0.1.2"
try
tell application "iTunes" of machine Dora to quit
end try
Here's the event log that running that script generates:
tell application "iTunes" of machine "eppc://epps/adam%253kslajdlll%4010.0.1.2.local"
quit
--> error number -905
end tell
Is it possible/probable that the OS X Server application is mis-configured and is preventing the script from controlling the remote machine? Any other thoughts or things to try?
Thanks!
UPDATE 2
In the Groups section of the OS X Server application running on the remote machine, I found that there is a group called Apple Remote Events ACL. When I click the Edit button to view it's settings I see the actual account name is "com.apple.access_remote_ae-disabled". I wonder if this is telling us something. I searched several libraries for "com.apple.access" thinking it may be something that could be edited, but found nothing. I'm a member of that group. I tried removing myself from the group and tried the script with no change in the results so I added myself back into it.
UPDATE 3
As suggested I'm trying to eliminate OSX Server from the equation. To do this I'm going to try to launch TextEdit (since it's faster to launch than iTunes) on a third machine, known as Office Mini that does not have the Server application on it. Here's the script:
set OfficeMini to "eppc://10.0.1.196"
try
tell application "System Events" of machine OfficeMini
open "/Applications/TextEdit.app"
end tell
end try
When I ran the script initially I got two dialog boxes asking for username and password. I supplied them and checked the "Save in Keychain" checkbox. The script didn't open TextEdit, but I'm not getting the access errors. I am getting different errors though, -600 or -10010 depending on if I use System Events or the Finder. Using the list on this page: Nicholas Reilingh AppleScript Error Codes I find that with System Events I get an error -600 which means the application isn't running. That's no surprise, I'm trying to open it. When I use the Finder instead of System Events, I get an error -10010 which the list indicates is "Handler can’t handle objects of this class." So, there's progress, but I'm still stumped.
UPDATE 4 To further clarify/simplify, I tried running a simple script to open iTunes on the Office Mini locally on that machine and it worked fine.
tell application "iTunes" to activate
Substituting the "quit" for "activate", and trying this syntax with several different applications all worked quite well and very fast. I tried the same script and variations on the Dora machine with the same, successful results.
I then tried to make that syntax work remotely with this code:
set OfficeMini to "eppc://10.0.1.196"
tell application "iTunes" of machine OfficeMini to quit
I got this error message in the event log:
tell application "iTunes" of machine "eppc://10.0.1.196"
quit
--> error number -927
Result:
error "iTunes got an error: Unable to authenticate user." number -927
So, since OSX Server isn't running on the Office Mini, this seems to eliminate that as a culprit for the error. I tried altering the code with another variant I saw online that uses "epps" in place of "eppc" which results in a similar error message: "iTunes got an error: Remote access isn’t allowed." number -905. I did not get dialog boxes requesting credentials. When I've seen the "epps" string used online, it was formatted as "epps://username:password#location" so I used "epps://adam:slajdlll#10.0.1.196" and received the same error message. I even tried "Adam" in place of "adam" with no change in the results.
Yes, step 1 is to try to make your script as simple as possible to narrow down the point of failure.
I have copied your minimal script onto my machine & gotten it to work:
set Dora to "minipuppy.local"
try
tell application "iTunes" of machine Dora to quit
end try
A few notes:
I used "minipuppy.local" (the Bonjour linklocal name) rather than your eppc stuff, because I know what the former is, but not the latter. (You can get the link local name from the Sharing prefs panel* where it says "Computers on your local network can access your computer at:XXXXX"
An authentication dialog popped up saying that I needed to enter the username and password for the target machine - but it did have
an eppc address in the dialog (I didn't take a screenshot :-( )
After entering the username/password my script did nothing. Interestingly, I could not get it to print out a log as yours has?
I fixed this by going to the target Mac's System Preferences & enabling "Remote Apple Events" in the Sharing panel*. After turning that on, my script worked.
I'm hoping enabling "Remote Apple Events" is the ultimate solution to your simplified problem.
*Apple Menu -> System Preferences -> Sharing

XCode Server CI Bot Integrate error (Swift)

I am trying to setup a CI server on my Macbook, I have followed the documentation on the apple website up to the point of creating a bot and integrating my build. When I attempt to integrate the build I repeatedly get the following error:
Bot Issue: error. Build Service Error.
Issue: '/Library/Developer/XcodeServer/Integrations/Caches/14a8ea2a72904f1abcecd38b1c02196b' exists and is not an empty directory (-4).
Integration Number: 13.
Integration URL: https://DavidMcQueens-MacBook-Pro-2.local/xcode/bots/BF817C9/integrations
Description: '/Library/Developer/XcodeServer/Integrations/Caches/14a8ea2a72904f1abcecd38b1c02196b' exists and is not an empty directory (-4).
I have manually deleted the folders in this location, as well as changing the permissions incase the server was having issues writing. Each time I run, I receive the same error. Even after I have deleted the folder so it is empty before the integration.
Does anyone have any ideas on how to solve this issue? I have built my iOS application in Swift (which I believe should still work with the CI server)
I am running OSX Server 4.0 and the latest version of XCode.
I followed Apple's documentation for creating bots
Thanks,
EDIT:
After some experimenting and trying different things to see what the issue is, I disabled 2-factor authentication on my GitHub hosting. This appeared to solve the issue, despite the fact that I was generating a specific application key to get around 2-factor. It solved the issue for a small amount of time, and I managed to successfully get the bot to integrate a few times. However it appears to have gone back to its old tricks.
If anyone has any other knowledge on this, or has managed to get it working on their own machines it will be good to know.
So I believe I have solved this issue, the GitHub 2-factor authentication issue looks to be a red herring.
When setting up the bot, there is a section that says "Checkout the repository", I did not do this step because I already had the repository on my local machine and presumed that it would simply create the repository in another location, and server no other purpose.
However, after some investigation this step is very necessary. From what I understand, checking out the repository does create it again in another location, however this is necessary as this new repository is where the Bot's will pull changes into and build in order to perform the tests. I was trying to use the same repo for development and for the Bots, which it did not like.
Creating a clean checkout of the project (on the server), and configuring the bots in that project then allowed me to progress and get everything setup correctly. It comes down to user error. In hindsight, it makes perfect sense to have a separate repo for the bots (this is my first CI server setup), however the error messages were not helpful and I can't remember seeing this emphasised in the setup guide.

Resources