Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return Promise.resolve().then(function () {
return localStorage.getItem(key) || "anonymous";
});
}
};
export const custom_header = async () => {
try {
return { Authorization: (await Auth.currentSession()).getIdToken().getJwtToken() }
}
catch (e) {
console.warn(e, "Defaulting to stored JWT in localStorage...");
// Get JWT from SAML.
return { Authorization: await asyncLocalStorage.getItem("jwt") }
}
}
Auth.configure({
region: 'us-east-1',
userPoolId: COGNITO_USER_POOL_ID,
userPoolWebClientId: COGNITO_CLIENT_ID,
mandatorySignIn: false
});
API.configure({
endpoints: [
{
name: "treehacks",
endpoint: ENDPOINT_URL,
custom_header: custom_header
}
]
});
const authScreenLabels = {
renderSignOutButton() {
const { federated = {} } = this.props;
const {
google_client_id,
facebook_app_id,
amazon_client_id,
auth0,
} = federated;
// @ts-ignore
const config = Auth.configure();
const { oauth = {} } = config;
// @ts-ignore
const googleClientId = google_client_id || config.googleClientId;
// @ts-ignore
const facebookAppId = facebook_app_id || config.facebookClientId;
// @ts-ignore
const amazonClientId = amazon_client_id || config.amazonClientId;
// @ts-ignore
const auth0_config = auth0 || oauth.auth0;
let SignOutComponent = SignOut;
// @ts-ignore
if (googleClientId) SignOutComponent = withGoogle(SignOut);
// @ts-ignore
if (facebookAppId) SignOutComponent = withFacebook(SignOut);
// @ts-ignore
initialize() {
// @ts-ignore
const { oauth = {} } = Auth.configure();
// @ts-ignore
const config = this.props.auth0 || options || oauth.auth0;
const { onError, onStateChange, authState } = this.props;
if (!config) {
logger.debug('Auth0 is not configured');
return;
}
logger.debug('withAuth0 configuration', config);
if (!this._auth0) {
this._auth0 = new window['auth0'].WebAuth(config);
window.auth0_client = this._auth0;
}
if (authState !== 'signedIn') {
render() {
const { authState } = this.props;
if (!['signIn', 'signedOut', 'signedUp'].includes(authState)) {
return null;
}
const federated = this.props.federated || {};
if (!Auth || typeof Auth.configure !== 'function') {
throw new Error(
'No Auth module found, please ensure @aws-amplify/auth is imported'
);
}
// @ts-ignore
const { oauth = {} } = Auth.configure();
// backward compatibility
if (oauth['domain']) {
federated.oauth_config = Object.assign({}, federated.oauth_config, oauth);
// @ts-ignore
} else if (oauth.awsCognito) {
// @ts-ignore
federated.oauth_config = Object.assign(
{},
federated.oauth_config,
// @ts-ignore
oauth.awsCognito
);
}
// @ts-ignore
if (oauth.auth0) {
export default config => {
// Configure Amplify Auth
Auth.configure(config);
return {
name: "security-authentication-provider-cognito",
type: "security-authentication-provider",
securityProviderHook({ onIdToken }) {
const renderAuthentication = () => {
return ;
};
const logout = async () => {
await Auth.signOut();
};
const getIdToken = async () => {
const cognitoUser = await Auth.currentSession();
return cognitoUser ? cognitoUser.idToken.jwtToken : null;
import Auth from '@aws-amplify/auth';
import Amplify from 'aws-amplify';
import awsconfig from './aws-exports';
import aws_exports from './aws-exports';
import { XR as AwsXR } from 'aws-amplify';
import scene1Config from './sumerian-exports';
Amplify.configure(aws_exports);
Auth.configure(awsconfig);
AwsXR.configure({
SumerianProvider: {
region: 'us-west-2', // Sumerian region
scenes: {
"scene1": { // Friendly scene name
sceneConfig: scene1Config // Scene configuration from Sumerian publish
}
},
}
});
let xrready = false
const isXrReady = () => {
return xrready
import React from 'react';
import { Platform, StatusBar, StyleSheet, View } from 'react-native';
import { AppLoading, Asset, Font, Icon } from 'expo';
import AppNavigator from './navigation/AppNavigator';
import Auth from '@aws-amplify/auth';
import awsconfig from './aws-exports';
import { withAuthenticator } from 'aws-amplify-react-native';
import { ActionSheetProvider,connectActionSheet} from '@expo/react-native-action-sheet';
Auth.configure(awsconfig);
class App extends React.Component {
state = {
isLoadingComplete: false,
};
render() {
if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
return (
);
} else {
import { Component, State, h } from '@stencil/core';
import { AuthenticatorExample } from './authenticator-example';
import example4 from './example4';
import sceneExample from './scene-example';
import Auth from '@aws-amplify/auth';
import XR from '@aws-amplify/xr';
import awsexports from './src/aws-exports';
Auth.configure(awsexports);
XR.configure(awsexports);
const examples = [AuthenticatorExample, example4, sceneExample];
(window as any).LOG_LEVEL = 'DEBUG';
const Tabs = ({ active, set }) => (
<ul>
{examples.map(({ title }, index) => (
<li class="{active">
<a> set(index)} href="javascript:void(0);">
{title}
</a>
</li>
))}
</ul>
import { h } from '@stencil/core';
import Auth from '@aws-amplify/auth';
import XR from '@aws-amplify/xr';
import awsexports from './src/aws-exports';
Auth.configure(awsexports);
XR.configure(awsexports);
const sceneExample = () => ;
export default {
title: 'Scene example',
Content: sceneExample,
};