Pushwoosh how to export presets - pushwoosh

In Pushwoosh I have to configure over 200 presets in 3 environments(test, UAT, and Production). Is there a way to export and import presets?
It would be too time-consuming if I have to manually create them in each environment.

There is a couple of ways to clone presets programmatically.
Open API
This way is preferrable if you'd like to clone presets across different accounts.
1.1. Obtain the list of presets via listPresets API
1.2. Filter the list (if needed)
1.3. For each preset that you'd like to clone, obtain preset information using getPreset API
1.4. Prepare mapping of properties as per the guide
1.5. Create new presets at target account using createPreset API
If your preferred scripting language is Python, you may use this library for easy access to these API methods.
Internal Browser API
If you want to simply clone presets between two apps/projects of the same account, you may opt to use Javascript macros from this Gist.
This is how you do it:
2.1. Log in to Pushwoosh account where you want to clone presets/events
2.2. Make sure that DESTINATION app has all platforms configured, that are selected in presets
2.3. Make sure the Max Presets limit of your account would allow the total number of presets to be created.
2.4. Open the Console of your browser where you logged in to your Pushwoosh account
Set up HOST variable to point to your dedicated server. E.g. if your dedicated server address is subdomain.pushwoosh.com, you should do the following:
type const HOST="subdomain"; and press Enter
If your account is on go.pushwoosh.com, set the HOST variable to "go".
2.5. Copy-paste contents of migrate-presets-events.js to Console and hit Enter.
2.6. Now launch command to migrate all presets from SRC to DST:
await migrate_presets('SRC_APP_CODE', 'DST_APP_CODE');
If either of methods looks challenging, feel free to contact our support for assistance: help#pushwoosh.com

Related

Where are secure locations to store encryption keys in a react-native app?

I have a react-native app that communicates with a server that makes calls to stripe for payment processing/customer creation. I want to ensure that requests are coming only from my app. so i figured i could create a token of sorts on the client, and encrypt it with a special key using b-crypt, then on the server side when the request comes in with the encrypted token as a parameter, i can decrypt that token with the same special key.
i understand the optimal place to store this key is in the env variables server-side, but how do you manage security of a secret key client-side in a react-native app?
There are several ways to store keys on the client side.
The easiest way is to use the Async storage which stores data in a key value pair.
The problem with Async storage is that its nor encrypted so it wont suit your requirement.
The other option is to use the react-native-keychain library which stores the passwords or keys in the securely in the keychain of IOS and keystore in Android. The security part will be managed by the operating system. So this is an approach that can be recommended for your requirement.
There are multiple ways to do this, these are just two options.
After further research, I ended up revoking the accepted status of #GuruparanGiritharan. his solution (react-native-keychain) dealt with storing passwords in an OS's keychain implementation. this ended up not being the solution for my question. as my question deals with storing secrets keys in a way they wouldn't be visible in binary, de-compiling situation.
What I did was research key management services. I found this:
Handling secrets with dotenv
In Node.js secrets are usually loaded from env files using the dotenv
module. This is done in order to separate the secrets from source
code. For example an env file might look like this (reference below):
DB_HOST=localhost
DB_USER=root
DB_PASS=s1mpl3
Now doing this in a context (potentially development) where you dont need to implement continuous integration, it's referred to a "manual provisioning"
My issue (admittedly, I did not specify a production environment in my question) is when it comes to a production environment, in my case, with visual studio app center (a CI option for React-Native apps)
Continuing on this site for an option for key management services:
While this removes hardcoded secrets from source code, it doesn’t
solve your problem completely; Now you need to find a way to provision
your app with the .env file.
This guide will show how you can remove the secrets from the .env file
altogether, so that it can be safely checked into source control and
shipped with your application.
This guide is discussing how to implement key management in the context of a production environment with continuous integration. This approach is relatively simple and straightforward, as all you need to do is create an .env file, add the keys with a variable, and add (in this tool's case) an additional run script to your main node.js start script.
Tool mentioned: SecretHub
https://secrethub.io/docs/guides/nodejs/

How does Gatsby hide API-keys on the frontend

So, I'm struggling to understand how Gatsby works. I'm using the https://www.gatsbyjs.org/starters/AlexanderProd/gatsby-shopify-starter/ which uses a Gatsby plugin called gatsby-source-shopify. The plugin takes two params: shopName and accessToken. It looks like this in gatsby-config.js:
{
resolve: `gatsby-source-shopify`,
options: {
// The domain name of your Shopify shop. This is required.
shopName: process.env.SHOP_NAME,
// An API access token to your Shopify shop. This is required.
accessToken: process.env.SHOPIFY_ACCESS_TOKEN,
},
},
Will the access token be available for people to look at when I deploy the app? Do I need to use something like Serverless functions to hide my API keys, or is this fine. Any general explanation of how this works in Gatsby would be awesome.
Thanks Gatsby fam!
As the code shows, it uses process.env.SHOP_NAME where SHOP_NAMEis the name of the environment variable. Those files are declared at the root of the project using some naming such as .env.domain1.com. In this file, you can store any desired variable to use it in your Gatsby configurations. When dealing with delicate variables (API keys, tokens, passwords, etc) it's recommended to use that way and ignore all .env files in your .gitignore.
When you trigger a command in Gatsby, you can pass it some variables, for example:
"develop": "GATSBY_ACTIVE_ENV=domain1.com gatsby develop"
In this case, GATSBY_ACTIVE_ENV var will have domain1.com as a value. Then, in you gataby-config.js, when you can use environment variables (above module.exports):
require("dotenv").config({
path: `.env.${process.env.NODE_ENV}`,
})
Then, you can create an environment file such as .env.domain1.com in your root project and store any desired variable:
SHOP_NAME: 12345
Taking into account the code you've provided if you run develop (with all I've explained) command it will take SHOP_NAME as 12345.
So, answering your question, you won't have access to that tokens. You need to store them in your local machine and in your deploy server, not in your repository.
From Gatsby docs:
Please note that you shouldn’t commit .env.* files to your source
control and rather use options given by your Continuous Deployment
(CD) provider...
Edit: Thanks to #Hans Martin Henken for providing the following article about Gatsby security

Parse server account key

Installed Parse Server on Digital Ocean, and have been trying to use the CLI to manage cloud code. I've hit a wall, since the CLI tool will not move forward without an account key on Parse.com (which no longer offers account keys). For example, if I type in "parse new", I get this:
We've changed the way the CLI works. To save time logging in, you should create an account key. Type "parse configure accountkey" to create a new account key. Read more at: https://parse.com/docs/cloudcode/guide#command-line-account-keys
If you actually do that, it responds:
Input your account key or press ENTER to generate a new one. NOTE: on pressing ENTER we'll try to open the url: "https://www.parse.com/account/keys" in the default browser:
This leads to a login page. Since I don't have an account on Parse.com (nor should it be necessary for Parse Server), I'm stuck. If I click on the "I don't have an account" link, it just takes me to the front page.
I find it hard to believe that there's no way to manage/create cloud code on Parse Server. But, it is sure looking that way. Is this just a failure to update the CLI or am I missing something obvious.
Many thanks.
Parse cli is not meant to be used with parse server. At least not currently. Parse server is simply a node module which means that you will have to handle deployment etc yourself. There are many tools that will handle everything that the parse cli did, and much more, from the nodejs community however.
You said that you used digital ocean. You might want to consider heroku, aws or google cloud. Heroku for example has the heroku cli with many of the same features as the parse cli which might save you some time.
You can't use parse cli on parse-server. Parse-server and parse.com environment are both different , parse-server is just the node module so deployment can be automated using other tools.
I am using forever to restart my parse-server automatically when a file changes. So you can just copy/paste your files using filezilla and that's it.

How do I backup to google drive using duplicity?

I have been trying to get duplicity to backup to google drive. But it looks like it is still using the old client API.
I found some thread saying that the new API should be supported but not much details on how to get it to work.
I got as far as compiling and using duplicity 7.0.3 but then I got this error:
BackendException: GOOGLE_DRIVE_ACCOUNT_KEY environment variable not set. Please read the manpage to fix.
Has anyone set up duplicity to work with Google Drive and know how to do this?
Now that Google has begun forcing clients to use OAuth, using Google Drive as a backup target has actually gotten very confusing. I found an excellent blog post that walked me through it. The salient steps are:
Install PyDrive
PyDrive is the library that lets Duplicity use OAuth to access Drive.
pip install pydrive
should be sufficient, or you can go through your distribution's package manager.
Create an API token
Navigate to the Google Developer Console and log in. Create a project and select it from the drop-down on the top toolbar.
Now select the "Enable APIs and Services" button in the Dashboard, which should already be pulled up, but if not, is in the hamburger menu on the left.
Search for and enable the Drive API. After it's enabled, you can actually create the token. Choose "Credentials" from the left navigation bar, and click "Add Credential" > "OAuth 2.0 Client ID." Set the application type to "Other."
After the credential is created, click on it to view the details. Your Client ID and secret will be displayed. Take note of them.
Configure Duplicity
Whew. Time to actually configure the program. Paste the following into a file, replacing your client ID and secret with the ones from the Console above.
client_config_backend: settings
client_config:
client_id: <your client ID>.apps.googleusercontent.com
client_secret: <your client secret>
save_credentials: True
save_credentials_backend: file
save_credentials_file: gdrive.cache
get_refresh_token: True
(I'm using the excellent Duply frontend, so I saved this as ~/.duply/<server name>/gdrive).
Duplicity needs to be given the name of this file in the GOOGLE_DRIVE_SETTINGS environment variable. So you could invoke duplicity like this:
GOOGLE_DRIVE_SETTINGS=gdrive duplicity <...>
Or if you're using Duply, you can export this variable in the Duply configuration file:
export GOOGLE_DRIVE_SETTINGS=gdrive
Running Duplicity for the first time will begin the OAuth process; you'll be given a link to visit, which will ask permission for the app you created earlier in the Console to access your Drive account. Accept, and it will give you another authentication token to paste back into the terminal. The authorization info will be saved in a .cache file alongside the gdrive settings file.
At this point you should be good to go, and Duplicity should behave normally. Good luck!

Add a route in osx's routing table programmatically

In my app i want to add a specific route in OSX's routing table which i can easily add through the terminal like this
/sbin/route add -host X.X.X.X -interface en1
. for that i do some search on google and get to know that there is a file /etc/ppp/ip-up which consult by OS every time when a ppp link is up so i set my target to modify this file programmatically
but then OS not allow me without root access so now i have to make possible this command to run programmatically now i found on google "i have to run a helper tool with my app because it can be run as root user" and get SMJobBless API and run it's sample. It was successful
but now i have a question how i can add this route in routing table by this helper tool i mean if i use CreateAuthorization and use this command to run with this! it again prompt for root password which user already give at the time of installation of this app, which is very very annoying
as in this sample app
http://ideveloper.co/designing-writing-and-deploying-a-privileged-helper-on-mac-os-x/
now please tell me what i should do
The best place to look is the source code for Apple's pppd and route tools. Both should include code for adding routes.
http://www.opensource.apple.com/source/network_cmds/network_cmds-307.0.1