@bifold/react-native-attestation 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +39 -0
  3. package/android/build.gradle +123 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +3 -0
  6. package/android/src/main/AndroidManifestNew.xml +2 -0
  7. package/android/src/main/java/com/attestation/AttestationModule.kt +89 -0
  8. package/android/src/main/java/com/attestation/AttestationPackage.kt +35 -0
  9. package/android/src/newarch/AttestationSpec.kt +7 -0
  10. package/android/src/oldarch/AttestationSpec.kt +12 -0
  11. package/build/commonjs/NativeAttestation.js +9 -0
  12. package/build/commonjs/NativeAttestation.js.map +1 -0
  13. package/build/commonjs/index.js +72 -0
  14. package/build/commonjs/index.js.map +1 -0
  15. package/build/module/NativeAttestation.js +3 -0
  16. package/build/module/NativeAttestation.js.map +1 -0
  17. package/build/module/index.js +59 -0
  18. package/build/module/index.js.map +1 -0
  19. package/build/typescript/NativeAttestation.d.ts +12 -0
  20. package/build/typescript/NativeAttestation.d.ts.map +1 -0
  21. package/build/typescript/__tests__/index.test.d.ts +1 -0
  22. package/build/typescript/__tests__/index.test.d.ts.map +1 -0
  23. package/build/typescript/index.d.ts +8 -0
  24. package/build/typescript/index.d.ts.map +1 -0
  25. package/ios/Attestation.h +12 -0
  26. package/ios/Attestation.mm +280 -0
  27. package/ios/Attestation.xcodeproj/project.pbxproj +276 -0
  28. package/package.json +116 -0
  29. package/react-native-attestation.podspec +44 -0
  30. package/src/NativeAttestation.ts +13 -0
  31. package/src/__tests__/index.test.tsx +1 -0
  32. package/src/index.ts +95 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2021 Indicio, PBC.
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+
195
+ You may obtain a copy of the License at
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # react-native-attestation
2
+
3
+ Mobile app attestation
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ yarn add @bifold/react-native-attestation
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import {
15
+ generateKey,
16
+ appleAttestation,
17
+ isPlayIntegrityAvailable,
18
+ googleAttestation,
19
+ } from '@bifold/react-native-attestation';
20
+
21
+ // ...
22
+ if (Platform.OS === 'ios') {
23
+ const keyId = await generateKey();
24
+ const attestationAsBuffer = await appleAttestation(keyId, nonce);
25
+ } else if (Platform.OS === 'android') {
26
+ const available = await isPlayIntegrityAvailable();
27
+ if (available) {
28
+ const integrityToken = await googleAttestation(nonce);
29
+ }
30
+ }
31
+ ```
32
+
33
+ ## License
34
+
35
+ Apache-2.0 License
36
+
37
+ ---
38
+
39
+ Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
@@ -0,0 +1,123 @@
1
+ buildscript {
2
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["Attestation_kotlinVersion"]
4
+
5
+ repositories {
6
+ google()
7
+ mavenCentral()
8
+ }
9
+
10
+ dependencies {
11
+ classpath "com.android.tools.build:gradle:7.2.1"
12
+ // noinspection DifferentKotlinGradleVersion
13
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
+ }
15
+ }
16
+
17
+ def isNewArchitectureEnabled() {
18
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
19
+ }
20
+
21
+ apply plugin: "com.android.library"
22
+ apply plugin: "kotlin-android"
23
+
24
+
25
+ def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
26
+
27
+ if (isNewArchitectureEnabled()) {
28
+ apply plugin: "com.facebook.react"
29
+ }
30
+
31
+ def getExtOrDefault(name) {
32
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Attestation_" + name]
33
+ }
34
+
35
+ def getExtOrIntegerDefault(name) {
36
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Attestation_" + name]).toInteger()
37
+ }
38
+
39
+ def supportsNamespace() {
40
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
41
+ def major = parsed[0].toInteger()
42
+ def minor = parsed[1].toInteger()
43
+
44
+ // Namespace support was added in 7.3.0
45
+ if (major == 7 && minor >= 3) {
46
+ return true
47
+ }
48
+
49
+ return major >= 8
50
+ }
51
+
52
+ android {
53
+ if (supportsNamespace()) {
54
+ namespace "com.attestation"
55
+
56
+ sourceSets {
57
+ main {
58
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
59
+ }
60
+ }
61
+ }
62
+
63
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
64
+
65
+ defaultConfig {
66
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
67
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
68
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
69
+ }
70
+ buildTypes {
71
+ release {
72
+ minifyEnabled false
73
+ }
74
+ }
75
+
76
+ lintOptions {
77
+ disable "GradleCompatible"
78
+ }
79
+
80
+ compileOptions {
81
+ sourceCompatibility JavaVersion.VERSION_1_8
82
+ targetCompatibility JavaVersion.VERSION_1_8
83
+ }
84
+
85
+ sourceSets {
86
+ main {
87
+ if (isNewArchitectureEnabled()) {
88
+ java.srcDirs += [
89
+ "src/newarch",
90
+ // This is needed to build Kotlin project with NewArch enabled
91
+ "${project.buildDir}/generated/source/codegen/java"
92
+ ]
93
+ } else {
94
+ java.srcDirs += ["src/oldarch"]
95
+ }
96
+ }
97
+ }
98
+ }
99
+
100
+ repositories {
101
+ mavenCentral()
102
+ google()
103
+ }
104
+
105
+ def kotlin_version = getExtOrDefault("kotlinVersion")
106
+
107
+ dependencies {
108
+ // For < 0.71, this will be from the local maven repo
109
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
110
+ //noinspection GradleDynamicVersion
111
+ implementation "com.facebook.react:react-native:+"
112
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
113
+ implementation "com.google.android.gms:play-services-base:18.2.0"
114
+ implementation "com.google.android.play:integrity:1.2.0"
115
+ }
116
+
117
+ if (isNewArchitectureEnabled()) {
118
+ react {
119
+ jsRootDir = file("../src/")
120
+ libraryName = "Attestation"
121
+ codegenJavaPackageName = "com.attestation"
122
+ }
123
+ }
@@ -0,0 +1,5 @@
1
+ Attestation_kotlinVersion=1.7.0
2
+ Attestation_minSdkVersion=21
3
+ Attestation_targetSdkVersion=31
4
+ Attestation_compileSdkVersion=31
5
+ Attestation_ndkversion=21.4.7075529
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.attestation">
3
+ </manifest>
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,89 @@
1
+ package com.attestation
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext;
4
+ import com.facebook.react.bridge.ReactMethod;
5
+ import com.facebook.react.bridge.Promise;
6
+ import com.google.android.gms.common.ConnectionResult;
7
+ import com.google.android.gms.common.GooglePlayServicesUtil;
8
+ import com.google.android.gms.tasks.Task;
9
+ import com.google.android.play.core.integrity.IntegrityManager;
10
+ import com.google.android.play.core.integrity.IntegrityManagerFactory;
11
+ import com.google.android.play.core.integrity.IntegrityServiceException;
12
+ import com.google.android.play.core.integrity.IntegrityTokenRequest;
13
+ import com.google.android.play.core.integrity.IntegrityTokenResponse;
14
+
15
+ class AttestationModule : AttestationSpec {
16
+
17
+ private val reactContext: ReactApplicationContext;
18
+ private val baseContext: ReactApplicationContext;
19
+
20
+ constructor(context: ReactApplicationContext) : super(context) {
21
+ reactContext = context;
22
+ baseContext = getReactApplicationContext();
23
+ }
24
+
25
+ override fun getName(): String {
26
+ return NAME
27
+ }
28
+
29
+ companion object {
30
+ const val NAME = "Attestation"
31
+ }
32
+
33
+ /**
34
+ * Checks if Google Play Integrity API is available
35
+ * See https://developer.android.com/google/play/integrity/overview
36
+ *
37
+ * @param promise
38
+ */
39
+ @ReactMethod
40
+ override fun isPlayIntegrityAvailable(promise: Promise) {
41
+ try {
42
+ val apiAvailable = GooglePlayServicesUtil.isGooglePlayServicesAvailable(baseContext) == ConnectionResult.SUCCESS;
43
+ promise.resolve(apiAvailable);
44
+ } catch (e: Throwable) {
45
+ promise.reject("Error checking Play Integrity availability", e)
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Request an integrity verdict
51
+ * See https://developer.android.com/google/play/integrity/verdict#request
52
+ *
53
+ * @param nonce
54
+ * @param promise
55
+ */
56
+ @ReactMethod
57
+ override fun googleAttestation(nonce: String, promise: Promise) {
58
+ try {
59
+ // Create an instance of a manager
60
+ val integrityManager: IntegrityManager =
61
+ IntegrityManagerFactory.create(baseContext)
62
+
63
+ // Request the integrity token by providing a nonce
64
+ val integrityTokenResponse: Task<IntegrityTokenResponse> =
65
+ integrityManager.requestIntegrityToken(
66
+ IntegrityTokenRequest.builder()
67
+ .setNonce(nonce)
68
+ .build())
69
+
70
+ // Success listener
71
+ integrityTokenResponse.addOnSuccessListener { response: IntegrityTokenResponse -> promise.resolve(response.token()) };
72
+
73
+ // Cancelled listener
74
+ integrityTokenResponse.addOnCanceledListener { -> promise.reject("Integrity token request cancelled") };
75
+
76
+ // Failure listener
77
+ integrityTokenResponse.addOnFailureListener { e: Exception ->
78
+ if (e is IntegrityServiceException) {
79
+ promise.reject(e.getErrorCode().toString(), e)
80
+ } else {
81
+ promise.reject("Unexpected failure during integrity token request", e)
82
+ }
83
+ };
84
+
85
+ } catch (e: Throwable) {
86
+ promise.reject("Error requesting integrity token", e);
87
+ }
88
+ }
89
+ }
@@ -0,0 +1,35 @@
1
+ package com.attestation
2
+
3
+ import com.facebook.react.TurboReactPackage
4
+ import com.facebook.react.bridge.ReactApplicationContext
5
+ import com.facebook.react.bridge.NativeModule
6
+ import com.facebook.react.module.model.ReactModuleInfoProvider
7
+ import com.facebook.react.module.model.ReactModuleInfo
8
+ import java.util.HashMap
9
+
10
+ class AttestationPackage : TurboReactPackage() {
11
+ override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
12
+ return if (name == AttestationModule.NAME) {
13
+ AttestationModule(reactContext)
14
+ } else {
15
+ null
16
+ }
17
+ }
18
+
19
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
20
+ return ReactModuleInfoProvider {
21
+ val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
22
+ val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
23
+ moduleInfos[AttestationModule.NAME] = ReactModuleInfo(
24
+ AttestationModule.NAME,
25
+ AttestationModule.NAME,
26
+ false, // canOverrideExistingModule
27
+ false, // needsEagerInit
28
+ true, // hasConstants
29
+ false, // isCxxModule
30
+ isTurboModule // isTurboModule
31
+ )
32
+ moduleInfos
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,7 @@
1
+ package com.attestation
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+
5
+ abstract class AttestationSpec internal constructor(context: ReactApplicationContext) :
6
+ NativeAttestationSpec(context) {
7
+ }
@@ -0,0 +1,12 @@
1
+ package com.attestation
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
5
+ import com.facebook.react.bridge.Promise
6
+
7
+ abstract class AttestationSpec internal constructor(context: ReactApplicationContext) :
8
+ ReactContextBaseJavaModule(context) {
9
+
10
+ abstract fun isPlayIntegrityAvailable(promise: Promise)
11
+ abstract fun googleAttestation(nonce: String, promise: Promise)
12
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing('Attestation');
9
+ //# sourceMappingURL=NativeAttestation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeAttestation.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAWpCC,gCAAmB,CAACC,YAAY,CAAO,aAAa,CAAC","ignoreList":[]}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sha256 = exports.isPlayIntegrityAvailable = exports.googleAttestation = exports.generateKey = exports.appleKeyAttestation = exports.appleAttestation = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _buffer = require("buffer");
9
+ var _NativeAttestation = _interopRequireDefault(require("./NativeAttestation"));
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ const LINKING_ERROR = `The package 'react-native-attestation' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
12
+ ios: "- You have run 'pod install'\n",
13
+ default: ''
14
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
15
+
16
+ // @ts-expect-error global.__turboModuleProxy is a global variable injected by TurboModuleProxy
17
+ const isTurboModuleEnabled = global.__turboModuleProxy != null;
18
+ const AttestationModule = isTurboModuleEnabled ? _NativeAttestation.default : _reactNative.NativeModules.Attestation;
19
+ const Attestation = AttestationModule ? AttestationModule : new Proxy({}, {
20
+ get() {
21
+ throw new Error(LINKING_ERROR);
22
+ }
23
+ });
24
+
25
+ // TODO: Make available from Android.
26
+ const sha256 = async stringToHash => {
27
+ if (_reactNative.Platform.OS !== 'ios') {
28
+ throw new Error('sha256 is only available on iOS');
29
+ }
30
+ const bytes = await Attestation.sha256(stringToHash);
31
+ return _buffer.Buffer.from(bytes);
32
+ };
33
+ exports.sha256 = sha256;
34
+ const generateKey = async (cache = false) => {
35
+ if (_reactNative.Platform.OS !== 'ios') {
36
+ throw new Error('generateKey is only available on iOS');
37
+ }
38
+ return Attestation.generateKey(cache);
39
+ };
40
+ exports.generateKey = generateKey;
41
+ const appleKeyAttestation = async (keyId, challenge) => {
42
+ if (_reactNative.Platform.OS !== 'ios') {
43
+ throw new Error('appleKeyAttestation is only available on iOS');
44
+ }
45
+ const bytes = await Attestation.appleKeyAttestation(keyId, challenge);
46
+ return _buffer.Buffer.from(bytes);
47
+ };
48
+ exports.appleKeyAttestation = appleKeyAttestation;
49
+ const appleAttestation = async (keyId, challenge) => {
50
+ if (_reactNative.Platform.OS !== 'ios') {
51
+ throw new Error('appleAttestation is only available on iOS');
52
+ }
53
+ const bytes = await Attestation.appleAttestation(keyId, challenge);
54
+ return _buffer.Buffer.from(bytes);
55
+ };
56
+ exports.appleAttestation = appleAttestation;
57
+ const googleAttestation = async nonce => {
58
+ if (_reactNative.Platform.OS !== 'android') {
59
+ throw new Error('googleAttestation is only available on Android');
60
+ }
61
+ const token = await Attestation.googleAttestation(nonce);
62
+ return token;
63
+ };
64
+ exports.googleAttestation = googleAttestation;
65
+ const isPlayIntegrityAvailable = async () => {
66
+ if (_reactNative.Platform.OS !== 'android') {
67
+ throw new Error('isPlayIntegrityAvailable is only available on Android');
68
+ }
69
+ return Attestation.isPlayIntegrityAvailable();
70
+ };
71
+ exports.isPlayIntegrityAvailable = isPlayIntegrityAvailable;
72
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_buffer","_NativeAttestation","_interopRequireDefault","e","__esModule","default","LINKING_ERROR","Platform","select","ios","isTurboModuleEnabled","global","__turboModuleProxy","AttestationModule","NativeAttestationSpec","NativeModules","Attestation","Proxy","get","Error","sha256","stringToHash","OS","bytes","Buffer","from","exports","generateKey","cache","appleKeyAttestation","keyId","challenge","appleAttestation","googleAttestation","nonce","token","isPlayInt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,KAAK,SAAS,EAAE;IAC7B,MAAM,IAAIH,KAAK,CAAC,uDAAuD,CAAC;EAC1E;EAEA,OAAOH,WAAW,CAACoB,wBAAwB,CAAC,CAAC;AAC/C,CAAC;AAACV,OAAA,CAAAU,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import { TurboModuleRegistry } from 'react-native';
2
+ export default TurboModuleRegistry.getEnforcing('Attestation');
3
+ //# sourceMappingURL=NativeAttestation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeAttestation.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;AAWlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,aAAa,CAAC","ignoreList":[]}