chromium/third_party/blink/renderer/modules/smart_card/smart_card_connection.idl

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// https://wicg.github.io/web-smart-card/#smartcardconnection-interface

enum SmartCardDisposition {
  "leave",
  "reset",
  "unpower",
  "eject"
};

dictionary SmartCardTransactionOptions {
  AbortSignal signal;
};

dictionary SmartCardTransmitOptions {
  SmartCardProtocol protocol;
};

callback SmartCardTransactionCallback = Promise<SmartCardDisposition?> ();

[
  Exposed=Window,
  RuntimeEnabled=SmartCard,
  SecureContext,
  IsolatedContext
] interface SmartCardConnection {
  [CallWith=ScriptState, RaisesException]
  Promise<undefined> disconnect(optional SmartCardDisposition disposition = "leave");

  [CallWith=ScriptState, RaisesException]
  Promise<ArrayBuffer> transmit(BufferSource sendBuffer,
    optional SmartCardTransmitOptions options = {});

  [CallWith=ScriptState, RaisesException]
  Promise<SmartCardConnectionStatus> status();

  [CallWith=ScriptState, RaisesException]
  Promise<ArrayBuffer> control([EnforceRange] unsigned long controlCode,
      BufferSource data);

  [CallWith=ScriptState, RaisesException]
  Promise<ArrayBuffer> getAttribute([EnforceRange] unsigned long tag);

  [CallWith=ScriptState, RaisesException]
  Promise<undefined> setAttribute([EnforceRange] unsigned long tag,
      BufferSource value);

  [CallWith=ScriptState, RaisesException]
  Promise<undefined> startTransaction(SmartCardTransactionCallback transaction,
      optional SmartCardTransactionOptions options = {});
};