{"id":35730772,"url":"https://github.com/ably/ably-encrypted-channels-react-native-polyfills","last_synced_at":"2026-01-20T17:01:45.254Z","repository":{"id":324718653,"uuid":"1096460394","full_name":"ably/ably-encrypted-channels-react-native-polyfills","owner":"ably","description":"A lightweight set of polyfills that enable Ably encrypted channels to work seamlessly in React Native environments","archived":false,"fork":false,"pushed_at":"2025-11-17T12:57:45.000Z","size":64,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-17T14:37:48.974Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ably.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-14T13:10:21.000Z","updated_at":"2025-11-17T12:57:50.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ably/ably-encrypted-channels-react-native-polyfills","commit_stats":null,"previous_names":["ably/ably-encrypted-channels-react-native-polyfills"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/ably/ably-encrypted-channels-react-native-polyfills","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ably%2Fably-encrypted-channels-react-native-polyfills","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ably%2Fably-encrypted-channels-react-native-polyfills/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ably%2Fably-encrypted-channels-react-native-polyfills/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ably%2Fably-encrypted-channels-react-native-polyfills/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ably","download_url":"https://codeload.github.com/ably/ably-encrypted-channels-react-native-polyfills/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ably%2Fably-encrypted-channels-react-native-polyfills/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28607624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T16:10:39.856Z","status":"ssl_error","status_checked_at":"2026-01-20T16:10:39.493Z","response_time":117,"last_error":"SSL_read: 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":[],"created_at":"2026-01-06T11:00:57.427Z","updated_at":"2026-01-20T17:01:45.248Z","avatar_url":"https://github.com/ably.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ably Encrypted Channels React Native Polyfills\n\nA lightweight set of polyfills that enable Ably encrypted channels to work seamlessly in React Native environments.\n\n## Prerequisites\n\n### Option 1: Using the default AES implementation\n\nIf you want to use the default AES encryption/decryption implementation, install:\n\n- `@ably/react-native-aes` - For AES encryption/decryption\n\n```bash\nnpm install @ably/react-native-aes\n```\n\nor\n\n```bash\nyarn add @ably/react-native-aes\n```\n\nFor React Native 0.60+, this dependency should auto-link. For older versions, you may need to link it manually.\n\n### Option 2: Using a custom implementation\n\nAlternatively, you can provide your own encryption/decryption functions. In this case, no additional dependencies are required. See the [Custom Encryption/Decryption](#custom-encryptiondecryption) section below for details.\n\n## Installation\n\nAfter installing the prerequisites, install this package:\n\n```bash\nnpm install @ably/encrypted-channels-react-native-polyfills\n```\n\nor\n\n```bash\nyarn add @ably/encrypted-channels-react-native-polyfills\n```\n\n## Usage\n\nImport and initialize the polyfills at the entry point of your React Native application:\n\n```typescript\nimport { install } from '@ably/encrypted-channels-react-native-polyfills';\n\n// Initialize polyfills before using Ably\ninstall();\n```\n\nThis will polyfill the following Web Crypto API methods:\n\n- `crypto.subtle.importKey()` - Import raw AES keys\n- `crypto.subtle.encrypt()` - Encrypt data using AES-CBC\n- `crypto.subtle.decrypt()` - Decrypt data using AES-CBC\n\n### Example with Ably\n\n```typescript\nimport { install } from '@ably/encrypted-channels-react-native-polyfills';\n\n// Install polyfills first\ninstall();\n\nfunction App() {\n    const [encrypted, setEncrypted] = useState\u003cstring\u003e(\"\");\n    const [key, setKey] = useState\u003cAbly.CipherKey | null\u003e(null);\n\n    useEffect(() =\u003e {\n        if (key) return;\n        Ably.Realtime.Crypto.generateRandomKey().then(generatedKey =\u003e setKey(generatedKey))\n    }, [key]);\n\n    useEffect(() =\u003e {\n        if (!key) return;\n        const channel = client.channels.get('encrypted-channel', {\n            cipher: { key }\n        });\n        channel.subscribe(message =\u003e {\n            setEncrypted(message.data.toString())\n        });\n        channel.publish('test', \"Hello World\");\n    }, [key]);\n}\n```\n\n### Custom Encryption/Decryption\n\nIf you don't want to use `@ably/react-native-aes`, you can provide your own encryption and decryption implementations:\n\n```typescript\nimport { install, type EncryptionFunction, type DecryptionFunction } from '@ably/encrypted-channels-react-native-polyfills';\n\nconst customEncrypt: EncryptionFunction = async (algorithm, key, data) =\u003e {\n    // Your custom encryption implementation\n    // algorithm: { name: string, iv: BufferSource }\n    // key: BufferSource - the raw key data\n    // data: BufferSource - the data to encrypt\n    // Returns: Promise\u003cArrayBuffer\u003e - the encrypted data\n\n    // Example using a hypothetical crypto library\n    const encrypted = await MyCryptoLib.encrypt({\n        key: keyData,\n        iv: algorithm.iv,\n        data: data,\n        algorithm: algorithm.name\n    });\n\n    return encrypted;\n};\n\nconst customDecrypt: DecryptionFunction = async (algorithm, key, data) =\u003e {\n    // Your custom decryption implementation\n    // algorithm: { name: string, iv: BufferSource }\n    // key: BufferSource - the raw key data\n    // data: BufferSource - the encrypted data to decrypt\n    // Returns: Promise\u003cArrayBuffer\u003e - the decrypted data\n\n    // Example using a hypothetical crypto library\n    const decrypted = await MyCryptoLib.decrypt({\n        key: keyData,\n        iv: algorithm.iv,\n        data: data,\n        algorithm: algorithm.name\n    });\n\n    return decrypted;\n};\n\n// Install with custom functions\ninstall({\n    encryptionFunction: customEncrypt,\n    decryptionFunction: customDecrypt\n});\n```\n\n**Note:** Both `encryptionFunction` and `decryptionFunction` must be provided together. If you provide only one, an error will be thrown.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fably%2Fably-encrypted-channels-react-native-polyfills","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fably%2Fably-encrypted-channels-react-native-polyfills","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fably%2Fably-encrypted-channels-react-native-polyfills/lists"}