@synonymdev/react-native-pubky 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +20 -0
- package/README.md +57 -0
- package/android/build.gradle +101 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/pubky/PubkyModule.kt +43 -0
- package/android/src/main/java/com/pubky/PubkyPackage.kt +17 -0
- package/android/src/main/java/com/pubky/pubky.iml +11 -0
- package/android/src/main/java/uniffi/mobile/mobile.kt +688 -0
- package/android/src/main/jniLibs/arm64-v8a/libmobile.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libmobile.so +0 -0
- package/android/src/main/jniLibs/x86/libmobile.so +0 -0
- package/android/src/main/jniLibs/x86_64/libmobile.so +0 -0
- package/ios/Frameworks/Mobile.xcframework/Info.plist +47 -0
- package/ios/Frameworks/Mobile.xcframework/ios-arm64/Headers/mobileFFI.h +194 -0
- package/ios/Frameworks/Mobile.xcframework/ios-arm64/Headers/module.modulemap +6 -0
- package/ios/Frameworks/Mobile.xcframework/ios-arm64/libmobile.a +0 -0
- package/ios/Frameworks/Mobile.xcframework/ios-arm64-simulator/Headers/mobileFFI.h +194 -0
- package/ios/Frameworks/Mobile.xcframework/ios-arm64-simulator/Headers/module.modulemap +6 -0
- package/ios/Frameworks/Mobile.xcframework/ios-arm64-simulator/libmobile.a +0 -0
- package/ios/Pubky-Bridging-Header.h +2 -0
- package/ios/Pubky.mm +16 -0
- package/ios/Pubky.swift +16 -0
- package/ios/mobile.swift +484 -0
- package/lib/commonjs/index.js +25 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/index.js +21 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +3 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/index.d.ts +3 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +198 -0
- package/react-native-pubky.podspec +50 -0
- package/src/index.tsx +30 -0
package/package.json
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
{
|
2
|
+
"name": "@synonymdev/react-native-pubky",
|
3
|
+
"version": "0.1.0",
|
4
|
+
"description": "React Native Implementation of Pubky",
|
5
|
+
"source": "./src/index.tsx",
|
6
|
+
"main": "./lib/commonjs/index.js",
|
7
|
+
"module": "./lib/module/index.js",
|
8
|
+
"react-native": "src/index",
|
9
|
+
"exports": {
|
10
|
+
".": {
|
11
|
+
"import": {
|
12
|
+
"types": "./lib/typescript/module/src/index.d.ts",
|
13
|
+
"default": "./lib/module/index.js"
|
14
|
+
},
|
15
|
+
"require": {
|
16
|
+
"types": "./lib/typescript/commonjs/src/index.d.ts",
|
17
|
+
"default": "./lib/commonjs/index.js"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
},
|
21
|
+
"files": [
|
22
|
+
"src",
|
23
|
+
"lib",
|
24
|
+
"android",
|
25
|
+
"ios",
|
26
|
+
"cpp",
|
27
|
+
"*.podspec",
|
28
|
+
"!ios/build",
|
29
|
+
"!android/build",
|
30
|
+
"!android/gradle",
|
31
|
+
"!android/gradlew",
|
32
|
+
"!android/gradlew.bat",
|
33
|
+
"!android/local.properties",
|
34
|
+
"!**/__tests__",
|
35
|
+
"!**/__fixtures__",
|
36
|
+
"!**/__mocks__",
|
37
|
+
"!**/.*"
|
38
|
+
],
|
39
|
+
"scripts": {
|
40
|
+
"example": "yarn workspace react-native-pubky-example",
|
41
|
+
"test": "jest",
|
42
|
+
"typecheck": "tsc",
|
43
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
44
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
45
|
+
"prepare": "bob build",
|
46
|
+
"release": "release-it",
|
47
|
+
"reinstall": "npm i && npm run clean && npm run prepare",
|
48
|
+
"cargo-build": "cd rust && cargo build --release && cd pubky && cargo build --release && cd pubky && cargo build --release && cd ../ && cd pubky-common && cargo build --release && cd ../ && cd pubky-homeserver && cargo build --release && cd ../../../",
|
49
|
+
"update-bindings:ios": "npm run cargo-build && node setup-ios-bindings.js && npm run reinstall",
|
50
|
+
"update-bindings:android": "npm run cargo-build && node setup-android-bindings.js && npm run reinstall",
|
51
|
+
"update-bindings": "npm run cargo-build && npm run update-bindings:ios && npm run update-bindings:android"
|
52
|
+
},
|
53
|
+
"keywords": [
|
54
|
+
"pubky",
|
55
|
+
"react-native",
|
56
|
+
"ios",
|
57
|
+
"android"
|
58
|
+
],
|
59
|
+
"repository": {
|
60
|
+
"type": "git",
|
61
|
+
"url": "git+https://https://github.com/pubky/react-native-pubky.git"
|
62
|
+
},
|
63
|
+
"author": "coreyphillips <corey@synonym.to> (https://github.com/coreyphillips)",
|
64
|
+
"license": "MIT",
|
65
|
+
"bugs": {
|
66
|
+
"url": "https://github.com/pubky/react-native-pubky/issues"
|
67
|
+
},
|
68
|
+
"homepage": "https://github.com/pubky/react-native-pubky#readme",
|
69
|
+
"publishConfig": {
|
70
|
+
"access": "restricted",
|
71
|
+
"registry": "https://registry.npmjs.org/"
|
72
|
+
},
|
73
|
+
"dependencies": {
|
74
|
+
"@synonymdev/result": "^0.0.2"
|
75
|
+
},
|
76
|
+
"devDependencies": {
|
77
|
+
"@commitlint/config-conventional": "^17.0.2",
|
78
|
+
"@evilmartians/lefthook": "^1.5.0",
|
79
|
+
"@react-native/eslint-config": "^0.73.1",
|
80
|
+
"@release-it/conventional-changelog": "^5.0.0",
|
81
|
+
"@types/jest": "^29.5.5",
|
82
|
+
"@types/react": "^18.2.44",
|
83
|
+
"commitlint": "^17.0.2",
|
84
|
+
"del-cli": "^5.1.0",
|
85
|
+
"eslint": "^8.51.0",
|
86
|
+
"eslint-config-prettier": "^9.0.0",
|
87
|
+
"eslint-plugin-prettier": "^5.0.1",
|
88
|
+
"jest": "^29.7.0",
|
89
|
+
"prettier": "^3.0.3",
|
90
|
+
"react": "18.3.1",
|
91
|
+
"react-native": "0.75.2",
|
92
|
+
"react-native-builder-bob": "^0.30.2",
|
93
|
+
"release-it": "^15.0.0",
|
94
|
+
"turbo": "^1.10.7",
|
95
|
+
"typescript": "^5.2.2"
|
96
|
+
},
|
97
|
+
"resolutions": {
|
98
|
+
"@types/react": "^18.2.44"
|
99
|
+
},
|
100
|
+
"peerDependencies": {
|
101
|
+
"react": "*",
|
102
|
+
"react-native": "*"
|
103
|
+
},
|
104
|
+
"workspaces": [
|
105
|
+
"example"
|
106
|
+
],
|
107
|
+
"packageManager": "yarn@3.6.1",
|
108
|
+
"jest": {
|
109
|
+
"preset": "react-native",
|
110
|
+
"modulePathIgnorePatterns": [
|
111
|
+
"<rootDir>/example/node_modules",
|
112
|
+
"<rootDir>/lib/"
|
113
|
+
]
|
114
|
+
},
|
115
|
+
"commitlint": {
|
116
|
+
"extends": [
|
117
|
+
"@commitlint/config-conventional"
|
118
|
+
]
|
119
|
+
},
|
120
|
+
"release-it": {
|
121
|
+
"git": {
|
122
|
+
"commitMessage": "chore: release ${version}",
|
123
|
+
"tagName": "v${version}"
|
124
|
+
},
|
125
|
+
"npm": {
|
126
|
+
"publish": true
|
127
|
+
},
|
128
|
+
"github": {
|
129
|
+
"release": true
|
130
|
+
},
|
131
|
+
"plugins": {
|
132
|
+
"@release-it/conventional-changelog": {
|
133
|
+
"preset": "angular"
|
134
|
+
}
|
135
|
+
}
|
136
|
+
},
|
137
|
+
"eslintConfig": {
|
138
|
+
"root": true,
|
139
|
+
"extends": [
|
140
|
+
"@react-native",
|
141
|
+
"prettier"
|
142
|
+
],
|
143
|
+
"rules": {
|
144
|
+
"react/react-in-jsx-scope": "off",
|
145
|
+
"prettier/prettier": [
|
146
|
+
"error",
|
147
|
+
{
|
148
|
+
"quoteProps": "consistent",
|
149
|
+
"singleQuote": true,
|
150
|
+
"tabWidth": 2,
|
151
|
+
"trailingComma": "es5",
|
152
|
+
"useTabs": false
|
153
|
+
}
|
154
|
+
]
|
155
|
+
}
|
156
|
+
},
|
157
|
+
"eslintIgnore": [
|
158
|
+
"node_modules/",
|
159
|
+
"lib/"
|
160
|
+
],
|
161
|
+
"prettier": {
|
162
|
+
"quoteProps": "consistent",
|
163
|
+
"singleQuote": true,
|
164
|
+
"tabWidth": 2,
|
165
|
+
"trailingComma": "es5",
|
166
|
+
"useTabs": false
|
167
|
+
},
|
168
|
+
"react-native-builder-bob": {
|
169
|
+
"source": "src",
|
170
|
+
"output": "lib",
|
171
|
+
"targets": [
|
172
|
+
[
|
173
|
+
"commonjs",
|
174
|
+
{
|
175
|
+
"esm": true
|
176
|
+
}
|
177
|
+
],
|
178
|
+
[
|
179
|
+
"module",
|
180
|
+
{
|
181
|
+
"esm": true
|
182
|
+
}
|
183
|
+
],
|
184
|
+
[
|
185
|
+
"typescript",
|
186
|
+
{
|
187
|
+
"project": "tsconfig.build.json",
|
188
|
+
"esm": true
|
189
|
+
}
|
190
|
+
]
|
191
|
+
]
|
192
|
+
},
|
193
|
+
"create-react-native-library": {
|
194
|
+
"type": "module-legacy",
|
195
|
+
"languages": "kotlin-swift",
|
196
|
+
"version": "0.41.1"
|
197
|
+
}
|
198
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "json"
|
2
|
+
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
4
|
+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
5
|
+
|
6
|
+
min_ios_version_supported = '13.4'
|
7
|
+
|
8
|
+
Pod::Spec.new do |s|
|
9
|
+
s.name = "react-native-pubky"
|
10
|
+
s.version = package["version"]
|
11
|
+
s.summary = package["description"]
|
12
|
+
s.homepage = package["homepage"]
|
13
|
+
s.license = package["license"]
|
14
|
+
s.authors = package["author"]
|
15
|
+
|
16
|
+
s.platforms = { :ios => min_ios_version_supported }
|
17
|
+
s.ios.deployment_target = min_ios_version_supported
|
18
|
+
s.source = { :git => "https://github.com/coreyphillips/react-native-pubky.git", :tag => "#{s.version}" }
|
19
|
+
|
20
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
21
|
+
s.ios.source_files = "ios/**/*.{h,m,mm,swift}"
|
22
|
+
s.ios.vendored_frameworks = "ios/Frameworks/Mobile.xcframework"
|
23
|
+
|
24
|
+
s.pod_target_xcconfig = {
|
25
|
+
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" => "x86_64"
|
26
|
+
}
|
27
|
+
|
28
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
29
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
30
|
+
if respond_to?(:install_modules_dependencies, true)
|
31
|
+
install_modules_dependencies(s)
|
32
|
+
else
|
33
|
+
s.dependency "React-Core"
|
34
|
+
|
35
|
+
# Don't install the dependencies when we run `pod install` in the old architecture.
|
36
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
37
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
38
|
+
s.pod_target_xcconfig = {
|
39
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
40
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
41
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
42
|
+
}
|
43
|
+
s.dependency "React-Codegen"
|
44
|
+
s.dependency "RCT-Folly"
|
45
|
+
s.dependency "RCTRequired"
|
46
|
+
s.dependency "RCTTypeSafety"
|
47
|
+
s.dependency "ReactCommon/turbomodule/core"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
package/src/index.tsx
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
2
|
+
import { ok, err, type Result } from '@synonymdev/result';
|
3
|
+
|
4
|
+
const LINKING_ERROR =
|
5
|
+
`The package 'react-native-pubky' doesn't seem to be linked. Make sure: \n\n` +
|
6
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
7
|
+
'- You rebuilt the app after installing the package\n' +
|
8
|
+
'- You are not using Expo Go\n';
|
9
|
+
|
10
|
+
const Pubky = NativeModules.Pubky
|
11
|
+
? NativeModules.Pubky
|
12
|
+
: new Proxy(
|
13
|
+
{},
|
14
|
+
{
|
15
|
+
get() {
|
16
|
+
throw new Error(LINKING_ERROR);
|
17
|
+
},
|
18
|
+
}
|
19
|
+
);
|
20
|
+
|
21
|
+
export async function auth(
|
22
|
+
url: string,
|
23
|
+
secretKey: string
|
24
|
+
): Promise<Result<string[]>> {
|
25
|
+
const res = await Pubky.auth(url, secretKey);
|
26
|
+
if (res[0] === 'error') {
|
27
|
+
return err(res[1]);
|
28
|
+
}
|
29
|
+
return ok(res[1]);
|
30
|
+
}
|