@mediaviz/react-native-sdk 1.9.0-dev.116 → 1.9.0-dev.117
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/sdk.cjs +0 -60
- package/dist/sdk.d.cts +156 -20
- package/dist/sdk.d.ts +156 -20
- package/dist/sdk.esm.d.ts +156 -20
- package/dist/sdk.esm.js +1 -60
- package/package.json +1 -1
package/dist/sdk.cjs
CHANGED
|
@@ -1631,17 +1631,6 @@ class Keywords {
|
|
|
1631
1631
|
}
|
|
1632
1632
|
}
|
|
1633
1633
|
|
|
1634
|
-
class Media {
|
|
1635
|
-
constructor(ctx) { this._ctx = ctx; }
|
|
1636
|
-
|
|
1637
|
-
async getProjectAccessQuery(projectTableName) {
|
|
1638
|
-
this._ctx.requireTokens();
|
|
1639
|
-
const path = `/api/v1/media/project/${encodeURIComponent(projectTableName)}/access_query`;
|
|
1640
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1641
|
-
return data;
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
|
|
1645
1634
|
class OauthAuthorization {
|
|
1646
1635
|
constructor(ctx) { this._ctx = ctx; }
|
|
1647
1636
|
|
|
@@ -2461,7 +2450,6 @@ class _Context {
|
|
|
2461
2450
|
get refreshToken() { return this._mv._refreshToken; }
|
|
2462
2451
|
get baseUrl() { return this._mv._config.baseUrl; }
|
|
2463
2452
|
get hosts() { return this._mv._hosts; }
|
|
2464
|
-
get utils() { return this._mv.utils; }
|
|
2465
2453
|
requireHost(key) {
|
|
2466
2454
|
const url = this._mv._hosts[key];
|
|
2467
2455
|
if (!url) throw new Error(`Host '${key}' not configured. Pass hosts.${key} in MediaViz constructor or set the corresponding env var.`);
|
|
@@ -2484,51 +2472,6 @@ class _TokenTrackingClient {
|
|
|
2484
2472
|
}
|
|
2485
2473
|
}
|
|
2486
2474
|
|
|
2487
|
-
class _Utils {
|
|
2488
|
-
constructor(mv) { this._mv = mv; }
|
|
2489
|
-
async getMediaAccessQuery(projectTableName) {
|
|
2490
|
-
if (!this._mv._accessToken) throw new Error('Not authenticated. Call authenticate(), handleCallback(), or setTokens() first.');
|
|
2491
|
-
// Memo lives on the _Utils instance, so it is scoped to one MediaViz client
|
|
2492
|
-
// (one authenticated user) — keying on project alone cannot leak across users.
|
|
2493
|
-
if (!this._mediaQueryMemo) this._mediaQueryMemo = new Map();
|
|
2494
|
-
const _nowSec = Date.now() / 1000;
|
|
2495
|
-
const _memo = this._mediaQueryMemo.get(projectTableName);
|
|
2496
|
-
// Re-mint 60s early: an <img> load that starts just before expiry must not race
|
|
2497
|
-
// the policy going stale and 403 mid-flight.
|
|
2498
|
-
if (_memo && _memo.expiresEpoch - 60 > _nowSec) return _memo.result;
|
|
2499
|
-
|
|
2500
|
-
// Through the generated endpoint method, not a bare fetch: this inherits the
|
|
2501
|
-
// oauth client's 401-refresh-and-retry. Errors propagate — without a query
|
|
2502
|
-
// string there is nothing to render.
|
|
2503
|
-
const _result = await this._mv.media.getProjectAccessQuery(projectTableName);
|
|
2504
|
-
|
|
2505
|
-
const _expiresEpoch = Date.parse(_result.expires_at) / 1000;
|
|
2506
|
-
// Skip the memo on an unparseable expiry rather than cache something that can
|
|
2507
|
-
// never be invalidated.
|
|
2508
|
-
if (!Number.isNaN(_expiresEpoch)) {
|
|
2509
|
-
this._mediaQueryMemo.set(projectTableName, { expiresEpoch: _expiresEpoch, result: _result });
|
|
2510
|
-
}
|
|
2511
|
-
return _result;
|
|
2512
|
-
}
|
|
2513
|
-
async authorizeMediaUrl(photoUrl, projectTableName) {
|
|
2514
|
-
if (!this._mv._accessToken) throw new Error('Not authenticated. Call authenticate(), handleCallback(), or setTokens() first.');
|
|
2515
|
-
// Memoized upstream, so calling this once per tile in a grid still costs one
|
|
2516
|
-
// round trip for the whole project.
|
|
2517
|
-
const _access = await this.getMediaAccessQuery(projectTableName);
|
|
2518
|
-
|
|
2519
|
-
// Already signed: return untouched. Appending a second policy yields duplicate
|
|
2520
|
-
// Policy/Signature params and an opaque 403 at the edge, and the caller almost
|
|
2521
|
-
// certainly passed a URL this function already authorized.
|
|
2522
|
-
//
|
|
2523
|
-
// Keyed on Key-Pair-Id, not Policy: the query-string params are Policy /
|
|
2524
|
-
// Signature / Key-Pair-Id (NOT the CloudFront-* spelling the cookie path used),
|
|
2525
|
-
// and 'Policy' alone is generic enough to collide with an unrelated param.
|
|
2526
|
-
if (/[?&]Key-Pair-Id=/.test(photoUrl)) return photoUrl;
|
|
2527
|
-
|
|
2528
|
-
return photoUrl + (photoUrl.includes('?') ? '&' : '?') + _access.query_string;
|
|
2529
|
-
}
|
|
2530
|
-
}
|
|
2531
|
-
|
|
2532
2475
|
class MediaViz {
|
|
2533
2476
|
constructor(config = {}) {
|
|
2534
2477
|
this._config = {
|
|
@@ -2562,7 +2505,6 @@ class MediaViz {
|
|
|
2562
2505
|
this.emailTokens = new EmailTokens(_ctx);
|
|
2563
2506
|
this.health = new Health(_ctx);
|
|
2564
2507
|
this.keywords = new Keywords(_ctx);
|
|
2565
|
-
this.media = new Media(_ctx);
|
|
2566
2508
|
this.oAuthAuthorization = new OauthAuthorization(_ctx);
|
|
2567
2509
|
this.oAuthToken = new OauthToken(_ctx);
|
|
2568
2510
|
this.oauthLogin = new OauthLogin(_ctx);
|
|
@@ -2574,7 +2516,6 @@ class MediaViz {
|
|
|
2574
2516
|
this.subscription = new Subscription(_ctx);
|
|
2575
2517
|
this.users = new Users(_ctx);
|
|
2576
2518
|
this.webhooks = new WebhookConsumer(_ctx, this.subscription);
|
|
2577
|
-
this.utils = new _Utils(this);
|
|
2578
2519
|
}
|
|
2579
2520
|
|
|
2580
2521
|
async authenticate() {
|
|
@@ -2996,7 +2937,6 @@ exports.EmailTokens = EmailTokens;
|
|
|
2996
2937
|
exports.Health = Health;
|
|
2997
2938
|
exports.InMemoryWebhookStore = InMemoryWebhookStore;
|
|
2998
2939
|
exports.Keywords = Keywords;
|
|
2999
|
-
exports.Media = Media;
|
|
3000
2940
|
exports.MediaViz = MediaViz;
|
|
3001
2941
|
exports.MemoryTokenStore = MemoryTokenStore;
|
|
3002
2942
|
exports.NotFoundError = NotFoundError;
|
package/dist/sdk.d.cts
CHANGED
|
@@ -216,15 +216,8 @@ export interface KeywordListDisplayWithProjects {
|
|
|
216
216
|
list_projects_associated?: string[];
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
export interface MediaAccessQueryDisplay {
|
|
220
|
-
query_string: string;
|
|
221
|
-
url_prefix: string;
|
|
222
|
-
expires_at: string;
|
|
223
|
-
project_table_name: string;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
219
|
export interface PhotoDisplay {
|
|
227
|
-
photo_s3_link
|
|
220
|
+
photo_s3_link: string;
|
|
228
221
|
client_side_id?: string;
|
|
229
222
|
moment_id?: number;
|
|
230
223
|
file_path?: string;
|
|
@@ -336,7 +329,7 @@ export interface PhotoPersonWithS3Link {
|
|
|
336
329
|
bounding_box: Record<string, any>;
|
|
337
330
|
confidence: number;
|
|
338
331
|
person_name: string;
|
|
339
|
-
photo_s3_link
|
|
332
|
+
photo_s3_link: string;
|
|
340
333
|
}
|
|
341
334
|
|
|
342
335
|
export interface ProjectRunDisplay {
|
|
@@ -507,10 +500,6 @@ export class Keywords {
|
|
|
507
500
|
deleteKeywordFilteringListById(keywordListId: number): Promise<Record<string, any>>;
|
|
508
501
|
}
|
|
509
502
|
|
|
510
|
-
export class Media {
|
|
511
|
-
getProjectAccessQuery(projectTableName: string): Promise<MediaAccessQueryDisplay>;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
503
|
export class OauthAuthorization {
|
|
515
504
|
authorize(options?: { responseType?: string | string[], clientId?: string | string[], redirectUri?: string | string[], state?: string | string[], codeChallenge?: string | string[], codeChallengeMethod?: string | string[] }): Promise<any>;
|
|
516
505
|
getConsent(sessionId: string): Promise<any>;
|
|
@@ -612,11 +601,6 @@ export class Users {
|
|
|
612
601
|
deleteUser(userId: number, options?: { newCompanyOwnerId?: number | number[] }): Promise<Record<string, any>>;
|
|
613
602
|
}
|
|
614
603
|
|
|
615
|
-
export interface MediaVizUtils {
|
|
616
|
-
getMediaAccessQuery(projectTableName: string): Promise<any>;
|
|
617
|
-
authorizeMediaUrl(photoUrl: string, projectTableName: string): Promise<any>;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
604
|
export class MediaViz {
|
|
621
605
|
constructor(config?: MediaVizConfig);
|
|
622
606
|
authenticate(): Promise<TokenResponse>;
|
|
@@ -633,7 +617,6 @@ export class MediaViz {
|
|
|
633
617
|
readonly emailTokens: EmailTokens;
|
|
634
618
|
readonly health: Health;
|
|
635
619
|
readonly keywords: Keywords;
|
|
636
|
-
readonly media: Media;
|
|
637
620
|
readonly oAuthAuthorization: OauthAuthorization;
|
|
638
621
|
readonly oAuthToken: OauthToken;
|
|
639
622
|
readonly oauthLogin: OauthLogin;
|
|
@@ -645,6 +628,159 @@ export class MediaViz {
|
|
|
645
628
|
readonly subscription: Subscription;
|
|
646
629
|
readonly users: Users;
|
|
647
630
|
readonly webhooks: WebhookConsumer;
|
|
648
|
-
readonly utils: MediaVizUtils;
|
|
649
631
|
}
|
|
650
632
|
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
// ── React Native adapters ──────────────────────────────────────────────────
|
|
636
|
+
// Bundled from react_native_module/ and re-exported from the package root.
|
|
637
|
+
|
|
638
|
+
/** Token shape the stores read back. Both tokens may be absent. */
|
|
639
|
+
export interface TokenPair {
|
|
640
|
+
accessToken: string | null;
|
|
641
|
+
refreshToken: string | null;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Persistence contract. `save` accepts either the OAuth client's snake_case
|
|
646
|
+
* response or the client's camelCase getters; both normalise to TokenPair.
|
|
647
|
+
*/
|
|
648
|
+
export interface TokenStore {
|
|
649
|
+
load(): Promise<TokenPair>;
|
|
650
|
+
save(tokens: unknown): Promise<void>;
|
|
651
|
+
clear(): Promise<void>;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/** Native crypto, as expo-crypto or react-native-quick-crypto expose it. */
|
|
655
|
+
export interface CryptoImpl {
|
|
656
|
+
/** May fill in place and return void (expo-crypto) or return the array. */
|
|
657
|
+
getRandomValues(bytes: Uint8Array): Uint8Array | void;
|
|
658
|
+
/** May resolve a Uint8Array, ArrayBuffer, typed array, or byte array. */
|
|
659
|
+
digest(bytes: Uint8Array): Promise<Uint8Array | ArrayBuffer | ArrayBufferView | number[]> | Uint8Array | ArrayBuffer | ArrayBufferView | number[];
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/** Normalised provider the OAuth SDK's PKCE path consumes. */
|
|
663
|
+
export interface CryptoProvider {
|
|
664
|
+
getRandomValues(bytes: Uint8Array): Uint8Array;
|
|
665
|
+
sha256(bytes: Uint8Array): Promise<Uint8Array>;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/** Normalises either native crypto convention into a CryptoProvider. */
|
|
669
|
+
export declare function createCryptoProvider(impl: CryptoImpl): CryptoProvider;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Installs the provider PKCE uses. Must be called before any sign-in:
|
|
673
|
+
* Hermes ships no SubtleCrypto, so the default WebCrypto path throws.
|
|
674
|
+
*/
|
|
675
|
+
export declare function configureCrypto(provider: CryptoProvider): void;
|
|
676
|
+
|
|
677
|
+
/** Non-persistent default. Tokens are lost when the app is killed. */
|
|
678
|
+
export declare class MemoryTokenStore implements TokenStore {
|
|
679
|
+
load(): Promise<TokenPair>;
|
|
680
|
+
save(tokens: unknown): Promise<void>;
|
|
681
|
+
clear(): Promise<void>;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/** The subset of expo-secure-store this SDK calls. */
|
|
685
|
+
export interface SecureStoreLike {
|
|
686
|
+
getItemAsync(key: string, options?: Record<string, unknown>): Promise<string | null>;
|
|
687
|
+
setItemAsync(key: string, value: string, options?: Record<string, unknown>): Promise<void>;
|
|
688
|
+
deleteItemAsync(key: string, options?: Record<string, unknown>): Promise<void>;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
export interface SecureTokenStoreOptions {
|
|
692
|
+
accessKey?: string;
|
|
693
|
+
refreshKey?: string;
|
|
694
|
+
secureStoreOptions?: Record<string, unknown>;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Backed by expo-secure-store (Keychain on iOS, Keystore on Android). Tokens
|
|
699
|
+
* are stored under separate keys — a single value is capped at 2048 bytes and
|
|
700
|
+
* two JWTs in one blob can cross that.
|
|
701
|
+
*/
|
|
702
|
+
export declare function createSecureTokenStore(
|
|
703
|
+
SecureStore: SecureStoreLike,
|
|
704
|
+
options?: SecureTokenStoreOptions
|
|
705
|
+
): TokenStore;
|
|
706
|
+
|
|
707
|
+
/** The subset of react-native-keychain this SDK calls. */
|
|
708
|
+
export interface KeychainLike {
|
|
709
|
+
getGenericPassword(options?: Record<string, unknown>): Promise<{ password: string } | false>;
|
|
710
|
+
setGenericPassword(username: string, password: string, options?: Record<string, unknown>): Promise<unknown>;
|
|
711
|
+
resetGenericPassword(options?: Record<string, unknown>): Promise<unknown>;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
export interface KeychainTokenStoreOptions {
|
|
715
|
+
service?: string;
|
|
716
|
+
keychainOptions?: Record<string, unknown>;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/** Backed by react-native-keychain, which has no size cap, so one JSON entry. */
|
|
720
|
+
export declare function createKeychainTokenStore(
|
|
721
|
+
Keychain: KeychainLike,
|
|
722
|
+
options?: KeychainTokenStoreOptions
|
|
723
|
+
): TokenStore;
|
|
724
|
+
|
|
725
|
+
/** Contract of expo-web-browser's openAuthSessionAsync. */
|
|
726
|
+
export type OpenAuthSession = (
|
|
727
|
+
url: string,
|
|
728
|
+
redirectUri: string,
|
|
729
|
+
options?: Record<string, unknown>
|
|
730
|
+
) => Promise<{ type: string; url?: string }>;
|
|
731
|
+
|
|
732
|
+
/** 'cancelled' when the user dismissed the sheet, 'failed' otherwise. */
|
|
733
|
+
export declare class AuthSessionError extends Error {
|
|
734
|
+
readonly name: 'AuthSessionError';
|
|
735
|
+
readonly code: string;
|
|
736
|
+
constructor(code: string, message: string);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
export interface AuthSessionOptions {
|
|
740
|
+
openAuthSession: OpenAuthSession;
|
|
741
|
+
redirectUri: string;
|
|
742
|
+
state?: string;
|
|
743
|
+
sessionOptions?: Record<string, unknown>;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/** Runs the full interactive login and leaves the client authenticated. */
|
|
747
|
+
export declare function startAuthSession(
|
|
748
|
+
mv: MediaViz,
|
|
749
|
+
options: AuthSessionOptions
|
|
750
|
+
): Promise<TokenResponse>;
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Extracts query and fragment params from a redirect URL. Hand-rolled because
|
|
754
|
+
* React Native's URL polyfill mis-parses the custom schemes native redirect
|
|
755
|
+
* URIs use. Returns an empty object for input it cannot parse.
|
|
756
|
+
*/
|
|
757
|
+
export declare function parseRedirectUrl(url: string): Record<string, string>;
|
|
758
|
+
|
|
759
|
+
export interface SignInOverrides {
|
|
760
|
+
openAuthSession?: OpenAuthSession;
|
|
761
|
+
redirectUri?: string;
|
|
762
|
+
state?: string;
|
|
763
|
+
sessionOptions?: Record<string, unknown>;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
export interface CreateSessionOptions {
|
|
767
|
+
/** The MediaViz class itself — this module is copied into the package and cannot name its host. */
|
|
768
|
+
MediaViz: new (config?: MediaVizConfig) => MediaViz;
|
|
769
|
+
config?: MediaVizConfig;
|
|
770
|
+
/** Defaults to a MemoryTokenStore. */
|
|
771
|
+
store?: TokenStore;
|
|
772
|
+
openAuthSession?: OpenAuthSession;
|
|
773
|
+
onTokens?: (tokens: unknown | null) => void;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/** The signed-in lifecycle, independent of React. react.js binds over this. */
|
|
777
|
+
export interface Session {
|
|
778
|
+
readonly client: MediaViz;
|
|
779
|
+
readonly store: TokenStore;
|
|
780
|
+
/** Loads persisted tokens into the client. Resolves null when there are none. */
|
|
781
|
+
restore(): Promise<TokenPair | null>;
|
|
782
|
+
signIn(overrides?: SignInOverrides): Promise<TokenResponse>;
|
|
783
|
+
signOut(): Promise<void>;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
export declare function createSession(options: CreateSessionOptions): Session;
|
package/dist/sdk.d.ts
CHANGED
|
@@ -216,15 +216,8 @@ export interface KeywordListDisplayWithProjects {
|
|
|
216
216
|
list_projects_associated?: string[];
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
export interface MediaAccessQueryDisplay {
|
|
220
|
-
query_string: string;
|
|
221
|
-
url_prefix: string;
|
|
222
|
-
expires_at: string;
|
|
223
|
-
project_table_name: string;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
219
|
export interface PhotoDisplay {
|
|
227
|
-
photo_s3_link
|
|
220
|
+
photo_s3_link: string;
|
|
228
221
|
client_side_id?: string;
|
|
229
222
|
moment_id?: number;
|
|
230
223
|
file_path?: string;
|
|
@@ -336,7 +329,7 @@ export interface PhotoPersonWithS3Link {
|
|
|
336
329
|
bounding_box: Record<string, any>;
|
|
337
330
|
confidence: number;
|
|
338
331
|
person_name: string;
|
|
339
|
-
photo_s3_link
|
|
332
|
+
photo_s3_link: string;
|
|
340
333
|
}
|
|
341
334
|
|
|
342
335
|
export interface ProjectRunDisplay {
|
|
@@ -507,10 +500,6 @@ export class Keywords {
|
|
|
507
500
|
deleteKeywordFilteringListById(keywordListId: number): Promise<Record<string, any>>;
|
|
508
501
|
}
|
|
509
502
|
|
|
510
|
-
export class Media {
|
|
511
|
-
getProjectAccessQuery(projectTableName: string): Promise<MediaAccessQueryDisplay>;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
503
|
export class OauthAuthorization {
|
|
515
504
|
authorize(options?: { responseType?: string | string[], clientId?: string | string[], redirectUri?: string | string[], state?: string | string[], codeChallenge?: string | string[], codeChallengeMethod?: string | string[] }): Promise<any>;
|
|
516
505
|
getConsent(sessionId: string): Promise<any>;
|
|
@@ -612,11 +601,6 @@ export class Users {
|
|
|
612
601
|
deleteUser(userId: number, options?: { newCompanyOwnerId?: number | number[] }): Promise<Record<string, any>>;
|
|
613
602
|
}
|
|
614
603
|
|
|
615
|
-
export interface MediaVizUtils {
|
|
616
|
-
getMediaAccessQuery(projectTableName: string): Promise<any>;
|
|
617
|
-
authorizeMediaUrl(photoUrl: string, projectTableName: string): Promise<any>;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
604
|
export class MediaViz {
|
|
621
605
|
constructor(config?: MediaVizConfig);
|
|
622
606
|
authenticate(): Promise<TokenResponse>;
|
|
@@ -633,7 +617,6 @@ export class MediaViz {
|
|
|
633
617
|
readonly emailTokens: EmailTokens;
|
|
634
618
|
readonly health: Health;
|
|
635
619
|
readonly keywords: Keywords;
|
|
636
|
-
readonly media: Media;
|
|
637
620
|
readonly oAuthAuthorization: OauthAuthorization;
|
|
638
621
|
readonly oAuthToken: OauthToken;
|
|
639
622
|
readonly oauthLogin: OauthLogin;
|
|
@@ -645,6 +628,159 @@ export class MediaViz {
|
|
|
645
628
|
readonly subscription: Subscription;
|
|
646
629
|
readonly users: Users;
|
|
647
630
|
readonly webhooks: WebhookConsumer;
|
|
648
|
-
readonly utils: MediaVizUtils;
|
|
649
631
|
}
|
|
650
632
|
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
// ── React Native adapters ──────────────────────────────────────────────────
|
|
636
|
+
// Bundled from react_native_module/ and re-exported from the package root.
|
|
637
|
+
|
|
638
|
+
/** Token shape the stores read back. Both tokens may be absent. */
|
|
639
|
+
export interface TokenPair {
|
|
640
|
+
accessToken: string | null;
|
|
641
|
+
refreshToken: string | null;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Persistence contract. `save` accepts either the OAuth client's snake_case
|
|
646
|
+
* response or the client's camelCase getters; both normalise to TokenPair.
|
|
647
|
+
*/
|
|
648
|
+
export interface TokenStore {
|
|
649
|
+
load(): Promise<TokenPair>;
|
|
650
|
+
save(tokens: unknown): Promise<void>;
|
|
651
|
+
clear(): Promise<void>;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/** Native crypto, as expo-crypto or react-native-quick-crypto expose it. */
|
|
655
|
+
export interface CryptoImpl {
|
|
656
|
+
/** May fill in place and return void (expo-crypto) or return the array. */
|
|
657
|
+
getRandomValues(bytes: Uint8Array): Uint8Array | void;
|
|
658
|
+
/** May resolve a Uint8Array, ArrayBuffer, typed array, or byte array. */
|
|
659
|
+
digest(bytes: Uint8Array): Promise<Uint8Array | ArrayBuffer | ArrayBufferView | number[]> | Uint8Array | ArrayBuffer | ArrayBufferView | number[];
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/** Normalised provider the OAuth SDK's PKCE path consumes. */
|
|
663
|
+
export interface CryptoProvider {
|
|
664
|
+
getRandomValues(bytes: Uint8Array): Uint8Array;
|
|
665
|
+
sha256(bytes: Uint8Array): Promise<Uint8Array>;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/** Normalises either native crypto convention into a CryptoProvider. */
|
|
669
|
+
export declare function createCryptoProvider(impl: CryptoImpl): CryptoProvider;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Installs the provider PKCE uses. Must be called before any sign-in:
|
|
673
|
+
* Hermes ships no SubtleCrypto, so the default WebCrypto path throws.
|
|
674
|
+
*/
|
|
675
|
+
export declare function configureCrypto(provider: CryptoProvider): void;
|
|
676
|
+
|
|
677
|
+
/** Non-persistent default. Tokens are lost when the app is killed. */
|
|
678
|
+
export declare class MemoryTokenStore implements TokenStore {
|
|
679
|
+
load(): Promise<TokenPair>;
|
|
680
|
+
save(tokens: unknown): Promise<void>;
|
|
681
|
+
clear(): Promise<void>;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/** The subset of expo-secure-store this SDK calls. */
|
|
685
|
+
export interface SecureStoreLike {
|
|
686
|
+
getItemAsync(key: string, options?: Record<string, unknown>): Promise<string | null>;
|
|
687
|
+
setItemAsync(key: string, value: string, options?: Record<string, unknown>): Promise<void>;
|
|
688
|
+
deleteItemAsync(key: string, options?: Record<string, unknown>): Promise<void>;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
export interface SecureTokenStoreOptions {
|
|
692
|
+
accessKey?: string;
|
|
693
|
+
refreshKey?: string;
|
|
694
|
+
secureStoreOptions?: Record<string, unknown>;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Backed by expo-secure-store (Keychain on iOS, Keystore on Android). Tokens
|
|
699
|
+
* are stored under separate keys — a single value is capped at 2048 bytes and
|
|
700
|
+
* two JWTs in one blob can cross that.
|
|
701
|
+
*/
|
|
702
|
+
export declare function createSecureTokenStore(
|
|
703
|
+
SecureStore: SecureStoreLike,
|
|
704
|
+
options?: SecureTokenStoreOptions
|
|
705
|
+
): TokenStore;
|
|
706
|
+
|
|
707
|
+
/** The subset of react-native-keychain this SDK calls. */
|
|
708
|
+
export interface KeychainLike {
|
|
709
|
+
getGenericPassword(options?: Record<string, unknown>): Promise<{ password: string } | false>;
|
|
710
|
+
setGenericPassword(username: string, password: string, options?: Record<string, unknown>): Promise<unknown>;
|
|
711
|
+
resetGenericPassword(options?: Record<string, unknown>): Promise<unknown>;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
export interface KeychainTokenStoreOptions {
|
|
715
|
+
service?: string;
|
|
716
|
+
keychainOptions?: Record<string, unknown>;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/** Backed by react-native-keychain, which has no size cap, so one JSON entry. */
|
|
720
|
+
export declare function createKeychainTokenStore(
|
|
721
|
+
Keychain: KeychainLike,
|
|
722
|
+
options?: KeychainTokenStoreOptions
|
|
723
|
+
): TokenStore;
|
|
724
|
+
|
|
725
|
+
/** Contract of expo-web-browser's openAuthSessionAsync. */
|
|
726
|
+
export type OpenAuthSession = (
|
|
727
|
+
url: string,
|
|
728
|
+
redirectUri: string,
|
|
729
|
+
options?: Record<string, unknown>
|
|
730
|
+
) => Promise<{ type: string; url?: string }>;
|
|
731
|
+
|
|
732
|
+
/** 'cancelled' when the user dismissed the sheet, 'failed' otherwise. */
|
|
733
|
+
export declare class AuthSessionError extends Error {
|
|
734
|
+
readonly name: 'AuthSessionError';
|
|
735
|
+
readonly code: string;
|
|
736
|
+
constructor(code: string, message: string);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
export interface AuthSessionOptions {
|
|
740
|
+
openAuthSession: OpenAuthSession;
|
|
741
|
+
redirectUri: string;
|
|
742
|
+
state?: string;
|
|
743
|
+
sessionOptions?: Record<string, unknown>;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/** Runs the full interactive login and leaves the client authenticated. */
|
|
747
|
+
export declare function startAuthSession(
|
|
748
|
+
mv: MediaViz,
|
|
749
|
+
options: AuthSessionOptions
|
|
750
|
+
): Promise<TokenResponse>;
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Extracts query and fragment params from a redirect URL. Hand-rolled because
|
|
754
|
+
* React Native's URL polyfill mis-parses the custom schemes native redirect
|
|
755
|
+
* URIs use. Returns an empty object for input it cannot parse.
|
|
756
|
+
*/
|
|
757
|
+
export declare function parseRedirectUrl(url: string): Record<string, string>;
|
|
758
|
+
|
|
759
|
+
export interface SignInOverrides {
|
|
760
|
+
openAuthSession?: OpenAuthSession;
|
|
761
|
+
redirectUri?: string;
|
|
762
|
+
state?: string;
|
|
763
|
+
sessionOptions?: Record<string, unknown>;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
export interface CreateSessionOptions {
|
|
767
|
+
/** The MediaViz class itself — this module is copied into the package and cannot name its host. */
|
|
768
|
+
MediaViz: new (config?: MediaVizConfig) => MediaViz;
|
|
769
|
+
config?: MediaVizConfig;
|
|
770
|
+
/** Defaults to a MemoryTokenStore. */
|
|
771
|
+
store?: TokenStore;
|
|
772
|
+
openAuthSession?: OpenAuthSession;
|
|
773
|
+
onTokens?: (tokens: unknown | null) => void;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/** The signed-in lifecycle, independent of React. react.js binds over this. */
|
|
777
|
+
export interface Session {
|
|
778
|
+
readonly client: MediaViz;
|
|
779
|
+
readonly store: TokenStore;
|
|
780
|
+
/** Loads persisted tokens into the client. Resolves null when there are none. */
|
|
781
|
+
restore(): Promise<TokenPair | null>;
|
|
782
|
+
signIn(overrides?: SignInOverrides): Promise<TokenResponse>;
|
|
783
|
+
signOut(): Promise<void>;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
export declare function createSession(options: CreateSessionOptions): Session;
|
package/dist/sdk.esm.d.ts
CHANGED
|
@@ -216,15 +216,8 @@ export interface KeywordListDisplayWithProjects {
|
|
|
216
216
|
list_projects_associated?: string[];
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
export interface MediaAccessQueryDisplay {
|
|
220
|
-
query_string: string;
|
|
221
|
-
url_prefix: string;
|
|
222
|
-
expires_at: string;
|
|
223
|
-
project_table_name: string;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
219
|
export interface PhotoDisplay {
|
|
227
|
-
photo_s3_link
|
|
220
|
+
photo_s3_link: string;
|
|
228
221
|
client_side_id?: string;
|
|
229
222
|
moment_id?: number;
|
|
230
223
|
file_path?: string;
|
|
@@ -336,7 +329,7 @@ export interface PhotoPersonWithS3Link {
|
|
|
336
329
|
bounding_box: Record<string, any>;
|
|
337
330
|
confidence: number;
|
|
338
331
|
person_name: string;
|
|
339
|
-
photo_s3_link
|
|
332
|
+
photo_s3_link: string;
|
|
340
333
|
}
|
|
341
334
|
|
|
342
335
|
export interface ProjectRunDisplay {
|
|
@@ -507,10 +500,6 @@ export class Keywords {
|
|
|
507
500
|
deleteKeywordFilteringListById(keywordListId: number): Promise<Record<string, any>>;
|
|
508
501
|
}
|
|
509
502
|
|
|
510
|
-
export class Media {
|
|
511
|
-
getProjectAccessQuery(projectTableName: string): Promise<MediaAccessQueryDisplay>;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
503
|
export class OauthAuthorization {
|
|
515
504
|
authorize(options?: { responseType?: string | string[], clientId?: string | string[], redirectUri?: string | string[], state?: string | string[], codeChallenge?: string | string[], codeChallengeMethod?: string | string[] }): Promise<any>;
|
|
516
505
|
getConsent(sessionId: string): Promise<any>;
|
|
@@ -612,11 +601,6 @@ export class Users {
|
|
|
612
601
|
deleteUser(userId: number, options?: { newCompanyOwnerId?: number | number[] }): Promise<Record<string, any>>;
|
|
613
602
|
}
|
|
614
603
|
|
|
615
|
-
export interface MediaVizUtils {
|
|
616
|
-
getMediaAccessQuery(projectTableName: string): Promise<any>;
|
|
617
|
-
authorizeMediaUrl(photoUrl: string, projectTableName: string): Promise<any>;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
604
|
export class MediaViz {
|
|
621
605
|
constructor(config?: MediaVizConfig);
|
|
622
606
|
authenticate(): Promise<TokenResponse>;
|
|
@@ -633,7 +617,6 @@ export class MediaViz {
|
|
|
633
617
|
readonly emailTokens: EmailTokens;
|
|
634
618
|
readonly health: Health;
|
|
635
619
|
readonly keywords: Keywords;
|
|
636
|
-
readonly media: Media;
|
|
637
620
|
readonly oAuthAuthorization: OauthAuthorization;
|
|
638
621
|
readonly oAuthToken: OauthToken;
|
|
639
622
|
readonly oauthLogin: OauthLogin;
|
|
@@ -645,6 +628,159 @@ export class MediaViz {
|
|
|
645
628
|
readonly subscription: Subscription;
|
|
646
629
|
readonly users: Users;
|
|
647
630
|
readonly webhooks: WebhookConsumer;
|
|
648
|
-
readonly utils: MediaVizUtils;
|
|
649
631
|
}
|
|
650
632
|
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
// ── React Native adapters ──────────────────────────────────────────────────
|
|
636
|
+
// Bundled from react_native_module/ and re-exported from the package root.
|
|
637
|
+
|
|
638
|
+
/** Token shape the stores read back. Both tokens may be absent. */
|
|
639
|
+
export interface TokenPair {
|
|
640
|
+
accessToken: string | null;
|
|
641
|
+
refreshToken: string | null;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Persistence contract. `save` accepts either the OAuth client's snake_case
|
|
646
|
+
* response or the client's camelCase getters; both normalise to TokenPair.
|
|
647
|
+
*/
|
|
648
|
+
export interface TokenStore {
|
|
649
|
+
load(): Promise<TokenPair>;
|
|
650
|
+
save(tokens: unknown): Promise<void>;
|
|
651
|
+
clear(): Promise<void>;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/** Native crypto, as expo-crypto or react-native-quick-crypto expose it. */
|
|
655
|
+
export interface CryptoImpl {
|
|
656
|
+
/** May fill in place and return void (expo-crypto) or return the array. */
|
|
657
|
+
getRandomValues(bytes: Uint8Array): Uint8Array | void;
|
|
658
|
+
/** May resolve a Uint8Array, ArrayBuffer, typed array, or byte array. */
|
|
659
|
+
digest(bytes: Uint8Array): Promise<Uint8Array | ArrayBuffer | ArrayBufferView | number[]> | Uint8Array | ArrayBuffer | ArrayBufferView | number[];
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/** Normalised provider the OAuth SDK's PKCE path consumes. */
|
|
663
|
+
export interface CryptoProvider {
|
|
664
|
+
getRandomValues(bytes: Uint8Array): Uint8Array;
|
|
665
|
+
sha256(bytes: Uint8Array): Promise<Uint8Array>;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/** Normalises either native crypto convention into a CryptoProvider. */
|
|
669
|
+
export declare function createCryptoProvider(impl: CryptoImpl): CryptoProvider;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Installs the provider PKCE uses. Must be called before any sign-in:
|
|
673
|
+
* Hermes ships no SubtleCrypto, so the default WebCrypto path throws.
|
|
674
|
+
*/
|
|
675
|
+
export declare function configureCrypto(provider: CryptoProvider): void;
|
|
676
|
+
|
|
677
|
+
/** Non-persistent default. Tokens are lost when the app is killed. */
|
|
678
|
+
export declare class MemoryTokenStore implements TokenStore {
|
|
679
|
+
load(): Promise<TokenPair>;
|
|
680
|
+
save(tokens: unknown): Promise<void>;
|
|
681
|
+
clear(): Promise<void>;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/** The subset of expo-secure-store this SDK calls. */
|
|
685
|
+
export interface SecureStoreLike {
|
|
686
|
+
getItemAsync(key: string, options?: Record<string, unknown>): Promise<string | null>;
|
|
687
|
+
setItemAsync(key: string, value: string, options?: Record<string, unknown>): Promise<void>;
|
|
688
|
+
deleteItemAsync(key: string, options?: Record<string, unknown>): Promise<void>;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
export interface SecureTokenStoreOptions {
|
|
692
|
+
accessKey?: string;
|
|
693
|
+
refreshKey?: string;
|
|
694
|
+
secureStoreOptions?: Record<string, unknown>;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Backed by expo-secure-store (Keychain on iOS, Keystore on Android). Tokens
|
|
699
|
+
* are stored under separate keys — a single value is capped at 2048 bytes and
|
|
700
|
+
* two JWTs in one blob can cross that.
|
|
701
|
+
*/
|
|
702
|
+
export declare function createSecureTokenStore(
|
|
703
|
+
SecureStore: SecureStoreLike,
|
|
704
|
+
options?: SecureTokenStoreOptions
|
|
705
|
+
): TokenStore;
|
|
706
|
+
|
|
707
|
+
/** The subset of react-native-keychain this SDK calls. */
|
|
708
|
+
export interface KeychainLike {
|
|
709
|
+
getGenericPassword(options?: Record<string, unknown>): Promise<{ password: string } | false>;
|
|
710
|
+
setGenericPassword(username: string, password: string, options?: Record<string, unknown>): Promise<unknown>;
|
|
711
|
+
resetGenericPassword(options?: Record<string, unknown>): Promise<unknown>;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
export interface KeychainTokenStoreOptions {
|
|
715
|
+
service?: string;
|
|
716
|
+
keychainOptions?: Record<string, unknown>;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/** Backed by react-native-keychain, which has no size cap, so one JSON entry. */
|
|
720
|
+
export declare function createKeychainTokenStore(
|
|
721
|
+
Keychain: KeychainLike,
|
|
722
|
+
options?: KeychainTokenStoreOptions
|
|
723
|
+
): TokenStore;
|
|
724
|
+
|
|
725
|
+
/** Contract of expo-web-browser's openAuthSessionAsync. */
|
|
726
|
+
export type OpenAuthSession = (
|
|
727
|
+
url: string,
|
|
728
|
+
redirectUri: string,
|
|
729
|
+
options?: Record<string, unknown>
|
|
730
|
+
) => Promise<{ type: string; url?: string }>;
|
|
731
|
+
|
|
732
|
+
/** 'cancelled' when the user dismissed the sheet, 'failed' otherwise. */
|
|
733
|
+
export declare class AuthSessionError extends Error {
|
|
734
|
+
readonly name: 'AuthSessionError';
|
|
735
|
+
readonly code: string;
|
|
736
|
+
constructor(code: string, message: string);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
export interface AuthSessionOptions {
|
|
740
|
+
openAuthSession: OpenAuthSession;
|
|
741
|
+
redirectUri: string;
|
|
742
|
+
state?: string;
|
|
743
|
+
sessionOptions?: Record<string, unknown>;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/** Runs the full interactive login and leaves the client authenticated. */
|
|
747
|
+
export declare function startAuthSession(
|
|
748
|
+
mv: MediaViz,
|
|
749
|
+
options: AuthSessionOptions
|
|
750
|
+
): Promise<TokenResponse>;
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Extracts query and fragment params from a redirect URL. Hand-rolled because
|
|
754
|
+
* React Native's URL polyfill mis-parses the custom schemes native redirect
|
|
755
|
+
* URIs use. Returns an empty object for input it cannot parse.
|
|
756
|
+
*/
|
|
757
|
+
export declare function parseRedirectUrl(url: string): Record<string, string>;
|
|
758
|
+
|
|
759
|
+
export interface SignInOverrides {
|
|
760
|
+
openAuthSession?: OpenAuthSession;
|
|
761
|
+
redirectUri?: string;
|
|
762
|
+
state?: string;
|
|
763
|
+
sessionOptions?: Record<string, unknown>;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
export interface CreateSessionOptions {
|
|
767
|
+
/** The MediaViz class itself — this module is copied into the package and cannot name its host. */
|
|
768
|
+
MediaViz: new (config?: MediaVizConfig) => MediaViz;
|
|
769
|
+
config?: MediaVizConfig;
|
|
770
|
+
/** Defaults to a MemoryTokenStore. */
|
|
771
|
+
store?: TokenStore;
|
|
772
|
+
openAuthSession?: OpenAuthSession;
|
|
773
|
+
onTokens?: (tokens: unknown | null) => void;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/** The signed-in lifecycle, independent of React. react.js binds over this. */
|
|
777
|
+
export interface Session {
|
|
778
|
+
readonly client: MediaViz;
|
|
779
|
+
readonly store: TokenStore;
|
|
780
|
+
/** Loads persisted tokens into the client. Resolves null when there are none. */
|
|
781
|
+
restore(): Promise<TokenPair | null>;
|
|
782
|
+
signIn(overrides?: SignInOverrides): Promise<TokenResponse>;
|
|
783
|
+
signOut(): Promise<void>;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
export declare function createSession(options: CreateSessionOptions): Session;
|
package/dist/sdk.esm.js
CHANGED
|
@@ -1629,17 +1629,6 @@ class Keywords {
|
|
|
1629
1629
|
}
|
|
1630
1630
|
}
|
|
1631
1631
|
|
|
1632
|
-
class Media {
|
|
1633
|
-
constructor(ctx) { this._ctx = ctx; }
|
|
1634
|
-
|
|
1635
|
-
async getProjectAccessQuery(projectTableName) {
|
|
1636
|
-
this._ctx.requireTokens();
|
|
1637
|
-
const path = `/api/v1/media/project/${encodeURIComponent(projectTableName)}/access_query`;
|
|
1638
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1639
|
-
return data;
|
|
1640
|
-
}
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
1632
|
class OauthAuthorization {
|
|
1644
1633
|
constructor(ctx) { this._ctx = ctx; }
|
|
1645
1634
|
|
|
@@ -2459,7 +2448,6 @@ class _Context {
|
|
|
2459
2448
|
get refreshToken() { return this._mv._refreshToken; }
|
|
2460
2449
|
get baseUrl() { return this._mv._config.baseUrl; }
|
|
2461
2450
|
get hosts() { return this._mv._hosts; }
|
|
2462
|
-
get utils() { return this._mv.utils; }
|
|
2463
2451
|
requireHost(key) {
|
|
2464
2452
|
const url = this._mv._hosts[key];
|
|
2465
2453
|
if (!url) throw new Error(`Host '${key}' not configured. Pass hosts.${key} in MediaViz constructor or set the corresponding env var.`);
|
|
@@ -2482,51 +2470,6 @@ class _TokenTrackingClient {
|
|
|
2482
2470
|
}
|
|
2483
2471
|
}
|
|
2484
2472
|
|
|
2485
|
-
class _Utils {
|
|
2486
|
-
constructor(mv) { this._mv = mv; }
|
|
2487
|
-
async getMediaAccessQuery(projectTableName) {
|
|
2488
|
-
if (!this._mv._accessToken) throw new Error('Not authenticated. Call authenticate(), handleCallback(), or setTokens() first.');
|
|
2489
|
-
// Memo lives on the _Utils instance, so it is scoped to one MediaViz client
|
|
2490
|
-
// (one authenticated user) — keying on project alone cannot leak across users.
|
|
2491
|
-
if (!this._mediaQueryMemo) this._mediaQueryMemo = new Map();
|
|
2492
|
-
const _nowSec = Date.now() / 1000;
|
|
2493
|
-
const _memo = this._mediaQueryMemo.get(projectTableName);
|
|
2494
|
-
// Re-mint 60s early: an <img> load that starts just before expiry must not race
|
|
2495
|
-
// the policy going stale and 403 mid-flight.
|
|
2496
|
-
if (_memo && _memo.expiresEpoch - 60 > _nowSec) return _memo.result;
|
|
2497
|
-
|
|
2498
|
-
// Through the generated endpoint method, not a bare fetch: this inherits the
|
|
2499
|
-
// oauth client's 401-refresh-and-retry. Errors propagate — without a query
|
|
2500
|
-
// string there is nothing to render.
|
|
2501
|
-
const _result = await this._mv.media.getProjectAccessQuery(projectTableName);
|
|
2502
|
-
|
|
2503
|
-
const _expiresEpoch = Date.parse(_result.expires_at) / 1000;
|
|
2504
|
-
// Skip the memo on an unparseable expiry rather than cache something that can
|
|
2505
|
-
// never be invalidated.
|
|
2506
|
-
if (!Number.isNaN(_expiresEpoch)) {
|
|
2507
|
-
this._mediaQueryMemo.set(projectTableName, { expiresEpoch: _expiresEpoch, result: _result });
|
|
2508
|
-
}
|
|
2509
|
-
return _result;
|
|
2510
|
-
}
|
|
2511
|
-
async authorizeMediaUrl(photoUrl, projectTableName) {
|
|
2512
|
-
if (!this._mv._accessToken) throw new Error('Not authenticated. Call authenticate(), handleCallback(), or setTokens() first.');
|
|
2513
|
-
// Memoized upstream, so calling this once per tile in a grid still costs one
|
|
2514
|
-
// round trip for the whole project.
|
|
2515
|
-
const _access = await this.getMediaAccessQuery(projectTableName);
|
|
2516
|
-
|
|
2517
|
-
// Already signed: return untouched. Appending a second policy yields duplicate
|
|
2518
|
-
// Policy/Signature params and an opaque 403 at the edge, and the caller almost
|
|
2519
|
-
// certainly passed a URL this function already authorized.
|
|
2520
|
-
//
|
|
2521
|
-
// Keyed on Key-Pair-Id, not Policy: the query-string params are Policy /
|
|
2522
|
-
// Signature / Key-Pair-Id (NOT the CloudFront-* spelling the cookie path used),
|
|
2523
|
-
// and 'Policy' alone is generic enough to collide with an unrelated param.
|
|
2524
|
-
if (/[?&]Key-Pair-Id=/.test(photoUrl)) return photoUrl;
|
|
2525
|
-
|
|
2526
|
-
return photoUrl + (photoUrl.includes('?') ? '&' : '?') + _access.query_string;
|
|
2527
|
-
}
|
|
2528
|
-
}
|
|
2529
|
-
|
|
2530
2473
|
class MediaViz {
|
|
2531
2474
|
constructor(config = {}) {
|
|
2532
2475
|
this._config = {
|
|
@@ -2560,7 +2503,6 @@ class MediaViz {
|
|
|
2560
2503
|
this.emailTokens = new EmailTokens(_ctx);
|
|
2561
2504
|
this.health = new Health(_ctx);
|
|
2562
2505
|
this.keywords = new Keywords(_ctx);
|
|
2563
|
-
this.media = new Media(_ctx);
|
|
2564
2506
|
this.oAuthAuthorization = new OauthAuthorization(_ctx);
|
|
2565
2507
|
this.oAuthToken = new OauthToken(_ctx);
|
|
2566
2508
|
this.oauthLogin = new OauthLogin(_ctx);
|
|
@@ -2572,7 +2514,6 @@ class MediaViz {
|
|
|
2572
2514
|
this.subscription = new Subscription(_ctx);
|
|
2573
2515
|
this.users = new Users(_ctx);
|
|
2574
2516
|
this.webhooks = new WebhookConsumer(_ctx, this.subscription);
|
|
2575
|
-
this.utils = new _Utils(this);
|
|
2576
2517
|
}
|
|
2577
2518
|
|
|
2578
2519
|
async authenticate() {
|
|
@@ -2983,4 +2924,4 @@ var _react_native = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
|
|
|
2983
2924
|
// Auto-generated — do not edit
|
|
2984
2925
|
const { createCryptoProvider, MemoryTokenStore, createSecureTokenStore, createKeychainTokenStore, startAuthSession, parseRedirectUrl, AuthSessionError, createSession } = _react_native;
|
|
2985
2926
|
|
|
2986
|
-
export { Admin, AiModelCredits, ApiError, AuthSessionError, Company, CuratedAlbums, CustomAlbums, EmailTokens, Health, InMemoryWebhookStore, Keywords,
|
|
2927
|
+
export { Admin, AiModelCredits, ApiError, AuthSessionError, Company, CuratedAlbums, CustomAlbums, EmailTokens, Health, InMemoryWebhookStore, Keywords, MediaViz, MemoryTokenStore, NotFoundError, OAuthClient, OAuthError, OAuthErrorCode, OauthAuthorization, OauthLogin, OauthToken, Person, Photos, Photoupload, Projects, RateLimitError, Search, ServerError, Subscription, Users, ValidationError, WEBHOOK_MODEL_COLUMNS, WEBHOOK_OUTCOME_MODELS, WebhookConsumer, configureCrypto, createCryptoProvider, createKeychainTokenStore, createSecureTokenStore, createSession, handleResponse, parseRedirectUrl, selectResultColumns, signWebhookPayload, startAuthSession, verifyWebhookSignature };
|
package/package.json
CHANGED