Skip to content

Commit 00dd7af

Browse files
authored
Merge pull request #277 from aykutbulut/fix_fetch_api
Update fetch API in explainer
2 parents 676d852 + 83aa022 commit 00dd7af

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

README.md

+10-15
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,8 @@ When an `issuer.example` context wants to provide tokens to a user (i.e. when th
6464
```
6565
fetch('<issuer>/<issuance path>', {
6666
privateToken: {
67-
type: 'private-state-token',
6867
version: 1,
69-
operation: 'token-request',
70-
issuer: <issuer>
68+
operation: 'token-request'
7169
}
7270
}).then(...)
7371
```
@@ -88,7 +86,7 @@ When the user is browsing another site (```publisher.example```), that site (or
8886

8987

9088
```
91-
document.hasPrivateToken(<issuer>, 'private-state-token')
89+
document.hasPrivateToken(<issuer>)
9290
```
9391

9492

@@ -98,11 +96,9 @@ This returns whether there are any valid private state tokens for a particular i
9896
```
9997
fetch('<issuer>/<redemption path>', {
10098
privateToken: {
101-
type: 'private-state-token',
10299
version: 1,
103100
operation: 'token-redemption',
104-
issuer: <issuer>,
105-
refreshPolicy: {'none', 'refresh'}
101+
refreshPolicy: 'refresh' // either 'refresh' or 'none', default is 'none'
106102
}
107103
}).then(...)
108104
```
@@ -115,7 +111,7 @@ The RR is HTTP-only and JavaScript is only able to access/send the RR via Privat
115111
UA stores the RR obtained from the initial redemption. A publisher site can query whether a valid RR exists for a specific issuer using the following method.
116112

117113
```
118-
document.hasRedemptionRecord(<issuer>, 'private-state-token')
114+
document.hasRedemptionRecord(<issuer>)
119115
```
120116

121117
This returns whether there are any valid RRs from the given issuer.
@@ -133,7 +129,6 @@ Redemption Records are only accessible via a new option to the Fetch API:
133129
fetch(<resource-url>, {
134130
...
135131
privateToken: {
136-
type: 'private-state-token',
137132
version: 1,
138133
operation: 'send-redemption-record',
139134
issuers: [<issuer>, ...]
@@ -148,9 +143,9 @@ The RRs will be added as a new request header `Sec-Redemption-Record`. The heade
148143

149144
### Extension: Private State Token Versioning
150145

151-
In order to allow multiple versions of Private State Token to be supported in the ecosystem, issuers include the version of the protocol (i.e. "PrivateStateTokenV1") in their key commitments via the ```protocol_version``` field, and that is included in Private State Token requests via the ```Sec-Private-State-Token-Version``` header. Private State Token operations should not be performed with issuers configured with an unknown protocol version.
146+
In order to allow multiple versions of Private State Token to be supported in the ecosystem, issuers include the version of the protocol (i.e. "PrivateStateTokenV1") in their key commitments via the ```protocol_version``` field, and that is included in Private State Token requests via the ```Sec-Private-State-Token-Crypto-Version``` header. Private State Token operations should not be performed with issuers configured with an unknown protocol version.
152147

153-
In addition to the core cryptographic layer, signed requests' formats (see the next section) might change from version to version. In order to make adapting to these changes easier, we could employ a mechanism like the ```Sec-Private-State-Token-Version``` header, or an addition to the requests' payloads, to tell consumers the version of the client that generated the request.
148+
In addition to the core cryptographic layer, signed requests' formats (see the next section) might change from version to version. In order to make adapting to these changes easier, we could employ a mechanism like the ```Sec-Private-State-Token-Crypto-Version``` header, or an addition to the requests' payloads, to tell consumers the version of the client that generated the request.
154149

155150

156151
### Extension: Metadata
@@ -170,7 +165,7 @@ This can be managed by assigning different keys in the key commitment to have di
170165

171166
### Extension: iframe Activation
172167

173-
Some resources requests are performed via iframes or other non-Fetch-based methods. One extension to support such use cases would be the addition of a `privateToken` attribute to iframes that includes the parameters specified in the Fetch API. This would allow an RR to be sent with an iframe by setting an attribute of `privateToken="{type:'private-state-token',version:1,operation:'send-redemption-record',issuer:<issuer>,refreshPolicy:'refresh'}"`.
168+
Some resources requests are performed via iframes or other non-Fetch-based methods. One extension to support such use cases would be the addition of a `privateToken` attribute to iframes that includes the parameters specified in the Fetch API. This would allow an RR to be sent with an iframe by setting an attribute of `privateToken="{version:1,operation:'send-redemption-record',issuers:[<issuer>]}"`.
174169

175170
## Privacy Considerations
176171

@@ -280,14 +275,14 @@ foo.example - Site requiring a Private State Token to prove the user is trusted.
280275

281276

282277
1. User visits `areyouahuman.example`.
283-
1. `areyouahuman.example` verifies the user is a human, and calls `fetch('areyouahuman.example/get-human-tokens', {privateToken: {type: 'private-state-token', version: 1, operation: 'token-request', issuer: 'areyouahuman.example'}})`.
278+
1. `areyouahuman.example` verifies the user is a human, and calls `fetch('areyouahuman.example/get-human-tokens', {privateToken: {version: 1, operation: 'token-request'}})`.
284279
1. The browser stores the trust tokens associated with `areyouahuman.example`.
285280
1. Sometime later, the user visits `coolwebsite.example`.
286-
1. `coolwebsite.example` wants to know if the user is a human, by asking `areyouahuman.example` that question, by calling `fetch('areyouahuman.example/redeem-human-token', {privateToken: {type: 'private-state-token', version: 1, operation: 'token-redemption', issuer: 'areyouahuman.example'}})`.
281+
1. `coolwebsite.example` wants to know if the user is a human, by asking `areyouahuman.example` that question, by calling `fetch('areyouahuman.example/redeem-human-token', {privateToken: {version: 1, operation: 'token-redemption'}})`.
287282
1. The browser requests a redemption.
288283
1. The issuer returns an RR (this indicates that `areyouahuman.example` at some point issued a valid token to this browser).
289284
1. When the promise returned by the method resolves, the RR can be used in subsequent resource requests.
290-
1. Script running code in the top level `coolwebsite.example` document can call `fetch('foo.example/get-content', {privateToken: {type: 'private-state-token', version: 1, operation: 'send-redemption-record', issuer: 'areyouahuman.example'}})`
285+
1. Script running code in the top level `coolwebsite.example` document can call `fetch('foo.example/get-content', {privateToken: {version: 1, operation: 'send-redemption-record', issuers: ['https://areyouahuman.example']}})`
291286
1. The third-party receives the RR, and now has some indication that `areyouahuman.example` thought this user was a human.
292287
1. The third-party responds to this fetch request based on that fact.
293288

0 commit comments

Comments
 (0)