@qr-device-flow/react-native 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Thauan Almeida
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,35 @@
1
- # Temporary Holding Version
1
+ # @qr-device-flow/react-native
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Mobile side of the [QR device flow](../../README.md): a client for the consent screen (`fetchChallengeDetails`, `approve`, `deny`), a React hook, and a camera scanner component.
4
+
5
+ ```tsx
6
+ import { DeviceFlowMobileClient, QRScanner } from "@qr-device-flow/react-native";
7
+
8
+ const client = new DeviceFlowMobileClient({
9
+ endpoint: "https://api.example.com/device",
10
+ getAuthToken: () => session.accessToken, // the logged-in user's token
11
+ });
12
+
13
+ <QRScanner
14
+ onScan={async (userCode) => {
15
+ const details = await client.fetchChallengeDetails(userCode);
16
+ // Show details.requesterInfo (browser, IP, location) on a consent screen.
17
+ // Ask the user to type the two-digit number shown on the login screen.
18
+ const number = await askUserForNumber();
19
+ await client.approve(userCode, number); // or client.deny(userCode)
20
+ }}
21
+ />;
22
+ ```
23
+
24
+ ## Entry points
25
+
26
+ | Import | Contents |
27
+ |---|---|
28
+ | `@qr-device-flow/react-native` | Client, hook and `QRScanner` (needs `react-native` and `expo-camera`) |
29
+ | `@qr-device-flow/react-native/client` | Client and types only, with no native dependencies. Works in any JS runtime |
30
+
31
+ ## Notes
32
+
33
+ - There is no auto-approve. The consent screen is part of the flow.
34
+ - `approve` needs the verification number shown on the browser. A wrong number is rejected, and three wrong numbers deny the login.
35
+ - `scan`, `approve` and `deny` send the auth token as `Authorization: Bearer`. The server decides who the user is.
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import type { QRScannerProps } from "./types.js";
3
+ /**
4
+ * QR code scanner component for the device flow.
5
+ *
6
+ * Wraps `expo-camera`'s CameraView with barcode scanning configured for QR codes.
7
+ * Debounces scan events to prevent firing multiple times for the same QR code.
8
+ *
9
+ * Requires `expo-camera` as a peer dependency.
10
+ *
11
+ * Usage:
12
+ * ```tsx
13
+ * <QRScanner
14
+ * onScan={(userCode) => handleScan(userCode)}
15
+ * active={isScanning}
16
+ * />
17
+ * ```
18
+ */
19
+ export declare function QRScanner({ onScan, style, active, }: QRScannerProps): React.ReactElement | null;
20
+ //# sourceMappingURL=QRScanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QRScanner.d.ts","sourceRoot":"","sources":["../src/QRScanner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAKjD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,EACxB,MAAM,EACN,KAAK,EACL,MAAa,GACd,EAAE,cAAc,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CAiC5C"}
@@ -0,0 +1,128 @@
1
+ // src/validators.ts
2
+ /**
3
+ * Type guard for RequesterInfo.
4
+ *
5
+ * Validates optional fields that provide context about the requesting browser:
6
+ * - `userAgent`: browser user agent string
7
+ * - `ip`: requesting IP address
8
+ * - `approxLocation`: approximate geographic location
9
+ *
10
+ * All fields are advisory and must NOT be used for security decisions.
11
+ */
12
+ function isRequesterInfo(data) {
13
+ if (typeof data !== "object" || data === null) return false;
14
+ const obj = data;
15
+ if ("userAgent" in obj && typeof obj.userAgent !== "string") return false;
16
+ if ("ip" in obj && typeof obj.ip !== "string") return false;
17
+ if ("approxLocation" in obj && typeof obj.approxLocation !== "string") return false;
18
+ if ("origin" in obj && typeof obj.origin !== "string") return false;
19
+ return true;
20
+ }
21
+ /**
22
+ * Type guard for the response from `/scan` endpoint (fetchChallengeDetails).
23
+ *
24
+ * Validates:
25
+ * - `requester_info`: RequesterInfo object
26
+ * - `expires_at`: TTL timestamp in milliseconds
27
+ */
28
+ function isChallengeDetailsResponse(data) {
29
+ return typeof data === "object" && data !== null && "requester_info" in data && isRequesterInfo(data.requester_info) && "expires_at" in data && typeof data.expires_at === "number" && data.expires_at > 0;
30
+ }
31
+ // src/client.ts
32
+ /**
33
+ * Error thrown when the device flow server returns a non-OK response.
34
+ */
35
+ var DeviceFlowClientError = class extends Error {
36
+ statusCode;
37
+ constructor(statusCode, message) {
38
+ super(message);
39
+ this.name = "DeviceFlowClientError";
40
+ this.statusCode = statusCode;
41
+ }
42
+ };
43
+ /**
44
+ * Mobile client for the QR-based device authentication flow (RFC 8628).
45
+ *
46
+ * This client communicates with the device flow server to:
47
+ * 1. Report a scanned QR code and fetch challenge details for the consent screen
48
+ * 2. Approve or deny the login request after user review
49
+ *
50
+ * SECURITY: This client intentionally provides NO auto-approve capability.
51
+ * Every approval must pass through a consent screen showing requester info.
52
+ */
53
+ var DeviceFlowMobileClient = class {
54
+ #endpoint;
55
+ #getAuthToken;
56
+ constructor(config) {
57
+ this.#endpoint = config.endpoint.replace(/\/+$/, "");
58
+ this.#getAuthToken = config.getAuthToken;
59
+ }
60
+ /**
61
+ * Notifies the server that a QR code was scanned, transitioning the
62
+ * challenge to "scanned" status. Returns details for the consent screen.
63
+ *
64
+ * The caller MUST display `requesterInfo` to the user before calling
65
+ * `approve()` or `deny()`.
66
+ */
67
+ async fetchChallengeDetails(userCode) {
68
+ const body = await (await this.#post("/scan", { user_code: userCode })).json();
69
+ if (!isChallengeDetailsResponse(body)) throw new DeviceFlowClientError(0, "Invalid challenge details response: missing or invalid requester_info or expires_at");
70
+ return {
71
+ userCode,
72
+ requesterInfo: body.requester_info,
73
+ expiresAt: body.expires_at,
74
+ verification: body.verification === "none" ? "none" : "number"
75
+ };
76
+ }
77
+ /**
78
+ * Approves the challenge after the user has reviewed the consent screen.
79
+ * `verificationNumber` is the two-digit number shown on the browser; the user
80
+ * must type it on the phone when `fetchChallengeDetails` reports verification
81
+ * "number". Omit it when verification is "none". The server identifies the approving user via the
82
+ * Bearer token. A wrong number is rejected, and three wrong numbers deny the
83
+ * challenge.
84
+ */
85
+ async approve(userCode, verificationNumber) {
86
+ const body = { user_code: userCode };
87
+ if (verificationNumber !== void 0) body.verification_number = verificationNumber;
88
+ await this.#post("/approve", body);
89
+ }
90
+ /**
91
+ * Denies the challenge. The requesting browser will be notified that
92
+ * the login was rejected.
93
+ */
94
+ async deny(userCode) {
95
+ await this.#post("/deny", { user_code: userCode });
96
+ }
97
+ /**
98
+ * Internal helper: POST to a server endpoint with auth and JSON body.
99
+ */
100
+ async #post(path, body) {
101
+ const token = await this.#getAuthToken();
102
+ let response;
103
+ try {
104
+ response = await fetch(`${this.#endpoint}${path}`, {
105
+ method: "POST",
106
+ headers: {
107
+ "Content-Type": "application/json",
108
+ Authorization: `Bearer ${token}`
109
+ },
110
+ body: JSON.stringify(body)
111
+ });
112
+ } catch (error) {
113
+ throw new DeviceFlowClientError(0, `Network error calling ${path}: ${error instanceof Error ? error.message : String(error)}`);
114
+ }
115
+ if (!response.ok) {
116
+ let detail;
117
+ try {
118
+ const errorBody = await response.json();
119
+ detail = typeof errorBody === "object" && errorBody !== null && "error" in errorBody && typeof errorBody.error === "string" ? errorBody.error : response.statusText;
120
+ } catch {
121
+ detail = response.statusText;
122
+ }
123
+ throw new DeviceFlowClientError(response.status, `Server error ${response.status} on ${path}: ${detail}`);
124
+ }
125
+ return response;
126
+ }
127
+ };
128
+ export { isRequesterInfo as i, DeviceFlowMobileClient as n, isChallengeDetailsResponse as r, DeviceFlowClientError as t };
@@ -0,0 +1,46 @@
1
+ import type { ChallengeDetails, DeviceFlowMobileConfig } from "./types.js";
2
+ export type { ChallengeDetails, DeviceFlowMobileConfig } from "./types.js";
3
+ /**
4
+ * Error thrown when the device flow server returns a non-OK response.
5
+ */
6
+ export declare class DeviceFlowClientError extends Error {
7
+ readonly statusCode: number;
8
+ constructor(statusCode: number, message: string);
9
+ }
10
+ /**
11
+ * Mobile client for the QR-based device authentication flow (RFC 8628).
12
+ *
13
+ * This client communicates with the device flow server to:
14
+ * 1. Report a scanned QR code and fetch challenge details for the consent screen
15
+ * 2. Approve or deny the login request after user review
16
+ *
17
+ * SECURITY: This client intentionally provides NO auto-approve capability.
18
+ * Every approval must pass through a consent screen showing requester info.
19
+ */
20
+ export declare class DeviceFlowMobileClient {
21
+ #private;
22
+ constructor(config: DeviceFlowMobileConfig);
23
+ /**
24
+ * Notifies the server that a QR code was scanned, transitioning the
25
+ * challenge to "scanned" status. Returns details for the consent screen.
26
+ *
27
+ * The caller MUST display `requesterInfo` to the user before calling
28
+ * `approve()` or `deny()`.
29
+ */
30
+ fetchChallengeDetails(userCode: string): Promise<ChallengeDetails>;
31
+ /**
32
+ * Approves the challenge after the user has reviewed the consent screen.
33
+ * `verificationNumber` is the two-digit number shown on the browser; the user
34
+ * must type it on the phone when `fetchChallengeDetails` reports verification
35
+ * "number". Omit it when verification is "none". The server identifies the approving user via the
36
+ * Bearer token. A wrong number is rejected, and three wrong numbers deny the
37
+ * challenge.
38
+ */
39
+ approve(userCode: string, verificationNumber?: string): Promise<void>;
40
+ /**
41
+ * Denies the challenge. The requesting browser will be notified that
42
+ * the login was rejected.
43
+ */
44
+ deny(userCode: string): Promise<void>;
45
+ }
46
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAG3E,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAE3E;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAKhD;AAED;;;;;;;;;GASG;AACH,qBAAa,sBAAsB;;gBAIrB,MAAM,EAAE,sBAAsB;IAM1C;;;;;;OAMG;IACG,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAoBxE;;;;;;;OAOG;IACG,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM3E;;;OAGG;IACG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CA6C5C"}
package/dist/client.js ADDED
@@ -0,0 +1 @@
1
+ export { t as DeviceFlowClientError, n as DeviceFlowMobileClient } from "./client-BT1YFMee.js";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @qr-device-flow/react-native
3
+ *
4
+ * React Native client for QR-based device authentication (RFC 8628).
5
+ *
6
+ * Provides:
7
+ * - `DeviceFlowMobileClient` — HTTP client for scan/approve/deny
8
+ * - `useDeviceFlowClient` — React hook returning a memoized client
9
+ * - `QRScanner` — Camera component for scanning QR codes
10
+ * - Types for configuration and challenge details
11
+ */
12
+ export { DeviceFlowMobileClient, DeviceFlowClientError } from "./client.js";
13
+ export { useDeviceFlowClient } from "./use-device-flow.js";
14
+ export { QRScanner } from "./QRScanner.js";
15
+ export { isRequesterInfo, isChallengeDetailsResponse } from "./validators.js";
16
+ export type { DeviceFlowMobileConfig, ChallengeDetails, QRScannerProps, } from "./types.js";
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC9E,YAAY,EACV,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,64 @@
1
+ import { i as isRequesterInfo, n as DeviceFlowMobileClient, r as isChallengeDetailsResponse, t as DeviceFlowClientError } from "./client-BT1YFMee.js";
2
+ import { useCallback, useMemo, useRef } from "react";
3
+ import { CameraView } from "expo-camera";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/use-device-flow.ts
6
+ /**
7
+ * React hook that returns a memoized DeviceFlowMobileClient instance.
8
+ *
9
+ * The client is recreated only when `config.endpoint` changes.
10
+ *
11
+ * Usage:
12
+ * ```tsx
13
+ * const client = useDeviceFlowClient({
14
+ * endpoint: "https://auth.example.com/device",
15
+ * getAuthToken: () => authStore.getToken(),
16
+ * });
17
+ *
18
+ * // On QR scan:
19
+ * const details = await client.fetchChallengeDetails(userCode);
20
+ * // Show consent screen with details.requesterInfo
21
+ * // Then:
22
+ * await client.approve(userCode);
23
+ * ```
24
+ */
25
+ function useDeviceFlowClient(config) {
26
+ return useMemo(() => new DeviceFlowMobileClient(config), [config.endpoint]);
27
+ }
28
+ // src/QRScanner.tsx
29
+ const DEBOUNCE_MS = 2e3;
30
+ /**
31
+ * QR code scanner component for the device flow.
32
+ *
33
+ * Wraps `expo-camera`'s CameraView with barcode scanning configured for QR codes.
34
+ * Debounces scan events to prevent firing multiple times for the same QR code.
35
+ *
36
+ * Requires `expo-camera` as a peer dependency.
37
+ *
38
+ * Usage:
39
+ * ```tsx
40
+ * <QRScanner
41
+ * onScan={(userCode) => handleScan(userCode)}
42
+ * active={isScanning}
43
+ * />
44
+ * ```
45
+ */
46
+ function QRScanner({ onScan, style, active = true }) {
47
+ const lastScannedRef = useRef(null);
48
+ const lastScannedTimeRef = useRef(0);
49
+ const handleBarcodeScanned = useCallback(({ data }) => {
50
+ if (!active) return;
51
+ const now = Date.now();
52
+ if (data === lastScannedRef.current && now - lastScannedTimeRef.current < DEBOUNCE_MS) return;
53
+ lastScannedRef.current = data;
54
+ lastScannedTimeRef.current = now;
55
+ onScan(data);
56
+ }, [active, onScan]);
57
+ if (!active) return null;
58
+ return /* @__PURE__ */ jsx(CameraView, {
59
+ style: style ?? { flex: 1 },
60
+ barcodeScannerSettings: { barcodeTypes: ["qr"] },
61
+ onBarcodeScanned: handleBarcodeScanned
62
+ });
63
+ }
64
+ export { DeviceFlowClientError, DeviceFlowMobileClient, QRScanner, isChallengeDetailsResponse, isRequesterInfo, useDeviceFlowClient };
@@ -0,0 +1,35 @@
1
+ import type { RequesterInfo, VerificationMode } from "@qr-device-flow/core";
2
+ /**
3
+ * Configuration for the mobile device flow client.
4
+ */
5
+ export interface DeviceFlowMobileConfig {
6
+ /** Base URL of the device flow server (e.g., "https://auth.example.com/device") */
7
+ readonly endpoint: string;
8
+ /** Returns the auth token of the logged-in mobile user, sent as Bearer */
9
+ readonly getAuthToken: () => string | Promise<string>;
10
+ }
11
+ /**
12
+ * Details about a scanned challenge, shown on the consent screen.
13
+ *
14
+ * The user MUST review `requesterInfo` before approving — this is a
15
+ * non-negotiable security requirement to prevent phishing attacks.
16
+ */
17
+ export interface ChallengeDetails {
18
+ readonly userCode: string;
19
+ readonly requesterInfo: RequesterInfo;
20
+ readonly expiresAt: number;
21
+ /** "number": ask the user for the number shown on the browser. "none": approve on consent alone. */
22
+ readonly verification: VerificationMode;
23
+ }
24
+ /**
25
+ * Props for the QRScanner component.
26
+ */
27
+ export interface QRScannerProps {
28
+ /** Called when a QR code is successfully scanned */
29
+ readonly onScan: (userCode: string) => void | Promise<void>;
30
+ /** Optional: custom camera style */
31
+ readonly style?: object;
32
+ /** Optional: whether the scanner is active (default: true) */
33
+ readonly active?: boolean;
34
+ }
35
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,0EAA0E;IAC1E,QAAQ,CAAC,YAAY,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACvD;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,oGAAoG;IACpG,QAAQ,CAAC,YAAY,EAAE,gBAAgB,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,oCAAoC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B"}
@@ -0,0 +1,23 @@
1
+ import { DeviceFlowMobileClient } from "./client.js";
2
+ import type { DeviceFlowMobileConfig } from "./types.js";
3
+ /**
4
+ * React hook that returns a memoized DeviceFlowMobileClient instance.
5
+ *
6
+ * The client is recreated only when `config.endpoint` changes.
7
+ *
8
+ * Usage:
9
+ * ```tsx
10
+ * const client = useDeviceFlowClient({
11
+ * endpoint: "https://auth.example.com/device",
12
+ * getAuthToken: () => authStore.getToken(),
13
+ * });
14
+ *
15
+ * // On QR scan:
16
+ * const details = await client.fetchChallengeDetails(userCode);
17
+ * // Show consent screen with details.requesterInfo
18
+ * // Then:
19
+ * await client.approve(userCode);
20
+ * ```
21
+ */
22
+ export declare function useDeviceFlowClient(config: DeviceFlowMobileConfig): DeviceFlowMobileClient;
23
+ //# sourceMappingURL=use-device-flow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-device-flow.d.ts","sourceRoot":"","sources":["../src/use-device-flow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,sBAAsB,GAC7B,sBAAsB,CAGxB"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Runtime JSON validation type guards for React Native mobile client.
3
+ *
4
+ * These functions provide type safety by validating the structure of JSON
5
+ * responses from the server before they are used in the mobile app.
6
+ */
7
+ import type { RequesterInfo } from "@qr-device-flow/core";
8
+ /**
9
+ * Type guard for RequesterInfo.
10
+ *
11
+ * Validates optional fields that provide context about the requesting browser:
12
+ * - `userAgent`: browser user agent string
13
+ * - `ip`: requesting IP address
14
+ * - `approxLocation`: approximate geographic location
15
+ *
16
+ * All fields are advisory and must NOT be used for security decisions.
17
+ */
18
+ export declare function isRequesterInfo(data: unknown): data is RequesterInfo;
19
+ /**
20
+ * Type guard for the response from `/scan` endpoint (fetchChallengeDetails).
21
+ *
22
+ * Validates:
23
+ * - `requester_info`: RequesterInfo object
24
+ * - `expires_at`: TTL timestamp in milliseconds
25
+ */
26
+ export declare function isChallengeDetailsResponse(data: unknown): data is {
27
+ requester_info: RequesterInfo;
28
+ expires_at: number;
29
+ };
30
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,aAAa,CAyBpE;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI;IAAE,cAAc,EAAE,aAAa,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAU/D"}
package/package.json CHANGED
@@ -1,6 +1,66 @@
1
1
  {
2
2
  "name": "@qr-device-flow/react-native",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "React Native client for QR device flow authentication",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./client": {
14
+ "types": "./dist/client.d.ts",
15
+ "import": "./dist/client.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "dependencies": {
24
+ "@qr-device-flow/core": "^0.1.0"
25
+ },
26
+ "peerDependencies": {
27
+ "expo-camera": ">=15.0.0",
28
+ "react": ">=18.0.0",
29
+ "react-native": ">=0.72.0"
30
+ },
31
+ "peerDependenciesMeta": {},
32
+ "devDependencies": {
33
+ "@types/react": "^19.0.0",
34
+ "react": "^19.0.0",
35
+ "tsdown": "^0.12.0",
36
+ "typescript": "^5.4.0",
37
+ "vitest": "^3.2.0",
38
+ "@types/node": "^20.0.0"
39
+ },
40
+ "keywords": [
41
+ "qr",
42
+ "auth",
43
+ "rfc8628",
44
+ "device-flow",
45
+ "react-native",
46
+ "mobile"
47
+ ],
48
+ "license": "MIT",
49
+ "author": "Thauan Almeida",
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/Thauan/qr-device-flow.git",
53
+ "directory": "packages/react-native"
54
+ },
55
+ "homepage": "https://github.com/Thauan/qr-device-flow/tree/main/packages/react-native#readme",
56
+ "bugs": {
57
+ "url": "https://github.com/Thauan/qr-device-flow/issues"
58
+ },
59
+ "scripts": {
60
+ "build": "tsdown && tsc -p tsconfig.build.json",
61
+ "typecheck": "tsc --noEmit",
62
+ "test": "vitest run",
63
+ "test:watch": "vitest",
64
+ "clean": "rm -rf dist"
65
+ }
6
66
  }