yaver-feedback-react-native 0.6.0 → 0.6.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/dist/YaverFeedback.js +3 -0
- package/dist/auth.d.ts +7 -0
- package/dist/auth.js +28 -3
- package/dist/types.d.ts +19 -0
- package/package.json +1 -1
- package/src/YaverFeedback.ts +4 -0
- package/src/auth.ts +29 -3
- package/src/types.ts +19 -0
package/dist/YaverFeedback.js
CHANGED
|
@@ -76,6 +76,9 @@ class YaverFeedback {
|
|
|
76
76
|
convexSiteUrl: cfg.authConvexSiteUrl,
|
|
77
77
|
webBaseUrl: cfg.authWebBaseUrl,
|
|
78
78
|
});
|
|
79
|
+
// Compile-time lockdown: refuse any browser-hop / device-code fallback
|
|
80
|
+
// and force ASWebAuthenticationSession in ephemeral mode for OAuth.
|
|
81
|
+
(0, auth_1.setStrictNativeAuth)(cfg.strictNativeAuth === true);
|
|
79
82
|
// If no explicit convexUrl was set but we have an auth site URL, use it
|
|
80
83
|
// so Discovery.discoverFromConvex() has somewhere to look up the user's
|
|
81
84
|
// machines (works for both LAN-direct and off-LAN relay paths).
|
package/dist/auth.d.ts
CHANGED
|
@@ -22,6 +22,13 @@ export declare function configureAuthEndpoints(opts: {
|
|
|
22
22
|
convexSiteUrl?: string;
|
|
23
23
|
webBaseUrl?: string;
|
|
24
24
|
}): void;
|
|
25
|
+
/**
|
|
26
|
+
* Enable strict native auth: refuse any fallback that would redirect the
|
|
27
|
+
* user to an external browser (Safari / Chrome) or show a device code.
|
|
28
|
+
* See FeedbackConfig.strictNativeAuth for rationale.
|
|
29
|
+
*/
|
|
30
|
+
export declare function setStrictNativeAuth(enabled: boolean): void;
|
|
31
|
+
export declare function isStrictNativeAuth(): boolean;
|
|
25
32
|
export declare function getConvexSiteUrl(): string;
|
|
26
33
|
export declare function getWebBaseUrl(): string;
|
|
27
34
|
export type OAuthProvider = 'google' | 'microsoft' | 'apple' | 'github' | 'gitlab';
|
package/dist/auth.js
CHANGED
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.DEFAULT_OAUTH_REDIRECT = exports.DEFAULT_WEB_BASE_URL = exports.DEFAULT_CONVEX_SITE_URL = void 0;
|
|
21
21
|
exports.configureAuthEndpoints = configureAuthEndpoints;
|
|
22
|
+
exports.setStrictNativeAuth = setStrictNativeAuth;
|
|
23
|
+
exports.isStrictNativeAuth = isStrictNativeAuth;
|
|
22
24
|
exports.getConvexSiteUrl = getConvexSiteUrl;
|
|
23
25
|
exports.getWebBaseUrl = getWebBaseUrl;
|
|
24
26
|
exports.getToken = getToken;
|
|
@@ -65,6 +67,7 @@ exports.DEFAULT_CONVEX_SITE_URL = 'https://shocking-echidna-394.eu-west-1.convex
|
|
|
65
67
|
exports.DEFAULT_WEB_BASE_URL = 'https://yaver.io';
|
|
66
68
|
let convexSiteUrl = exports.DEFAULT_CONVEX_SITE_URL;
|
|
67
69
|
let webBaseUrl = exports.DEFAULT_WEB_BASE_URL;
|
|
70
|
+
let strictNativeAuth = false;
|
|
68
71
|
/** Override the Convex site URL + web base (staging vs prod). */
|
|
69
72
|
function configureAuthEndpoints(opts) {
|
|
70
73
|
if (opts.convexSiteUrl)
|
|
@@ -72,6 +75,17 @@ function configureAuthEndpoints(opts) {
|
|
|
72
75
|
if (opts.webBaseUrl)
|
|
73
76
|
webBaseUrl = opts.webBaseUrl;
|
|
74
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Enable strict native auth: refuse any fallback that would redirect the
|
|
80
|
+
* user to an external browser (Safari / Chrome) or show a device code.
|
|
81
|
+
* See FeedbackConfig.strictNativeAuth for rationale.
|
|
82
|
+
*/
|
|
83
|
+
function setStrictNativeAuth(enabled) {
|
|
84
|
+
strictNativeAuth = enabled;
|
|
85
|
+
}
|
|
86
|
+
function isStrictNativeAuth() {
|
|
87
|
+
return strictNativeAuth;
|
|
88
|
+
}
|
|
75
89
|
function getConvexSiteUrl() {
|
|
76
90
|
return convexSiteUrl;
|
|
77
91
|
}
|
|
@@ -259,14 +273,25 @@ exports.DEFAULT_OAUTH_REDIRECT = 'yaver://oauth-callback';
|
|
|
259
273
|
*/
|
|
260
274
|
async function signInWithOAuth(provider, opts) {
|
|
261
275
|
if (!WebBrowser) {
|
|
262
|
-
|
|
276
|
+
// In strictNativeAuth we hard-fail rather than letting the caller
|
|
277
|
+
// fall back to any homegrown `Linking.openURL(…)` flow that would
|
|
278
|
+
// leave the app for Safari. Without strict mode we still can't
|
|
279
|
+
// proceed (no browser module available) so the behavior is the same
|
|
280
|
+
// — just a clearer error message.
|
|
281
|
+
throw new Error('expo-web-browser is not installed. Add it as a peer dep to enable in-app OAuth sign-in.');
|
|
263
282
|
}
|
|
264
283
|
const redirectUrl = opts?.redirectUrl ?? exports.DEFAULT_OAUTH_REDIRECT;
|
|
265
284
|
const params = new URLSearchParams({ client: 'mobile' });
|
|
266
285
|
const authUrl = `${webBaseUrl}/api/auth/oauth/${provider}?${params.toString()}`;
|
|
286
|
+
// In strict mode force ephemeral session (ASWebAuthenticationSession
|
|
287
|
+
// with no shared cookie jar) so the OAuth dance is visibly native and
|
|
288
|
+
// can never hand off to the user's default browser.
|
|
289
|
+
const prefer = strictNativeAuth || opts?.preferEphemeralSession
|
|
290
|
+
? true
|
|
291
|
+
: false;
|
|
267
292
|
const result = await WebBrowser.openAuthSessionAsync(authUrl, redirectUrl, {
|
|
268
|
-
preferEphemeralSession:
|
|
269
|
-
showInRecents:
|
|
293
|
+
preferEphemeralSession: prefer,
|
|
294
|
+
showInRecents: !strictNativeAuth,
|
|
270
295
|
});
|
|
271
296
|
if (result.type !== 'success' || !result.url) {
|
|
272
297
|
throw new Error('cancelled');
|
package/dist/types.d.ts
CHANGED
|
@@ -157,6 +157,25 @@ export interface FeedbackConfig {
|
|
|
157
157
|
* Default: false (HTTPS preferred when fingerprint available, HTTP fallback).
|
|
158
158
|
*/
|
|
159
159
|
requireTLS?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Compile-time lockdown of the auth flow. When true the SDK refuses to
|
|
162
|
+
* ever open the user's external browser (Safari / Chrome) or show a
|
|
163
|
+
* 6-char device code. Auth happens only via native Apple Sign-In
|
|
164
|
+
* (`expo-apple-authentication`), in-app OAuth (`expo-web-browser`'s
|
|
165
|
+
* `ASWebAuthenticationSession` with `preferEphemeralSession: true`), or
|
|
166
|
+
* the built-in email/password form. If a required peer dep is missing,
|
|
167
|
+
* `signInWithOAuth`/`signInWithApple` throw instead of silently falling
|
|
168
|
+
* back to a web redirect.
|
|
169
|
+
*
|
|
170
|
+
* Recommended for apps that already embed OAuth on the native side and
|
|
171
|
+
* never want their users to see a `yaver.io` landing page. This is the
|
|
172
|
+
* belt-and-suspenders version of what the SDK has done since 0.6; set
|
|
173
|
+
* it to guarantee future regressions can't quietly reintroduce a
|
|
174
|
+
* browser-hop fallback.
|
|
175
|
+
*
|
|
176
|
+
* Default: false (preserve historical behavior).
|
|
177
|
+
*/
|
|
178
|
+
strictNativeAuth?: boolean;
|
|
160
179
|
}
|
|
161
180
|
export interface FeedbackBundle {
|
|
162
181
|
metadata: FeedbackMetadata;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yaver-feedback-react-native",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Visual feedback SDK for Yaver — bug reports, screen recording, voice annotations, and local-first developer workflows",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
package/src/YaverFeedback.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { P2PClient } from './P2PClient';
|
|
|
6
6
|
import { ShakeDetector } from './ShakeDetector';
|
|
7
7
|
import {
|
|
8
8
|
configureAuthEndpoints,
|
|
9
|
+
setStrictNativeAuth,
|
|
9
10
|
getToken,
|
|
10
11
|
getSelectedDeviceId,
|
|
11
12
|
clearToken,
|
|
@@ -88,6 +89,9 @@ export class YaverFeedback {
|
|
|
88
89
|
convexSiteUrl: cfg.authConvexSiteUrl,
|
|
89
90
|
webBaseUrl: cfg.authWebBaseUrl,
|
|
90
91
|
});
|
|
92
|
+
// Compile-time lockdown: refuse any browser-hop / device-code fallback
|
|
93
|
+
// and force ASWebAuthenticationSession in ephemeral mode for OAuth.
|
|
94
|
+
setStrictNativeAuth(cfg.strictNativeAuth === true);
|
|
91
95
|
// If no explicit convexUrl was set but we have an auth site URL, use it
|
|
92
96
|
// so Discovery.discoverFromConvex() has somewhere to look up the user's
|
|
93
97
|
// machines (works for both LAN-direct and off-LAN relay paths).
|
package/src/auth.ts
CHANGED
|
@@ -73,6 +73,7 @@ export const DEFAULT_WEB_BASE_URL = 'https://yaver.io';
|
|
|
73
73
|
|
|
74
74
|
let convexSiteUrl = DEFAULT_CONVEX_SITE_URL;
|
|
75
75
|
let webBaseUrl = DEFAULT_WEB_BASE_URL;
|
|
76
|
+
let strictNativeAuth = false;
|
|
76
77
|
|
|
77
78
|
/** Override the Convex site URL + web base (staging vs prod). */
|
|
78
79
|
export function configureAuthEndpoints(opts: {
|
|
@@ -83,6 +84,19 @@ export function configureAuthEndpoints(opts: {
|
|
|
83
84
|
if (opts.webBaseUrl) webBaseUrl = opts.webBaseUrl;
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Enable strict native auth: refuse any fallback that would redirect the
|
|
89
|
+
* user to an external browser (Safari / Chrome) or show a device code.
|
|
90
|
+
* See FeedbackConfig.strictNativeAuth for rationale.
|
|
91
|
+
*/
|
|
92
|
+
export function setStrictNativeAuth(enabled: boolean): void {
|
|
93
|
+
strictNativeAuth = enabled;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function isStrictNativeAuth(): boolean {
|
|
97
|
+
return strictNativeAuth;
|
|
98
|
+
}
|
|
99
|
+
|
|
86
100
|
export function getConvexSiteUrl(): string {
|
|
87
101
|
return convexSiteUrl;
|
|
88
102
|
}
|
|
@@ -291,17 +305,29 @@ export async function signInWithOAuth(
|
|
|
291
305
|
opts?: { redirectUrl?: string; preferEphemeralSession?: boolean },
|
|
292
306
|
): Promise<{ token: string }> {
|
|
293
307
|
if (!WebBrowser) {
|
|
308
|
+
// In strictNativeAuth we hard-fail rather than letting the caller
|
|
309
|
+
// fall back to any homegrown `Linking.openURL(…)` flow that would
|
|
310
|
+
// leave the app for Safari. Without strict mode we still can't
|
|
311
|
+
// proceed (no browser module available) so the behavior is the same
|
|
312
|
+
// — just a clearer error message.
|
|
294
313
|
throw new Error(
|
|
295
|
-
'expo-web-browser is not installed. Add it as a peer dep to enable OAuth sign-in.',
|
|
314
|
+
'expo-web-browser is not installed. Add it as a peer dep to enable in-app OAuth sign-in.',
|
|
296
315
|
);
|
|
297
316
|
}
|
|
298
317
|
const redirectUrl = opts?.redirectUrl ?? DEFAULT_OAUTH_REDIRECT;
|
|
299
318
|
const params = new URLSearchParams({ client: 'mobile' });
|
|
300
319
|
const authUrl = `${webBaseUrl}/api/auth/oauth/${provider}?${params.toString()}`;
|
|
301
320
|
|
|
321
|
+
// In strict mode force ephemeral session (ASWebAuthenticationSession
|
|
322
|
+
// with no shared cookie jar) so the OAuth dance is visibly native and
|
|
323
|
+
// can never hand off to the user's default browser.
|
|
324
|
+
const prefer =
|
|
325
|
+
strictNativeAuth || opts?.preferEphemeralSession
|
|
326
|
+
? true
|
|
327
|
+
: false;
|
|
302
328
|
const result = await WebBrowser.openAuthSessionAsync(authUrl, redirectUrl, {
|
|
303
|
-
preferEphemeralSession:
|
|
304
|
-
showInRecents:
|
|
329
|
+
preferEphemeralSession: prefer,
|
|
330
|
+
showInRecents: !strictNativeAuth,
|
|
305
331
|
});
|
|
306
332
|
|
|
307
333
|
if (result.type !== 'success' || !result.url) {
|
package/src/types.ts
CHANGED
|
@@ -157,6 +157,25 @@ export interface FeedbackConfig {
|
|
|
157
157
|
* Default: false (HTTPS preferred when fingerprint available, HTTP fallback).
|
|
158
158
|
*/
|
|
159
159
|
requireTLS?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Compile-time lockdown of the auth flow. When true the SDK refuses to
|
|
162
|
+
* ever open the user's external browser (Safari / Chrome) or show a
|
|
163
|
+
* 6-char device code. Auth happens only via native Apple Sign-In
|
|
164
|
+
* (`expo-apple-authentication`), in-app OAuth (`expo-web-browser`'s
|
|
165
|
+
* `ASWebAuthenticationSession` with `preferEphemeralSession: true`), or
|
|
166
|
+
* the built-in email/password form. If a required peer dep is missing,
|
|
167
|
+
* `signInWithOAuth`/`signInWithApple` throw instead of silently falling
|
|
168
|
+
* back to a web redirect.
|
|
169
|
+
*
|
|
170
|
+
* Recommended for apps that already embed OAuth on the native side and
|
|
171
|
+
* never want their users to see a `yaver.io` landing page. This is the
|
|
172
|
+
* belt-and-suspenders version of what the SDK has done since 0.6; set
|
|
173
|
+
* it to guarantee future regressions can't quietly reintroduce a
|
|
174
|
+
* browser-hop fallback.
|
|
175
|
+
*
|
|
176
|
+
* Default: false (preserve historical behavior).
|
|
177
|
+
*/
|
|
178
|
+
strictNativeAuth?: boolean;
|
|
160
179
|
}
|
|
161
180
|
|
|
162
181
|
export interface FeedbackBundle {
|