Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SmartCardConnection.getAttribute() algorithm #27

Merged
merged 1 commit into from
Sep 8, 2023
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
51 changes: 49 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1538,8 +1538,55 @@ <h3><dfn>control()</dfn> method</h3>
</section>
<section>
<h3><dfn>getAttribute()</dfn> method</h3>
<p>Queries a card reader's attribute or capability value, given its tag.</p>
<div class="issue">Write an algorithm for this method.</div>
<p>The {{SmartCardConnection/getAttribute(tag)}} method steps are:</p>
<ol>
<li>Let |promise:Promise| be [=a new promise=].</li>
<li>If
[=this=].{{SmartCardConnection/[[context]]}}.{{SmartCardContext/[[operationInProgress]]}}
is `true`, [=reject=] |promise| with a "{{InvalidStateError}}"
{{DOMException}} and return |promise|.</li>
<li>If [=this=].{{SmartCardConnection/[[comm]]}} is `null`, [=reject=]
|promise| with a "{{InvalidStateError}}" {{DOMException}} and return
|promise|.</li>
<li>Set
[=this=].{{SmartCardConnection/[[context]]}}.{{SmartCardContext/[[operationInProgress]]}}
to `true`.</li>
<li>Run the following steps [=in parallel=]:
<ol>
<li>Let |pcscTag:DWORD| be a [[PCSC5]] `DWORD` containing |tag|.</li>
<li>Let |buffer:array of BYTE| be a [[PCSC5]] `BYTE[]` large
enough to hold this reader attribute, as determined by the
platform's [[PCSC5]] implementation.</li>
<li>Call [=this=].{{SmartCardConnection/[[comm]]}}.`GetReaderCapabilities()`
with |pcscTag| and |buffer| as arguments.</li>
<li>Let |responseCode:RESPONSECODE| be the returned
`RESPONSECODE`.</li>
<li>[=Queue a global task=] on the [=relevant global object=] of
[=this=] using the [=smart card task source=] which performs the
following steps:
<ol>
<li>[=Clear the operationInProgress=] of
[=this=].{{SmartCardConnection/[[context]]}}.</li>
<li>If |responseCode| is not `SCARD_S_SUCCESS`, [=reject=]
|promise| with an [=exception=]
{{SmartCardError/corresponding}} to |responseCode| and abort
these steps.</li>
<li>Let |resultBytes:byte sequence| be the bytes of |buffer|
containing the attribute read.</li>
<li>[=Resolve=] |promise| with the result of
[=ArrayBuffer/Create|creating=] an {{ArrayBuffer}} from
|resultBytes| in [=this=]'s [=relevant Realm=].</li>
</ol>
</li>
</ol>
</li>
<li>Return |promise|.</li>
</ol>
<aside class="note" title="Output buffer size">
<p>Known [[PCSC5]] platform implementations allow either the output
buffer to be automatically allocated or to query the size needed for
it. This covers the gap left by [[PCSC5]] in that regard.</p>
</aside>
</section>
<section>
<h3><dfn>setAttribute()</dfn> method</h3>
Expand Down