Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log(
`[GraphQL Accounts Error]: Message: ${message}, Location: ${locations}, Path: ${path}`
)
);
}
if (networkError) {
console.log(`[Network error]: ${networkError}`);
}
}),
new HttpLink({
uri: options.uri,
}),
]),
});
const client = new AccountsClient(
options,
new AccountsGraphQLClient({
graphQLClient: apollo,
})
);
let password;
if (require.resolve('@accounts/client-password')) {
const AccountsClientPassword = require('@accounts/client-password').AccountsClientPassword; // tslint:disable-line no-implicit-dependencies
password = new AccountsClientPassword(client, options.password);
}
return {
client,
apollo,
link: accountsLink(client),
import { InMemoryCache } from 'apollo-cache-inmemory';
// This auth link will inject the token in the headers on every request you make using apollo client
const authLink = accountsLink(() => accountsClient);
const httpLink = new HttpLink({
uri: 'http://localhost:4000/graphql',
});
const apolloClient = new ApolloClient({
link: from([authLink, httpLink]),
cache: new InMemoryCache(),
});
const accountsGraphQL = new GraphQLClient({ graphQLClient: apolloClient });
const accountsClient = new AccountsClient({}, accountsGraphQL);
const accountsPassword = new AccountsClientPassword(accountsClient);
export { accountsClient, accountsGraphQL, accountsPassword, apolloClient };
import { CookieStorage } from 'cookie-storage';
import fetch from 'isomorphic-fetch';
const cookieStorage = new CookieStorage();
const link = new HttpLink({
uri: 'http://localhost:4000/graphql',
fetch,
});
const cache = new InMemoryCache();
const apolloClient = new ApolloClient({
link,
cache,
});
const accountsGraphQL = new GraphQLClient({ graphQLClient: apolloClient });
const accountsClient = new AccountsClient(
{
// We tell the accounts-js client to use cookieStorage to store the tokens
tokenStorage: cookieStorage,
},
accountsGraphQL
);
const accountsPassword = new AccountsClientPassword(accountsClient);
export { accountsClient, accountsGraphQL, accountsPassword, apolloClient };
);
const { schema, context } = AccountsModule.forRoot({
accountsServer: this.accountsServer,
});
this.apolloServer = new ApolloServer({
schema,
context,
});
const apolloClient = new ApolloClient({ uri: `http://localhost:${this.port}` });
const accountsClientGraphQL = new AccountsGraphQLClient({
graphQLClient: apolloClient,
});
this.accountsClient = new AccountsClient({}, accountsClientGraphQL);
this.accountsClientPassword = new AccountsClientPassword(this.accountsClient);
this.emails = [];
}
}
);
/**
* Setup express
*/
this.app = express();
this.app.use(bodyParser.json());
this.app.use(bodyParser.urlencoded({ extended: true }));
this.app.use(accountsExpress(this.accountsServer));
const accountsRest = new RestClient({
apiHost: `http://localhost:${this.port}`,
rootPath: '/accounts',
});
this.accountsClient = new AccountsClient({}, accountsRest);
this.accountsClientPassword = new AccountsClientPassword(this.accountsClient);
this.emails = [];
}
import { AccountsClient } from '@accounts/client';
import { AccountsClientPassword } from '@accounts/client-password';
import { RestClient } from '@accounts/rest-client';
const accountsRest = new RestClient({
apiHost: process.env.REACT_APP_API_URL!,
rootPath: '/accounts',
});
const accountsClient = new AccountsClient({}, accountsRest);
const accountsPassword = new AccountsClientPassword(accountsClient);
export { accountsClient, accountsRest, accountsPassword };
constructor(apolloClient, accountsClientOptions) {
const accountsGraphQL = new GraphQLClient({ graphQLClient: apolloClient })
const accountsClient = new AccountsClient(
accountsClientOptions,
accountsGraphQL
)
const accountsPassword = new AccountsClientPassword(accountsClient)
this.accountsGraphQL = accountsGraphQL
this.accountsClient = accountsClient
this.accountsPassword = accountsPassword
this.createUser = accountsPassword.createUser.bind(accountsPassword)
this.login = accountsPassword.login.bind(accountsPassword)
this.refreshSession = accountsClient.refreshSession.bind(accountsClient)
this.logout = accountsClient.logout.bind(accountsClient)
this.getUser = accountsGraphQL.getUser.bind(accountsGraphQL)
const withToken = setContext(() => {
return {
headers: {
'x-prime-token': localStorage.getItem('accounts:accessToken'),
},
};
});
const client = new ApolloClient({
link: concat(withToken, httpLink),
cache: new InMemoryCache(),
});
const accountsGraphQL = new GraphQLClient({ graphQLClient: client });
const accountsClient = new AccountsClient({}, accountsGraphQL);
const accountsPassword = new AccountsClientPassword(accountsClient);
export { accountsClient, accountsGraphQL, accountsPassword };
import { GraphQLClient } from '@accounts/graphql-client';
import { AccountsClient, config } from '@accounts/client';
import { userFieldsFragment } from '../../graphql/queries/user.fragment';
import { getApolloClient } from '../../graphql/client/apollo-client';
import { store } from '../common/store';
const client = getApolloClient();
const graphQLInterface = new GraphQLClient({
graphQLClient: client,
userFieldsFragment,
});
const accountsClient = new AccountsClient({
tokenStorage: localStorage,
reduxStoreKey: 'accounts',
store,
onSignedOutHook: () => null,
onEnrollAccountHook: () => null,
onResetPasswordHook: () => null,
onVerifyEmailHook: () => null,
onSignedInHook: () => null,
}, graphQLInterface);
export function getAccountsClient() {
return accountsClient;
}