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: pipe auth user agent details through to service call #11755

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
cfe55be
chore: copy Auth code to InternalAuth
erinleigh90 Jul 7, 2023
9ba4d67
feat: add customUserAgentDetails param to InternalAuth methods
erinleigh90 Jul 10, 2023
3c0eb2b
feat: make AuthClass extend InternalAuthClass, override functions wit…
erinleigh90 Jul 10, 2023
8eac22a
build: export auth internals from /internals scope
erinleigh90 Jul 10, 2023
8d3f5d5
fix: changes signUp back to method type instead of prop so Auth can e…
erinleigh90 Jul 10, 2023
d33fc45
chore: update auth lint settings to allow class arrow functions to en…
erinleigh90 Jul 10, 2023
800c1f1
fix: add overloaded method signature back in - unrelated change
erinleigh90 Jul 10, 2023
838161b
test: fix auth tests by mocking InternalAuthClass instead of AuthClass
erinleigh90 Jul 10, 2023
e0d55cf
Merge branch 'main' into feat/custom-user-agent-ui/auth
erinleigh90 Jul 11, 2023
6edc14e
chore: change arrow methods to normal functions
erinleigh90 Jul 12, 2023
f01cf5a
Merge branch 'main' into feat/custom-user-agent-ui/auth
erinleigh90 Jul 31, 2023
b39528d
fix: remove async from overridden async functions
erinleigh90 Aug 2, 2023
db0ebeb
Merge branch 'main' into feat/custom-user-agent-ui/auth
erinleigh90 Aug 2, 2023
01d5c2e
chore: increase bundle size limits
erinleigh90 Aug 2, 2023
19b7cdb
chore: publish feature branch for testing
erinleigh90 Aug 2, 2023
3500229
Merge branch 'feat/custom-user-agent-ui/auth' into feat/auth-internals
erinleigh90 Aug 2, 2023
8641fe4
chore: port code from CognitoUser and CognitoUserPool to internals
erinleigh90 Jul 17, 2023
ab77ff3
chore: delete InternalCognitoUserPool - separate PR
erinleigh90 Aug 2, 2023
25b639b
chore: update imports and class name
erinleigh90 Jul 17, 2023
467ede4
feat: add userAgentValue param to cognito client api's
erinleigh90 Jul 17, 2023
94fb259
feat: add userAgentValue param to InternalCognitoUser api's, pass to …
erinleigh90 Jul 17, 2023
cfc6c29
feat: make CognitoUser extend InternalCognitoUser and override api's
erinleigh90 Jul 17, 2023
747b1e8
test: update tests to work with additional param, minor fix
erinleigh90 Jul 17, 2023
b85d388
chore: clean up unused imports and const's
erinleigh90 Jul 17, 2023
f9b4c81
feat: add missing userAgentValue param
erinleigh90 Jul 17, 2023
49e66ec
chore: add new param to documentation comments
erinleigh90 Jul 17, 2023
3bcf69f
build: export InternalCognitoUser from internals scope
erinleigh90 Jul 17, 2023
cd95804
fix: remove default from InternalCognitoUser to fix scoped export
erinleigh90 Jul 18, 2023
ce3f687
fix: fix typo causing signOut failure
erinleigh90 Jul 31, 2023
3588e6e
build: correct index.d.ts files with changes
erinleigh90 Jul 31, 2023
fa415f9
test: revert auth tests
erinleigh90 Aug 2, 2023
9df968f
chore: increase bundle size limits
erinleigh90 Aug 2, 2023
7a28cf3
Merge branch 'feat/internal-cognito' into feat/auth-internals
erinleigh90 Aug 2, 2023
a149b6c
chore: increase bundle size limits
erinleigh90 Aug 2, 2023
5fa456c
chore: port CognitoUserPool over to InternalCognitoUserPool
erinleigh90 Aug 3, 2023
8f74304
chore: restore CognitoUserPool
erinleigh90 Aug 3, 2023
1b8553a
feat: add userAgentValue parameter to signUp
erinleigh90 Aug 3, 2023
2c0d9c6
feat: update class name and imports
erinleigh90 Aug 3, 2023
7995aa6
feat: make CognitoUserPool extend internal and override signUp
erinleigh90 Aug 3, 2023
5b216a6
feat: export InternalCognitoUserPool from internals index
erinleigh90 Aug 3, 2023
e45491d
feat: send userAgentValue to client service call
erinleigh90 Aug 3, 2023
622bb40
test: fix internalsIndex test
erinleigh90 Aug 3, 2023
bcf5946
build: export InternalCognitoUserPool from internals scope
erinleigh90 Aug 3, 2023
11e22ad
chore: update CognitoUserPool type to extend internal
erinleigh90 Aug 3, 2023
1b5f0b0
Merge branch 'feat/internal-cognito-user-pool' into feat/auth-internals
erinleigh90 Aug 3, 2023
9bf4dba
chore: increase bundle size limits
erinleigh90 Aug 3, 2023
a12ad2a
feat: add utils for auth user agent
erinleigh90 Aug 4, 2023
07bf2cd
feat: add/uncomment AuthActions
erinleigh90 Aug 4, 2023
ef29b68
feat: pass userAgentValue to OAuth
erinleigh90 Aug 4, 2023
4bb72f7
feat: send user agent details through cognito
erinleigh90 Aug 4, 2023
5253c2e
test: update test to user InternalCognitoUserPool
erinleigh90 Aug 8, 2023
46c073e
test: update test to user internal cognito classes
erinleigh90 Aug 8, 2023
2257987
fix: send user agent with auth details instead of received
erinleigh90 Aug 8, 2023
7cfbb72
Merge branch 'main' into feat/auth-to-internal-cognito
erinleigh90 Aug 8, 2023
53394a0
test: mock cognito internals in auth-attribute-test
erinleigh90 Aug 8, 2023
29534b4
test: mock cognito internals in auth-federation-unit-tests
erinleigh90 Aug 8, 2023
e0801c1
test: mock cognito internals in auth-refresh-token-test
erinleigh90 Aug 8, 2023
bb75532
test: mock cognito internals in hosted-ui.test
erinleigh90 Aug 8, 2023
a8ab0b8
test: mock cognito internals in totp-unit-test
erinleigh90 Aug 8, 2023
f48abd7
fix: add in missed user agent details
erinleigh90 Aug 8, 2023
bd386d9
fix: pass user agent details to private implementations
erinleigh90 Aug 8, 2023
4a20868
fix: send user agent string instead of object
erinleigh90 Aug 8, 2023
0445167
fix: accidental replacement of currentUserPoolUser
erinleigh90 Aug 8, 2023
717ff8c
test: mock new private methods
erinleigh90 Aug 8, 2023
f75fe96
test: mock private method
erinleigh90 Aug 8, 2023
80f7a6e
chore: send undefined instead of null for userAgentValue:
erinleigh90 Aug 8, 2023
9f6236d
test: account for added param in OAuth
erinleigh90 Aug 8, 2023
3a773ea
chore: increase bundle size limits
erinleigh90 Aug 8, 2023
4d61aa1
chore: remove publishing of preid release
erinleigh90 Aug 9, 2023
1dad697
chore: increase bundle size limit
erinleigh90 Aug 9, 2023
ae8e7cb
chore: remove comment
erinleigh90 Aug 9, 2023
d40af9e
Merge branch 'main' into feat/auth-to-internal-cognito
erinleigh90 Aug 9, 2023
bd7ce76
fix: send undefined clientMetadata before useragentvalue
erinleigh90 Aug 9, 2023
2448898
fix: use InternalCognitoUser as underlying instance
erinleigh90 Aug 11, 2023
2172303
fix: send userAgentValue through fetchUser
erinleigh90 Aug 11, 2023
61db787
fix: send userAgentValue through _getUserData
erinleigh90 Aug 11, 2023
cbf07be
test: fix tests to expect userAgentValue
erinleigh90 Aug 11, 2023
10b14ca
fix: add missing param and AuthAction for currentCredentials
erinleigh90 Aug 11, 2023
91cb30a
Merge branch 'main' into feat/auth-to-internal-cognito
erinleigh90 Aug 11, 2023
1fb4e49
chore: increase bundle size limits
erinleigh90 Aug 11, 2023
20cde26
Merge branch 'main' into feat/auth-to-internal-cognito
erinleigh90 Aug 11, 2023
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
47 changes: 24 additions & 23 deletions packages/amazon-cognito-identity-js/internals/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@ export class InternalCognitoUser {
const userData = this.getUserDataFromCache();

if (!userData) {
this.fetchUserData()
this.fetchUserData(userAgentValue)
.then(data => {
callback(null, data);
})
Expand All @@ -1387,7 +1387,7 @@ export class InternalCognitoUser {
}

if (this.isFetchUserDataAndTokenRequired(params)) {
this.fetchUserData()
this.fetchUserData(userAgentValue)
.then(data => {
return this.refreshSessionIfPossible(params, userAgentValue).then(
() => data
Expand Down Expand Up @@ -1436,10 +1436,10 @@ export class InternalCognitoUser {
* @param {string} userAgentValue Optional string containing custom user agent value
*/
fetchUserData(userAgentValue) {
return this.createGetUserRequest().then(data => {
return this.createGetUserRequest(userAgentValue).then(data => {
this.cacheUserData(data);
return data;
}, userAgentValue);
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import Client from '../Client';
import CognitoUser from '../CognitoUser';
import { InternalCognitoUser } from '../internals';
import StorageHelper from '../StorageHelper';

const USER_POOL_ID_MAX_LENGTH = 55;
Expand Down Expand Up @@ -130,7 +131,7 @@ export class InternalCognitoUserPool {
};

const returnData = {
user: new CognitoUser(cognitoUser),
user: new InternalCognitoUser(cognitoUser),
userConfirmed: data.UserConfirmed,
userSub: data.UserSub,
codeDeliveryDetails: data.CodeDeliveryDetails,
Expand All @@ -156,7 +157,7 @@ export class InternalCognitoUserPool {
Storage: this.storage,
};

return new CognitoUser(cognitoUser);
return new InternalCognitoUser(cognitoUser);
}

return null;
Expand Down
4 changes: 2 additions & 2 deletions packages/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@
"name": "Analytics (Pinpoint)",
"path": "./lib-esm/index.js",
"import": "{ Amplify, Analytics, AWSPinpointProvider }",
"limit": "31.5 kB"
"limit": "31.57 kB"
},
{
"name": "Analytics (Kinesis)",
"path": "./lib-esm/index.js",
"import": "{ Amplify, Analytics, AWSKinesisProvider }",
"limit": "60.5 kB"
"limit": "60.82 kB"
}
],
"jest": {
Expand Down
2 changes: 1 addition & 1 deletion packages/api-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"name": "API (GraphQL client)",
"path": "./lib-esm/index.js",
"import": "{ Amplify, GraphQLAPI }",
"limit": "89.52 kB"
"limit": "90.35 kB"
}
],
"jest": {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"name": "API (top-level class)",
"path": "./lib-esm/index.js",
"import": "{ Amplify, API }",
"limit": "90.28 kB"
"limit": "91.12 kB"
}
],
"jest": {
Expand Down
14 changes: 9 additions & 5 deletions packages/auth/__tests__/auth-attribute-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import {
CognitoAccessToken,
CognitoUserAttribute,
} from 'amazon-cognito-identity-js';
import {
InternalCognitoUserPool,
InternalCognitoUser,
} from 'amazon-cognito-identity-js/internals';

import { AuthOptions } from '../src/types';
import { InternalAuthClass } from '../src/internals/InternalAuth';
Expand All @@ -23,7 +27,7 @@ const authOptions: AuthOptions = {
describe('User-Attribute-validation', () => {
it('Check-non-verified-attributes', async () => {
const spyonAuthUserAttributes = jest
.spyOn(InternalAuthClass.prototype, 'userAttributes')
.spyOn(InternalAuthClass.prototype as any, '_userAttributes')
.mockImplementation((user: CognitoUser) => {
const emailAttribute = new CognitoUserAttribute({
Name: 'email',
Expand Down Expand Up @@ -75,10 +79,10 @@ describe('User-Attribute-validation', () => {
const auth = new Auth(authOptions);

const spyUserPoolCurrentUser = jest
.spyOn(CognitoUserPool.prototype, 'getCurrentUser')
.spyOn(InternalCognitoUserPool.prototype, 'getCurrentUser')
.mockImplementation(() => {
return new CognitoUser({
Pool: new CognitoUserPool({
Pool: new InternalCognitoUserPool({
UserPoolId: authOptions.userPoolId,
ClientId: authOptions.userPoolWebClientId,
}),
Expand All @@ -87,7 +91,7 @@ describe('User-Attribute-validation', () => {
});

const spyUserGetSession = jest
.spyOn(CognitoUser.prototype, 'getSession')
.spyOn(InternalCognitoUser.prototype, 'getSession')
.mockImplementation((callback: any) => {
const session = new CognitoUserSession({
AccessToken: new CognitoAccessToken({ AccessToken: 'accesstoken' }),
Expand All @@ -103,7 +107,7 @@ describe('User-Attribute-validation', () => {
});

const spyGetUserData = jest
.spyOn(CognitoUser.prototype, 'getUserData')
.spyOn(InternalCognitoUser.prototype, 'getUserData')
.mockImplementation(callback => {
const emailAttribute = {
Name: 'email',
Expand Down
12 changes: 8 additions & 4 deletions packages/auth/__tests__/auth-creds-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ import { Credentials } from '@aws-amplify/core';
import { AuthOptions } from '../src/types';
import {
CognitoUser,
CognitoUserPool,
CognitoUserSession,
CognitoAccessToken,
CognitoIdToken,
CognitoUserPool,
} from 'amazon-cognito-identity-js';
import {
InternalCognitoUser,
InternalCognitoUserPool,
} from 'amazon-cognito-identity-js/internals';
const authOptions: AuthOptions = {
userPoolId: 'us-west-2_0xxxxxxxx',
userPoolWebClientId: 'awsUserPoolsWebClientId',
Expand All @@ -21,7 +25,7 @@ describe('credentials syncing tests', () => {
const auth = new Auth(authOptions);

jest
.spyOn(CognitoUser.prototype, 'authenticateUser')
.spyOn(InternalCognitoUser.prototype, 'authenticateUser')
.mockImplementation((authenticationDetails, callback) => {
const session = new CognitoUserSession({
AccessToken: new CognitoAccessToken({ AccessToken: 'accesstoken' }),
Expand All @@ -32,7 +36,7 @@ describe('credentials syncing tests', () => {
});

jest
.spyOn(CognitoUserPool.prototype, 'getCurrentUser')
.spyOn(InternalCognitoUserPool.prototype, 'getCurrentUser')
.mockImplementation(() => {
return new CognitoUser({
Pool: new CognitoUserPool({
Expand All @@ -49,7 +53,7 @@ describe('credentials syncing tests', () => {
});

jest
.spyOn(CognitoUser.prototype, 'getSession')
.spyOn(InternalCognitoUser.prototype, 'getSession')
.mockImplementation((callback: any) => {
callback(null, session);
});
Expand Down
Loading