@moon-x/react-native-sdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +462 -0
- package/app.plugin.js +4 -0
- package/dist/ethereum.d.mts +2 -0
- package/dist/ethereum.d.ts +2 -0
- package/dist/ethereum.js +42 -0
- package/dist/ethereum.mjs +19 -0
- package/dist/index.d.mts +273 -0
- package/dist/index.d.ts +273 -0
- package/dist/index.js +1008 -0
- package/dist/index.mjs +982 -0
- package/dist/solana.d.mts +1 -0
- package/dist/solana.d.ts +1 -0
- package/dist/solana.js +36 -0
- package/dist/solana.mjs +13 -0
- package/package.json +85 -0
- package/plugin/index.js +172 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useGetBalance, useSendTransaction, useSignMessage, useSignTransaction } from '@moon-x/core/react/solana';
|
package/dist/solana.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useGetBalance, useSendTransaction, useSignMessage, useSignTransaction } from '@moon-x/core/react/solana';
|
package/dist/solana.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/solana.ts
|
|
21
|
+
var solana_exports = {};
|
|
22
|
+
__export(solana_exports, {
|
|
23
|
+
useGetBalance: () => import_solana.useGetBalance,
|
|
24
|
+
useSendTransaction: () => import_solana.useSendTransaction,
|
|
25
|
+
useSignMessage: () => import_solana.useSignMessage,
|
|
26
|
+
useSignTransaction: () => import_solana.useSignTransaction
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(solana_exports);
|
|
29
|
+
var import_solana = require("@moon-x/core/react/solana");
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
useGetBalance,
|
|
33
|
+
useSendTransaction,
|
|
34
|
+
useSignMessage,
|
|
35
|
+
useSignTransaction
|
|
36
|
+
});
|
package/dist/solana.mjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@moon-x/react-native-sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "MoonX React Native SDK — WebView-backed transport, react-native-passkeys, AsyncStorage. Mobile parity with @moon-x/react-sdk + @moon-x/core-sdk.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./ethereum": {
|
|
15
|
+
"types": "./dist/ethereum.d.ts",
|
|
16
|
+
"import": "./dist/ethereum.mjs",
|
|
17
|
+
"require": "./dist/ethereum.js"
|
|
18
|
+
},
|
|
19
|
+
"./solana": {
|
|
20
|
+
"types": "./dist/solana.d.ts",
|
|
21
|
+
"import": "./dist/solana.mjs",
|
|
22
|
+
"require": "./dist/solana.js"
|
|
23
|
+
},
|
|
24
|
+
"./app.plugin.js": "./app.plugin.js",
|
|
25
|
+
"./plugin": "./plugin/index.js",
|
|
26
|
+
"./plugin/index.js": "./plugin/index.js",
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"plugin",
|
|
32
|
+
"app.plugin.js"
|
|
33
|
+
],
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@expo/config-plugins": "55.0.8",
|
|
39
|
+
"@react-native-async-storage/async-storage": "2.2.0",
|
|
40
|
+
"@types/react": "19.2.14",
|
|
41
|
+
"expo-linking": "55.0.15",
|
|
42
|
+
"expo-web-browser": "55.0.15",
|
|
43
|
+
"react": "19.2.0",
|
|
44
|
+
"react-native": "0.83.6",
|
|
45
|
+
"react-native-passkeys": "0.3.3",
|
|
46
|
+
"react-native-webview": "13.16.0",
|
|
47
|
+
"tsup": "8.5.1",
|
|
48
|
+
"typescript": "5.9.3"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@moon-x/core": "0.2.0"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"@expo/config-plugins": ">=10.0.0",
|
|
55
|
+
"@react-native-async-storage/async-storage": "^1.21.0 || ^2.0.0",
|
|
56
|
+
"bs58": "^6.0.0",
|
|
57
|
+
"buffer": "^6.0.0",
|
|
58
|
+
"expo-linking": ">=6.0.0",
|
|
59
|
+
"expo-web-browser": ">=13.0.0",
|
|
60
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
61
|
+
"react-native": ">=0.78.0",
|
|
62
|
+
"react-native-get-random-values": "^1.11.0",
|
|
63
|
+
"react-native-passkeys": ">=0.3.0",
|
|
64
|
+
"react-native-url-polyfill": "^2.0.0",
|
|
65
|
+
"react-native-webview": ">=13.0.0",
|
|
66
|
+
"viem": "^2.0.0"
|
|
67
|
+
},
|
|
68
|
+
"peerDependenciesMeta": {
|
|
69
|
+
"@expo/config-plugins": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"expo-linking": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"expo-web-browser": {
|
|
76
|
+
"optional": true
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"scripts": {
|
|
80
|
+
"build": "tsup",
|
|
81
|
+
"dev": "tsup --watch",
|
|
82
|
+
"type-check": "tsc --noEmit",
|
|
83
|
+
"clean": "rm -rf dist .turbo node_modules"
|
|
84
|
+
}
|
|
85
|
+
}
|
package/plugin/index.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// Expo config plugin for @moon-x/react-native-sdk.
|
|
2
|
+
//
|
|
3
|
+
// Wires the native config that bare-RN / Expo prebuild apps would
|
|
4
|
+
// otherwise have to maintain manually:
|
|
5
|
+
//
|
|
6
|
+
// - iOS: Associated Domains entitlement for `webcredentials:<rp>`
|
|
7
|
+
// so platform passkeys (iOS 16+ ASAuthorization) can claim
|
|
8
|
+
// credentials registered against the configured RP.
|
|
9
|
+
// - iOS: ITSAppUsesNonExemptEncryption = false (export-compliance).
|
|
10
|
+
// - Android: deep-link intent filter for the OAuth redirect scheme.
|
|
11
|
+
//
|
|
12
|
+
// Usage in the consumer's `app.json`:
|
|
13
|
+
//
|
|
14
|
+
// {
|
|
15
|
+
// "expo": {
|
|
16
|
+
// "scheme": "myapp",
|
|
17
|
+
// "plugins": [
|
|
18
|
+
// ["@moon-x/react-native-sdk", {
|
|
19
|
+
// "passkeyDomains": ["acme.com"],
|
|
20
|
+
// "oauthRedirectScheme": "myapp"
|
|
21
|
+
// }]
|
|
22
|
+
// ]
|
|
23
|
+
// }
|
|
24
|
+
// }
|
|
25
|
+
//
|
|
26
|
+
// Run `expo prebuild` after editing app.json. Bare RN apps that don't
|
|
27
|
+
// use prebuild can read this plugin's logic as a reference for the
|
|
28
|
+
// equivalent manual edits to Xcode / Gradle.
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
withAndroidManifest,
|
|
32
|
+
withEntitlementsPlist,
|
|
33
|
+
withInfoPlist,
|
|
34
|
+
withStringsXml,
|
|
35
|
+
AndroidConfig,
|
|
36
|
+
} = require("@expo/config-plugins");
|
|
37
|
+
|
|
38
|
+
const withAssociatedDomains = (config, passkeyDomains, developerMode) => {
|
|
39
|
+
if (!passkeyDomains || passkeyDomains.length === 0) return config;
|
|
40
|
+
return withEntitlementsPlist(config, (cfg) => {
|
|
41
|
+
const key = "com.apple.developer.associated-domains";
|
|
42
|
+
const existing = cfg.modResults[key] || [];
|
|
43
|
+
const merged = new Set(existing);
|
|
44
|
+
for (const domain of passkeyDomains) {
|
|
45
|
+
// `webcredentials:` is the right prefix for WebAuthn / passkeys.
|
|
46
|
+
// `applinks:` would be for Universal Links — different concern,
|
|
47
|
+
// not needed for passkeys but consumers can add their own.
|
|
48
|
+
//
|
|
49
|
+
// `?mode=developer` tells iOS to skip the standard AASA fetch +
|
|
50
|
+
// validation and trust the entitlement directly. Use ONLY in dev:
|
|
51
|
+
// simulator behaviour with production AASA is famously flaky
|
|
52
|
+
// (Apple's CDN caches "not found" for hours, simulator bypasses
|
|
53
|
+
// some validators, etc.). Production builds MUST omit this flag.
|
|
54
|
+
const suffix = developerMode ? "?mode=developer" : "";
|
|
55
|
+
merged.add(`webcredentials:${domain}${suffix}`);
|
|
56
|
+
}
|
|
57
|
+
cfg.modResults[key] = Array.from(merged);
|
|
58
|
+
return cfg;
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const withExportCompliance = (config) =>
|
|
63
|
+
withInfoPlist(config, (cfg) => {
|
|
64
|
+
if (cfg.modResults.ITSAppUsesNonExemptEncryption === undefined) {
|
|
65
|
+
// Default to false — the SDK only uses standard HTTPS / WebAuthn
|
|
66
|
+
// crypto, no proprietary encryption that would require export
|
|
67
|
+
// documentation. Consumers can override by setting their own
|
|
68
|
+
// value before this plugin runs.
|
|
69
|
+
cfg.modResults.ITSAppUsesNonExemptEncryption = false;
|
|
70
|
+
}
|
|
71
|
+
return cfg;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const withAssetStatements = (config, passkeyDomains) => {
|
|
75
|
+
if (!passkeyDomains || passkeyDomains.length === 0) return config;
|
|
76
|
+
|
|
77
|
+
// Android Credential Manager validates RP IDs against assetlinks.json
|
|
78
|
+
// hosted at the apex of each passkey domain. The OS only trusts those
|
|
79
|
+
// links if the app declares them via an `asset_statements` resource
|
|
80
|
+
// referenced by a `<meta-data>` tag in `<application>`. Without this,
|
|
81
|
+
// GMS rejects passkey ceremonies with "[50152] RP ID cannot be
|
|
82
|
+
// validated." even when the assetlinks.json file is otherwise correct.
|
|
83
|
+
// https://developer.android.com/identity/sign-in/credential-manager#add-support-dal
|
|
84
|
+
//
|
|
85
|
+
// Skip `localhost` and bare-IP entries — those are iOS dev-mode tricks
|
|
86
|
+
// (Associated Domains `?mode=developer` accepts them) and have no
|
|
87
|
+
// analogue on Android, where the OS fetches the include URL over HTTPS.
|
|
88
|
+
const publicDomains = passkeyDomains.filter(
|
|
89
|
+
(d) => d !== "localhost" && !/^\d+\.\d+\.\d+\.\d+$/.test(d),
|
|
90
|
+
);
|
|
91
|
+
if (publicDomains.length === 0) return config;
|
|
92
|
+
const includes = publicDomains
|
|
93
|
+
.map((domain) => `{ \\"include\\": \\"https://${domain}/.well-known/assetlinks.json\\" }`)
|
|
94
|
+
.join(", ");
|
|
95
|
+
const assetStatements = `[${includes}]`;
|
|
96
|
+
|
|
97
|
+
let next = withStringsXml(config, (cfg) => {
|
|
98
|
+
cfg.modResults = AndroidConfig.Strings.setStringItem(
|
|
99
|
+
[
|
|
100
|
+
{
|
|
101
|
+
$: { name: "asset_statements", translatable: "false" },
|
|
102
|
+
_: assetStatements,
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
cfg.modResults,
|
|
106
|
+
);
|
|
107
|
+
return cfg;
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
next = withAndroidManifest(next, (cfg) => {
|
|
111
|
+
const mainApp = AndroidConfig.Manifest.getMainApplicationOrThrow(
|
|
112
|
+
cfg.modResults,
|
|
113
|
+
);
|
|
114
|
+
AndroidConfig.Manifest.addMetaDataItemToMainApplication(
|
|
115
|
+
mainApp,
|
|
116
|
+
"asset_statements",
|
|
117
|
+
"@string/asset_statements",
|
|
118
|
+
"resource",
|
|
119
|
+
);
|
|
120
|
+
return cfg;
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
return next;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const withOAuthIntentFilter = (config, oauthRedirectScheme) => {
|
|
127
|
+
if (!oauthRedirectScheme) return config;
|
|
128
|
+
return withAndroidManifest(config, (cfg) => {
|
|
129
|
+
const mainActivity = AndroidConfig.Manifest.getMainActivityOrThrow(
|
|
130
|
+
cfg.modResults,
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
// Add a VIEW intent filter scoped to the consumer's deep-link
|
|
134
|
+
// scheme so the OS routes the OAuth-redirect callback back into
|
|
135
|
+
// the app. Idempotent — skipped if an equivalent filter already
|
|
136
|
+
// exists.
|
|
137
|
+
const intentFilters = mainActivity["intent-filter"] || [];
|
|
138
|
+
const alreadyHas = intentFilters.some((filter) =>
|
|
139
|
+
(filter.data || []).some(
|
|
140
|
+
(d) => d?.$?.["android:scheme"] === oauthRedirectScheme,
|
|
141
|
+
),
|
|
142
|
+
);
|
|
143
|
+
if (alreadyHas) return cfg;
|
|
144
|
+
|
|
145
|
+
intentFilters.push({
|
|
146
|
+
$: { "android:autoVerify": "false" },
|
|
147
|
+
action: [{ $: { "android:name": "android.intent.action.VIEW" } }],
|
|
148
|
+
category: [
|
|
149
|
+
{ $: { "android:name": "android.intent.category.DEFAULT" } },
|
|
150
|
+
{ $: { "android:name": "android.intent.category.BROWSABLE" } },
|
|
151
|
+
],
|
|
152
|
+
data: [{ $: { "android:scheme": oauthRedirectScheme } }],
|
|
153
|
+
});
|
|
154
|
+
mainActivity["intent-filter"] = intentFilters;
|
|
155
|
+
return cfg;
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const withMoonKey = (config, props = {}) => {
|
|
160
|
+
let next = config;
|
|
161
|
+
next = withAssociatedDomains(
|
|
162
|
+
next,
|
|
163
|
+
props.passkeyDomains,
|
|
164
|
+
props.passkeyDeveloperMode === true,
|
|
165
|
+
);
|
|
166
|
+
next = withExportCompliance(next);
|
|
167
|
+
next = withAssetStatements(next, props.passkeyDomains);
|
|
168
|
+
next = withOAuthIntentFilter(next, props.oauthRedirectScheme);
|
|
169
|
+
return next;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
module.exports = withMoonKey;
|