@luciq/react-native 19.4.0-40394-SNAPSHOT → 19.4.0-47163-SNAPSHOT

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@luciq/react-native",
3
3
  "description": "Luciq is the Agentic Observability Platform built for Mobile.",
4
- "version": "19.4.0-40394-SNAPSHOT",
4
+ "version": "19.4.0-47163-SNAPSHOT",
5
5
  "author": "Luciq (https://luciq.ai)",
6
6
  "repository": "github:luciqai/luciq-reactnative-sdk",
7
7
  "homepage": "https://www.luciq.ai/platforms/react-native",
@@ -0,0 +1,70 @@
1
+ #!/bin/bash
2
+
3
+ # Generates a GitHub App installation token using openssl + curl.
4
+ # No external dependencies required.
5
+ #
6
+ # Usage: bash get-github-app-token.sh <APP_ID_ENV> <PRIVATE_KEY_ENV> <INSTALLATION_ID_ENV>
7
+ # Example: bash get-github-app-token.sh AND_LUCIQ_APP_ID AND_LUCIQ_PRIVATE_KEY AND_LUCIQ_INSTALLATION_ID
8
+ # Example: bash get-github-app-token.sh AND_INSTABUG_APP_ID AND_INSTABUG_PRIVATE_KEY AND_INSTABUG_INSTALLATION_ID
9
+
10
+ set -euo pipefail
11
+
12
+ APP_ID_ENV="${1:?Usage: $0 <APP_ID_ENV> <PRIVATE_KEY_ENV> <INSTALLATION_ID_ENV>}"
13
+ PRIVATE_KEY_ENV="${2:?Usage: $0 <APP_ID_ENV> <PRIVATE_KEY_ENV> <INSTALLATION_ID_ENV>}"
14
+ INSTALL_ID_ENV="${3:?Usage: $0 <APP_ID_ENV> <PRIVATE_KEY_ENV> <INSTALLATION_ID_ENV>}"
15
+
16
+ APP_ID="${!APP_ID_ENV:?Error: $APP_ID_ENV is not set}"
17
+ PRIVATE_KEY="${!PRIVATE_KEY_ENV:?Error: $PRIVATE_KEY_ENV is not set}"
18
+ INSTALL_ID="${!INSTALL_ID_ENV:?Error: $INSTALL_ID_ENV is not set}"
19
+
20
+ # Reconstruct PEM file from flattened env var
21
+ # CircleCI flattens multiline env vars into a single line,
22
+ # so we extract header/footer and re-wrap the base64 body at 64 chars
23
+ PEM_FILE=$(mktemp)
24
+ chmod 600 "$PEM_FILE"
25
+ trap 'rm -f "$PEM_FILE"' EXIT
26
+
27
+ BODY=$(printf '%s' "$PRIVATE_KEY" | sed 's/-----BEGIN RSA PRIVATE KEY-----//;s/-----END RSA PRIVATE KEY-----//;s/ //g')
28
+ {
29
+ echo "-----BEGIN RSA PRIVATE KEY-----"
30
+ echo "$BODY" | fold -w 64
31
+ echo "-----END RSA PRIVATE KEY-----"
32
+ } > "$PEM_FILE"
33
+
34
+ # Base64url encode (RFC 4648): replace +/ with -_, strip =
35
+ b64url() {
36
+ openssl base64 -A | tr '+/' '-_' | tr -d '='
37
+ }
38
+
39
+ NOW=$(date +%s)
40
+ IAT=$((NOW - 60)) # 60s clock skew allowance per GitHub docs
41
+ EXP=$((NOW + 600)) # 10min max JWT lifetime per GitHub docs
42
+
43
+ # Create JWT header and payload
44
+ HEADER=$(printf '{"alg":"RS256","typ":"JWT"}' | b64url)
45
+ PAYLOAD=$(printf '{"iat":%d,"exp":%d,"iss":"%s"}' "$IAT" "$EXP" "$APP_ID" | b64url)
46
+
47
+ # Sign with RSA-SHA256
48
+ SIGNATURE=$(printf '%s.%s' "$HEADER" "$PAYLOAD" | openssl dgst -sha256 -sign "$PEM_FILE" -binary | b64url)
49
+
50
+ JWT_TOKEN="${HEADER}.${PAYLOAD}.${SIGNATURE}"
51
+
52
+ # Exchange JWT for installation token
53
+ RESPONSE=$(curl -sf -X POST \
54
+ -H "Authorization: Bearer $JWT_TOKEN" \
55
+ -H "Accept: application/vnd.github+json" \
56
+ -H "X-GitHub-Api-Version: 2022-11-28" \
57
+ "https://api.github.com/app/installations/${INSTALL_ID}/access_tokens") || {
58
+ echo "Error: GitHub API request failed (HTTP error)" >&2
59
+ exit 1
60
+ }
61
+
62
+ TOKEN=$(echo "$RESPONSE" | jq -r '.token // empty')
63
+
64
+ if [ -z "$TOKEN" ]; then
65
+ ERROR_MSG=$(echo "$RESPONSE" | jq -r '.message // "unknown error"')
66
+ echo "Error: Failed to get installation token: $ERROR_MSG" >&2
67
+ exit 1
68
+ fi
69
+
70
+ echo "$TOKEN"