Skip to content

Commit 441bb43

Browse files
fboemerAkshay Wadia
andauthored
Adding Documentation for NEURLFilter (#83)
* Adding Documentation for NEURLFilter --------- Co-authored-by: Akshay Wadia <awadia@apple.com>
1 parent 4ff41ab commit 441bb43

File tree

10 files changed

+315
-58
lines changed

10 files changed

+315
-58
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ callers and display identity information on the incoming call screen.
1111
<img alt="Overview of the Live Caller ID Lookup" src="https://github.com/apple/pir-service-example/raw/main/Sources/PIRService/PIRService.docc/Resources/overview@2x.png">
1212
</picture>
1313

14-
This repository provides a functional server backend to test the Live Caller ID Lookup feature.
14+
[NEURLFilter](https://developer.apple.com/documentation/networkextension/neurlfiltermanager) is a new feature for iOS and MacOS that allows the system
15+
to communicate with a third party service to privately check if a requested URL should be allowed or not. This allows your app to implement URL filtering in a privacy preserving manner.
16+
17+
This repository provides a functional server backend to test the Live Caller ID Lookup and NEURLFilter features.
1518

1619
> [!WARNING]
1720
> While functional, this is just an example service and should not be run in production.

Sources/PIRService/PIRService.docc/Authentication.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ that different level of details can be provided based on the user tier.
2424
7. The system does not know which user tier is associated with which public key, so it sends the User Token to the
2525
authentication server.
2626
8. Authentication server verifies the User Token and returns the public key that is associated with the User Tier. The
27-
system verifies that the returned public key is present in the Token Issuer Directory and it is valid based in the
27+
system verifies that the returned public key is present in the Token Issuer Directory and it is valid based on the
2828
current time.
2929
9. The system constructs a Privacy Pass token request using the specific public key. The token request is sent along
3030
with the User Token to the authentication server.
@@ -33,7 +33,7 @@ that different level of details can be provided based on the user tier.
3333
* the token request uses the public key that is associated with the right user tier,
3434

3535
and issues the token response that the system uses to get a Privacy Pass token.
36-
11. When a PIR request is made, the system attached an unused Privacy Pass token to the request. The PIR node can use
36+
11. When a PIR request is made, the system attaches an unused Privacy Pass token to the request. The PIR node can use
3737
the public key to verify that the token is valid and that assures that the request is authorized.
3838
12. Response to the PIR request is returned to the system.
3939

Sources/PIRService/PIRService.docc/CommonErrors.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Learn about the common errors that the device logs and why they happen.
44

55
## Overview
66

7-
While using the example service or when developing your own service, you will most probably encounter one of the errors
8-
that will be listed below. This page gives more details about the errors, like why they happen, what they mean, and how
7+
While using the example service or when developing your own service, you may encounter one of the common errors
8+
listed below. This page gives more details about these errors, like why they happen, what they mean, and how
99
to work around them.
1010

1111
### How to look for errors
@@ -20,7 +20,7 @@ You can use the Console app to see on-device logs. Search for error messages fro
2020

2121
```
2222
"The request timed out." UserInfo={NSLocalizedDescription=The request timed out.,
23-
NSErrorFailingURLKey=http://MacBook-Pro.local:8080/.well-known/private-token-issuer-director
23+
NSErrorFailingURLKey=http://MacBook-Pro.local:8080/.well-known/private-token-issuer-directory
2424
```
2525

2626
**Reason:**
@@ -69,11 +69,16 @@ Device issued a request to the configuration endpoint (`/config`), but did not f
6969
was looking for.
7070

7171
**Workaround:**
72-
Double-check that the service has usecases configured the way the device expects them. Usecase names should be:
73-
* `<bundleIdentifier>.block`
74-
* `<bundleIdentifier>.identity`
72+
Double-check that the service has usecases configured the way the device expects them. Usecase names for Live Caller ID Lookup should be:
73+
* `<app_extension_bundle_identifier>.block`
74+
* `<app_extension_bundle_identifier>.identity`
7575

76-
where `<bundleIdentifier>` is replaced with bundle identifier of your Live Caller ID Lookup extension.
76+
In the above, replace `<app_extension_bundle_identifier>` with your app extension's bundle identifier.
77+
78+
And usecase name for NEURLFilter should be:
79+
* `<app_bundle_identifier>.url.filtering`
80+
81+
In the above, replace `<app_bundle_identifier>` with your application's bundle identifier.
7782

7883
#### No token key found with key id
7984

@@ -102,8 +107,9 @@ you restarted the service, which means that new keys were generated, and the exa
102107
therefore making the cached tokens invalid.
103108

104109
**Workaround:**
105-
Once the device runs out of cached tokens, it will fetch new ones. One way to speed up the process is to call
106-
[refreshPIRParameters(forExtensionWithIdentifier:)](https://developer.apple.com/documentation/sms_and_call_reporting/livecalleridlookupmanager/4418043-refreshpirparameters).
110+
Once the device runs out of cached tokens, it will fetch new ones. One way to speed up the process is to explicitly refresh the PIR parameters.
111+
* For example, for Live Caller ID Lookup, call [refreshPIRParameters(forExtensionWithIdentifier:)](https://developer.apple.com/documentation/sms_and_call_reporting/livecalleridlookupmanager/4418043-refreshpirparameters).
112+
* For NEURLFilter, see [NEURLFilter API documentation](https://developer.apple.com/documentation/networkextension/neurlfiltermanager).
107113

108114
#### Evaluation key not found
109115

@@ -123,7 +129,6 @@ A real service should persist the evaluation key, but the example service only s
123129
copy of the evaluation key is gone after you restart the example service.
124130

125131
**Workaround:**
126-
The device will periodically refetch the configuration from the server and will notice the missing evaluation key. You
127-
can call
128-
[refreshPIRParameters(forExtensionWithIdentifier:)](https://developer.apple.com/documentation/sms_and_call_reporting/livecalleridlookupmanager/4418043-refreshpirparameters)
129-
to let system know that it should refetch the configuration immediately.
132+
The device will periodically refetch the configuration from the server and will notice the missing evaluation key. You can also force the system to refresh configuration by calling the appropriate refresh API.
133+
* For Live Caller ID Lookup, you can call [refreshPIRParameters(forExtensionWithIdentifier:)](https://developer.apple.com/documentation/sms_and_call_reporting/livecalleridlookupmanager/4418043-refreshpirparameters).
134+
* For NEURLFilter, refer to [NEURLFilter API documentation](https://developer.apple.com/documentation/networkextension/neurlfiltermanager).

Sources/PIRService/PIRService.docc/HTTPEndpoints.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
# Setting up the HTTP endpoints for Live Caller ID Lookup
1+
# Setting up the HTTP endpoints
22

33
Learn about the required endpoints that the system expects from your service.
44

55
## Overview
66

7-
Your client side app needs your
8-
[serviceURL](https://developer.apple.com/documentation/sms_and_call_reporting/livecalleridlookupextensioncontext/4365180-serviceurl)
9-
so the system can fetch information from your server. Communication between the system and server uses Protocol
7+
Communication between the system and server uses Protocol
108
Buffer (Protobuf) messages over HTTP. For the Protobuf schema please see [Homomorphic Encryption
119
Protobuf](https://github.com/apple/swift-homomorphic-encryption-protobuf).
1210

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Data format for NEURLFilter
2+
3+
Understand the data format that Network Extension URL Filter expects.
4+
5+
## Overview
6+
7+
Network Extension on-device examines all URL requests, checking each URL against a Bloom filter built from your URL data set, containing URLs you want to block.
8+
If the Bloom filter match is negative, the URL is not in your data set and it will be allowed immediately. If the Bloom filter match is positive, the match result is not
9+
definitive due to potential false positives. In this case, an off-device URL query will be sent to your PIR server to match against your URL data set to get a final verdict.
10+
If your PIR server responds with a match, the system on-device will block the URL, and the URL request will fail.
11+
12+
## URL Data Record
13+
14+
The URL data record has the URL (excluding the scheme portion) as the key. For example, for URL `https://www.example.com`, the URL key should be
15+
`www.example.com`. If an entry is found matching the URL key, it already indicates a match. So the value for the record is simply set to the integer 1 serving as place holder.
16+
17+
Value | Description
18+
----- | -----------
19+
1 | <Place holder>
Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# How to onboard Live Caller ID Lookup extension with Apple's Oblivious HTTP relay
1+
# How to onboard with an Oblivious HTTP relay hosted by Apple
22

3-
Understand the requirements for running a Live Caller ID Lookup service.
3+
Understand the requirements for running PIRService.
44

55
## Overview
66

7-
To hide client’s IP address all network request made by the system to the Live Caller ID Lookup server will go over
7+
To hide client’s IP address all network request made by the system to the server will go over
88
[Oblivious HTTP](https://www.rfc-editor.org/rfc/rfc9458). Apple will provide the oblivious relay and therefore there is
99
a required onboarding step to make sure that Apple’s oblivious HTTP relay has been configured to forward requests to
1010
your chosen oblivious HTTP gateway.
@@ -13,14 +13,14 @@ your chosen oblivious HTTP gateway.
1313

1414
### How to test without private relay
1515

16-
The system does not use private relay, when the application is installed directly from Xcode. This allows the
16+
The system does not use private relay when the application is installed directly from Xcode. This allows the
1717
application & the service deployment to be tested before filling out the onboarding form and setting up Oblivious HTTP
1818
relay.
1919

2020

2121
### Requirements
2222

23-
Before filling out the form, there are a few requirements you have to satisfy to ensure smooth operations.
23+
Before filling out the onboarding form, there are a few requirements you have to satisfy to ensure smooth operations.
2424

2525
#### OHTTP gateway
2626

@@ -31,10 +31,10 @@ openssl s_client -alpn h2 -connect $(OHTTP_GATEWAY_FQDN):443 </dev/null
3131
In the output check if the SSL session was established or not.
3232

3333
#### URLs
34-
Please provide the URLs as you would put them into the
35-
[LiveCallerIDLookupExtensionContext](https://developer.apple.com/documentation/identitylookup/livecalleridlookupextensioncontext).
34+
You will need to provide the URLs you would put into your feature configuration. For example, for Live Caller ID Lookup, you would provide the URLs configured in
35+
[LiveCallerIDLookupExtensionContext](https://developer.apple.com/documentation/identitylookup/livecalleridlookupextensioncontext). For NEURLFilter, you will provide the URLs specified in [NEURLFilter API documentation](https://developer.apple.com/documentation/networkextension/neurlfiltermanager).
3636

37-
> Important: In addition, we strongly advice you to use subdomains instead of paths. Support for custom paths for the
37+
> Important: In addition, we strongly advise you to use subdomains instead of paths. Support for custom paths for the
3838
> service URL and token issuer URL will be deprecated in a future iOS version.
3939
4040
Good example:
@@ -50,20 +50,20 @@ http://example.net:8080/lookup - No HTTPS, non standard port, path instead of su
5050
```
5151

5252
#### HTTP Bearer Token / UserToken
53-
The `userToken` field is a of type `Data` and the system sets the "Authorization" header like this:
53+
The `userToken` field is of type `String` and the system sets the "Authorization" header like this:
5454
```swift
55-
request.setValue("Bearer \(userToken.base64EncodedString())", forHTTPHeaderField: "Authorization")
55+
request.setValue("Bearer \(userToken)", forHTTPHeaderField: "Authorization")
5656
```
57-
This implies that when filling out the form, you must enter a valid base64 encoding.
58-
> Warning: For example JSON Web Tokens are not valid base64 encodings and are therefore unsupported.
5957

6058
#### Checklist
6159

62-
1. You must know the bundle identifier of your Live Caller ID Lookup extension.
60+
1. You must know the bundle identifier of your extension for Live Caller ID Lookup, or bundle identifier of your application for NEURLFilter.
6361
2. You need to provide expected request and response size and per continent traffic estimates that include:
6462
* peak requests per second
6563
* total requests per day
66-
3. You have added a test identity (+14085551212 with name “Johnny Appleseed”) to your dataset.
64+
3. You have added a test identity to your dataset.
65+
* For Live Caller ID Lookup, it should be +14085551212 with name “Johnny Appleseed”.
66+
* For NEURLFilter, it should be `www.apple.com/url-filter-test` with value as the integer `1`.
6767
4. You have set up an Oblivious HTTP gateway.
6868
5. You must provide your Oblivious HTTP Gateway configuration resource.
6969
6. You must provide your Oblivious HTTP Gateway resource -- a URL used to make oblivious HTTP requests to your service.
@@ -72,16 +72,22 @@ This implies that when filling out the form, you must enter a valid base64 encod
7272
9. You must provide an HTTP Bearer token, that allows us to validate that your deployment is set up correctly and we can
7373
successfully fetch the test identity.
7474
10. You must add a DNS TXT record to your service URL to prove your ownership, control, and intent to serve Live Caller
75-
ID Lookups. More specifically you need to add the following record:
76-
`apple-live-caller-id-lookup=<bundle_identifier>` where `<bundle_identifier>` is replaced with your extension's
77-
bundle identifier. For example, if your Live Caller ID Lookup extension's bundle identifier is `net.example.lookup`
78-
the DNS TXT record should be: `apple-live-caller-id-lookup=net.example.lookup`.
75+
ID Lookups or NEURLFilter. More specifically you need to add one of the following records, depending on whether you are hosting
76+
Live Caller ID Lookups, or NEURLFilter:
77+
* For Live Caller ID Lookup, add `apple-live-caller-id-lookup=<app_extension_bundle_identifier>`
78+
* For NEURLFilter, add `apple-url-filter=<app_bundle_identifier>`
79+
80+
Here, `<app_extension_bundle_identifier>` is replaced with your extension's bundle identifier for Live Caller ID Lookup; and `<app_bundle_identifier>` is replaced with your application bundle identifier for NEURLFilter. For example, if your Live Caller ID Lookup
81+
extension's bundle identifier is `net.example.lookup` the DNS TXT record should be: `apple-live-caller-id-lookup=net.example.lookup`.
7982
11. You must ensure that your deployment (including Oblivious HTTP gateway & PIR service) is running so that we can
8083
perform the validation test.
8184

82-
### Onboarding form
85+
### Onboarding forms
8386

8487
The onboarding form should be filled out when you have a working service, but before you start distributing your
85-
application with the Live Caller ID Lookup extension.
88+
application.
8689

87-
> Important: [Link to the onboarding form.](https://developer.apple.com/contact/request/live-caller-id-lookup/)
90+
> Important:
91+
> [Link to the onboarding form for Live Caller ID Lookup.](https://developer.apple.com/contact/request/live-caller-id-lookup/)
92+
>
93+
> [Link to onboarding form for NEURLFilter.](https://developer.apple.com/contact/request/network-extension-url-filter)
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
# ``PIRService``
22

3-
Example service for Live Caller ID Lookup
3+
Example service for Live Caller ID Lookup and NEURLFilter
44

55
## Overview
66

7+
This service is a non-scalable example that can be used to test both Live Caller ID Lookup and NEURLFilter features. Please see
8+
<doc:TestingInstructionsLiveCallerIdLookup> and <doc:TestingInstructionsNEURLFilter> to see instructions on how to run the example service and connect your phone to the service.
9+
10+
### Live Caller ID Lookup
11+
712
[Live Caller ID
813
Lookup](https://developer.apple.com/documentation/sms_and_call_reporting/getting_up-to-date_calling_and_blocking_information_for_your_app)
9-
is a new feature that allows the system to communicate with a third party service to privately retrieve information
14+
is a new feature in iOS 18.0 that allows the system to communicate with a third party service to privately retrieve information
1015
about a phone number for an incoming call. This allows the system to automatically block known spam callers and display
1116
identity information on the incoming call screen.
1217

1318
![Live Caller ID Lookup data flow diagram](overview.png)
1419

15-
This service is an non-scalable example that can be used to test the Live Caller ID Lookup feature. Please see
16-
<doc:TestingInstructions> to see intructions on how to run the example service and connect your phone to the service.
20+
### NEURLFilter
21+
22+
[NEURLFilter](https://developer.apple.com/documentation/networkextension/neurlfiltermanager) is a new feature for iOS and MacOS that allows the system
23+
to communicate with a third party service to privately check if a requested URL should be allowed or not. This allows your app to implement URL filtering in a privacy preserving manner.
1724

1825
## Topics

0 commit comments

Comments
 (0)