Skip to content

Commit

Permalink
release(required): Amplify JS release (#11536)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblanc committed Jun 21, 2023
2 parents 8e05589 + dc84cc8 commit 60c705c
Show file tree
Hide file tree
Showing 33 changed files with 87 additions and 91 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/aws-amplify-dependency-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
with:
persist-credentials: true
- name: Determine if "aws-amplify" package.json has been changed
id: aws-amplify-package-check
uses: tj-actions/changed-files@v36
uses: tj-actions/changed-files@54479c37f5eb47a43e595c6b71e1df2c112ce7f1 # v36 https://github.com/tj-actions/changed-files/commit/54479c37f5eb47a43e595c6b71e1df2c112ce7f1
with:
files: packages/aws-amplify/package.json
- name: Write a PR comment
uses: actions/github-script@v6
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0 https://github.com/actions/github-script/commit/98814c53be79b1d30f795b907e553d8679345975
if: steps.aws-amplify-package-check.outputs.any_changed == 'true'
with:
script: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
with:
# Minimal depth 2 so we can checkout the commit before possible merge commit.
fetch-depth: 2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@d23060145bc9131d50558d5d4185494a20208101 # v2.12.5 https://github.com/github/codeql-action/commit/d23060145bc9131d50558d5d4185494a20208101
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@d23060145bc9131d50558d5d4185494a20208101 # v2.12.5 https://github.com/github/codeql-action/commit/d23060145bc9131d50558d5d4185494a20208101

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@d23060145bc9131d50558d5d4185494a20208101 # v2.12.5 https://github.com/github/codeql-action/commit/d23060145bc9131d50558d5d4185494a20208101
with:
category: '/language:${{matrix.language}}'
2 changes: 1 addition & 1 deletion .github/workflows/issue-pending-response.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
if: ${{ !github.event.issue.pull_request && contains(github.event.issue.labels.*.name, 'pending-response') }}
runs-on: ubuntu-latest
steps:
- uses: siegerts/pending-author-response@v1
- uses: siegerts/pending-author-response@409a63bf27370ba9a0e98e8d5fbda7a12398d456 # v1 https://github.com/siegerts/pending-author-response/commit/409a63bf27370ba9a0e98e8d5fbda7a12398d456
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
pending-response-label: pending-response
2 changes: 1 addition & 1 deletion .github/workflows/lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
lock:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v2
- uses: dessant/lock-threads@f1a42f0f44eb83361d617a014663e1a76cf282d2 # v2 https://github.com/dessant/lock-threads/commit/f1a42f0f44eb83361d617a014663e1a76cf282d2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
issue-lock-inactive-days: '365'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/snyk-security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
- name: Set up Snyk CLI to check for security issues
uses: snyk/actions/setup@806182742461562b67788a64410098c9d9b96adb
uses: snyk/actions/setup@806182742461562b67788a64410098c9d9b96adb # v0.4.0 https://github.com/snyk/actions/commit/806182742461562b67788a64410098c9d9b96adb
- name: Build
run: yarn install || true
# Using `|| true` to not fail the pipeline
Expand All @@ -31,6 +31,6 @@ jobs:

# Push the Snyk Code results into GitHub Code Scanning tab
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@6c089f53dd51dc3fc7e599c3cb5356453a52ca9e # v2 https://github.com/github/codeql-action/commit/6c089f53dd51dc3fc7e599c3cb5356453a52ca9e
with:
sarif_file: snyk-code.sarif
10 changes: 5 additions & 5 deletions packages/amazon-cognito-identity-js/__tests__/UserAgent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import UserAgent, {
addAuthCategoryToCognitoUserAgent,
addFrameworkToCognitoUserAgent,
appendToCognitoUserAgent,
getAmplifyUserAgentString,
getAmplifyUserAgent,
} from '../src/UserAgent';

const DEFAULT_USER_AGENT = 'aws-amplify/0.1.x';
Expand All @@ -29,7 +29,7 @@ describe('UserAgent test', () => {
appendToCognitoUserAgent('test');
expect(UserAgent.prototype.userAgent).toBe(`${DEFAULT_USER_AGENT} test`);

expect(getAmplifyUserAgentString()).toBe(`${DEFAULT_USER_AGENT} test`);
expect(getAmplifyUserAgent()).toBe(`${DEFAULT_USER_AGENT} test`);
});

test('appendToCognitoUserAgent does not append duplicate content', () => {
Expand All @@ -41,7 +41,7 @@ describe('UserAgent test', () => {

expect(UserAgent.prototype.userAgent).toBe(`${DEFAULT_USER_AGENT} test`);

expect(getAmplifyUserAgentString()).toBe(`${DEFAULT_USER_AGENT} test`);
expect(getAmplifyUserAgent()).toBe(`${DEFAULT_USER_AGENT} test`);
});

test('appendToCognitoUserAgent sets userAgent if userAgent has no content', () => {
Expand All @@ -58,7 +58,7 @@ describe('UserAgent test', () => {
addAuthCategoryToCognitoUserAgent();
expect(UserAgent.category).toBe(AUTH_CATEGORY);

expect(getAmplifyUserAgentString()).toBe(
expect(getAmplifyUserAgent()).toBe(
`${DEFAULT_USER_AGENT} ${USER_AGENT_AUTH}`
);
});
Expand All @@ -67,7 +67,7 @@ describe('UserAgent test', () => {
addFrameworkToCognitoUserAgent('0');
expect(UserAgent.framework).toBe('0');

expect(getAmplifyUserAgentString()).toBe(
expect(getAmplifyUserAgent()).toBe(
`${DEFAULT_USER_AGENT} ${USER_AGENT_FRAMEWORK0}`
);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/amazon-cognito-identity-js/src/Client.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'isomorphic-unfetch';

import { getAmplifyUserAgentString } from './UserAgent';
import { getAmplifyUserAgent } from './UserAgent';

class CognitoError extends Error {
constructor(message, code, name, statusCode) {
Expand Down Expand Up @@ -79,7 +79,7 @@ export default class Client {
const headers = {
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': `AWSCognitoIdentityProviderService.${operation}`,
'X-Amz-User-Agent': getAmplifyUserAgentString(),
'X-Amz-User-Agent': getAmplifyUserAgent(),
'Cache-Control': 'no-store',
};

Expand Down
2 changes: 1 addition & 1 deletion packages/amazon-cognito-identity-js/src/UserAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const addFrameworkToCognitoUserAgent = framework => {
UserAgent.framework = framework;
};

export const getAmplifyUserAgentString = action => {
export const getAmplifyUserAgent = action => {
const uaCategoryAction = UserAgent.category ? ` ${UserAgent.category}` : '';
const uaFramework = UserAgent.framework
? ` framework/${UserAgent.framework}`
Expand Down
6 changes: 3 additions & 3 deletions packages/analytics/src/utils/UserAgent.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {
AnalyticsAction,
Category,
getAmplifyUserAgentObject,
getAmplifyUserAgent,
getAmplifyUserAgentString,
} from '@aws-amplify/core';

export function getAnalyticsUserAgent(action: AnalyticsAction) {
return getAmplifyUserAgent({
return getAmplifyUserAgentObject({
category: Category.Analytics,
action,
});
}

export function getAnalyticsUserAgentString(action: AnalyticsAction) {
return getAmplifyUserAgentString({
return getAmplifyUserAgent({
category: Category.Analytics,
action,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/api-graphql/src/internals/InternalGraphQLAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
ConsoleLogger as Logger,
Credentials,
CustomUserAgentDetails,
getAmplifyUserAgentString,
getAmplifyUserAgent,
INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER,
} from '@aws-amplify/core';
import { InternalPubSub } from '@aws-amplify/pubsub/internals';
Expand Down Expand Up @@ -293,7 +293,7 @@ export class InternalGraphQLAPIClass {
...(await graphql_headers({ query, variables })),
...additionalHeaders,
...(!customGraphqlEndpoint && {
[USER_AGENT_HEADER]: getAmplifyUserAgentString(customUserAgentDetails),
[USER_AGENT_HEADER]: getAmplifyUserAgent(customUserAgentDetails),
}),
};

Expand Down
2 changes: 1 addition & 1 deletion packages/auth/__tests__/oauth-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jest.mock('@aws-amplify/core', () => ({
urlSafeEncode: jest.fn(),
Category: { Auth: 'auth' },
AuthAction: { FederatedSignIn: '30' },
getAmplifyUserAgentString: () => jest.fn(),
getAmplifyUserAgent: () => jest.fn(),
}));

function fetchMockReturn(response) {
Expand Down
6 changes: 2 additions & 4 deletions packages/auth/src/OAuth/OAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
Category,
ConsoleLogger as Logger,
CustomUserAgentDetails,
getAmplifyUserAgentString,
getAmplifyUserAgent,
Hub,
urlSafeEncode,
USER_AGENT_HEADER,
Expand Down Expand Up @@ -179,9 +179,7 @@ export default class OAuth {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
[USER_AGENT_HEADER]: getAmplifyUserAgentString(
customUserAgentDetails
),
[USER_AGENT_HEADER]: getAmplifyUserAgent(customUserAgentDetails),
},
body,
})) as any
Expand Down
14 changes: 7 additions & 7 deletions packages/core/__tests__/Platform-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
getAmplifyUserAgentObject,
getAmplifyUserAgent,
getAmplifyUserAgentString,
Platform,
} from '../src/Platform';
import { version } from '../src/Platform/version';
Expand All @@ -16,9 +16,9 @@ describe('Platform test', () => {
});
});

describe('getAmplifyUserAgent test', () => {
describe('getAmplifyUserAgentObject test', () => {
test('without customUserAgentDetails', () => {
expect(getAmplifyUserAgent()).toStrictEqual([
expect(getAmplifyUserAgentObject()).toStrictEqual([
['aws-amplify', version],
['framework', Framework.WebUnknown],
]);
Expand All @@ -27,7 +27,7 @@ describe('Platform test', () => {
/* TODO: test with actual API action */
test('with customUserAgentDetails', () => {
expect(
getAmplifyUserAgent({
getAmplifyUserAgentObject({
category: Category.API,
action: ApiAction.None,
})
Expand All @@ -39,16 +39,16 @@ describe('Platform test', () => {
});
});

describe('getAmplifyUserAgentString test', () => {
describe('getAmplifyUserAgent test', () => {
test('without customUserAgentDetails', () => {
expect(getAmplifyUserAgentString()).toBe(
expect(getAmplifyUserAgent()).toBe(
`${Platform.userAgent} framework/${Framework.WebUnknown}`
);
});

test('with customUserAgentDetails', () => {
expect(
getAmplifyUserAgentString({
getAmplifyUserAgent({
category: Category.API,
action: ApiAction.None,
})
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/AwsClients/CognitoIdentity/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
jitteredBackoff,
getRetryDecider,
} from '../../clients/middleware/retry';
import { getAmplifyUserAgentString } from '../../Platform';
import { getAmplifyUserAgent } from '../../Platform';
import { observeFrameworkChanges } from '../../Platform/detectFramework';

/**
Expand Down Expand Up @@ -63,11 +63,11 @@ export const defaultConfig = {
endpointResolver,
retryDecider: getRetryDecider(parseJsonError),
computeDelay: jitteredBackoff,
userAgentValue: getAmplifyUserAgentString(),
userAgentValue: getAmplifyUserAgent(),
};

observeFrameworkChanges(() => {
defaultConfig.userAgentValue = getAmplifyUserAgentString();
defaultConfig.userAgentValue = getAmplifyUserAgent();
});

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/AwsClients/Pinpoint/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '../../clients/middleware/retry';
import { parseJsonError } from '../../clients/serde/json';
import type { EndpointResolverOptions, Headers } from '../../clients/types';
import { getAmplifyUserAgentString } from '../../Platform';
import { getAmplifyUserAgent } from '../../Platform';

/**
* The service name used to sign requests if the API requires authentication.
Expand All @@ -30,7 +30,7 @@ export const defaultConfig = {
endpointResolver,
retryDecider: getRetryDecider(parseJsonError),
computeDelay: jitteredBackoff,
userAgentValue: getAmplifyUserAgentString(),
userAgentValue: getAmplifyUserAgent(),
};

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/Platform/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PlatformBuilder {

export const Platform = new PlatformBuilder();

export const getAmplifyUserAgent = ({
export const getAmplifyUserAgentObject = ({
category,
action,
framework,
Expand All @@ -39,10 +39,10 @@ export const getAmplifyUserAgent = ({
return userAgent;
};

export const getAmplifyUserAgentString = (
export const getAmplifyUserAgent = (
customUserAgentDetails?: CustomUserAgentDetails
): string => {
const userAgent = getAmplifyUserAgent(customUserAgentDetails);
const userAgent = getAmplifyUserAgentObject(customUserAgentDetails);
const userAgentString = userAgent
.map(([agentKey, agentValue]) => `${agentKey}/${agentValue}`)
.join(' ');
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Providers/AWSCloudWatchProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
} from '../types/types';
import { Credentials } from '../..';
import { ConsoleLogger as Logger } from '../Logger';
import { getAmplifyUserAgent } from '../Platform';
import { getAmplifyUserAgentObject } from '../Platform';
import { parseAWSExports } from '../parseAWSExports';
import {
AWS_CLOUDWATCH_BASE_BUFFER_SIZE,
Expand Down Expand Up @@ -321,7 +321,7 @@ class AWSCloudWatchProvider implements LoggingProvider {
return new CloudWatchLogsClient({
region: this._config.region,
credentials: this._config.credentials,
customUserAgent: getAmplifyUserAgent(),
customUserAgent: getAmplifyUserAgentObject(),
endpoint: this._config.endpoint,
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export { StorageHelper, MemoryStorage } from './StorageHelper';
export { UniversalStorage } from './UniversalStorage';
export {
Platform,
getAmplifyUserAgentObject,
getAmplifyUserAgent,
getAmplifyUserAgentString,
} from './Platform';
export {
ApiAction,
Expand Down
6 changes: 2 additions & 4 deletions packages/datastore/__tests__/mutation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
Category,
CustomUserAgentDetails,
DataStoreAction,
getAmplifyUserAgentString,
getAmplifyUserAgent,
} from '@aws-amplify/core';

let syncClasses: any;
Expand Down Expand Up @@ -168,9 +168,7 @@ describe('MutationProcessor', () => {
expect.anything(),
expect.objectContaining({
headers: expect.objectContaining({
'x-amz-user-agent': getAmplifyUserAgentString(
datastoreUserAgentDetails
),
'x-amz-user-agent': getAmplifyUserAgent(datastoreUserAgentDetails),
}),
})
);
Expand Down
2 changes: 1 addition & 1 deletion packages/datastore/__tests__/subscription.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Category,
CustomUserAgentDetails,
DataStoreAction,
getAmplifyUserAgent,
getAmplifyUserAgentObject,
} from '@aws-amplify/core';
import { CONTROL_MSG as PUBSUB_CONTROL_MSG } from '@aws-amplify/pubsub';
import {
Expand Down
Loading

0 comments on commit 60c705c

Please sign in to comment.