or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-7/

International Social Media OAuth Client

Create an OAuth 1.0 client utility that handles authentication requests for a social media API that accepts posts in multiple languages, including non-ASCII characters.

Requirements

Your task is to build a utility that generates properly signed OAuth 1.0 requests for posting status updates in different languages. The utility should:

  1. Accept status messages containing Unicode characters (e.g., Japanese, Arabic, Emoji, Chinese)
  2. Properly encode all OAuth parameters including those with international characters
  3. Generate valid OAuth signatures that work with non-ASCII content
  4. Support the HMAC-SHA1 signature method
  5. Return a properly formatted OAuth signature that can be used in API requests

The utility should handle the following scenarios:

  • English text with special characters
  • Japanese characters (Hiragana, Katakana, Kanji)
  • Arabic script
  • Emoji and other Unicode symbols
  • Mixed language content

Implementation

@generates

Create a function generateOAuthSignature(httpMethod, baseUrl, params) that:

  • Takes an HTTP method (e.g., 'POST')
  • Takes a base URL (e.g., 'https://api.example.com/statuses/update')
  • Takes an object containing OAuth parameters and request parameters (including status text with Unicode)
  • Returns the OAuth signature as a string

The function should use the provided consumer secret ('consumer_secret_123') and token secret ('token_secret_456') for signature generation.

Test Cases

  • Given a POST request to 'https://api.example.com/statuses/update' with status "Hello World", the function generates a valid signature @test

  • Given a POST request with Japanese text "こんにちは世界" (Hello World in Japanese), the function generates a valid signature @test

  • Given a POST request with emoji "Hello 🌍 World 🚀", the function generates a valid signature @test

  • Given a POST request with Arabic text "مرحبا بالعالم" (Hello World in Arabic), the function generates a valid signature @test

API

/**
 * Generates an OAuth 1.0 signature for API requests containing international characters.
 *
 * @param {string} httpMethod - The HTTP method (e.g., 'POST', 'GET')
 * @param {string} baseUrl - The base URL of the API endpoint
 * @param {Object} params - Object containing OAuth and request parameters
 * @returns {string} The OAuth signature string
 */
function generateOAuthSignature(httpMethod, baseUrl, params) {
  // Implementation here
}

module.exports = { generateOAuthSignature };

Dependencies { .dependencies }

oauth-sign { .dependency }

Provides OAuth 1.0 signature generation with support for international characters.