Skip to content

Commit

Permalink
Merge branch 'main' into amplify-js/update-issue-template
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerabread committed Dec 16, 2022
2 parents c84135c + d7a18e0 commit cc5f1c3
Show file tree
Hide file tree
Showing 57 changed files with 817 additions and 122 deletions.
69 changes: 68 additions & 1 deletion .circleci/config.yml
Expand Up @@ -1065,6 +1065,13 @@ jobs:
steps:
- integ_test_rn_ios

integ_rn_ios_device_tracking:
executor: macos-executor
<<: *test_env_vars
working_directory: ~/amplify-js-samples-staging/samples/react-native/auth/deviceTracking
steps:
- integ_test_rn_ios

integ_datastore_auth:
parameters:
scenario:
Expand Down Expand Up @@ -1354,6 +1361,40 @@ jobs:
spec: nested-predicate
browser: << parameters.browser >>

integ_next_datastore_13_basic:
parameters:
browser:
type: string
executor: js-test-executor
<<: *test_env_vars
working_directory: ~/amplify-js-samples-staging/samples/next/datastore/next-13-basic
steps:
- prepare_test_env
- integ_test_js:
test_name: 'DataStore - Nextjs 13 build with SWC - basic JS app'
framework: next
category: datastore
sample_name: next-13-basic
spec: nextjs-13-basic
browser: << parameters.browser >>

integ_next_datastore_13_js:
parameters:
browser:
type: string
executor: js-test-executor
<<: *test_env_vars
working_directory: ~/amplify-js-samples-staging/samples/next/datastore/next-13-js
steps:
- prepare_test_env
- integ_test_js:
test_name: 'DataStore - Nextjs 13 build with SWC - JS app'
framework: next
category: datastore
sample_name: next-13-js
spec: nextjs-13
browser: << parameters.browser >>

deploy:
executor: macos-executor
working_directory: ~/amplify-js
Expand Down Expand Up @@ -1763,6 +1804,12 @@ workflows:
- build
filters:
<<: *releasable_branches
- integ_rn_ios_device_tracking:
requires:
- integ_setup
- build
filters:
<<: *releasable_branches
# - integ_rn_android_storage:
# requires:
# - integ_setup
Expand Down Expand Up @@ -1910,7 +1957,24 @@ workflows:
matrix:
parameters:
<<: *test_browsers

- integ_next_datastore_13_basic:
requires:
- integ_setup
- build
filters:
<<: *releasable_branches
matrix:
parameters:
<<: *test_browsers
- integ_next_datastore_13_js:
requires:
- integ_setup
- build
filters:
<<: *releasable_branches
matrix:
parameters:
<<: *test_browsers
- deploy:
filters:
<<: *releasable_branches
Expand Down Expand Up @@ -1951,6 +2015,7 @@ workflows:
- integ_rn_ios_storage_multipart_progress
# - integ_rn_android_storage_multipart_progress
- integ_rn_ios_push_notifications
- integ_rn_ios_device_tracking
# - integ_rn_android_storage
# - integ_rn_ios_datastore_sqlite_adapter
- integ_datastore_auth
Expand All @@ -1970,6 +2035,8 @@ workflows:
- integ_react_api_reconnect
- integ_react_datastore_selective_sync
- integ_react_datastore_nested_predicate
- integ_next_datastore_13_basic
- integ_next_datastore_13_js
- post_release:
filters:
branches:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -21,7 +21,7 @@
"lint": "lerna run lint",
"link-all": "yarn unlink-all && lerna exec --no-bail --parallel yarn link",
"unlink-all": "lerna exec --no-bail --parallel -- yarn unlink; exit 0",
"publish:main": "lerna publish --canary --force-publish \"*\" --yes --dist-tag=unstable --preid=unstable --exact --no-verify-access",
"publish:main": "lerna publish --canary --force-publish \"*\" --yes --dist-tag=unstable --preid=unstable-v5 --exact --no-verify-access",
"publish:next-major-version/5": "lerna publish --canary --force-publish \"*\" --yes --dist-tag=next --preid=next --exact --no-verify-access",
"publish:beta": "lerna publish --canary --force-publish \"*\" --yes --dist-tag=beta --preid=beta --exact --no-verify-access",
"publish:release": "lerna publish --conventional-commits --yes --message 'chore(release): Publish [ci skip]' --no-verify-access",
Expand Down
27 changes: 27 additions & 0 deletions packages/amazon-cognito-identity-js/CHANGELOG.md
Expand Up @@ -3,6 +3,33 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [6.1.1](https://github.com/aws-amplify/amplify-js/compare/amazon-cognito-identity-js@6.1.0...amazon-cognito-identity-js@6.1.1) (2022-12-16)


### Bug Fixes

* **amazon-cognito-identity-js:** specify the correct userAgent/deviceName when remembering devices (React Native) ([#10724](https://github.com/aws-amplify/amplify-js/issues/10724)) ([01a5b84](https://github.com/aws-amplify/amplify-js/commit/01a5b84ea010f7fb66c4e19e73301cce82fc7370))





# [6.1.0](https://github.com/aws-amplify/amplify-js/compare/amazon-cognito-identity-js@6.0.1...amazon-cognito-identity-js@6.1.0) (2022-12-15)


### Bug Fixes

* **core:** add cache-control header to cognito identity client ([#10753](https://github.com/aws-amplify/amplify-js/issues/10753)) ([dfbabaf](https://github.com/aws-amplify/amplify-js/commit/dfbabaf54dda902f1f77c4501e78f49e6a9397af))


### Features

* **auth,cognito-identity-js:** returning code delivery details as part of callback for updateAttributes, adds hub event to Auth.updateUserAttributes ([#10731](https://github.com/aws-amplify/amplify-js/issues/10731)) ([fc4940b](https://github.com/aws-amplify/amplify-js/commit/fc4940bc17e0deeb9e9ca2a00bed101e8ff7d3df))





## [6.0.1](https://github.com/aws-amplify/amplify-js/compare/amazon-cognito-identity-js@6.0.0...amazon-cognito-identity-js@6.0.1) (2022-11-11)

**Note:** Version bump only for package amazon-cognito-identity-js
Expand Down
2 changes: 1 addition & 1 deletion packages/amazon-cognito-identity-js/package.json
@@ -1,7 +1,7 @@
{
"name": "amazon-cognito-identity-js",
"description": "Amazon Cognito Identity Provider JavaScript SDK",
"version": "6.0.1",
"version": "6.1.1",
"author": {
"name": "Amazon Web Services",
"email": "aws@amazon.com",
Expand Down
70 changes: 43 additions & 27 deletions packages/amazon-cognito-identity-js/src/Client.js
Expand Up @@ -49,15 +49,20 @@ export default class Client {
requestWithRetry(operation, params, callback) {
const MAX_DELAY_IN_MILLIS = 5 * 1000;

jitteredExponentialRetry((p) => new Promise((res, rej) => {
this.request(operation, p, (error, result) => {
if (error) {
rej(error);
} else {
res(result);
}
});
}), [params], MAX_DELAY_IN_MILLIS)
jitteredExponentialRetry(
p =>
new Promise((res, rej) => {
this.request(operation, p, (error, result) => {
if (error) {
rej(error);
} else {
res(result);
}
});
}),
[params],
MAX_DELAY_IN_MILLIS
)
.then(result => callback(null, result))
.catch(error => callback(error));
}
Expand Down Expand Up @@ -112,9 +117,9 @@ export default class Client {
// Taken from aws-sdk-js/lib/protocol/json.js
// eslint-disable-next-line no-underscore-dangle
const code = (data.__type || data.code).split('#').pop();
const error = new Error(data.message || data.Message || null)
error.name = code
error.code = code
const error = new Error(data.message || data.Message || null);
error.name = code;
error.code = code;
return callback(error);
})
.catch(err => {
Expand All @@ -126,17 +131,19 @@ export default class Client {
) {
try {
const code = response.headers.get('x-amzn-errortype').split(':')[0];
const error = new Error(response.status ? response.status.toString() : null)
error.code = code
error.name = code
error.statusCode = response.status
const error = new Error(
response.status ? response.status.toString() : null
);
error.code = code;
error.name = code;
error.statusCode = response.status;
return callback(error);
} catch (ex) {
return callback(err);
}
// otherwise check if error is Network error
} else if (err instanceof Error && err.message === 'Network error') {
err.code = 'NetworkError'
err.code = 'NetworkError';
}
return callback(err);
});
Expand All @@ -146,7 +153,7 @@ export default class Client {
const logger = {
debug: () => {
// Intentionally blank. This package doesn't have logging
}
},
};

/**
Expand All @@ -159,7 +166,7 @@ class NonRetryableError extends Error {
}
}

const isNonRetryableError = (obj) => {
const isNonRetryableError = obj => {
const key = 'nonRetryable';
return obj && obj[key];
};
Expand All @@ -169,9 +176,13 @@ function retry(functionToRetry, args, delayFn, attempt = 1) {
throw Error('functionToRetry must be a function');
}

logger.debug(`${functionToRetry.name} attempt #${attempt} with args: ${JSON.stringify(args)}`);
logger.debug(
`${functionToRetry.name} attempt #${attempt} with args: ${JSON.stringify(
args
)}`
);

return functionToRetry(...args).catch((err) => {
return functionToRetry(...args).catch(err => {
logger.debug(`error on ${functionToRetry.name}`, err);

if (isNonRetryableError(err)) {
Expand All @@ -184,12 +195,13 @@ function retry(functionToRetry, args, delayFn, attempt = 1) {
logger.debug(`${functionToRetry.name} retrying in ${retryIn} ms`);

if (retryIn !== false) {
return new Promise(res => setTimeout(res, retryIn))
.then(() => retry(functionToRetry, args, delayFn, attempt + 1))
return new Promise(res => setTimeout(res, retryIn)).then(() =>
retry(functionToRetry, args, delayFn, attempt + 1)
);
} else {
throw err;
}
})
});
}

function jitteredBackoff(maxDelayMs) {
Expand All @@ -203,6 +215,10 @@ function jitteredBackoff(maxDelayMs) {
}

const MAX_DELAY_MS = 5 * 60 * 1000;
function jitteredExponentialRetry(functionToRetry, args, maxDelayMs = MAX_DELAY_MS) {
return retry(functionToRetry, args, jitteredBackoff(maxDelayMs))
};
function jitteredExponentialRetry(
functionToRetry,
args,
maxDelayMs = MAX_DELAY_MS
) {
return retry(functionToRetry, args, jitteredBackoff(maxDelayMs));
}
9 changes: 7 additions & 2 deletions packages/amazon-cognito-identity-js/src/CognitoUser.js
Expand Up @@ -5,6 +5,7 @@

import { Buffer } from 'buffer';
import { Sha256 } from '@aws-crypto/sha256-js';
import { Platform } from './Platform';

import BigInteger from './BigInteger';
import AuthenticationHelper from './AuthenticationHelper';
Expand Down Expand Up @@ -55,8 +56,12 @@ import StorageHelper from './StorageHelper';
* @param {bool=} userConfirmationNecessary User must be confirmed.
*/

const isBrowser = typeof navigator !== 'undefined';
const userAgent = isBrowser ? navigator.userAgent : 'nodejs';
const isNavigatorAvailable = typeof navigator !== 'undefined';
const userAgent = isNavigatorAvailable
? Platform.isReactNative
? 'react-native'
: navigator.userAgent
: 'nodejs';

/** @class */
export default class CognitoUser {
Expand Down
16 changes: 16 additions & 0 deletions packages/analytics/CHANGELOG.md
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [6.0.7](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/analytics@6.0.6...@aws-amplify/analytics@6.0.7) (2022-12-16)

**Note:** Version bump only for package @aws-amplify/analytics





## [6.0.6](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/analytics@6.0.5...@aws-amplify/analytics@6.0.6) (2022-12-15)

**Note:** Version bump only for package @aws-amplify/analytics





## [6.0.5](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/analytics@6.0.4...@aws-amplify/analytics@6.0.5) (2022-12-06)

**Note:** Version bump only for package @aws-amplify/analytics
Expand Down
Expand Up @@ -74,6 +74,44 @@ describe('kinesis firehose provider test', () => {
spyon.mockRestore();
});

test('record with immediate transmission', async () => {
const kinesisProvider = new KinesisFirehoseProvider();
const putRecordBatchCommandSpy = jest.spyOn(
PutRecordBatchCommand.prototype,
'constructor'
);

jest.spyOn(Credentials, 'get').mockImplementationOnce(() => {
return Promise.resolve(credentials);
});

await expect(
kinesisProvider.record({
event: {
data: {
d: 1,
},
streamName: 'testStream',
immediate: true,
},
config: {},
})
).resolves.toBe(true);

// Ensure PutRecord was constructed as expected
expect(putRecordBatchCommandSpy).toHaveBeenCalledTimes(1);
expect(putRecordBatchCommandSpy).toHaveBeenCalledWith({
DeliveryStreamName: 'testStream',
Records: [
{
Data: new Uint8Array([123, 34, 100, 34, 58, 49, 125]), // Encoded data payload
},
],
});

expect(FirehoseClient.prototype.send).toHaveBeenCalledTimes(1);
});

test('record happy case', async () => {
const analytics = new KinesisFirehoseProvider();
analytics.configure({ region: 'region1' });
Expand Down

0 comments on commit cc5f1c3

Please sign in to comment.