Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*.iml
local.properties
build
.DS_Store
**/.DS_Store
# Created by https://www.gitignore.io

### Android ###
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.13.0'
classpath 'com.android.tools.build:gradle:8.13.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -26,10 +26,10 @@ allprojects {

maven {
credentials {
username "$ANDROID_INTERNAL_PUBLISHING_USERNAME"
password "$ANDROID_INTERNAL_PUBLISHING_PASSWORD"
username "aws"
password System.env.CODEARTIFACT_AUTH_TOKEN
}
url "$ANDROID_INTERNAL_PUBLISHING_URL"
url 'https://threesidedcube-android-735275294014.d.codeartifact.us-east-1.amazonaws.com/maven/3SidedCube-Android/'
}
}
}
6 changes: 3 additions & 3 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import com.cube.storm.content.BundleDownloadStrategy
buildscript {
repositories {
maven {
url "$ANDROID_INTERNAL_PUBLISHING_URL"
url 'https://threesidedcube-android-735275294014.d.codeartifact.us-east-1.amazonaws.com/maven/3SidedCube-Android/'
credentials {
username "$ANDROID_INTERNAL_PUBLISHING_USERNAME"
password "$ANDROID_INTERNAL_PUBLISHING_PASSWORD"
username "aws"
password System.env.CODEARTIFACT_AUTH_TOKEN
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=3.0.0
VERSION_NAME=3.0.1-rc2
GROUP=com.3sidedcube.storm

POM_NAME=LightningContent
Expand All @@ -16,4 +16,4 @@ POM_LICENSE_DIST=repo
POM_DEVELOPER_ID=scruffyfox
POM_DEVELOPER_NAME=Callum Taylor
android.useAndroidX=true
android.enableJetifier=true
android.enableJetifier=true
6 changes: 3 additions & 3 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ allprojects {
}
}

ext.PUBLISHING_URL = properties.get('ANDROID_INTERNAL_PUBLISHING_URL', '')
ext.PUBLISHING_USERNAME = properties.get('ANDROID_INTERNAL_PUBLISHING_USERNAME', '')
ext.PUBLISHING_PASSWORD = properties.get('ANDROID_INTERNAL_PUBLISHING_PASSWORD', '')
ext.PUBLISHING_URL = 'https://threesidedcube-android-735275294014.d.codeartifact.us-east-1.amazonaws.com/maven/3SidedCube-Android/'
ext.PUBLISHING_USERNAME = "aws"
ext.PUBLISHING_PASSWORD = System.env.CODEARTIFACT_AUTH_TOKEN

afterEvaluate { project ->
publishing {
Expand Down
18 changes: 18 additions & 0 deletions library/src/main/java/com/cube/storm/ContentSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ public static ContentSettings getInstance()
*/
@Getter @Setter private String authorizationToken;

/**
* Content key to use when downloading updates/bundles from the CDN
*/
@Getter @Setter @Nullable private String contentKey;

/**
* The builder class for {@link com.cube.storm.ContentSettings}. Use this to create a new {@link com.cube.storm.ContentSettings} instance
* with the customised properties specific for your project.
Expand Down Expand Up @@ -324,6 +329,19 @@ public Builder authorizationToken(@NonNull String token)
return this;
}

/**
* Set the content key header to be used when downloading updates/bundles from the CDN
*
* @param contentKey The content key
*
* @return The {@link com.cube.storm.ContentSettings.Builder} instance for chaining
*/
public Builder contentKey(@Nullable String contentKey)
{
construct.contentKey = contentKey;
return this;
}

/**
* Set the content URL to download bundles from
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ public void downloadUpdates(String endpoint, Observer<UpdateContentProgress> obs
.get()
.header("Connection", "close");

String contentKey = ContentSettings.getInstance().getContentKey();
if (!TextUtils.isEmpty(contentKey))
{
request.header("x-content-key", contentKey);
}

// Get the response
Call call = redirectingHttpClient.newCall(request.build());
call.enqueue(new GZIPTarCacheConnectionInfoCallback(ContentSettings.getInstance().getStoragePath() + "/delta")
Expand Down
10 changes: 5 additions & 5 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ dependencies {
POM_NAME='LightningContentGradlePlugin'
POM_ARTIFACT_ID='content-gradle-plugin'
POM_PACKAGING='jar'
// 2.0.0: migrated to the AndroidComponents variant API. Requires AGP 7.2+ (supports AGP 9.x).
VERSION_NAME="2.0.0"
// 2.0.1: adds StormExtension.bypassKey, sent as the x-bypass-key header on the build-time bundle download request.
VERSION_NAME="2.0.1-rc2"

java {
sourceCompatibility = JavaVersion.VERSION_17
Expand All @@ -45,9 +45,9 @@ allprojects {
}
}

ext.PUBLISHING_URL = properties.get('ANDROID_INTERNAL_PUBLISHING_URL', '')
ext.PUBLISHING_USERNAME = properties.get('ANDROID_INTERNAL_PUBLISHING_USERNAME', '')
ext.PUBLISHING_PASSWORD = properties.get('ANDROID_INTERNAL_PUBLISHING_PASSWORD', '')
ext.PUBLISHING_URL = 'https://threesidedcube-android-735275294014.d.codeartifact.us-east-1.amazonaws.com/maven/3SidedCube-Android/'
ext.PUBLISHING_USERNAME = "aws"
ext.PUBLISHING_PASSWORD = System.env.CODEARTIFACT_AUTH_TOKEN

afterEvaluate { project ->
publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ class StormExtension {
String bundleEnvironment = ""
String authUsername = ""
String authPassword = ""
/**
* Static key sent as the x-bypass-key header on the build-time bundle download request, for
* CDN edge gating that isn't tied to a running app (so Firebase AppCheck doesn't apply here).
*/
String bypassKey = ""
Date bundleTimestamp = null
Boolean obeyLandmark = null

Expand Down Expand Up @@ -48,7 +53,8 @@ class StormExtension {
obeyLandmark: this.obeyLandmark == null ? other.obeyLandmark : this.obeyLandmark,
bundleDownloadStrategy: this.bundleDownloadStrategy == null ? other.bundleDownloadStrategy : this.bundleDownloadStrategy,
authUsername: this.authUsername.isEmpty() ? other.authUsername : this.authUsername,
authPassword: this.authPassword.isEmpty() ? other.authPassword : this.authPassword
authPassword: this.authPassword.isEmpty() ? other.authPassword : this.authPassword,
bypassKey: this.bypassKey.isEmpty() ? other.bypassKey : this.bypassKey
)
}

Expand All @@ -58,6 +64,6 @@ class StormExtension {

public String toString()
{
return "Storm(apiBase=${apiBase}, apiVersion=${apiVersion}, appId=${appId}, orgId=${orgId}, orgName=${orgName}, bundleEnv=${bundleEnvironment}, bundleTimestamp=${bundleTimestamp}, obeyLandmark=${obeyLandmark}, bundleDownloadStrategy=${bundleDownloadStrategy}, authUsername=${authUsername}, authPassword=${authPassword}, url=${url})"
return "Storm(apiBase=${apiBase}, apiVersion=${apiVersion}, appId=${appId}, orgId=${orgId}, orgName=${orgName}, bundleEnv=${bundleEnvironment}, bundleTimestamp=${bundleTimestamp}, obeyLandmark=${obeyLandmark}, bundleDownloadStrategy=${bundleDownloadStrategy}, authUsername=${authUsername}, authPassword=${authPassword}, bypassKey=${bypassKey.isEmpty() ? "" : "***"}, url=${url})"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class StormPlugin implements Plugin<Project> {
boolean requiresAuth = mergedStormConfig.requiresAuth()
String url = mergedStormConfig.url
String authUsername = mergedStormConfig.authUsername
String bypassKey = mergedStormConfig.bypassKey

String sanitisedUrl = url.replaceAll("[\\\\/:*?\"<>|]", "_")
def archiveFile = project.layout.buildDirectory.file("storm/${sanitisedUrl}/bundle.tar.gz")
Expand Down Expand Up @@ -173,6 +174,9 @@ class StormPlugin implements Plugin<Project> {
println "Setting auth token for user ${authUsername}: ${authToken}"
downloadTaskRef.header "Authorization", authToken
}
if (!bypassKey.isEmpty()) {
downloadTaskRef.header "x-bypass-key", bypassKey
}
}
src url
dest archiveFile.get().asFile
Expand Down