{"id":23826036,"url":"https://github.com/wultra/powerauth-js-test-client","last_synced_at":"2026-02-13T12:50:24.965Z","repository":{"id":58858275,"uuid":"528790651","full_name":"wultra/powerauth-js-test-client","owner":"wultra","description":"Client library for PowerAuth Server RESTful API to support JavaScript integration tests with PowerAuth Server","archived":false,"fork":false,"pushed_at":"2025-03-11T17:32:15.000Z","size":539,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-10-11T00:58:09.784Z","etag":null,"topics":["integration-testing","javascript","mobile","powerauth","react-native","typescript"],"latest_commit_sha":null,"homepage":"https://developers.wultra.com/products/mobile-security-suite","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wultra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-25T09:57:10.000Z","updated_at":"2025-03-11T13:19:29.000Z","dependencies_parsed_at":"2024-10-03T12:38:12.882Z","dependency_job_id":"0bf07ba9-c39f-4dc0-a146-a462d9cc383f","html_url":"https://github.com/wultra/powerauth-js-test-client","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/wultra/powerauth-js-test-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wultra%2Fpowerauth-js-test-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wultra%2Fpowerauth-js-test-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wultra%2Fpowerauth-js-test-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wultra%2Fpowerauth-js-test-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wultra","download_url":"https://codeload.github.com/wultra/powerauth-js-test-client/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wultra%2Fpowerauth-js-test-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29406544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["integration-testing","javascript","mobile","powerauth","react-native","typescript"],"created_at":"2025-01-02T12:14:21.241Z","updated_at":"2026-02-13T12:50:24.931Z","avatar_url":"https://github.com/wultra.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PowerAuth Test Client for JavaScript\n\n[![npm](https://img.shields.io/npm/v/powerauth-js-test-client)](https://www.npmjs.com/package/powerauth-js-test-client) ![license](https://img.shields.io/github/license/wultra/powerauth-js-test-client) ![released](https://img.shields.io/github/release-date/wultra/powerauth-js-test-client)\n\nThis library provides client written in TypeScript that allows you to conenct directly to the [PowerAuth Server's RESTful API](https://github.com/wultra/powerauth-server/blob/develop/docs/WebServices-Methods.md). This is useful for various integration testing purposes for projects that needs to test the functionality against real [PowerAuth Server](https://github.com/wultra/powerauth-server).\n\n\u003c!-- begin box warning --\u003e\nThis library shold not be used in production application. You usually don't have direct access to PowerAuth Server in production.\n\u003c!-- end --\u003e\n\n## Installation\n\nInstall the package via `npm` as a development dependency:\n\n```\nnpm i powerauth-js-test-client -D\n``` \n\n## Configuration\n\nThe basic configuration is easy:\n\n```typescript\nimport { Config, PowerAuthTestServer } from 'powerauth-js-test-client'\n\nasync function prepareTestServer(): Promise\u003cPowerAuthTestServer\u003e {\n    const server = new PowerAuthTestServer({ connection: { baseUrl: \"http://localhost:8080/powerauth-java-server\"}})\n    await server.connect()\n    return server\n}\n```\n\nFor more details, check documentation for `Config` interface. You can also check `tests/config/config.ts` file to see how this library is preparing configuration for its own tests.\n\n## Usage\n\n### `ActivationHelper` class\n\nThe `ActivationHelper` class simplifies regular tasks with activation creation. To create a propper instance of this object you need to have implementation that provides PowerAuth mobile SDK functionality. In this example, we'll use our [react-native wrapper](https://github.com/wultra/react-native-powerauth-mobile-sdk) as such provider:\n\n```typescript\nimport { ActivationHelper, PowerAuthTestServer } from 'powerauth-js-test-client'\nimport { PowerAuth, PowerAuthActivation, PowerAuthAuthentication, PowerAuthCreateActivationResult } from 'react-native-powerauth-mobile-sdk'\n\ntype RNActivationHelper = ActivationHelper\u003cPowerAuth, PowerAuthCreateActivationResult\u003e\n\nconst PA_SERVER_URL = \"http://localhost:8080/powerauth-java-server\"\nconst PA_ENROLLMENT = \"http://localhost:8080/enrollment-server\"\nconst PA_INSTANCE = 'your-app-instance-id'\n\nexport interface CustomActivationHelperPrepareData extends ActivationHelperPrepareData {\n    instanceId?: string\n}\n\n/**\n * Function create instnace of activation helper typed with RN wrapper objects.\n */\nasync function getActivationHelper(): Promise\u003cRNActivationHelper\u003e {\n    const cfg = { connection: { baseUrl: PA_SERVER_URL}}\n    const helper: RNActivationHelper = await ActivationHelper.createWithConfig(cfg)\n    helper.createSdk = async (appSetup, prepareData) =\u003e {\n        // Prepare instanceId. We're using custom data in prepare interface to keep instance id.\n        const instanceId = (prepareData as CustomActivationHelperPrepareData).instanceId ?? PA_INSTANCE\n        const sdk = new PowerAuth(instanceId)\n        if (await sdk.isConfigured()) {\n            await sdk.deconfigure() // depending on whether you expect config changes\n        }\n        const unsecure = PA_ENROLLMENT.startsWith('http://')\n        await sdk.configure(appSetup.appKey, appSetup.appSecret, appSetup.masterServerPublicKey, PA_ENROLLMENT, unsecure)\n        return sdk\n    }\n    helper.prepareStep = async (helper, activation, prepareData) =\u003e {\n        if (!prepareData) throw new Error('Missing prepare data object')\n        if (!prepareData.password) throw new Error('Missing password in prepare data object')\n        const sdk = await helper.getPowerAuthSdk()\n        const deviceName = 'Test device'\n        const activationData = PowerAuthActivation.createWithActivationCode(activation.activationCode!, deviceName)\n        // Create activation\n        const result = await sdk.createActivation(activationData)\n        // Commit activation locally\n        const auth = new PowerAuthAuthentication()\n        auth.usePossession = true\n        auth.userPassword = prepareData.password\n        auth.useBiometry = prepareData.useBiometry ?? false\n        if (auth.useBiometry) {\n            auth.biometryMessage = \"Enable biometry\"\n        }\n        await sdk.commitActivation(auth)\n        return result\n    }\n    return helper\n}\n\n/**\n * Function prepare activation to active state.\n */\nasync function prepareActivationWithHelper(prepareData: CustomActivationHelperPrepareData): Promise\u003cRNActivationHelper\u003e {\n    const config = { connection: { baseUrl: PA_SERVER_URL }}\n    const helper = await createActivationHelper(config, prepareData)\n    await helper.createActivation(helper.userId, prepareData)\n    return helper\n}\n```\n\nOnce the activation helper is created, then you can use it in tests. For example:\n\n```typescript\ndescribe('Manage PowerAuth applications', () =\u003e {\n\n    let activationHelper: RNActivationHelper\n\n    beforeEach(async () =\u003e {\n        activationHelper = await prepareActivationWithHelper({ password: \"1234\" })\n    })\n\n    afterEach(async () =\u003e {\n        await activationHelper.cleanup()\n    })\n\n    test('Test activation block and unblock', async () =\u003e {\n        await activationHelper.blockActivation('TEST-REASON')\n        const status = await activationHelper.getActivationStatus()\n        expect(status).toBe(ActivationStatus.BLOCKED)\n    })\n})\n```\n\n### `PowerAuthTestServer` class\n\nThe `PowerAuthTestServer` class provides subset of PowerAuth Server RESTful API that allows you to manupulate activations. You can construct this object on your own, or simply use `activationHelper.server` property to access helper's own instance. You can check documentation for this class for more details.\n\n## License\n\nAll sources are licensed using Apache 2.0 license, you can use them with no restriction. If you are using PowerAuth 2.0, please let us know. We will be happy to share and promote your project.\n\n## Contact\n\nIf you need any assistance, do not hesitate to drop us a line at [hello@wultra.com](mailto:hello@wultra.com).\n\n### Security Disclosure\n\nIf you believe you have identified a security vulnerability with PowerAuth, you should report it as soon as possible via email to [support@wultra.com](mailto:support@wultra.com). Please do not post it to a public issue tracker.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwultra%2Fpowerauth-js-test-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwultra%2Fpowerauth-js-test-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwultra%2Fpowerauth-js-test-client/lists"}