@somewhere-cloud/sdk 0.0.0-stage → 0.13.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/LICENSE +21 -0
- package/README.md +191 -2
- package/dist/cjs/auth/client.js +1059 -0
- package/dist/cjs/auth/client.js.map +1 -0
- package/dist/cjs/auth/continuation.js +27 -0
- package/dist/cjs/auth/continuation.js.map +1 -0
- package/dist/cjs/auth/index.js +21 -0
- package/dist/cjs/auth/index.js.map +1 -0
- package/dist/cjs/auth/react.js +295 -0
- package/dist/cjs/auth/react.js.map +1 -0
- package/dist/cjs/auth/server.js +368 -0
- package/dist/cjs/auth/server.js.map +1 -0
- package/dist/cjs/client.js +392 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/errors.js +16 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.cjs +215 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/query-cache.js +91 -0
- package/dist/cjs/query-cache.js.map +1 -0
- package/dist/cjs/resources/auth.js +875 -0
- package/dist/cjs/resources/auth.js.map +1 -0
- package/dist/cjs/resources/calls.js +42 -0
- package/dist/cjs/resources/calls.js.map +1 -0
- package/dist/cjs/resources/chat.js +82 -0
- package/dist/cjs/resources/chat.js.map +1 -0
- package/dist/cjs/resources/db.js +124 -0
- package/dist/cjs/resources/db.js.map +1 -0
- package/dist/cjs/resources/emails.js +39 -0
- package/dist/cjs/resources/emails.js.map +1 -0
- package/dist/cjs/resources/fs.js +141 -0
- package/dist/cjs/resources/fs.js.map +1 -0
- package/dist/cjs/resources/functions.js +145 -0
- package/dist/cjs/resources/functions.js.map +1 -0
- package/dist/cjs/resources/inbox.js +76 -0
- package/dist/cjs/resources/inbox.js.map +1 -0
- package/dist/cjs/resources/payments.js +68 -0
- package/dist/cjs/resources/payments.js.map +1 -0
- package/dist/cjs/resources/postgrest.js +391 -0
- package/dist/cjs/resources/postgrest.js.map +1 -0
- package/dist/cjs/resources/projects.js +71 -0
- package/dist/cjs/resources/projects.js.map +1 -0
- package/dist/cjs/resources/storage.js +191 -0
- package/dist/cjs/resources/storage.js.map +1 -0
- package/dist/cjs/resources/tasks.js +99 -0
- package/dist/cjs/resources/tasks.js.map +1 -0
- package/dist/cjs/resources/video.js +50 -0
- package/dist/cjs/resources/video.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/auth/client.js +1054 -0
- package/dist/esm/auth/client.js.map +1 -0
- package/dist/esm/auth/continuation.js +22 -0
- package/dist/esm/auth/continuation.js.map +1 -0
- package/dist/esm/auth/index.js +5 -0
- package/dist/esm/auth/index.js.map +1 -0
- package/dist/esm/auth/react.js +279 -0
- package/dist/esm/auth/react.js.map +1 -0
- package/dist/esm/auth/server.js +365 -0
- package/dist/esm/auth/server.js.map +1 -0
- package/dist/esm/client.js +388 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/errors.js +12 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.js +188 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/query-cache.js +87 -0
- package/dist/esm/query-cache.js.map +1 -0
- package/dist/esm/resources/auth.js +871 -0
- package/dist/esm/resources/auth.js.map +1 -0
- package/dist/esm/resources/calls.js +38 -0
- package/dist/esm/resources/calls.js.map +1 -0
- package/dist/esm/resources/chat.js +77 -0
- package/dist/esm/resources/chat.js.map +1 -0
- package/dist/esm/resources/db.js +120 -0
- package/dist/esm/resources/db.js.map +1 -0
- package/dist/esm/resources/emails.js +35 -0
- package/dist/esm/resources/emails.js.map +1 -0
- package/dist/esm/resources/fs.js +137 -0
- package/dist/esm/resources/fs.js.map +1 -0
- package/dist/esm/resources/functions.js +141 -0
- package/dist/esm/resources/functions.js.map +1 -0
- package/dist/esm/resources/inbox.js +70 -0
- package/dist/esm/resources/inbox.js.map +1 -0
- package/dist/esm/resources/payments.js +64 -0
- package/dist/esm/resources/payments.js.map +1 -0
- package/dist/esm/resources/postgrest.js +386 -0
- package/dist/esm/resources/postgrest.js.map +1 -0
- package/dist/esm/resources/projects.js +67 -0
- package/dist/esm/resources/projects.js.map +1 -0
- package/dist/esm/resources/storage.js +186 -0
- package/dist/esm/resources/storage.js.map +1 -0
- package/dist/esm/resources/tasks.js +95 -0
- package/dist/esm/resources/tasks.js.map +1 -0
- package/dist/esm/resources/video.js +46 -0
- package/dist/esm/resources/video.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/types/auth/client.d.ts +272 -0
- package/dist/types/auth/client.d.ts.map +1 -0
- package/dist/types/auth/continuation.d.ts +10 -0
- package/dist/types/auth/continuation.d.ts.map +1 -0
- package/dist/types/auth/index.d.ts +2 -0
- package/dist/types/auth/index.d.ts.map +1 -0
- package/dist/types/auth/react.d.ts +140 -0
- package/dist/types/auth/react.d.ts.map +1 -0
- package/dist/types/auth/server.d.ts +124 -0
- package/dist/types/auth/server.d.ts.map +1 -0
- package/dist/types/client.d.ts +128 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/errors.d.ts +17 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/index.d.ts +145 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/query-cache.d.ts +59 -0
- package/dist/types/query-cache.d.ts.map +1 -0
- package/dist/types/resources/auth.d.ts +188 -0
- package/dist/types/resources/auth.d.ts.map +1 -0
- package/dist/types/resources/calls.d.ts +27 -0
- package/dist/types/resources/calls.d.ts.map +1 -0
- package/dist/types/resources/chat.d.ts +24 -0
- package/dist/types/resources/chat.d.ts.map +1 -0
- package/dist/types/resources/db.d.ts +81 -0
- package/dist/types/resources/db.d.ts.map +1 -0
- package/dist/types/resources/emails.d.ts +20 -0
- package/dist/types/resources/emails.d.ts.map +1 -0
- package/dist/types/resources/fs.d.ts +68 -0
- package/dist/types/resources/fs.d.ts.map +1 -0
- package/dist/types/resources/functions.d.ts +30 -0
- package/dist/types/resources/functions.d.ts.map +1 -0
- package/dist/types/resources/inbox.d.ts +52 -0
- package/dist/types/resources/inbox.d.ts.map +1 -0
- package/dist/types/resources/payments.d.ts +31 -0
- package/dist/types/resources/payments.d.ts.map +1 -0
- package/dist/types/resources/postgrest.d.ts +121 -0
- package/dist/types/resources/postgrest.d.ts.map +1 -0
- package/dist/types/resources/projects.d.ts +79 -0
- package/dist/types/resources/projects.d.ts.map +1 -0
- package/dist/types/resources/storage.d.ts +63 -0
- package/dist/types/resources/storage.d.ts.map +1 -0
- package/dist/types/resources/tasks.d.ts +87 -0
- package/dist/types/resources/tasks.d.ts.map +1 -0
- package/dist/types/resources/video.d.ts +30 -0
- package/dist/types/resources/video.d.ts.map +1 -0
- package/dist/types/types.d.ts +379 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +86 -4
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { SomewhereError } from '../errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Prefix-oriented file API.
|
|
4
|
+
*
|
|
5
|
+
* Routes through `/v1/fs/*` (the platform's structured filesystem).
|
|
6
|
+
* "Buckets" are prefix directories under the project's file namespace:
|
|
7
|
+
* `sw.storage.from('avatars').upload('a.png', ...)` writes to
|
|
8
|
+
* `/v1/fs/{project_id}/avatars/a.png`.
|
|
9
|
+
*
|
|
10
|
+
* For browser uploads with per-user or per-team rules, declare a file
|
|
11
|
+
* collection in db/schema.ts and use the generated `somewhere:files` client
|
|
12
|
+
* instead: docs({ topic: 'declared-files' }).
|
|
13
|
+
*/
|
|
14
|
+
export class StorageClient {
|
|
15
|
+
constructor(client) {
|
|
16
|
+
this.client = client;
|
|
17
|
+
}
|
|
18
|
+
from(bucket) {
|
|
19
|
+
return new StorageFileApi(this.client, bucket);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class StorageFileApi {
|
|
23
|
+
constructor(client, bucket) {
|
|
24
|
+
this.client = client;
|
|
25
|
+
this.bucket = bucket;
|
|
26
|
+
}
|
|
27
|
+
async upload(path, fileBody, options = {}) {
|
|
28
|
+
const projectId = this.requireProjectId('upload');
|
|
29
|
+
const fullPath = this.fullKey(path);
|
|
30
|
+
try {
|
|
31
|
+
const result = await this.client.putBytes(`/fs/${enc(projectId)}/${encKey(fullPath)}`, fileBody, options.contentType ?? inferContentType(fileBody) ?? 'application/octet-stream');
|
|
32
|
+
return {
|
|
33
|
+
data: {
|
|
34
|
+
path,
|
|
35
|
+
fullPath: result.path ?? fullPath,
|
|
36
|
+
id: result.path ?? fullPath,
|
|
37
|
+
},
|
|
38
|
+
error: null,
|
|
39
|
+
status: 200,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
return toResultError(err);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async download(path) {
|
|
47
|
+
const projectId = this.requireProjectId('download');
|
|
48
|
+
const fullPath = this.fullKey(path);
|
|
49
|
+
try {
|
|
50
|
+
const result = await this.client.getBytes(`/fs/${enc(projectId)}/${encKey(fullPath)}`);
|
|
51
|
+
return { data: result, error: null, status: 200 };
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
return toResultError(err);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* List files in this bucket (or a sub-prefix).
|
|
59
|
+
* Routes to `GET /v1/fs/{pid}/{bucket}/{prefix}` which returns
|
|
60
|
+
* a directory listing when the path is a directory.
|
|
61
|
+
*/
|
|
62
|
+
async list(prefix = '', _options = {}) {
|
|
63
|
+
const projectId = this.requireProjectId('list');
|
|
64
|
+
const dirPath = prefix ? this.fullKey(prefix) : this.bucket;
|
|
65
|
+
try {
|
|
66
|
+
const result = await this.client.getBytes(`/fs/${enc(projectId)}/${encKey(dirPath)}`);
|
|
67
|
+
if (result.contentType.includes('application/json')) {
|
|
68
|
+
const text = new TextDecoder().decode(result.body);
|
|
69
|
+
const parsed = JSON.parse(text);
|
|
70
|
+
const data = parsed?.ok ? parsed.data : parsed;
|
|
71
|
+
if (data?.type === 'directory' && Array.isArray(data.entries)) {
|
|
72
|
+
const objects = data.entries.map((e) => ({
|
|
73
|
+
name: e.name,
|
|
74
|
+
size: e.size_bytes ?? 0,
|
|
75
|
+
content_type: e.content_type,
|
|
76
|
+
updated_at: e.updated_at,
|
|
77
|
+
}));
|
|
78
|
+
return { data: objects, error: null, status: 200 };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return { data: [], error: null, status: 200 };
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
return toResultError(err);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async remove(paths) {
|
|
88
|
+
const projectId = this.requireProjectId('remove');
|
|
89
|
+
const removed = [];
|
|
90
|
+
for (const p of paths) {
|
|
91
|
+
const fullPath = this.fullKey(p);
|
|
92
|
+
try {
|
|
93
|
+
await this.client.call('DELETE', `/fs/${enc(projectId)}/${encKey(fullPath)}`);
|
|
94
|
+
removed.push({ name: p, size: 0 });
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
return toResultError(err);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return { data: removed, error: null, status: 200 };
|
|
101
|
+
}
|
|
102
|
+
getPublicUrl(path) {
|
|
103
|
+
const projectId = this.requireProjectId('getPublicUrl');
|
|
104
|
+
const fullPath = this.fullKey(path);
|
|
105
|
+
const publicUrl = `${this.client.baseUrl}/fs/${enc(projectId)}/${encKey(fullPath)}`;
|
|
106
|
+
return { data: { publicUrl } };
|
|
107
|
+
}
|
|
108
|
+
async signedUrl(path, options = {}) {
|
|
109
|
+
const projectId = this.requireProjectId('signedUrl');
|
|
110
|
+
const fullPath = this.fullKey(path);
|
|
111
|
+
try {
|
|
112
|
+
const body = { path: '/' + fullPath };
|
|
113
|
+
if (typeof options.expiresIn === 'number')
|
|
114
|
+
body.expires_in = options.expiresIn;
|
|
115
|
+
const res = await this.client.call('POST', `/fs/${enc(projectId)}/sign`, body);
|
|
116
|
+
return { data: res, error: null, status: 200 };
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
return toResultError(err);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Alias of `signedUrl`. `createSignedUrl(path, expiresIn)` resolves to
|
|
124
|
+
* `{ data: { signedUrl, ...meta }, error }`.
|
|
125
|
+
*/
|
|
126
|
+
async createSignedUrl(path, expiresIn) {
|
|
127
|
+
const res = await this.signedUrl(path, { expiresIn });
|
|
128
|
+
if (res.error || !res.data) {
|
|
129
|
+
return { data: null, error: res.error, status: res.status };
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
data: { ...res.data, signedUrl: res.data.url },
|
|
133
|
+
error: null,
|
|
134
|
+
status: res.status,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
async integrityCheck(options = {}) {
|
|
138
|
+
const projectId = this.requireProjectId('integrityCheck');
|
|
139
|
+
try {
|
|
140
|
+
const body = {};
|
|
141
|
+
if (options.autoClean === true)
|
|
142
|
+
body.auto_clean = true;
|
|
143
|
+
if (typeof options.limit === 'number')
|
|
144
|
+
body.limit = options.limit;
|
|
145
|
+
if (typeof options.cursor === 'string')
|
|
146
|
+
body.cursor = options.cursor;
|
|
147
|
+
const res = await this.client.call('POST', `/fs/${enc(projectId)}/integrity-check`, body);
|
|
148
|
+
return { data: res, error: null, status: 200 };
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
return toResultError(err);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
fullKey(path) {
|
|
155
|
+
const trimmed = path.startsWith('/') ? path.slice(1) : path;
|
|
156
|
+
return `${this.bucket}/${trimmed}`;
|
|
157
|
+
}
|
|
158
|
+
requireProjectId(method) {
|
|
159
|
+
return this.client.requireProjectId(undefined, `storage.from('${this.bucket}').${method}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function enc(s) {
|
|
163
|
+
return encodeURIComponent(s);
|
|
164
|
+
}
|
|
165
|
+
function encKey(key) {
|
|
166
|
+
return key
|
|
167
|
+
.split('/')
|
|
168
|
+
.map(encodeURIComponent)
|
|
169
|
+
.join('/');
|
|
170
|
+
}
|
|
171
|
+
function inferContentType(body) {
|
|
172
|
+
if (typeof Blob !== 'undefined' && body instanceof Blob && body.type) {
|
|
173
|
+
return body.type;
|
|
174
|
+
}
|
|
175
|
+
if (typeof body === 'string') {
|
|
176
|
+
return 'text/plain; charset=utf-8';
|
|
177
|
+
}
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
function toResultError(err) {
|
|
181
|
+
if (err instanceof SomewhereError) {
|
|
182
|
+
return { data: null, error: err, status: err.statusCode };
|
|
183
|
+
}
|
|
184
|
+
throw err;
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/resources/storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAU9C;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,aAAa;IACxB,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE/C,IAAI,CAAC,MAAc;QACjB,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC;CACF;AAOD,MAAM,OAAO,cAAc;IACzB,YACmB,MAAc,EACd,MAAc;QADd,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAQ;IAC9B,CAAC;IAEJ,KAAK,CAAC,MAAM,CACV,IAAY,EACZ,QAAkB,EAClB,UAAyB,EAAE;QAE3B,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAClD,MAAM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AM,CAAC,gBAAgB,CACjC,SAAS,EACT,iBAAiB,IAAI,CAAC,MAAM,MAAM,MAAM,EAAE,CAC3C,CAAC;IACJ,CAAC;CACF;AAED,SAAS,GAAG,CAAC,CAAS;IACpB,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,MAAM,CAAC,GAAW;IACzB,OAAO,GAAG;SACP,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,kBAAkB,CAAC;SACvB,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAc;IACtC,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,YAAY,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACrE,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,2BAA2B,CAAC;IACrC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,aAAa,CAAI,GAAY;IACpC,IAAI,GAAG,YAAY,cAAc,EAAE,CAAC;QAClC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC;IAC5D,CAAC;IACD,MAAM,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { SomewhereError } from '../errors.js';
|
|
2
|
+
export class TasksClient {
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
}
|
|
6
|
+
async create(input) {
|
|
7
|
+
const projectId = this.client.requireProjectId(input.projectId, 'tasks.create');
|
|
8
|
+
const { projectId: _omit, ...rest } = input;
|
|
9
|
+
try {
|
|
10
|
+
const result = await this.client.call('POST', '/tasks', {
|
|
11
|
+
body: { project_id: projectId, ...rest },
|
|
12
|
+
});
|
|
13
|
+
return { data: result, error: null, status: 200 };
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
return toResultError(err);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async list(options = {}) {
|
|
20
|
+
const projectId = this.client.requireProjectId(options.projectId, 'tasks.list');
|
|
21
|
+
const q = new URLSearchParams({ project_id: projectId });
|
|
22
|
+
if (options.status) {
|
|
23
|
+
const v = Array.isArray(options.status) ? options.status[0] : options.status;
|
|
24
|
+
if (v)
|
|
25
|
+
q.set('status', v);
|
|
26
|
+
}
|
|
27
|
+
if (options.assignee)
|
|
28
|
+
q.set('assignee', options.assignee);
|
|
29
|
+
if (options.area)
|
|
30
|
+
q.set('area', options.area);
|
|
31
|
+
if (options.limit != null)
|
|
32
|
+
q.set('limit', String(options.limit));
|
|
33
|
+
try {
|
|
34
|
+
const result = await this.client.call('GET', `/tasks?${q}`);
|
|
35
|
+
const data = Array.isArray(result) ? result : (result?.tasks ?? []);
|
|
36
|
+
return { data, error: null, status: 200 };
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
return toResultError(err);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async get(id, options = {}) {
|
|
43
|
+
const projectId = this.client.requireProjectId(options.projectId, 'tasks.get');
|
|
44
|
+
try {
|
|
45
|
+
const result = await this.client.call('GET', `/tasks/${encodeURIComponent(id)}?project_id=${encodeURIComponent(projectId)}`);
|
|
46
|
+
return { data: result, error: null, status: 200 };
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
return toResultError(err);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async update(id, input) {
|
|
53
|
+
const projectId = this.client.requireProjectId(input.projectId, 'tasks.update');
|
|
54
|
+
const { projectId: _omit, ...rest } = input;
|
|
55
|
+
try {
|
|
56
|
+
const result = await this.client.call('PATCH', `/tasks/${encodeURIComponent(id)}`, {
|
|
57
|
+
body: { project_id: projectId, ...rest },
|
|
58
|
+
});
|
|
59
|
+
return { data: result, error: null, status: 200 };
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
return toResultError(err);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async delete(id, options = {}) {
|
|
66
|
+
const projectId = this.client.requireProjectId(options.projectId, 'tasks.delete');
|
|
67
|
+
try {
|
|
68
|
+
await this.client.call('DELETE', `/tasks/${encodeURIComponent(id)}?project_id=${encodeURIComponent(projectId)}`);
|
|
69
|
+
return { data: { deleted: true }, error: null, status: 200 };
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
return toResultError(err);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async comment(id, body, options = {}) {
|
|
76
|
+
const projectId = this.client.requireProjectId(options.projectId, 'tasks.comment');
|
|
77
|
+
try {
|
|
78
|
+
const result = await this.client.call('POST', `/tasks/${encodeURIComponent(id)}/comments`, { body: { project_id: projectId, body } });
|
|
79
|
+
return { data: result, error: null, status: 200 };
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
return toResultError(err);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function arr(v) {
|
|
87
|
+
return Array.isArray(v) ? v : [v];
|
|
88
|
+
}
|
|
89
|
+
function toResultError(err) {
|
|
90
|
+
if (err instanceof SomewhereError) {
|
|
91
|
+
return { data: null, error: err, status: err.statusCode };
|
|
92
|
+
}
|
|
93
|
+
throw err;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=tasks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../../src/resources/tasks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAsE9C,MAAM,OAAO,WAAW;IACtB,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE/C,KAAK,CAAC,MAAM,C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AAC,OAAO,CACX,EAAU,EACV,IAAY,EACZ,UAAkC,EAAE;QAEpC,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QACnF,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACnC,MAAM,EACN,UAAU,kBAAkB,CAAC,EAAE,CAAC,WAAW,EAC3C,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAC1C,CAAC;YACF,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;QACpD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;CACF;AAED,SAAS,GAAG,CAAI,CAAU;IACxB,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,aAAa,CAAI,GAAY;IACpC,IAAI,GAAG,YAAY,cAAc,EAAE,CAAC;QAClC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC;IAC5D,CAAC;IACD,MAAM,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Video upload + playback. The platform issues a one-time direct upload
|
|
3
|
+
* URL — bytes go straight from the user's browser to the upstream
|
|
4
|
+
* delivery network, never through the platform — then exposes
|
|
5
|
+
* playback URLs (HLS + DASH) and a thumbnail once the video is ready.
|
|
6
|
+
*
|
|
7
|
+
* // 1. Get a one-time upload URL (server side).
|
|
8
|
+
* const { data } = await sw.video.createUploadUrl({ title: 'demo' })
|
|
9
|
+
* // 2. POST the file bytes to data.upload_url from the browser.
|
|
10
|
+
* // 3. Poll for readiness.
|
|
11
|
+
* const v = await sw.video.get(data.video_id)
|
|
12
|
+
* if (v.data?.ready) play(v.data.hls_url)
|
|
13
|
+
*/
|
|
14
|
+
export class VideoClient {
|
|
15
|
+
constructor(client) {
|
|
16
|
+
this.client = client;
|
|
17
|
+
}
|
|
18
|
+
async createUploadUrl(input = {}) {
|
|
19
|
+
const project_id = this.client.requireProjectId(input.projectId, 'video.createUploadUrl');
|
|
20
|
+
return this.client.safeCall('POST', '/video/upload-url', {
|
|
21
|
+
auth: 'developer',
|
|
22
|
+
body: {
|
|
23
|
+
project_id,
|
|
24
|
+
title: input.title,
|
|
25
|
+
max_duration_seconds: input.max_duration_seconds,
|
|
26
|
+
require_signed_urls: input.require_signed_urls,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async list(opts = {}) {
|
|
31
|
+
const project_id = this.client.requireProjectId(opts.projectId, 'video.list');
|
|
32
|
+
return this.client.safeCall('GET', '/video', {
|
|
33
|
+
auth: 'developer',
|
|
34
|
+
query: { project_id, limit: opts.limit },
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async get(id) {
|
|
38
|
+
return this.client.safeCall('GET', `/video/${encodeURIComponent(id)}`, {
|
|
39
|
+
auth: 'developer',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async delete(id) {
|
|
43
|
+
return this.client.safeCall('DELETE', `/video/${encodeURIComponent(id)}`, { auth: 'developer' });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=video.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video.js","sourceRoot":"","sources":["../../../src/resources/video.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,WAAW;IACtB,YAA6B,MAAc;QAA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
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @somewhere-cloud/sdk/auth — framework-agnostic session client.
|
|
3
|
+
*
|
|
4
|
+
* ONLY-PATH CONTRACT (tsk_acd56ee8): a browser uses same-origin httpOnly
|
|
5
|
+
* cookie sessions and holds zero credentials. This package is an optional UI
|
|
6
|
+
* adapter over that runtime contract, not a new transport.
|
|
7
|
+
*
|
|
8
|
+
* Explicit header mode exists for scripts/native clients and compatibility
|
|
9
|
+
* with older browser integrations. In that mode it wraps fetch so that:
|
|
10
|
+
*
|
|
11
|
+
* 1. Every authed request carries `Authorization: Bearer <access>` AND
|
|
12
|
+
* `X-Refresh-Token: <refresh>` (the ride-along), letting the server
|
|
13
|
+
* auto-refresh an expired access token in-band.
|
|
14
|
+
* 2. When the server rotates the session it returns `X-New-Access-Token` +
|
|
15
|
+
* `X-New-Refresh-Token`; we persist the NEW PAIR ATOMICALLY (one write,
|
|
16
|
+
* both or neither). A half-write is how sessions desync.
|
|
17
|
+
* 3. A network blip (fetch throws) NEVER clears the session — we re-throw
|
|
18
|
+
* and keep the tokens. Logging the user out because their wifi hiccuped
|
|
19
|
+
* is the single most common hand-rolled-auth bug.
|
|
20
|
+
* 4. CROSS-TAB: when another tab rotates the session, this tab picks the
|
|
21
|
+
* new pair up off the `storage` event instead of riding its stale copy
|
|
22
|
+
* past the server's reuse-grace window (which reads as a phantom
|
|
23
|
+
* logout in every background tab). A 401 on a request that carried a
|
|
24
|
+
* since-rotated pair retries ONCE with the freshest stored pair before
|
|
25
|
+
* concluding the session is dead.
|
|
26
|
+
*
|
|
27
|
+
* COOKIE MODE (0.2.0+, the BROWSER DEFAULT): instead of holding tokens in
|
|
28
|
+
* localStorage (XSS-exfiltratable), the backend sets the session as httpOnly
|
|
29
|
+
* cookies and the browser owns it — this client stores NO tokens, sends
|
|
30
|
+
* `credentials: 'include'`, and caches only the (non-secret) user object for
|
|
31
|
+
* optimistic rendering. Mode is negotiated per sign-in: the client hints
|
|
32
|
+
* `X-Sw-Auth-Mode: cookie`; only a server that actually set the cookies
|
|
33
|
+
* replies `cookie_session: true`. A backend that doesn't (its handler omits
|
|
34
|
+
* cookie mode) gets a typed `AuthError` with code
|
|
35
|
+
* `COOKIE_SESSION_NOT_CONFIRMED` and NOTHING is stored — the client never
|
|
36
|
+
* quietly puts a token pair where page scripts can read it (0.9.0). An
|
|
37
|
+
* EXISTING stored header session is adopted as-is (no forced re-auth) and
|
|
38
|
+
* migrates to cookies transparently on the next login.
|
|
39
|
+
*
|
|
40
|
+
* SESSION STATE AND ORDERING (tsk_166b8ddf): `getState()` and
|
|
41
|
+
* `onChange` report what the backend last said: 'checking' before any answer
|
|
42
|
+
* (a cached user is unverified), 'authenticated', 'signed-out', or
|
|
43
|
+
* 'indeterminate' when a check failed (network, 5xx, unreadable body) — the
|
|
44
|
+
* last-known user is kept but is not verified. Identity changes are ordered:
|
|
45
|
+
*
|
|
46
|
+
* - Each sign-in/sign-up/completion and signOut() advances a generation when
|
|
47
|
+
* it is CALLED. A /me answer, a 401, or a token rotation that started under
|
|
48
|
+
* an earlier generation never writes user, session or status.
|
|
49
|
+
* - Cookie-changing calls from one client (login, signup, magic-link verify,
|
|
50
|
+
* OAuth completions, logout) run one at a time in call order, so their
|
|
51
|
+
* Set-Cookie responses cannot land out of order. A sign-in answered after a
|
|
52
|
+
* newer signOut()/sign-in rejects with code 'AUTH_SUPERSEDED' and changes
|
|
53
|
+
* nothing locally; the queued logout still runs after it on the server.
|
|
54
|
+
* - This orders one client instance only. Another tab, or a request the
|
|
55
|
+
* server processes late, can still change the shared cookies; the next
|
|
56
|
+
* check reports it. A timed-out call (mutationTimeoutMs covers the
|
|
57
|
+
* request, its body and any follow-up /me) is abandoned locally and writes
|
|
58
|
+
* nothing afterwards, but the server may still have acted on it.
|
|
59
|
+
* - signOut() drops local credentials at once and retains the last-known user
|
|
60
|
+
* while `signingOut` is true. Only a successful /logout confirms server
|
|
61
|
+
* sign-out; a failure clears the local user but leaves `signOutUnconfirmed`
|
|
62
|
+
* true so the next signOut() retries it.
|
|
63
|
+
*
|
|
64
|
+
* The token trio originates from the app's own backend (login/signup are
|
|
65
|
+
* developer-key-gated on the platform, so they can't be called from the
|
|
66
|
+
* browser). Mount `somewhereAuth` from `@somewhere-cloud/sdk/server` at
|
|
67
|
+
* `/api/auth/*` to expose the standard endpoints this client talks to.
|
|
68
|
+
*/
|
|
69
|
+
export interface Session {
|
|
70
|
+
accessToken: string;
|
|
71
|
+
refreshToken: string;
|
|
72
|
+
}
|
|
73
|
+
export type AppUserRole = 'user' | 'admin';
|
|
74
|
+
export interface User {
|
|
75
|
+
id: string;
|
|
76
|
+
email: string | null;
|
|
77
|
+
/** Platform-owned app role. Optional while cached users and older servers
|
|
78
|
+
* roll forward. Use it for UI rendering only; enforce admin access
|
|
79
|
+
* server-side with sw.auth.requireUser(req, { role: 'admin' }). */
|
|
80
|
+
role?: AppUserRole;
|
|
81
|
+
[key: string]: unknown;
|
|
82
|
+
}
|
|
83
|
+
/** One plan from the project's code-defined catalog (sw.billing). */
|
|
84
|
+
export interface BillingPlan {
|
|
85
|
+
slug: string;
|
|
86
|
+
name: string;
|
|
87
|
+
description: string | null;
|
|
88
|
+
price_cents: number | null;
|
|
89
|
+
currency: string;
|
|
90
|
+
interval: string | null;
|
|
91
|
+
stripe_price_id: string | null;
|
|
92
|
+
sort_order: number;
|
|
93
|
+
is_default: boolean;
|
|
94
|
+
active: boolean;
|
|
95
|
+
features: Array<{
|
|
96
|
+
feature: string;
|
|
97
|
+
limit_value: number | null;
|
|
98
|
+
}>;
|
|
99
|
+
}
|
|
100
|
+
/** Explicit catalog and checkout operations. Paid access is checked server-side. */
|
|
101
|
+
export interface BillingClient {
|
|
102
|
+
/** @deprecated Identity has no paid assertions. Use a server endpoint calling await sw.billing.has(feature). */
|
|
103
|
+
has(feature: string): never;
|
|
104
|
+
/** @deprecated Identity has no paid assertions. Use a server endpoint calling await sw.billing.entitlements(). */
|
|
105
|
+
entitlements(): never;
|
|
106
|
+
/** The project's plan catalog (network). */
|
|
107
|
+
plans(): Promise<BillingPlan[]>;
|
|
108
|
+
/** Start a subscription checkout for the CURRENT user and (by default) redirect
|
|
109
|
+
* the browser to Stripe. success/cancel default to the current page. The
|
|
110
|
+
* buyer is the signed-in user — resolved server-side, never passed from here. */
|
|
111
|
+
subscribe(plan: string, opts?: {
|
|
112
|
+
successUrl?: string;
|
|
113
|
+
cancelUrl?: string;
|
|
114
|
+
redirect?: boolean;
|
|
115
|
+
}): Promise<{
|
|
116
|
+
url: string;
|
|
117
|
+
}>;
|
|
118
|
+
/** Open the Stripe billing portal for the CURRENT user (manage / cancel) and
|
|
119
|
+
* (by default) redirect there. return_url defaults to the current page. */
|
|
120
|
+
openBillingPortal(opts?: {
|
|
121
|
+
returnUrl?: string;
|
|
122
|
+
redirect?: boolean;
|
|
123
|
+
}): Promise<{
|
|
124
|
+
url: string;
|
|
125
|
+
}>;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* What this client last learned from the backend about the session.
|
|
129
|
+
* checking no answer yet since the client was created, or sign-out is pending;
|
|
130
|
+
* `user` is cached, unverified
|
|
131
|
+
* authenticated the backend confirmed `user` (a sign-in response, or /me with a user)
|
|
132
|
+
* signed-out no identity in this client: the backend confirmed no session
|
|
133
|
+
* (/me 401 or { user: null }, a 401 on the current identity), or
|
|
134
|
+
* signOut() finished locally. `signOutUnconfirmed` means the
|
|
135
|
+
* server did not confirm that sign-out.
|
|
136
|
+
* indeterminate the last check failed (network error, non-401 error status,
|
|
137
|
+
* unreadable body); `user` is the last-known identity, unverified
|
|
138
|
+
*/
|
|
139
|
+
export type AuthStatus = 'checking' | 'authenticated' | 'signed-out' | 'indeterminate';
|
|
140
|
+
export interface AuthState {
|
|
141
|
+
status: AuthStatus;
|
|
142
|
+
user: User | null;
|
|
143
|
+
session: Session | null;
|
|
144
|
+
/** 'SESSION_CHECK_FAILED' in 'indeterminate'; 'SIGN_OUT_UNCONFIRMED' while a
|
|
145
|
+
* sign-out is still owed to the server. */
|
|
146
|
+
error: AuthError | null;
|
|
147
|
+
/** True after a signOut() whose server call failed: the server session may
|
|
148
|
+
* still exist. Cleared when a later signOut() reaches the server, /me
|
|
149
|
+
* answers definitively, or a sign-in replaces the session. */
|
|
150
|
+
signOutUnconfirmed: boolean;
|
|
151
|
+
/** True from a signOut() call until its /logout is answered (or fails or
|
|
152
|
+
* times out). The last-known `user` remains while pending so user-null UI
|
|
153
|
+
* cannot imply completion. Show a pending state and disable private actions. */
|
|
154
|
+
signingOut: boolean;
|
|
155
|
+
}
|
|
156
|
+
export interface StorageLike {
|
|
157
|
+
getItem(key: string): string | null;
|
|
158
|
+
setItem(key: string, value: string): void;
|
|
159
|
+
removeItem(key: string): void;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* 'cookie' — httpOnly cookie session set by the backend; no tokens in JS.
|
|
163
|
+
* 'header' — compatibility/non-browser mode: Bearer + refresh ride-along
|
|
164
|
+
* with tokens in `storage`. Do not select this for a new browser app.
|
|
165
|
+
* Default: 'cookie' in a browser (document exists), 'header' elsewhere
|
|
166
|
+
* (Node / CLI / native — where httpOnly cookies don't exist).
|
|
167
|
+
*/
|
|
168
|
+
export type AuthMode = 'cookie' | 'header';
|
|
169
|
+
export interface SomewhereAuthOptions {
|
|
170
|
+
/** Base URL of the app's backend auth routes. Default '' (same-origin). */
|
|
171
|
+
baseUrl?: string;
|
|
172
|
+
/** Path prefix the backend handler is mounted at. Default '/api/auth'. */
|
|
173
|
+
authPath?: string;
|
|
174
|
+
/** Header-mode token storage. Unused by a cookie-native browser session. */
|
|
175
|
+
storage?: StorageLike;
|
|
176
|
+
/** localStorage key. Default 'sw_auth'. */
|
|
177
|
+
storageKey?: string;
|
|
178
|
+
/** Session transport. Default: 'cookie' in browsers, 'header' elsewhere. */
|
|
179
|
+
mode?: AuthMode;
|
|
180
|
+
/** How long one queued sign-in/sign-out call may take, including reading the
|
|
181
|
+
* response and any follow-up /me, before it is abandoned (AuthError
|
|
182
|
+
* 'AUTH_TIMEOUT') so later calls can run. 1 to 2147483647 ms; default 30000. */
|
|
183
|
+
mutationTimeoutMs?: number;
|
|
184
|
+
}
|
|
185
|
+
export interface SomewhereAuth {
|
|
186
|
+
/** fetch wrapper that rides the session + persists rotation. Use it for
|
|
187
|
+
* every request to your backend that needs the user. */
|
|
188
|
+
fetch: typeof fetch;
|
|
189
|
+
signUp(input: {
|
|
190
|
+
email: string;
|
|
191
|
+
password: string;
|
|
192
|
+
displayName?: string;
|
|
193
|
+
}): Promise<User>;
|
|
194
|
+
signIn(input: {
|
|
195
|
+
email: string;
|
|
196
|
+
password: string;
|
|
197
|
+
}): Promise<User>;
|
|
198
|
+
/** Send a magic-link / OTP email. The link/code completes via verifyMagicLink. */
|
|
199
|
+
sendMagicLink(input: {
|
|
200
|
+
email: string;
|
|
201
|
+
redirectUri?: string;
|
|
202
|
+
}): Promise<void>;
|
|
203
|
+
verifyMagicLink(input: {
|
|
204
|
+
token: string;
|
|
205
|
+
}): Promise<User>;
|
|
206
|
+
/** Whether the signed-in account's email address is verified. */
|
|
207
|
+
emailVerified(): Promise<boolean>;
|
|
208
|
+
/** Email the signed-in account a 6-digit verification code. The session
|
|
209
|
+
* decides the account; no token is handled in page code. */
|
|
210
|
+
requestEmailVerification(): Promise<void>;
|
|
211
|
+
/** Check that code; resolves once the address is verified. */
|
|
212
|
+
verifyEmail(input: {
|
|
213
|
+
code: string;
|
|
214
|
+
}): Promise<void>;
|
|
215
|
+
/** Get the platform-owned Google OAuth URL (no Google project needed). */
|
|
216
|
+
googleSignInUrl(input?: {
|
|
217
|
+
redirectUri?: string;
|
|
218
|
+
}): Promise<string>;
|
|
219
|
+
/** Exchange a Google `?code=` (from the callback) for a session. Pass the
|
|
220
|
+
* callback's `?attempt=` too; on the callback page it is read from the URL. */
|
|
221
|
+
completeGoogleSignIn(input: {
|
|
222
|
+
code: string;
|
|
223
|
+
attempt?: string;
|
|
224
|
+
}): Promise<User>;
|
|
225
|
+
/** Get the platform-owned GitHub OAuth URL. */
|
|
226
|
+
githubSignInUrl(input?: {
|
|
227
|
+
redirectUri?: string;
|
|
228
|
+
}): Promise<string>;
|
|
229
|
+
/** Exchange a GitHub `?code=` (from the callback) for a session. Pass the
|
|
230
|
+
* callback's `?attempt=` too; on the callback page it is read from the URL. */
|
|
231
|
+
completeGithubSignIn(input: {
|
|
232
|
+
code: string;
|
|
233
|
+
attempt?: string;
|
|
234
|
+
}): Promise<User>;
|
|
235
|
+
/** Get the platform-owned Discord OAuth URL. */
|
|
236
|
+
discordSignInUrl(input?: {
|
|
237
|
+
redirectUri?: string;
|
|
238
|
+
}): Promise<string>;
|
|
239
|
+
/** Exchange a Discord `?code=` (from the callback) for a session. Pass the
|
|
240
|
+
* callback's `?attempt=` too; on the callback page it is read from the URL. */
|
|
241
|
+
completeDiscordSignIn(input: {
|
|
242
|
+
code: string;
|
|
243
|
+
attempt?: string;
|
|
244
|
+
}): Promise<User>;
|
|
245
|
+
/** Complete the pending sign-in with an authenticator or backup code. */
|
|
246
|
+
completeMfa(input: {
|
|
247
|
+
code: string;
|
|
248
|
+
}): Promise<User>;
|
|
249
|
+
signOut(): Promise<void>;
|
|
250
|
+
/** Re-fetch the current user from the backend (validates + refreshes). */
|
|
251
|
+
getUser(): Promise<User | null>;
|
|
252
|
+
/** Current session from memory (no network). Always null for a cookie
|
|
253
|
+
* session — the tokens are httpOnly, deliberately unreadable from JS;
|
|
254
|
+
* use getCachedUser()/getUser() for signed-in state. */
|
|
255
|
+
getSession(): Session | null;
|
|
256
|
+
getCachedUser(): User | null;
|
|
257
|
+
/** Status, user, session and error as of now (no network). */
|
|
258
|
+
getState(): AuthState;
|
|
259
|
+
/** Subscribe to session/user/status changes (login, logout, rotation, checks). */
|
|
260
|
+
onChange(listener: (state: AuthState) => void): () => void;
|
|
261
|
+
/** Entitlements (sw.billing) — `has(feature)` / `entitlements()` / `plans()`. */
|
|
262
|
+
billing: BillingClient;
|
|
263
|
+
}
|
|
264
|
+
export declare function createSomewhereAuth(options?: SomewhereAuthOptions): SomewhereAuth;
|
|
265
|
+
export declare class AuthError extends Error {
|
|
266
|
+
status: number;
|
|
267
|
+
/** Set when the client itself refuses a response, e.g.
|
|
268
|
+
* 'COOKIE_SESSION_NOT_CONFIRMED'. Undefined for server-reported failures. */
|
|
269
|
+
code?: string;
|
|
270
|
+
constructor(message: string, status: number, code?: string);
|
|
271
|
+
}
|
|
272
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/auth/client.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AAEH,MAAM,WAAW,OAAO;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3C,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;wEAEoE;IACpE,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,qEAAqE;AACrE,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,eAAe,EAAE,MAA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AAC,IAAI,CAAC,CAAC;IAChF,yEAAyE;IACzE,WAAW,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,0EAA0E;IAC1E,OAAO,IAAI,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAChC;;6DAEyD;IACzD,UAAU,IAAI,OAAO,GAAG,IAAI,CAAC;IAC7B,aAAa,IAAI,IAAI,GAAG,IAAI,CAAC;IAC7B,8DAA8D;IAC9D,QAAQ,IAAI,SAAS,CAAC;IACtB,kFAAkF;IAClF,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC3D,iFAAiF;IACjF,OAAO,EAAE,aAAa,CAAC;CACxB;AA8BD,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa,CAs2BrF;AAED,qBAAa,SAAU,SAAQ,KAAK;IAClC,MAAM,EAAE,MAAM,CAAC;IACf;kFAC8E;IAC9E,IAAI,CAAC,EAAE,MAAM,CAAC;gBACF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAM3D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Internal auth response parsing. Pending credentials never enter user state. */
|
|
2
|
+
export declare function authData(value: unknown): Record<string, unknown> | null;
|
|
3
|
+
export declare function mfaChallenge(value: unknown): {
|
|
4
|
+
mfa_required: true;
|
|
5
|
+
mfa_token: string;
|
|
6
|
+
} | null;
|
|
7
|
+
export declare function isAuthUser(value: unknown): value is {
|
|
8
|
+
id: string;
|
|
9
|
+
} & Record<string, unknown>;
|
|
10
|
+
//# sourceMappingURL=continuation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"continuation.d.ts","sourceRoot":"","sources":["../../../src/auth/continuation.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAKvE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,YAAY,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAK7F;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAK5F"}
|