Skip to content

Implement client-side OAuth 1.0a to eliminate proxy server dependency#6

Draft
Copilot wants to merge 6 commits into
mainfrom
copilot/fix-nounproject-implementation
Draft

Implement client-side OAuth 1.0a to eliminate proxy server dependency#6
Copilot wants to merge 6 commits into
mainfrom
copilot/fix-nounproject-implementation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 11, 2026

Removed Node.js proxy server requirement by implementing OAuth 1.0a HMAC-SHA1 signing directly in browser using Web Crypto API. App now runs as pure static HTML.

Changes

OAuth 1.0a client implementation

  • Added generateOAuthSignature() using crypto.subtle.sign() for HMAC-SHA1
  • Implemented RFC 5849 compliant signature base string construction
  • Updated searchNounProjectIcons() to call API directly with OAuth headers
  • Removed all proxy server references from main code
async function generateOAuthSignature(method, url, params, consumerSecret) {
  const sortedParams = Object.keys(params).sort()
    .map(key => `${percentEncode(key)}=${percentEncode(params[key])}`)
    .join('&');
  
  const baseString = [method.toUpperCase(), percentEncode(url), percentEncode(sortedParams)].join('&');
  const signingKey = `${percentEncode(consumerSecret)}&`;
  
  const key = await crypto.subtle.importKey('raw', encoder.encode(signingKey), 
    { name: 'HMAC', hash: 'SHA-1' }, false, ['sign']);
  const signature = await crypto.subtle.sign('HMAC', key, encoder.encode(baseString));
  
  return btoa(String.fromCharCode(...new Uint8Array(signature)));
}

Security & CORS handling

  • Added prominent warnings about credential exposure in localStorage and page source
  • Documented CORS limitation (Noun Project API blocks direct browser calls)
  • Added CORS_PROXY constant for optional proxy service workaround
  • Enhanced error messaging for credential validation

Documentation

  • Updated README with three CORS workaround options (proxy service, browser extension, backend)
  • Clarified api-proxy.js is now optional, kept for production deployments
  • Removed hardcoded line references

Settings modal with security warnings

Tradeoffs

Gains: No backend deployment required, runs as static file, simpler architecture

Costs: API credentials visible in client code and localStorage, CORS restrictions require workaround (proxy service/extension/backend)

Recommendation: Suitable for personal use only. For production, deploy included api-proxy.js backend.

Original prompt

This section details on the original issue you should resolve

<issue_title>Fix nounproject implementation</issue_title>
<issue_description>I added my key, and the UI said the api was connected, but the search didn't bring up any extra results.</issue_description>

<agent_instructions>here are the keys:
API Key: 00faf90d314e4bfa97c6f3e8f8b65acf
API Secret: 2be95ccf383e49ef9c8b25eb60391a7b
</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits March 11, 2026 19:44
Co-authored-by: jjm578 <163756567+jjm578@users.noreply.github.com>
Co-authored-by: jjm578 <163756567+jjm578@users.noreply.github.com>
Co-authored-by: jjm578 <163756567+jjm578@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix nounproject implementation for search results Fix Noun Project API integration - implement OAuth 1.0a proxy Mar 11, 2026
Copilot AI and others added 2 commits March 11, 2026 20:32
Co-authored-by: jjm578 <163756567+jjm578@users.noreply.github.com>
…ssages

Co-authored-by: jjm578 <163756567+jjm578@users.noreply.github.com>
Copilot AI changed the title Fix Noun Project API integration - implement OAuth 1.0a proxy Implement client-side OAuth 1.0a to eliminate proxy server dependency Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix nounproject implementation

2 participants