@oxy.so/core 4.5.0-oxy-one.0 → 4.5.0-oxy-one.1
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/api/assets.js +10 -1
- package/dist/cjs/api/auth.js +9 -3
- package/dist/esm/api/assets.js +10 -1
- package/dist/esm/api/auth.js +9 -3
- package/dist/types/api/assets.d.ts +2 -0
- package/dist/types/api/auth.d.ts +8 -3
- package/dist/types/server/requesterAssertion.d.ts +2 -2
- package/package.json +1 -1
- package/src/api/assets.ts +13 -1
- package/src/api/auth.ts +11 -4
package/dist/cjs/api/assets.js
CHANGED
|
@@ -38,6 +38,12 @@ const ASSET_URL_CACHE_LIFETIME_FRACTION = 0.5;
|
|
|
38
38
|
/** Assumed URL lifetime (seconds) when no `expiresIn` is asked for; the API default. */
|
|
39
39
|
const DEFAULT_ASSET_URL_EXPIRES_IN_SECONDS = 3600;
|
|
40
40
|
const ASSET_TTL = 5 * 60 * 1000;
|
|
41
|
+
/**
|
|
42
|
+
* Default bound on one `POST /assets/upload`, in ms. The client's per-request
|
|
43
|
+
* default (5s) is sized for JSON calls; a video sent over a phone connection
|
|
44
|
+
* needs minutes, and timing it out at 5s failed every upload past a few MB.
|
|
45
|
+
*/
|
|
46
|
+
const ASSET_UPLOAD_TIMEOUT_MS = 10 * 60 * 1000;
|
|
41
47
|
/**
|
|
42
48
|
* How long a resolved asset URL may stay in the SDK's GET cache, in ms: never
|
|
43
49
|
* longer than the media token's lifetime, and discounted below it.
|
|
@@ -114,7 +120,10 @@ class AssetsApi {
|
|
|
114
120
|
if (options.metadata)
|
|
115
121
|
formData.append('metadata', JSON.stringify(options.metadata));
|
|
116
122
|
try {
|
|
117
|
-
const response = await this.ctx.request('POST', '/assets/upload', formData, {
|
|
123
|
+
const response = await this.ctx.request('POST', '/assets/upload', formData, {
|
|
124
|
+
cache: false,
|
|
125
|
+
timeout: options.timeout ?? ASSET_UPLOAD_TIMEOUT_MS,
|
|
126
|
+
});
|
|
118
127
|
options.onProgress?.(100);
|
|
119
128
|
return response;
|
|
120
129
|
}
|
package/dist/cjs/api/auth.js
CHANGED
|
@@ -714,14 +714,19 @@ class AuthApi {
|
|
|
714
714
|
this.agent = new AuthAgentApi(ctx);
|
|
715
715
|
}
|
|
716
716
|
/**
|
|
717
|
-
* Register a new
|
|
718
|
-
*
|
|
717
|
+
* Register a new account for a public key, together with its username.
|
|
718
|
+
*
|
|
719
|
+
* The username is required: the server writes it in the same insert as the
|
|
720
|
+
* key, so an account never exists without one. A taken username is a 409
|
|
721
|
+
* (`Username already taken`), as is a key that is already registered
|
|
722
|
+
* (`Identity already registered`).
|
|
719
723
|
*
|
|
720
724
|
* @param publicKey - The user's ECDSA public key (hex)
|
|
721
725
|
* @param signature - Signature of the registration request
|
|
722
726
|
* @param timestamp - Timestamp when the signature was created
|
|
727
|
+
* @param username - The account's username
|
|
723
728
|
*/
|
|
724
|
-
async registerKey(publicKey, signature, timestamp) {
|
|
729
|
+
async registerKey(publicKey, signature, timestamp, username) {
|
|
725
730
|
// Advisory for now (server soft-enforces — see
|
|
726
731
|
// `SessionController.register`), but solved unconditionally so every
|
|
727
732
|
// client is already sending it once the server starts requiring it.
|
|
@@ -731,6 +736,7 @@ class AuthApi {
|
|
|
731
736
|
publicKey,
|
|
732
737
|
signature,
|
|
733
738
|
timestamp,
|
|
739
|
+
username,
|
|
734
740
|
powNonce,
|
|
735
741
|
}, { cache: false, skipAuth: true });
|
|
736
742
|
if (!res || (typeof res === 'object' && Object.keys(res).length === 0)) {
|
package/dist/esm/api/assets.js
CHANGED
|
@@ -34,6 +34,12 @@ const ASSET_URL_CACHE_LIFETIME_FRACTION = 0.5;
|
|
|
34
34
|
/** Assumed URL lifetime (seconds) when no `expiresIn` is asked for; the API default. */
|
|
35
35
|
const DEFAULT_ASSET_URL_EXPIRES_IN_SECONDS = 3600;
|
|
36
36
|
const ASSET_TTL = 5 * 60 * 1000;
|
|
37
|
+
/**
|
|
38
|
+
* Default bound on one `POST /assets/upload`, in ms. The client's per-request
|
|
39
|
+
* default (5s) is sized for JSON calls; a video sent over a phone connection
|
|
40
|
+
* needs minutes, and timing it out at 5s failed every upload past a few MB.
|
|
41
|
+
*/
|
|
42
|
+
const ASSET_UPLOAD_TIMEOUT_MS = 10 * 60 * 1000;
|
|
37
43
|
/**
|
|
38
44
|
* How long a resolved asset URL may stay in the SDK's GET cache, in ms: never
|
|
39
45
|
* longer than the media token's lifetime, and discounted below it.
|
|
@@ -110,7 +116,10 @@ export class AssetsApi {
|
|
|
110
116
|
if (options.metadata)
|
|
111
117
|
formData.append('metadata', JSON.stringify(options.metadata));
|
|
112
118
|
try {
|
|
113
|
-
const response = await this.ctx.request('POST', '/assets/upload', formData, {
|
|
119
|
+
const response = await this.ctx.request('POST', '/assets/upload', formData, {
|
|
120
|
+
cache: false,
|
|
121
|
+
timeout: options.timeout ?? ASSET_UPLOAD_TIMEOUT_MS,
|
|
122
|
+
});
|
|
114
123
|
options.onProgress?.(100);
|
|
115
124
|
return response;
|
|
116
125
|
}
|
package/dist/esm/api/auth.js
CHANGED
|
@@ -672,14 +672,19 @@ export class AuthApi {
|
|
|
672
672
|
this.agent = new AuthAgentApi(ctx);
|
|
673
673
|
}
|
|
674
674
|
/**
|
|
675
|
-
* Register a new
|
|
676
|
-
*
|
|
675
|
+
* Register a new account for a public key, together with its username.
|
|
676
|
+
*
|
|
677
|
+
* The username is required: the server writes it in the same insert as the
|
|
678
|
+
* key, so an account never exists without one. A taken username is a 409
|
|
679
|
+
* (`Username already taken`), as is a key that is already registered
|
|
680
|
+
* (`Identity already registered`).
|
|
677
681
|
*
|
|
678
682
|
* @param publicKey - The user's ECDSA public key (hex)
|
|
679
683
|
* @param signature - Signature of the registration request
|
|
680
684
|
* @param timestamp - Timestamp when the signature was created
|
|
685
|
+
* @param username - The account's username
|
|
681
686
|
*/
|
|
682
|
-
async registerKey(publicKey, signature, timestamp) {
|
|
687
|
+
async registerKey(publicKey, signature, timestamp, username) {
|
|
683
688
|
// Advisory for now (server soft-enforces — see
|
|
684
689
|
// `SessionController.register`), but solved unconditionally so every
|
|
685
690
|
// client is already sending it once the server starts requiring it.
|
|
@@ -689,6 +694,7 @@ export class AuthApi {
|
|
|
689
694
|
publicKey,
|
|
690
695
|
signature,
|
|
691
696
|
timestamp,
|
|
697
|
+
username,
|
|
692
698
|
powNonce,
|
|
693
699
|
}, { cache: false, skipAuth: true });
|
|
694
700
|
if (!res || (typeof res === 'object' && Object.keys(res).length === 0)) {
|
|
@@ -27,6 +27,8 @@ export interface AssetUploadOptions {
|
|
|
27
27
|
metadata?: AssetMetadata;
|
|
28
28
|
/** Called with `100` once the upload completes. */
|
|
29
29
|
onProgress?: (progress: number) => void;
|
|
30
|
+
/** Bound on the whole upload, in ms. Default {@link ASSET_UPLOAD_TIMEOUT_MS}. */
|
|
31
|
+
timeout?: number;
|
|
30
32
|
}
|
|
31
33
|
export interface AssetLinkTarget {
|
|
32
34
|
app: string;
|
package/dist/types/api/auth.d.ts
CHANGED
|
@@ -633,14 +633,19 @@ export declare class AuthApi {
|
|
|
633
633
|
readonly agent: AuthAgentApi;
|
|
634
634
|
constructor(ctx: OxyContext);
|
|
635
635
|
/**
|
|
636
|
-
* Register a new
|
|
637
|
-
*
|
|
636
|
+
* Register a new account for a public key, together with its username.
|
|
637
|
+
*
|
|
638
|
+
* The username is required: the server writes it in the same insert as the
|
|
639
|
+
* key, so an account never exists without one. A taken username is a 409
|
|
640
|
+
* (`Username already taken`), as is a key that is already registered
|
|
641
|
+
* (`Identity already registered`).
|
|
638
642
|
*
|
|
639
643
|
* @param publicKey - The user's ECDSA public key (hex)
|
|
640
644
|
* @param signature - Signature of the registration request
|
|
641
645
|
* @param timestamp - Timestamp when the signature was created
|
|
646
|
+
* @param username - The account's username
|
|
642
647
|
*/
|
|
643
|
-
registerKey(publicKey: string, signature: string, timestamp: number): Promise<{
|
|
648
|
+
registerKey(publicKey: string, signature: string, timestamp: number, username: string): Promise<{
|
|
644
649
|
message: string;
|
|
645
650
|
user: User;
|
|
646
651
|
}>;
|
|
@@ -36,8 +36,8 @@ export declare const oxyRequesterAssertionClaimsSchema: z.ZodObject<{
|
|
|
36
36
|
/** The one native agent this requester may reach with it. */
|
|
37
37
|
agentId: z.ZodString;
|
|
38
38
|
}, "strict", z.ZodTypeAny, {
|
|
39
|
-
sub: string;
|
|
40
39
|
exp: number;
|
|
40
|
+
sub: string;
|
|
41
41
|
aud: string;
|
|
42
42
|
iss: string;
|
|
43
43
|
jti: string;
|
|
@@ -46,8 +46,8 @@ export declare const oxyRequesterAssertionClaimsSchema: z.ZodObject<{
|
|
|
46
46
|
cid: string;
|
|
47
47
|
agentId: string;
|
|
48
48
|
}, {
|
|
49
|
-
sub: string;
|
|
50
49
|
exp: number;
|
|
50
|
+
sub: string;
|
|
51
51
|
aud: string;
|
|
52
52
|
iss: string;
|
|
53
53
|
jti: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxy.so/core",
|
|
3
|
-
"version": "4.5.0-oxy-one.
|
|
3
|
+
"version": "4.5.0-oxy-one.1",
|
|
4
4
|
"description": "OxyHQ SDK Foundation — API client, authentication, cryptographic identity, and shared utilities",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
package/src/api/assets.ts
CHANGED
|
@@ -52,6 +52,13 @@ const DEFAULT_ASSET_URL_EXPIRES_IN_SECONDS = 3600;
|
|
|
52
52
|
|
|
53
53
|
const ASSET_TTL = 5 * 60 * 1000;
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Default bound on one `POST /assets/upload`, in ms. The client's per-request
|
|
57
|
+
* default (5s) is sized for JSON calls; a video sent over a phone connection
|
|
58
|
+
* needs minutes, and timing it out at 5s failed every upload past a few MB.
|
|
59
|
+
*/
|
|
60
|
+
const ASSET_UPLOAD_TIMEOUT_MS = 10 * 60 * 1000;
|
|
61
|
+
|
|
55
62
|
/**
|
|
56
63
|
* How long a resolved asset URL may stay in the SDK's GET cache, in ms: never
|
|
57
64
|
* longer than the media token's lifetime, and discounted below it.
|
|
@@ -85,6 +92,8 @@ export interface AssetUploadOptions {
|
|
|
85
92
|
metadata?: AssetMetadata;
|
|
86
93
|
/** Called with `100` once the upload completes. */
|
|
87
94
|
onProgress?: (progress: number) => void;
|
|
95
|
+
/** Bound on the whole upload, in ms. Default {@link ASSET_UPLOAD_TIMEOUT_MS}. */
|
|
96
|
+
timeout?: number;
|
|
88
97
|
}
|
|
89
98
|
|
|
90
99
|
export interface AssetLinkTarget {
|
|
@@ -160,7 +169,10 @@ export class AssetsApi {
|
|
|
160
169
|
if (options.metadata) formData.append('metadata', JSON.stringify(options.metadata));
|
|
161
170
|
|
|
162
171
|
try {
|
|
163
|
-
const response = await this.ctx.request<{ file: UploadedAsset }>('POST', '/assets/upload', formData, {
|
|
172
|
+
const response = await this.ctx.request<{ file: UploadedAsset }>('POST', '/assets/upload', formData, {
|
|
173
|
+
cache: false,
|
|
174
|
+
timeout: options.timeout ?? ASSET_UPLOAD_TIMEOUT_MS,
|
|
175
|
+
});
|
|
164
176
|
options.onProgress?.(100);
|
|
165
177
|
return response;
|
|
166
178
|
} catch (error) {
|
package/src/api/auth.ts
CHANGED
|
@@ -1208,17 +1208,23 @@ export class AuthApi {
|
|
|
1208
1208
|
}
|
|
1209
1209
|
|
|
1210
1210
|
/**
|
|
1211
|
-
* Register a new
|
|
1212
|
-
*
|
|
1213
|
-
*
|
|
1211
|
+
* Register a new account for a public key, together with its username.
|
|
1212
|
+
*
|
|
1213
|
+
* The username is required: the server writes it in the same insert as the
|
|
1214
|
+
* key, so an account never exists without one. A taken username is a 409
|
|
1215
|
+
* (`Username already taken`), as is a key that is already registered
|
|
1216
|
+
* (`Identity already registered`).
|
|
1217
|
+
*
|
|
1214
1218
|
* @param publicKey - The user's ECDSA public key (hex)
|
|
1215
1219
|
* @param signature - Signature of the registration request
|
|
1216
1220
|
* @param timestamp - Timestamp when the signature was created
|
|
1221
|
+
* @param username - The account's username
|
|
1217
1222
|
*/
|
|
1218
1223
|
async registerKey(
|
|
1219
1224
|
publicKey: string,
|
|
1220
1225
|
signature: string,
|
|
1221
|
-
timestamp: number
|
|
1226
|
+
timestamp: number,
|
|
1227
|
+
username: string
|
|
1222
1228
|
): Promise<{ message: string; user: User }> {
|
|
1223
1229
|
// Advisory for now (server soft-enforces — see
|
|
1224
1230
|
// `SessionController.register`), but solved unconditionally so every
|
|
@@ -1230,6 +1236,7 @@ export class AuthApi {
|
|
|
1230
1236
|
publicKey,
|
|
1231
1237
|
signature,
|
|
1232
1238
|
timestamp,
|
|
1239
|
+
username,
|
|
1233
1240
|
powNonce,
|
|
1234
1241
|
}, { cache: false, skipAuth: true });
|
|
1235
1242
|
|