{"action":"created","issue":{"url":"https://api.github.com/repos/w3c/webappsec/issues/274","labels_url":"https://api.github.com/repos/w3c/webappsec/issues/274/labels{/name}","comments_url":"https://api.github.com/repos/w3c/webappsec/issues/274/comments","events_url":"https://api.github.com/repos/w3c/webappsec/issues/274/events","html_url":"https://github.com/w3c/webappsec/issues/274","id":69124116,"number":274,"title":"CREDENTIAL: Use a generic matching algorithm that would work for custom Credentials types","user":{"login":"adrianhopebailie","id":49902,"avatar_url":"https://avatars.githubusercontent.com/u/49902?v=3","gravatar_id":"","url":"https://api.github.com/users/adrianhopebailie","html_url":"https://github.com/adrianhopebailie","followers_url":"https://api.github.com/users/adrianhopebailie/followers","following_url":"https://api.github.com/users/adrianhopebailie/following{/other_user}","gists_url":"https://api.github.com/users/adrianhopebailie/gists{/gist_id}","starred_url":"https://api.github.com/users/adrianhopebailie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adrianhopebailie/subscriptions","organizations_url":"https://api.github.com/users/adrianhopebailie/orgs","repos_url":"https://api.github.com/users/adrianhopebailie/repos","events_url":"https://api.github.com/users/adrianhopebailie/events{/privacy}","received_events_url":"https://api.github.com/users/adrianhopebailie/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/w3c/webappsec/labels/CREDENTIAL","name":"CREDENTIAL","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/w3c/webappsec/milestones/6","html_url":"https://github.com/w3c/webappsec/milestones/CREDENTIALS:%20Level%201","labels_url":"https://api.github.com/repos/w3c/webappsec/milestones/6/labels","id":1070411,"number":6,"title":"CREDENTIALS: Level 1","description":"","creator":{"login":"mikewest","id":1497,"avatar_url":"https://avatars.githubusercontent.com/u/1497?v=3","gravatar_id":"","url":"https://api.github.com/users/mikewest","html_url":"https://github.com/mikewest","followers_url":"https://api.github.com/users/mikewest/followers","following_url":"https://api.github.com/users/mikewest/following{/other_user}","gists_url":"https://api.github.com/users/mikewest/gists{/gist_id}","starred_url":"https://api.github.com/users/mikewest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikewest/subscriptions","organizations_url":"https://api.github.com/users/mikewest/orgs","repos_url":"https://api.github.com/users/mikewest/repos","events_url":"https://api.github.com/users/mikewest/events{/privacy}","received_events_url":"https://api.github.com/users/mikewest/received_events","type":"User","site_admin":false},"open_issues":11,"closed_issues":23,"state":"open","created_at":"2015-04-16T09:56:59Z","updated_at":"2015-04-21T11:31:03Z","due_on":null,"closed_at":null},"comments":12,"created_at":"2015-04-17T11:50:08Z","updated_at":"2015-04-21T14:03:43Z","closed_at":null,"body":"The spec defines custom matching algorithms for the different sub-classes of `Credential`. If this could be restructured into a single-generic algorithm it could be used for custom sub-classes of `Credential`.\r\n\r\nPossible use-case illustrated below but suggests that `options` could be elevated/merged to the parent as `types` is also just a filter OR `type` could be a property of `options`.\r\n\r\nMatching algorithm would be something like:\r\n*For each property of `options` eliminate all possible credentials where the `Credential` has a property with the same name and the value is not in the set of values provided.*\r\n\r\n```javascript\r\n//Store a FederatedCredential\r\nnavigator.credentials.store(\r\n  new FederatedCredential({\r\n    \"id\": \"username\",\r\n    \"federation\": \"https://federation.com\"\r\n  })\r\n);\r\n\r\n//Get a FederatedCredential filtered on the 'federation' property\r\nnavigator.credentials.get({\r\n  \"types\": [ \"FederatedCredential\" ],\r\n  \"options\": {\r\n      \"federation\": [ \"https://federation.com\" ] //NOTE: This is no-longer called 'federations'\r\n  }\r\n});\r\n\r\n// Assume we have defined an AgeVerificationCredential class which extends Credential\r\n//  and defines it's type to be \"ageVerification\". There are some extra properties we might use\r\n//  to do things like verification that are out of scope of this API\r\n\r\n//Store a custom credential\r\nnavigator.credentials.store(\r\n  new AgeVerificationCredential({\r\n    \"id\": \"person_12345_age\",\r\n    \"isOlderThan18\": true,\r\n    \"isOlderThan21\": true,\r\n    \"issuer\": \"http://credentialissuer.com\",\r\n    \"signature\": { ... },\r\n  })\r\n);\r\n\r\n//Get this custom credential filtered on some properties specific to this credential type\r\nnavigator.credentials.get({\r\n  \"types\": [ \"ageVerification\" ],\r\n  \"options\": {\r\n      \"isOlderThan18\" : [ true ],\r\n      \"issuer\" : [ \"http://credentialissuer.com\", \"http://othertrustedissuer.com\" ]\r\n  }\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/w3c/webappsec/issues/comments/94805780","html_url":"https://github.com/w3c/webappsec/issues/274#issuecomment-94805780","issue_url":"https://api.github.com/repos/w3c/webappsec/issues/274","id":94805780,"user":{"login":"mikewest","id":1497,"avatar_url":"https://avatars.githubusercontent.com/u/1497?v=3","gravatar_id":"","url":"https://api.github.com/users/mikewest","html_url":"https://github.com/mikewest","followers_url":"https://api.github.com/users/mikewest/followers","following_url":"https://api.github.com/users/mikewest/following{/other_user}","gists_url":"https://api.github.com/users/mikewest/gists{/gist_id}","starred_url":"https://api.github.com/users/mikewest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikewest/subscriptions","organizations_url":"https://api.github.com/users/mikewest/orgs","repos_url":"https://api.github.com/users/mikewest/repos","events_url":"https://api.github.com/users/mikewest/events{/privacy}","received_events_url":"https://api.github.com/users/mikewest/received_events","type":"User","site_admin":false},"created_at":"2015-04-21T14:03:43Z","updated_at":"2015-04-21T14:03:43Z","body":"*shrug* Perhaps I'm overestimating the complexity.\r\n\r\nWhat, concretely, would you like to see added to the spec?"}}