Initial commit

This commit is contained in:
Mark Vayngrib
2015-11-19 19:50:48 +00:00
committed by Mark Vayngrib
commit 9b90576393
12 changed files with 570 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
+22
View File
@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Mark Vayngrib
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+15
View File
@@ -0,0 +1,15 @@
//
// RNRandomBytes.h
// randombytes
//
// Created by Mark Vayngrib on 10/13/15.
// Copyright (c) 2015 Facebook. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
#import "RCTBridge.h"
@interface RNRandomBytes : NSObject<RCTBridgeModule>
@end
+28
View File
@@ -0,0 +1,28 @@
//
// RNRandom.m
// randombytes
//
// Created by Mark Vayngrib on 10/13/15.
// Copyright (c) 2015 Facebook. All rights reserved.
//
#import "RNRandomBytes.h"
#import "RCTBridgeModule.h"
#import "RCTBridge.h"
@implementation RNRandomBytes
RCT_EXPORT_MODULE()
@synthesize bridge = _bridge;
RCT_EXPORT_METHOD(randomBytes:(NSUInteger)length
callback:(RCTResponseSenderBlock)callback)
{
NSMutableData* bytes = [NSMutableData dataWithLength:length];
SecRandomCopyBytes(kSecRandomDefault, length, [bytes mutableBytes]);
NSString *passphrase = [bytes base64EncodedStringWithOptions:0];
callback(@[[NSNull null], passphrase]);
}
@end
+274
View File
@@ -0,0 +1,274 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
73EEC93D1BFE4B1D00D468EB /* RNRandomBytes.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 73EEC93C1BFE4B1D00D468EB /* RNRandomBytes.h */; };
73EEC93F1BFE4B1D00D468EB /* RNRandomBytes.m in Sources */ = {isa = PBXBuildFile; fileRef = 73EEC93E1BFE4B1D00D468EB /* RNRandomBytes.m */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
73EEC9371BFE4B1D00D468EB /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "include/$(PRODUCT_NAME)";
dstSubfolderSpec = 16;
files = (
73EEC93D1BFE4B1D00D468EB /* RNRandomBytes.h in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
73EEC9391BFE4B1D00D468EB /* libRNRandomBytes.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNRandomBytes.a; sourceTree = BUILT_PRODUCTS_DIR; };
73EEC93C1BFE4B1D00D468EB /* RNRandomBytes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNRandomBytes.h; sourceTree = "<group>"; };
73EEC93E1BFE4B1D00D468EB /* RNRandomBytes.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNRandomBytes.m; sourceTree = "<group>"; };
73EEC94A1BFE4B1D00D468EB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
73EEC9361BFE4B1D00D468EB /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
73EEC9301BFE4B1D00D468EB = {
isa = PBXGroup;
children = (
73EEC93C1BFE4B1D00D468EB /* RNRandomBytes.h */,
73EEC93E1BFE4B1D00D468EB /* RNRandomBytes.m */,
73EEC9481BFE4B1D00D468EB /* RNRandomBytesTests */,
73EEC93A1BFE4B1D00D468EB /* Products */,
);
sourceTree = "<group>";
};
73EEC93A1BFE4B1D00D468EB /* Products */ = {
isa = PBXGroup;
children = (
73EEC9391BFE4B1D00D468EB /* libRNRandomBytes.a */,
);
name = Products;
sourceTree = "<group>";
};
73EEC9481BFE4B1D00D468EB /* RNRandomBytesTests */ = {
isa = PBXGroup;
children = (
73EEC9491BFE4B1D00D468EB /* Supporting Files */,
);
path = RNRandomBytesTests;
sourceTree = "<group>";
};
73EEC9491BFE4B1D00D468EB /* Supporting Files */ = {
isa = PBXGroup;
children = (
73EEC94A1BFE4B1D00D468EB /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
73EEC9381BFE4B1D00D468EB /* RNRandomBytes */ = {
isa = PBXNativeTarget;
buildConfigurationList = 73EEC94D1BFE4B1D00D468EB /* Build configuration list for PBXNativeTarget "RNRandomBytes" */;
buildPhases = (
73EEC9351BFE4B1D00D468EB /* Sources */,
73EEC9361BFE4B1D00D468EB /* Frameworks */,
73EEC9371BFE4B1D00D468EB /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = RNRandomBytes;
productName = RNRandomBytes;
productReference = 73EEC9391BFE4B1D00D468EB /* libRNRandomBytes.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
73EEC9311BFE4B1D00D468EB /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0640;
ORGANIZATIONNAME = "Tradle, Inc.";
TargetAttributes = {
73EEC9381BFE4B1D00D468EB = {
CreatedOnToolsVersion = 6.4;
};
};
};
buildConfigurationList = 73EEC9341BFE4B1D00D468EB /* Build configuration list for PBXProject "RNRandomBytes" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 73EEC9301BFE4B1D00D468EB;
productRefGroup = 73EEC93A1BFE4B1D00D468EB /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
73EEC9381BFE4B1D00D468EB /* RNRandomBytes */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
73EEC9351BFE4B1D00D468EB /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
73EEC93F1BFE4B1D00D468EB /* RNRandomBytes.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
73EEC94B1BFE4B1D00D468EB /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../React/**",
"$(SRCROOT)/../react-native/React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
73EEC94C1BFE4B1D00D468EB /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../React/**",
"$(SRCROOT)/../react-native/React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
73EEC94E1BFE4B1D00D468EB /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
name = Debug;
};
73EEC94F1BFE4B1D00D468EB /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
73EEC9341BFE4B1D00D468EB /* Build configuration list for PBXProject "RNRandomBytes" */ = {
isa = XCConfigurationList;
buildConfigurations = (
73EEC94B1BFE4B1D00D468EB /* Debug */,
73EEC94C1BFE4B1D00D468EB /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
73EEC94D1BFE4B1D00D468EB /* Build configuration list for PBXNativeTarget "RNRandomBytes" */ = {
isa = XCConfigurationList;
buildConfigurations = (
73EEC94E1BFE4B1D00D468EB /* Debug */,
73EEC94F1BFE4B1D00D468EB /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 73EEC9311BFE4B1D00D468EB /* Project object */;
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:RNRandomBytes.xcodeproj">
</FileRef>
</Workspace>
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0640"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "73EEC9381BFE4B1D00D468EB"
BuildableName = "libRNRandomBytes.a"
BlueprintName = "RNRandomBytes"
ReferencedContainer = "container:RNRandomBytes.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "73EEC9431BFE4B1D00D468EB"
BuildableName = "RNRandomBytesTests.xctest"
BlueprintName = "RNRandomBytesTests"
ReferencedContainer = "container:RNRandomBytes.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "73EEC9431BFE4B1D00D468EB"
BuildableName = "RNRandomBytesTests.xctest"
BlueprintName = "RNRandomBytesTests"
ReferencedContainer = "container:RNRandomBytes.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "73EEC9381BFE4B1D00D468EB"
BuildableName = "libRNRandomBytes.a"
BlueprintName = "RNRandomBytes"
ReferencedContainer = "container:RNRandomBytes.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "73EEC9381BFE4B1D00D468EB"
BuildableName = "libRNRandomBytes.a"
BlueprintName = "RNRandomBytes"
ReferencedContainer = "container:RNRandomBytes.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "73EEC9381BFE4B1D00D468EB"
BuildableName = "libRNRandomBytes.a"
BlueprintName = "RNRandomBytes"
ReferencedContainer = "container:RNRandomBytes.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>RNRandomBytes.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>73EEC9381BFE4B1D00D468EB</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>73EEC9431BFE4B1D00D468EB</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
+24
View File
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>io.tradle.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
+16
View File
@@ -0,0 +1,16 @@
if (typeof Buffer === 'undefined') {
global.Buffer = require('buffer').Buffer
}
var {
RNRandomBytes
} = require('react-native').NativeModules
export function randomBytes (length, cb) {
if (!cb) throw new Error('synchronous API not supported')
RNRandomBytes.randomBytes(length, function (err, base64String) {
if (err) cb(err)
else cb(null, new Buffer(base64String, 'base64'))
})
}
+20
View File
@@ -0,0 +1,20 @@
{
"name": "react-native-randombytes",
"version": "1.0.0",
"description": "randomBytes for react-native",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"react-component",
"react-native",
"randomBytes",
"rng"
],
"dependencies": {
"buffer": "^3.5.2"
},
"author": "Mark Vayngrib <mark.vayngrib@lablz.com> (http://github.com/mvayngrib)",
"license": "ISC"
}