Skip to content

Commit

Permalink
Add first version
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Lefèvre committed Aug 3, 2016
1 parent 1674a76 commit e62ee8d
Show file tree
Hide file tree
Showing 439 changed files with 57,014 additions and 2,068 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Tests
provider_credentials.json

### OSX ###
*.DS_Store
.AppleDouble
Expand Down Expand Up @@ -34,6 +37,7 @@ Temporary Items

## Build generated
build/
!dependencies/build
DerivedData/

## Various settings
Expand Down Expand Up @@ -78,8 +82,7 @@ playground.xcworkspace
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Checkouts
Carthage/Build

# fastlane
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

1 change: 1 addition & 0 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github "antitypical/Result" ~> 2.1.3
1 change: 1 addition & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github "antitypical/Result" "2.1.3"
51 changes: 51 additions & 0 deletions Documentation/CodeOfConduct.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Contributor Code of Conduct

As contributors and maintainers of this project, and in the interest of
fostering an open and welcoming community, we pledge to respect all people who
contribute through reporting issues, posting feature requests, updating
documentation, submitting pull requests or patches, and other activities.

We are committed to making participation in this project a harassment-free
experience for everyone, regardless of level of experience, gender, gender
identity and expression, sexual orientation, disability, personal appearance,
body size, race, ethnicity, age, religion, or nationality.

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information, such as physical or electronic
addresses, without explicit permission
* Other unethical or unprofessional conduct

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

By adopting this Code of Conduct, project maintainers commit themselves to
fairly and consistently applying these principles to every aspect of managing
this project. Project maintainers who do not follow or enforce the Code of
Conduct may be permanently removed from the project team.

This code of conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting a project maintainer at [[email protected]](mailto:[email protected]) or [[email protected]](mailto:[email protected]). All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. Maintainers are
obligated to maintain confidentiality with regard to the reporter of an
incident.


This Code of Conduct is adapted from the [Moya code of conduct](https://github.com/Moya/contributors/blob/master/Code%20of%20Conduct.md)
itself adapted from the [Contributor Covenant][homepage],
version 1.3.0, available at
[http://contributor-covenant.org/version/1/3/0/][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/3/0/
71 changes: 71 additions & 0 deletions Documentation/ProviderQuirks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Provider quirks

## Rationale
Email protocol is standardized. However providers implementations often provides extension or variations of these standards.

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.

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.

## OAuth

For some of the most common providers, [OAuth](https://en.wikipedia.org/wiki/OAuth) is the *mandatory* way to connect:

### GMAIL

#### Using OAuth

Reference: [Google OAuth reference](https://developers.google.com/gmail/xoauth2_protocol)

You can use your favorite library to handle the oauth flow:

- [OAuthSwift](https://github.com/OAuthSwift/OAuthSwift)
- [SwiftyOAuth](https://github.com/delba/SwiftyOAuth)
- [And many more...](https://github.com/search?utf8=%E2%9C%93&q=oauth+swift)

**Scope**: The access token will need the following scope to allow an access to imap: `https://mail.google.com/`.

You will then have to use your oauth access token as the password and your email as the login when connecting.

#### Using password

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)

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.

### YAHOO

It should be possible to access yahoo using email and password if 2fa is disabled.

However if 2fa is enabled, you will have to use OAuth. The app is not so easy to create in the yahoo developer interface.

- [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)
- [A more official way to do it](https://developer.yahoo.com/oauth/guide/cck-form.html)

**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.
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).

**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.


## Two factor auth

Two factor authentication can cause of lot of trouble when handling connection.
Most of the time, it is solved by the web flow displayed by the provider and you won't have to handle this.

### iCloud

In the case of iCloud, the 2fa option exists, but no OAuth flow is provided.
You will have to ask your user to generate an app-specific passwer [using this link](http://support.apple.com/kb/ht6186)

## Other Provider limitations and variations

### iCloud

There seem to be a hard limit (in bytes) to imap responses. We set a batch size of max. 500 items in the code.

### Common folder names

- 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.

- 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.
14 changes: 14 additions & 0 deletions Documentation/Roadmap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Roadmap

A lot has been done, but many more is still missing.
These are the things we would like to see happen in Postal :

- [ ] more documentation
- [ ] CocoaPods subspec for RxSwift
- [ ] CocoaPods try pod demo integration
- [ ] TravisCI integration
- [ ] Improve libetpan with more constness and int/long to allow more fluent interactions with swift
- [ ] SPM integration (with linux integration)
- [ ] Find ways to add robust tests to the parsing / wrapping
- [ ] tvOS? watchOS ?
- [ ] your own proposition, please [contribute](https://github.com/snipsco/Postal/issues)
21 changes: 21 additions & 0 deletions Documentation/TechnicalNotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Technical Notes

## How does it work ?

- Postal is a swift wrapper over [libetpan](https://github.com/dinhviethoa/libetpan).
- Libetpan handles all the low-level imap connection and parsing in a synchronous way.
- Postal wraps some features provided by libetpan and exposes them with an high-level asynchronous API.
- The high level API must be simple and comprehensive swift.
- Libetpan is provided in the repo as a pre-built static library for a better ease-of-use and easier CocoaPods distrbution
- Libetpan can be built from source using the shell scripts found in the [dependencies](https://github.com/snipsco/Postal/tree/master/dependencies) folder.

## About mailcore ?

[Mailcore2](https://github.com/MailCore/mailcore2) is a library wrapping libetpan providing a great set of features when interacting with mails.

The main drawback which made us start a fresh library is that Mailcore is an objective-c wrapper over a C++ wrapper over libetpan.
These layers of complexity makes the library quite awkward to use in cunjunction with swift.

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.

[dependencies]: dependencies/
Binary file added Documentation/logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions LICENCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Snips

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions Postal/Info.plist → Postal-iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2016 Snips. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
31 changes: 31 additions & 0 deletions Postal-iOS/Postal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// The MIT License (MIT)
//
// Copyright (c) 2016 Snips
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//

#import <UIKit/UIKit.h>

//! Project version number for Postal.
FOUNDATION_EXPORT double PostalVersionNumber;

//! Project version string for Postal.
FOUNDATION_EXPORT const unsigned char PostalVersionString[];
28 changes: 28 additions & 0 deletions Postal-macOS/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2016 Snips. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
32 changes: 32 additions & 0 deletions Postal-macOS/Postal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// The MIT License (MIT)
//
// Copyright (c) 2016 Snips
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//

#import <Cocoa/Cocoa.h>

//! Project version number for Postal.
FOUNDATION_EXPORT double PostalVersionNumber;

//! Project version string for Postal.
FOUNDATION_EXPORT const unsigned char PostalVersionString[];

45 changes: 45 additions & 0 deletions Postal.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Pod::Spec.new do |s|
s.name = 'Postal'
s.version = '0.0.2'
s.summary = 'A swift framework for working with emails.'
s.description = 'A Swift framework for working with emails. Simple and quick to use. Built on top of libetpan.'
s.homepage = 'https://github.com/snipsco/Postal'
s.license = 'MIT'
s.author = { 'Kevin Lefevre' => '[email protected]', 'Jeremie Girault' => '[email protected]' }

s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.10'

s.source = { :git => 'https://github.com/snipsco/Postal.git', :tag => s.version.to_s }

s.default_subspec = 'Core'

s.subspec 'Core' do |sp|
sp.source_files = 'Postal/*.{swift,h}'

sp.pod_target_xcconfig = {
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) NO_MACROS=1'
}
sp.ios.pod_target_xcconfig = {
'SWIFT_INCLUDE_PATHS' => '"$(SRCROOT)/Postal/dependencies" "$(SRCROOT)/Postal/dependencies/build/ios/include"',
'LIBRARY_SEARCH_PATHS' => '"$(SRCROOT)/Postal/dependencies/build/ios/lib"',
'HEADER_SEARCH_PATHS' => '"$(SRCROOT)/Postal/dependencies/build/ios/include"'
}
s.osx.pod_target_xcconfig = {
'SWIFT_INCLUDE_PATHS' => '"$(SRCROOT)/Postal/dependencies" "$(SRCROOT)/Postal/dependencies/build/macos/include"',
'LIBRARY_SEARCH_PATHS' => '"$(SRCROOT)/Postal/dependencies/build/macos/lib"',
'HEADER_SEARCH_PATHS' => '"$(SRCROOT)/Postal/dependencies/build/macos/include"'
}
sp.preserve_paths = 'dependencies'

sp.libraries = 'etpan', 'sasl2', 'z', 'iconv'
sp.dependency 'Result', '~> 2.1.3'
end

s.subspec 'ReactiveCocoa' do |sp|
sp.source_files = 'Postal/ReactiveCocoa/*.swift'
sp.dependency "Postal/Core"
sp.dependency 'ReactiveCocoa', '~> 4.2.1'
end

end
Loading

0 comments on commit e62ee8d

Please sign in to comment.