<?php

/**
 * Example Configuration for NetSuite OAuth 2.0 JWT Authentication
 * 
 * This file shows how to configure the NetSuite extension with OAuth 2.0 JWT authentication
 */

return [
    'components' => [
        'netsuite' => [
            'class' => 'PortalPeople\netsuite\components\NetSuiteComponent',
            
            // Basic NetSuite account information
            'accountId' => 'YOUR_ACCOUNT_ID', // e.g., '123456_SB1'
            
            // OAuth 2.0 credentials from Integration Record
            'clientId' => 'YOUR_CLIENT_ID',
            'clientSecret' => 'YOUR_CLIENT_SECRET',
            
            // Certificate information (from public key upload)
            'certificateId' => 'sMyoQV48HFBT2jkfx8n1M8CxMI0oNVYs-8_R3D6A-xg', // Example Key ID
            
            // Private key file path (relative to app root or absolute path)
            'privateKeyPath' => 'modules/netsuite/config/private.pem',
            
            // NetSuite User for impersonation
            'userId' => 'YOUR_USER_INTERNAL_ID', // Internal ID of NetSuite user
            
            // Optional: Custom base URL (auto-generated if not provided)
            // 'baseUrl' => 'https://YOUR_ACCOUNT.suitetalk.api.netsuite.com/services/rest',
        ],
    ],
    
    // Alternative: Using environment variables for security
    /*
    'components' => [
        'netsuite' => [
            'class' => 'PortalPeople\netsuite\components\NetSuiteComponent',
            'accountId' => $_ENV['NETSUITE_ACCOUNT_ID'],
            'clientId' => $_ENV['NETSUITE_CLIENT_ID'],
            'clientSecret' => $_ENV['NETSUITE_CLIENT_SECRET'],
            'certificateId' => $_ENV['NETSUITE_CERTIFICATE_ID'],
            'privateKeyPath' => $_ENV['NETSUITE_PRIVATE_KEY_PATH'],
            'userId' => $_ENV['NETSUITE_USER_ID'],
        ],
    ],
    */
];

/**
 * JWT Parameters Used Internally:
 * 
 * The extension automatically handles JWT generation with these parameters:
 * 
 * $jwtParams = [
 *     'header' => [
 *         'alg' => 'ES256',  // NetSuite requires ES256 algorithm
 *         'kid' => $this->certificateId, // Your certificate ID from config
 *         'typ' => 'JWT'
 *     ],
 *     'payload' => [
 *         'iss' => $this->clientId,    // Issuer: Your client ID
 *         'sub' => $this->userId,      // Subject: User for impersonation
 *         'aud' => 'https://ACCOUNT.suitetalk.api.netsuite.com/services/rest/auth/oauth2/v1/token',
 *         'exp' => time() + 3600,      // Expires in 1 hour
 *         'iat' => time(),             // Issued at current time
 *         'scope' => 'rest_webservices' // Required scope
 *     ],
 *     'signatureKey' => $privateKey    // Your private key for signing
 * ];
 * 
 * The private key is read from the file specified in 'privateKeyPath' configuration.
 */