This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from exoego/cloudfront-signer
Add cloudfront.Signer
- Loading branch information
Showing
2 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
src/main/scala/facade/amazonaws/services/cloudfront/Signer.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | ||
} | ||
} |