Skip to content

Commit

Permalink
chore: update liveness streaming client (#855)
Browse files Browse the repository at this point in the history
* chore: update liveness streaming client

* chore: remove CA install step
  • Loading branch information
thaddmt committed Apr 7, 2023
1 parent a0f6956 commit 2d48c8d
Show file tree
Hide file tree
Showing 4 changed files with 639 additions and 270 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/liveness-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,15 @@ jobs:
repository: ${{github.event.pull_request.head.repo.full_name}}
persist-credentials: false

- name: Configure CodeArtifact
id: configure-codeartifact
uses: ./.github/actions/codeartifact-action
with:
role-to-assume: ${{ secrets.LIVENESS_DEPLOYMENT_ROLE }}
domain: amplify-ui-liveness
repository: amplify-ui

- name: Setup Node.js 16
uses: actions/setup-node@v2
with:
node-version: 16
cache: 'yarn'
registry-url: ${{ steps.configure-codeartifact.outputs.repository-endpoint }}
always-auth: true

- name: Install packages
run: yarn --frozen-lockfile --prefer-offline
env:
NODE_AUTH_TOKEN: ${{ steps.configure-codeartifact.outputs.repository-token }}

- name: Build ui package
run: yarn ui build
Expand Down Expand Up @@ -119,20 +108,11 @@ jobs:
repository: ${{github.event.pull_request.head.repo.full_name}}
persist-credentials: false

- name: Configure CodeArtifact
id: configure-codeartifact
uses: ./.github/actions/codeartifact-action
with:
role-to-assume: ${{ secrets.LIVENESS_DEPLOYMENT_ROLE }}
domain: amplify-ui-liveness
repository: amplify-ui

- name: Setup Node.js 16
uses: actions/setup-node@v2
with:
node-version: 16
cache: 'yarn'
registry-url: ${{ steps.configure-codeartifact.outputs.repository-endpoint }}
always-auth: true

- name: Restore node_modules cache
Expand All @@ -154,8 +134,6 @@ jobs:
- name: Install packages
if: steps.restore-cache.outputs.cache-hit != 'true'
run: yarn --frozen-lockfile --prefer-offline --prefer-offline
env:
NODE_AUTH_TOKEN: ${{ steps.configure-codeartifact.outputs.repository-token }}

- name: Build ui package
if: ${{ steps.restore-ui-cache.outputs.cache-hit != 'true' && matrix.package != 'ui' }}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-liveness/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"dependencies": {
"@aws-amplify/ui": "5.5.7",
"@aws-amplify/ui-react": "^4.5.1",
"@aws-sdk/client-rekognitionstreaming": "^3.306.0",
"@aws-sdk/client-rekognitionstreaming": "3.309.0",
"@tensorflow-models/blazeface": "0.0.7",
"@tensorflow/tfjs-backend-cpu": "3.11.0",
"@tensorflow/tfjs-backend-wasm": "3.11.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ClientSessionInformationEvent,
LivenessResponseStream,
RekognitionStreamingClient,
RekognitionStreamingClientConfig,
StartFaceLivenessSessionCommand,
} from '@aws-sdk/client-rekognitionstreaming';
import { VideoRecorder } from './videoRecorder';
Expand All @@ -25,10 +26,7 @@ export interface Credentials {
sessionToken: string;
}

// FIXME: default endpoint to prod for now, remove this when sdk has the proper endpoints setup
const ENDPOINT =
process.env.NEXT_PUBLIC_STREAMING_API_URL ??
'wss://streaming-rekognition.us-east-1.amazonaws.com:443';
const ENDPOINT = process.env.NEXT_PUBLIC_STREAMING_API_URL;
export const TIME_SLICE = 1000;

function isBlob(obj: unknown): obj is Blob {
Expand Down Expand Up @@ -115,15 +113,20 @@ export class LivenessStreamProvider extends AmazonAIInterpretPredictionsProvider
throw new Error('No credentials');
}

this._client = new RekognitionStreamingClient({
const clientconfig: RekognitionStreamingClientConfig = {
credentials,
endpointProvider: () => {
const url = new URL(ENDPOINT);
return { url };
},
region: this.region,
customUserAgent: getAmplifyUserAgent(),
});
};

if (ENDPOINT) {
clientconfig.endpointProvider = () => {
const url = new URL(ENDPOINT);
return { url };
};
}

this._client = new RekognitionStreamingClient(clientconfig);

this.responseStream = await this.startLivenessVideoConnection();
}
Expand Down
Loading

0 comments on commit 2d48c8d

Please sign in to comment.