https://github.com/dracoon/dracoon-swift-sdk
Official DRACOON SDK for Swift
https://github.com/dracoon/dracoon-swift-sdk
dracoon sdk swift
Last synced: about 2 months ago
JSON representation
Official DRACOON SDK for Swift
- Host: GitHub
- URL: https://github.com/dracoon/dracoon-swift-sdk
- Owner: dracoon
- License: apache-2.0
- Created: 2018-10-22T13:28:20.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2025-03-28T11:41:12.000Z (2 months ago)
- Last Synced: 2025-04-09T00:41:22.394Z (2 months ago)
- Topics: dracoon, sdk, swift
- Language: Swift
- Size: 42.8 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Support: Supporting Files/Info.plist
Awesome Lists containing this project
README
# DRACOON Swift SDK
A library to access DRACOON REST API
# Setup
#### Minimum Requirements
Xcode 16
#### Swift Package Manager
Add this line to the dependencies section of your Package.swift:
`.package(name: "crypto_sdk", url: "https://github.com/dracoon/dracoon-swift-sdk", .upToNextMajor(from: "3.0.0"))`
#### Carthage
Add the SDK to your Cartfile:
`github "dracoon/dracoon-swift-sdk.git" ~> 3.0.0`
Then run
`carthage update --platform iOS`
to create a framework or
`carthage update --use-xcframeworks --platform iOS`
to create an xcframework.
#### CocoaPods
Add to your Podfile:
```
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '15.0'
use_frameworks!target '' do
pod 'DRACOON-SDK', '~> 3.0.0'
end
```
Then run`pod install`
# Example
Too see how OAuth Code Grant flow works with DRACOON SDK, check out the example app in /Example/oauth2.example.
Build it with carthage and make sure to store your configuration to /Example/oauth2.example/oauth2.example/OAuthConfig.swift first.```swift
// Create authMode
// Use this mode the first time initializing your DracoonClient. authCode is the code from your OAuth2 code flow authorization response.
let authMode = DracoonAuthMode.authorizationCode(clientId: clientId, clientSecret: clientSecret, authorizationCode: authCode)// If you received your access and refresh tokens use this mode to initialize your DracoonClient.
let token = DracoonTokens(refreshToken: "refreshToken", accessToken: "accessToken", timestamp: Date(), accessTokenValidity: 3600)
let authMode2 = DracoonAuthMode.accessRefreshToken(clientId: "clientId", clientSecret: "clientSecret", tokens: token)// Create client
let client = DracoonClientImpl(serverUrl: serverUrl, authMode: authMode, getEncryptionPassword: getEncryptionPassword)
// -- Example Requests --
// Nodes
client.nodes.getNodes(parentNodeId: nodeId, limit: nil, offset: nil, completion: { result in
switch result {
case .value(let nodeList):
// ...
case .error(let error):
// ...
}
})client.nodes.deleteNodes(request: deleteRequest, completion: { result in
if let error = result.error {
// ...
} else {
// ...
}
})// Account
client.account.getUserAccount(completion: { result in
switch result {
case .error(let error):
// ...
case .value(let user):
// ...
}
})client.account.setUserKeyPair(password: password, completion: { result in
switch result {
case .error(let error):
// ...
case .value(let keyPair):
// ...
}
})// Download
client.nodes.downloadFile(nodeId: nodeId, targetUrl: url, callback: callback)// Upload
client.nodes.uploadFile(uploadId: uploadId, request: createRequest, filePath: filePath, callback: callback, resolutionStrategy: .autorename)// Shares
client.shares.createDownloadShare(nodeId: idToShare, password: sharePassword, completion: { result in
switch result {
case .error(let error):
// ...
case .value(let share):
// ...
}
})let request = CreateUploadShareRequest(targetId: self.nodeId, name: self.containerName){$0.expiration = expiration; $0.password = password; $0.notes = notes}
client.shares.requestCreateUploadShare(request: createRequest, completion: { result in
switch result {
case .error(let error):
// ...
case .value(let share):
// ...
}
})```
# Copyright and License
See [LICENSE](LICENSE)