diff --git a/.github/workflows/test-java.yaml b/.github/workflows/test-java.yaml index e76cc2248..6791e6cfe 100644 --- a/.github/workflows/test-java.yaml +++ b/.github/workflows/test-java.yaml @@ -112,13 +112,13 @@ jobs: java-example: name: Example project – JavaThemis - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Install system dependencies run: | sudo sh -c 'echo "DEBIAN_FRONTEND=noninteractive" >> /etc/environment' sudo apt update - sudo apt install --yes gcc make libssl-dev default-jdk + sudo apt install --yes gcc make libssl-dev default-jdk dpkg-dev - name: Check out code uses: actions/checkout@v2 - name: Install Themis Core with JNI @@ -128,10 +128,10 @@ jobs: - name: Build JavaThemis example run: | cd docs/examples/java - ./gradlew --no-daemon build + JAVA_TOOL_OPTIONS=-Djava.library.path=/usr/local/lib ./gradlew --no-daemon build # Thus runs a bit of an abomination: Themis Core and JNI libs are built # from source while JavaThemis binaries are installed from Maven Central. - name: Run JavaThemis example run: | cd docs/examples/java - java -Djava.library.path=/usr/local/lib -jar app/build/libs/app.jar + JAVA_TOOL_OPTIONS=-Djava.library.path=/usr/local/lib ./gradlew --no-daemon run diff --git a/.github/workflows/test-nodejs.yaml b/.github/workflows/test-nodejs.yaml index 2a62921c8..23a77a0f8 100644 --- a/.github/workflows/test-nodejs.yaml +++ b/.github/workflows/test-nodejs.yaml @@ -5,6 +5,7 @@ on: paths: - '.github/workflows/test-nodejs.yaml' - 'docs/examples/js/**' + - 'docs/examples/ts/**' - 'src/soter/**' - 'src/themis/**' - 'src/wrappers/themis/jsthemis/**' @@ -132,3 +133,62 @@ jobs: node secure_comparator_client.js kill -SIGTERM "$!" echo "ok" + - name: Test 'import' syntax + if: always() + run: | + cd $GITHUB_WORKSPACE/docs/examples/js/ + echo "Test import syntax..." + node import_module.mjs + echo "ok" + - name: Install Typescript deps + if: always() + run: | + cd $GITHUB_WORKSPACE/docs/examples/ts/ + npm install + npm run compile + - name: Test Typescript examples (Secure Keygen) + if: always() + run: | + cd $GITHUB_WORKSPACE/docs/examples/ts + echo "Test Secure Keygen..." + node secure_keygen.js + echo "ok" + - name: Test Typescript examples (Secure Cell) + if: always() + run: | + cd $GITHUB_WORKSPACE/docs/examples/ts + echo "Test Secure Cell..." + node secure_cell.js + echo "ok" + - name: Test Typescript examples (Secure Message) + if: always() + run: | + cd $GITHUB_WORKSPACE/docs/examples/ts + echo "Test Secure Message..." + alice=($(node secure_keygen.js | cut -c 15-)) + bob=($(node secure_keygen.js | cut -c 15-)) + enc=$(node secure_message.js enc "${alice[1]}" "${bob[2]}" message) + dec=$(node secure_message.js dec "${bob[1]}" "${alice[2]}" "$enc") + test "$dec" = "message" + echo "ok" + - name: Test Typescript examples (Secure Session) + if: always() + run: | + cd $GITHUB_WORKSPACE/docs/examples/ts + echo "Test Secure Session..." + node secure_session_server.js & + sleep 1 # give the server time to launch + node secure_session_client.js > output.txt + kill -SIGTERM "$!" + grep -q 'Hello server!!!' output.txt + echo "ok" + - name: Test Typescript examples (Secure Comparator) + if: always() + run: | + cd $GITHUB_WORKSPACE/docs/examples/ts + echo "Test Secure Comparator..." + node secure_comparator_server.js & + sleep 1 # give the server time to launch + node secure_comparator_client.js + kill -SIGTERM "$!" + echo "ok" \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index a1d2f8c85..a2965b874 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,25 @@ Changes that are currently in development and have not been released yet. +## [0.15.2](https://github.com/cossacklabs/themis/releases/tag/0.15.2), November 24 2023 + +### JsThemis wrapper +- Added the ability to use the `import` syntax for the jsthemis module. +- Added a declaration file for TypeScript. + +### Android, ReactNative wrappers +Updated versions of dependencies. New minimum versions of iOS, Android are set. +- Target API level 33 +- Minimum API level 21 +- Minumum iOS set to 12.4 due to ReactNative requirements + +## [0.15.1](https://github.com/cossacklabs/themis/releases/tag/0.15.1), September 13 2023 + +### Swift, Objective-C wrappers +- Updated OpenSSL to 1.1.1v +- Removed support of 32-bit platforms +- Minimum iOS: 11, macOS: 10.13, Catalyst: 14 + ## [0.15.0](https://github.com/cossacklabs/themis/releases/tag/0.15.0), June 21st 2023 **TL;DR:** diff --git a/Cartfile b/Cartfile index 48af3bd59..98f658e1a 100644 --- a/Cartfile +++ b/Cartfile @@ -1,2 +1,3 @@ -# OpenSSL 1.1.1k -binary "https://raw.githubusercontent.com/cossacklabs/openssl-apple/cossacklabs/carthage/openssl-static-xcframework.json" == 1.1.11101 +# OpenSSL 1.1.1v - we need this to build themis framework. +binary "https://raw.githubusercontent.com/cossacklabs/openssl-apple/cossacklabs/carthage/openssl-static-xcframework.json" == 1.1.12201 + diff --git a/Cartfile.resolved b/Cartfile.resolved index f47126628..d51b67b62 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -binary "https://raw.githubusercontent.com/cossacklabs/openssl-apple/cossacklabs/carthage/openssl-static-xcframework.json" "1.1.11101" +binary "https://raw.githubusercontent.com/cossacklabs/openssl-apple/cossacklabs/carthage/openssl-static-xcframework.json" "1.1.12201" diff --git a/Makefile b/Makefile index 184982b53..ef18f1274 100644 --- a/Makefile +++ b/Makefile @@ -93,6 +93,11 @@ LDFLAGS += -L$(BIN_PATH) # Build shared libraries CFLAGS += -fPIC +#----- Mode packaging ---------------------------------------------------------- +# Default value is not packaging mode. Goals: dev, rpm, deb_php will set it to 1 +MODE_PACKAGING = 0 + + ######################################################################## # # Pretty-printing utilities diff --git a/Package.swift b/Package.swift index 14817383a..5a02cd76d 100644 --- a/Package.swift +++ b/Package.swift @@ -15,11 +15,11 @@ let package = Package( targets: [ .binaryTarget(name: "themis", // update version in URL path - url: "https://github.com/cossacklabs/themis/releases/download/0.14.0/themis.xcframework.zip", + url: "https://github.com/cossacklabs/themis/releases/download/0.15.1/themis.xcframework.zip", // The scripts/create_xcframework.sh calculates the checksum when generating the XCF. // Alternatively, run from package directory: // swift package compute-checksum build/xcf_output/themis.xcframework.zip - checksum: "182587c9070b94e552816d3cc174d64ea0f0a64d5b19483210bcf3dcac4d2658"), + checksum: "2d5bfbba7d5d3ecd0d40acdaee65d1b5d42dee5df5ae9d99faec4119087238c5"), ] ) diff --git a/Themis.xcodeproj/project.pbxproj b/Themis.xcodeproj/project.pbxproj index ea0ac397d..16b126261 100644 --- a/Themis.xcodeproj/project.pbxproj +++ b/Themis.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 56; objects = { /* Begin PBXBuildFile section */ @@ -1022,7 +1022,7 @@ }; }; buildConfigurationList = 738B81092239809D00A9947C /* Build configuration list for PBXProject "Themis" */; - compatibilityVersion = "Xcode 9.3"; + compatibilityVersion = "Xcode 14.0"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( @@ -1321,7 +1321,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 11; + CURRENT_PROJECT_VERSION = 12; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -1342,9 +1342,9 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; - MACOSX_DEPLOYMENT_TARGET = 10.11; - MARKETING_VERSION = 0.14.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MACOSX_DEPLOYMENT_TARGET = 10.13; + MARKETING_VERSION = 0.15.1; ONLY_ACTIVE_ARCH = YES; SUPPORTS_MACCATALYST = NO; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; @@ -1387,7 +1387,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 11; + CURRENT_PROJECT_VERSION = 12; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -1402,9 +1402,9 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; - MACOSX_DEPLOYMENT_TARGET = 10.11; - MARKETING_VERSION = 0.14.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MACOSX_DEPLOYMENT_TARGET = 10.13; + MARKETING_VERSION = 0.15.1; SUPPORTS_MACCATALYST = NO; SWIFT_COMPILATION_MODE = wholemodule; TARGETED_DEVICE_FAMILY = "1,2"; @@ -1439,7 +1439,8 @@ "@executable_path/../Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 0.14.0; + MACOSX_DEPLOYMENT_TARGET = 10.13; + MARKETING_VERSION = 0.15.1; PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis; PRODUCT_MODULE_NAME = themis; PRODUCT_NAME = themis; @@ -1475,7 +1476,8 @@ "@executable_path/../Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 0.14.0; + MACOSX_DEPLOYMENT_TARGET = 10.13; + MARKETING_VERSION = 0.15.1; PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis; PRODUCT_MODULE_NAME = themis; PRODUCT_NAME = themis; @@ -1488,15 +1490,16 @@ 9F4A24A7223A8D7F005CB63A /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = ""; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 11; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = ""; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - ENABLE_BITCODE = YES; + ENABLE_BITCODE = NO; EXCLUDED_ARCHS = ""; EXPORTED_SYMBOLS_FILE = "$(PROJECT_DIR)/src/wrappers/themis/Obj-C/exported.symbols"; FRAMEWORK_SEARCH_PATHS = ( @@ -1510,15 +1513,17 @@ ); INFOPLIST_FILE = "src/wrappers/themis/Obj-c/Themis/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 0.14.0; + MARKETING_VERSION = 0.15.1; PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis; PRODUCT_MODULE_NAME = themis; PRODUCT_NAME = themis; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = iphoneos; SKIP_INSTALL = YES; SUPPORTS_MACCATALYST = NO; @@ -1529,15 +1534,16 @@ 9F4A24A8223A8D7F005CB63A /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = ""; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 11; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = ""; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - ENABLE_BITCODE = YES; + ENABLE_BITCODE = NO; EXCLUDED_ARCHS = ""; EXPORTED_SYMBOLS_FILE = "$(PROJECT_DIR)/src/wrappers/themis/Obj-C/exported.symbols"; FRAMEWORK_SEARCH_PATHS = ( @@ -1551,15 +1557,17 @@ ); INFOPLIST_FILE = "src/wrappers/themis/Obj-c/Themis/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 0.14.0; + MARKETING_VERSION = 0.15.1; PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis; PRODUCT_MODULE_NAME = themis; PRODUCT_NAME = themis; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = iphoneos; SKIP_INSTALL = YES; SUPPORTS_MACCATALYST = NO; diff --git a/docs/examples/android/README.md b/docs/examples/android/README.md new file mode 100644 index 000000000..221a842f4 --- /dev/null +++ b/docs/examples/android/README.md @@ -0,0 +1,17 @@ +# Android example + +## Compile +``` +./gradlew clean build +``` + +## Install +``` +./gradlew installDebug +``` +You should see the empty screen with the message "Hello from themis!" and title "ThemisTestApp". +Also, you may to run `adb logcat | grep SMC` and see something like this: +```agsl +10-03 21:36:57.842 16956 16956 D SMC : encrypted string = AAEBQQwAAAAQAAAADQAAABYAAAASizR1/IPS4UYioLPeH8VpdgvaXl9875aZorAZ/soEABAAa/ARqQwo6liyQrluj06zohARxU/0LBNYb3UvKAc= +10-03 21:36:58.776 16956 16956 D SMC : decrypted data = hello message +``` diff --git a/docs/examples/android/app/build.gradle b/docs/examples/android/app/build.gradle index a442b632b..5c32eab0d 100644 --- a/docs/examples/android/app/build.gradle +++ b/docs/examples/android/app/build.gradle @@ -2,12 +2,12 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { - compileSdkVersion 29 - buildToolsVersion '29.0.2' + compileSdkVersion 33 + buildToolsVersion '34.0.0' defaultConfig { applicationId "com.cossacklabs.themis.android.example" minSdkVersion 25 - targetSdkVersion 29 + targetSdkVersion 33 versionCode 1 versionName "1.0" testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' @@ -20,6 +20,7 @@ android { } productFlavors { } + namespace 'com.cossacklabs.themis.android.example' } dependencies { @@ -29,7 +30,7 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' testImplementation 'junit:junit:4.12' - implementation 'com.cossacklabs.com:themis:0.14.0' + implementation 'com.cossacklabs.com:themis:0.15.2' implementation "androidx.core:core-ktx:1.3.2" //noinspection GradleDependency: we use slightly outdated "kotlin_version" on purpose implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" diff --git a/docs/examples/android/app/src/main/AndroidManifest.xml b/docs/examples/android/app/src/main/AndroidManifest.xml index 431368e48..881171d0f 100644 --- a/docs/examples/android/app/src/main/AndroidManifest.xml +++ b/docs/examples/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + @@ -12,20 +11,25 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - + + - + + diff --git a/docs/examples/android/build.gradle b/docs/examples/android/build.gradle index 7234a068b..2515ad73d 100644 --- a/docs/examples/android/build.gradle +++ b/docs/examples/android/build.gradle @@ -5,15 +5,14 @@ // https://developer.android.com/studio/build/jcenter-migration buildscript { - ext.kotlin_version = '1.4.32' + ext.kotlin_version = '1.6.21' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:4.1.3' + classpath 'com.android.tools.build:gradle:7.4.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/docs/examples/android/gradle/wrapper/gradle-wrapper.jar b/docs/examples/android/gradle/wrapper/gradle-wrapper.jar index 62d4c0535..afba10928 100644 Binary files a/docs/examples/android/gradle/wrapper/gradle-wrapper.jar and b/docs/examples/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/docs/examples/android/gradle/wrapper/gradle-wrapper.properties b/docs/examples/android/gradle/wrapper/gradle-wrapper.properties index 622ab64a3..bdc9a83b1 100644 --- a/docs/examples/android/gradle/wrapper/gradle-wrapper.properties +++ b/docs/examples/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/docs/examples/android/gradlew b/docs/examples/android/gradlew index fbd7c5158..65dcd68d6 100755 --- a/docs/examples/android/gradlew +++ b/docs/examples/android/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +140,105 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/docs/examples/android/gradlew.bat b/docs/examples/android/gradlew.bat index a9f778a7a..6689b85be 100644 --- a/docs/examples/android/gradlew.bat +++ b/docs/examples/android/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -54,7 +55,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -64,21 +65,6 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line @@ -86,17 +72,19 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/docs/examples/java/README.md b/docs/examples/java/README.md new file mode 100644 index 000000000..c901b5b04 --- /dev/null +++ b/docs/examples/java/README.md @@ -0,0 +1,7 @@ +# Java example + +## Run +``` +JAVA_TOOL_OPTIONS=-Djava.library.path=/opt/homebrew/lib ./gradlew run +``` + diff --git a/docs/examples/java/app/build.gradle b/docs/examples/java/app/build.gradle index dfa2079b2..80434b881 100644 --- a/docs/examples/java/app/build.gradle +++ b/docs/examples/java/app/build.gradle @@ -1,27 +1,36 @@ -apply plugin: 'java' +/* + * This file was generated by the Gradle 'init' task. + * + * This generated file contains a sample Java application project to get you started. + * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle + * User Manual available at https://docs.gradle.org/8.0.2/userguide/building_java_projects.html + */ + +plugins { + // Apply the application plugin to add support for building a CLI application in Java. + id 'application' +} repositories { + // Use Maven Central for resolving dependencies. mavenCentral() } dependencies { - implementation 'com.cossacklabs.com:java-themis:0.14.0' -} + // Use JUnit Jupiter for testing. + testImplementation 'org.junit.jupiter:junit-jupiter:5.9.1' -sourceSets { - main { - java.srcDirs = ["src"] - } + // This dependency is used by the application. + implementation 'com.google.guava:guava:31.1-jre' + implementation("com.cossacklabs.com:java-themis:0.15.2") } -// Pack *everything* into JAR, including dependencies and their dependencies. -// By default this will pack only local classes, compiled here. -jar { - manifest { - attributes "Main-Class": "main" - } +application { + // Define the main class for the application. + mainClass = 'java_themis_example.App' +} - from { - configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } - } +tasks.named('test') { + // Use JUnit Platform for unit tests. + useJUnitPlatform() } diff --git a/docs/examples/java/app/src/main.java b/docs/examples/java/app/src/main/java/java_themis_example/App.java similarity index 96% rename from docs/examples/java/app/src/main.java rename to docs/examples/java/app/src/main/java/java_themis_example/App.java index 852d259fb..f2edf0589 100644 --- a/docs/examples/java/app/src/main.java +++ b/docs/examples/java/app/src/main/java/java_themis_example/App.java @@ -1,3 +1,8 @@ +/* + * This Java source file was generated by the Gradle 'init' task. + */ +package java_themis_example; + import com.cossacklabs.themis.*; import java.io.IOException; @@ -8,7 +13,7 @@ import java.util.Base64; -public class main { +public class App { static Charset charset = StandardCharsets.UTF_8; diff --git a/docs/examples/java/app/src/test/java/java_themis_example/AppTest.java b/docs/examples/java/app/src/test/java/java_themis_example/AppTest.java new file mode 100644 index 000000000..fafc579d1 --- /dev/null +++ b/docs/examples/java/app/src/test/java/java_themis_example/AppTest.java @@ -0,0 +1,17 @@ +/* + * This Java source file was generated by the Gradle 'init' task. + */ +package java_themis_example; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +class AppTest { + @Test void appDoesNotThrow() { + App classUnderTest = new App(); + assertDoesNotThrow(() -> App.encryptDataForStoring(), "encryptDataForStoring() should run without exceptions"); + assertDoesNotThrow(() -> App.encryptDataForMessaging(), "encryptDataForMessaging() should run without exceptions"); + } +} + + diff --git a/docs/examples/java/build.gradle b/docs/examples/java/build.gradle deleted file mode 100644 index d02677fda..000000000 --- a/docs/examples/java/build.gradle +++ /dev/null @@ -1,17 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - repositories { - jcenter() - } -} - -allprojects { - repositories { - jcenter() - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/docs/examples/java/gradle/wrapper/gradle-wrapper.jar b/docs/examples/java/gradle/wrapper/gradle-wrapper.jar index f3d88b1c2..ccebba771 100644 Binary files a/docs/examples/java/gradle/wrapper/gradle-wrapper.jar and b/docs/examples/java/gradle/wrapper/gradle-wrapper.jar differ diff --git a/docs/examples/java/gradle/wrapper/gradle-wrapper.properties b/docs/examples/java/gradle/wrapper/gradle-wrapper.properties index 6f3a881c2..bdc9a83b1 100644 --- a/docs/examples/java/gradle/wrapper/gradle-wrapper.properties +++ b/docs/examples/java/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Dec 20 16:40:39 EET 2021 -distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/docs/examples/java/gradlew b/docs/examples/java/gradlew index 2fe81a7d9..79a61d421 100755 --- a/docs/examples/java/gradlew +++ b/docs/examples/java/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,78 +17,113 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -97,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -105,79 +140,105 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/docs/examples/java/gradlew.bat b/docs/examples/java/gradlew.bat index 24467a141..6689b85be 100644 --- a/docs/examples/java/gradlew.bat +++ b/docs/examples/java/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,10 +25,14 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -51,7 +55,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -61,38 +65,26 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/docs/examples/java/settings.gradle b/docs/examples/java/settings.gradle index e7b4def49..b1524d591 100644 --- a/docs/examples/java/settings.gradle +++ b/docs/examples/java/settings.gradle @@ -1 +1,11 @@ -include ':app' +/* + * This file was generated by the Gradle 'init' task. + * + * The settings file is used to specify which projects to include in your build. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user manual at https://docs.gradle.org/8.0.2/userguide/multi_project_builds.html + */ + +rootProject.name = 'java_themis_example' +include('app') diff --git a/docs/examples/js/import_module.mjs b/docs/examples/js/import_module.mjs new file mode 100644 index 000000000..860fdb4ce --- /dev/null +++ b/docs/examples/js/import_module.mjs @@ -0,0 +1,11 @@ +import themis from 'jsthemis'; +const { SymmetricKey, KeyPair} = themis; + +let masterKey = new SymmetricKey() +console.log(masterKey); + +let keypair = new KeyPair() +let privateKey = keypair.private() +let publicKey = keypair.public() +console.log(privateKey); +console.log(publicKey); diff --git a/docs/examples/objc/iOS-Carthage/Cartfile b/docs/examples/objc/iOS-Carthage/Cartfile index 2dcbf4838..366903edf 100644 --- a/docs/examples/objc/iOS-Carthage/Cartfile +++ b/docs/examples/objc/iOS-Carthage/Cartfile @@ -1 +1,2 @@ -github "cossacklabs/themis" ~> 0.14.0 \ No newline at end of file +github "cossacklabs/themis" "0.15.1" + diff --git a/docs/examples/objc/iOS-Carthage/Cartfile.resolved b/docs/examples/objc/iOS-Carthage/Cartfile.resolved index b797566b5..2281e75b9 100644 --- a/docs/examples/objc/iOS-Carthage/Cartfile.resolved +++ b/docs/examples/objc/iOS-Carthage/Cartfile.resolved @@ -1,2 +1,2 @@ -binary "https://raw.githubusercontent.com/cossacklabs/openssl-apple/cossacklabs/carthage/openssl-static-xcframework.json" "1.1.11101" -github "cossacklabs/themis" "0.14.0" +binary "https://raw.githubusercontent.com/cossacklabs/openssl-apple/cossacklabs/carthage/openssl-static-xcframework.json" "1.1.12201" +github "cossacklabs/themis" "0.15.1" diff --git a/docs/examples/objc/iOS-Carthage/ThemisTest.xcodeproj/project.pbxproj b/docs/examples/objc/iOS-Carthage/ThemisTest.xcodeproj/project.pbxproj index 28f950335..4089bc22d 100644 --- a/docs/examples/objc/iOS-Carthage/ThemisTest.xcodeproj/project.pbxproj +++ b/docs/examples/objc/iOS-Carthage/ThemisTest.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -275,7 +275,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -332,7 +332,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.1; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; @@ -356,7 +356,7 @@ "$(PROJECT_DIR)/Carthage/Build", ); INFOPLIST_FILE = ThemisTest/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -384,7 +384,7 @@ "$(PROJECT_DIR)/Carthage/Build", ); INFOPLIST_FILE = ThemisTest/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/docs/examples/objc/iOS-CocoaPods/Podfile b/docs/examples/objc/iOS-CocoaPods/Podfile index 044cb51f6..d957a0c00 100644 --- a/docs/examples/objc/iOS-CocoaPods/Podfile +++ b/docs/examples/objc/iOS-CocoaPods/Podfile @@ -16,13 +16,13 @@ source 'https://cdn.cocoapods.org/' -platform :ios, '12.0' +platform :ios, '12.4' project 'ThemisTest/ThemisTest.xcodeproj' inhibit_all_warnings! use_frameworks! target :"ThemisTest" do - pod 'themis', '0.14.0' + pod 'themis', '0.15.1' end diff --git a/docs/examples/objc/iOS-CocoaPods/Podfile.lock b/docs/examples/objc/iOS-CocoaPods/Podfile.lock index 8e2e2fe22..df8d01abe 100644 --- a/docs/examples/objc/iOS-CocoaPods/Podfile.lock +++ b/docs/examples/objc/iOS-CocoaPods/Podfile.lock @@ -1,19 +1,19 @@ PODS: - - CLOpenSSL-XCF (1.1.11101) - - themis (0.14.0): - - themis/openssl-1.1.1 (= 0.14.0) - - themis/openssl-1.1.1 (0.14.0): - - CLOpenSSL-XCF (= 1.1.11101) - - themis/openssl-1.1.1/core (= 0.14.0) - - themis/openssl-1.1.1/objcwrapper (= 0.14.0) - - themis/openssl-1.1.1/core (0.14.0): - - CLOpenSSL-XCF (= 1.1.11101) - - themis/openssl-1.1.1/objcwrapper (0.14.0): - - CLOpenSSL-XCF (= 1.1.11101) + - CLOpenSSL-XCF (1.1.12201) + - themis (0.15.1): + - themis/openssl-1.1.1 (= 0.15.1) + - themis/openssl-1.1.1 (0.15.1): + - CLOpenSSL-XCF (= 1.1.12201) + - themis/openssl-1.1.1/core (= 0.15.1) + - themis/openssl-1.1.1/objcwrapper (= 0.15.1) + - themis/openssl-1.1.1/core (0.15.1): + - CLOpenSSL-XCF (= 1.1.12201) + - themis/openssl-1.1.1/objcwrapper (0.15.1): + - CLOpenSSL-XCF (= 1.1.12201) - themis/openssl-1.1.1/core DEPENDENCIES: - - themis (= 0.14.0) + - themis (= 0.15.1) SPEC REPOS: trunk: @@ -21,9 +21,9 @@ SPEC REPOS: - themis SPEC CHECKSUMS: - CLOpenSSL-XCF: 71ce1fb96734754ea5936e239e15999129413793 - themis: 4bcef173f13a428822f8db4cb504e4c7b2c302b1 + CLOpenSSL-XCF: e2a7aaaa5b72683e1b52f168272f3f5eeec02446 + themis: e26d27e3889c07bddebad32ea98b0e502020d82a -PODFILE CHECKSUM: c544df5cbc47ee301679b77bbdbc4d4509f4d351 +PODFILE CHECKSUM: b415dfb4d230ccd5775f41ad7fe3c2193f5e0e3b -COCOAPODS: 1.11.3 +COCOAPODS: 1.12.1 diff --git a/docs/examples/objc/iOS-CocoaPods/ThemisTest/ThemisTest.xcodeproj/project.pbxproj b/docs/examples/objc/iOS-CocoaPods/ThemisTest/ThemisTest.xcodeproj/project.pbxproj index 1b1bc1d2a..e9ea7d78e 100644 --- a/docs/examples/objc/iOS-CocoaPods/ThemisTest/ThemisTest.xcodeproj/project.pbxproj +++ b/docs/examples/objc/iOS-CocoaPods/ThemisTest/ThemisTest.xcodeproj/project.pbxproj @@ -342,7 +342,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -391,7 +391,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTS_MACCATALYST = NO; @@ -407,10 +407,10 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; CURRENT_PROJECT_VERSION = 2021122301; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = ThemisTest/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.ThemisTest; @@ -429,10 +429,10 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; CURRENT_PROJECT_VERSION = 2021122301; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = ThemisTest/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.ThemisTest; diff --git a/docs/examples/objc/iOS-SPM/ThemisTest.xcodeproj/project.pbxproj b/docs/examples/objc/iOS-SPM/ThemisTest.xcodeproj/project.pbxproj index 9b245a15a..405f3aa6e 100644 --- a/docs/examples/objc/iOS-SPM/ThemisTest.xcodeproj/project.pbxproj +++ b/docs/examples/objc/iOS-SPM/ThemisTest.xcodeproj/project.pbxproj @@ -3,11 +3,11 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ - 1D0749F228D10B6A00EAF77F /* themis in Frameworks */ = {isa = PBXBuildFile; productRef = 1D0749F128D10B6A00EAF77F /* themis */; }; + 1DD6A1AF2AB0E1510086E940 /* themis in Frameworks */ = {isa = PBXBuildFile; productRef = 1DD6A1AE2AB0E1510086E940 /* themis */; }; 6D93CFF9263C294600ED53C4 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D93CFF8263C294600ED53C4 /* AppDelegate.m */; }; 6D93CFFC263C294600ED53C4 /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D93CFFB263C294600ED53C4 /* SceneDelegate.m */; }; 6D93CFFF263C294600ED53C4 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D93CFFE263C294600ED53C4 /* ViewController.m */; }; @@ -45,7 +45,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 1D0749F228D10B6A00EAF77F /* themis in Frameworks */, + 1DD6A1AF2AB0E1510086E940 /* themis in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -115,7 +115,7 @@ ); name = ThemisTest; packageProductDependencies = ( - 1D0749F128D10B6A00EAF77F /* themis */, + 1DD6A1AE2AB0E1510086E940 /* themis */, ); productName = ThemisTest; productReference = 6D93CFF4263C294600ED53C4 /* ThemisTest.app */; @@ -144,7 +144,7 @@ ); mainGroup = 6D93CFEB263C294600ED53C4; packageReferences = ( - 1D0749F028D10B6A00EAF77F /* XCRemoteSwiftPackageReference "themis" */, + 1DD6A1AD2AB0E1510086E940 /* XCRemoteSwiftPackageReference "themis" */, ); productRefGroup = 6D93CFF5263C294600ED53C4 /* Products */; projectDirPath = ""; @@ -257,7 +257,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.4; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -310,7 +310,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.4; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; @@ -323,11 +323,12 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = ""; CURRENT_PROJECT_VERSION = 2021122301; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = ThemisTest/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -345,11 +346,12 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = ""; CURRENT_PROJECT_VERSION = 2021122301; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = ThemisTest/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -386,20 +388,20 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - 1D0749F028D10B6A00EAF77F /* XCRemoteSwiftPackageReference "themis" */ = { + 1DD6A1AD2AB0E1510086E940 /* XCRemoteSwiftPackageReference "themis" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/cossacklabs/themis"; requirement = { - kind = exactVersion; - version = 0.14.9; + kind = upToNextMajorVersion; + minimumVersion = 0.15.1; }; }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - 1D0749F128D10B6A00EAF77F /* themis */ = { + 1DD6A1AE2AB0E1510086E940 /* themis */ = { isa = XCSwiftPackageProductDependency; - package = 1D0749F028D10B6A00EAF77F /* XCRemoteSwiftPackageReference "themis" */; + package = 1DD6A1AD2AB0E1510086E940 /* XCRemoteSwiftPackageReference "themis" */; productName = themis; }; /* End XCSwiftPackageProductDependency section */ diff --git a/docs/examples/objc/iOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/docs/examples/objc/iOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index e47c2d834..306ef7de6 100644 --- a/docs/examples/objc/iOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/docs/examples/objc/iOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/cossacklabs/themis", "state" : { - "revision" : "b573ad970462e5ccc9dbafe5d954e57dcc386ba8", - "version" : "0.14.9" + "revision" : "7f06746a645947cf8d40cfca95d9562517457093", + "version" : "0.15.1" } } ], diff --git a/docs/examples/objc/macOS-Carthage/Cartfile b/docs/examples/objc/macOS-Carthage/Cartfile index 6dabbc94c..5491d89fa 100644 --- a/docs/examples/objc/macOS-Carthage/Cartfile +++ b/docs/examples/objc/macOS-Carthage/Cartfile @@ -1 +1 @@ -github "cossacklabs/themis" ~> 0.14.0 +github "cossacklabs/themis" "0.15.1" diff --git a/docs/examples/objc/macOS-Carthage/Cartfile.resolved b/docs/examples/objc/macOS-Carthage/Cartfile.resolved index b797566b5..2281e75b9 100644 --- a/docs/examples/objc/macOS-Carthage/Cartfile.resolved +++ b/docs/examples/objc/macOS-Carthage/Cartfile.resolved @@ -1,2 +1,2 @@ -binary "https://raw.githubusercontent.com/cossacklabs/openssl-apple/cossacklabs/carthage/openssl-static-xcframework.json" "1.1.11101" -github "cossacklabs/themis" "0.14.0" +binary "https://raw.githubusercontent.com/cossacklabs/openssl-apple/cossacklabs/carthage/openssl-static-xcframework.json" "1.1.12201" +github "cossacklabs/themis" "0.15.1" diff --git a/docs/examples/objc/macOS-Carthage/ThemisTest.xcodeproj/project.pbxproj b/docs/examples/objc/macOS-Carthage/ThemisTest.xcodeproj/project.pbxproj index 1b0b2eb21..ed4d3fee3 100644 --- a/docs/examples/objc/macOS-Carthage/ThemisTest.xcodeproj/project.pbxproj +++ b/docs/examples/objc/macOS-Carthage/ThemisTest.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -241,7 +241,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; + MACOSX_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = NO; @@ -295,7 +295,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; + MACOSX_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = NO; @@ -322,7 +322,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 11.0; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis.ThemisTest; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -348,7 +348,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 11.0; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis.ThemisTest; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/docs/examples/objc/macOS-SPM/ThemisTest.xcodeproj/project.pbxproj b/docs/examples/objc/macOS-SPM/ThemisTest.xcodeproj/project.pbxproj index 93d7aabf3..a843a09ff 100644 --- a/docs/examples/objc/macOS-SPM/ThemisTest.xcodeproj/project.pbxproj +++ b/docs/examples/objc/macOS-SPM/ThemisTest.xcodeproj/project.pbxproj @@ -3,11 +3,11 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ - 1DC9905A28D10F9800179131 /* themis in Frameworks */ = {isa = PBXBuildFile; productRef = 1DC9905928D10F9800179131 /* themis */; }; + 1D39D6D72AB0E95900AAE562 /* themis in Frameworks */ = {isa = PBXBuildFile; productRef = 1D39D6D62AB0E95900AAE562 /* themis */; }; 6D445235263C2B4C00871215 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D445234263C2B4C00871215 /* AppDelegate.m */; }; 6D445238263C2B4C00871215 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D445237263C2B4C00871215 /* ViewController.m */; }; 6D44523A263C2B4E00871215 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6D445239263C2B4E00871215 /* Assets.xcassets */; }; @@ -41,7 +41,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 1DC9905A28D10F9800179131 /* themis in Frameworks */, + 1D39D6D72AB0E95900AAE562 /* themis in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -109,7 +109,7 @@ ); name = ThemisTest; packageProductDependencies = ( - 1DC9905928D10F9800179131 /* themis */, + 1D39D6D62AB0E95900AAE562 /* themis */, ); productName = ThemisTest; productReference = 6D445230263C2B4C00871215 /* ThemisTest.app */; @@ -138,7 +138,7 @@ ); mainGroup = 6D445227263C2B4C00871215; packageReferences = ( - 1DC9905828D10F9800179131 /* XCRemoteSwiftPackageReference "themis" */, + 1D39D6D52AB0E95900AAE562 /* XCRemoteSwiftPackageReference "themis" */, ); productRefGroup = 6D445231263C2B4C00871215 /* Products */; projectDirPath = ""; @@ -241,7 +241,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.15; + MACOSX_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -294,7 +294,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.15; + MACOSX_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; @@ -363,20 +363,20 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - 1DC9905828D10F9800179131 /* XCRemoteSwiftPackageReference "themis" */ = { + 1D39D6D52AB0E95900AAE562 /* XCRemoteSwiftPackageReference "themis" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/cossacklabs/themis"; requirement = { - kind = exactVersion; - version = 0.14.9; + kind = upToNextMajorVersion; + minimumVersion = 0.15.1; }; }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - 1DC9905928D10F9800179131 /* themis */ = { + 1D39D6D62AB0E95900AAE562 /* themis */ = { isa = XCSwiftPackageProductDependency; - package = 1DC9905828D10F9800179131 /* XCRemoteSwiftPackageReference "themis" */; + package = 1D39D6D52AB0E95900AAE562 /* XCRemoteSwiftPackageReference "themis" */; productName = themis; }; /* End XCSwiftPackageProductDependency section */ diff --git a/docs/examples/objc/macOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/docs/examples/objc/macOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index e47c2d834..306ef7de6 100644 --- a/docs/examples/objc/macOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/docs/examples/objc/macOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/cossacklabs/themis", "state" : { - "revision" : "b573ad970462e5ccc9dbafe5d954e57dcc386ba8", - "version" : "0.14.9" + "revision" : "7f06746a645947cf8d40cfca95d9562517457093", + "version" : "0.15.1" } } ], diff --git a/docs/examples/react-native/react-native-example/_bundle/config b/docs/examples/react-native/RNThemisExample/.bundle/config similarity index 100% rename from docs/examples/react-native/react-native-example/_bundle/config rename to docs/examples/react-native/RNThemisExample/.bundle/config diff --git a/docs/examples/react-native/RNThemisExample/.eslintrc.js b/docs/examples/react-native/RNThemisExample/.eslintrc.js new file mode 100644 index 000000000..187894b6a --- /dev/null +++ b/docs/examples/react-native/RNThemisExample/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + root: true, + extends: '@react-native', +}; diff --git a/docs/examples/react-native/react-native-example/.gitignore b/docs/examples/react-native/RNThemisExample/.gitignore similarity index 72% rename from docs/examples/react-native/react-native-example/.gitignore rename to docs/examples/react-native/RNThemisExample/.gitignore index cc53454ef..0cab2ac6f 100644 --- a/docs/examples/react-native/react-native-example/.gitignore +++ b/docs/examples/react-native/RNThemisExample/.gitignore @@ -20,6 +20,7 @@ DerivedData *.hmap *.ipa *.xcuserstate +ios/.xcode.env.local # Android/IntelliJ # @@ -29,6 +30,9 @@ build/ local.properties *.iml *.hprof +.cxx/ +*.keystore +!debug.keystore # node.js # @@ -36,12 +40,6 @@ node_modules/ npm-debug.log yarn-error.log -# BUCK -buck-out/ -\.buckd/ -*.keystore -!debug.keystore - # fastlane # # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the @@ -49,12 +47,20 @@ buck-out/ # For more information about the recommended setup visit: # https://docs.fastlane.tools/best-practices/source-control/ -*/fastlane/report.xml -*/fastlane/Preview.html -*/fastlane/screenshots +**/fastlane/report.xml +**/fastlane/Preview.html +**/fastlane/screenshots +**/fastlane/test_output # Bundle artifact *.jsbundle -# CocoaPods +# Ruby / CocoaPods /ios/Pods/ +/vendor/bundle/ + +# Temporary files created by Metro to check the health of the file watcher +.metro-health-check* + +# testing +/coverage diff --git a/docs/examples/react-native/react-native-example/.prettierrc.js b/docs/examples/react-native/RNThemisExample/.prettierrc.js similarity index 80% rename from docs/examples/react-native/react-native-example/.prettierrc.js rename to docs/examples/react-native/RNThemisExample/.prettierrc.js index 84196d95f..2b540746a 100644 --- a/docs/examples/react-native/react-native-example/.prettierrc.js +++ b/docs/examples/react-native/RNThemisExample/.prettierrc.js @@ -1,7 +1,7 @@ module.exports = { + arrowParens: 'avoid', + bracketSameLine: true, bracketSpacing: false, - jsxBracketSameLine: true, singleQuote: true, trailingComma: 'all', - arrowParens: 'avoid', }; diff --git a/docs/examples/react-native/RNThemisExample/.watchmanconfig b/docs/examples/react-native/RNThemisExample/.watchmanconfig new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/docs/examples/react-native/RNThemisExample/.watchmanconfig @@ -0,0 +1 @@ +{} diff --git a/docs/examples/react-native/react-native-example/App.js b/docs/examples/react-native/RNThemisExample/App.tsx similarity index 84% rename from docs/examples/react-native/react-native-example/App.js rename to docs/examples/react-native/RNThemisExample/App.tsx index e9667ae95..18a03f456 100644 --- a/docs/examples/react-native/react-native-example/App.js +++ b/docs/examples/react-native/RNThemisExample/App.tsx @@ -6,8 +6,8 @@ * @flow strict-local */ -import React, { useState, useEffect } from 'react'; -import type { Node } from 'react'; +import React, {useState, useEffect} from 'react'; +import type {ReactNode} from 'react'; import { SafeAreaView, ScrollView, @@ -51,50 +51,54 @@ import { COMPARATOR_ERROR } from 'react-native-themis'; +type SectionProps = { + children: ReactNode; + title: string; +}; -const Section = ({ children, title }): Node => { +const Section: React.FC = ({ children, title }) => { const isDarkMode = useColorScheme() === 'dark'; return ( - + - { title } + ]}> + {title} - { children } + ]}> + {children} ); }; -const App: () => Node = () => { +const App: React.FC = () => { const isDarkMode = useColorScheme() === 'dark'; const backgroundStyle = { backgroundColor: isDarkMode ? Colors.darker : Colors.lighter, }; - const [privateKey, setPrivateKey] = useState(''); - const [publicKey, setPublicKey] = useState(''); - const [masterKey, setMasterKey] = useState(''); - const [encryptedWithKey, setEncryptedWithKey] = useState(''); - const [encryptedWithPassphrase, setEncryptedWithPassphrase] = useState(''); - const [encryptedWithTokenProtect, setEncryptedWithTokenProtect] = useState(''); - const [tokenProtect, setTokenProtect] = useState(''); - const [encryptedWithContextImprint, setEncryptedWithContextImprint] = useState(''); - const [signedSecureMessage, setSignedSecureMessage] = useState(''); - const [encryptedSecureMessage, setEncryptedSecureMessage] = useState(''); + const [privateKey, setPrivateKey] = useState(''); + const [publicKey, setPublicKey] = useState(''); + const [masterKey, setMasterKey] = useState(''); + const [encryptedWithKey, setEncryptedWithKey] = useState(''); + const [encryptedWithPassphrase, setEncryptedWithPassphrase] = useState(''); + const [encryptedWithTokenProtect, setEncryptedWithTokenProtect] = useState(''); + const [tokenProtect, setTokenProtect] = useState(''); + const [encryptedWithContextImprint, setEncryptedWithContextImprint] = useState(''); + const [signedSecureMessage, setSignedSecureMessage] = useState(''); + const [encryptedSecureMessage, setEncryptedSecureMessage] = useState(''); const plaintext = "Hello, Themis!"; const context = "Themis context"; @@ -102,12 +106,6 @@ const App: () => Node = () => { useEffect(() => { - // Just converting incoming base64 string to UTF-8 encoded string - const cat = "0JrQvtGI0LrQsCDRjdGC0LAg0LHRi9C70LAg0LDQsdGB0L7Qu9GO0YLQvdC+INGH0LXRgNC90LDRjywg0LPQu9Cw0LTQutCw0Y8sINC60LDQuiDQv9Cw0L3RgtC10YDQsCwg0LrRgNCw0YHQuNCy0LDRjyDQuCwg0L/Qvi3QstC40LTQuNC80L7QvNGDLCDRhdC+0YDQvtGI0LjRhSDQutGA0L7QstC10LkuINCd0L4g0LXQuSDQvdC1INC/0L7QstC10LfQu9C+INCyINC20LjQt9C90LggKNGB0LrQvtGA0LXQtSDQstGB0LXQs9C+LCDQutGC0L4t0YLQviDQstGL0LPQvdCw0Lsg0LjQtyDQtNC+0LzRgykg0Lgg0L7QvdCwINGB0LDQvNCwINC/0YDQvtC80YvRiNC70Y/Qu9CwINC/0YDQvtC/0LjRgtCw0L3QuNC1Lg0K0JvQtdGC0L7QvCDQvdCwINCx0LvQuNC20LDQudGI0LjRhSDQtNCw0YfQvdGL0YUg0YPRh9Cw0YHRgtC60LDRhSwg0LAg0LfQuNC80L7QuSDQvdCwINC+0LrRgNC10YHRgtC90YvRhSDQv9C+0LzQvtC50LrQsNGFINCyINC/0L7RgdC10LvQutC1LiDQm9GO0LTQtdC5INC90LUg0LHQvtGP0LvQsNGB0YwsINC90L4g0Lgg0L3QtSDQt9Cw0LjRgdC60LjQstCw0LvQsCwg0Lgg0LIg0YDRg9C60Lgg0L3QtSDQtNCw0LLQsNC70LDRgdGMLiDQl9CwINC/0L7QvNC+0LnQutC4INGB0LLQuNGA0LXQv9C+INC00YDQsNC70LDRgdGMINCyINC+0LrRgNC10YHRgtC90YvQvNC4INC60L7RgtCw0LzQuCwg0LrQvtGC0L7RgNGL0LUg0LXQtSDRgdC40LvRjNC90L4g0YPQstCw0LbQsNC70LguINCt0LTQsNC60LDRjyDRhdCy0L7RgdGC0LDRgtCw0Y8gwqvQu9C10LTQuC3QvNCw0YTQuNGPwrsg0LIg0YfQtdGA0L3QvtC8LCDRgSDRgNC10LLQvtC70YzQstC10YDQvtC8INC30LAg0L/QvtGP0YHQvtC8LCDQutC+0YLQvtGA0LDRjyDQtNGA0LDQuiDQvdC1INC30LDRgtC10LLQsNC10YIsINC90L4g0LIg0YHQu9GD0YfQsNC1INGH0LXQs9C+INC/0YDQuNGB0YLRgNC10LvQuNGCLCDQvdC1INC80L7RgNCz0L3Rg9CyINCz0LvQsNC30L7QvC4="; - const buf = Buffer.from(cat, 'base64').toString("utf-8"); - console.log("==> Cat <==:", buf); - // End of converting example - // Async Themis keyPair64 example. It resolves with asymmetric key pair anyway. // Always return base64 encoded strings keyPair64(KEYTYPE_EC) @@ -236,7 +234,7 @@ const App: () => Node = () => { const lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam aliquam dictum tellus, eget malesuada lectus scelerisque non. Curabitur at nibh vestibulum, sagittis felis non, convallis magna. Vestibulum fringilla a urna quis facilisis. Etiam rhoncus hendrerit diam, at elementum nisi condimentum dignissim. Nam eleifend libero accumsan pharetra cursus. Phasellus eget nulla pellentesque, elementum dui eu, malesuada mi. Quisque dolor augue, mattis ut mauris id, sollicitudin fermentum elit. Suspendisse nulla velit, tincidunt a viverra interdum, cursus vitae nunc. Proin turpis ante, consectetur nec nisl consequat, rhoncus congue risus. Sed mattis tempus mi quis hendrerit. Nullam sit amet arcu dapibus, dignissim risus nec, tempus metus. Morbi condimentum sagittis metus eu eleifend. Duis scelerisque eu tellus non porta. Duis viverra tincidunt congue."; const lorem64 = string64(lorem); - async function proceedCompare(data64: String, serverID: String, clientID: String): Promise { + async function proceedCompare(data64: string, serverID: string, clientID: string): Promise { console.log("Before server part of comparator", serverID, data64); const serverResult = await comparatorProceed64(serverID, data64); console.log("Server proceeded with result:", serverResult); @@ -384,8 +382,8 @@ const App: () => Node = () => { - - + + ); }; @@ -407,11 +405,11 @@ const styles = StyleSheet.create({ fontWeight: '700', }, blob: { - fontSize: 14, - fontFamily: Platform.OS === 'ios' ? 'Courier' : 'monospace', - flexWrap: 'nowrap', - flexShrink: 1, - } + fontFamily: "Courier", + backgroundColor: 'lightgray', + borderRadius: 5, + padding: 5, + }, }); export default App; diff --git a/docs/examples/react-native/react-native-example/Gemfile b/docs/examples/react-native/RNThemisExample/Gemfile similarity index 56% rename from docs/examples/react-native/react-native-example/Gemfile rename to docs/examples/react-native/RNThemisExample/Gemfile index 2c3edcf4b..993d6c33f 100644 --- a/docs/examples/react-native/react-native-example/Gemfile +++ b/docs/examples/react-native/RNThemisExample/Gemfile @@ -1,6 +1,8 @@ source 'https://rubygems.org' # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version -ruby '2.7.4' +ruby ">= 2.6.10" + +gem 'cocoapods', '~> 1.12' +gem 'activesupport', '~> 7.0', '<= 7.0.8' -gem 'cocoapods', '~> 1.11', '>= 1.11.2' diff --git a/docs/examples/react-native/react-native-example/Gemfile.lock b/docs/examples/react-native/RNThemisExample/Gemfile.lock similarity index 69% rename from docs/examples/react-native/react-native-example/Gemfile.lock rename to docs/examples/react-native/RNThemisExample/Gemfile.lock index 640d2f1ed..4509e597f 100644 --- a/docs/examples/react-native/react-native-example/Gemfile.lock +++ b/docs/examples/react-native/RNThemisExample/Gemfile.lock @@ -1,30 +1,29 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (3.0.5) + CFPropertyList (3.0.6) rexml - activesupport (6.1.4.6) + activesupport (7.0.8) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.5) + public_suffix (>= 2.0.2, < 6.0) algoliasearch (1.27.5) httpclient (~> 2.8, >= 2.8.3) json (>= 1.5.1) atomos (0.1.3) claide (1.1.0) - cocoapods (1.11.2) + cocoapods (1.13.0) addressable (~> 2.8) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.11.2) + cocoapods-core (= 1.13.0) cocoapods-deintegrate (>= 1.0.3, < 2.0) - cocoapods-downloader (>= 1.4.0, < 2.0) + cocoapods-downloader (>= 1.6.0, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0) cocoapods-search (>= 1.0.0, < 2.0) - cocoapods-trunk (>= 1.4.0, < 2.0) + cocoapods-trunk (>= 1.6.0, < 2.0) cocoapods-try (>= 1.1.0, < 2.0) colored2 (~> 3.1) escape (~> 0.0.4) @@ -32,10 +31,10 @@ GEM gh_inspector (~> 1.0) molinillo (~> 0.8.0) nap (~> 1.0) - ruby-macho (>= 1.0, < 3.0) - xcodeproj (>= 1.21.0, < 2.0) - cocoapods-core (1.11.2) - activesupport (>= 5.0, < 7) + ruby-macho (>= 2.3.0, < 3.0) + xcodeproj (>= 1.23.0, < 2.0) + cocoapods-core (1.13.0) + activesupport (>= 5.0, < 8) addressable (~> 2.8) algoliasearch (~> 1.0) concurrent-ruby (~> 1.1) @@ -45,7 +44,7 @@ GEM public_suffix (~> 4.0) typhoeus (~> 1.0) cocoapods-deintegrate (1.0.5) - cocoapods-downloader (1.5.1) + cocoapods-downloader (1.6.3) cocoapods-plugins (1.0.0) nap cocoapods-search (1.0.1) @@ -54,47 +53,47 @@ GEM netrc (~> 0.11) cocoapods-try (1.2.0) colored2 (3.1.2) - concurrent-ruby (1.1.9) + concurrent-ruby (1.2.2) escape (0.0.4) - ethon (0.15.0) + ethon (0.16.0) ffi (>= 1.15.0) - ffi (1.15.5) + ffi (1.16.3) fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) httpclient (2.8.3) - i18n (1.10.0) + i18n (1.14.1) concurrent-ruby (~> 1.0) - json (2.6.1) - minitest (5.15.0) + json (2.6.3) + minitest (5.20.0) molinillo (0.8.0) nanaimo (0.3.0) nap (1.1.0) netrc (0.11.0) - public_suffix (4.0.6) - rexml (3.2.5) + public_suffix (4.0.7) + rexml (3.2.6) ruby-macho (2.5.1) typhoeus (1.4.0) ethon (>= 0.9.0) - tzinfo (2.0.4) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) - xcodeproj (1.21.0) + xcodeproj (1.23.0) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) nanaimo (~> 0.3.0) rexml (~> 3.2.4) - zeitwerk (2.5.4) PLATFORMS ruby DEPENDENCIES - cocoapods (~> 1.11, >= 1.11.2) + activesupport (~> 7.0, <= 7.0.8) + cocoapods (~> 1.12) RUBY VERSION - ruby 2.7.4p191 + ruby 3.2.2p53 BUNDLED WITH - 2.2.27 + 2.4.10 diff --git a/docs/examples/react-native/RNThemisExample/README.md b/docs/examples/react-native/RNThemisExample/README.md new file mode 100644 index 000000000..12470c30e --- /dev/null +++ b/docs/examples/react-native/RNThemisExample/README.md @@ -0,0 +1,79 @@ +This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli). + +# Getting Started + +>**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding. + +## Step 1: Start the Metro Server + +First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native. + +To start Metro, run the following command from the _root_ of your React Native project: + +```bash +# using npm +npm start + +# OR using Yarn +yarn start +``` + +## Step 2: Start your Application + +Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app: + +### For Android + +```bash +# using npm +npm run android + +# OR using Yarn +yarn android +``` + +### For iOS + +```bash +# using npm +npm run ios + +# OR using Yarn +yarn ios +``` + +If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly. + +This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively. + +## Step 3: Modifying your App + +Now that you have successfully run the app, let's modify it. + +1. Open `App.tsx` in your text editor of choice and edit some lines. +2. For **Android**: Press the R key twice or select **"Reload"** from the **Developer Menu** (Ctrl + M (on Window and Linux) or Cmd ⌘ + M (on macOS)) to see your changes! + + For **iOS**: Hit Cmd ⌘ + R in your iOS Simulator to reload the app and see your changes! + +## Congratulations! :tada: + +You've successfully run and modified your React Native App. :partying_face: + +### Now what? + +- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps). +- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started). + +# Troubleshooting + +If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page. + +# Learn More + +To learn more about React Native, take a look at the following resources: + +- [React Native Website](https://reactnative.dev) - learn more about React Native. +- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment. +- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**. +- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts. +- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native. diff --git a/docs/examples/react-native/ThemisTest/__tests__/App-test.js b/docs/examples/react-native/RNThemisExample/__tests__/App.test.tsx similarity index 73% rename from docs/examples/react-native/ThemisTest/__tests__/App-test.js rename to docs/examples/react-native/RNThemisExample/__tests__/App.test.tsx index 178476699..3413ac1c4 100644 --- a/docs/examples/react-native/ThemisTest/__tests__/App-test.js +++ b/docs/examples/react-native/RNThemisExample/__tests__/App.test.tsx @@ -6,6 +6,9 @@ import 'react-native'; import React from 'react'; import App from '../App'; +// Note: import explicitly to use the types shiped with jest. +import {it} from '@jest/globals'; + // Note: test renderer must be required after react-native. import renderer from 'react-test-renderer'; diff --git a/docs/examples/react-native/RNThemisExample/android/app/build.gradle b/docs/examples/react-native/RNThemisExample/android/app/build.gradle new file mode 100644 index 000000000..c777175eb --- /dev/null +++ b/docs/examples/react-native/RNThemisExample/android/app/build.gradle @@ -0,0 +1,123 @@ +apply plugin: "com.android.application" +apply plugin: "com.facebook.react" + +/** + * This is the configuration block to customize your React Native Android app. + * By default you don't need to apply any configuration, just uncomment the lines you need. + */ +react { + /* Folders */ + // The root of your project, i.e. where "package.json" lives. Default is '..' + // root = file("../") + // The folder where the react-native NPM package is. Default is ../node_modules/react-native + // reactNativeDir = file("../node_modules/react-native") + // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen + // codegenDir = file("../node_modules/@react-native/codegen") + // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js + // cliFile = file("../node_modules/react-native/cli.js") + + /* Variants */ + // The list of variants to that are debuggable. For those we're going to + // skip the bundling of the JS bundle and the assets. By default is just 'debug'. + // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. + // debuggableVariants = ["liteDebug", "prodDebug"] + + /* Bundling */ + // A list containing the node command and its flags. Default is just 'node'. + // nodeExecutableAndArgs = ["node"] + // + // The command to run when bundling. By default is 'bundle' + // bundleCommand = "ram-bundle" + // + // The path to the CLI configuration file. Default is empty. + // bundleConfig = file(../rn-cli.config.js) + // + // The name of the generated asset file containing your JS bundle + // bundleAssetName = "MyApplication.android.bundle" + // + // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' + // entryFile = file("../js/MyApplication.android.js") + // + // A list of extra flags to pass to the 'bundle' commands. + // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle + // extraPackagerArgs = [] + + /* Hermes Commands */ + // The hermes compiler command to run. By default it is 'hermesc' + // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" + // + // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" + // hermesFlags = ["-O", "-output-source-map"] +} + +/** + * Set this to true to Run Proguard on Release builds to minify the Java bytecode. + */ +def enableProguardInReleaseBuilds = false + +/** + * The preferred build flavor of JavaScriptCore (JSC) + * + * For example, to use the international variant, you can use: + * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` + * + * The international variant includes ICU i18n library and necessary data + * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that + * give correct results when using with locales other than en-US. Note that + * this variant is about 6MiB larger per architecture than default. + */ +def jscFlavor = 'org.webkit:android-jsc:+' + +android { + ndkVersion rootProject.ext.ndkVersion + + compileSdkVersion rootProject.ext.compileSdkVersion + + namespace "com.rnthemisexample" + defaultConfig { + applicationId "com.rnthemisexample" + minSdkVersion rootProject.ext.minSdkVersion + targetSdkVersion rootProject.ext.targetSdkVersion + versionCode 1 + versionName "1.0" + } + signingConfigs { + debug { + storeFile file('debug.keystore') + storePassword 'android' + keyAlias 'androiddebugkey' + keyPassword 'android' + } + } + buildTypes { + debug { + signingConfig signingConfigs.debug + } + release { + // Caution! In production, you need to generate your own keystore file. + // see https://reactnative.dev/docs/signed-apk-android. + signingConfig signingConfigs.debug + minifyEnabled enableProguardInReleaseBuilds + proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" + } + } +} + +dependencies { + // The version of react-native is set by the React Native Gradle Plugin + implementation("com.facebook.react:react-android") + + debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") + debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { + exclude group:'com.squareup.okhttp3', module:'okhttp' + } + + debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") + if (hermesEnabled.toBoolean()) { + implementation("com.facebook.react:hermes-android") + } else { + implementation jscFlavor + } +} + +apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) diff --git a/docs/examples/react-native/react-native-example/android/app/debug.keystore b/docs/examples/react-native/RNThemisExample/android/app/debug.keystore similarity index 100% rename from docs/examples/react-native/react-native-example/android/app/debug.keystore rename to docs/examples/react-native/RNThemisExample/android/app/debug.keystore diff --git a/docs/examples/react-native/react-native-example/android/app/proguard-rules.pro b/docs/examples/react-native/RNThemisExample/android/app/proguard-rules.pro similarity index 100% rename from docs/examples/react-native/react-native-example/android/app/proguard-rules.pro rename to docs/examples/react-native/RNThemisExample/android/app/proguard-rules.pro diff --git a/docs/examples/react-native/react-native-example/android/app/src/debug/AndroidManifest.xml b/docs/examples/react-native/RNThemisExample/android/app/src/debug/AndroidManifest.xml similarity index 90% rename from docs/examples/react-native/react-native-example/android/app/src/debug/AndroidManifest.xml rename to docs/examples/react-native/RNThemisExample/android/app/src/debug/AndroidManifest.xml index b2f3ad9fc..4b185bc15 100644 --- a/docs/examples/react-native/react-native-example/android/app/src/debug/AndroidManifest.xml +++ b/docs/examples/react-native/RNThemisExample/android/app/src/debug/AndroidManifest.xml @@ -8,6 +8,6 @@ android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning"> - + diff --git a/docs/examples/react-native/react-native-example/android/app/src/debug/java/com/themisexample/ReactNativeFlipper.java b/docs/examples/react-native/RNThemisExample/android/app/src/debug/java/com/rnthemisexample/ReactNativeFlipper.java similarity index 88% rename from docs/examples/react-native/react-native-example/android/app/src/debug/java/com/themisexample/ReactNativeFlipper.java rename to docs/examples/react-native/RNThemisExample/android/app/src/debug/java/com/rnthemisexample/ReactNativeFlipper.java index 62ac7448f..70e8d4c81 100644 --- a/docs/examples/react-native/react-native-example/android/app/src/debug/java/com/themisexample/ReactNativeFlipper.java +++ b/docs/examples/react-native/RNThemisExample/android/app/src/debug/java/com/rnthemisexample/ReactNativeFlipper.java @@ -1,10 +1,10 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * Copyright (c) Meta Platforms, Inc. and affiliates. * *

This source code is licensed under the MIT license found in the LICENSE file in the root * directory of this source tree. */ -package com.themisexample; +package com.rnthemisexample; import android.content.Context; import com.facebook.flipper.android.AndroidFlipperClient; @@ -17,20 +17,23 @@ import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; -import com.facebook.flipper.plugins.react.ReactFlipperPlugin; import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; +import com.facebook.react.ReactInstanceEventListener; import com.facebook.react.ReactInstanceManager; import com.facebook.react.bridge.ReactContext; import com.facebook.react.modules.network.NetworkingModule; import okhttp3.OkHttpClient; +/** + * Class responsible of loading Flipper inside your React Native application. This is the debug + * flavor of it. Here you can add your own plugins and customize the Flipper setup. + */ public class ReactNativeFlipper { public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { if (FlipperUtils.shouldEnableFlipper(context)) { final FlipperClient client = AndroidFlipperClient.getInstance(context); client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); - client.addPlugin(new ReactFlipperPlugin()); client.addPlugin(new DatabasesFlipperPlugin(context)); client.addPlugin(new SharedPreferencesFlipperPlugin(context)); client.addPlugin(CrashReporterPlugin.getInstance()); @@ -51,7 +54,7 @@ public void apply(OkHttpClient.Builder builder) { ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); if (reactContext == null) { reactInstanceManager.addReactInstanceEventListener( - new ReactInstanceManager.ReactInstanceEventListener() { + new ReactInstanceEventListener() { @Override public void onReactContextInitialized(ReactContext reactContext) { reactInstanceManager.removeReactInstanceEventListener(this); diff --git a/docs/examples/react-native/react-native-example/android/app/src/main/AndroidManifest.xml b/docs/examples/react-native/RNThemisExample/android/app/src/main/AndroidManifest.xml similarity index 85% rename from docs/examples/react-native/react-native-example/android/app/src/main/AndroidManifest.xml rename to docs/examples/react-native/RNThemisExample/android/app/src/main/AndroidManifest.xml index 96a7aa473..4122f36a5 100644 --- a/docs/examples/react-native/react-native-example/android/app/src/main/AndroidManifest.xml +++ b/docs/examples/react-native/RNThemisExample/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + @@ -13,9 +12,10 @@ + android:windowSoftInputMode="adjustResize" + android:exported="true"> diff --git a/docs/examples/react-native/RNThemisExample/android/app/src/main/java/com/rnthemisexample/MainActivity.java b/docs/examples/react-native/RNThemisExample/android/app/src/main/java/com/rnthemisexample/MainActivity.java new file mode 100644 index 000000000..dd92445ae --- /dev/null +++ b/docs/examples/react-native/RNThemisExample/android/app/src/main/java/com/rnthemisexample/MainActivity.java @@ -0,0 +1,32 @@ +package com.rnthemisexample; + +import com.facebook.react.ReactActivity; +import com.facebook.react.ReactActivityDelegate; +import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; +import com.facebook.react.defaults.DefaultReactActivityDelegate; + +public class MainActivity extends ReactActivity { + + /** + * Returns the name of the main component registered from JavaScript. This is used to schedule + * rendering of the component. + */ + @Override + protected String getMainComponentName() { + return "RNThemisExample"; + } + + /** + * Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link + * DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React + * (aka React 18) with two boolean flags. + */ + @Override + protected ReactActivityDelegate createReactActivityDelegate() { + return new DefaultReactActivityDelegate( + this, + getMainComponentName(), + // If you opted-in for the New Architecture, we enable the Fabric Renderer. + DefaultNewArchitectureEntryPoint.getFabricEnabled()); + } +} diff --git a/docs/examples/react-native/RNThemisExample/android/app/src/main/java/com/rnthemisexample/MainApplication.java b/docs/examples/react-native/RNThemisExample/android/app/src/main/java/com/rnthemisexample/MainApplication.java new file mode 100644 index 000000000..4e6d4a8e2 --- /dev/null +++ b/docs/examples/react-native/RNThemisExample/android/app/src/main/java/com/rnthemisexample/MainApplication.java @@ -0,0 +1,62 @@ +package com.rnthemisexample; + +import android.app.Application; +import com.facebook.react.PackageList; +import com.facebook.react.ReactApplication; +import com.facebook.react.ReactNativeHost; +import com.facebook.react.ReactPackage; +import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; +import com.facebook.react.defaults.DefaultReactNativeHost; +import com.facebook.soloader.SoLoader; +import java.util.List; + +public class MainApplication extends Application implements ReactApplication { + + private final ReactNativeHost mReactNativeHost = + new DefaultReactNativeHost(this) { + @Override + public boolean getUseDeveloperSupport() { + return BuildConfig.DEBUG; + } + + @Override + protected List getPackages() { + @SuppressWarnings("UnnecessaryLocalVariable") + List packages = new PackageList(this).getPackages(); + // Packages that cannot be autolinked yet can be added manually here, for example: + // packages.add(new MyReactNativePackage()); + return packages; + } + + @Override + protected String getJSMainModuleName() { + return "index"; + } + + @Override + protected boolean isNewArchEnabled() { + return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; + } + + @Override + protected Boolean isHermesEnabled() { + return BuildConfig.IS_HERMES_ENABLED; + } + }; + + @Override + public ReactNativeHost getReactNativeHost() { + return mReactNativeHost; + } + + @Override + public void onCreate() { + super.onCreate(); + SoLoader.init(this, /* native exopackage */ false); + if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { + // If you opted-in for the New Architecture, we load the native entry point for this app. + DefaultNewArchitectureEntryPoint.load(); + } + ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); + } +} diff --git a/docs/examples/react-native/react-native-example/android/app/src/main/res/drawable/rn_edit_text_material.xml b/docs/examples/react-native/RNThemisExample/android/app/src/main/res/drawable/rn_edit_text_material.xml similarity index 99% rename from docs/examples/react-native/react-native-example/android/app/src/main/res/drawable/rn_edit_text_material.xml rename to docs/examples/react-native/RNThemisExample/android/app/src/main/res/drawable/rn_edit_text_material.xml index f35d99620..73b37e4d9 100644 --- a/docs/examples/react-native/react-native-example/android/app/src/main/res/drawable/rn_edit_text_material.xml +++ b/docs/examples/react-native/RNThemisExample/android/app/src/main/res/drawable/rn_edit_text_material.xml @@ -20,7 +20,7 @@ android:insetBottom="@dimen/abc_edit_text_inset_bottom_material"> -