From c951e307c2bfac19fc2023903b87d51d1aafd2a8 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Thu, 9 Jan 2025 12:19:11 +1100 Subject: [PATCH 1/6] Digital Credentials: Rename DigitalCredentialsRequest to DigitalCredentialRequest --- digital-credentials/dc-types.ts | 8 ++--- digital-credentials/support/helper.js | 42 +++++++++++++-------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/digital-credentials/dc-types.ts b/digital-credentials/dc-types.ts index 6ea100c6727d6d..8c1cf31d035a7b 100644 --- a/digital-credentials/dc-types.ts +++ b/digital-credentials/dc-types.ts @@ -6,11 +6,11 @@ export type CredentialMediationRequirement = | "silent"; /** - * @see https://wicg.github.io/digital-credentials/#dom-identityrequestprovider + * @see https://wicg.github.io/digital-credentials/#dom-digitalcredentialrequest */ -export interface IdentityRequestProvider { +export interface DigitalCredentialRequest { protocol: string; - request: object; + data: object; } /** @@ -20,7 +20,7 @@ export interface DigitalCredentialRequestOptions { /** * The list of identity request providers */ - providers: IdentityRequestProvider[] | any; + requests: DigitalCredentialRequest[] | any; } /** diff --git a/digital-credentials/support/helper.js b/digital-credentials/support/helper.js index 0b71ae9822a727..96373a96d09f1d 100644 --- a/digital-credentials/support/helper.js +++ b/digital-credentials/support/helper.js @@ -2,60 +2,60 @@ // Import the types from the TypeScript file /** * @typedef {import('../dc-types').ProviderType} ProviderType - * @typedef {import('../dc-types').IdentityRequestProvider} IdentityRequestProvider + * @typedef {import('../dc-types').DigitalCredentialRequest} DigitalCredentialRequest * @typedef {import('../dc-types').DigitalCredentialRequestOptions} DigitalCredentialRequestOptions * @typedef {import('../dc-types').CredentialRequestOptions} CredentialRequestOptions * @typedef {import('../dc-types').SendMessageData} SendMessageData */ /** - * @param {ProviderType | ProviderType[]} [providersToUse=["default"]] + * @param {ProviderType | ProviderType[]} [requestsToUse=["default"]] * @param {CredentialMediationRequirement} [mediation="required"] * @returns {CredentialRequestOptions} */ -export function makeGetOptions(providersToUse, mediation = "required") { - if (typeof providersToUse === "string") { - if (providersToUse === "default" || providersToUse === "openid4vp"){ - return makeGetOptions([providersToUse], mediation); +export function makeGetOptions(requestsToUse, mediation = "required") { + if (typeof requestsToUse === "string") { + if (requestsToUse === "default" || requestsToUse === "openid4vp") { + return makeGetOptions([requestsToUse], mediation); } } - if (!Array.isArray(providersToUse) || !providersToUse?.length) { - return { digital: { providers: providersToUse }, mediation }; + if (!Array.isArray(requestsToUse) || !requestsToUse?.length) { + return { digital: { requests: requestsToUse }, mediation }; } - const providers = []; - for (const provider of providersToUse) { - switch (provider) { + const requests = []; + for (const request of requestsToUse) { + switch (request) { case "openid4vp": - providers.push(makeOID4VPDict()); + requests.push(makeOID4VPDict()); break; case "default": - providers.push(makeIdentityRequestProvider(undefined, undefined)); + requests.push(makeDigitalCredentialRequest(undefined, undefined)); break; default: - throw new Error(`Unknown provider type: ${provider}`); + throw new Error(`Unknown provider type: ${request}`); } } - return { digital: { providers }, mediation }; + return { digital: { requests }, mediation }; } /** * * @param {string} protocol - * @param {object} request - * @returns {IdentityRequestProvider} + * @param {object} data + * @returns {DigitalCredentialRequest} */ -function makeIdentityRequestProvider(protocol = "protocol", request = {}) { +function makeDigitalCredentialRequest(protocol = "protocol", data = {}) { return { protocol, - request, + data, }; } /** * Representation of a digital identity object with an OpenID4VP provider. * - * @returns {IdentityRequestProvider} + * @returns {DigitalCredentialRequest} **/ function makeOID4VPDict() { - return makeIdentityRequestProvider("openid4vp", { + return makeDigitalCredentialRequest("openid4vp", { // Canonical example of an OpenID4VP request coming soon. }); } From f93aa40bdb9a114905ee22f1c98d4e15bdf79307 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Thu, 9 Jan 2025 14:37:39 +1100 Subject: [PATCH 2/6] Fixup .requests and whitespace --- digital-credentials/allow-attribute.https.html | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/digital-credentials/allow-attribute.https.html b/digital-credentials/allow-attribute.https.html index d988e94cd23547..1b0c6e721047e7 100644 --- a/digital-credentials/allow-attribute.https.html +++ b/digital-credentials/allow-attribute.https.html @@ -105,7 +105,7 @@ const options = { digital: { // Results in TypeError when allowed, NotAllowedError when disallowed - providers: [], + requests: [], }, }; const { data } = await new Promise((resolve) => { @@ -118,14 +118,15 @@ ); }); const { name, message } = data; + const fullMessage = `${iframe.outerHTML} - ${message}`; if (expectIsAllowed) { - assert_true(name == "TypeError" || - (name == "NotAllowedError" && message.includes("transient activation")), - `${iframe.outerHTML} - ${message}`); + assert_true( + name == "TypeError" || (name == "NotAllowedError" && message.includes("transient activation")), + fullMessage + ); } else { - assert_equals(name, "NotAllowedError", `${iframe.outerHTML} - ${message}`); - assert_false(message.includes("transient activation"), - `${iframe.outerHTML} - ${message}`); + assert_equals(name, "NotAllowedError", `${iframe.outerHTML} - ${message}`); + assert_false(message.includes("transient activation"), fullMessage); } iframe.remove(); }, `Policy to use: ${details.policy}, is cross-origin: ${details.crossOrigin}, is allowed by policy: ${details.expectIsAllowed}`); From fd7b0de1938f9ed8abe3974803ddd2196c5880f0 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Thu, 9 Jan 2025 15:01:18 +1100 Subject: [PATCH 3/6] few more fixes --- digital-credentials/allow-attribute.https.html | 1 + digital-credentials/dc-types.ts | 4 ++-- digital-credentials/support/helper.js | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/digital-credentials/allow-attribute.https.html b/digital-credentials/allow-attribute.https.html index 1b0c6e721047e7..f977e941199177 100644 --- a/digital-credentials/allow-attribute.https.html +++ b/digital-credentials/allow-attribute.https.html @@ -107,6 +107,7 @@ // Results in TypeError when allowed, NotAllowedError when disallowed requests: [], }, + mediation: "required", }; const { data } = await new Promise((resolve) => { window.addEventListener("message", resolve, { diff --git a/digital-credentials/dc-types.ts b/digital-credentials/dc-types.ts index 8c1cf31d035a7b..70826db8d04263 100644 --- a/digital-credentials/dc-types.ts +++ b/digital-credentials/dc-types.ts @@ -18,13 +18,13 @@ export interface DigitalCredentialRequest { */ export interface DigitalCredentialRequestOptions { /** - * The list of identity request providers + * The list of credential requests. */ requests: DigitalCredentialRequest[] | any; } /** - * @see https://wicg.github.io/digital-credentials/#extensions-to-credentialrequestoptions-dictionary + * @see https://wicg.github.io/digital-credentials/#extensions-to-credentialrequestoptions */ export interface CredentialRequestOptions { /** diff --git a/digital-credentials/support/helper.js b/digital-credentials/support/helper.js index 96373a96d09f1d..fb96547a1b4b01 100644 --- a/digital-credentials/support/helper.js +++ b/digital-credentials/support/helper.js @@ -31,7 +31,7 @@ export function makeGetOptions(requestsToUse, mediation = "required") { requests.push(makeDigitalCredentialRequest(undefined, undefined)); break; default: - throw new Error(`Unknown provider type: ${request}`); + throw new Error(`Unknown request type: ${request}`); } } return { digital: { requests }, mediation }; @@ -50,7 +50,7 @@ function makeDigitalCredentialRequest(protocol = "protocol", data = {}) { } /** - * Representation of a digital identity object with an OpenID4VP provider. + * Representation of an OpenID4VP request. * * @returns {DigitalCredentialRequest} **/ From cd79237001f65307079d71226122343bb85cf891 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Thu, 9 Jan 2025 16:21:16 +1100 Subject: [PATCH 4/6] Remove message check - not interoperable --- digital-credentials/allow-attribute.https.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/digital-credentials/allow-attribute.https.html b/digital-credentials/allow-attribute.https.html index f977e941199177..667b84bc704c23 100644 --- a/digital-credentials/allow-attribute.https.html +++ b/digital-credentials/allow-attribute.https.html @@ -122,12 +122,11 @@ const fullMessage = `${iframe.outerHTML} - ${message}`; if (expectIsAllowed) { assert_true( - name == "TypeError" || (name == "NotAllowedError" && message.includes("transient activation")), + name == "TypeError" || name == "NotAllowedError", fullMessage ); } else { - assert_equals(name, "NotAllowedError", `${iframe.outerHTML} - ${message}`); - assert_false(message.includes("transient activation"), fullMessage); + assert_equals(name, "NotAllowedError", fullMessage); } iframe.remove(); }, `Policy to use: ${details.policy}, is cross-origin: ${details.crossOrigin}, is allowed by policy: ${details.expectIsAllowed}`); From c8a974e37524b74f093122c69a52f933a3d82730 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Thu, 9 Jan 2025 16:25:46 +1100 Subject: [PATCH 5/6] use location instead... less noisy --- digital-credentials/allow-attribute.https.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/digital-credentials/allow-attribute.https.html b/digital-credentials/allow-attribute.https.html index 667b84bc704c23..a6cee8cd94ac83 100644 --- a/digital-credentials/allow-attribute.https.html +++ b/digital-credentials/allow-attribute.https.html @@ -119,7 +119,7 @@ ); }); const { name, message } = data; - const fullMessage = `${iframe.outerHTML} - ${message}`; + const fullMessage = `${iframe.location} - ${message}`; if (expectIsAllowed) { assert_true( name == "TypeError" || name == "NotAllowedError", From a8a9378fb5c0bc409861318c5194525e3447d3a8 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Fri, 10 Jan 2025 17:39:27 +1100 Subject: [PATCH 6/6] Use outerHTML instead of message. --- digital-credentials/allow-attribute.https.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/digital-credentials/allow-attribute.https.html b/digital-credentials/allow-attribute.https.html index a6cee8cd94ac83..667b84bc704c23 100644 --- a/digital-credentials/allow-attribute.https.html +++ b/digital-credentials/allow-attribute.https.html @@ -119,7 +119,7 @@ ); }); const { name, message } = data; - const fullMessage = `${iframe.location} - ${message}`; + const fullMessage = `${iframe.outerHTML} - ${message}`; if (expectIsAllowed) { assert_true( name == "TypeError" || name == "NotAllowedError",