Skip to content

Instantly share code, notes, and snippets.

@skiph
skiph / modified config.js
Created May 4, 2017
API Proxy Key - modified for approov
View modified config.js
module.exports = {
proxy_port: /* port the proxy listens on */
8080,
nasa_host: /* NASA API host */
'api.nasa.gov',
nasa_protocol: /* NASA API protocol */
'https:',
approov_header: /* Approov header name */
'approov',
approov_enforcement: /* set true to enforce token checks */
@skiph
skiph / enhanced nasa.js
Created May 4, 2017
API Key Proxy - enhanced API processing
View enhanced nasa.js
const path = require('path');
const url = require('url');
const request = require('request');
const chalk = require('chalk');
// load api configuration and secrets
const config = require(`${__dirname}/../config.js`);
if (config.nasa_host == null) {
View sample secret.gradle
ext {
// google credentials
apiKey = "GOOGLE_API_KEY"
clientId = "GOOGLE_CLIENT_ID"
// google authorization adapter service
View sample secrets.js
module.exports = {
approov_token_secret: /* token secret received from Approov demo download */
'APPROOV DEMO TOKEN SECRET BASE64 STRING HERE',
google_client_secret: /* client secret received from Google */
'GOOGLE CLIENT SECRET HERE'
};
@skiph
skiph / App.js
Last active Apr 27, 2018
RNDemo - Say Hello
View App.js
import React from 'react';
import { View, Image, Text, Button, StyleSheet } from 'react-native';
import ShapeView from './ShapeView'
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {shape: 'logo',
status: ''};
}
@skiph
skiph / ShapeView.js
Created Apr 27, 2018
RNDemo - shapes component
View ShapeView.js
import React from "react";
import { View, Image, Text, StyleSheet } from "react-native";
const shapeView = (props) => {
const imgSrc = {
'logo': require('./assets/approov_largelogo.png'),
'hello': require('./assets/hello.png'),
'confused': require('./assets/confused.png'),
'Rectangle': require('./assets/rectangle.png'),
'Square': require('./assets/square.png'),
@skiph
skiph / ApproovModule.java
Last active Apr 27, 2018
RNDemo - Approov native module
View ApproovModule.java
package com.criticalblue.approov;
import ...
import com.criticalblue.attestationlibrary.ApproovAttestation;
import com.criticalblue.attestationlibrary.ApproovConfig;
import com.criticalblue.attestationlibrary.TokenInterface;
class ApproovModule extends ReactContextBaseJavaModule {
@skiph
skiph / ApproovPackage.java
Last active May 2, 2018
RNDemo - Approov Package
View ApproovPackage.java
package com.criticalblue.approov;
import ...
public class ApproovPackage implements ReactPackage {
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
@skiph
skiph / MainApplication.java
Last active Apr 27, 2018
RNDemo - Main Application.java
View MainApplication.java
package com.rndemo;
import ...
import com.criticalblue.approov.ApproovPackage;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
@skiph
skiph / Approov.js
Last active May 2, 2018
RNDemo - Approov module wrapper
View Approov.js
import {NativeModules} from 'react-native';
const fetchWithToken = (input, options) => {
return NativeModules.Approov.fetchApproovToken(input)
.then(token => {
let optionsA = (options? {...options, headers:{ ...options.headers}}:{headers: {}});
optionsA.headers['Approov-Token'] = token;
return fetch(input, optionsA)
.then((response) => {