Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(SSR): withSSRContext #6146

Merged
merged 112 commits into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
b6e2d72
Add jest config to aws-amplify
ericclemmons Apr 15, 2020
1158231
Add exports-test.ts
ericclemmons Apr 15, 2020
a07e0ac
aws-amplify has named export DataStore
ericclemmons Apr 15, 2020
7dd9dde
Move __tests__ so build script ignores them
ericclemmons Apr 15, 2020
aaa31f5
Add Predicates from DataStore
ericclemmons Apr 15, 2020
9ce2624
Mark datastore as having sideEffects (initSchema)
ericclemmons Apr 16, 2020
a733a4e
Node is always "online"
ericclemmons Apr 16, 2020
b1e41c8
getDefaultAdapter uses fake-indexeddb for Node
ericclemmons Apr 16, 2020
fea8126
Node support for WebSocket (via isomorphic-ws)
ericclemmons Apr 17, 2020
8dd5fe2
Warn when schema has been initialized rather than throw
ericclemmons Apr 17, 2020
0baf796
Add model.fromJSON([] | {}) for creating existing instances from JSON
ericclemmons Apr 17, 2020
10a8141
Revert "Mark datastore as having sideEffects (initSchema)"
ericclemmons Apr 17, 2020
4733b5c
Remove `isomorphic-ws` from Predictions until formally supported & te…
ericclemmons Apr 17, 2020
644a5f1
Use modelInstanceCreator for fromJSON
ericclemmons Apr 17, 2020
a267d05
Add DataStore.toJSON()
ericclemmons Apr 17, 2020
280e685
Merge branch 'master' of github.com:aws-amplify/amplify-js into next-…
ericclemmons Apr 20, 2020
8636462
Use isomorphic-unfetch to support SSR fetch for Cognito
ericclemmons May 7, 2020
f8d0d94
Add UniversalStorage to @aws-amplify/core + aws-amplify
ericclemmons May 19, 2020
1b2d2a0
Merge branch 'master' into next-auth
ericclemmons May 19, 2020
6f92a34
Simplify with Observerable.from
ericclemmons May 20, 2020
c9e1c25
Add @types/next so UniversalStorage can compile
ericclemmons May 22, 2020
edba55b
Merge branch 'master' of github.com:ericclemmons/amplify-js into next…
ericclemmons Jun 15, 2020
8083938
Merge branch 'master' of github.com:aws-amplify/amplify-js into next-…
ericclemmons Jun 15, 2020
b476969
Merge branch 'master' of github.com:aws-amplify/amplify-js into next-…
ericclemmons Jun 16, 2020
fb25ade
Fix TypeScript error with Observable.from({ online: true })
ericclemmons Jun 16, 2020
bf5d5d5
DataStore awaits SYNC_ENGINE_SYNC_QUERIES_READY when in Node
ericclemmons Jun 16, 2020
a34bd42
Correct `Observable.from` usage in 6f92a34
ericclemmons Jun 16, 2020
eca5e86
Merge branch 'next-auth' into next-amplify
ericclemmons Jun 22, 2020
dc048de
Merge branch 'next-datastore' into next-amplify
ericclemmons Jun 22, 2020
2ce91b9
build:watch runs build:cjs:watch and build:esm:watch
ericclemmons Jun 23, 2020
96d7845
Collapse redundant import/export
ericclemmons Jun 23, 2020
8bd59e6
Initial withServerContext helper for Auth & DataStore
ericclemmons Jun 23, 2020
8f431f9
Use an in-memory instance of AsyncStorage rather than a singleton
ericclemmons Jun 24, 2020
864f7b8
Move DataStore class methods into the class declaration
ericclemmons Jun 24, 2020
a4c6cc6
Rename datastore to DataStore
ericclemmons Jun 24, 2020
952bedf
Move all of datastore.ts into separate utility files
ericclemmons Jun 24, 2020
87a332d
Revert "Move all of datastore.ts into separate utility files"
ericclemmons Jun 25, 2020
c56bd06
Revert "Rename datastore to DataStore"
ericclemmons Jun 25, 2020
63107ed
Merge branch 'main' of github.com:aws-amplify/amplify-js into next-am…
ericclemmons Jun 25, 2020
8e4785c
Scope `storage` to the `DataStore` instance
ericclemmons Jun 25, 2020
af53902
Each instance of DataStore gets initialized separately
ericclemmons Jun 25, 2020
13f01e2
Convert Amplify to an instance instead of a singleton
ericclemmons Jul 1, 2020
b805139
withServerContext extends Amplify's config with new instances
ericclemmons Jul 1, 2020
dfff4e5
UniversalStorage accepts context in the constructor
ericclemmons Jul 1, 2020
167c787
Register category to Amplify on import, not instantiation
ericclemmons Jul 1, 2020
d896644
API (+ GraphQL/REST) can have Credentials injected
ericclemmons Jul 1, 2020
d499bc8
Only export withServerContext, not UniversalStorage
ericclemmons Jul 1, 2020
a579c9b
Restrict cookies to httpOnly, sameSite, and secure outside of production
ericclemmons Jul 1, 2020
b9a767d
Auth uses this.Credentials
ericclemmons Jul 1, 2020
9bb784e
Fix reference to CredentialsClass
ericclemmons Jul 1, 2020
fbfa4ae
Cookies cannot be httpOnly from JavaScript
ericclemmons Jul 1, 2020
27ae726
Move global variables into DataStore instance
ericclemmons Jul 1, 2020
19d0393
Ignore max-line-length for comments
ericclemmons Jul 1, 2020
8def8f4
Combine imports
ericclemmons Jul 1, 2020
4d29a12
Merge github.com:aws-amplify/amplify-js into next-amplify
ericclemmons Jul 1, 2020
9a9342b
Fix test title
ericclemmons Jul 2, 2020
39f57e4
Remove unused export
ericclemmons Jul 2, 2020
875c10a
Rename withServerContext to withSSRContext
ericclemmons Jul 6, 2020
123e90c
Publish next-amplify branch to @preview
ericclemmons Jul 7, 2020
ec15663
Merge github.com:aws-amplify/amplify-js into next-amplify
ericclemmons Jul 7, 2020
c77c0e2
Revert "Publish next-amplify branch to @preview"
ericclemmons Jul 7, 2020
48efc32
Merge branch 'main' of github.com:aws-amplify/amplify-js into next-am…
ericclemmons Aug 18, 2020
fc140e0
Add @types/cookie and @types/express to dev build with nookies
ericclemmons Aug 19, 2020
0d70618
Merge branch 'main' into next-amplify
sammartinez Aug 19, 2020
1cb7ca1
Convert this.Credentials to this.amplify
ericclemmons Aug 19, 2020
e1de0e5
Add TODO for DataStore's subscription being SSR-aware
ericclemmons Aug 19, 2020
60b84d3
Merge branch 'next-amplify' of github.com:ericclemmons/amplify-js int…
ericclemmons Aug 19, 2020
bf3c38a
Remove unnecessary export of AuthClass
ericclemmons Aug 19, 2020
3da1663
Add build:esm and build:cjs to be build:watch compatible
ericclemmons Aug 21, 2020
d0c7d58
Add build:esm:watch for the root build:watch command
ericclemmons Aug 21, 2020
c4d0535
Remove unused import
ericclemmons Aug 21, 2020
c8156b4
Correct bidirectional reference to amplify before configuring
ericclemmons Aug 21, 2020
13282f5
API recreates RestAPI & GraphQLAPI references when configured
ericclemmons Aug 21, 2020
1ea7e71
withSSRContext overrides storage for Amplify in the browser
ericclemmons Aug 21, 2020
6861ead
Merge branch 'main' of github.com:aws-amplify/amplify-js into next-am…
ericclemmons Aug 25, 2020
3151357
Move DataStore.toJSON to serializeModel helper
ericclemmons Aug 25, 2020
43bf3ea
withSSRContext exports deserializeModel & serializeModel
ericclemmons Aug 25, 2020
fd68da2
Merge branch 'main' into next-amplify
iartemiev Aug 26, 2020
9b0ecdd
Merge branch 'main' into next-amplify
sammartinez Aug 26, 2020
1e6ed37
Convert spaces back to tabs
ericclemmons Aug 27, 2020
8aa0290
deserializeModel accepts Model, not model
ericclemmons Aug 27, 2020
20a1191
Merge branch 'next-amplify' of github.com:ericclemmons/amplify-js int…
ericclemmons Aug 27, 2020
3da5f46
Validate Model.fromJSON
ericclemmons Aug 27, 2020
84a3fab
UniversalStorage defaults path to "/"
ericclemmons Sep 1, 2020
75490f2
Secure cookies when not on localhost
ericclemmons Sep 1, 2020
e96f3b5
Amplify.configure({ ssr: true }) defaults to UniversalStorage
ericclemmons Sep 1, 2020
17888e0
Modules rely on instance properties for dependencies (e.g. this.Auth)
ericclemmons Sep 1, 2020
39f03ee
Amplify injects modules into other modules that accept them
ericclemmons Sep 1, 2020
af0167b
withSSRContext explicitly supports only API, Auth, Credentials, DataS…
ericclemmons Sep 1, 2020
abedee1
Merge branch 'main' into next-amplify
sammartinez Sep 1, 2020
06c3b12
Merge branch 'main' of github.com:aws-amplify/amplify-js into next-am…
ericclemmons Sep 1, 2020
8b6db08
Merge branch 'next-amplify' of github.com:ericclemmons/amplify-js int…
ericclemmons Sep 1, 2020
1e467e7
Default context for client-side usage
ericclemmons Sep 1, 2020
4582562
Add @aws-amplify/auth|core to devDependencies for lerna topo-sorting
ericclemmons Sep 1, 2020
53a3355
Merge branch 'main' into next-amplify
ericclemmons Sep 1, 2020
0ba9e3a
Move serializeModel/deserializeModel to @aws-amplify/datastore/ssr
ericclemmons Sep 1, 2020
c365524
Merge branch 'next-amplify' of github.com:ericclemmons/amplify-js int…
ericclemmons Sep 1, 2020
96fc69b
Revert changes to _components. Track modules in _modules instead.
ericclemmons Sep 1, 2020
fd830eb
Update Amplify.register test to validate registration happens once
ericclemmons Sep 1, 2020
80bf422
Fix tslint max-line-length error (not ignoring comments)
ericclemmons Sep 1, 2020
a8c0e49
Fix tslint "unnecessary semi-colon error"
ericclemmons Sep 1, 2020
e3baf30
withSSRContext isn't called on the server anymore
ericclemmons Sep 1, 2020
cf51392
Update withSSRContext-test with latest behavior
ericclemmons Sep 1, 2020
bf11192
DataStore no longer throws for previously initialized schema, but warns
ericclemmons Sep 1, 2020
75d4cf4
Use browserOrNode instead of JS
ericclemmons Sep 1, 2020
08c17d4
Revert to main and add InMemoryStore(.native).ts
ericclemmons Sep 2, 2020
2bb6c86
Replace `npm run` with `yarn` because it handles workspaces better
ericclemmons Sep 2, 2020
4b65b77
Explicitly set file paths (because rollup bin can't find it)
ericclemmons Sep 2, 2020
83cf9cc
Revert "Replace `npm run` with `yarn` because it handles workspaces b…
ericclemmons Sep 2, 2020
5135af4
Remove unused import
ericclemmons Sep 2, 2020
7975c74
Revert "Explicitly set file paths (because rollup bin can't find it)"
ericclemmons Sep 2, 2020
4ef5503
Replace nookies with universal-cookie to fix ui-angular build
ericclemmons Sep 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"coverage": "codecov || exit 0",
"docs": "typedoc packages/**/src --name amplify-js --hideGenerator --excludePrivate --ignoreCompilerErrors --mode file --out docs/api --theme docs/amplify-theme/typedoc/ --readme README.md",
"build": "lerna run build --stream",
"build:watch": "concurrently 'lerna run build:cjs:watch --parallel' 'lerna run build:esm:watch --parallel' --raw",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a crapshoot whether CRA/Next/whatever wants the ESM or CJS build when yarn linking. This ensures we build both 🤷

"build:esm:watch": "lerna run build:esm:watch --parallel",
"build:cjs:watch": "lerna run build:cjs:watch --parallel",
"clean": "lerna run clean --parallel",
Expand Down
1 change: 1 addition & 0 deletions packages/amazon-cognito-identity-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"dependencies": {
"buffer": "4.9.1",
"crypto-js": "^3.3.0",
"isomorphic-unfetch": "^3.0.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Necessary on the server due to usage of fetch:

request(operation, params, callback) {
const headers = {
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': `AWSCognitoIdentityProviderService.${operation}`,
'X-Amz-User-Agent': UserAgent.prototype.userAgent,
};
const options = Object.assign({}, this.fetchOptions, {
headers,
method: 'POST',
mode: 'cors',
cache: 'no-cache',
body: JSON.stringify(params),
});
let response;
let responseJsonData;
fetch(this.endpoint, options)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im good with this @elorzafe what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll be doing build comparisons to determine if there are any bundle size concerns.

By design, this package is a polyfill that falls back to window.fetch on the browser.

"js-cookie": "^2.1.4"
},
"devDependencies": {
Expand Down
2 changes: 2 additions & 0 deletions packages/amazon-cognito-identity-js/src/Client.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'isomorphic-unfetch';

import UserAgent from './UserAgent';

class CognitoError extends Error {
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics/src/Analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export class AnalyticsClass {
Hub.listen('auth', listener);
Hub.listen('storage', listener);
Hub.listen('analytics', listener);
Amplify.register(this);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is moved outside of the constructor because we want there to be a single instance of Analytics registered with the global Amplify.

New instances of Analytics on the server shouldn't override the first one.

}

public getModuleName() {
Expand Down Expand Up @@ -402,3 +401,4 @@ const sendEvents = () => {
};

export const Analytics = new AnalyticsClass();
Amplify.register(Analytics);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue of having it inside of the constructor is for multiple Analytics instances?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elorzafe That's correct!

Otherwise, ever instance will get pushed onto Amplify._components and leak memory.

12 changes: 9 additions & 3 deletions packages/api-graphql/src/GraphQLAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ export class GraphQLAPIClass {
private _options;
private _api = null;

Credentials = Credentials;

ericclemmons marked this conversation as resolved.
Show resolved Hide resolved
/**
* Initialize GraphQL API with AWS configuration
* @param {Object} options - Configuration object for API
*/
constructor(options) {
this._options = options;
Amplify.register(this);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, new instances should be registered to the global Amplify, only the exported singleton.

logger.debug('API Options', this._options);
}

Expand All @@ -70,6 +71,10 @@ export class GraphQLAPIClass {
let opt = { ...otherOptions, ...API };
logger.debug('configure GraphQL API', { opt });

if (opt['Credentials']) {
this.Credentials = opt['Credentials'];
}

if (opt['aws_project_region']) {
opt = Object.assign({}, opt, {
region: opt['aws_project_region'],
Expand Down Expand Up @@ -355,10 +360,10 @@ export class GraphQLAPIClass {
* @private
*/
_ensureCredentials() {
return Credentials.get()
return this.Credentials.get()
.then(credentials => {
if (!credentials) return false;
const cred = Credentials.shear(credentials);
const cred = this.Credentials.shear(credentials);
logger.debug('set credentials for api', cred);

return true;
Expand All @@ -371,3 +376,4 @@ export class GraphQLAPIClass {
}

export const GraphQLAPI = new GraphQLAPIClass(null);
Amplify.register(GraphQLAPI);
6 changes: 5 additions & 1 deletion packages/api-rest/src/RestAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class RestAPIClass {
*/
constructor(options) {
this._options = options;
Amplify.register(this);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, new instances should be registered to the global Amplify, only the exported singleton.

logger.debug('API Options', this._options);
}

Expand All @@ -49,6 +48,10 @@ export class RestAPIClass {
let opt = { ...otherOptions, ...API };
logger.debug('configure Rest API', { opt });

if (opt['Credentials']) {
this._api.Credentials = opt['Credentials'];
}

if (opt['aws_project_region']) {
if (opt['aws_cloud_logic_custom']) {
const custom = opt['aws_cloud_logic_custom'];
Expand Down Expand Up @@ -245,3 +248,4 @@ export class RestAPIClass {
}

export const RestAPI = new RestAPIClass(null);
Amplify.register(RestAPI);
11 changes: 9 additions & 2 deletions packages/api-rest/src/RestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import {
ConsoleLogger as Logger,
CredentialsClass,
DateUtils,
Signer,
Platform,
Expand Down Expand Up @@ -60,15 +61,21 @@ export class RestClient {
*/
private _cancelTokenMap: WeakMap<any, CancelTokenSource> = null;

Credentials = Credentials;

/**
* @param {RestClientOptions} [options] - Instance options
*/
constructor(options: apiOptions) {
constructor(options: apiOptions & { Credentials?: CredentialsClass }) {
this._options = options;
logger.debug('API Options', this._options);
if (this._cancelTokenMap == null) {
this._cancelTokenMap = new WeakMap();
}

if (options.Credentials) {
this.Credentials = options.Credentials;
}
}

/**
Expand Down Expand Up @@ -168,7 +175,7 @@ export class RestClient {
}

// Signing the request in case there credentials are available
return Credentials.get().then(
return this.Credentials.get().then(
credentials => {
return this._signed({ ...params }, credentials, isAllResponse).catch(
error => {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export class APIClass {
this._options = options;
this._restApi = new RestAPIClass(options);
this._graphqlApi = new GraphQLAPIClass(options);
Amplify.register(this);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, new instances should be registered to the global Amplify, only the exported singleton.

logger.debug('API Options', this._options);
}

Expand Down Expand Up @@ -179,3 +178,4 @@ export class APIClass {
}

export const API = new APIClass(null);
Amplify.register(API);
45 changes: 26 additions & 19 deletions packages/auth/src/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export class AuthClass {
private _storageSync;
private oAuthFlowInProgress: boolean = false;

Credentials = Credentials;

/**
* Initialize Auth with AWS configurations
* @param {Object} config - Configuration of the Auth
Expand All @@ -122,7 +124,6 @@ export class AuthClass {
break;
}
});
Amplify.register(this);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, new instances should be registered to the global Amplify, only the exported singleton.

}

public getModuleName() {
Expand Down Expand Up @@ -181,7 +182,7 @@ export class AuthClass {
this.userPool = new CognitoUserPool(userPoolData);
}

Credentials.configure({
this.Credentials.configure({
mandatorySignIn,
region: identityPoolRegion || region,
userPoolId,
Expand Down Expand Up @@ -480,8 +481,8 @@ export class AuthClass {
delete user['challengeName'];
delete user['challengeParam'];
try {
await Credentials.clear();
const cred = await Credentials.set(session, 'session');
await this.Credentials.clear();
const cred = await this.Credentials.set(session, 'session');
logger.debug('succeed to get cognito credentials', cred);
} catch (e) {
logger.debug('cannot get cognito credentials', e);
Expand Down Expand Up @@ -701,7 +702,9 @@ export class AuthClass {
user: CognitoUser | any,
mfaMethod: 'TOTP' | 'SMS' | 'NOMFA'
): Promise<string> {
const userData = await this._getUserData(user, { bypassCache: true });
const userData = await this._getUserData(user, {
bypassCache: true,
});
let smsMfaSettings = null;
let totpMfaSettings = null;

Expand Down Expand Up @@ -903,8 +906,8 @@ export class AuthClass {
onSuccess: async session => {
logger.debug(session);
try {
await Credentials.clear();
const cred = await Credentials.set(session, 'session');
await this.Credentials.clear();
const cred = await this.Credentials.set(session, 'session');
logger.debug('succeed to get cognito credentials', cred);
} catch (e) {
logger.debug('cannot get cognito credentials', e);
Expand Down Expand Up @@ -945,8 +948,8 @@ export class AuthClass {
onSuccess: async session => {
logger.debug(session);
try {
await Credentials.clear();
const cred = await Credentials.set(session, 'session');
await this.Credentials.clear();
const cred = await this.Credentials.set(session, 'session');
logger.debug('succeed to get cognito credentials', cred);
} catch (e) {
logger.debug('cannot get cognito credentials', e);
Expand Down Expand Up @@ -1356,23 +1359,23 @@ export class AuthClass {

if (federatedInfo) {
// refresh the jwt token here if necessary
return Credentials.refreshFederatedToken(federatedInfo);
return this.Credentials.refreshFederatedToken(federatedInfo);
} else {
return this.currentSession()
.then(session => {
logger.debug('getting session success', session);
return Credentials.set(session, 'session');
return this.Credentials.set(session, 'session');
})
.catch(error => {
logger.debug('getting session failed', error);
return Credentials.set(null, 'guest');
return this.Credentials.set(null, 'guest');
});
}
}

public currentCredentials(): Promise<ICredentials> {
logger.debug('getting current credentials');
return Credentials.get();
return this.Credentials.get();
}

/**
Expand Down Expand Up @@ -1539,7 +1542,7 @@ export class AuthClass {

private async cleanCachedItems() {
// clear cognito cached item
await Credentials.clear();
await this.Credentials.clear();
}

/**
Expand Down Expand Up @@ -1685,7 +1688,7 @@ export class AuthClass {
* @return {Object }- current User's information
*/
public async currentUserInfo() {
const source = Credentials.getCredSource();
const source = this.Credentials.getCredSource();

if (!source || source === 'aws' || source === 'userPool') {
const user = await this.currentUserPoolUser().catch(err =>
Expand Down Expand Up @@ -1808,9 +1811,9 @@ export class AuthClass {
} catch (e) {}

const { token, identity_id, expires_at } = response;
// Because Credentials.set would update the user info with identity id
// Because this.Credentials.set would update the user info with identity id
// So we need to retrieve the user again.
const credentials = await Credentials.set(
const credentials = await this.Credentials.set(
{ provider, token, identity_id, user, expires_at },
'federation'
);
Expand Down Expand Up @@ -1877,13 +1880,15 @@ export class AuthClass {
RefreshToken: new CognitoRefreshToken({
RefreshToken: refreshToken,
}),
AccessToken: new CognitoAccessToken({ AccessToken: accessToken }),
AccessToken: new CognitoAccessToken({
AccessToken: accessToken,
}),
});

let credentials;
// Get AWS Credentials & store if Identity Pool is defined
if (this._config.identityPoolId) {
credentials = await Credentials.set(session, 'session');
credentials = await this.Credentials.set(session, 'session');
logger.debug('AWS credentials', credentials);
}

Expand Down Expand Up @@ -2044,3 +2049,5 @@ export class AuthClass {
}

export const Auth = new AuthClass(null);

Amplify.register(Auth);
21 changes: 14 additions & 7 deletions packages/auth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@
* and limitations under the License.
*/

import { Auth, CognitoHostedUIIdentityProvider } from './Auth';
import { CognitoUser, CookieStorage, appendToCognitoUserAgent } from 'amazon-cognito-identity-js';
export {
CognitoUser,
CookieStorage,
appendToCognitoUserAgent,
} from 'amazon-cognito-identity-js';

/**
* @deprecated use named import
*/
export default Auth;
export { Auth, CognitoUser, CookieStorage, CognitoHostedUIIdentityProvider, appendToCognitoUserAgent };
export {
/**
* @deprecated use named import
*/
Auth as default,
Auth,
AuthClass,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Por que?

CognitoHostedUIIdentityProvider,
} from './Auth';
1 change: 1 addition & 0 deletions packages/aws-amplify/__tests__/exports-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ describe('aws-amplify', () => {
"Signer",
"I18n",
"ServiceWorker",
"withSSRContext",
"default",
]
`);
Expand Down
Loading