Skip to content

Commit

Permalink
Merge pull request #571 from twilio-labs/passkeys-env-variables
Browse files Browse the repository at this point in the history
(passkeys-backend) Change RELYING_PARTY to DOMAIN_NAME to use build in function context
  • Loading branch information
robinske authored Sep 26, 2024
2 parents 8bc9426 + 2082499 commit 910372c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
5 changes: 0 additions & 5 deletions passkeys-backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
# required: true
API_URL=

# description: The domain of the relying party
# format: url
# required: true
RELYING_PARTY=

# description: The domain of the adroid identity provider
# format: list(text)
# required: false
Expand Down
4 changes: 2 additions & 2 deletions passkeys-backend/functions/authentication/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const axios = require('axios');

// eslint-disable-next-line consistent-return
exports.handler = async (context, _, callback) => {
const { RELYING_PARTY, API_URL } = context;
const { DOMAIN_NAME, API_URL } = context;

const response = new Twilio.Response();
response.appendHeader('Content-Type', 'application/json');
Expand All @@ -12,7 +12,7 @@ exports.handler = async (context, _, callback) => {
const requestBody = {
content: {
// eslint-disable-next-line camelcase
rp_id: RELYING_PARTY,
rp_id: DOMAIN_NAME,
},
};

Expand Down
6 changes: 3 additions & 3 deletions passkeys-backend/functions/registration/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const assets = Runtime.getAssets();
const { detectMissingParams } = require(assets['/services/helpers.js'].path);

exports.handler = async (context, event, callback) => {
const { RELYING_PARTY, API_URL, ANDROID_APP_KEYS } = context;
const { DOMAIN_NAME, API_URL, ANDROID_APP_KEYS } = context;

const response = new Twilio.Response();
response.appendHeader('Content-Type', 'application/json');
Expand All @@ -31,10 +31,10 @@ exports.handler = async (context, event, callback) => {
},
content: {
relying_party: {
id: RELYING_PARTY,
id: DOMAIN_NAME,
name: 'PasskeySample',
origins: [
`https://${RELYING_PARTY}`,
`https://${DOMAIN_NAME}`,
...(ANDROID_APP_KEYS?.split(',') ?? []),
],
},
Expand Down
4 changes: 2 additions & 2 deletions passkeys-backend/tests/registration-start.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jest.mock('axios');

const mockContext = {
API_URL: 'https://api.com',
RELYING_PARTY: 'example.com',
DOMAIN_NAME: 'example.com',
ANDROID_APP_KEYS: 'key1,key2,key3',
getTwilioClient: () => ({
username: 'mockUsername',
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('registration/start', () => {

const mockContextWithoutAndroidKeys = {
API_URL: 'https://api.com',
RELYING_PARTY: 'example.com',
DOMAIN_NAME: 'example.com',
getTwilioClient: () => ({
username: 'mockUsername',
password: 'mockPassword',
Expand Down

0 comments on commit 910372c

Please sign in to comment.