// SPDX-FileCopyrightText: 2025 Contributors to the CitrineOS Project
//
// SPDX-License-Identifier: Apache-2.0
import { applyUpdateFunction, UpdateFunction } from '../utils/UpdateUtil';

export const HUBJECT_DEFAULT_AUTH_TOKEN =
  'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IkJ3eEV0TkFGUnpSM3JlNVF2elM2QyJ9.eyJodHRwczovL2V1LnBsdWduY2hhcmdlLXRlc3QuaHViamVjdC5jb20vcm9sZSI6WyJBRE1JTiIsIk9FTSIsIkNQTyIsIk1PX0hVQkpFQ1RfUEtJIl0sImh0dHBzOi8vZXUucGx1Z25jaGFyZ2UtdGVzdC5odWJqZWN0LmNvbS9wY2lkIjpbIkhVQiIsImh1YiJdLCJodHRwczovL2V1LnBsdWduY2hhcmdlLXRlc3QuaHViamVjdC5jb20vZW1haWQiOlsiREVIVUIiLCJFTVA3NyJdLCJodHRwczovL2V1LnBsdWduY2hhcmdlLXRlc3QuaHViamVjdC5jb20vY2xpZW50X25hbWUiOlsiSHViamVjdCJdLCJodHRwczovL2V1LnBsdWduY2hhcmdlLXRlc3QuaHViamVjdC5jb20vZGFzaDIwIjpbInRydWUiXSwiaHR0cHM6Ly9ldS5wbHVnbmNoYXJnZS10ZXN0Lmh1YmplY3QuY29tL2NsaWVudF9hcHAiOiJPcGVuIFRlc3QgRW52aXJvbm1lbnQiLCJpc3MiOiJodHRwczovL2F1dGguZXUucGx1Z25jaGFyZ2UuaHViamVjdC5jb20vIiwic3ViIjoibzU3UWF3cTFvbms3VWtacmhGbUVxalNPTXFkaDM0UmdAY2xpZW50cyIsImF1ZCI6Imh0dHBzOi8vZXUucGx1Z25jaGFyZ2UtdGVzdC5odWJqZWN0LmNvbSIsImlhdCI6MTc3MDcwMTgxMSwiZXhwIjoxNzcwNzg4MjExLCJzY29wZSI6InJjcHNlcnZpY2UgcGNwc2VydmljZSBjY3BzZXJ2aWNlIGNwc2VydmljZSBwa2lnYXRld2F5IiwiZ3R5IjoiY2xpZW50LWNyZWRlbnRpYWxzIiwiYXpwIjoibzU3UWF3cTFvbms3VWtacmhGbUVxalNPTXFkaDM0UmciLCJwZXJtaXNzaW9ucyI6WyJyY3BzZXJ2aWNlIiwicGNwc2VydmljZSIsImNjcHNlcnZpY2UiLCJjcHNlcnZpY2UiLCJwa2lnYXRld2F5Il19.qpkB0reRKznCNXnbxCs0WMPCZx2ezo3Uv7vb0FW0qtMFHLF88IjzA0TUn4azD3zwjIG0N6rnTws4kzKkzwC-_XejCF-RvTEWKM4iUisdbl3Hz8nov0QmAME9U7BYJ52BHaQxP0S6o89qWRgtkzB63XRbbI_Z1fAh9Pzz-eVJePgD2GANNb8JqCzlV0vgyZU3jvdmVvJDYMyqyGe_lLlU5E0ocUntAWaP_TyrmRqctb5VB82WEdwdsRB5Wusqc5C0rLUwsySOff5gcDg5LXtGwUZtsA7TTtVQSqhQ1HrPVYhlKl-s5TZ-v7uho8wCnaCoJt6GPvZzKqHJHydBMlWDWg';

export const aValidSignedContractData = (updateFunction?: UpdateFunction<object>): object => {
  // This example is from https://hubject.stoplight.io/docs/open-plugncharge/9fabe1661696f-get-signed-contract-data
  const item = {
    CCPResponse: {
      emaidContent: [
        {
          messageDef: {
            metaData: 'string',
            certificateInstallationRes:
              '[encoded data, 7368 characters]',
            emaid: 'DECGN000020001',
          },
        },
      ],
    },
  };
  return applyUpdateFunction(item, updateFunction);
};

export const aValidAuthorizationToken = (updateFunction?: UpdateFunction<object>): object => {
  // This example is from https://hubject.stoplight.io/api/v1/projects/cHJqOjk0NTg5/nodes/6bb8b3bc79c2e-authorization-token
  const item = {
    id: '6bb8b3bc79c2e',
    branch_node_id: 28203168,
    type: 'article',
    uri: '/docs/Token.md',
    slug: '6bb8b3bc79c2e-authorization-token',
    title: 'Authorization Token',
    summary: 'Please use the following token to authorize your requests on Open Plugncharge:',
    project_id: 'cHJqOjk0NTg5',
    branch_id: 'YnI6MTUxOTIwMw',
    branch: 'master',
    links: {},
    outbound_edges: [],
    inbound_edges: [],
    data: `# Authorization Token\n> Please use the following token to authorize your requests on Open Plugncharge:\n\n\`\`\`\nBearer ${HUBJECT_DEFAULT_AUTH_TOKEN}\n\`\`\``,
  };
  return applyUpdateFunction(item, updateFunction);
};

export const aValidRootCertificates = (updateFunction?: UpdateFunction<object>): object => {
  // This example is from https://hubject.stoplight.io/docs/open-plugncharge/fdc9bdfdd4fb2-get-all-root-certificates
  const item = {
    RootCertificateCollection: {
      rootCertificates: [
        {
          rootCertificateId: 'e6c58da2-aeaf-438c-b484-40c3cca35e97',
          distinguishedName: 'CN=US V2G Root CA QA G2, DC=V2G, O=Hubject Inc., C=US',
          caCertificate:
            'MIICFjCCAbygAwIBAgIQbIqT2zas5F2twNToU49ArDAKBggqhkjOPQQDAjBYMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMSHViamVjdCBJbmMuMRMwEQYKCZImiZPyLGQBGRYDVjJHMR0wGwYDVQQDExRVUyBWMkcgUm9vdCBDQSBRQSBHMjAgFw0yMDA1MTkyMTU5NTlaGA8yMDYwMDUxOTIxNTk1OVowWDELMAkGA1UEBhMCVVMxFTATBgNVBAoTDEh1YmplY3QgSW5jLjETMBEGCgmSJomT8ixkARkWA1YyRzEdMBsGA1UEAxMUVVMgVjJHIFJvb3QgQ0EgUUEgRzIwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAR2/KiLLZNcg4l5jANoMMotv5eY252KPiMegm8N9gOdj3/vskoamOAPD18ot+jczZRwPrxgRhS0Jq4PwlIdCWibo2YwZDAPBgNVHRMBAf8EBTADAQH/MBEGA1UdDgQKBAhK2xerpZDAaDAZBgNVHSAEEjAQMA4GDCsGAQQBg64NAQIBAjATBgNVHSMEDDAKgAhK2xerpZDAaDAOBgNVHQ8BAf8EBAMCAQYwCgYIKoZIzj0EAwIDSAAwRQIhAMUGxn3tBpgOZ/JnaKgFinRufQYRhoTtxFjbNw5d4OebAiBZrbKEoMHbBiWz7dSfwGfmzMQbgqPoGA8SSpA1a053Gg==',
          commonName: 'CN=US V2G Root CA QA G2, DC=V2G, O=Hubject Inc., C=US',
          rootAuthorityKeyIdentifier: 'StsXq6WQwGg=',
          rootIssuerSerialNumber: '6c8a93db36ace45dadc0d4e8538f40ac',
          validFrom: '2020-05-19T21:59:59Z',
          validTo: '2060-05-19T21:59:59Z',
          organizationName: 'Hubject Inc.',
        },
        {
          rootCertificateId: '7e3889c6-473c-4777-94a5-a532e4439218',
          distinguishedName: 'CN=Hubject Root INTERNAL, O=Nexus, C=DE',
          caCertificate:
            'MIIBqjCCAVGgAwIBAgIQVxCaWc+R9k7esNEQSBW22jAKBggqhkjOPQQDAjA9MQswCQYDVQQGEwJERTEOMAwGA1UEChMFTmV4dXMxHjAcBgNVBAMTFUh1YmplY3QgUm9vdCBJTlRFUk5BTDAeFw0xOTA3MjUxMDQ3NThaFw0yNDA3MjUxMDQ3NThaMD0xCzAJBgNVBAYTAkRFMQ4wDAYDVQQKEwVOZXh1czEeMBwGA1UEAxMVSHViamVjdCBSb290IElOVEVSTkFMMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEj/frqHOQRfacyKNNDreXJTbVjrjBLart/OaNB8pV9HzWWhHdG3qkwYMCk7ip8Y/4hvZDAPCcTKNCAqjSqMg66qMzMDEwDwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQIRD+HP5qgLzowCwYDVR0PBAQDAgEGMAoGCCqGSM49BAMCA0cAMEQCIHOz3U0fewDP/N7o/pFmDtoz12tyXk0V2IK5kIQN9LCnAiAG7bbNzTYFy2cGIGr8uCX9i8kPz43IWYhyGwI1vsUa+w==',
          commonName: 'Hubject Root INTERNAL',
          rootIssuerSerialNumber: '57109a59cf91f64edeb0d1104815b6da',
          validFrom: '2019-07-25T10:47:58Z',
          validTo: '2024-07-25T10:47:58Z',
          organizationName: 'Nexus',
          rootType: 'V2G',
        },
      ],
    },
  };
  return applyUpdateFunction(item, updateFunction);
};
