@open-mercato/gateway-autopay 0.10.1-develop.8045.1.3e5aadf0fb → 0.10.1-develop.8050.1.45ae874fe7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/gateway_autopay/lib/preset.ts"],
4
- "sourcesContent": ["import { parseBooleanToken } from '@open-mercato/shared/lib/boolean'\nimport type { IntegrationScope } from '@open-mercato/shared/modules/integrations/types'\nimport type { CredentialsService } from '@open-mercato/core/modules/integrations/lib/credentials-service'\nimport type { IntegrationLogService } from '@open-mercato/core/modules/integrations/lib/log-service'\nimport type { IntegrationStateService } from '@open-mercato/core/modules/integrations/lib/state-service'\n\nconst AUTOPAY_INTEGRATION_ID = 'gateway_autopay'\n\ntype AutopayCredentialShape = {\n serviceId: string\n sharedKey: string\n hashAlgorithm?: string\n gatewayUrl: string\n}\n\ntype AutopayEnvPreset = {\n credentials: AutopayCredentialShape\n force: boolean\n enabled: boolean\n}\n\nexport type ApplyAutopayPresetResult =\n | { status: 'skipped'; reason: string }\n | { status: 'configured'; enabled: boolean }\n\nfunction readEnvValue(env: NodeJS.ProcessEnv, keys: string[]): string | undefined {\n for (const key of keys) {\n const value = env[key]?.trim()\n if (value) return value\n }\n return undefined\n}\n\nfunction readBooleanEnv(env: NodeJS.ProcessEnv, keys: string[]): boolean | undefined {\n for (const key of keys) {\n const parsed = parseBooleanToken(env[key])\n if (parsed !== null) return parsed\n }\n return undefined\n}\n\n/**\n * Reads sandbox/production Autopay credentials from env. There is no\n * publicly-usable default here (unlike some providers) \u2014 the sandbox\n * worked-example values (ServiceID=2, sharedKey=2test2) authenticate the\n * hash math only, never an actual redirect, per the `paytalk/autopay-sandbox`\n * reference project's own findings.\n */\nexport function readAutopayEnvPreset(env: NodeJS.ProcessEnv = process.env): AutopayEnvPreset | null {\n const credentialKeys = {\n serviceId: ['OM_INTEGRATION_AUTOPAY_SERVICE_ID'],\n sharedKey: ['OM_INTEGRATION_AUTOPAY_SHARED_KEY'],\n gatewayUrl: ['OM_INTEGRATION_AUTOPAY_GATEWAY_URL'],\n } as const\n\n const anyCredentialProvided = Object.values(credentialKeys).some((keys) => Boolean(readEnvValue(env, [...keys])))\n if (!anyCredentialProvided) {\n return null\n }\n\n const serviceId = readEnvValue(env, [...credentialKeys.serviceId])\n const sharedKey = readEnvValue(env, [...credentialKeys.sharedKey])\n const gatewayUrl = readEnvValue(env, [...credentialKeys.gatewayUrl])\n\n if (!serviceId || !sharedKey || !gatewayUrl) {\n throw new Error(\n '[gateway_autopay] Incomplete Autopay env preset. Set OM_INTEGRATION_AUTOPAY_SERVICE_ID, OM_INTEGRATION_AUTOPAY_SHARED_KEY, and OM_INTEGRATION_AUTOPAY_GATEWAY_URL.',\n )\n }\n\n const hashAlgorithm = readEnvValue(env, ['OM_INTEGRATION_AUTOPAY_HASH_ALGORITHM'])\n\n return {\n credentials: { serviceId, sharedKey, gatewayUrl, hashAlgorithm },\n force: readBooleanEnv(env, ['OM_INTEGRATION_AUTOPAY_FORCE_PRECONFIGURE']) ?? false,\n enabled: readBooleanEnv(env, ['OM_INTEGRATION_AUTOPAY_ENABLED']) ?? true,\n }\n}\n\nasync function hasExistingAutopayConfiguration(\n credentialsService: CredentialsService,\n integrationStateService: IntegrationStateService,\n scope: IntegrationScope,\n): Promise<boolean> {\n const [credentials, state] = await Promise.all([\n credentialsService.getRaw(AUTOPAY_INTEGRATION_ID, scope),\n integrationStateService.get(AUTOPAY_INTEGRATION_ID, scope),\n ])\n\n return Boolean(credentials) || Boolean(state)\n}\n\nexport async function applyAutopayEnvPreset(params: {\n credentialsService: CredentialsService\n integrationStateService: IntegrationStateService\n integrationLogService?: IntegrationLogService\n scope: IntegrationScope\n force?: boolean\n env?: NodeJS.ProcessEnv\n}): Promise<ApplyAutopayPresetResult> {\n const preset = readAutopayEnvPreset(params.env)\n if (!preset) {\n return { status: 'skipped', reason: 'No Autopay preset env variables were provided.' }\n }\n\n const force = params.force ?? preset.force\n if (!force && await hasExistingAutopayConfiguration(params.credentialsService, params.integrationStateService, params.scope)) {\n return { status: 'skipped', reason: 'Autopay credentials or state already exist. Use force to overwrite them.' }\n }\n\n await params.credentialsService.save(AUTOPAY_INTEGRATION_ID, preset.credentials, params.scope)\n await params.integrationStateService.upsert(\n AUTOPAY_INTEGRATION_ID,\n { isEnabled: preset.enabled },\n params.scope,\n )\n\n if (params.integrationLogService) {\n await params.integrationLogService.scoped(AUTOPAY_INTEGRATION_ID, params.scope).info(\n 'Autopay integration was preconfigured from environment variables.',\n { enabled: preset.enabled },\n )\n }\n\n return { status: 'configured', enabled: preset.enabled }\n}\n"],
4
+ "sourcesContent": ["import { parseBooleanToken } from '@open-mercato/shared/lib/boolean'\nimport type { IntegrationScope } from '@open-mercato/shared/modules/integrations/types'\nimport type { CredentialsService } from '@open-mercato/core/modules/integrations/lib/credentials-service'\nimport type { IntegrationLogService } from '@open-mercato/core/modules/integrations/lib/log-service'\nimport type { IntegrationStateService } from '@open-mercato/core/modules/integrations/lib/state-service'\n\nconst AUTOPAY_INTEGRATION_ID = 'gateway_autopay'\n\ntype AutopayCredentialShape = {\n serviceId: string\n sharedKey: string\n hashAlgorithm?: string\n gatewayUrl: string\n}\n\ntype AutopayEnvPreset = {\n credentials: AutopayCredentialShape\n force: boolean\n enabled: boolean\n}\n\nexport type ApplyAutopayPresetResult =\n | { status: 'skipped'; reason: string }\n | { status: 'configured'; enabled: boolean }\n\nfunction readEnvValue(env: NodeJS.ProcessEnv, keys: string[]): string | undefined {\n for (const key of keys) {\n const value = env[key]?.trim()\n if (value) return value\n }\n return undefined\n}\n\nfunction readBooleanEnv(env: NodeJS.ProcessEnv, keys: string[]): boolean | undefined {\n for (const key of keys) {\n const parsed = parseBooleanToken(env[key])\n if (parsed !== null) return parsed\n }\n return undefined\n}\n\n/**\n * Reads sandbox/production Autopay credentials from env. There is no\n * publicly-usable default here (unlike some providers) \u2014 the worked-example\n * values in the official docs (ServiceID=2, sharedKey=2test2) only serve to\n * reproduce the documented hash examples; a real session needs the\n * credentials issued for the tenant's own Partner Service registration.\n */\nexport function readAutopayEnvPreset(env: NodeJS.ProcessEnv = process.env): AutopayEnvPreset | null {\n const credentialKeys = {\n serviceId: ['OM_INTEGRATION_AUTOPAY_SERVICE_ID'],\n sharedKey: ['OM_INTEGRATION_AUTOPAY_SHARED_KEY'],\n gatewayUrl: ['OM_INTEGRATION_AUTOPAY_GATEWAY_URL'],\n } as const\n\n const anyCredentialProvided = Object.values(credentialKeys).some((keys) => Boolean(readEnvValue(env, [...keys])))\n if (!anyCredentialProvided) {\n return null\n }\n\n const serviceId = readEnvValue(env, [...credentialKeys.serviceId])\n const sharedKey = readEnvValue(env, [...credentialKeys.sharedKey])\n const gatewayUrl = readEnvValue(env, [...credentialKeys.gatewayUrl])\n\n if (!serviceId || !sharedKey || !gatewayUrl) {\n throw new Error(\n '[gateway_autopay] Incomplete Autopay env preset. Set OM_INTEGRATION_AUTOPAY_SERVICE_ID, OM_INTEGRATION_AUTOPAY_SHARED_KEY, and OM_INTEGRATION_AUTOPAY_GATEWAY_URL.',\n )\n }\n\n const hashAlgorithm = readEnvValue(env, ['OM_INTEGRATION_AUTOPAY_HASH_ALGORITHM'])\n\n return {\n credentials: { serviceId, sharedKey, gatewayUrl, hashAlgorithm },\n force: readBooleanEnv(env, ['OM_INTEGRATION_AUTOPAY_FORCE_PRECONFIGURE']) ?? false,\n enabled: readBooleanEnv(env, ['OM_INTEGRATION_AUTOPAY_ENABLED']) ?? true,\n }\n}\n\nasync function hasExistingAutopayConfiguration(\n credentialsService: CredentialsService,\n integrationStateService: IntegrationStateService,\n scope: IntegrationScope,\n): Promise<boolean> {\n const [credentials, state] = await Promise.all([\n credentialsService.getRaw(AUTOPAY_INTEGRATION_ID, scope),\n integrationStateService.get(AUTOPAY_INTEGRATION_ID, scope),\n ])\n\n return Boolean(credentials) || Boolean(state)\n}\n\nexport async function applyAutopayEnvPreset(params: {\n credentialsService: CredentialsService\n integrationStateService: IntegrationStateService\n integrationLogService?: IntegrationLogService\n scope: IntegrationScope\n force?: boolean\n env?: NodeJS.ProcessEnv\n}): Promise<ApplyAutopayPresetResult> {\n const preset = readAutopayEnvPreset(params.env)\n if (!preset) {\n return { status: 'skipped', reason: 'No Autopay preset env variables were provided.' }\n }\n\n const force = params.force ?? preset.force\n if (!force && await hasExistingAutopayConfiguration(params.credentialsService, params.integrationStateService, params.scope)) {\n return { status: 'skipped', reason: 'Autopay credentials or state already exist. Use force to overwrite them.' }\n }\n\n await params.credentialsService.save(AUTOPAY_INTEGRATION_ID, preset.credentials, params.scope)\n await params.integrationStateService.upsert(\n AUTOPAY_INTEGRATION_ID,\n { isEnabled: preset.enabled },\n params.scope,\n )\n\n if (params.integrationLogService) {\n await params.integrationLogService.scoped(AUTOPAY_INTEGRATION_ID, params.scope).info(\n 'Autopay integration was preconfigured from environment variables.',\n { enabled: preset.enabled },\n )\n }\n\n return { status: 'configured', enabled: preset.enabled }\n}\n"],
5
5
  "mappings": "AAAA,SAAS,yBAAyB;AAMlC,MAAM,yBAAyB;AAmB/B,SAAS,aAAa,KAAwB,MAAoC;AAChF,aAAW,OAAO,MAAM;AACtB,UAAM,QAAQ,IAAI,GAAG,GAAG,KAAK;AAC7B,QAAI,MAAO,QAAO;AAAA,EACpB;AACA,SAAO;AACT;AAEA,SAAS,eAAe,KAAwB,MAAqC;AACnF,aAAW,OAAO,MAAM;AACtB,UAAM,SAAS,kBAAkB,IAAI,GAAG,CAAC;AACzC,QAAI,WAAW,KAAM,QAAO;AAAA,EAC9B;AACA,SAAO;AACT;AASO,SAAS,qBAAqB,MAAyB,QAAQ,KAA8B;AAClG,QAAM,iBAAiB;AAAA,IACrB,WAAW,CAAC,mCAAmC;AAAA,IAC/C,WAAW,CAAC,mCAAmC;AAAA,IAC/C,YAAY,CAAC,oCAAoC;AAAA,EACnD;AAEA,QAAM,wBAAwB,OAAO,OAAO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A,EACjH;AAEA,QAAM,OAAO,mBAAmB,KAAK,wBAAwB,OAAO,aAAa,OAAO,KAAK;AAC7F,QAAM,OAAO,wBAAwB;AAAA,IACnC;AAAA,IACA,EAAE,WAAW,OAAO,QAAQ;AAAA,IAC5B,OAAO;AAAA,EACT;AAEA,MAAI,OAAO,uBAAuB;AAChC,UAAM,OAAO,sBAAsB,OAAO,wBAAwB,OAAO,KAAK,EAAE;AAAA,MAC9E;AAAA,MACA,EAAE,SAAS,OAAO,QAAQ;AAAA,IAC5B;AAAA,EACF;AAEA,SAAO,EAAE,QAAQ,cAAc,SAAS,OAAO,QAAQ;AACzD;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/gateway-autopay",
3
- "version": "0.10.1-develop.8045.1.3e5aadf0fb",
3
+ "version": "0.10.1-develop.8050.1.45ae874fe7",
4
4
  "license": "MIT",
5
5
  "description": "Autopay Online v1.1 hosted PLN payment gateway provider for Open Mercato",
6
6
  "type": "module",
@@ -63,19 +63,19 @@
63
63
  }
64
64
  },
65
65
  "dependencies": {
66
- "@open-mercato/core": "0.10.1-develop.8045.1.3e5aadf0fb"
66
+ "@open-mercato/core": "0.10.1-develop.8050.1.45ae874fe7"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "@mikro-orm/postgresql": "^7.0.14",
70
- "@open-mercato/ai-assistant": "0.10.1-develop.8045.1.3e5aadf0fb",
71
- "@open-mercato/shared": "0.10.1-develop.8045.1.3e5aadf0fb",
72
- "@open-mercato/ui": "0.10.1-develop.8045.1.3e5aadf0fb",
70
+ "@open-mercato/ai-assistant": "0.10.1-develop.8050.1.45ae874fe7",
71
+ "@open-mercato/shared": "0.10.1-develop.8050.1.45ae874fe7",
72
+ "@open-mercato/ui": "0.10.1-develop.8050.1.45ae874fe7",
73
73
  "react": "^19.0.0",
74
74
  "react-dom": "^19.0.0"
75
75
  },
76
76
  "devDependencies": {
77
- "@open-mercato/ai-assistant": "0.10.1-develop.8045.1.3e5aadf0fb",
78
- "@open-mercato/shared": "0.10.1-develop.8045.1.3e5aadf0fb",
77
+ "@open-mercato/ai-assistant": "0.10.1-develop.8050.1.45ae874fe7",
78
+ "@open-mercato/shared": "0.10.1-develop.8050.1.45ae874fe7",
79
79
  "@types/jest": "^30.0.0",
80
80
  "esbuild": "^0.28.1",
81
81
  "glob": "^14.0.3",
@@ -41,10 +41,10 @@ function readBooleanEnv(env: NodeJS.ProcessEnv, keys: string[]): boolean | undef
41
41
 
42
42
  /**
43
43
  * Reads sandbox/production Autopay credentials from env. There is no
44
- * publicly-usable default here (unlike some providers) — the sandbox
45
- * worked-example values (ServiceID=2, sharedKey=2test2) authenticate the
46
- * hash math only, never an actual redirect, per the `paytalk/autopay-sandbox`
47
- * reference project's own findings.
44
+ * publicly-usable default here (unlike some providers) — the worked-example
45
+ * values in the official docs (ServiceID=2, sharedKey=2test2) only serve to
46
+ * reproduce the documented hash examples; a real session needs the
47
+ * credentials issued for the tenant's own Partner Service registration.
48
48
  */
49
49
  export function readAutopayEnvPreset(env: NodeJS.ProcessEnv = process.env): AutopayEnvPreset | null {
50
50
  const credentialKeys = {