@authenta/core 1.0.0 → 1.0.1
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.
- package/README.md +1 -42
- package/dist/client.d.ts +1 -1
- package/dist/client.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,6 @@ Use this package directly if you want headless control over uploads, polling, an
|
|
|
18
18
|
- [Models](#models)
|
|
19
19
|
- [Error Handling](#error-handling)
|
|
20
20
|
- [TypeScript Types](#typescript-types)
|
|
21
|
-
- [Contributing](#contributing)
|
|
22
21
|
|
|
23
22
|
---
|
|
24
23
|
|
|
@@ -183,7 +182,7 @@ const media = await client.upload('file:///path/to/selfie.jpg', 'FI-1', {
|
|
|
183
182
|
console.log(media.mid); // "abc-123"
|
|
184
183
|
|
|
185
184
|
// 2. Poll until processing completes
|
|
186
|
-
const processed = await client.
|
|
185
|
+
const processed = await client.pollResult(media.mid, {
|
|
187
186
|
interval: 3000, // poll every 3 s
|
|
188
187
|
timeout: 120000, // give up after 2 min
|
|
189
188
|
});
|
|
@@ -277,46 +276,6 @@ import type {
|
|
|
277
276
|
ProcessedMedia,
|
|
278
277
|
} from '@authenta/core';
|
|
279
278
|
```
|
|
280
|
-
|
|
281
|
-
---
|
|
282
|
-
|
|
283
|
-
## Contributing
|
|
284
|
-
|
|
285
|
-
### Setup
|
|
286
|
-
|
|
287
|
-
```bash
|
|
288
|
-
git clone https://github.com/phospheneai/authenta-reactnative-sdk.git
|
|
289
|
-
cd authenta-reactnative-sdk
|
|
290
|
-
npm install
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
### Build
|
|
294
|
-
|
|
295
|
-
```bash
|
|
296
|
-
npm run build --workspace=packages/core
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
### Test
|
|
300
|
-
|
|
301
|
-
```bash
|
|
302
|
-
npm test --workspace=packages/core
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
### Guidelines
|
|
306
|
-
|
|
307
|
-
- **No native modules** — this package must work in plain Node.js. Do not import React, React Native, or any native module.
|
|
308
|
-
- **No Node.js built-ins at the top level** — Metro (React Native bundler) cannot resolve `fs`, `path`, etc. Use the `_require = require` alias trick only inside runtime guards (`typeof XMLHttpRequest === 'undefined'`).
|
|
309
|
-
- **Typed errors** — all thrown values must extend `AuthentaError`. New error types go in `errors.ts` and must be exported from `index.ts`.
|
|
310
|
-
- **Types in one place** — all interfaces belong in `src/types/index.ts`.
|
|
311
|
-
- **No breaking changes** — `AuthentaClient` and all exported types are the stable public surface.
|
|
312
|
-
|
|
313
|
-
### Publish
|
|
314
|
-
|
|
315
|
-
```bash
|
|
316
|
-
# Bump version in packages/core/package.json, then:
|
|
317
|
-
npm publish --workspace=packages/core --access public
|
|
318
|
-
```
|
|
319
|
-
|
|
320
279
|
---
|
|
321
280
|
|
|
322
281
|
## License
|
package/dist/client.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export declare class AuthentaClient {
|
|
|
33
33
|
* Pass `fiOptions` only when modelType is "FI-1".
|
|
34
34
|
*/
|
|
35
35
|
upload(uri: string, modelType: ModelType, fiOptions?: FIOptions): Promise<CreateMediaResponse>;
|
|
36
|
-
|
|
36
|
+
pollResult(mid: string, { interval, timeout }?: PollingOptions): Promise<MediaRecord>;
|
|
37
37
|
getResult(media: MediaRecord): Promise<DetectionResult>;
|
|
38
38
|
/**
|
|
39
39
|
* Upload a file URI and process it with the given model.
|
package/dist/client.js
CHANGED
|
@@ -158,7 +158,7 @@ class AuthentaClient {
|
|
|
158
158
|
return media;
|
|
159
159
|
}
|
|
160
160
|
// ─── Polling ───────────────────────────────────────────────────────────────
|
|
161
|
-
async
|
|
161
|
+
async pollResult(mid, { interval = 5000, timeout = 600000 } = {}) {
|
|
162
162
|
const deadline = Date.now() + timeout;
|
|
163
163
|
while (true) {
|
|
164
164
|
const media = await this.getMedia(mid);
|
|
@@ -226,7 +226,7 @@ class AuthentaClient {
|
|
|
226
226
|
const meta = await this.upload(uri, modelType, fiOptions);
|
|
227
227
|
if (!autoPolling)
|
|
228
228
|
return meta;
|
|
229
|
-
const media = await this.
|
|
229
|
+
const media = await this.pollResult(meta.mid, { interval, timeout });
|
|
230
230
|
const result = media.resultURL ? await this.getResult(media) : undefined;
|
|
231
231
|
return Object.assign(Object.assign({}, media), { result });
|
|
232
232
|
}
|