Invalid value for transfer while using ipcRenderer.postMessage of electron?I don't know what's wrong with it
// eslint-disable-next-line no-undef
const { port1 } = new MessageChannel();
// eslint-disable-next-line no-undef
ipcRenderer.postMessage('port', { message: 'hello' }, [port1]);
I wonder if something wrong in my preload.js?
I upload all my code to github
https://github.com/codeh2o/electronVuePreloadIssue
I am integrating the apple pay and following the payment request API!
According to the documentation
(https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/requesting_an_apple_pay_payment_session)
cert: merchIdentityCert and key: merchIdentityCert both are the same. I append my merchantIdentityCertificate.pem to both cert and key.
But, Unable to get any response from the apple pay servers. After my request it is throwing an error and safari is displaying a message as “This resource came from a local override”
Code:
const merchIdentityCert = fs.readFileSync("./merchIdentityCert.pem")
const httpsAgent = new https.Agent({
cert: merchIdentityCert,
key: merchIdentityCert,
maxVersion: "TLSv1.2",
minVersion: "TLSv1.2"
})
const post = (url, body) => {
logger.info({ message: "apple pay START", url, body })
fetch(url, {
body: JSON.stringify(body),
method: "POST",
agent: httpsAgent
}).then(resp => {
logger.info({ message: "apple pay SUCCESS", resp })
return resp
}).catch((error) => {
logger.info({ message: "apple pay ERROR", error })
return error
})
}
Logs:
message: "apple pay START", url:
"https://-pay-gateway-cert.apple.com/paymentservices/startSession", body: {"merchantIdentifier":"..","displayName":"Test
Pay","initiative":"web","initiativeContext":"--**.***."}
message: "apple pay ERROR", error: {}*
I am using a node-fetch library. My web app and node app deployed in AWS servers. I have fulfilled server setup and environment setup requirements with certificates.
[https://developer.apple.com/documentation/apple_pay_on_the_web/setting_up_your_server]
Does anyone have an idea about this?
There was an issue with the private key of my merchIdentityCert and I fixed it. After installing the .cer file, expand it from the Keychain Access, and export 2 items as .p12 and convert it to .pem using OpenSSL. Now, I have a PEM file that contains both assets. Then I continued my process and didn’t get the below error in this time which I mentioned in the above post.
message: "apple pay ERROR", error: {}
But, After the request, I am getting below log,
message: "apple pay SUCCESS", resp: {"size":0,"timeout":0}
As well, In the Inspect Element → Network → (click on my request) → Preview
Top of the response Preview, It is displaying a message as “Reveal | This resource came from a local override”
Does anyone have an idea?
I am getting {"size":0,"timeout":0} from apple pay servers
Able to resolve the {"size":0,"timeout":0} issue and it is related to node fetch library. I fixed it from my code level.
(Node-fetch problems with POST requests, https://www.npmjs.com/package/node-fetch)
Apart from that, I used the below request to debug using the remote server, and It was giving the session object to me.
curl -XPOST -H "Content-type: application/json" -d '{"merchantIdentifier":"merchant.***.xxxxx","displayName":"TestPay","initiative":"web","initiativeContext":"***-***-xxxxxx.xxxxxxxxxx.xx"}' --cert cert.pem:cert.pem 'https://apple-pay-gateway-cert.apple.com/paymentservices/startSession'
my code:
import fetch from "node-fetch"
import fs from "fs"
import { promiseReject } from "../utils/misc"
import { Logger } from "../services/Logger"
import https from "https"
const logger = new Logger("Apple Pay Client")
const checkStatusAndGetJSON = (fetchResponse) =>
fetchResponse.ok
? fetchResponse.json()
: fetchResponse.json().then(promiseReject)
const merchIdentityCert = fs.readFileSync("./merchIdentityCert.pem")
const httpsAgent = new https.Agent({
cert: merchIdentityCert,
key: merchIdentityCert,
maxVersion: "TLSv1.2",
minVersion: "TLSv1.2"
})
const basicHeaders = {
"Accept": "application/json",
"lang": "en",
"Content-Type": "application/json"
}
const post = (url, body) => {
const start = Date.now()
return fetch(url, {
body: JSON.stringify(body),
headers: basicHeaders,
method: "POST",
agent: httpsAgent
}).then(resp => {
const duration = Date.now() - start
logger.debug(`apple pay call took ${duration} millis.`, { endpoint: url, method: "POST", duration })
return resp
}).then(checkStatusAndGetJSON)
}
/** Apple Pay */
export const performValidation = (url, body) => post(url, body)
I am using react-native-firebase to work with our Firebase account for authentication, firestore and storage. Attempting to upload a photo to Storage is failing with an unknown error. Here is the code attempted:
_pickImage = async () => {
await this.getCameraRollPermission()
let result = await ImagePicker.launchImageLibraryAsync({
allowsEditing: true,
aspect: [4, 3],
});
console.log(result);
if (!result.cancelled) {
// this.setState({ photoURL: result.uri });
this._handlePhotoChoice(result)
}
};
_handlePhotoChoice = async pickerResult => {
let userId = this.state.userId
firebase
.storage()
.ref('photos/profile_' + userId + '.jpg')
.putFile(pickerResult.uri)
.then(uploadedFile => {
console.log("Firebase profile photo uploaded successfully")
})
.catch(error => {
console.log("Firebase profile upload failed: " + error)
})
}
Testing in iOS Simulator and using the debugger to detect the errors I'm just getting back this error:
"Error: An unknown error has occurred.
at createErrorFromErrorData (blob:http://localhost:19001/e9d43477-4e42-4f7a-b494-16485def4c28:2371:17)
at blob:http://localhost:19001/e9d43477-4e42-4f7a-b494-16485def4c28:2323:27
at MessageQueue.__invokeCallback (blob:http://localhost:19001/e9d43477-4e42-4f7a-b494-16485def4c28:2765:18)
at blob:http://localhost:19001/e9d43477-4e42-4f7a-b494-16485def4c28:2510:18
at MessageQueue.__guardSafe (blob:http://localhost:19001/e9d43477-4e42-4f7a-b494-16485def4c28:2678:11)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (blob:http://localhost:19001/e9d43477-4e42-4f7a-b494-16485def4c28:2509:14)
at http://localhost:19001/debugger-ui/debuggerWorker.js:70:58"
UPDATE:
A file is uploaded to the storage bucket, but the file is not the JPEG photo, but instead is JSON content about the file:
{"contentType":"image\/jpeg","name":"photos\/profile_XPIO2lHjlYbdLPchACZHBsmY9Jr1.jpg"}
So somehow a JSON file is ending up in the bucket instead of the actual photo and then the error is thrown.
It looks like this issue is tracked a couple times, but not resolved:
https://github.com/invertase/react-native-firebase/issues/1177
https://github.com/invertase/react-native-firebase/issues/302
Finally found my issue. The URI of the image from the ImagePicker had a '%' character in it from the local app cache. This percent was being URI encoded to '%25' which resulted in the file not being found by the putFile code. Adding a decodeURI call around the uri fixed the issue.
let fileUri = decodeURI(pickerResult.uri)
In case you are using react-native-document-picker, check out this:
https://github.com/rnmods/react-native-document-picker/issues/235
The error I get when the user fails to log in is "Error: Request failed with status code 401". This error is logged here:
static login(username : string, password : string){
return new Promise(resolve =>{
let user = new CB.CloudUser();
user.set('username', username);
user.set('password', password);
user.logIn({
success: function(user) {
console.log("user");
resolve();
},
error: function(error) {
console.log(error);
resolve(error);
}
});
});
}
But what I need is the error that actually says what went wrong e.g. "invalid username" or "User is not authenticated".
How do I get these?
Error: Request failed with status code 401
This error generally means that the login request you made to the server was not authenticated/ you were not authorized to make the login request. This can mean that the CB instance is not properly initialized. Please check the appId and the master/client key you are using to initialize the CB instance.
I'm using node-apn to send push notifications to my device. Whenever I try, I get the following:
{ sent: [],
failed:
[ { device: '****',
status: '400',
response: [Object] } ] }
I'm fairly certain my device token is correct. Is there any way to find out more info about why this error occurs. Is there info in the "response"—if so how do I get it? It would be helpful to get one of the error strings listed here (https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html) like "BadCollapseId"
Here is my node.js code for reference.
var deviceToken = "***";
var notification = new apn.Notification();
notification.topic = '*****';
notification.alert = "HI DER";
notification.payload = {id: 3};
apnProvider.send(notification, deviceToken).then(function(result) {
console.log(result);
});
The app is built using ionic 2, but I don't think that would make a difference.
Thanks!
Basically all I needed was this line:
console.log(result.failed);
instead of
console.log(result);
This gave me the code "DeviceTokenNotForTopic" and I was able to go from there!