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

Add a disconnect method #515

Merged
merged 8 commits into from
Dec 1, 2023
Merged
Changes from 2 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
41 changes: 23 additions & 18 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -494,17 +494,21 @@ To <dfn>create a connection between the RP and the IdP account</dfn> given an
</div>

<div algorithm>
To <dfn>remove a connection</dfn> given |accountId|, |rpOrigin|, |idpOrigin|, run the following
steps. It returns whether a connection matching the |accountId| was found and removed:
1. If |accountId| is not failure:
1. Let |triple| be (|rpOrigin|, |idpOrigin|, |accountId|).
1. If [=connected accounts set=] [=list/contains=] |triple|:
1. [=list/Remove=] |triple| from the [=connected accounts set=].
1. Return true.
1. For every (|rp|, |idp|, |accountId|) |triple| in the [=connected accounts set=]:
To <dfn>remove the connection</dfn> given |accountId|, |rpOrigin|, and |idpOrigin|, run the
npm1 marked this conversation as resolved.
Show resolved Hide resolved
following steps. It returns whether the |accountId| connection was successfully removed.
1. Let |triple| be (|rpOrigin|, |idpOrigin|, |accountId|).
1. If [=connected accounts set=] [=list/contains=] |triple|:
1. [=list/Remove=] |triple| from the [=connected accounts set=].
1. Return true.
1. Return false.
</div>

<div algorithm>
To <dfn>remove all connections</dfn> given |rpOrigin| and |idpOrigin|, run the following steps:
npm1 marked this conversation as resolved.
Show resolved Hide resolved
npm1 marked this conversation as resolved.
Show resolved Hide resolved
1. For every (|rp|, |idp|, <var ignore="">accountId</var>) |triple| in the
[=connected accounts set=]:
1. If |rp| equals |rpOrigin| and |idp| equals |idpOrigin|, [=list/remove=] |triple| from the
[=connected accounts set=].
1. Return false.
</div>

<!-- ============================================================ -->
Expand Down Expand Up @@ -553,10 +557,6 @@ When the static {{IdentityCredential/disconnect}} method is invoked, given an
1. Let |document| be |globalObject|'s [=associated Document=].
1. If |document| is not [=allowed to use=] the [=identity-credentials-get=]
[=policy-controlled feature=], throw a "{{NotAllowedError}}" {{DOMException}}.
1. If any of the following members from |options| are empty, throw a new {{TypeError}}:
* {{IdentityProviderConfig/configURL}}
* {{IdentityProviderConfig/clientId}}
* {{IdentityCredentialDisconnectOptions/accountHint}}
1. Let |promise| be a new {{Promise}}.
1. [=In parallel=], [=attempt to disconnect=] given |options|, |promise|, and |globalObject|.
1. Return |promise|.
Expand Down Expand Up @@ -594,13 +594,18 @@ When asked to <dfn>attempt to disconnect</dfn> given an {{IdentityCredentialDisc
1. If |disconnectUrl| is failure, [=reject=] |promise| with a "{{NetworkError}}"
{{DOMException}}.
1. [=Send a disconnect request=] with |disconnectUrl|, |options|, and |globalObject|, and let
|accountId| be the result.
|result| be the result.
1. Let |idpOrigin| be the [=url/origin=] corresponding to |configUrl|.
1. Let |rpOrigin| be |globalObject|'s [=associated Document=]'s [=Document/origin=].
1. [=Remove a connection=] for |accountId|, |rpOrigin|, and |idpOrigin| and let |foundAccount|
be the result.
1. If |foundAccount|, [=resolve=] |promise|, otherwise [=reject=] |promise| with a
"{{NetworkError}}" {{DOMException}}.
1. If |result| is failure:
1. [=Remove all connections=] given |rpOrigin| and |idpOrigin|.
1. [=Reject=] |promise| with a "{{NetworkError}}" {{DOMException}}.
1. Return.
1. Let |accountId| be |result| (note that it is not failure).
1. [=Remove the connection=] given |accountId|, |rpOrigin|, and |idpOrigin| and let
npm1 marked this conversation as resolved.
Show resolved Hide resolved
|wasAccountRemoved| be the result.
1. If |wasAccountRemoved| is false, [=remove all connections=] given |rpOrigin| and |idpOrigin|.
1. [=Resolve=] |promise|.
</div>

<!-- ============================================================ -->
Expand Down
Loading