Skip to content

Commit

Permalink
Merge pull request #5359 from AhmetAhunbayAWS/feat-identity-providers…
Browse files Browse the repository at this point in the history
…/main

Feat identity providers/main
  • Loading branch information
calebpollman authored Jul 2, 2024
2 parents c0897e6 + cfc7f5d commit 99f9216
Show file tree
Hide file tree
Showing 24 changed files with 1,320 additions and 229 deletions.
5 changes: 0 additions & 5 deletions .changeset/chilled-rice-listen.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/plenty-bears-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@aws-amplify/ui-react-liveness": patch
---

chore(deps): Update client-rekognitionstreaming sdk and custom fetch handler
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ the requirements below.

- [ ] Have read the [Pull Request Guidelines](https://github.com/aws-amplify/amplify-ui/blob/main/CONTRIBUTING.md)
- [ ] PR description included
- [ ] Relevant documentation is changed or added (and PR referenced)
- [ ] `yarn test` passes and tests are updated/added
- [ ] No side effects or [`sideEffects`](https://github.com/aws-amplify/amplify-ui/blob/main/packages/react/CONTRIBUTING.md#code-standards) field updated
- [ ] PR title and commit messages follow [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) syntax
- [ ] _If this change should result in a version bump_, [changeset added](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md) (This can be done after creating the PR.) This does not apply to changes made to `docs`, `e2e`, `examples`, or other private packages.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ You should open an issue to discuss your pull request, unless it's a trivial cha
1. [`nvm install`](https://github.com/nvm-sh/nvm)
1. [`nvm use`](https://github.com/nvm-sh/nvm)
1. `yarn setup`
1. Within your fork, create a new branch based on the issue you're addressing -- `git checkout -b angular/remove-browser-module`
1. Within your fork, create a new branch based on the issue you're addressing, e.g. `git checkout -b angular/remove-browser-module`
1. Commit your code using [conventional commit messages](https://www.conventionalcommits.org/en/v1.0.0/#summary), e.g. `git commit -m "chore: remove browser module"`.
1. Once your work is committed, validate your changes according to [local development guides](#local-development-guides).
1. If this is a change to any customer-facing aspect of a component, for example a new prop, feature, or a breaking change, update or add relevant documentation. If this is a large change, documentation updates can be made in a separate PR, but should be noted as a followup in the PR description. See the specific contributing guide for documentation [here](docs/README.md#contributing)
1. Push your branch with `git push origin -u`
1. Open a PR against this repo from your newly published branch.
1. Add a [changeset](https://github.com/changesets/changesets) that describes your changes. More info [here](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md). Please make sure that your changeset only bumps `@aws-amplify/*` packages and does not bump any of private packages like `docs`, `e2e`, `examples`, etc. If you only updated a private package like `docs`, `e2e`, or `examples`, skip this step.
Expand Down
17 changes: 11 additions & 6 deletions build-system-tests/scripts/mega-app-copy-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ if [ "$FRAMEWORK" == "react-native" ]; then
AWS_EXPORTS_FILE="templates/template-react-native-aws-exports.js"
else
AWS_EXPORTS_FILE="templates/template-aws-exports.js"
AWS_EXPORTS_DECLARATION_FILE="templates/template-aws-exports.d.ts"
fi

echo "Installing json and strip-json-comments"
Expand Down Expand Up @@ -117,15 +118,17 @@ fi
if [[ "$FRAMEWORK" == 'react' && "$BUILD_TOOL" == 'vite' ]]; then
echo "cp $AWS_EXPORTS_FILE mega-apps/${MEGA_APP_NAME}/src/aws-exports.js"
cp $AWS_EXPORTS_FILE mega-apps/${MEGA_APP_NAME}/src/aws-exports.js
echo "cp $AWS_EXPORTS_DECLARATION_FILE mega-apps/${MEGA_APP_NAME}/src/aws-exports.d.ts"
cp $AWS_EXPORTS_DECLARATION_FILE mega-apps/${MEGA_APP_NAME}/src/aws-exports.d.ts
echo "cp templates/components/react/vite/App.tsx mega-apps/${MEGA_APP_NAME}/src/App.tsx"
cp templates/components/react/vite/App.tsx mega-apps/${MEGA_APP_NAME}/src/App.tsx

# See troubleshooting:
# https://ui.docs.amplify.aws/react/getting-started/troubleshooting#vite
echo "cp templates/components/react/vite/index.html mega-apps/${MEGA_APP_NAME}/index.html"
cp templates/components/react/vite/index.html mega-apps/${MEGA_APP_NAME}/index.html
echo "cp templates/components/react/vite/template-tsconfig-vite-${BUILD_TOOL_VERSION}.json mega-apps/${MEGA_APP_NAME}/tsconfig.json"
cp templates/components/react/vite/template-tsconfig-vite-${BUILD_TOOL_VERSION}.json mega-apps/${MEGA_APP_NAME}/tsconfig.json
echo "cp templates/components/react/vite/template-tsconfig-vite-${BUILD_TOOL_VERSION}.json mega-apps/${MEGA_APP_NAME}/tsconfig.app.json"
cp templates/components/react/vite/template-tsconfig-vite-${BUILD_TOOL_VERSION}.json mega-apps/${MEGA_APP_NAME}/tsconfig.app.json
echo "cp templates/components/react/vite/vite.config.ts mega-apps/${MEGA_APP_NAME}/vite.config.ts"
cp templates/components/react/vite/vite.config.ts mega-apps/${MEGA_APP_NAME}/vite.config.ts
fi
Expand Down Expand Up @@ -166,10 +169,12 @@ if [[ "$FRAMEWORK" == 'vue' ]]; then
cp templates/components/vue/App.vue mega-apps/${MEGA_APP_NAME}/src/App.vue
echo "cp $AWS_EXPORTS_FILE mega-apps/${MEGA_APP_NAME}/src/aws-exports.js"
cp $AWS_EXPORTS_FILE mega-apps/${MEGA_APP_NAME}/src/aws-exports.js
echo "cp $AWS_EXPORTS_DECLARATION_FILE mega-apps/${MEGA_APP_NAME}/src/aws-exports.d.ts"
cp $AWS_EXPORTS_DECLARATION_FILE mega-apps/${MEGA_APP_NAME}/src/aws-exports.d.ts

# remove comments from JSON files because `json` package can't process comments
echo "npx strip-json-comments mega-apps/${MEGA_APP_NAME}/tsconfig.json >tmpfile && mv tmpfile mega-apps/${MEGA_APP_NAME}/tsconfig.json && rm -f tmpfile"
npx strip-json-comments mega-apps/${MEGA_APP_NAME}/tsconfig.json >tmpfile && mv tmpfile mega-apps/${MEGA_APP_NAME}/tsconfig.json && rm -f tmpfile
echo "npx strip-json-comments mega-apps/${MEGA_APP_NAME}/tsconfig.app.json >tmpfile && mv tmpfile mega-apps/${MEGA_APP_NAME}/tsconfig.app.json && rm -f tmpfile"
npx strip-json-comments mega-apps/${MEGA_APP_NAME}/tsconfig.app.json >tmpfile && mv tmpfile mega-apps/${MEGA_APP_NAME}/tsconfig.app.json && rm -f tmpfile

# See Troubleshooting: https://ui.docs.amplify.aws/vue/getting-started/troubleshooting
if [[ "$BUILD_TOOL" == 'vite' ]]; then
Expand All @@ -188,8 +193,8 @@ if [[ "$FRAMEWORK" == 'vue' ]]; then
npx json -I -f mega-apps/${MEGA_APP_NAME}/tsconfig.json -e "this.allowJs=true"
else
echo "add allowJs: true to tsconfig for aws-exports.js"
echo "npx json -I -f mega-apps/${MEGA_APP_NAME}/tsconfig.json -e \"this.compilerOptions.allowJs=true\""
npx json -I -f mega-apps/${MEGA_APP_NAME}/tsconfig.json -e "this.compilerOptions.allowJs=true"
echo "npx json -I -f mega-apps/${MEGA_APP_NAME}/tsconfig.app.json -e \"this.compilerOptions.allowJs=true\""
npx json -I -f mega-apps/${MEGA_APP_NAME}/tsconfig.app.json -e "this.compilerOptions.allowJs=true"
fi
fi

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{
"compilerOptions": {
"composite": true,
"allowJs": true,
"target": "ESNext",
"lib": [
"DOM",
"DOM.Iterable",
"ESNext"
],
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
Expand All @@ -20,12 +17,5 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": [
"src"
],
"references": [
{
"path": "./tsconfig.node.json"
}
]
"include": ["src"]
}
2 changes: 2 additions & 0 deletions build-system-tests/templates/template-aws-exports.d.ts

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

2 changes: 1 addition & 1 deletion examples/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@aws-amplify/geo": "3.0.31",
"@aws-amplify/ui-react": "^6.1.12",
"@aws-amplify/ui-react-geo": "^2.0.16",
"@aws-amplify/ui-react-liveness": "^3.0.23",
"@aws-amplify/ui-react-liveness": "^3.0.24",
"@aws-amplify/ui-react-notifications": "^2.0.20",
"@aws-amplify/ui-react-storage": "^3.1.3",
"@aws-sdk/credential-providers": "^3.370.0",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
"tough-cookie": "4.1.3",
"trim-newlines": "3.0.1",
"webpack-dev-middleware": "^5.3.4",
"yaml": "2.2.2"
"yaml": "2.2.2",
"ws": "^8.17.1"
},
"devDependencies": {
"@aws-amplify/eslint-config-amplify-ui": "0.0.0",
Expand Down
63 changes: 63 additions & 0 deletions packages/react-core/src/hooks/__tests__/useDataState.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { act, renderHook } from '@testing-library/react-hooks';
import useDataState from '../useDataState';

const asyncAction = jest.fn((_prev: string, next: string) =>
Promise.resolve(next)
);
const syncAction = jest.fn((_prev: string, next: string) => next);

describe('useDataState', () => {
it.each([
{ type: 'async', action: asyncAction },
{ type: 'sync', action: syncAction },
])(
'handles a $type action as expected in the happy path',
async ({ action }) => {
const initData = 'initial-data';
const nextData = 'next-data';

const { result, waitForNextUpdate } = renderHook(() =>
useDataState(action, 'initial-data')
);

// first render
const [initState, handleAction] = result.current;

expect(action).not.toHaveBeenCalled();

expect(initState.data).toBe(initData);
expect(initState.isLoading).toBe(false);
expect(initState.message).toBeUndefined();

// call action
act(() => {
handleAction(nextData);
});

// loading result
const [loadingState] = result.current;

expect(action).toHaveBeenCalledTimes(1);
expect(action).toHaveBeenCalledWith(initData, nextData);

expect(loadingState.data).toBe(initData);
expect(loadingState.isLoading).toBe(true);
expect(loadingState.message).toBeUndefined();

await waitForNextUpdate();

// action complete
const [nextState] = result.current;

expect(action).toHaveBeenCalledTimes(1);
expect(action).toHaveBeenCalledWith(initData, nextData);

expect(nextState.data).toBe(nextData);
expect(nextState.isLoading).toBe(false);
expect(nextState.message).toBeUndefined();
}
);

it.todo('only returns the values of the last call to handleAction');
it.todo('handles exceptions thrown from provided action');
});
1 change: 1 addition & 0 deletions packages/react-core/src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as useDataState } from './useDataState';
export {
default as useDeprecationWarning,
UseDeprecationWarning,
Expand Down
42 changes: 42 additions & 0 deletions packages/react-core/src/hooks/useDataState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';

interface ActionState<T> {
data: T;
isLoading: boolean;
message: string | undefined;
}

const getActionState = <T>(data: T): ActionState<T> => ({
data,
isLoading: false,
message: undefined,
});

export default function useDataState<T, K>(
action: (prevData: Awaited<T>, ...input: K[]) => T | Promise<T>,
initialData: Awaited<T>
): [state: ActionState<Awaited<T>>, handleAction: (...input: K[]) => void] {
const [actionState, setActionState] = React.useState<ActionState<Awaited<T>>>(
() => getActionState(initialData)
);

const prevData = React.useRef(initialData);

const handleAction: (...input: K[]) => void = React.useCallback(
(...input) => {
setActionState((prev) => ({ ...prev, isLoading: true }));

Promise.resolve(action(prevData.current, ...input))
.then((data) => {
prevData.current = data;
setActionState(getActionState(data));
})
.catch(({ message }: Error) => {
setActionState((prev) => ({ ...prev, isLoading: false, message }));
});
},
[action]
);

return [actionState, handleAction];
}
6 changes: 6 additions & 0 deletions packages/react-liveness/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @aws-amplify/ui-react-liveness

## 3.0.24

### Patch Changes

- [#5303](https://github.com/aws-amplify/amplify-ui/pull/5303) [`47fb5ef77`](https://github.com/aws-amplify/amplify-ui/commit/47fb5ef778847c11310e4200bbfed17e9edf250a) Thanks [@esauerbo](https://github.com/esauerbo)! - fix(liveness): Fix photosensitivity text customization

## 3.0.23

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/react-liveness/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aws-amplify/ui-react-liveness",
"version": "3.0.23",
"version": "3.0.24",
"main": "dist/index.js",
"module": "dist/esm/index.mjs",
"exports": {
Expand Down Expand Up @@ -49,7 +49,7 @@
"dependencies": {
"@aws-amplify/ui": "6.0.16",
"@aws-amplify/ui-react": "6.1.12",
"@aws-sdk/client-rekognitionstreaming": "3.398.0",
"@aws-sdk/client-rekognitionstreaming": "3.600.0",
"@aws-sdk/util-format-url": "^3.410.0",
"@smithy/eventstream-serde-browser": "^2.0.4",
"@smithy/fetch-http-handler": "^2.1.3",
Expand Down Expand Up @@ -81,7 +81,7 @@
"name": "FaceLivenessDetector",
"path": "dist/esm/index.mjs",
"import": "{ FaceLivenessDetector }",
"limit": "280 kB"
"limit": "287 kB"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
IlluminationState,
LivenessErrorState,
} from '../../types';
import { SessionInformation } from '@aws-sdk/client-rekognitionstreaming';

const context = getMockContext();

Expand Down Expand Up @@ -314,7 +315,7 @@ describe('Liveness Helper', () => {
});

it('should work even if there are no color sequences', async () => {
const mockSessionInfo = {
const mockSessionInfo: SessionInformation = {
Challenge: {
FaceMovementAndLightChallenge: {
ChallengeConfig: {
Expand Down Expand Up @@ -347,7 +348,7 @@ describe('Liveness Helper', () => {
});

it('should not return values if color sequences do not contain durations', async () => {
const mockSessionInfo = {
const mockSessionInfo: SessionInformation = {
Challenge: {
FaceMovementAndLightChallenge: {
ChallengeConfig: {
Expand Down
Loading

0 comments on commit 99f9216

Please sign in to comment.