@broadcastingplatforms/sdk 0.0.0-dev.9cfcfc6
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/auth-CRWthQ_B.d.mts +1176 -0
- package/dist/auth-CRWthQ_B.d.ts +1176 -0
- package/dist/auth.d.mts +1 -0
- package/dist/auth.d.ts +1 -0
- package/dist/auth.js +456 -0
- package/dist/auth.mjs +433 -0
- package/dist/base-client-BmVTsKhL.d.mts +70 -0
- package/dist/base-client-Dk56EJj-.d.ts +70 -0
- package/dist/browser-client.d.mts +47 -0
- package/dist/browser-client.d.ts +47 -0
- package/dist/browser-client.js +1983 -0
- package/dist/browser-client.mjs +1952 -0
- package/dist/channels.d.mts +1 -0
- package/dist/channels.d.ts +1 -0
- package/dist/channels.js +78 -0
- package/dist/channels.mjs +55 -0
- package/dist/chat.d.mts +1 -0
- package/dist/chat.d.ts +1 -0
- package/dist/chat.js +105 -0
- package/dist/chat.mjs +80 -0
- package/dist/errors.d.mts +68 -0
- package/dist/errors.d.ts +68 -0
- package/dist/errors.js +151 -0
- package/dist/errors.mjs +127 -0
- package/dist/http.d.mts +1 -0
- package/dist/http.d.ts +1 -0
- package/dist/http.js +323 -0
- package/dist/http.mjs +298 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +2072 -0
- package/dist/index.mjs +2025 -0
- package/dist/realtime.d.mts +9 -0
- package/dist/realtime.d.ts +9 -0
- package/dist/realtime.js +1050 -0
- package/dist/realtime.mjs +1021 -0
- package/dist/resource.d.mts +1 -0
- package/dist/resource.d.ts +1 -0
- package/dist/resource.js +52 -0
- package/dist/resource.mjs +27 -0
- package/dist/server-client.d.mts +60 -0
- package/dist/server-client.d.ts +60 -0
- package/dist/server-client.js +1984 -0
- package/dist/server-client.mjs +1954 -0
- package/dist/storage.d.mts +149 -0
- package/dist/storage.d.ts +149 -0
- package/dist/storage.js +243 -0
- package/dist/storage.mjs +211 -0
- package/dist/streams.d.mts +1 -0
- package/dist/streams.d.ts +1 -0
- package/dist/streams.js +267 -0
- package/dist/streams.mjs +242 -0
- package/dist/types.d.mts +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +19 -0
- package/dist/types.mjs +1 -0
- package/package.json +139 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { l as CookiesStorageAdapter, j as CookieAccessors, k as CookieOptions, z as StorageAdapter } from './auth-CRWthQ_B.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Storage adapter implementations for auth token persistence.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Default cookie name used for auth tokens.
|
|
9
|
+
*/
|
|
10
|
+
declare const DEFAULT_AUTH_COOKIE_NAME = "auth_token";
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for the browser cookie storage adapter.
|
|
13
|
+
*/
|
|
14
|
+
interface BrowserCookieStorageOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Prefix applied to cookie names.
|
|
17
|
+
*/
|
|
18
|
+
cookiePrefix?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Cookie attributes for persisted values.
|
|
21
|
+
*/
|
|
22
|
+
cookieOptions?: CookieOptions;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Configuration for server-side cookie storage.
|
|
26
|
+
*/
|
|
27
|
+
interface ServerCookieStorageOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Cookie accessors from the hosting runtime.
|
|
30
|
+
*/
|
|
31
|
+
cookies: CookieAccessors;
|
|
32
|
+
/**
|
|
33
|
+
* Prefix applied to cookie names.
|
|
34
|
+
*/
|
|
35
|
+
cookiePrefix?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Cookie attributes for persisted values.
|
|
38
|
+
*/
|
|
39
|
+
cookieOptions?: CookieOptions;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Options for creating the default storage adapter.
|
|
43
|
+
*/
|
|
44
|
+
interface DefaultStorageAdapterOptions extends BrowserCookieStorageOptions {
|
|
45
|
+
/**
|
|
46
|
+
* Server-side cookie accessors when running in Node.
|
|
47
|
+
*/
|
|
48
|
+
cookies?: CookieAccessors;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Resolve the cookie name for a given storage key.
|
|
52
|
+
* @param prefix - Prefix applied to cookie names.
|
|
53
|
+
* @param key - Storage key.
|
|
54
|
+
* @returns Resolved cookie name.
|
|
55
|
+
*/
|
|
56
|
+
declare const resolveCookieName: (prefix: string, key: string) => string;
|
|
57
|
+
/**
|
|
58
|
+
* Normalize cookie accessor values into a string.
|
|
59
|
+
* @param value - Cookie accessor return value.
|
|
60
|
+
* @returns Normalized cookie value or null.
|
|
61
|
+
*/
|
|
62
|
+
declare const resolveCookieValue: (value: ReturnType<CookieAccessors["get"]>) => string | null;
|
|
63
|
+
/**
|
|
64
|
+
* Browser storage adapter backed by cookies.
|
|
65
|
+
*/
|
|
66
|
+
declare class BrowserCookieStorageAdapter implements CookiesStorageAdapter {
|
|
67
|
+
readonly cookiePrefix: string;
|
|
68
|
+
private readonly cookieOptions;
|
|
69
|
+
constructor(options?: BrowserCookieStorageOptions);
|
|
70
|
+
/**
|
|
71
|
+
* Read a cookie value.
|
|
72
|
+
*/
|
|
73
|
+
get(key: string): string | null;
|
|
74
|
+
/**
|
|
75
|
+
* Persist a cookie value.
|
|
76
|
+
*/
|
|
77
|
+
set(key: string, value: string): void;
|
|
78
|
+
/**
|
|
79
|
+
* Delete a persisted cookie value.
|
|
80
|
+
*/
|
|
81
|
+
delete(key: string): void;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Server-side storage adapter that delegates cookie operations to the host runtime.
|
|
85
|
+
*/
|
|
86
|
+
declare class ServerCookieAccessorsStorageAdapter implements CookiesStorageAdapter {
|
|
87
|
+
readonly cookiePrefix: string;
|
|
88
|
+
private readonly cookieOptions;
|
|
89
|
+
private readonly cookies;
|
|
90
|
+
constructor(options: ServerCookieStorageOptions);
|
|
91
|
+
/**
|
|
92
|
+
* Read a cookie value.
|
|
93
|
+
*/
|
|
94
|
+
get(key: string): string | null;
|
|
95
|
+
/**
|
|
96
|
+
* Persist a cookie value.
|
|
97
|
+
*/
|
|
98
|
+
set(key: string, value: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* Delete a persisted cookie value.
|
|
101
|
+
*/
|
|
102
|
+
delete(key: string): void;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Create a server-side cookie storage adapter from host cookie accessors.
|
|
107
|
+
*/
|
|
108
|
+
declare const createServerCookieStorageAdapter: (cookies: CookieAccessors, options?: Omit<ServerCookieStorageOptions, "cookies">) => ServerCookieAccessorsStorageAdapter;
|
|
109
|
+
/**
|
|
110
|
+
* In-memory storage adapter (useful for tests or SSR).
|
|
111
|
+
*/
|
|
112
|
+
declare class MemoryStorageAdapter implements StorageAdapter {
|
|
113
|
+
private readonly store;
|
|
114
|
+
/**
|
|
115
|
+
* Read a stored value.
|
|
116
|
+
*/
|
|
117
|
+
get(key: string): string | null;
|
|
118
|
+
/**
|
|
119
|
+
* Persist a stored value.
|
|
120
|
+
*/
|
|
121
|
+
set(key: string, value: string): void;
|
|
122
|
+
/**
|
|
123
|
+
* Delete a stored value.
|
|
124
|
+
*/
|
|
125
|
+
delete(key: string): void;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* SSR-safe storage adapter that performs no persistence.
|
|
129
|
+
*/
|
|
130
|
+
declare class NoopStorageAdapter implements StorageAdapter {
|
|
131
|
+
/**
|
|
132
|
+
* Read a stored value (always null).
|
|
133
|
+
*/
|
|
134
|
+
get(): string | null;
|
|
135
|
+
/**
|
|
136
|
+
* Persist a stored value (no-op).
|
|
137
|
+
*/
|
|
138
|
+
set(): void;
|
|
139
|
+
/**
|
|
140
|
+
* Delete a stored value (no-op).
|
|
141
|
+
*/
|
|
142
|
+
delete(): void;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Create the default storage adapter for the current runtime.
|
|
146
|
+
*/
|
|
147
|
+
declare const createDefaultStorageAdapter: (options?: DefaultStorageAdapterOptions) => StorageAdapter;
|
|
148
|
+
|
|
149
|
+
export { ServerCookieAccessorsStorageAdapter as BrowserCookieAccessorsStorageAdapter, BrowserCookieStorageAdapter, type BrowserCookieStorageOptions, DEFAULT_AUTH_COOKIE_NAME, type DefaultStorageAdapterOptions, MemoryStorageAdapter, NoopStorageAdapter, ServerCookieAccessorsStorageAdapter, type ServerCookieStorageOptions, createDefaultStorageAdapter, createServerCookieStorageAdapter, resolveCookieName, resolveCookieValue };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { l as CookiesStorageAdapter, j as CookieAccessors, k as CookieOptions, z as StorageAdapter } from './auth-CRWthQ_B.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Storage adapter implementations for auth token persistence.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Default cookie name used for auth tokens.
|
|
9
|
+
*/
|
|
10
|
+
declare const DEFAULT_AUTH_COOKIE_NAME = "auth_token";
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for the browser cookie storage adapter.
|
|
13
|
+
*/
|
|
14
|
+
interface BrowserCookieStorageOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Prefix applied to cookie names.
|
|
17
|
+
*/
|
|
18
|
+
cookiePrefix?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Cookie attributes for persisted values.
|
|
21
|
+
*/
|
|
22
|
+
cookieOptions?: CookieOptions;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Configuration for server-side cookie storage.
|
|
26
|
+
*/
|
|
27
|
+
interface ServerCookieStorageOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Cookie accessors from the hosting runtime.
|
|
30
|
+
*/
|
|
31
|
+
cookies: CookieAccessors;
|
|
32
|
+
/**
|
|
33
|
+
* Prefix applied to cookie names.
|
|
34
|
+
*/
|
|
35
|
+
cookiePrefix?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Cookie attributes for persisted values.
|
|
38
|
+
*/
|
|
39
|
+
cookieOptions?: CookieOptions;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Options for creating the default storage adapter.
|
|
43
|
+
*/
|
|
44
|
+
interface DefaultStorageAdapterOptions extends BrowserCookieStorageOptions {
|
|
45
|
+
/**
|
|
46
|
+
* Server-side cookie accessors when running in Node.
|
|
47
|
+
*/
|
|
48
|
+
cookies?: CookieAccessors;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Resolve the cookie name for a given storage key.
|
|
52
|
+
* @param prefix - Prefix applied to cookie names.
|
|
53
|
+
* @param key - Storage key.
|
|
54
|
+
* @returns Resolved cookie name.
|
|
55
|
+
*/
|
|
56
|
+
declare const resolveCookieName: (prefix: string, key: string) => string;
|
|
57
|
+
/**
|
|
58
|
+
* Normalize cookie accessor values into a string.
|
|
59
|
+
* @param value - Cookie accessor return value.
|
|
60
|
+
* @returns Normalized cookie value or null.
|
|
61
|
+
*/
|
|
62
|
+
declare const resolveCookieValue: (value: ReturnType<CookieAccessors["get"]>) => string | null;
|
|
63
|
+
/**
|
|
64
|
+
* Browser storage adapter backed by cookies.
|
|
65
|
+
*/
|
|
66
|
+
declare class BrowserCookieStorageAdapter implements CookiesStorageAdapter {
|
|
67
|
+
readonly cookiePrefix: string;
|
|
68
|
+
private readonly cookieOptions;
|
|
69
|
+
constructor(options?: BrowserCookieStorageOptions);
|
|
70
|
+
/**
|
|
71
|
+
* Read a cookie value.
|
|
72
|
+
*/
|
|
73
|
+
get(key: string): string | null;
|
|
74
|
+
/**
|
|
75
|
+
* Persist a cookie value.
|
|
76
|
+
*/
|
|
77
|
+
set(key: string, value: string): void;
|
|
78
|
+
/**
|
|
79
|
+
* Delete a persisted cookie value.
|
|
80
|
+
*/
|
|
81
|
+
delete(key: string): void;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Server-side storage adapter that delegates cookie operations to the host runtime.
|
|
85
|
+
*/
|
|
86
|
+
declare class ServerCookieAccessorsStorageAdapter implements CookiesStorageAdapter {
|
|
87
|
+
readonly cookiePrefix: string;
|
|
88
|
+
private readonly cookieOptions;
|
|
89
|
+
private readonly cookies;
|
|
90
|
+
constructor(options: ServerCookieStorageOptions);
|
|
91
|
+
/**
|
|
92
|
+
* Read a cookie value.
|
|
93
|
+
*/
|
|
94
|
+
get(key: string): string | null;
|
|
95
|
+
/**
|
|
96
|
+
* Persist a cookie value.
|
|
97
|
+
*/
|
|
98
|
+
set(key: string, value: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* Delete a persisted cookie value.
|
|
101
|
+
*/
|
|
102
|
+
delete(key: string): void;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Create a server-side cookie storage adapter from host cookie accessors.
|
|
107
|
+
*/
|
|
108
|
+
declare const createServerCookieStorageAdapter: (cookies: CookieAccessors, options?: Omit<ServerCookieStorageOptions, "cookies">) => ServerCookieAccessorsStorageAdapter;
|
|
109
|
+
/**
|
|
110
|
+
* In-memory storage adapter (useful for tests or SSR).
|
|
111
|
+
*/
|
|
112
|
+
declare class MemoryStorageAdapter implements StorageAdapter {
|
|
113
|
+
private readonly store;
|
|
114
|
+
/**
|
|
115
|
+
* Read a stored value.
|
|
116
|
+
*/
|
|
117
|
+
get(key: string): string | null;
|
|
118
|
+
/**
|
|
119
|
+
* Persist a stored value.
|
|
120
|
+
*/
|
|
121
|
+
set(key: string, value: string): void;
|
|
122
|
+
/**
|
|
123
|
+
* Delete a stored value.
|
|
124
|
+
*/
|
|
125
|
+
delete(key: string): void;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* SSR-safe storage adapter that performs no persistence.
|
|
129
|
+
*/
|
|
130
|
+
declare class NoopStorageAdapter implements StorageAdapter {
|
|
131
|
+
/**
|
|
132
|
+
* Read a stored value (always null).
|
|
133
|
+
*/
|
|
134
|
+
get(): string | null;
|
|
135
|
+
/**
|
|
136
|
+
* Persist a stored value (no-op).
|
|
137
|
+
*/
|
|
138
|
+
set(): void;
|
|
139
|
+
/**
|
|
140
|
+
* Delete a stored value (no-op).
|
|
141
|
+
*/
|
|
142
|
+
delete(): void;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Create the default storage adapter for the current runtime.
|
|
146
|
+
*/
|
|
147
|
+
declare const createDefaultStorageAdapter: (options?: DefaultStorageAdapterOptions) => StorageAdapter;
|
|
148
|
+
|
|
149
|
+
export { ServerCookieAccessorsStorageAdapter as BrowserCookieAccessorsStorageAdapter, BrowserCookieStorageAdapter, type BrowserCookieStorageOptions, DEFAULT_AUTH_COOKIE_NAME, type DefaultStorageAdapterOptions, MemoryStorageAdapter, NoopStorageAdapter, ServerCookieAccessorsStorageAdapter, type ServerCookieStorageOptions, createDefaultStorageAdapter, createServerCookieStorageAdapter, resolveCookieName, resolveCookieValue };
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
+
|
|
22
|
+
// src/storage.ts
|
|
23
|
+
var storage_exports = {};
|
|
24
|
+
__export(storage_exports, {
|
|
25
|
+
BrowserCookieAccessorsStorageAdapter: () => ServerCookieAccessorsStorageAdapter,
|
|
26
|
+
BrowserCookieStorageAdapter: () => BrowserCookieStorageAdapter,
|
|
27
|
+
DEFAULT_AUTH_COOKIE_NAME: () => DEFAULT_AUTH_COOKIE_NAME,
|
|
28
|
+
MemoryStorageAdapter: () => MemoryStorageAdapter,
|
|
29
|
+
NoopStorageAdapter: () => NoopStorageAdapter,
|
|
30
|
+
ServerCookieAccessorsStorageAdapter: () => ServerCookieAccessorsStorageAdapter,
|
|
31
|
+
createDefaultStorageAdapter: () => createDefaultStorageAdapter,
|
|
32
|
+
createServerCookieStorageAdapter: () => createServerCookieStorageAdapter,
|
|
33
|
+
resolveCookieName: () => resolveCookieName,
|
|
34
|
+
resolveCookieValue: () => resolveCookieValue
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(storage_exports);
|
|
37
|
+
var DEFAULT_AUTH_COOKIE_NAME = "auth_token";
|
|
38
|
+
var DEFAULT_COOKIE_OPTIONS = {
|
|
39
|
+
path: "/",
|
|
40
|
+
sameSite: "lax"
|
|
41
|
+
};
|
|
42
|
+
var isBrowser = () => typeof document !== "undefined";
|
|
43
|
+
var resolveCookieName = (prefix, key) => prefix ? `${prefix}${key}` : key;
|
|
44
|
+
var resolveCookieValue = (value) => {
|
|
45
|
+
if (value === null || value === void 0) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
if (typeof value === "string") {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
if (typeof value === "object" && typeof value.value === "string") {
|
|
52
|
+
return value.value;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
};
|
|
56
|
+
var decodeCookieValue = (value) => decodeURIComponent(value.replace(/\+/g, " "));
|
|
57
|
+
var encodeCookieValue = (value) => encodeURIComponent(value);
|
|
58
|
+
var readCookie = (name) => {
|
|
59
|
+
if (!isBrowser()) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const entries = document.cookie ? document.cookie.split("; ") : [];
|
|
63
|
+
for (const entry of entries) {
|
|
64
|
+
const [rawKey, ...rest] = entry.split("=");
|
|
65
|
+
if (rawKey && decodeCookieValue(rawKey) === name) {
|
|
66
|
+
return decodeCookieValue(rest.join("="));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
};
|
|
71
|
+
var writeCookie = (name, value, options) => {
|
|
72
|
+
if (!isBrowser()) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const parts = [`${encodeCookieValue(name)}=${encodeCookieValue(value)}`];
|
|
76
|
+
if (options.path) {
|
|
77
|
+
parts.push(`Path=${options.path}`);
|
|
78
|
+
}
|
|
79
|
+
if (options.domain) {
|
|
80
|
+
parts.push(`Domain=${options.domain}`);
|
|
81
|
+
}
|
|
82
|
+
if (options.sameSite) {
|
|
83
|
+
parts.push(`SameSite=${options.sameSite}`);
|
|
84
|
+
}
|
|
85
|
+
if (options.secure) {
|
|
86
|
+
parts.push("Secure");
|
|
87
|
+
}
|
|
88
|
+
if (options.expires instanceof Date) {
|
|
89
|
+
parts.push(`Expires=${options.expires.toUTCString()}`);
|
|
90
|
+
} else if (typeof options.expires === "number") {
|
|
91
|
+
const expires = /* @__PURE__ */ new Date();
|
|
92
|
+
expires.setDate(expires.getDate() + options.expires);
|
|
93
|
+
parts.push(`Expires=${expires.toUTCString()}`);
|
|
94
|
+
}
|
|
95
|
+
document.cookie = parts.join("; ");
|
|
96
|
+
};
|
|
97
|
+
var deleteCookie = (name, options) => {
|
|
98
|
+
if (!isBrowser()) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
writeCookie(name, "", { ...options, expires: /* @__PURE__ */ new Date(0) });
|
|
102
|
+
};
|
|
103
|
+
var BrowserCookieStorageAdapter = class {
|
|
104
|
+
constructor(options = {}) {
|
|
105
|
+
__publicField(this, "cookiePrefix");
|
|
106
|
+
__publicField(this, "cookieOptions");
|
|
107
|
+
this.cookiePrefix = options.cookiePrefix ?? "";
|
|
108
|
+
this.cookieOptions = { ...DEFAULT_COOKIE_OPTIONS, ...options.cookieOptions };
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Read a cookie value.
|
|
112
|
+
*/
|
|
113
|
+
get(key) {
|
|
114
|
+
const cookieName = resolveCookieName(this.cookiePrefix, key);
|
|
115
|
+
return readCookie(cookieName);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Persist a cookie value.
|
|
119
|
+
*/
|
|
120
|
+
set(key, value) {
|
|
121
|
+
const cookieName = resolveCookieName(this.cookiePrefix, key);
|
|
122
|
+
writeCookie(cookieName, value, this.cookieOptions);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Delete a persisted cookie value.
|
|
126
|
+
*/
|
|
127
|
+
delete(key) {
|
|
128
|
+
const cookieName = resolveCookieName(this.cookiePrefix, key);
|
|
129
|
+
deleteCookie(cookieName, this.cookieOptions);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
var ServerCookieAccessorsStorageAdapter = class {
|
|
133
|
+
constructor(options) {
|
|
134
|
+
__publicField(this, "cookiePrefix");
|
|
135
|
+
__publicField(this, "cookieOptions");
|
|
136
|
+
__publicField(this, "cookies");
|
|
137
|
+
this.cookies = options.cookies;
|
|
138
|
+
this.cookiePrefix = options.cookiePrefix ?? "";
|
|
139
|
+
this.cookieOptions = { ...DEFAULT_COOKIE_OPTIONS, ...options.cookieOptions };
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Read a cookie value.
|
|
143
|
+
*/
|
|
144
|
+
get(key) {
|
|
145
|
+
const cookieName = resolveCookieName(this.cookiePrefix, key);
|
|
146
|
+
const value = this.cookies.get(cookieName);
|
|
147
|
+
return resolveCookieValue(value);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Persist a cookie value.
|
|
151
|
+
*/
|
|
152
|
+
set(key, value) {
|
|
153
|
+
const cookieName = resolveCookieName(this.cookiePrefix, key);
|
|
154
|
+
this.cookies.set(cookieName, value, this.cookieOptions);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Delete a persisted cookie value.
|
|
158
|
+
*/
|
|
159
|
+
delete(key) {
|
|
160
|
+
const cookieName = resolveCookieName(this.cookiePrefix, key);
|
|
161
|
+
this.cookies.delete(cookieName, this.cookieOptions);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
var createServerCookieStorageAdapter = (cookies, options = {}) => new ServerCookieAccessorsStorageAdapter({
|
|
165
|
+
cookies,
|
|
166
|
+
cookiePrefix: options.cookiePrefix,
|
|
167
|
+
cookieOptions: options.cookieOptions
|
|
168
|
+
});
|
|
169
|
+
var MemoryStorageAdapter = class {
|
|
170
|
+
constructor() {
|
|
171
|
+
__publicField(this, "store", /* @__PURE__ */ new Map());
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Read a stored value.
|
|
175
|
+
*/
|
|
176
|
+
get(key) {
|
|
177
|
+
return this.store.get(key) ?? null;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Persist a stored value.
|
|
181
|
+
*/
|
|
182
|
+
set(key, value) {
|
|
183
|
+
this.store.set(key, value);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Delete a stored value.
|
|
187
|
+
*/
|
|
188
|
+
delete(key) {
|
|
189
|
+
this.store.delete(key);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
var NoopStorageAdapter = class {
|
|
193
|
+
/**
|
|
194
|
+
* Read a stored value (always null).
|
|
195
|
+
*/
|
|
196
|
+
get() {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Persist a stored value (no-op).
|
|
201
|
+
*/
|
|
202
|
+
set() {
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Delete a stored value (no-op).
|
|
206
|
+
*/
|
|
207
|
+
delete() {
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
var createDefaultStorageAdapter = (options = {}) => {
|
|
211
|
+
if (isBrowser()) {
|
|
212
|
+
if (options.cookies) {
|
|
213
|
+
return new ServerCookieAccessorsStorageAdapter({
|
|
214
|
+
cookies: options.cookies,
|
|
215
|
+
cookiePrefix: options.cookiePrefix,
|
|
216
|
+
cookieOptions: options.cookieOptions
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
return new BrowserCookieStorageAdapter(options);
|
|
220
|
+
}
|
|
221
|
+
if (options.cookies) {
|
|
222
|
+
return new ServerCookieAccessorsStorageAdapter({
|
|
223
|
+
cookies: options.cookies,
|
|
224
|
+
cookiePrefix: options.cookiePrefix,
|
|
225
|
+
cookieOptions: options.cookieOptions
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
return new NoopStorageAdapter();
|
|
229
|
+
};
|
|
230
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
231
|
+
0 && (module.exports = {
|
|
232
|
+
BrowserCookieAccessorsStorageAdapter,
|
|
233
|
+
BrowserCookieStorageAdapter,
|
|
234
|
+
DEFAULT_AUTH_COOKIE_NAME,
|
|
235
|
+
MemoryStorageAdapter,
|
|
236
|
+
NoopStorageAdapter,
|
|
237
|
+
ServerCookieAccessorsStorageAdapter,
|
|
238
|
+
createDefaultStorageAdapter,
|
|
239
|
+
createServerCookieStorageAdapter,
|
|
240
|
+
resolveCookieName,
|
|
241
|
+
resolveCookieValue
|
|
242
|
+
});
|
|
243
|
+
//# sourceMappingURL=storage.js.map
|