Skip to content

Commit

Permalink
Add support for FedCM, Passkey, and WebAuthn well-known files (#158)
Browse files Browse the repository at this point in the history
* updated /.well-known/assetlinks.json parsing

* updated /.well-known/assetlinks.json parsing and test URLs

* Update .markdown-lint.yml

* Update pull_request_template.md

* Update pull_request_template.md

* Update wpt-test.yml

* FedCM, passkey, Related Origin Requests

* Update dist/well-known.js

* Update .github/pull_request_template.md

* Restore example.com

* Update assetlink.json relation to check array to correctly reflect the setup.

* Restore test website example.com

* correct lint error for .github/pull_request_template.md

* Update /.well-known/web-identity error handling

* Update /.well-known/passkey-endpoints error handling

* Update /.well-known/webauthn error handling

* Removed redundant  properties

* Update responding with default results.

---------

Co-authored-by: Barry Pollard <[email protected]>
Co-authored-by: Barry Pollard <[email protected]>
  • Loading branch information
3 people authored Feb 11, 2025
1 parent 8750d94 commit c57d482
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions dist/well-known.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ return Promise.all([
let hasDeepLinking = false;
let hasCredentialSharing = false;
data.forEach(statement => {
if (statement.relation === 'delegate_permission/common.handle_all_urls') {
if (statement.relation.includes('delegate_permission/common.handle_all_urls')) {
hasDeepLinking = true;
} else if (statement.relation === 'delegate_permission/common.get_login_creds') {
}
if (statement.relation.includes('delegate_permission/common.get_login_creds')) {
hasCredentialSharing = true;
}
});
Expand All @@ -115,6 +116,57 @@ return Promise.all([
return data;
});
}),
// FedCM
parseResponse('/.well-known/web-identity', r => {
return r.text().then(text => {
let result = {
provider_urls: [],
accounts_endpoint: null,
login_url: null
};
try {
let data = JSON.parse(text);
result.provider_urls = Array.isArray(data.provider_urls) && data.provider_urls.length > 0 ? data.provider_urls : [];
result.accounts_endpoint = data.accounts_endpoint || null;
result.login_url = data.login_url || null;
} catch (e) {
// Failed to parse JSON
}
return result;
});
}),
// Passkey
parseResponse('/.well-known/passkey-endpoints', r => {
return r.text().then(text => {
let result = {
enroll: null,
manage: null
};
try {
let data = JSON.parse(text);
result.enroll = data.enroll || null;
result.manage = data.manage || null;
} catch (e) {
// Failed to parse JSON
}
return result;
});
}),
// Related Origin Requests
parseResponse('/.well-known/webauthn', r => {
return r.text().then(text => {
let result = {
origins: []
};
try {
let data = JSON.parse(text);
result.origins = Array.isArray(data.origins) && data.origins.length > 0 ? data.origins : [];
} catch (e) {
// Failed to parse JSON
}
return result;
});
}),
// security
parseResponse('/robots.txt', r => {
return r.text().then(text => {
Expand Down

0 comments on commit c57d482

Please sign in to comment.