@unisim/sdk 0.141.6 → 0.141.8

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.
Files changed (42) hide show
  1. package/README.md +95 -3
  2. package/android/src/main/AndroidManifest.xml +24 -0
  3. package/android/src/main/java/uk/co/unisim/sdk/OAuthCallbackActivity.java +72 -0
  4. package/android/src/main/java/uk/co/unisim/sdk/UnisimSuiteAuthPlugin.java +129 -0
  5. package/dist/DeleteAccountDialog.d.ts +12 -0
  6. package/dist/DeleteAccountDialog.d.ts.map +1 -0
  7. package/dist/DeleteAccountDialog.js +185 -0
  8. package/dist/DeleteAccountDialog.js.map +1 -0
  9. package/dist/SignInDialog.d.ts.map +1 -1
  10. package/dist/SignInDialog.js +49 -3
  11. package/dist/SignInDialog.js.map +1 -1
  12. package/dist/UniversalAppsNavBar.d.ts +8 -1
  13. package/dist/UniversalAppsNavBar.d.ts.map +1 -1
  14. package/dist/UniversalAppsNavBar.js +2 -2
  15. package/dist/UniversalAppsNavBar.js.map +1 -1
  16. package/dist/UserProfile.d.ts +22 -1
  17. package/dist/UserProfile.d.ts.map +1 -1
  18. package/dist/UserProfile.js +26 -4
  19. package/dist/UserProfile.js.map +1 -1
  20. package/dist/deleteAccount.d.ts +32 -0
  21. package/dist/deleteAccount.d.ts.map +1 -0
  22. package/dist/deleteAccount.js +61 -0
  23. package/dist/deleteAccount.js.map +1 -0
  24. package/dist/deleteAccountCopy.d.ts +22 -0
  25. package/dist/deleteAccountCopy.d.ts.map +1 -0
  26. package/dist/deleteAccountCopy.js +217 -0
  27. package/dist/deleteAccountCopy.js.map +1 -0
  28. package/dist/index.d.ts +8 -0
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +9 -0
  31. package/dist/index.js.map +1 -1
  32. package/dist/nativeOAuth.d.ts +208 -0
  33. package/dist/nativeOAuth.d.ts.map +1 -0
  34. package/dist/nativeOAuth.js +372 -0
  35. package/dist/nativeOAuth.js.map +1 -0
  36. package/dist/oauth.d.ts +6 -0
  37. package/dist/oauth.d.ts.map +1 -1
  38. package/dist/oauth.js +9 -1
  39. package/dist/oauth.js.map +1 -1
  40. package/ios/Sources/UnisimSuiteAuthPlugin/SuiteOAuth.swift +257 -0
  41. package/ios/Sources/UnisimSuiteAuthPlugin/UnisimSuiteAuthPlugin.swift +14 -1
  42. package/package.json +3 -1
@@ -0,0 +1,208 @@
1
+ import type { useUniversal } from './provider.js';
2
+ import { type OAuthProvider, type OAuthReturnError } from './oauth.js';
3
+ type Supabase = ReturnType<typeof useUniversal>['supabase'];
4
+ /** The host of every app's callback: `<bundle id>://auth-callback`. */
5
+ export declare const NATIVE_OAUTH_CALLBACK_HOST = "auth-callback";
6
+ export type NativePlatform = 'ios' | 'android';
7
+ export interface NativeOAuthSupport {
8
+ platform: NativePlatform;
9
+ /** `<bundle id>://auth-callback` — where Supabase sends the browser back to. */
10
+ callbackUrl: string;
11
+ /** True where Apple is the OS sheet rather than a browser page (iOS). */
12
+ appleNative: boolean;
13
+ }
14
+ /**
15
+ * The native half: three methods on the EXISTING `UnisimSuiteAuth` plugin.
16
+ *
17
+ * ⚠️ On that plugin rather than a new one on purpose — Capacitor resolves
18
+ * plugins through a `capacitor.plugins.json` generated per app, so a new
19
+ * plugin class would be missing from every app until each re-synced, and
20
+ * missing looks like nothing at all. See the note in UnisimSuiteAuthPlugin.
21
+ */
22
+ export interface NativeOAuthPlugin {
23
+ oauthSupport(): Promise<{
24
+ platform?: string;
25
+ callbackUrl?: string;
26
+ appleNative?: boolean;
27
+ }>;
28
+ oauthStart(options: {
29
+ url: string;
30
+ }): Promise<{
31
+ url?: string | null;
32
+ cancelled?: boolean;
33
+ }>;
34
+ appleSignIn(): Promise<{
35
+ cancelled?: boolean;
36
+ identityToken?: string | null;
37
+ nonce?: string | null;
38
+ givenName?: string | null;
39
+ familyName?: string | null;
40
+ }>;
41
+ }
42
+ /** Validate what the plugin reported; anything unexpected reads as "unsupported". */
43
+ export declare function normaliseNativeSupport(raw: unknown): NativeOAuthSupport | null;
44
+ /**
45
+ * Whether this build can do native provider sign-in, and how. Null in a
46
+ * browser, and in a native build whose plugin predates it (an app synced
47
+ * against an older SDK) — the dialog then offers no provider tab at all, which
48
+ * is the honest page.
49
+ */
50
+ export declare function nativeOAuthSupport(plugin?: NativeOAuthPlugin | null): Promise<NativeOAuthSupport | null>;
51
+ /**
52
+ * The providers a native shell should offer, given what the project has
53
+ * switched on.
54
+ *
55
+ * ⚠️ App Review guideline 4.8: an iPhone app offering Google or Microsoft
56
+ * sign-in must offer Sign in with Apple too. So on iOS the provider list is
57
+ * all-or-nothing on Apple — if Apple is off, Google and Microsoft are withheld
58
+ * as well, and the app offers the email code alone (which 4.8 accepts). Android
59
+ * has no such rule; there Apple, where on, is a browser page like the others.
60
+ */
61
+ export declare function nativeProvidersToOffer(enabled: readonly OAuthProvider[], support: NativeOAuthSupport | null): OAuthProvider[];
62
+ interface CryptoLike {
63
+ getRandomValues<T extends ArrayBufferView>(array: T): T;
64
+ subtle?: {
65
+ digest(algorithm: string, data: BufferSource): Promise<ArrayBuffer>;
66
+ };
67
+ }
68
+ export interface PkcePair {
69
+ verifier: string;
70
+ challenge: string;
71
+ /** GoTrue's spelling — lower-case, as supabase-js sends it. */
72
+ method: 's256' | 'plain';
73
+ }
74
+ /** RFC 4648 §5 base64url, no padding — RFC 7636's encoding of the challenge. */
75
+ export declare function base64UrlEncode(bytes: Uint8Array): string;
76
+ /**
77
+ * The S256 challenge for a verifier, or the verifier itself as a `plain`
78
+ * challenge where WebCrypto is unavailable — the same fallback supabase-js
79
+ * makes. `crypto.subtle` exists only in a secure context, and whether a
80
+ * Capacitor origin counts is WebKit's decision, not ours.
81
+ *
82
+ * `plain` still protects the thing PKCE is here for: the verifier travels
83
+ * app → browser in the authorize URL and never through the redirect an
84
+ * interloper could intercept.
85
+ */
86
+ export declare function pkceChallenge(verifier: string, cryptoImpl?: CryptoLike | null): Promise<{
87
+ challenge: string;
88
+ method: 's256' | 'plain';
89
+ }>;
90
+ /** A fresh verifier (64 hex characters — inside RFC 7636's 43–128) and its challenge. */
91
+ export declare function createPkcePair(cryptoImpl?: CryptoLike | null): Promise<PkcePair>;
92
+ export interface NativeAuthorizeUrlInput {
93
+ supabaseUrl: string;
94
+ provider: OAuthProvider;
95
+ /** The app's deep link, from `nativeOAuthSupport().callbackUrl`. */
96
+ redirectTo: string;
97
+ pkce: {
98
+ challenge: string;
99
+ method: 's256' | 'plain';
100
+ };
101
+ loginHint?: string;
102
+ /**
103
+ * Link the provider to the signed-in (anonymous) user instead of signing in.
104
+ * Uses the identities endpoint, which must be called WITH the user's bearer
105
+ * token and answers JSON `{ url }` — see `skip_http_redirect`.
106
+ */
107
+ link?: boolean;
108
+ }
109
+ /**
110
+ * The GoTrue URL that starts a provider round trip, carrying the PKCE
111
+ * challenge. Sign-in: open it in the system browser. Link: fetch it with the
112
+ * user's JWT and open the `url` it answers with.
113
+ */
114
+ export declare function buildNativeAuthorizeUrl(input: NativeAuthorizeUrlInput): string;
115
+ export interface CustomSchemeUrlParts {
116
+ scheme: string;
117
+ host: string;
118
+ path: string;
119
+ query: URLSearchParams;
120
+ fragment: URLSearchParams;
121
+ }
122
+ /**
123
+ * Split `scheme://host/path?query#fragment` by hand.
124
+ *
125
+ * ⚠️ Not `new URL()`: for a non-special scheme (anything that isn't http,
126
+ * file, …) older Android System WebViews return an EMPTY host and fold the
127
+ * authority into the path, so `url.host === 'auth-callback'` would fail on
128
+ * some phones and pass on the test machine.
129
+ */
130
+ export declare function splitCustomSchemeUrl(value: string): CustomSchemeUrlParts | null;
131
+ export type NativeOAuthCallback = {
132
+ kind: 'code';
133
+ code: string;
134
+ } | {
135
+ kind: 'error';
136
+ error: OAuthReturnError;
137
+ } | {
138
+ kind: 'invalid';
139
+ reason: string;
140
+ };
141
+ /**
142
+ * Read the deep link Supabase sent the browser back to.
143
+ *
144
+ * Errors are read from the query string AND the fragment, for the reason
145
+ * `readOAuthError` gives. Success must be a `code` in the query: tokens in a
146
+ * fragment are refused (see the header) — they would mean the project ignored
147
+ * the PKCE challenge, and accepting them is how an injected callback signs
148
+ * someone into the wrong account.
149
+ */
150
+ export declare function parseNativeOAuthCallback(received: string, expected: string): NativeOAuthCallback;
151
+ type NativeError = {
152
+ message: string;
153
+ code: string | null;
154
+ };
155
+ /**
156
+ * A GoTrue error body as `{ code, message }`, in the codes the web flow
157
+ * produces. GoTrue has used two shapes — `{ code: 422, error_code, msg }` and,
158
+ * on the newer API version, `{ code: 'manual_linking_disabled', message }` —
159
+ * and OAuth-style `{ error, error_description }` besides.
160
+ */
161
+ export declare function gotrueError(body: unknown, status: number): NativeError;
162
+ export interface NativeOAuthOptions {
163
+ /** `config.supabaseUrl` — the GoTrue calls are made directly (see header). */
164
+ supabaseUrl: string;
165
+ /** `config.supabaseAnonKey`. */
166
+ anonKey: string;
167
+ /** A typed email, passed to Google/Microsoft as `login_hint`. */
168
+ loginHint?: string;
169
+ /**
170
+ * Sign in as a fresh user even over a trial session — the recovery path for
171
+ * `identity_already_exists`, and only after the user has agreed to leave the
172
+ * trial's work behind. See `abandonTrialAndSignInNative`.
173
+ */
174
+ forceNewSession?: boolean;
175
+ /** Test seams. */
176
+ plugin?: NativeOAuthPlugin | null;
177
+ fetchImpl?: typeof fetch;
178
+ cryptoImpl?: CryptoLike | null;
179
+ }
180
+ export interface NativeOAuthResult {
181
+ /**
182
+ * `signed-in`: the session is installed (and in the shared store).
183
+ * `cancelled`: the person closed the sheet or the browser — not an error,
184
+ * say nothing. `error`: see `error`, which carries the web flow's codes.
185
+ */
186
+ status: 'signed-in' | 'cancelled' | 'error';
187
+ /** `link` when a trial session was being upgraded in place. */
188
+ mode: 'link' | 'signin';
189
+ error: NativeError | null;
190
+ }
191
+ /**
192
+ * Apple / Google / Microsoft sign-in from a native shell, upgrading a trial
193
+ * session in place where there is one. Unlike the web `startOAuthSignIn` this
194
+ * resolves when the whole round trip is over — the app never navigates away.
195
+ */
196
+ export declare function startNativeOAuthSignIn(supabase: Supabase, provider: OAuthProvider, options: NativeOAuthOptions): Promise<NativeOAuthResult>;
197
+ /**
198
+ * The native escape hatch for `identity_already_exists`: sign in as the
199
+ * provider's existing account, leaving the trial's work behind. Call it only
200
+ * after the user has agreed to that.
201
+ *
202
+ * Unlike the web `abandonTrialAndSignIn` there is no sign-out first: the new
203
+ * session simply replaces the trial one when it lands, so a person who cancels
204
+ * the sheet still has their trial.
205
+ */
206
+ export declare function abandonTrialAndSignInNative(supabase: Supabase, provider: OAuthProvider, options: NativeOAuthOptions): Promise<NativeOAuthResult>;
207
+ export {};
208
+ //# sourceMappingURL=nativeOAuth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nativeOAuth.d.ts","sourceRoot":"","sources":["../src/nativeOAuth.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,EAAyC,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAgE7G,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,UAAU,CAAC,CAAA;AAE3D,uEAAuE;AACvE,eAAO,MAAM,0BAA0B,kBAAkB,CAAA;AAEzD,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,SAAS,CAAA;AAE9C,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,cAAc,CAAA;IACxB,gFAAgF;IAChF,WAAW,EAAE,MAAM,CAAA;IACnB,yEAAyE;IACzE,WAAW,EAAE,OAAO,CAAA;CACrB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,YAAY,IAAI,OAAO,CAAC;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;IAC3F,UAAU,CAAC,OAAO,EAAE;QAAE,GAAG,EAAE,M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GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAE5B"}
@@ -0,0 +1,372 @@
1
+ 'use client';
2
+ import { capacitorPlugin } from './sessionStorage.js';
3
+ import { loginHintParams, oauthErrorFromParams } from './oauth.js';
4
+ /** The host of every app's callback: `<bundle id>://auth-callback`. */
5
+ export const NATIVE_OAUTH_CALLBACK_HOST = 'auth-callback';
6
+ function nativeOAuthPlugin() {
7
+ return capacitorPlugin('UnisimSuiteAuth');
8
+ }
9
+ /** Validate what the plugin reported; anything unexpected reads as "unsupported". */
10
+ export function normaliseNativeSupport(raw) {
11
+ const r = raw;
12
+ if (!r || typeof r !== 'object')
13
+ return null;
14
+ const platform = r.platform === 'ios' || r.platform === 'android' ? r.platform : null;
15
+ const callbackUrl = typeof r.callbackUrl === 'string' ? r.callbackUrl : '';
16
+ const parts = splitCustomSchemeUrl(callbackUrl);
17
+ if (!platform || !parts || parts.host !== NATIVE_OAUTH_CALLBACK_HOST)
18
+ return null;
19
+ if (parts.scheme === 'http' || parts.scheme === 'https')
20
+ return null;
21
+ return { platform, callbackUrl, appleNative: platform === 'ios' && r.appleNative === true };
22
+ }
23
+ /**
24
+ * Whether this build can do native provider sign-in, and how. Null in a
25
+ * browser, and in a native build whose plugin predates it (an app synced
26
+ * against an older SDK) — the dialog then offers no provider tab at all, which
27
+ * is the honest page.
28
+ */
29
+ export async function nativeOAuthSupport(plugin = nativeOAuthPlugin()) {
30
+ if (!plugin || typeof plugin.oauthSupport !== 'function')
31
+ return null;
32
+ try {
33
+ return normaliseNativeSupport(await plugin.oauthSupport());
34
+ }
35
+ catch {
36
+ // An older native half answers "not implemented" here.
37
+ return null;
38
+ }
39
+ }
40
+ /**
41
+ * The providers a native shell should offer, given what the project has
42
+ * switched on.
43
+ *
44
+ * ⚠️ App Review guideline 4.8: an iPhone app offering Google or Microsoft
45
+ * sign-in must offer Sign in with Apple too. So on iOS the provider list is
46
+ * all-or-nothing on Apple — if Apple is off, Google and Microsoft are withheld
47
+ * as well, and the app offers the email code alone (which 4.8 accepts). Android
48
+ * has no such rule; there Apple, where on, is a browser page like the others.
49
+ */
50
+ export function nativeProvidersToOffer(enabled, support) {
51
+ if (!support)
52
+ return [];
53
+ if (support.platform === 'ios' && !enabled.includes('apple'))
54
+ return [];
55
+ return [...enabled];
56
+ }
57
+ function defaultCrypto() {
58
+ return globalThis.crypto ?? null;
59
+ }
60
+ /** RFC 4648 §5 base64url, no padding — RFC 7636's encoding of the challenge. */
61
+ export function base64UrlEncode(bytes) {
62
+ let binary = '';
63
+ for (const b of bytes)
64
+ binary += String.fromCharCode(b);
65
+ return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
66
+ }
67
+ /**
68
+ * The S256 challenge for a verifier, or the verifier itself as a `plain`
69
+ * challenge where WebCrypto is unavailable — the same fallback supabase-js
70
+ * makes. `crypto.subtle` exists only in a secure context, and whether a
71
+ * Capacitor origin counts is WebKit's decision, not ours.
72
+ *
73
+ * `plain` still protects the thing PKCE is here for: the verifier travels
74
+ * app → browser in the authorize URL and never through the redirect an
75
+ * interloper could intercept.
76
+ */
77
+ export async function pkceChallenge(verifier, cryptoImpl = defaultCrypto()) {
78
+ const subtle = cryptoImpl?.subtle;
79
+ if (subtle && typeof TextEncoder !== 'undefined') {
80
+ try {
81
+ const digest = await subtle.digest('SHA-256', new TextEncoder().encode(verifier));
82
+ return { challenge: base64UrlEncode(new Uint8Array(digest)), method: 's256' };
83
+ }
84
+ catch {
85
+ /* fall through to plain */
86
+ }
87
+ }
88
+ return { challenge: verifier, method: 'plain' };
89
+ }
90
+ /** A fresh verifier (64 hex characters — inside RFC 7636's 43–128) and its challenge. */
91
+ export async function createPkcePair(cryptoImpl = defaultCrypto()) {
92
+ if (!cryptoImpl || typeof cryptoImpl.getRandomValues !== 'function') {
93
+ throw new Error('No secure random source to start a sign-in with');
94
+ }
95
+ const bytes = cryptoImpl.getRandomValues(new Uint8Array(32));
96
+ const verifier = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
97
+ const { challenge, method } = await pkceChallenge(verifier, cryptoImpl);
98
+ return { verifier, challenge, method };
99
+ }
100
+ /**
101
+ * The GoTrue URL that starts a provider round trip, carrying the PKCE
102
+ * challenge. Sign-in: open it in the system browser. Link: fetch it with the
103
+ * user's JWT and open the `url` it answers with.
104
+ */
105
+ export function buildNativeAuthorizeUrl(input) {
106
+ const base = input.supabaseUrl.replace(/\/+$/, '');
107
+ const path = input.link ? '/auth/v1/user/identities/authorize' : '/auth/v1/authorize';
108
+ const params = new URLSearchParams({
109
+ provider: input.provider,
110
+ redirect_to: input.redirectTo,
111
+ code_challenge: input.pkce.challenge,
112
+ code_challenge_method: input.pkce.method,
113
+ });
114
+ for (const [key, value] of Object.entries(loginHintParams(input.provider, input.loginHint) ?? {})) {
115
+ params.set(key, value);
116
+ }
117
+ if (input.link)
118
+ params.set('skip_http_redirect', 'true');
119
+ return `${base}${path}?${params.toString()}`;
120
+ }
121
+ /**
122
+ * Split `scheme://host/path?query#fragment` by hand.
123
+ *
124
+ * ⚠️ Not `new URL()`: for a non-special scheme (anything that isn't http,
125
+ * file, …) older Android System WebViews return an EMPTY host and fold the
126
+ * authority into the path, so `url.host === 'auth-callback'` would fail on
127
+ * some phones and pass on the test machine.
128
+ */
129
+ export function splitCustomSchemeUrl(value) {
130
+ const m = /^([a-zA-Z][a-zA-Z0-9+.-]*):\/\/([^/?#]*)([^?#]*)(\?[^#]*)?(#.*)?$/.exec(value);
131
+ if (!m)
132
+ return null;
133
+ return {
134
+ scheme: (m[1] ?? '').toLowerCase(),
135
+ host: (m[2] ?? '').toLowerCase(),
136
+ path: m[3] ?? '',
137
+ query: new URLSearchParams((m[4] ?? '').slice(1)),
138
+ fragment: new URLSearchParams((m[5] ?? '').slice(1)),
139
+ };
140
+ }
141
+ /**
142
+ * Read the deep link Supabase sent the browser back to.
143
+ *
144
+ * Errors are read from the query string AND the fragment, for the reason
145
+ * `readOAuthError` gives. Success must be a `code` in the query: tokens in a
146
+ * fragment are refused (see the header) — they would mean the project ignored
147
+ * the PKCE challenge, and accepting them is how an injected callback signs
148
+ * someone into the wrong account.
149
+ */
150
+ export function parseNativeOAuthCallback(received, expected) {
151
+ const got = splitCustomSchemeUrl(received);
152
+ const want = splitCustomSchemeUrl(expected);
153
+ if (!got || !want || got.scheme !== want.scheme || got.host !== want.host) {
154
+ return { kind: 'invalid', reason: 'not this app\'s callback address' };
155
+ }
156
+ const error = oauthErrorFromParams([got.query, got.fragment]);
157
+ if (error)
158
+ return { kind: 'error', error };
159
+ const code = got.query.get('code');
160
+ if (code)
161
+ return { kind: 'code', code };
162
+ if (got.fragment.has('access_token')) {
163
+ return { kind: 'invalid', reason: 'tokens instead of a code' };
164
+ }
165
+ return { kind: 'invalid', reason: 'no code' };
166
+ }
167
+ function str(value) {
168
+ return typeof value === 'string' && value.length > 0 ? value : null;
169
+ }
170
+ /**
171
+ * A GoTrue error body as `{ code, message }`, in the codes the web flow
172
+ * produces. GoTrue has used two shapes — `{ code: 422, error_code, msg }` and,
173
+ * on the newer API version, `{ code: 'manual_linking_disabled', message }` —
174
+ * and OAuth-style `{ error, error_description }` besides.
175
+ */
176
+ export function gotrueError(body, status) {
177
+ const b = (body ?? {});
178
+ return {
179
+ code: str(b.error_code) ?? str(b.code) ?? str(b.error),
180
+ message: str(b.msg) ?? str(b.message) ?? str(b.error_description) ?? str(b.error) ??
181
+ `Sign-in failed (HTTP ${status})`,
182
+ };
183
+ }
184
+ async function gotrue(fetchImpl, url, init) {
185
+ let res;
186
+ try {
187
+ res = await fetchImpl(url, init);
188
+ }
189
+ catch (err) {
190
+ return { ok: false, error: { code: 'network_error', message: err?.message || 'Network error' } };
191
+ }
192
+ let body = {};
193
+ try {
194
+ body = ((await res.json()) ?? {});
195
+ }
196
+ catch {
197
+ /* an empty or non-JSON body — the status still says what happened */
198
+ }
199
+ if (!res.ok)
200
+ return { ok: false, error: gotrueError(body, res.status) };
201
+ return { ok: true, body };
202
+ }
203
+ function headers(anonKey, bearer) {
204
+ const h = { apikey: anonKey, 'Content-Type': 'application/json' };
205
+ if (bearer)
206
+ h.Authorization = `Bearer ${bearer}`;
207
+ return h;
208
+ }
209
+ function sessionFrom(body) {
210
+ const access_token = str(body.access_token);
211
+ const refresh_token = str(body.refresh_token);
212
+ return access_token && refresh_token ? { access_token, refresh_token } : null;
213
+ }
214
+ function pluginError(err, fallbackCode) {
215
+ const e = err;
216
+ return {
217
+ code: e?.code !== undefined && e?.code !== null ? String(e.code) : fallbackCode,
218
+ message: e?.message || 'Sign-in could not be started',
219
+ };
220
+ }
221
+ const BAD_RESPONSE = { code: 'invalid_response', message: 'Sign-in returned no session.' };
222
+ /**
223
+ * Apple / Google / Microsoft sign-in from a native shell, upgrading a trial
224
+ * session in place where there is one. Unlike the web `startOAuthSignIn` this
225
+ * resolves when the whole round trip is over — the app never navigates away.
226
+ */
227
+ export async function startNativeOAuthSignIn(supabase, provider, options) {
228
+ const plugin = options.plugin === undefined ? nativeOAuthPlugin() : options.plugin;
229
+ const fetchImpl = options.fetchImpl ?? fetch;
230
+ const base = options.supabaseUrl.replace(/\/+$/, '');
231
+ let mode = 'signin';
232
+ const fail = (error) => ({ status: 'error', mode, error });
233
+ const support = await nativeOAuthSupport(plugin);
234
+ if (!plugin || !support) {
235
+ return fail({ code: 'native_oauth_unavailable', message: 'This app cannot open a sign-in window.' });
236
+ }
237
+ // The trial check mirrors oauth.ts: anonymous → link, everyone else → sign in.
238
+ let bearer = null;
239
+ if (!options.forceNewSession) {
240
+ const { data } = await supabase.auth.getSession();
241
+ const session = data.session;
242
+ if (session?.user?.is_anonymous === true && session?.access_token) {
243
+ mode = 'link';
244
+ bearer = session.access_token;
245
+ }
246
+ }
247
+ const leg = provider === 'apple' && support.appleNative
248
+ ? await viaAppleSheet(plugin, base, options.anonKey, bearer, fetchImpl)
249
+ : await viaSystemBrowser(plugin, support, provider, base, options, bearer, fetchImpl);
250
+ if ('cancelled' in leg)
251
+ return { status: 'cancelled', mode, error: null };
252
+ if ('error' in leg)
253
+ return fail(leg.error);
254
+ // Through the client, so it lands in the storage adapter (the shared suite
255
+ // store) and every onAuthStateChange listener hears SIGNED_IN.
256
+ const { error } = await supabase.auth.setSession(leg.session);
257
+ if (error) {
258
+ const e = error;
259
+ return fail({ message: e.message ?? 'Sign-in failed', code: e.code ?? null });
260
+ }
261
+ // Apple hands over the name ONCE, on the first sign-in, and never puts it in
262
+ // the token — keep it or it is gone. Never fatal.
263
+ const given = leg.name?.given ?? null;
264
+ const family = leg.name?.family ?? null;
265
+ if (given || family) {
266
+ const fullName = [given, family].filter(Boolean).join(' ');
267
+ try {
268
+ await supabase.auth.updateUser({
269
+ data: { full_name: fullName, ...(given ? { given_name: given } : {}), ...(family ? { family_name: family } : {}) },
270
+ });
271
+ }
272
+ catch {
273
+ /* the sign-in itself succeeded */
274
+ }
275
+ }
276
+ return { status: 'signed-in', mode, error: null };
277
+ }
278
+ /**
279
+ * The native escape hatch for `identity_already_exists`: sign in as the
280
+ * provider's existing account, leaving the trial's work behind. Call it only
281
+ * after the user has agreed to that.
282
+ *
283
+ * Unlike the web `abandonTrialAndSignIn` there is no sign-out first: the new
284
+ * session simply replaces the trial one when it lands, so a person who cancels
285
+ * the sheet still has their trial.
286
+ */
287
+ export function abandonTrialAndSignInNative(supabase, provider, options) {
288
+ return startNativeOAuthSignIn(supabase, provider, { ...options, forceNewSession: true });
289
+ }
290
+ async function viaAppleSheet(plugin, base, anonKey, bearer, fetchImpl) {
291
+ let res;
292
+ try {
293
+ res = await plugin.appleSignIn();
294
+ }
295
+ catch (err) {
296
+ return { error: pluginError(err, 'apple_signin_failed') };
297
+ }
298
+ if (res?.cancelled)
299
+ return { cancelled: true };
300
+ if (!res?.identityToken || !res.nonce) {
301
+ return { error: { code: 'apple_no_token', message: 'Apple did not return a sign-in token.' } };
302
+ }
303
+ // The RAW nonce: the sheet sent Apple its SHA-256, and GoTrue hashes this to
304
+ // compare against the token's `nonce` claim.
305
+ const body = { provider: 'apple', id_token: res.identityToken, nonce: res.nonce };
306
+ if (bearer)
307
+ body.link_identity = true;
308
+ const r = await gotrue(fetchImpl, `${base}/auth/v1/token?grant_type=id_token`, {
309
+ method: 'POST',
310
+ headers: headers(anonKey, bearer),
311
+ body: JSON.stringify(body),
312
+ });
313
+ if (!r.ok)
314
+ return { error: r.error };
315
+ const session = sessionFrom(r.body);
316
+ if (!session)
317
+ return { error: BAD_RESPONSE };
318
+ return { session, name: { given: res.givenName ?? null, family: res.familyName ?? null } };
319
+ }
320
+ async function viaSystemBrowser(plugin, support, provider, base, options, bearer, fetchImpl) {
321
+ let pkce;
322
+ try {
323
+ pkce = await createPkcePair(options.cryptoImpl === undefined ? defaultCrypto() : options.cryptoImpl);
324
+ }
325
+ catch (err) {
326
+ return { error: { code: 'pkce_unavailable', message: err.message } };
327
+ }
328
+ let url = buildNativeAuthorizeUrl({
329
+ supabaseUrl: base,
330
+ provider,
331
+ redirectTo: support.callbackUrl,
332
+ pkce,
333
+ loginHint: options.loginHint,
334
+ link: bearer !== null,
335
+ });
336
+ if (bearer) {
337
+ // The identities endpoint needs the trial user's JWT, which a browser tab
338
+ // cannot carry — so ask for the provider URL here and open THAT.
339
+ const r = await gotrue(fetchImpl, url, { method: 'GET', headers: headers(options.anonKey, bearer) });
340
+ if (!r.ok)
341
+ return { error: r.error };
342
+ const providerUrl = str(r.body.url);
343
+ if (!providerUrl)
344
+ return { error: BAD_RESPONSE };
345
+ url = providerUrl;
346
+ }
347
+ let res;
348
+ try {
349
+ res = await plugin.oauthStart({ url });
350
+ }
351
+ catch (err) {
352
+ return { error: pluginError(err, 'browser_failed') };
353
+ }
354
+ if (res?.cancelled)
355
+ return { cancelled: true };
356
+ const callback = parseNativeOAuthCallback(res?.url ?? '', support.callbackUrl);
357
+ if (callback.kind === 'error')
358
+ return { error: callback.error };
359
+ if (callback.kind === 'invalid') {
360
+ return { error: { code: 'invalid_callback', message: `Sign-in came back in a form this app does not accept (${callback.reason}).` } };
361
+ }
362
+ const r = await gotrue(fetchImpl, `${base}/auth/v1/token?grant_type=pkce`, {
363
+ method: 'POST',
364
+ headers: headers(options.anonKey, null),
365
+ body: JSON.stringify({ auth_code: callback.code, code_verifier: pkce.verifier }),
366
+ });
367
+ if (!r.ok)
368
+ return { error: r.error };
369
+ const session = sessionFrom(r.body);
370
+ return session ? { session } : { error: BAD_RESPONSE };
371
+ }
372
+ //# sourceMappingURL=nativeOAuth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nativeOAuth.js","sourceRoot":"","sources":["../src/nativeOAuth.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAGZ,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAA6C,MAAM,YAAY,CAAA;AAkE7G,uEAAuE;AACvE,MAAM,CAAC,MAAM,0BAA0B,GAAG,eAAe,CAAA;AAgCzD,SAAS,iBAAiB;IACxB,OAAO,eAAe,CAAoB,iBAAiB,CAAC,CAAA;AAC9D,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,sBAAsB,CAAC,GAAY;IACjD,MAAM,CAAC,GAAG,GAA8F,CAAA;IACxG,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAA;IAC5C,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,KAAK,KAAK,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAA;IACrF,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAA;IAC1E,MAAM,KAAK,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAA;IAC/C,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KA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CHANGED
@@ -115,6 +115,12 @@ export interface OAuthReturnError {
115
115
  * in — the single worst outcome for this feature.
116
116
  */
117
117
  export declare function readOAuthError(href?: string): OAuthReturnError | null;
118
+ /**
119
+ * The first OAuth failure found in a list of parameter sets (query, then
120
+ * fragment). Shared with `nativeOAuth.ts`, which reads the same parameters off
121
+ * an app's deep link — the codes are GoTrue's either way.
122
+ */
123
+ export declare function oauthErrorFromParams(sources: URLSearchParams[]): OAuthReturnError | null;
118
124
  /**
119
125
  * Strip the OAuth error params from the address bar without adding a history
120
126
  * entry, so a reload (or a second attempt) doesn't resurrect a dead error.
@@ -1 +1 @@
1
- {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../src/oauth.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AA+BjD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,UAAU,CAAC,CAAA;AAE3D;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;AAExD;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,aAAa,EAAiC,CAAA;AAErF,8DAA8D;AAC9D,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,CAIlE;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,iFAAiF;IACjF,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAA;IACtD,oEAAoE;IACpE,IAAI,EAAE,MAAM,GAAG,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;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,aAAa,EACvB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,gBAAgB,CAAC,CAM3B;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,OAAO,KAAa,GAC9B,OAAO,CAAC,aAAa,EAAE,CAAC,CAkB1B;AAID,MAAM,WAAW,gBAAgB;IAC/B,2EAA2E;IAC3E,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAIrE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,gBAAgB,GAAG,IAAI,CAexF;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAStC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,OAAO,CAInG;AAED,yEAAyE;AACzE,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,OAAO,CAIvG"}
package/dist/oauth.js CHANGED
@@ -122,7 +122,15 @@ export function readOAuthError(href) {
122
122
  if (!href && typeof window === 'undefined')
123
123
  return null;
124
124
  const url = new URL(href ?? window.location.href);
125
- for (const params of [url.searchParams, new URLSearchParams(url.hash.replace(/^#/, ''))]) {
125
+ return oauthErrorFromParams([url.searchParams, new URLSearchParams(url.hash.replace(/^#/, ''))]);
126
+ }
127
+ /**
128
+ * The first OAuth failure found in a list of parameter sets (query, then
129
+ * fragment). Shared with `nativeOAuth.ts`, which reads the same parameters off
130
+ * an app's deep link — the codes are GoTrue's either way.
131
+ */
132
+ export function oauthErrorFromParams(sources) {
133
+ for (const params of sources) {
126
134
  const bucket = params.get('error');
127
135
  const code = params.get('error_code');
128
136
  const description = params.get('error_description');