@mediaviz/react-native-sdk 1.9.0-rc.4 → 1.9.0-rc.5

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.d.cts CHANGED
@@ -620,3 +620,157 @@ export class MediaViz {
620
620
  readonly webhooks: WebhookConsumer;
621
621
  }
622
622
 
623
+
624
+
625
+ // ── React Native adapters ──────────────────────────────────────────────────
626
+ // Bundled from react_native_module/ and re-exported from the package root.
627
+
628
+ /** Token shape the stores read back. Both tokens may be absent. */
629
+ export interface TokenPair {
630
+ accessToken: string | null;
631
+ refreshToken: string | null;
632
+ }
633
+
634
+ /**
635
+ * Persistence contract. `save` accepts either the OAuth client's snake_case
636
+ * response or the client's camelCase getters; both normalise to TokenPair.
637
+ */
638
+ export interface TokenStore {
639
+ load(): Promise<TokenPair>;
640
+ save(tokens: unknown): Promise<void>;
641
+ clear(): Promise<void>;
642
+ }
643
+
644
+ /** Native crypto, as expo-crypto or react-native-quick-crypto expose it. */
645
+ export interface CryptoImpl {
646
+ /** May fill in place and return void (expo-crypto) or return the array. */
647
+ getRandomValues(bytes: Uint8Array): Uint8Array | void;
648
+ /** May resolve a Uint8Array, ArrayBuffer, typed array, or byte array. */
649
+ digest(bytes: Uint8Array): Promise<Uint8Array | ArrayBuffer | ArrayBufferView | number[]> | Uint8Array | ArrayBuffer | ArrayBufferView | number[];
650
+ }
651
+
652
+ /** Normalised provider the OAuth SDK's PKCE path consumes. */
653
+ export interface CryptoProvider {
654
+ getRandomValues(bytes: Uint8Array): Uint8Array;
655
+ sha256(bytes: Uint8Array): Promise<Uint8Array>;
656
+ }
657
+
658
+ /** Normalises either native crypto convention into a CryptoProvider. */
659
+ export declare function createCryptoProvider(impl: CryptoImpl): CryptoProvider;
660
+
661
+ /**
662
+ * Installs the provider PKCE uses. Must be called before any sign-in:
663
+ * Hermes ships no SubtleCrypto, so the default WebCrypto path throws.
664
+ */
665
+ export declare function configureCrypto(provider: CryptoProvider): void;
666
+
667
+ /** Non-persistent default. Tokens are lost when the app is killed. */
668
+ export declare class MemoryTokenStore implements TokenStore {
669
+ load(): Promise<TokenPair>;
670
+ save(tokens: unknown): Promise<void>;
671
+ clear(): Promise<void>;
672
+ }
673
+
674
+ /** The subset of expo-secure-store this SDK calls. */
675
+ export interface SecureStoreLike {
676
+ getItemAsync(key: string, options?: Record<string, unknown>): Promise<string | null>;
677
+ setItemAsync(key: string, value: string, options?: Record<string, unknown>): Promise<void>;
678
+ deleteItemAsync(key: string, options?: Record<string, unknown>): Promise<void>;
679
+ }
680
+
681
+ export interface SecureTokenStoreOptions {
682
+ accessKey?: string;
683
+ refreshKey?: string;
684
+ secureStoreOptions?: Record<string, unknown>;
685
+ }
686
+
687
+ /**
688
+ * Backed by expo-secure-store (Keychain on iOS, Keystore on Android). Tokens
689
+ * are stored under separate keys — a single value is capped at 2048 bytes and
690
+ * two JWTs in one blob can cross that.
691
+ */
692
+ export declare function createSecureTokenStore(
693
+ SecureStore: SecureStoreLike,
694
+ options?: SecureTokenStoreOptions
695
+ ): TokenStore;
696
+
697
+ /** The subset of react-native-keychain this SDK calls. */
698
+ export interface KeychainLike {
699
+ getGenericPassword(options?: Record<string, unknown>): Promise<{ password: string } | false>;
700
+ setGenericPassword(username: string, password: string, options?: Record<string, unknown>): Promise<unknown>;
701
+ resetGenericPassword(options?: Record<string, unknown>): Promise<unknown>;
702
+ }
703
+
704
+ export interface KeychainTokenStoreOptions {
705
+ service?: string;
706
+ keychainOptions?: Record<string, unknown>;
707
+ }
708
+
709
+ /** Backed by react-native-keychain, which has no size cap, so one JSON entry. */
710
+ export declare function createKeychainTokenStore(
711
+ Keychain: KeychainLike,
712
+ options?: KeychainTokenStoreOptions
713
+ ): TokenStore;
714
+
715
+ /** Contract of expo-web-browser's openAuthSessionAsync. */
716
+ export type OpenAuthSession = (
717
+ url: string,
718
+ redirectUri: string,
719
+ options?: Record<string, unknown>
720
+ ) => Promise<{ type: string; url?: string }>;
721
+
722
+ /** 'cancelled' when the user dismissed the sheet, 'failed' otherwise. */
723
+ export declare class AuthSessionError extends Error {
724
+ readonly name: 'AuthSessionError';
725
+ readonly code: string;
726
+ constructor(code: string, message: string);
727
+ }
728
+
729
+ export interface AuthSessionOptions {
730
+ openAuthSession: OpenAuthSession;
731
+ redirectUri: string;
732
+ state?: string;
733
+ sessionOptions?: Record<string, unknown>;
734
+ }
735
+
736
+ /** Runs the full interactive login and leaves the client authenticated. */
737
+ export declare function startAuthSession(
738
+ mv: MediaViz,
739
+ options: AuthSessionOptions
740
+ ): Promise<TokenResponse>;
741
+
742
+ /**
743
+ * Extracts query and fragment params from a redirect URL. Hand-rolled because
744
+ * React Native's URL polyfill mis-parses the custom schemes native redirect
745
+ * URIs use. Returns an empty object for input it cannot parse.
746
+ */
747
+ export declare function parseRedirectUrl(url: string): Record<string, string>;
748
+
749
+ export interface SignInOverrides {
750
+ openAuthSession?: OpenAuthSession;
751
+ redirectUri?: string;
752
+ state?: string;
753
+ sessionOptions?: Record<string, unknown>;
754
+ }
755
+
756
+ export interface CreateSessionOptions {
757
+ /** The MediaViz class itself — this module is copied into the package and cannot name its host. */
758
+ MediaViz: new (config?: MediaVizConfig) => MediaViz;
759
+ config?: MediaVizConfig;
760
+ /** Defaults to a MemoryTokenStore. */
761
+ store?: TokenStore;
762
+ openAuthSession?: OpenAuthSession;
763
+ onTokens?: (tokens: unknown | null) => void;
764
+ }
765
+
766
+ /** The signed-in lifecycle, independent of React. react.js binds over this. */
767
+ export interface Session {
768
+ readonly client: MediaViz;
769
+ readonly store: TokenStore;
770
+ /** Loads persisted tokens into the client. Resolves null when there are none. */
771
+ restore(): Promise<TokenPair | null>;
772
+ signIn(overrides?: SignInOverrides): Promise<TokenResponse>;
773
+ signOut(): Promise<void>;
774
+ }
775
+
776
+ export declare function createSession(options: CreateSessionOptions): Session;
package/dist/sdk.d.ts CHANGED
@@ -620,3 +620,157 @@ export class MediaViz {
620
620
  readonly webhooks: WebhookConsumer;
621
621
  }
622
622
 
623
+
624
+
625
+ // ── React Native adapters ──────────────────────────────────────────────────
626
+ // Bundled from react_native_module/ and re-exported from the package root.
627
+
628
+ /** Token shape the stores read back. Both tokens may be absent. */
629
+ export interface TokenPair {
630
+ accessToken: string | null;
631
+ refreshToken: string | null;
632
+ }
633
+
634
+ /**
635
+ * Persistence contract. `save` accepts either the OAuth client's snake_case
636
+ * response or the client's camelCase getters; both normalise to TokenPair.
637
+ */
638
+ export interface TokenStore {
639
+ load(): Promise<TokenPair>;
640
+ save(tokens: unknown): Promise<void>;
641
+ clear(): Promise<void>;
642
+ }
643
+
644
+ /** Native crypto, as expo-crypto or react-native-quick-crypto expose it. */
645
+ export interface CryptoImpl {
646
+ /** May fill in place and return void (expo-crypto) or return the array. */
647
+ getRandomValues(bytes: Uint8Array): Uint8Array | void;
648
+ /** May resolve a Uint8Array, ArrayBuffer, typed array, or byte array. */
649
+ digest(bytes: Uint8Array): Promise<Uint8Array | ArrayBuffer | ArrayBufferView | number[]> | Uint8Array | ArrayBuffer | ArrayBufferView | number[];
650
+ }
651
+
652
+ /** Normalised provider the OAuth SDK's PKCE path consumes. */
653
+ export interface CryptoProvider {
654
+ getRandomValues(bytes: Uint8Array): Uint8Array;
655
+ sha256(bytes: Uint8Array): Promise<Uint8Array>;
656
+ }
657
+
658
+ /** Normalises either native crypto convention into a CryptoProvider. */
659
+ export declare function createCryptoProvider(impl: CryptoImpl): CryptoProvider;
660
+
661
+ /**
662
+ * Installs the provider PKCE uses. Must be called before any sign-in:
663
+ * Hermes ships no SubtleCrypto, so the default WebCrypto path throws.
664
+ */
665
+ export declare function configureCrypto(provider: CryptoProvider): void;
666
+
667
+ /** Non-persistent default. Tokens are lost when the app is killed. */
668
+ export declare class MemoryTokenStore implements TokenStore {
669
+ load(): Promise<TokenPair>;
670
+ save(tokens: unknown): Promise<void>;
671
+ clear(): Promise<void>;
672
+ }
673
+
674
+ /** The subset of expo-secure-store this SDK calls. */
675
+ export interface SecureStoreLike {
676
+ getItemAsync(key: string, options?: Record<string, unknown>): Promise<string | null>;
677
+ setItemAsync(key: string, value: string, options?: Record<string, unknown>): Promise<void>;
678
+ deleteItemAsync(key: string, options?: Record<string, unknown>): Promise<void>;
679
+ }
680
+
681
+ export interface SecureTokenStoreOptions {
682
+ accessKey?: string;
683
+ refreshKey?: string;
684
+ secureStoreOptions?: Record<string, unknown>;
685
+ }
686
+
687
+ /**
688
+ * Backed by expo-secure-store (Keychain on iOS, Keystore on Android). Tokens
689
+ * are stored under separate keys — a single value is capped at 2048 bytes and
690
+ * two JWTs in one blob can cross that.
691
+ */
692
+ export declare function createSecureTokenStore(
693
+ SecureStore: SecureStoreLike,
694
+ options?: SecureTokenStoreOptions
695
+ ): TokenStore;
696
+
697
+ /** The subset of react-native-keychain this SDK calls. */
698
+ export interface KeychainLike {
699
+ getGenericPassword(options?: Record<string, unknown>): Promise<{ password: string } | false>;
700
+ setGenericPassword(username: string, password: string, options?: Record<string, unknown>): Promise<unknown>;
701
+ resetGenericPassword(options?: Record<string, unknown>): Promise<unknown>;
702
+ }
703
+
704
+ export interface KeychainTokenStoreOptions {
705
+ service?: string;
706
+ keychainOptions?: Record<string, unknown>;
707
+ }
708
+
709
+ /** Backed by react-native-keychain, which has no size cap, so one JSON entry. */
710
+ export declare function createKeychainTokenStore(
711
+ Keychain: KeychainLike,
712
+ options?: KeychainTokenStoreOptions
713
+ ): TokenStore;
714
+
715
+ /** Contract of expo-web-browser's openAuthSessionAsync. */
716
+ export type OpenAuthSession = (
717
+ url: string,
718
+ redirectUri: string,
719
+ options?: Record<string, unknown>
720
+ ) => Promise<{ type: string; url?: string }>;
721
+
722
+ /** 'cancelled' when the user dismissed the sheet, 'failed' otherwise. */
723
+ export declare class AuthSessionError extends Error {
724
+ readonly name: 'AuthSessionError';
725
+ readonly code: string;
726
+ constructor(code: string, message: string);
727
+ }
728
+
729
+ export interface AuthSessionOptions {
730
+ openAuthSession: OpenAuthSession;
731
+ redirectUri: string;
732
+ state?: string;
733
+ sessionOptions?: Record<string, unknown>;
734
+ }
735
+
736
+ /** Runs the full interactive login and leaves the client authenticated. */
737
+ export declare function startAuthSession(
738
+ mv: MediaViz,
739
+ options: AuthSessionOptions
740
+ ): Promise<TokenResponse>;
741
+
742
+ /**
743
+ * Extracts query and fragment params from a redirect URL. Hand-rolled because
744
+ * React Native's URL polyfill mis-parses the custom schemes native redirect
745
+ * URIs use. Returns an empty object for input it cannot parse.
746
+ */
747
+ export declare function parseRedirectUrl(url: string): Record<string, string>;
748
+
749
+ export interface SignInOverrides {
750
+ openAuthSession?: OpenAuthSession;
751
+ redirectUri?: string;
752
+ state?: string;
753
+ sessionOptions?: Record<string, unknown>;
754
+ }
755
+
756
+ export interface CreateSessionOptions {
757
+ /** The MediaViz class itself — this module is copied into the package and cannot name its host. */
758
+ MediaViz: new (config?: MediaVizConfig) => MediaViz;
759
+ config?: MediaVizConfig;
760
+ /** Defaults to a MemoryTokenStore. */
761
+ store?: TokenStore;
762
+ openAuthSession?: OpenAuthSession;
763
+ onTokens?: (tokens: unknown | null) => void;
764
+ }
765
+
766
+ /** The signed-in lifecycle, independent of React. react.js binds over this. */
767
+ export interface Session {
768
+ readonly client: MediaViz;
769
+ readonly store: TokenStore;
770
+ /** Loads persisted tokens into the client. Resolves null when there are none. */
771
+ restore(): Promise<TokenPair | null>;
772
+ signIn(overrides?: SignInOverrides): Promise<TokenResponse>;
773
+ signOut(): Promise<void>;
774
+ }
775
+
776
+ export declare function createSession(options: CreateSessionOptions): Session;
package/dist/sdk.esm.d.ts CHANGED
@@ -620,3 +620,157 @@ export class MediaViz {
620
620
  readonly webhooks: WebhookConsumer;
621
621
  }
622
622
 
623
+
624
+
625
+ // ── React Native adapters ──────────────────────────────────────────────────
626
+ // Bundled from react_native_module/ and re-exported from the package root.
627
+
628
+ /** Token shape the stores read back. Both tokens may be absent. */
629
+ export interface TokenPair {
630
+ accessToken: string | null;
631
+ refreshToken: string | null;
632
+ }
633
+
634
+ /**
635
+ * Persistence contract. `save` accepts either the OAuth client's snake_case
636
+ * response or the client's camelCase getters; both normalise to TokenPair.
637
+ */
638
+ export interface TokenStore {
639
+ load(): Promise<TokenPair>;
640
+ save(tokens: unknown): Promise<void>;
641
+ clear(): Promise<void>;
642
+ }
643
+
644
+ /** Native crypto, as expo-crypto or react-native-quick-crypto expose it. */
645
+ export interface CryptoImpl {
646
+ /** May fill in place and return void (expo-crypto) or return the array. */
647
+ getRandomValues(bytes: Uint8Array): Uint8Array | void;
648
+ /** May resolve a Uint8Array, ArrayBuffer, typed array, or byte array. */
649
+ digest(bytes: Uint8Array): Promise<Uint8Array | ArrayBuffer | ArrayBufferView | number[]> | Uint8Array | ArrayBuffer | ArrayBufferView | number[];
650
+ }
651
+
652
+ /** Normalised provider the OAuth SDK's PKCE path consumes. */
653
+ export interface CryptoProvider {
654
+ getRandomValues(bytes: Uint8Array): Uint8Array;
655
+ sha256(bytes: Uint8Array): Promise<Uint8Array>;
656
+ }
657
+
658
+ /** Normalises either native crypto convention into a CryptoProvider. */
659
+ export declare function createCryptoProvider(impl: CryptoImpl): CryptoProvider;
660
+
661
+ /**
662
+ * Installs the provider PKCE uses. Must be called before any sign-in:
663
+ * Hermes ships no SubtleCrypto, so the default WebCrypto path throws.
664
+ */
665
+ export declare function configureCrypto(provider: CryptoProvider): void;
666
+
667
+ /** Non-persistent default. Tokens are lost when the app is killed. */
668
+ export declare class MemoryTokenStore implements TokenStore {
669
+ load(): Promise<TokenPair>;
670
+ save(tokens: unknown): Promise<void>;
671
+ clear(): Promise<void>;
672
+ }
673
+
674
+ /** The subset of expo-secure-store this SDK calls. */
675
+ export interface SecureStoreLike {
676
+ getItemAsync(key: string, options?: Record<string, unknown>): Promise<string | null>;
677
+ setItemAsync(key: string, value: string, options?: Record<string, unknown>): Promise<void>;
678
+ deleteItemAsync(key: string, options?: Record<string, unknown>): Promise<void>;
679
+ }
680
+
681
+ export interface SecureTokenStoreOptions {
682
+ accessKey?: string;
683
+ refreshKey?: string;
684
+ secureStoreOptions?: Record<string, unknown>;
685
+ }
686
+
687
+ /**
688
+ * Backed by expo-secure-store (Keychain on iOS, Keystore on Android). Tokens
689
+ * are stored under separate keys — a single value is capped at 2048 bytes and
690
+ * two JWTs in one blob can cross that.
691
+ */
692
+ export declare function createSecureTokenStore(
693
+ SecureStore: SecureStoreLike,
694
+ options?: SecureTokenStoreOptions
695
+ ): TokenStore;
696
+
697
+ /** The subset of react-native-keychain this SDK calls. */
698
+ export interface KeychainLike {
699
+ getGenericPassword(options?: Record<string, unknown>): Promise<{ password: string } | false>;
700
+ setGenericPassword(username: string, password: string, options?: Record<string, unknown>): Promise<unknown>;
701
+ resetGenericPassword(options?: Record<string, unknown>): Promise<unknown>;
702
+ }
703
+
704
+ export interface KeychainTokenStoreOptions {
705
+ service?: string;
706
+ keychainOptions?: Record<string, unknown>;
707
+ }
708
+
709
+ /** Backed by react-native-keychain, which has no size cap, so one JSON entry. */
710
+ export declare function createKeychainTokenStore(
711
+ Keychain: KeychainLike,
712
+ options?: KeychainTokenStoreOptions
713
+ ): TokenStore;
714
+
715
+ /** Contract of expo-web-browser's openAuthSessionAsync. */
716
+ export type OpenAuthSession = (
717
+ url: string,
718
+ redirectUri: string,
719
+ options?: Record<string, unknown>
720
+ ) => Promise<{ type: string; url?: string }>;
721
+
722
+ /** 'cancelled' when the user dismissed the sheet, 'failed' otherwise. */
723
+ export declare class AuthSessionError extends Error {
724
+ readonly name: 'AuthSessionError';
725
+ readonly code: string;
726
+ constructor(code: string, message: string);
727
+ }
728
+
729
+ export interface AuthSessionOptions {
730
+ openAuthSession: OpenAuthSession;
731
+ redirectUri: string;
732
+ state?: string;
733
+ sessionOptions?: Record<string, unknown>;
734
+ }
735
+
736
+ /** Runs the full interactive login and leaves the client authenticated. */
737
+ export declare function startAuthSession(
738
+ mv: MediaViz,
739
+ options: AuthSessionOptions
740
+ ): Promise<TokenResponse>;
741
+
742
+ /**
743
+ * Extracts query and fragment params from a redirect URL. Hand-rolled because
744
+ * React Native's URL polyfill mis-parses the custom schemes native redirect
745
+ * URIs use. Returns an empty object for input it cannot parse.
746
+ */
747
+ export declare function parseRedirectUrl(url: string): Record<string, string>;
748
+
749
+ export interface SignInOverrides {
750
+ openAuthSession?: OpenAuthSession;
751
+ redirectUri?: string;
752
+ state?: string;
753
+ sessionOptions?: Record<string, unknown>;
754
+ }
755
+
756
+ export interface CreateSessionOptions {
757
+ /** The MediaViz class itself — this module is copied into the package and cannot name its host. */
758
+ MediaViz: new (config?: MediaVizConfig) => MediaViz;
759
+ config?: MediaVizConfig;
760
+ /** Defaults to a MemoryTokenStore. */
761
+ store?: TokenStore;
762
+ openAuthSession?: OpenAuthSession;
763
+ onTokens?: (tokens: unknown | null) => void;
764
+ }
765
+
766
+ /** The signed-in lifecycle, independent of React. react.js binds over this. */
767
+ export interface Session {
768
+ readonly client: MediaViz;
769
+ readonly store: TokenStore;
770
+ /** Loads persisted tokens into the client. Resolves null when there are none. */
771
+ restore(): Promise<TokenPair | null>;
772
+ signIn(overrides?: SignInOverrides): Promise<TokenResponse>;
773
+ signOut(): Promise<void>;
774
+ }
775
+
776
+ export declare function createSession(options: CreateSessionOptions): Session;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediaviz/react-native-sdk",
3
- "version": "1.9.0-rc.4",
3
+ "version": "1.9.0-rc.5",
4
4
  "description": "MediaViz React Native SDK \u2014 auto-generated endpoint client for React Native and Expo.",
5
5
  "license": "MIT",
6
6
  "repository": {