@hermeticacomms/sdk-expo 0.0.0-stage → 0.4.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.
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hermetica
4
+
5
+ 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:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ 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.
package/README.md CHANGED
@@ -1,3 +1,30 @@
1
- # Temporary Holding Version
1
+ # @hermeticacomms/sdk-expo
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Expo config plugin for Hermeticor. At `expo prebuild` it sets what push needs natively (the `aps-environment` entitlement,
4
+ background remote notifications, Android 13's `POST_NOTIFICATIONS`), optionally the geofencing permissions, and stores the site
5
+ key and endpoint in `extra.hermetica`. The runtime SDK is `@hermeticacomms/sdk-react-native`.
6
+
7
+ ```json
8
+ {
9
+ "expo": {
10
+ "plugins": [
11
+ ["@hermeticacomms/sdk-expo", { "siteKey": "hm_pk_...", "endpoint": "https://api.example.com", "apsEnvironment": "production" }]
12
+ ]
13
+ }
14
+ }
15
+ ```
16
+
17
+ ```ts
18
+ import Constants from 'expo-constants';
19
+ import * as Notifications from 'expo-notifications';
20
+ import AsyncStorage from '@react-native-async-storage/async-storage';
21
+ import { createReactNativeClient } from '@hermeticacomms/sdk-react-native';
22
+
23
+ const { siteKey, endpoint } = Constants.expoConfig!.extra!.hermetica;
24
+ const hm = await createReactNativeClient({ siteKey, endpoint, storage: AsyncStorage, platform: Platform.OS === 'ios' ? 'ios' : 'android' });
25
+ const { data: token } = await Notifications.getDevicePushTokenAsync(); // APNs / FCM token
26
+ await hm.setPushToken(token, { platform: Platform.OS, vendor: Platform.OS === 'ios' ? 'apns' : 'fcm', environment: 'release', enablementStatus: 'AUTHORIZED', background: 'AVAILABLE' });
27
+ ```
28
+
29
+ Options: `push` (default true), `apsEnvironment` (`development` | `production`), `geofencing: { locationUsage }` (adds the location
30
+ permissions and the iOS prompt text). A secret `hm_sk_` key is refused. Running the plugin twice changes nothing.
package/app.plugin.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/plugin.js').default;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Expo config plugin for Hermeticor: sets the native config push (and optionally geofencing) need at `expo prebuild`, and puts the
3
+ * site key and endpoint in `extra.hermetica` for the app to read. It edits only the app config fields Expo already applies
4
+ * (`ios.entitlements`, `ios.infoPlist`, `android.permissions`, `extra`), so it needs no dependency on @expo/config-plugins.
5
+ * The runtime SDK is @hermetica/sdk-react-native.
6
+ */
7
+ export interface HermeticaPluginProps {
8
+ /** Public site key (never a secret key). Read back with `Constants.expoConfig.extra.hermetica.siteKey`. */
9
+ siteKey?: string;
10
+ endpoint?: string;
11
+ /** APNs environment of the build (default production; development for dev-client builds signed for development). */
12
+ apsEnvironment?: 'development' | 'production';
13
+ /** Push setup: aps-environment, background remote notifications, Android 13 POST_NOTIFICATIONS. Default true. */
14
+ push?: boolean;
15
+ /** Geofencing permissions; the string is the iOS "always" location prompt. Off unless given. */
16
+ geofencing?: {
17
+ locationUsage: string;
18
+ };
19
+ }
20
+ type Dict = Record<string, unknown>;
21
+ /** The parts of Expo's app config this plugin reads and writes. */
22
+ export interface ExpoConfig {
23
+ ios?: {
24
+ entitlements?: Dict;
25
+ infoPlist?: Dict;
26
+ } & Dict;
27
+ android?: {
28
+ permissions?: string[];
29
+ } & Dict;
30
+ extra?: Dict;
31
+ [k: string]: unknown;
32
+ }
33
+ export default function withHermetica(config: ExpoConfig, props?: HermeticaPluginProps): ExpoConfig;
34
+ export {};
package/dist/plugin.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = withHermetica;
4
+ const add = (list, ...items) => {
5
+ const out = Array.isArray(list) ? list.filter((x) => typeof x === 'string') : [];
6
+ for (const i of items)
7
+ if (!out.includes(i))
8
+ out.push(i);
9
+ return out;
10
+ };
11
+ function withHermetica(config, props = {}) {
12
+ if (props.siteKey?.startsWith('hm_sk_'))
13
+ throw new Error('withHermetica: use the public site key, never a secret hm_sk_ key, in an app');
14
+ const ios = { ...config.ios, entitlements: { ...config.ios?.entitlements }, infoPlist: { ...config.ios?.infoPlist } };
15
+ const android = { ...config.android, permissions: [...(config.android?.permissions ?? [])] };
16
+ if (props.push !== false) {
17
+ ios.entitlements['aps-environment'] = props.apsEnvironment ?? 'production';
18
+ ios.infoPlist['UIBackgroundModes'] = add(ios.infoPlist['UIBackgroundModes'], 'remote-notification');
19
+ android.permissions = add(android.permissions, 'android.permission.POST_NOTIFICATIONS');
20
+ }
21
+ if (props.geofencing) {
22
+ ios.infoPlist['NSLocationAlwaysAndWhenInUseUsageDescription'] ??= props.geofencing.locationUsage;
23
+ ios.infoPlist['NSLocationWhenInUseUsageDescription'] ??= props.geofencing.locationUsage;
24
+ ios.infoPlist['UIBackgroundModes'] = add(ios.infoPlist['UIBackgroundModes'], 'location');
25
+ android.permissions = add(android.permissions, 'android.permission.ACCESS_FINE_LOCATION', 'android.permission.ACCESS_BACKGROUND_LOCATION');
26
+ }
27
+ const hermetica = { ...(props.siteKey ? { siteKey: props.siteKey } : {}), ...(props.endpoint ? { endpoint: props.endpoint } : {}) };
28
+ return { ...config, ios, android, extra: { ...config.extra, hermetica: { ...config.extra?.['hermetica'], ...hermetica } } };
29
+ }
package/package.json CHANGED
@@ -1,6 +1,32 @@
1
1
  {
2
2
  "name": "@hermeticacomms/sdk-expo",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.4.0",
4
+ "description": "Expo config plugin for Hermetica: push entitlements and permissions, site key in app config",
5
+ "license": "MIT",
6
+ "type": "commonjs",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/hermeticacomms/hermetica-expo.git"
10
+ },
11
+ "homepage": "https://github.com/hermeticacomms/hermetica-expo#readme",
12
+ "publishConfig": {
13
+ "access": "public",
14
+ "provenance": true
15
+ },
16
+ "main": "./dist/plugin.js",
17
+ "types": "./dist/plugin.d.ts",
18
+ "files": [
19
+ "dist",
20
+ "app.plugin.js"
21
+ ],
22
+ "scripts": {
23
+ "prepare": "npm run build",
24
+ "build": "tsc -p tsconfig.json",
25
+ "test": "vitest run",
26
+ "typecheck": "tsc -p tsconfig.json --noEmit"
27
+ },
28
+ "devDependencies": {
29
+ "typescript": "^7.0.2",
30
+ "vitest": "^5.0.5"
31
+ }
32
+ }