@neetru/sdk 3.8.1 → 3.9.0
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/CHANGELOG.md +33 -0
- package/README.md +4 -1
- package/dist/ai.cjs +1 -1
- package/dist/ai.d.cts +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/ai.mjs +1 -1
- package/dist/auth.cjs +844 -803
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.mjs +841 -800
- package/dist/catalog.cjs +1 -1
- package/dist/catalog.d.cts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/checkout.cjs +62 -49
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/checkout.mjs +62 -49
- package/dist/db-react.d.cts +1 -1
- package/dist/db-react.d.ts +1 -1
- package/dist/db.cjs +200 -187
- package/dist/db.d.cts +1 -1
- package/dist/db.d.ts +1 -1
- package/dist/db.mjs +193 -180
- package/dist/entitlements.d.cts +1 -1
- package/dist/entitlements.d.ts +1 -1
- package/dist/firestore-compat.d.cts +1 -1
- package/dist/firestore-compat.d.ts +1 -1
- package/dist/index.cjs +880 -839
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +847 -806
- package/dist/mobile.cjs +328 -276
- package/dist/mobile.d.cts +12 -2
- package/dist/mobile.d.ts +12 -2
- package/dist/mobile.mjs +328 -276
- package/dist/mocks.cjs +5 -5
- package/dist/mocks.d.cts +2 -2
- package/dist/mocks.d.ts +2 -2
- package/dist/mocks.mjs +4 -4
- package/dist/notifications.cjs +1 -1
- package/dist/notifications.d.cts +1 -1
- package/dist/notifications.d.ts +1 -1
- package/dist/notifications.mjs +1 -1
- package/dist/react.cjs +119 -119
- package/dist/react.d.cts +8 -2
- package/dist/react.d.ts +8 -2
- package/dist/react.mjs +119 -119
- package/dist/support.cjs +1 -1
- package/dist/support.d.cts +1 -1
- package/dist/support.d.ts +1 -1
- package/dist/support.mjs +1 -1
- package/dist/telemetry.cjs +62 -49
- package/dist/telemetry.d.cts +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.mjs +62 -49
- package/dist/{types-yv3EDKg2.d.cts → types-Bl_4HROd.d.cts} +62 -3
- package/dist/{types-BYPk_3HR.d.ts → types-Bqnsqvow.d.ts} +62 -3
- package/dist/usage.cjs +1 -1
- package/dist/usage.d.cts +1 -1
- package/dist/usage.d.ts +1 -1
- package/dist/usage.mjs +1 -1
- package/dist/webhooks.cjs +1 -1
- package/dist/webhooks.d.cts +1 -1
- package/dist/webhooks.d.ts +1 -1
- package/dist/webhooks.mjs +1 -1
- package/package.json +9 -1
package/dist/mobile.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/errors.ts
|
|
4
|
-
var
|
|
4
|
+
var o = class t extends Error {
|
|
5
5
|
code;
|
|
6
6
|
status;
|
|
7
7
|
requestId;
|
|
@@ -21,65 +21,65 @@ var n = class t extends Error {
|
|
|
21
21
|
* `undefined` em erros que acontecem antes de qualquer requisição.
|
|
22
22
|
*/
|
|
23
23
|
correlationId;
|
|
24
|
-
constructor(e,
|
|
25
|
-
super(
|
|
24
|
+
constructor(e, n, i, a, f, p) {
|
|
25
|
+
super(n), this.name = "NeetruError", this.code = e, this.status = i, this.requestId = a, this.reason = f, this.correlationId = p, Object.setPrototypeOf(this, t.prototype);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
constructor(e,
|
|
29
|
-
super("auth_required", e,
|
|
27
|
+
}, R = class t extends o {
|
|
28
|
+
constructor(e, n, i, a, f) {
|
|
29
|
+
super("auth_required", e, i, a, n, f), this.name = "NeetruAuthRequiredError", Object.setPrototypeOf(this, t.prototype);
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
// src/types.ts
|
|
34
|
-
var
|
|
34
|
+
var B = "https://api.neetru.com";
|
|
35
35
|
|
|
36
36
|
// src/base-url-allowlist.ts
|
|
37
|
-
var
|
|
37
|
+
var F = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]", "::1"]), fe = ".neetru.com", ge = "neetru.com", me = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?\.(test|localhost)$/;
|
|
38
38
|
function j(t) {
|
|
39
|
-
return
|
|
39
|
+
return me.test(t);
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function he(t) {
|
|
42
42
|
return t.toLowerCase().replace(/\.+$/, "");
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function z(t, e = []) {
|
|
45
45
|
if (typeof t != "string" || t.length === 0)
|
|
46
|
-
throw new
|
|
47
|
-
let
|
|
46
|
+
throw new o("invalid_config", "baseUrl is required");
|
|
47
|
+
let n;
|
|
48
48
|
try {
|
|
49
|
-
|
|
49
|
+
n = new URL(t);
|
|
50
50
|
} catch {
|
|
51
|
-
throw new
|
|
51
|
+
throw new o("invalid_config", `baseUrl is not a valid URL: ${t}`);
|
|
52
52
|
}
|
|
53
|
-
let
|
|
54
|
-
if (
|
|
53
|
+
let i = n.protocol, a = he(n.hostname);
|
|
54
|
+
if (ye())
|
|
55
55
|
return typeof console < "u" && console.warn(
|
|
56
56
|
`[neetru-sdk] NEETRU_ALLOW_INSECURE_BASEURL=1 ativo. baseUrl=${t} aceito sem valida\xE7\xE3o.`
|
|
57
57
|
), t.replace(/\/+$/, "");
|
|
58
|
-
if (
|
|
59
|
-
throw new
|
|
58
|
+
if (i !== "https:" && i !== "http:")
|
|
59
|
+
throw new o(
|
|
60
60
|
"invalid_config",
|
|
61
|
-
`baseUrl protocol must be http: or https:, got ${
|
|
61
|
+
`baseUrl protocol must be http: or https:, got ${i}`
|
|
62
62
|
);
|
|
63
|
-
if (
|
|
64
|
-
if (!(
|
|
65
|
-
throw new
|
|
63
|
+
if (i === "http:") {
|
|
64
|
+
if (!(F.has(a) || j(a)))
|
|
65
|
+
throw new o(
|
|
66
66
|
"invalid_config",
|
|
67
|
-
`baseUrl with http: only allowed for localhost/127.0.0.1/*.test/*.localhost. Got: ${
|
|
67
|
+
`baseUrl with http: only allowed for localhost/127.0.0.1/*.test/*.localhost. Got: ${a}. Use https: or set NEETRU_ALLOW_INSECURE_BASEURL=1 to bypass.`
|
|
68
68
|
);
|
|
69
69
|
return t.replace(/\/+$/, "");
|
|
70
70
|
}
|
|
71
|
-
let
|
|
71
|
+
let f = a === ge || a.endsWith(fe), p = e.some((h) => {
|
|
72
72
|
let w = h.toLowerCase();
|
|
73
|
-
return
|
|
74
|
-
}),
|
|
75
|
-
if (!
|
|
76
|
-
throw new
|
|
73
|
+
return a === w || a.endsWith(`.${w}`);
|
|
74
|
+
}), y = F.has(a) || j(a);
|
|
75
|
+
if (!f && !p && !y)
|
|
76
|
+
throw new o(
|
|
77
77
|
"invalid_config",
|
|
78
|
-
`baseUrl ${
|
|
78
|
+
`baseUrl ${a} is not in the allowlist. Allowed: *.neetru.com, localhost, or configure { allowedHosts: ['...'] }. Bypass: NEETRU_ALLOW_INSECURE_BASEURL=1.`
|
|
79
79
|
);
|
|
80
80
|
return t.replace(/\/+$/, "");
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function ye() {
|
|
83
83
|
try {
|
|
84
84
|
let e = globalThis.process?.env?.NEETRU_ALLOW_INSECURE_BASEURL;
|
|
85
85
|
if (e === "1" || e === "true") return !0;
|
|
@@ -94,16 +94,16 @@ function fe() {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
// src/api-key.ts
|
|
97
|
-
var
|
|
98
|
-
function
|
|
97
|
+
var be = /^nrt_([A-Za-z0-9]+)_([A-Za-z0-9]+)$/;
|
|
98
|
+
function V(t) {
|
|
99
99
|
if (typeof t != "string" || t.length === 0)
|
|
100
|
-
throw new
|
|
100
|
+
throw new o(
|
|
101
101
|
"invalid_config",
|
|
102
102
|
"apiKey is required (formato nrt_<keyId>_<secret>)"
|
|
103
103
|
);
|
|
104
|
-
let e =
|
|
104
|
+
let e = be.exec(t);
|
|
105
105
|
if (!e)
|
|
106
|
-
throw new
|
|
106
|
+
throw new o(
|
|
107
107
|
"invalid_config",
|
|
108
108
|
"apiKey malformado - esperado formato nrt_<keyId>_<secret>"
|
|
109
109
|
);
|
|
@@ -111,57 +111,57 @@ function z(t) {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
// src/auth-pkce-shared.ts
|
|
114
|
-
function
|
|
114
|
+
function W() {
|
|
115
115
|
let t = globalThis.crypto;
|
|
116
116
|
if (!t || typeof t.getRandomValues != "function" || !t.subtle)
|
|
117
|
-
throw new
|
|
117
|
+
throw new o(
|
|
118
118
|
"runtime_unsupported",
|
|
119
119
|
"auth.signIn requer WebCrypto (crypto.subtle) \u2014 indispon\xEDvel neste runtime. Use HTTPS (ou http://localhost) num browser moderno, ou instale um polyfill WebCrypto (ex: react-native-quick-crypto) em React Native."
|
|
120
120
|
);
|
|
121
121
|
return t;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function J(t) {
|
|
124
124
|
let e = "";
|
|
125
|
-
for (let
|
|
125
|
+
for (let i of t) e += String.fromCharCode(i);
|
|
126
126
|
return (typeof btoa == "function" ? btoa(e) : Buffer.from(e, "binary").toString("base64")).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
127
127
|
}
|
|
128
128
|
function x(t, e) {
|
|
129
|
-
let
|
|
130
|
-
return t.getRandomValues(
|
|
129
|
+
let n = new Uint8Array(e);
|
|
130
|
+
return t.getRandomValues(n), J(n);
|
|
131
131
|
}
|
|
132
|
-
async function
|
|
133
|
-
let
|
|
134
|
-
return
|
|
132
|
+
async function G(t, e) {
|
|
133
|
+
let n = new TextEncoder().encode(e), i = await t.subtle.digest("SHA-256", n);
|
|
134
|
+
return J(new Uint8Array(i));
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function I(t) {
|
|
137
137
|
return (typeof globalThis.NEETRU_AUTH_URL == "string" ? globalThis.NEETRU_AUTH_URL : null) ?? t.replace(/^https?:\/\/api\./, "https://auth.");
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function O(t) {
|
|
140
140
|
let e = t.oidcClientId;
|
|
141
|
-
if (!e && t.apiKey && (e =
|
|
142
|
-
throw new
|
|
141
|
+
if (!e && t.apiKey && (e = V(t.apiKey).keyId), !e)
|
|
142
|
+
throw new o(
|
|
143
143
|
"invalid_config",
|
|
144
144
|
"auth OIDC requer `oidcClientId` (ou `apiKey`) configurado para montar o client_id."
|
|
145
145
|
);
|
|
146
146
|
return e;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function X(t) {
|
|
149
149
|
let e = new URL("/api/v1/oauth/authorize", t.idpOrigin);
|
|
150
150
|
return e.searchParams.set("response_type", "code"), e.searchParams.set("client_id", t.clientId), e.searchParams.set("redirect_uri", t.redirectUri), e.searchParams.set("scope", t.scope), e.searchParams.set("state", t.state), e.searchParams.set("nonce", t.nonce), e.searchParams.set("code_challenge", t.codeChallenge), e.searchParams.set("code_challenge_method", "S256"), e;
|
|
151
151
|
}
|
|
152
|
-
var
|
|
153
|
-
function
|
|
152
|
+
var Y = "/api/v1/oauth/token";
|
|
153
|
+
function L(t) {
|
|
154
154
|
let e = t.split(".");
|
|
155
155
|
if (e.length !== 3) return null;
|
|
156
156
|
try {
|
|
157
|
-
let
|
|
158
|
-
return JSON.parse(
|
|
157
|
+
let n = e[1].replace(/-/g, "+").replace(/_/g, "/"), i = "=".repeat((4 - n.length % 4) % 4), a = typeof atob == "function" ? atob(n + i) : Buffer.from(n + i, "base64").toString("utf-8");
|
|
158
|
+
return JSON.parse(a);
|
|
159
159
|
} catch {
|
|
160
160
|
return null;
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
function
|
|
164
|
-
let e =
|
|
163
|
+
function A(t) {
|
|
164
|
+
let e = L(t);
|
|
165
165
|
return !e || typeof e.sub != "string" || typeof e.exp == "number" && e.exp * 1e3 < Date.now() ? null : {
|
|
166
166
|
uid: e.sub,
|
|
167
167
|
email: typeof e.email == "string" ? e.email : "",
|
|
@@ -174,35 +174,35 @@ function T(t) {
|
|
|
174
174
|
...e
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
-
var
|
|
178
|
-
async function
|
|
179
|
-
let
|
|
180
|
-
for (let
|
|
181
|
-
if (!
|
|
182
|
-
let
|
|
183
|
-
token:
|
|
184
|
-
token_type_hint:
|
|
185
|
-
client_id:
|
|
177
|
+
var _e = "/api/v1/oauth/revoke";
|
|
178
|
+
async function Q(t, e, n, i) {
|
|
179
|
+
let a = `${e}${_e}`, f = true;
|
|
180
|
+
for (let p of i) {
|
|
181
|
+
if (!p.token) continue;
|
|
182
|
+
let y = new URLSearchParams({
|
|
183
|
+
token: p.token,
|
|
184
|
+
token_type_hint: p.hint,
|
|
185
|
+
client_id: n
|
|
186
186
|
}).toString(), h = false;
|
|
187
187
|
for (let w = 0; w < 2 && !h; w++)
|
|
188
188
|
try {
|
|
189
|
-
if (h = (await t(
|
|
189
|
+
if (h = (await t(a, {
|
|
190
190
|
method: "POST",
|
|
191
191
|
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
192
|
-
body:
|
|
192
|
+
body: y
|
|
193
193
|
})).ok, !h) break;
|
|
194
194
|
} catch {
|
|
195
|
-
w === 0 && await new Promise((
|
|
195
|
+
w === 0 && await new Promise((k) => setTimeout(k, 500));
|
|
196
196
|
}
|
|
197
|
-
h || (
|
|
197
|
+
h || (f = false);
|
|
198
198
|
}
|
|
199
|
-
return
|
|
199
|
+
return f;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
// src/server-only-key.ts
|
|
203
203
|
function Z(t) {
|
|
204
204
|
if (!(t == null || t === ""))
|
|
205
|
-
throw new
|
|
205
|
+
throw new o(
|
|
206
206
|
"server_only_key",
|
|
207
207
|
"[Neetru SDK] Recusado: @neetru/sdk/mobile n\xE3o aceita apiKey. A credencial nrt_ do produto \xE9 S\xD3 DE SERVIDOR \u2014 dentro do app ela \xE9 extra\xEDvel do pacote (.apk/.ipa). Remova a apiKey (e qualquer EXPO_PUBLIC_*_KEY com ela) do app: fa\xE7a login com oidcClientId (client OIDC p\xFAblico do app) e chame a API do seu produto com o access_token do usu\xE1rio; o backend do produto usa o SDK com a chave.",
|
|
208
208
|
void 0,
|
|
@@ -212,419 +212,471 @@ function Z(t) {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
// src/correlation.ts
|
|
215
|
-
var
|
|
216
|
-
var
|
|
217
|
-
function
|
|
218
|
-
return typeof t == "string" && t.length > 0 && t.length <= 128 &&
|
|
215
|
+
var ee = "x-correlation-id";
|
|
216
|
+
var we = /^[A-Za-z0-9._:\-]+$/;
|
|
217
|
+
function te(t) {
|
|
218
|
+
return typeof t == "string" && t.length > 0 && t.length <= 128 && we.test(t);
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function ke() {
|
|
221
221
|
let t = globalThis.crypto;
|
|
222
222
|
try {
|
|
223
223
|
if (t && typeof t.randomUUID == "function") return t.randomUUID();
|
|
224
224
|
} catch {
|
|
225
225
|
}
|
|
226
|
-
let e = new Uint8Array(16),
|
|
226
|
+
let e = new Uint8Array(16), n = false;
|
|
227
227
|
try {
|
|
228
|
-
t && typeof t.getRandomValues == "function" && (t.getRandomValues(e),
|
|
228
|
+
t && typeof t.getRandomValues == "function" && (t.getRandomValues(e), n = !0);
|
|
229
229
|
} catch {
|
|
230
|
-
|
|
230
|
+
n = false;
|
|
231
231
|
}
|
|
232
|
-
if (!
|
|
233
|
-
for (let
|
|
232
|
+
if (!n)
|
|
233
|
+
for (let a = 0; a < e.length; a++) e[a] = Math.floor(Math.random() * 256);
|
|
234
234
|
e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128;
|
|
235
|
-
let
|
|
236
|
-
return `${
|
|
235
|
+
let i = Array.from(e, (a) => a.toString(16).padStart(2, "0")).join("");
|
|
236
|
+
return `${i.slice(0, 8)}-${i.slice(8, 12)}-${i.slice(12, 16)}-${i.slice(16, 20)}-${i.slice(20)}`;
|
|
237
237
|
}
|
|
238
238
|
function K(t, e) {
|
|
239
|
-
let
|
|
240
|
-
for (let [
|
|
241
|
-
if (
|
|
242
|
-
|
|
239
|
+
let n, i = {};
|
|
240
|
+
for (let [f, p] of Object.entries(t)) {
|
|
241
|
+
if (f.toLowerCase() === ee) {
|
|
242
|
+
te(p) && (n = p);
|
|
243
243
|
continue;
|
|
244
244
|
}
|
|
245
|
-
|
|
245
|
+
i[f] = p;
|
|
246
246
|
}
|
|
247
|
-
let
|
|
248
|
-
return
|
|
247
|
+
let a = n ?? (te(e) ? e : void 0) ?? ke();
|
|
248
|
+
return i[ee] = a, { headers: i, correlationId: a };
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
// src/http.ts
|
|
252
|
-
function
|
|
252
|
+
function re(t) {
|
|
253
253
|
return t === 401 ? "unauthorized" : t === 403 ? "forbidden" : t === 404 ? "not_found" : t === 409 ? "conflict" : t === 410 ? "gone" : t === 422 || t === 400 ? "validation_failed" : t === 429 ? "rate_limited" : t >= 500 ? "server_error" : "unknown";
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
+
// src/timeout.ts
|
|
257
|
+
function ne(t) {
|
|
258
|
+
let e = globalThis.AbortSignal;
|
|
259
|
+
if (typeof e?.timeout == "function")
|
|
260
|
+
return { signal: e.timeout(t), clear: () => {
|
|
261
|
+
} };
|
|
262
|
+
if (typeof globalThis.AbortController != "function")
|
|
263
|
+
return { signal: void 0, clear: () => {
|
|
264
|
+
} };
|
|
265
|
+
let n = new AbortController(), i = setTimeout(() => n.abort(), t);
|
|
266
|
+
return i.unref?.(), { signal: n.signal, clear: () => clearTimeout(i) };
|
|
267
|
+
}
|
|
268
|
+
function oe(t, e, n) {
|
|
269
|
+
let i, a = new Promise((f) => {
|
|
270
|
+
i = setTimeout(() => f(n()), e), i.unref?.();
|
|
271
|
+
});
|
|
272
|
+
return Promise.race([t, a]).finally(() => {
|
|
273
|
+
i !== void 0 && clearTimeout(i);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
256
277
|
// src/mobile.ts
|
|
257
|
-
var
|
|
258
|
-
function
|
|
278
|
+
var v = "neetru_oauth_tx", E = "neetru_id_token", U = "neetru_refresh_token", C = "neetru_access_token", ve = 3e4, Re = "/api/v1/oauth/userinfo";
|
|
279
|
+
function Se(t) {
|
|
259
280
|
if (t === void 0 || t === "") return null;
|
|
260
281
|
let e;
|
|
261
282
|
try {
|
|
262
283
|
e = new URL(t);
|
|
263
284
|
} catch {
|
|
264
|
-
throw new
|
|
285
|
+
throw new o("invalid_config", `productApiUrl inv\xE1lida: ${t}`);
|
|
265
286
|
}
|
|
266
|
-
let
|
|
267
|
-
if (e.protocol !== "https:" && !(e.protocol === "http:" &&
|
|
268
|
-
throw new
|
|
287
|
+
let n = e.hostname === "localhost" || e.hostname === "127.0.0.1";
|
|
288
|
+
if (e.protocol !== "https:" && !(e.protocol === "http:" && n))
|
|
289
|
+
throw new o(
|
|
269
290
|
"invalid_config",
|
|
270
291
|
"productApiUrl precisa ser https:// (http s\xF3 para localhost) \u2014 o access_token n\xE3o pode trafegar sem TLS."
|
|
271
292
|
);
|
|
272
293
|
return e;
|
|
273
294
|
}
|
|
274
|
-
function
|
|
295
|
+
function Te(t) {
|
|
275
296
|
if (Z(t.apiKey), !t.storage)
|
|
276
|
-
throw new
|
|
297
|
+
throw new o(
|
|
277
298
|
"invalid_config",
|
|
278
299
|
"createMobileAuthNamespace requer `storage` (MobileAuthStorage) \u2014 ver JSDoc de src/mobile.ts requisito 4."
|
|
279
300
|
);
|
|
280
301
|
if (typeof t.openAuthUrl != "function")
|
|
281
|
-
throw new
|
|
302
|
+
throw new o(
|
|
282
303
|
"invalid_config",
|
|
283
304
|
"createMobileAuthNamespace requer `openAuthUrl` (browser externo, NUNCA WebView embutida) \u2014 ver JSDoc de src/mobile.ts requisito 3."
|
|
284
305
|
);
|
|
285
306
|
let e = t.fetch ?? globalThis.fetch;
|
|
286
307
|
if (typeof e != "function")
|
|
287
|
-
throw new
|
|
308
|
+
throw new o(
|
|
288
309
|
"invalid_config",
|
|
289
310
|
"fetch is not available in this runtime. Pass `fetch` explicitly to createMobileAuthNamespace."
|
|
290
311
|
);
|
|
291
312
|
if (typeof t.oidcClientId != "string" || t.oidcClientId.length === 0)
|
|
292
|
-
throw new
|
|
313
|
+
throw new o(
|
|
293
314
|
"invalid_config",
|
|
294
315
|
"createMobileAuthNamespace requer `oidcClientId` \u2014 o client OIDC P\xDABLICO do app registrado no Core (a apiKey n\xE3o \xE9 aceita no app; ver requisito 6 no JSDoc de src/mobile.ts)."
|
|
295
316
|
);
|
|
296
|
-
let
|
|
317
|
+
let n = z(t.baseUrl ?? B, t.allowedHosts ?? []);
|
|
297
318
|
return {
|
|
298
319
|
fetchImpl: e.bind(globalThis),
|
|
299
|
-
baseUrl:
|
|
320
|
+
baseUrl: n,
|
|
300
321
|
oidcClientId: t.oidcClientId,
|
|
301
|
-
productApiUrl:
|
|
322
|
+
productApiUrl: Se(t.productApiUrl),
|
|
302
323
|
storage: t.storage,
|
|
303
324
|
openAuthUrl: t.openAuthUrl
|
|
304
325
|
};
|
|
305
326
|
}
|
|
306
|
-
function
|
|
307
|
-
let
|
|
308
|
-
return typeof
|
|
327
|
+
function Ie(t) {
|
|
328
|
+
let n = L(t)?.exp;
|
|
329
|
+
return typeof n == "number" ? n * 1e3 : null;
|
|
309
330
|
}
|
|
310
|
-
async function
|
|
311
|
-
let
|
|
331
|
+
async function ie(t, e, n) {
|
|
332
|
+
let { signal: i, clear: a } = ne(15e3), f;
|
|
312
333
|
try {
|
|
313
|
-
|
|
334
|
+
f = await t(e, {
|
|
314
335
|
method: "POST",
|
|
315
336
|
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
316
|
-
body:
|
|
337
|
+
body: n.toString(),
|
|
338
|
+
signal: i
|
|
317
339
|
});
|
|
318
|
-
} catch (
|
|
319
|
-
throw new
|
|
340
|
+
} catch (y) {
|
|
341
|
+
throw new o(
|
|
320
342
|
"network_error",
|
|
321
|
-
`POST ${e} falhou (network): ${
|
|
343
|
+
`POST ${e} falhou (network): ${y?.message ?? String(y)}`
|
|
322
344
|
);
|
|
345
|
+
} finally {
|
|
346
|
+
a();
|
|
323
347
|
}
|
|
324
|
-
let
|
|
348
|
+
let p = null;
|
|
325
349
|
try {
|
|
326
|
-
|
|
350
|
+
p = await f.json();
|
|
327
351
|
} catch {
|
|
328
|
-
|
|
352
|
+
p = null;
|
|
329
353
|
}
|
|
330
|
-
if (!
|
|
331
|
-
let
|
|
332
|
-
throw new
|
|
354
|
+
if (!f.ok || typeof p?.error == "string") {
|
|
355
|
+
let y = typeof p?.error_description == "string" && p.error_description || typeof p?.error == "string" && p.error || `HTTP ${f.status}`;
|
|
356
|
+
throw new o(
|
|
333
357
|
"token_exchange_failed",
|
|
334
|
-
`Troca de tokens falhou no /token: ${
|
|
335
|
-
|
|
358
|
+
`Troca de tokens falhou no /token: ${y}`,
|
|
359
|
+
f.status
|
|
336
360
|
);
|
|
337
361
|
}
|
|
338
|
-
return
|
|
362
|
+
return p ?? {};
|
|
339
363
|
}
|
|
340
|
-
function
|
|
341
|
-
let e =
|
|
342
|
-
function
|
|
343
|
-
return `${
|
|
364
|
+
function Ge(t) {
|
|
365
|
+
let e = Te(t), n = /* @__PURE__ */ new Set();
|
|
366
|
+
function i() {
|
|
367
|
+
return `${I(e.baseUrl)}${Y}`;
|
|
344
368
|
}
|
|
345
|
-
async function
|
|
346
|
-
let
|
|
347
|
-
|
|
369
|
+
async function a(r) {
|
|
370
|
+
let s = null;
|
|
371
|
+
if (r !== void 0)
|
|
372
|
+
s = r;
|
|
373
|
+
else
|
|
348
374
|
try {
|
|
349
|
-
|
|
375
|
+
s = await h();
|
|
376
|
+
} catch {
|
|
377
|
+
s = null;
|
|
378
|
+
}
|
|
379
|
+
for (let l of n)
|
|
380
|
+
try {
|
|
381
|
+
l(s);
|
|
350
382
|
} catch {
|
|
351
383
|
}
|
|
352
384
|
}
|
|
353
|
-
async function
|
|
385
|
+
async function f(r) {
|
|
354
386
|
if (!r?.redirectUri)
|
|
355
|
-
throw new
|
|
387
|
+
throw new o(
|
|
356
388
|
"invalid_config",
|
|
357
389
|
"mobile auth.signIn requer `redirectUri` (Universal Link/App Link https://... registrado no Core) \u2014 n\xE3o h\xE1 location.origin impl\xEDcito em React Native."
|
|
358
390
|
);
|
|
359
|
-
let
|
|
391
|
+
let s = W(), l = r.scope ?? "openid profile email", u = O(e), d = x(s, 16), c = x(s, 16), m = x(s, 32), g = await G(s, m), b = {
|
|
360
392
|
state: d,
|
|
361
|
-
nonce:
|
|
362
|
-
codeVerifier:
|
|
393
|
+
nonce: c,
|
|
394
|
+
codeVerifier: m,
|
|
363
395
|
redirectUri: r.redirectUri,
|
|
364
396
|
postLoginRedirect: r.postLoginRedirect
|
|
365
397
|
};
|
|
366
|
-
await e.storage.setItem(
|
|
367
|
-
let
|
|
368
|
-
idpOrigin:
|
|
369
|
-
clientId:
|
|
398
|
+
await e.storage.setItem(v, JSON.stringify(b));
|
|
399
|
+
let _ = I(e.baseUrl), S = X({
|
|
400
|
+
idpOrigin: _,
|
|
401
|
+
clientId: u,
|
|
370
402
|
redirectUri: r.redirectUri,
|
|
371
|
-
scope:
|
|
403
|
+
scope: l,
|
|
372
404
|
state: d,
|
|
373
|
-
nonce:
|
|
405
|
+
nonce: c,
|
|
374
406
|
codeChallenge: g
|
|
375
407
|
});
|
|
376
|
-
await e.openAuthUrl(
|
|
408
|
+
await e.openAuthUrl(S.toString());
|
|
377
409
|
}
|
|
378
|
-
async function
|
|
410
|
+
async function p(r) {
|
|
379
411
|
if (!r || typeof r != "string")
|
|
380
|
-
throw new
|
|
412
|
+
throw new o(
|
|
381
413
|
"invalid_config",
|
|
382
414
|
"mobile auth.completeSignIn requer `callbackUrl` (a URL completa do deep link de retorno) \u2014 mobile n\xE3o tem location.href impl\xEDcito."
|
|
383
415
|
);
|
|
384
|
-
let
|
|
416
|
+
let s;
|
|
385
417
|
try {
|
|
386
|
-
|
|
418
|
+
s = new URL(r);
|
|
387
419
|
} catch {
|
|
388
|
-
throw new
|
|
420
|
+
throw new o("invalid_config", `callbackUrl n\xE3o \xE9 uma URL v\xE1lida: ${r}`);
|
|
389
421
|
}
|
|
390
|
-
let
|
|
391
|
-
if (
|
|
392
|
-
let
|
|
393
|
-
throw await e.storage.removeItem(
|
|
422
|
+
let l = s.searchParams, u = l.get("error");
|
|
423
|
+
if (u) {
|
|
424
|
+
let pe = l.get("error_description") ?? u;
|
|
425
|
+
throw await e.storage.removeItem(v), new o(u, `OIDC authorize falhou: ${pe}`);
|
|
394
426
|
}
|
|
395
|
-
let d =
|
|
427
|
+
let d = l.get("code");
|
|
396
428
|
if (!d)
|
|
397
|
-
throw await e.storage.removeItem(
|
|
429
|
+
throw await e.storage.removeItem(v), new o(
|
|
398
430
|
"invalid_config",
|
|
399
431
|
"callbackUrl n\xE3o cont\xE9m `?code=` nem `?error=` \u2014 n\xE3o \xE9 um callback OIDC v\xE1lido."
|
|
400
432
|
);
|
|
401
|
-
let
|
|
402
|
-
if (
|
|
433
|
+
let c = l.get("state"), m = await e.storage.getItem(v), g = null;
|
|
434
|
+
if (m)
|
|
403
435
|
try {
|
|
404
|
-
g = JSON.parse(
|
|
436
|
+
g = JSON.parse(m);
|
|
405
437
|
} catch {
|
|
406
438
|
g = null;
|
|
407
439
|
}
|
|
408
440
|
if (!g)
|
|
409
|
-
throw new
|
|
441
|
+
throw new o(
|
|
410
442
|
"oidc_state_mismatch",
|
|
411
443
|
"Callback OIDC sem transa\xE7\xE3o pendente \u2014 `signIn` n\xE3o foi iniciado (ou j\xE1 consumido)."
|
|
412
444
|
);
|
|
413
|
-
if (!
|
|
414
|
-
throw await e.storage.removeItem(
|
|
445
|
+
if (!c || c !== g.state)
|
|
446
|
+
throw await e.storage.removeItem(v), new o(
|
|
415
447
|
"oidc_state_mismatch",
|
|
416
448
|
"state do callback OIDC n\xE3o confere com o da transa\xE7\xE3o (poss\xEDvel CSRF)."
|
|
417
449
|
);
|
|
418
|
-
await e.storage.removeItem(
|
|
419
|
-
let
|
|
450
|
+
await e.storage.removeItem(v);
|
|
451
|
+
let b = O(e), _ = new URLSearchParams({
|
|
420
452
|
grant_type: "authorization_code",
|
|
421
453
|
code: d,
|
|
422
454
|
redirect_uri: g.redirectUri,
|
|
423
|
-
client_id:
|
|
455
|
+
client_id: b,
|
|
424
456
|
code_verifier: g.codeVerifier
|
|
425
|
-
}),
|
|
426
|
-
if (typeof
|
|
427
|
-
throw new
|
|
457
|
+
}), S = await ie(e.fetchImpl, i(), _), T = S.id_token;
|
|
458
|
+
if (typeof T != "string" || T.length === 0)
|
|
459
|
+
throw new o(
|
|
428
460
|
"token_exchange_failed",
|
|
429
461
|
"Resposta do /token sem `id_token` \u2014 o login n\xE3o pode ser completado."
|
|
430
462
|
);
|
|
431
|
-
let
|
|
432
|
-
if (
|
|
433
|
-
throw new
|
|
463
|
+
let q = L(T);
|
|
464
|
+
if (!q)
|
|
465
|
+
throw new o(
|
|
434
466
|
"token_exchange_failed",
|
|
435
467
|
"id_token retornado pelo /token \xE9 malformado (payload indecodific\xE1vel)."
|
|
436
468
|
);
|
|
437
|
-
if (
|
|
438
|
-
throw new
|
|
469
|
+
if (q.nonce !== g.nonce)
|
|
470
|
+
throw new o(
|
|
439
471
|
"oidc_nonce_mismatch",
|
|
440
472
|
"nonce do id_token n\xE3o confere com o da transa\xE7\xE3o OIDC (poss\xEDvel replay). Token descartado."
|
|
441
473
|
);
|
|
442
|
-
let
|
|
443
|
-
if (!
|
|
444
|
-
throw new
|
|
474
|
+
let H = A(T);
|
|
475
|
+
if (!H)
|
|
476
|
+
throw new o(
|
|
445
477
|
"token_exchange_failed",
|
|
446
478
|
"id_token retornado pelo /token n\xE3o tem `sub` ou j\xE1 est\xE1 expirado."
|
|
447
479
|
);
|
|
448
|
-
await e.storage.setItem(
|
|
449
|
-
let M =
|
|
450
|
-
return typeof M == "string" && M.length > 0 && await e.storage.setItem(
|
|
480
|
+
await e.storage.setItem(E, T);
|
|
481
|
+
let M = S.refresh_token;
|
|
482
|
+
return typeof M == "string" && M.length > 0 && await e.storage.setItem(U, M), await w(S.access_token), await a(), { user: H, postLoginRedirect: g.postLoginRedirect };
|
|
451
483
|
}
|
|
452
|
-
async function
|
|
453
|
-
let r = await e.storage.getItem(
|
|
454
|
-
return r &&
|
|
484
|
+
async function y() {
|
|
485
|
+
let r = await e.storage.getItem(E);
|
|
486
|
+
return r && A(r) ? r : null;
|
|
455
487
|
}
|
|
456
488
|
async function h() {
|
|
457
|
-
let r = await e.storage.getItem(
|
|
458
|
-
return r ?
|
|
489
|
+
let r = await e.storage.getItem(E);
|
|
490
|
+
return r ? A(r) : null;
|
|
459
491
|
}
|
|
460
492
|
async function w(r) {
|
|
461
493
|
typeof r == "string" && r.length > 0 ? await e.storage.setItem(C, r) : await e.storage.removeItem(C);
|
|
462
494
|
}
|
|
463
|
-
let
|
|
495
|
+
let k = null;
|
|
464
496
|
function N() {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
497
|
+
if (k) return k;
|
|
498
|
+
let r = { abandoned: false };
|
|
499
|
+
return k = oe(ae(r), 15e3, () => (r.abandoned = true, false)).finally(() => {
|
|
500
|
+
k = null;
|
|
501
|
+
}), k;
|
|
468
502
|
}
|
|
469
|
-
async function
|
|
470
|
-
let
|
|
471
|
-
if (!
|
|
472
|
-
let
|
|
503
|
+
async function ae(r = { abandoned: false }) {
|
|
504
|
+
let s = await e.storage.getItem(U);
|
|
505
|
+
if (!s) return false;
|
|
506
|
+
let l;
|
|
473
507
|
try {
|
|
474
|
-
|
|
508
|
+
l = O(e);
|
|
475
509
|
} catch {
|
|
476
510
|
return false;
|
|
477
511
|
}
|
|
478
|
-
let
|
|
512
|
+
let u = new URLSearchParams({
|
|
479
513
|
grant_type: "refresh_token",
|
|
480
|
-
refresh_token:
|
|
481
|
-
client_id:
|
|
482
|
-
}),
|
|
514
|
+
refresh_token: s,
|
|
515
|
+
client_id: l
|
|
516
|
+
}), d;
|
|
483
517
|
try {
|
|
484
|
-
|
|
518
|
+
d = await ie(e.fetchImpl, i(), u);
|
|
485
519
|
} catch {
|
|
486
520
|
return false;
|
|
487
521
|
}
|
|
488
|
-
let
|
|
489
|
-
if (typeof
|
|
490
|
-
await e.storage.setItem(
|
|
491
|
-
let
|
|
492
|
-
return typeof
|
|
522
|
+
let c = d.id_token;
|
|
523
|
+
if (typeof c != "string" || c.length === 0 || !A(c) || r.abandoned) return false;
|
|
524
|
+
await e.storage.setItem(E, c);
|
|
525
|
+
let g = d.refresh_token;
|
|
526
|
+
return typeof g == "string" && g.length > 0 && await e.storage.setItem(U, g), await w(d.access_token), await a(), true;
|
|
493
527
|
}
|
|
494
528
|
async function P() {
|
|
495
529
|
let r = await e.storage.getItem(C);
|
|
496
530
|
if (!r) return null;
|
|
497
|
-
let
|
|
498
|
-
return
|
|
531
|
+
let s = Ie(r);
|
|
532
|
+
return s === null || s - ve <= Date.now() ? null : r;
|
|
499
533
|
}
|
|
500
534
|
async function D() {
|
|
501
535
|
let r = await P();
|
|
502
536
|
return r || (await N() ? P() : null);
|
|
503
537
|
}
|
|
504
|
-
async function
|
|
505
|
-
let r = `${
|
|
506
|
-
let { headers: g, correlationId:
|
|
538
|
+
async function ce() {
|
|
539
|
+
let r = `${I(e.baseUrl)}${Re}`, s = async (m) => {
|
|
540
|
+
let { headers: g, correlationId: b } = K({
|
|
507
541
|
accept: "application/json",
|
|
508
|
-
authorization: `Bearer ${
|
|
542
|
+
authorization: `Bearer ${m}`
|
|
509
543
|
});
|
|
510
544
|
try {
|
|
511
|
-
return { res: await e.fetchImpl(r, { method: "GET", headers: g }), correlationId:
|
|
512
|
-
} catch (
|
|
513
|
-
throw new
|
|
545
|
+
return { res: await e.fetchImpl(r, { method: "GET", headers: g }), correlationId: b };
|
|
546
|
+
} catch (_) {
|
|
547
|
+
throw new o(
|
|
514
548
|
"network_error",
|
|
515
|
-
`GET ${r} falhou (network): ${
|
|
549
|
+
`GET ${r} falhou (network): ${_?.message ?? String(_)}`,
|
|
516
550
|
void 0,
|
|
517
551
|
void 0,
|
|
518
552
|
void 0,
|
|
519
|
-
|
|
553
|
+
b
|
|
520
554
|
);
|
|
521
555
|
}
|
|
522
|
-
},
|
|
523
|
-
if (!
|
|
524
|
-
throw new
|
|
556
|
+
}, l = await D();
|
|
557
|
+
if (!l)
|
|
558
|
+
throw new R(
|
|
525
559
|
"Sem sess\xE3o: fa\xE7a login (auth.signIn) antes de consultar o userinfo.",
|
|
526
560
|
"no_signed_in_user"
|
|
527
561
|
);
|
|
528
|
-
let { res:
|
|
529
|
-
if (
|
|
530
|
-
throw new
|
|
562
|
+
let { res: u, correlationId: d } = await s(l);
|
|
563
|
+
if (u.status === 401 && await N() && (l = await P(), l && ({ res: u, correlationId: d } = await s(l))), u.status === 401)
|
|
564
|
+
throw new R(
|
|
531
565
|
"O Core recusou a sess\xE3o (token revogado/expirado ou usu\xE1rio inativo). Fa\xE7a login novamente.",
|
|
532
566
|
"invalid_access_token",
|
|
533
567
|
401,
|
|
534
568
|
void 0,
|
|
535
569
|
d
|
|
536
570
|
);
|
|
537
|
-
let
|
|
571
|
+
let c;
|
|
538
572
|
try {
|
|
539
|
-
|
|
573
|
+
c = await u.json();
|
|
540
574
|
} catch {
|
|
541
|
-
|
|
575
|
+
c = void 0;
|
|
542
576
|
}
|
|
543
|
-
if (!
|
|
544
|
-
let
|
|
545
|
-
throw new
|
|
577
|
+
if (!u.ok) {
|
|
578
|
+
let m = c && typeof c == "object" && typeof c.error_description == "string" ? c.error_description : `HTTP ${u.status}`;
|
|
579
|
+
throw new o(re(u.status), `userinfo falhou: ${m}`, u.status, void 0, void 0, d);
|
|
546
580
|
}
|
|
547
|
-
if (!
|
|
548
|
-
throw new
|
|
549
|
-
return
|
|
581
|
+
if (!c || typeof c != "object" || typeof c.sub != "string")
|
|
582
|
+
throw new o("invalid_response", "userinfo sem `sub`.", u.status, void 0, void 0, d);
|
|
583
|
+
return c;
|
|
550
584
|
}
|
|
551
|
-
function
|
|
552
|
-
let
|
|
553
|
-
if (!
|
|
554
|
-
throw new
|
|
585
|
+
function le(r) {
|
|
586
|
+
let s = e.productApiUrl;
|
|
587
|
+
if (!s)
|
|
588
|
+
throw new o(
|
|
555
589
|
"invalid_config",
|
|
556
590
|
"auth.authFetch requer `productApiUrl` (URL da API do seu produto) no createMobileAuthNamespace."
|
|
557
591
|
);
|
|
558
|
-
let
|
|
592
|
+
let l;
|
|
559
593
|
if (/^[a-z][a-z0-9+.-]*:/i.test(r))
|
|
560
594
|
try {
|
|
561
|
-
|
|
595
|
+
l = new URL(r);
|
|
562
596
|
} catch {
|
|
563
|
-
throw new
|
|
597
|
+
throw new o("invalid_config", `URL inv\xE1lida: ${r}`);
|
|
564
598
|
}
|
|
565
599
|
else {
|
|
566
|
-
let
|
|
567
|
-
|
|
600
|
+
let u = s.pathname.replace(/\/+$/, ""), d = r.startsWith("/") ? r : `/${r}`;
|
|
601
|
+
l = new URL(`${s.origin}${u}${d}`);
|
|
568
602
|
}
|
|
569
|
-
if (
|
|
570
|
-
throw new
|
|
603
|
+
if (l.origin !== s.origin)
|
|
604
|
+
throw new o(
|
|
571
605
|
"invalid_config",
|
|
572
|
-
`auth.authFetch s\xF3 envia o access_token para a API do produto (${
|
|
606
|
+
`auth.authFetch s\xF3 envia o access_token para a API do produto (${s.origin}); recusado: ${l.origin}.`
|
|
573
607
|
);
|
|
574
|
-
return
|
|
608
|
+
return l.toString();
|
|
575
609
|
}
|
|
576
|
-
async function
|
|
577
|
-
let
|
|
578
|
-
new Headers(
|
|
579
|
-
|
|
610
|
+
async function ue(r, s = {}) {
|
|
611
|
+
let l = le(r), u = {};
|
|
612
|
+
new Headers(s.headers ?? {}).forEach((b, _) => {
|
|
613
|
+
u[_] = b;
|
|
580
614
|
});
|
|
581
|
-
let d = (
|
|
582
|
-
let { headers:
|
|
583
|
-
return e.fetchImpl(
|
|
584
|
-
},
|
|
585
|
-
if (!
|
|
586
|
-
throw new
|
|
615
|
+
let d = (b) => {
|
|
616
|
+
let { headers: _ } = K({ ...u, authorization: `Bearer ${b}` });
|
|
617
|
+
return e.fetchImpl(l, { ...s, headers: _ });
|
|
618
|
+
}, c = await D();
|
|
619
|
+
if (!c)
|
|
620
|
+
throw new R(
|
|
587
621
|
"Sem sess\xE3o: fa\xE7a login (auth.signIn) antes de chamar a API do produto.",
|
|
588
622
|
"no_signed_in_user"
|
|
589
623
|
);
|
|
590
|
-
let
|
|
591
|
-
return
|
|
624
|
+
let m = await d(c), g = s.body === void 0 || s.body === null || typeof s.body == "string";
|
|
625
|
+
return m.status === 401 && g && await N() && (c = await P(), c && (m = await d(c))), m;
|
|
626
|
+
}
|
|
627
|
+
async function $(r) {
|
|
628
|
+
try {
|
|
629
|
+
return await e.storage.getItem(r);
|
|
630
|
+
} catch {
|
|
631
|
+
return null;
|
|
632
|
+
}
|
|
592
633
|
}
|
|
593
|
-
async function
|
|
594
|
-
let r = await
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
634
|
+
async function de() {
|
|
635
|
+
let r = await $(U), s = await $(C), l = true;
|
|
636
|
+
for (let c of [E, U, C, v])
|
|
637
|
+
try {
|
|
638
|
+
await e.storage.removeItem(c);
|
|
639
|
+
} catch {
|
|
640
|
+
l = false;
|
|
641
|
+
}
|
|
642
|
+
let u = [];
|
|
643
|
+
r && u.push({ token: r, hint: "refresh_token" }), s && u.push({ token: s, hint: "access_token" });
|
|
644
|
+
let d = "skipped";
|
|
645
|
+
if (u.length > 0) {
|
|
646
|
+
let c = await Q(
|
|
647
|
+
e.fetchImpl,
|
|
648
|
+
I(e.baseUrl),
|
|
649
|
+
e.oidcClientId,
|
|
650
|
+
u
|
|
651
|
+
);
|
|
652
|
+
d = c ? "accepted" : "failed", !c && typeof console < "u" && console.warn(
|
|
653
|
+
"[neetru-sdk] mobile signOut: a revoga\xE7\xE3o no servidor n\xE3o foi confirmada. A sess\xE3o local foi encerrada, mas o refresh_token pode seguir v\xE1lido at\xE9 expirar. Trate o campo remoteRevocation do SignOutResult no produto."
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
return await a(null), { localSessionCleared: l, remoteRevocation: d };
|
|
605
657
|
}
|
|
606
658
|
return {
|
|
607
|
-
signIn:
|
|
608
|
-
completeSignIn:
|
|
609
|
-
getIdToken:
|
|
659
|
+
signIn: f,
|
|
660
|
+
completeSignIn: p,
|
|
661
|
+
getIdToken: y,
|
|
610
662
|
getAccessToken: D,
|
|
611
|
-
getUserInfo:
|
|
612
|
-
authFetch:
|
|
663
|
+
getUserInfo: ce,
|
|
664
|
+
authFetch: ue,
|
|
613
665
|
getUser: h,
|
|
614
666
|
onAuthStateChanged(r) {
|
|
615
|
-
return
|
|
616
|
-
if (
|
|
667
|
+
return n.add(r), h().then((s) => {
|
|
668
|
+
if (n.has(r))
|
|
617
669
|
try {
|
|
618
|
-
r(
|
|
670
|
+
r(s);
|
|
619
671
|
} catch {
|
|
620
672
|
}
|
|
621
673
|
}), () => {
|
|
622
|
-
|
|
674
|
+
n.delete(r);
|
|
623
675
|
};
|
|
624
676
|
},
|
|
625
677
|
refreshTokens: N,
|
|
626
|
-
signOut:
|
|
678
|
+
signOut: de
|
|
627
679
|
};
|
|
628
680
|
}
|
|
629
681
|
|
|
630
|
-
exports.createMobileAuthNamespace =
|
|
682
|
+
exports.createMobileAuthNamespace = Ge;
|