Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions digital-credentials/support/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,6 @@
* @typedef {GetProtocol | CreateProtocol} Protocol
*/

/** @type {GetProtocol[]} */
const GET_PROTOCOLS = /** @type {const} */ ([
"openid4vp-v1-unsigned",
"openid4vp-v1-signed",
"openid4vp-v1-multisigned",
"org-iso-mdoc",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still love to have test coverage for those
But I will add follow-up PR that adds dedicated tests then!

]);

/** @type {CreateProtocol[]} */
const CREATE_PROTOCOLS = /** @type {const} */ (["openid4vci"]);

const SUPPORTED_GET_PROTOCOL = GET_PROTOCOLS.find((protocol) =>
DigitalCredential.userAgentAllowsProtocol(protocol)
);
const SUPPORTED_CREATE_PROTOCOL = CREATE_PROTOCOLS.find((protocol) =>
DigitalCredential.userAgentAllowsProtocol(protocol)
);

/** @type {Record<Protocol, object | MobileDocumentRequest>} */
const CANONICAL_REQUEST_OBJECTS = {
openid4vci: {
Expand Down Expand Up @@ -174,8 +156,9 @@ function makeCredentialOptionsFromConfig(config, mapping) {
* @returns {CredentialRequestOptions}
*/
export function makeGetOptions(config = {}) {
/** @type {MakeGetOptionsConfig} */
const configWithDefaults = {
protocol: SUPPORTED_GET_PROTOCOL,
protocol: ["openid4vp-v1-unsigned", "org-iso-mdoc"],
...config,
};

Expand All @@ -191,8 +174,9 @@ export function makeGetOptions(config = {}) {
* @returns {CredentialCreationOptions}
*/
export function makeCreateOptions(config = {}) {
/** @type {MakeCreateOptionsConfig} */
const configWithDefaults = {
protocol: SUPPORTED_CREATE_PROTOCOL,
protocol: "openid4vci",
...config,
};

Expand Down