Skip to content

Commit e62ee8d

Browse files
author
Kevin Lefèvre
committed
Add first version
1 parent 1674a76 commit e62ee8d

439 files changed

Lines changed: 57014 additions & 2068 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Tests
2+
provider_credentials.json
3+
14
### OSX ###
25
*.DS_Store
36
.AppleDouble
@@ -34,6 +37,7 @@ Temporary Items
3437

3538
## Build generated
3639
build/
40+
!dependencies/build
3741
DerivedData/
3842

3943
## Various settings
@@ -78,8 +82,7 @@ playground.xcworkspace
7882
# Carthage
7983
#
8084
# Add this line if you want to avoid checking in source code from Carthage dependencies.
81-
# Carthage/Checkouts
82-
85+
Carthage/Checkouts
8386
Carthage/Build
8487

8588
# fastlane

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

Cartfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github "antitypical/Result" ~> 2.1.3

Cartfile.resolved

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github "antitypical/Result" "2.1.3"

Documentation/CodeOfConduct.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Contributor Code of Conduct
2+
3+
As contributors and maintainers of this project, and in the interest of
4+
fostering an open and welcoming community, we pledge to respect all people who
5+
contribute through reporting issues, posting feature requests, updating
6+
documentation, submitting pull requests or patches, and other activities.
7+
8+
We are committed to making participation in this project a harassment-free
9+
experience for everyone, regardless of level of experience, gender, gender
10+
identity and expression, sexual orientation, disability, personal appearance,
11+
body size, race, ethnicity, age, religion, or nationality.
12+
13+
Examples of unacceptable behavior by participants include:
14+
15+
* The use of sexualized language or imagery
16+
* Personal attacks
17+
* Trolling or insulting/derogatory comments
18+
* Public or private harassment
19+
* Publishing other's private information, such as physical or electronic
20+
addresses, without explicit permission
21+
* Other unethical or unprofessional conduct
22+
23+
Project maintainers have the right and responsibility to remove, edit, or
24+
reject comments, commits, code, wiki edits, issues, and other contributions
25+
that are not aligned to this Code of Conduct, or to ban temporarily or
26+
permanently any contributor for other behaviors that they deem inappropriate,
27+
threatening, offensive, or harmful.
28+
29+
By adopting this Code of Conduct, project maintainers commit themselves to
30+
fairly and consistently applying these principles to every aspect of managing
31+
this project. Project maintainers who do not follow or enforce the Code of
32+
Conduct may be permanently removed from the project team.
33+
34+
This code of conduct applies both within project spaces and in public spaces
35+
when an individual is representing the project or its community.
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
38+
reported by contacting a project maintainer at [kevin.lefevre@snips.ai](mailto:kevin.lefevre@snips.ai) or [jeremie.girault@gmail.com](mailto:jeremie.girault@gmail.com). All
39+
complaints will be reviewed and investigated and will result in a response that
40+
is deemed necessary and appropriate to the circumstances. Maintainers are
41+
obligated to maintain confidentiality with regard to the reporter of an
42+
incident.
43+
44+
45+
This Code of Conduct is adapted from the [Moya code of conduct](https://github.com/Moya/contributors/blob/master/Code%20of%20Conduct.md)
46+
itself adapted from the [Contributor Covenant][homepage],
47+
version 1.3.0, available at
48+
[http://contributor-covenant.org/version/1/3/0/][version]
49+
50+
[homepage]: http://contributor-covenant.org
51+
[version]: http://contributor-covenant.org/version/1/3/0/

Documentation/ProviderQuirks.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Provider quirks
2+
3+
## Rationale
4+
Email protocol is standardized. However providers implementations often provides extension or variations of these standards.
5+
6+
Postal tries to handle some of the edge cases whenever possible but some specificities have to be handled by the developer according to her choices.
7+
8+
This page is meant to regroup all the documentation we found about these quirks in order to make it easier to find a reference for each case.
9+
10+
## OAuth
11+
12+
For some of the most common providers, [OAuth](https://en.wikipedia.org/wiki/OAuth) is the *mandatory* way to connect:
13+
14+
### GMAIL
15+
16+
#### Using OAuth
17+
18+
Reference: [Google OAuth reference](https://developers.google.com/gmail/xoauth2_protocol)
19+
20+
You can use your favorite library to handle the oauth flow:
21+
22+
- [OAuthSwift](https://github.com/OAuthSwift/OAuthSwift)
23+
- [SwiftyOAuth](https://github.com/delba/SwiftyOAuth)
24+
- [And many more...](https://github.com/search?utf8=%E2%9C%93&q=oauth+swift)
25+
26+
**Scope**: The access token will need the following scope to allow an access to imap: `https://mail.google.com/`.
27+
28+
You will then have to use your oauth access token as the password and your email as the login when connecting.
29+
30+
#### Using password
31+
32+
You can still use your account password if 2fa is not enabled. You will have to allow less secure apps to access your mail first. [The documentation is available here.](https://support.google.com/accounts/answer/6010255?hl=en)
33+
34+
However OAuth is the prefered production solution and you should not ask your users to do this. This solution should only be used for tests or prototyping.
35+
36+
### YAHOO
37+
38+
It should be possible to access yahoo using email and password if 2fa is disabled.
39+
40+
However if 2fa is enabled, you will have to use OAuth. The app is not so easy to create in the yahoo developer interface.
41+
42+
- [A workaround exists here to create an OAuth application that have an email scope despite its absence in yahoo developer interface](http://stackoverflow.com/questions/36058534/how-can-yahoo-mail-be-accessed-by-imap-using-oauth-or-oauth2-authentication)
43+
- [A more official way to do it](https://developer.yahoo.com/oauth/guide/cck-form.html)
44+
45+
**OAuth Quirk:** at this date (07-02-2016) Yahoo OAuth form for mobile does not have a "switch account" or "disconnect" button. It may be problematic in the cases where you expect the user to connect multiple Yahoo email accounts.
46+
If you use `SFSafariViewController`, it will put your users in a loop where she can't switch to a new account (because of the cookies left by the previous flow).
47+
48+
**Workaround**: if you want to connect multiple yahoo email accounts, you will have to use a `UIWebView` or `WKWebView` and clear your cookies before opening your oauth flow.
49+
50+
51+
## Two factor auth
52+
53+
Two factor authentication can cause of lot of trouble when handling connection.
54+
Most of the time, it is solved by the web flow displayed by the provider and you won't have to handle this.
55+
56+
### iCloud
57+
58+
In the case of iCloud, the 2fa option exists, but no OAuth flow is provided.
59+
You will have to ask your user to generate an app-specific passwer [using this link](http://support.apple.com/kb/ht6186)
60+
61+
## Other Provider limitations and variations
62+
63+
### iCloud
64+
65+
There seem to be a hard limit (in bytes) to imap responses. We set a batch size of max. 500 items in the code.
66+
67+
### Common folder names
68+
69+
- Every provider seem to have a different identifier for the spam/junk folder. We discovered a set of default values but this setting can be specified in the imap configuration.
70+
71+
- Every provider seem to have a different identifier for the default/inbox folder. Most of the time the default value of `"INBOX"` will work as a good default when no other folder is found. The best method is to list folders and filter find one having the `.AllMail` attribute, or `.Inbox` if it could not be found.

Documentation/Roadmap.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Roadmap
2+
3+
A lot has been done, but many more is still missing.
4+
These are the things we would like to see happen in Postal :
5+
6+
- [ ] more documentation
7+
- [ ] CocoaPods subspec for RxSwift
8+
- [ ] CocoaPods try pod demo integration
9+
- [ ] TravisCI integration
10+
- [ ] Improve libetpan with more constness and int/long to allow more fluent interactions with swift
11+
- [ ] SPM integration (with linux integration)
12+
- [ ] Find ways to add robust tests to the parsing / wrapping
13+
- [ ] tvOS? watchOS ?
14+
- [ ] your own proposition, please [contribute](https://github.com/snipsco/Postal/issues)

Documentation/TechnicalNotes.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Technical Notes
2+
3+
## How does it work ?
4+
5+
- Postal is a swift wrapper over [libetpan](https://github.com/dinhviethoa/libetpan).
6+
- Libetpan handles all the low-level imap connection and parsing in a synchronous way.
7+
- Postal wraps some features provided by libetpan and exposes them with an high-level asynchronous API.
8+
- The high level API must be simple and comprehensive swift.
9+
- Libetpan is provided in the repo as a pre-built static library for a better ease-of-use and easier CocoaPods distrbution
10+
- Libetpan can be built from source using the shell scripts found in the [dependencies](https://github.com/snipsco/Postal/tree/master/dependencies) folder.
11+
12+
## About mailcore ?
13+
14+
[Mailcore2](https://github.com/MailCore/mailcore2) is a library wrapping libetpan providing a great set of features when interacting with mails.
15+
16+
The main drawback which made us start a fresh library is that Mailcore is an objective-c wrapper over a C++ wrapper over libetpan.
17+
These layers of complexity makes the library quite awkward to use in cunjunction with swift.
18+
19+
Swift provides a native way to interop with C and libetpan is fully portable. We hope that Postal may be ported to provide its feature set in a fully portable (server swift?) way.
20+
21+
[dependencies]: dependencies/

Documentation/logo.jpg

105 KB
Loading

LICENCE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Snips
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)