arkana 2.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/arkana/config_parser.rb +1 -1
- data/lib/arkana/encoder.rb +3 -4
- data/lib/arkana/kotlin_code_generator.rb +12 -7
- data/lib/arkana/models/config.rb +4 -0
- data/lib/arkana/models/salt.rb +2 -3
- data/lib/arkana/models/template_arguments.rb +1 -1
- data/lib/arkana/salt_generator.rb +1 -1
- data/lib/arkana/swift_code_generator.rb +2 -2
- data/lib/arkana/templates/kotlin/arkana.kt.erb +1 -1
- data/lib/arkana/templates/kotlin/build_kmp.gradle.kts.erb +28 -0
- data/lib/arkana/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52db8a00775241c44fa0e1768eb111a694e32215b505ec8122491db0700973c9
|
4
|
+
data.tar.gz: 0fee4f39353e59be30345847795a1017b547d9bfb6118edb85bc370e07bd76cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc8efcd05fd71b489a182688595d8fc8a29139cd7ca403c382940f9969cff1cb28fcd35b2a0998c9df588d9a88b155acd29d1963386b686f855c7d7ce0eec950
|
7
|
+
data.tar.gz: 182c8023f7b3d66bcda9e218d44ed0f78c79c9cfd8cc99f7861d8f74abe2484d699504a63bc71de5913f2c8357428d5fecfe1dba7efdd40e6f1b5b48236a5ffd
|
data/lib/arkana/config_parser.rb
CHANGED
data/lib/arkana/encoder.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative "helpers/string"
|
4
4
|
|
5
5
|
# The encoder is responsible for finding the env vars for given keys, encoding them, and creating Secrets based on the generated data.
|
6
6
|
module Encoder
|
@@ -26,10 +26,9 @@ module Encoder
|
|
26
26
|
result << (byte ^ cipher[index % cipher.length]) # XOR operation with a value of the cipher array.
|
27
27
|
end
|
28
28
|
|
29
|
-
encoded_key =
|
30
|
-
result.each do |element|
|
29
|
+
encoded_key = result.map do |element|
|
31
30
|
# Warning: this might be specific to Swift implementation. When generating code for other languages, beware.
|
32
|
-
|
31
|
+
format("%#x", element) # Format the binary number to "0xAB" format.
|
33
32
|
end
|
34
33
|
|
35
34
|
encoded_key.join(", ")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "erb"
|
4
|
-
require "fileutils"
|
3
|
+
require "erb" unless defined?(Erb)
|
4
|
+
require "fileutils" unless defined?(FileUtils)
|
5
5
|
require_relative "helpers/string"
|
6
6
|
|
7
7
|
# Responsible for generating Kotlin source and test files.
|
@@ -9,22 +9,27 @@ module KotlinCodeGenerator
|
|
9
9
|
# Generates Kotlin code and test files for the given template arguments.
|
10
10
|
def self.generate(template_arguments:, config:)
|
11
11
|
kotlin_module_dir = config.result_path
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
source_set = config.is_kotlin_multiplatform_module ? "commonMain" : "main"
|
14
|
+
test_set = config.is_kotlin_multiplatform_module ? "commonTest" : "test"
|
15
|
+
|
16
|
+
kotlin_sources_dir = File.join(kotlin_module_dir, "src", source_set, config.kotlin_sources_path, config.kotlin_package_name.split("."))
|
17
|
+
kotlin_tests_dir = File.join(kotlin_module_dir, "src", test_set, config.kotlin_sources_path, config.kotlin_package_name.split("."))
|
14
18
|
|
15
19
|
if config.should_generate_gradle_build_file
|
16
|
-
set_up_kotlin_module(kotlin_module_dir, template_arguments)
|
20
|
+
set_up_kotlin_module(kotlin_module_dir, template_arguments, config)
|
17
21
|
end
|
18
22
|
|
19
23
|
set_up_kotlin_interfaces(kotlin_sources_dir, template_arguments, config)
|
20
24
|
set_up_kotlin_classes(kotlin_sources_dir, kotlin_tests_dir, template_arguments, config)
|
21
25
|
end
|
22
26
|
|
23
|
-
def self.set_up_kotlin_module(path, template_arguments)
|
27
|
+
def self.set_up_kotlin_module(path, template_arguments, config)
|
24
28
|
dirname = File.dirname(__FILE__)
|
25
29
|
sources_dir = path
|
26
30
|
readme_template = File.read("#{dirname}/templates/readme.erb")
|
27
|
-
|
31
|
+
gradle_template_file = config.is_kotlin_multiplatform_module ? "build_kmp.gradle.kts.erb" : "build.gradle.kts.erb"
|
32
|
+
source_template = File.read("#{dirname}/templates/kotlin/#{gradle_template_file}")
|
28
33
|
FileUtils.mkdir_p(path)
|
29
34
|
render(readme_template, template_arguments, File.join(path, "README.md"))
|
30
35
|
render(source_template, template_arguments, File.join(sources_dir, "build.gradle.kts"))
|
data/lib/arkana/models/config.rb
CHANGED
@@ -34,6 +34,8 @@ class Config
|
|
34
34
|
attr_reader :should_generate_gradle_build_file
|
35
35
|
# @returns [int]
|
36
36
|
attr_reader :kotlin_jvm_toolchain_version
|
37
|
+
# @returns [boolean]
|
38
|
+
attr_reader :is_kotlin_multiplatform_module
|
37
39
|
|
38
40
|
# @returns [string]
|
39
41
|
attr_accessor :current_flavor
|
@@ -64,6 +66,8 @@ class Config
|
|
64
66
|
@should_generate_gradle_build_file = yaml["should_generate_gradle_build_file"]
|
65
67
|
@should_generate_gradle_build_file = true if @should_generate_gradle_build_file.nil?
|
66
68
|
@kotlin_jvm_toolchain_version = yaml["kotlin_jvm_toolchain_version"] || 11
|
69
|
+
@is_kotlin_multiplatform_module = yaml["is_kotlin_multiplatform_module"]
|
70
|
+
@is_kotlin_multiplatform_module = false if @should_generate_gradle_build_file.nil?
|
67
71
|
end
|
68
72
|
# rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
|
69
73
|
|
data/lib/arkana/models/salt.rb
CHANGED
@@ -10,10 +10,9 @@ class Salt
|
|
10
10
|
|
11
11
|
def initialize(raw:)
|
12
12
|
@raw = raw
|
13
|
-
formatted_salt =
|
14
|
-
raw.each do |element|
|
13
|
+
formatted_salt = raw.map do |element|
|
15
14
|
# Warning: this might be specific to Swift implementation. When generating code for other languages, beware.
|
16
|
-
|
15
|
+
format("%#x", element)
|
17
16
|
end
|
18
17
|
@formatted = formatted_salt.join(", ")
|
19
18
|
end
|
@@ -13,7 +13,7 @@ object <%= @namespace %> {
|
|
13
13
|
val decoded = encoded.mapIndexed { index, item ->
|
14
14
|
(item xor cipher[(index % cipher.size)]).toByte()
|
15
15
|
}.toByteArray()
|
16
|
-
return decoded.
|
16
|
+
return decoded.decodeToString()
|
17
17
|
}
|
18
18
|
|
19
19
|
internal fun decodeInt(encoded: List<Int>, cipher: List<Int>): Int {
|
@@ -0,0 +1,28 @@
|
|
1
|
+
// DO NOT MODIFY
|
2
|
+
// Automatically generated by Arkana (https://github.com/rogerluan/arkana)
|
3
|
+
|
4
|
+
plugins {
|
5
|
+
id("org.jetbrains.kotlin.multiplatform")
|
6
|
+
}
|
7
|
+
|
8
|
+
kotlin {
|
9
|
+
jvm()
|
10
|
+
iosX64()
|
11
|
+
iosArm64()
|
12
|
+
iosSimulatorArm64()
|
13
|
+
linuxX64()
|
14
|
+
js {
|
15
|
+
browser()
|
16
|
+
nodejs()
|
17
|
+
}
|
18
|
+
|
19
|
+
sourceSets {
|
20
|
+
val commonTest by getting {
|
21
|
+
dependencies {
|
22
|
+
implementation(kotlin("test"))
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
jvmToolchain(<%= @kotlin_jvm_toolchain_version %>)
|
28
|
+
}
|
data/lib/arkana/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arkana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roger Oba
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- lib/arkana/templates/kotlin/arkana_protocol.kt.erb
|
85
85
|
- lib/arkana/templates/kotlin/arkana_tests.kt.erb
|
86
86
|
- lib/arkana/templates/kotlin/build.gradle.kts.erb
|
87
|
+
- lib/arkana/templates/kotlin/build_kmp.gradle.kts.erb
|
87
88
|
- lib/arkana/templates/readme.erb
|
88
89
|
- lib/arkana/templates/swift/arkana.podspec.erb
|
89
90
|
- lib/arkana/templates/swift/arkana.swift.erb
|
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
118
|
- !ruby/object:Gem::Version
|
118
119
|
version: '0'
|
119
120
|
requirements: []
|
120
|
-
rubygems_version: 3.
|
121
|
+
rubygems_version: 3.5.11
|
121
122
|
signing_key:
|
122
123
|
specification_version: 4
|
123
124
|
summary: Store your keys and secrets away from your source code. Designed for Android
|