Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #32 from exoego/cloudfront-signer
Browse files Browse the repository at this point in the history
Add cloudfront.Signer
  • Loading branch information
TATSUNO Yasuhiro committed Jun 20, 2019
2 parents f9d950d + 443f9f9 commit 1b62a29
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Now with AWS introduced in re:Invent 2018.
libraryDependencies += "net.exoego" %%% "aws-sdk-scalajs-facade" % "0.22.0-v2-473"
```

Note) Starting from `0.22.0`, version number includes the version of AWS SDK, as qualifier like `-v2-473`,
which the facade is built for.

## Support matrix

| | ScalaJS 0.6.28+ | ScalaJS 1.x |
Expand Down
111 changes: 111 additions & 0 deletions src/main/scala/facade/amazonaws/services/cloudfront/Signer.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package facade.amazonaws.services.cloudfront

import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport

@js.native
@JSImport("aws-sdk", "CloudFront.Signer")
class CloudFrontSigner protected () extends js.Object {
def this(keyPairId: String, privateKey: String) = this()

def getSignedCookie(options: SignerOptionsWithPolicy): CustomPolicy = js.native

def getSignedCookie(options: SignerOptionsWithoutPolicy): CannedPolicy = js.native

def getSignedCookie(options: SignerOptionsWithPolicy, callback: js.Function2[Error, CustomPolicy, Unit]): Unit =
js.native

def getSignedCookie(options: SignerOptionsWithoutPolicy, callback: js.Function2[Error, CannedPolicy, Unit]): Unit =
js.native

def getSignedUrl(options: SignerOptionsWithPolicy): String = js.native

def getSignedUrl(options: SignerOptionsWithoutPolicy): String = js.native

def getSignedUrl(options: SignerOptionsWithPolicy, callback: js.Function2[Error, String, Unit]): Unit = js.native

def getSignedUrl(options: SignerOptionsWithoutPolicy, callback: js.Function2[Error, String, Unit]): Unit = js.native
}

@js.native
trait SignerOptionsWithPolicy extends js.Object {
var policy: String = js.native
}

object SignerOptionsWithPolicy {
def apply(
policy: String
): SignerOptionsWithPolicy = {
val _fields = IndexedSeq[(String, js.Any)](
"policy" -> policy.asInstanceOf[js.Any]
).filter(_._2 != (js.undefined: js.Any))

js.Dynamic.literal.applyDynamicNamed("apply")(_fields: _*).asInstanceOf[SignerOptionsWithPolicy]
}
}

@js.native
trait SignerOptionsWithoutPolicy extends js.Object {
var url: String = js.native
var expires: Int = js.native
}

object SignerOptionsWithoutPolicy {
def apply(
url: String,
expires: Int
): SignerOptionsWithoutPolicy = {
val _fields = IndexedSeq[(String, js.Any)](
"url" -> url.asInstanceOf[js.Any],
"expires" -> expires.asInstanceOf[js.Any]
).filter(_._2 != (js.undefined: js.Any))

js.Dynamic.literal.applyDynamicNamed("apply")(_fields: _*).asInstanceOf[SignerOptionsWithoutPolicy]
}
}

@js.native
trait CustomPolicy extends js.Object {
var `CloudFront-Policy`: String = js.native
var `CloudFront-Key-Pair-Id`: String = js.native
var `CloudFront-Signature`: String = js.native
}

object CustomPolicy {
def apply(
policy: String,
keyPairId: String,
signature: String
): CustomPolicy = {
val _fields = IndexedSeq[(String, js.Any)](
"CloudFront-Policy" -> policy.asInstanceOf[js.Any],
"CloudFront-Key-Pair-Id" -> keyPairId.asInstanceOf[js.Any],
"CloudFront-Signature" -> signature.asInstanceOf[js.Any]
).filter(_._2 != (js.undefined: js.Any))

js.Dynamic.literal.applyDynamicNamed("apply")(_fields: _*).asInstanceOf[CustomPolicy]
}
}

@js.native
trait CannedPolicy extends js.Object {
var `CloudFront-Expires`: Int = js.native
var `CloudFront-Key-Pair-Id`: String = js.native
var `CloudFront-Signature`: String = js.native
}

object CannedPolicy {
def apply(
expires: Int,
keyPairId: String,
signature: String
): CannedPolicy = {
val _fields = IndexedSeq[(String, js.Any)](
"CloudFront-Expires" -> expires.asInstanceOf[js.Any],
"CloudFront-Key-Pair-Id" -> keyPairId.asInstanceOf[js.Any],
"CloudFront-Signature" -> signature.asInstanceOf[js.Any]
).filter(_._2 != (js.undefined: js.Any))

js.Dynamic.literal.applyDynamicNamed("apply")(_fields: _*).asInstanceOf[CannedPolicy]
}
}

0 comments on commit 1b62a29

Please sign in to comment.