Skip to content

Commit 4ea4db6

Browse files
robhoganmeta-codesync[bot]
authored andcommitted
Add temporary OIDC claim debugging to npm publish workflow
Summary: Adds a temporary debug step to both jobs of the reusable npm publish workflow that requests the GitHub Actions OIDC token (npm audience) and prints its decoded claims. This makes it possible to compare the token claims against the npm Trusted Publisher configuration when the OIDC exchange fails. Only the decoded claims are printed, never the raw token. Changelog: [Internal] bypass-github-export-checks Reviewed By: cortinico, cipolleschi Differential Revision: D108108630 fbshipit-source-id: 6ae8be8c9e9e2e611b6941b336230a21f876e134
1 parent 9d03750 commit 4ea4db6

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

.github/workflows/publish-npm.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,23 @@ jobs:
7171
with:
7272
fetch-depth: 0
7373
fetch-tags: true
74+
# TEMPORARY DEBUG: print the OIDC token claims npm Trusted Publishing
75+
# matches against. A 404 from the OIDC exchange means these claims don't
76+
# match the Trusted Publisher entry configured on npmjs.com (org/repo/
77+
# workflow filename / environment). Prints only the decoded claims, never
78+
# the raw token. Remove once the 404 is resolved.
79+
- name: Debug OIDC token claims
80+
shell: bash
81+
run: |
82+
# ACTIONS_ID_TOKEN_REQUEST_TOKEN/_URL are auto-injected when the job
83+
# has `id-token: write` - they are NOT secrets, don't map them in env.
84+
OIDC_TOKEN=$(curl -sS -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
85+
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=npm:registry.npmjs.org" | jq -r '.value')
86+
# Decode the JWT payload (middle segment); convert base64url -> base64
87+
# and pad so `base64 -d` accepts it. Prints claims only, not the token.
88+
payload=$(echo "$OIDC_TOKEN" | cut -d'.' -f2 | tr '_-' '/+')
89+
case $(( ${#payload} % 4 )) in 2) payload+='==';; 3) payload+='=';; esac
90+
echo "$payload" | base64 -d 2>/dev/null | jq .
7491
- name: Build and Publish NPM Package
7592
uses: ./.github/actions/build-npm-package
7693
with:
@@ -92,6 +109,23 @@ jobs:
92109
uses: ./.github/actions/setup-node
93110
with:
94111
registry-url: "https://registry.npmjs.org"
112+
# TEMPORARY DEBUG: print the OIDC token claims npm Trusted Publishing
113+
# matches against. A 404 from the OIDC exchange means these claims don't
114+
# match the Trusted Publisher entry configured on npmjs.com (org/repo/
115+
# workflow filename / environment). Prints only the decoded claims, never
116+
# the raw token. Remove once the 404 is resolved.
117+
- name: Debug OIDC token claims
118+
shell: bash
119+
run: |
120+
# ACTIONS_ID_TOKEN_REQUEST_TOKEN/_URL are auto-injected when the job
121+
# has `id-token: write` - they are NOT secrets, don't map them in env.
122+
OIDC_TOKEN=$(curl -sS -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
123+
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=npm:registry.npmjs.org" | jq -r '.value')
124+
# Decode the JWT payload (middle segment); convert base64url -> base64
125+
# and pad so `base64 -d` accepts it. Prints claims only, not the token.
126+
payload=$(echo "$OIDC_TOKEN" | cut -d'.' -f2 | tr '_-' '/+')
127+
case $(( ${#payload} % 4 )) in 2) payload+='==';; 3) payload+='=';; esac
128+
echo "$payload" | base64 -d 2>/dev/null | jq .
95129
- name: Run Yarn Install
96130
uses: ./.github/actions/yarn-install
97131
- name: Build packages

0 commit comments

Comments
 (0)