@koolbase/core 12.36.0 → 12.38.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/dist/cjs/auth.js +8 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/memory-auth-storage.d.ts +12 -0
- package/dist/cjs/memory-auth-storage.js +23 -0
- package/dist/cjs/network.d.ts +9 -0
- package/dist/cjs/network.js +14 -1
- package/dist/cjs/types.d.ts +5 -0
- package/dist/esm/auth.js +8 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/memory-auth-storage.d.ts +12 -0
- package/dist/esm/memory-auth-storage.js +19 -0
- package/dist/esm/network.d.ts +9 -0
- package/dist/esm/network.js +13 -1
- package/dist/esm/types.d.ts +5 -0
- package/package.json +1 -1
package/dist/cjs/auth.js
CHANGED
|
@@ -392,6 +392,14 @@ class KoolbaseAuth {
|
|
|
392
392
|
if (params.nonce && params.nonce.length > 0) {
|
|
393
393
|
body.nonce = params.nonce;
|
|
394
394
|
}
|
|
395
|
+
// Exchanged by the server for the token it revokes when the account is
|
|
396
|
+
// deleted, as Apple asks.
|
|
397
|
+
if (params.authorizationCode && params.authorizationCode.length > 0) {
|
|
398
|
+
body.authorization_code = params.authorizationCode;
|
|
399
|
+
}
|
|
400
|
+
if (params.client) {
|
|
401
|
+
body.client = params.client;
|
|
402
|
+
}
|
|
395
403
|
if (params.fullName) {
|
|
396
404
|
const nameJson = {};
|
|
397
405
|
if (params.fullName.givenName)
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -23,6 +23,7 @@ exports.memoryPlatform = exports.getPlatform = exports.setPlatform = exports.Res
|
|
|
23
23
|
__exportStar(require("./types.js"), exports);
|
|
24
24
|
__exportStar(require("./errors.js"), exports);
|
|
25
25
|
__exportStar(require("./network.js"), exports);
|
|
26
|
+
__exportStar(require("./memory-auth-storage.js"), exports);
|
|
26
27
|
__exportStar(require("./aggregate.js"), exports);
|
|
27
28
|
__exportStar(require("./conflict.js"), exports);
|
|
28
29
|
__exportStar(require("./pending-write.js"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { KoolbaseAuthStorage, KoolbaseSession } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A session kept in memory only (R49): nothing survives the process. For
|
|
4
|
+
* tests -- Koolbase.initializeForTesting uses it -- and for a host that must
|
|
5
|
+
* not persist a session. The twin of the Flutter SDK's InMemoryAuthStorage.
|
|
6
|
+
*/
|
|
7
|
+
export declare class MemoryAuthStorage implements KoolbaseAuthStorage {
|
|
8
|
+
private session;
|
|
9
|
+
saveSession(session: KoolbaseSession): Promise<void>;
|
|
10
|
+
readSession(): Promise<KoolbaseSession | null>;
|
|
11
|
+
clear(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemoryAuthStorage = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* A session kept in memory only (R49): nothing survives the process. For
|
|
6
|
+
* tests -- Koolbase.initializeForTesting uses it -- and for a host that must
|
|
7
|
+
* not persist a session. The twin of the Flutter SDK's InMemoryAuthStorage.
|
|
8
|
+
*/
|
|
9
|
+
class MemoryAuthStorage {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.session = null;
|
|
12
|
+
}
|
|
13
|
+
async saveSession(session) {
|
|
14
|
+
this.session = session;
|
|
15
|
+
}
|
|
16
|
+
async readSession() {
|
|
17
|
+
return this.session;
|
|
18
|
+
}
|
|
19
|
+
async clear() {
|
|
20
|
+
this.session = null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.MemoryAuthStorage = MemoryAuthStorage;
|
package/dist/cjs/network.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FetchLike } from './types.js';
|
|
1
2
|
/**
|
|
2
3
|
* Network failures, made actionable.
|
|
3
4
|
*
|
|
@@ -17,6 +18,14 @@ export declare class KoolbaseNetworkError extends TypeError {
|
|
|
17
18
|
readonly origin?: string;
|
|
18
19
|
constructor(url: string, cause: unknown);
|
|
19
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Installed by Koolbase.initialize from KoolbaseConfig.fetch: the fetch every
|
|
23
|
+
* JSON request the SDK makes goes through -- a proxy, a logger, or a test's
|
|
24
|
+
* own server (initializeForTesting). Null is the global fetch, read at each
|
|
25
|
+
* call. File bytes sent to a storage URL are not JSON requests and use the
|
|
26
|
+
* global fetch.
|
|
27
|
+
*/
|
|
28
|
+
export declare function setFetch(fn: FetchLike | null): void;
|
|
20
29
|
/** fetch, with network failures turned into a KoolbaseNetworkError, and a
|
|
21
30
|
* failed answer traced in a development build (#169). */
|
|
22
31
|
export declare function koolbaseFetch(input: string, init?: RequestInit): Promise<Response>;
|
package/dist/cjs/network.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.KoolbaseNetworkError = void 0;
|
|
4
|
+
exports.setFetch = setFetch;
|
|
4
5
|
exports.koolbaseFetch = koolbaseFetch;
|
|
5
6
|
exports.setSessionRenewal = setSessionRenewal;
|
|
6
7
|
exports.sessionFetch = sessionFetch;
|
|
@@ -42,11 +43,23 @@ class KoolbaseNetworkError extends TypeError {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
exports.KoolbaseNetworkError = KoolbaseNetworkError;
|
|
46
|
+
// ─── The fetch every JSON request goes through (R49) ───────────────────
|
|
47
|
+
let installedFetch = null;
|
|
48
|
+
/**
|
|
49
|
+
* Installed by Koolbase.initialize from KoolbaseConfig.fetch: the fetch every
|
|
50
|
+
* JSON request the SDK makes goes through -- a proxy, a logger, or a test's
|
|
51
|
+
* own server (initializeForTesting). Null is the global fetch, read at each
|
|
52
|
+
* call. File bytes sent to a storage URL are not JSON requests and use the
|
|
53
|
+
* global fetch.
|
|
54
|
+
*/
|
|
55
|
+
function setFetch(fn) {
|
|
56
|
+
installedFetch = fn;
|
|
57
|
+
}
|
|
45
58
|
/** fetch, with network failures turned into a KoolbaseNetworkError. Not
|
|
46
59
|
* logged: sessionFetch's first attempt may yet be answered by renewal. */
|
|
47
60
|
async function sendOnce(input, init) {
|
|
48
61
|
try {
|
|
49
|
-
return await fetch(input, init);
|
|
62
|
+
return await (installedFetch ?? fetch)(input, init);
|
|
50
63
|
}
|
|
51
64
|
catch (e) {
|
|
52
65
|
// A request the caller cancelled keeps its meaning.
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -602,6 +602,11 @@ export interface SignInWithAppleParams {
|
|
|
602
602
|
identityToken: string;
|
|
603
603
|
nonce?: string;
|
|
604
604
|
fullName?: AppleFullName;
|
|
605
|
+
/** The credential's authorization code: the server exchanges it for the
|
|
606
|
+
* token it revokes when the account is deleted, as Apple asks. */
|
|
607
|
+
authorizationCode?: string;
|
|
608
|
+
/** 'web' when the code came from Apple's web sign-in (the services id). */
|
|
609
|
+
client?: 'web';
|
|
605
610
|
}
|
|
606
611
|
/**
|
|
607
612
|
* Parameters for `KoolbaseAuth.signInWithGoogle`. The SDK is
|
package/dist/esm/auth.js
CHANGED
|
@@ -389,6 +389,14 @@ export class KoolbaseAuth {
|
|
|
389
389
|
if (params.nonce && params.nonce.length > 0) {
|
|
390
390
|
body.nonce = params.nonce;
|
|
391
391
|
}
|
|
392
|
+
// Exchanged by the server for the token it revokes when the account is
|
|
393
|
+
// deleted, as Apple asks.
|
|
394
|
+
if (params.authorizationCode && params.authorizationCode.length > 0) {
|
|
395
|
+
body.authorization_code = params.authorizationCode;
|
|
396
|
+
}
|
|
397
|
+
if (params.client) {
|
|
398
|
+
body.client = params.client;
|
|
399
|
+
}
|
|
392
400
|
if (params.fullName) {
|
|
393
401
|
const nameJson = {};
|
|
394
402
|
if (params.fullName.givenName)
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { KoolbaseAuthStorage, KoolbaseSession } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A session kept in memory only (R49): nothing survives the process. For
|
|
4
|
+
* tests -- Koolbase.initializeForTesting uses it -- and for a host that must
|
|
5
|
+
* not persist a session. The twin of the Flutter SDK's InMemoryAuthStorage.
|
|
6
|
+
*/
|
|
7
|
+
export declare class MemoryAuthStorage implements KoolbaseAuthStorage {
|
|
8
|
+
private session;
|
|
9
|
+
saveSession(session: KoolbaseSession): Promise<void>;
|
|
10
|
+
readSession(): Promise<KoolbaseSession | null>;
|
|
11
|
+
clear(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A session kept in memory only (R49): nothing survives the process. For
|
|
3
|
+
* tests -- Koolbase.initializeForTesting uses it -- and for a host that must
|
|
4
|
+
* not persist a session. The twin of the Flutter SDK's InMemoryAuthStorage.
|
|
5
|
+
*/
|
|
6
|
+
export class MemoryAuthStorage {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.session = null;
|
|
9
|
+
}
|
|
10
|
+
async saveSession(session) {
|
|
11
|
+
this.session = session;
|
|
12
|
+
}
|
|
13
|
+
async readSession() {
|
|
14
|
+
return this.session;
|
|
15
|
+
}
|
|
16
|
+
async clear() {
|
|
17
|
+
this.session = null;
|
|
18
|
+
}
|
|
19
|
+
}
|
package/dist/esm/network.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FetchLike } from './types.js';
|
|
1
2
|
/**
|
|
2
3
|
* Network failures, made actionable.
|
|
3
4
|
*
|
|
@@ -17,6 +18,14 @@ export declare class KoolbaseNetworkError extends TypeError {
|
|
|
17
18
|
readonly origin?: string;
|
|
18
19
|
constructor(url: string, cause: unknown);
|
|
19
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Installed by Koolbase.initialize from KoolbaseConfig.fetch: the fetch every
|
|
23
|
+
* JSON request the SDK makes goes through -- a proxy, a logger, or a test's
|
|
24
|
+
* own server (initializeForTesting). Null is the global fetch, read at each
|
|
25
|
+
* call. File bytes sent to a storage URL are not JSON requests and use the
|
|
26
|
+
* global fetch.
|
|
27
|
+
*/
|
|
28
|
+
export declare function setFetch(fn: FetchLike | null): void;
|
|
20
29
|
/** fetch, with network failures turned into a KoolbaseNetworkError, and a
|
|
21
30
|
* failed answer traced in a development build (#169). */
|
|
22
31
|
export declare function koolbaseFetch(input: string, init?: RequestInit): Promise<Response>;
|
package/dist/esm/network.js
CHANGED
|
@@ -35,11 +35,23 @@ export class KoolbaseNetworkError extends TypeError {
|
|
|
35
35
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
+
// ─── The fetch every JSON request goes through (R49) ───────────────────
|
|
39
|
+
let installedFetch = null;
|
|
40
|
+
/**
|
|
41
|
+
* Installed by Koolbase.initialize from KoolbaseConfig.fetch: the fetch every
|
|
42
|
+
* JSON request the SDK makes goes through -- a proxy, a logger, or a test's
|
|
43
|
+
* own server (initializeForTesting). Null is the global fetch, read at each
|
|
44
|
+
* call. File bytes sent to a storage URL are not JSON requests and use the
|
|
45
|
+
* global fetch.
|
|
46
|
+
*/
|
|
47
|
+
export function setFetch(fn) {
|
|
48
|
+
installedFetch = fn;
|
|
49
|
+
}
|
|
38
50
|
/** fetch, with network failures turned into a KoolbaseNetworkError. Not
|
|
39
51
|
* logged: sessionFetch's first attempt may yet be answered by renewal. */
|
|
40
52
|
async function sendOnce(input, init) {
|
|
41
53
|
try {
|
|
42
|
-
return await fetch(input, init);
|
|
54
|
+
return await (installedFetch ?? fetch)(input, init);
|
|
43
55
|
}
|
|
44
56
|
catch (e) {
|
|
45
57
|
// A request the caller cancelled keeps its meaning.
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -602,6 +602,11 @@ export interface SignInWithAppleParams {
|
|
|
602
602
|
identityToken: string;
|
|
603
603
|
nonce?: string;
|
|
604
604
|
fullName?: AppleFullName;
|
|
605
|
+
/** The credential's authorization code: the server exchanges it for the
|
|
606
|
+
* token it revokes when the account is deleted, as Apple asks. */
|
|
607
|
+
authorizationCode?: string;
|
|
608
|
+
/** 'web' when the code came from Apple's web sign-in (the services id). */
|
|
609
|
+
client?: 'web';
|
|
605
610
|
}
|
|
606
611
|
/**
|
|
607
612
|
* Parameters for `KoolbaseAuth.signInWithGoogle`. The SDK is
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koolbase/core",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.38.0",
|
|
4
4
|
"description": "Koolbase SDK core \u2014 shared behaviour behind @koolbase/react-native and @koolbase/js. Install one of those, not this.",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"types": "./dist/esm/index.d.ts",
|