@nihinmedia/medgen-react-native 1.0.9

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.
@@ -0,0 +1,17 @@
1
+ export let MedGenEnvironment = function(MedGenEnvironment) {
2
+ MedGenEnvironment["Development"] = "development";
3
+ MedGenEnvironment["Staging"] = "staging";
4
+ MedGenEnvironment["Production"] = "production";
5
+ return MedGenEnvironment;
6
+ }({});
7
+
8
+ export class MedGenError extends Error {
9
+ constructor(code, message, retryable = false, supportReference) {
10
+ super(message);
11
+ this.name = "MedGenError";
12
+ this.code = code;
13
+ this.retryable = retryable;
14
+ this.supportReference = supportReference;
15
+ Object.setPrototypeOf(this, MedGenError.prototype);
16
+ }
17
+ }
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { MedGenCapabilities, MedGenNativeHandlers } from './types';
3
+
4
+ export declare const originOf: (u: string) => string;
5
+
6
+ export type NavigationDecision = 'load' | 'external' | 'block';
7
+ export declare const decideNavigation: (url: string, base: string, isTopFrame?: boolean) => NavigationDecision;
8
+
9
+ export declare const isSameOrigin: (target: string, base: string) => boolean;
10
+ interface Props {
11
+ url: string;
12
+ handlers: MedGenNativeHandlers;
13
+ capabilities: MedGenCapabilities;
14
+ onClose: () => void;
15
+ }
16
+
17
+ export declare const MedGenWebView: React.FC<Props>;
18
+ export {};
@@ -0,0 +1,12 @@
1
+ import { MedGenCapabilities, MedGenNativeHandlers } from './types';
2
+ type Reply = (json: string) => void;
3
+ export interface BridgeContext {
4
+ handlers: MedGenNativeHandlers;
5
+ capabilities: MedGenCapabilities;
6
+ onClose: () => void;
7
+
8
+ nonce: string;
9
+ }
10
+
11
+ export declare function handleBridgeMessage(raw: string, reply: Reply, ctx: BridgeContext): Promise<void>;
12
+ export {};
@@ -0,0 +1,28 @@
1
+ import { ExchangeResult, MedGenCapabilities, MedGenConfig, MedGenEventName } from './types';
2
+ export declare const SDK_VERSION = "1.0.9";
3
+
4
+ export declare function configure(cfg: MedGenConfig): void;
5
+
6
+ export declare function resetConfig(): void;
7
+
8
+ export declare function requireConfig(): MedGenConfig;
9
+ export declare const apiBase: () => string;
10
+ export declare const embedBase: () => string;
11
+
12
+ export declare function emit(name: MedGenEventName, detail?: Record<string, unknown>): void;
13
+ export interface Credentials {
14
+ access: string;
15
+ refresh: string;
16
+ }
17
+
18
+ export declare function storeCredentials(creds: Credentials): Promise<void>;
19
+
20
+ export declare function readCredentials(): Promise<Credentials | null>;
21
+
22
+ export declare function clearCredentials(): Promise<void>;
23
+
24
+ export declare function parseCapabilities(raw: unknown): MedGenCapabilities;
25
+
26
+ export declare function exchange(): Promise<ExchangeResult>;
27
+
28
+ export declare function buildEmbedUrl(handoffCode: string, entryQuestion?: string, capabilities?: MedGenCapabilities): string;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { MedGenConfig, MedGenError, MedGenPresentOptions } from './types';
3
+ export * from './types';
4
+ export { SDK_VERSION } from './client';
5
+ export declare const MedGen: {
6
+
7
+ initialize(config: MedGenConfig): void;
8
+
9
+ present(options?: MedGenPresentOptions): Promise<void>;
10
+
11
+ signOut(): Promise<void>;
12
+ };
13
+
14
+ export declare const MedGenHost: React.FC;
15
+
16
+ export declare const MedGenSurface: React.FC<{
17
+
18
+ visible?: boolean;
19
+ options?: MedGenPresentOptions;
20
+ onError?: (e: MedGenError) => void;
21
+ }>;
@@ -0,0 +1,108 @@
1
+ export declare enum MedGenEnvironment {
2
+
3
+ Development = "development",
4
+
5
+ Staging = "staging",
6
+ Production = "production"
7
+ }
8
+ export interface MedGenPalette {
9
+ primary?: string;
10
+ secondary?: string;
11
+ accent?: string;
12
+ surface?: string;
13
+ onSurface?: string;
14
+ }
15
+ export interface MedGenTheme extends MedGenPalette {
16
+ darkVariant?: MedGenPalette;
17
+ }
18
+
19
+ export type AssertionProvider = () => Promise<string>;
20
+
21
+ export type AttestationProvider = (challenge: string) => Promise<string>;
22
+
23
+ export interface MedGenCapabilities {
24
+ theming: boolean;
25
+ customLogo: boolean;
26
+ hideAttribution: boolean;
27
+ quickAnswer: boolean;
28
+ detailedAnswer: boolean;
29
+ japaneseAnswer: boolean;
30
+ dictation: boolean;
31
+ fileUpload: boolean;
32
+
33
+ clipboard: boolean;
34
+ richClipboard: boolean;
35
+ share: boolean;
36
+ chatHistory: boolean;
37
+ bookmarks: boolean;
38
+ citationsPanel: boolean;
39
+ directLink: boolean;
40
+ }
41
+
42
+ export interface MedGenNativeHandlers {
43
+
44
+ onShare?: (text: string) => Promise<boolean>;
45
+
46
+ onCopy?: (content: {
47
+ text: string;
48
+ html?: string;
49
+ }) => Promise<boolean>;
50
+
51
+ onSpeechStart?: () => Promise<void>;
52
+
53
+ onSpeechStop?: () => Promise<string>;
54
+
55
+ onFilePick?: () => Promise<MedGenFile[]>;
56
+ }
57
+ export interface MedGenFile {
58
+ uri: string;
59
+ name: string;
60
+ mimeType: string;
61
+ size: number;
62
+ }
63
+ export interface MedGenConfig {
64
+ partnerId: string;
65
+ environment: MedGenEnvironment;
66
+
67
+ assertionProvider?: AssertionProvider;
68
+
69
+ assertion?: string;
70
+ attestationProvider?: AttestationProvider;
71
+ nativeHandlers?: MedGenNativeHandlers;
72
+ locale?: 'ja' | 'en';
73
+ theme?: MedGenTheme;
74
+ apiBaseUrl?: string;
75
+ embedBaseUrl?: string;
76
+
77
+ onEvent?: (event: MedGenEvent) => void;
78
+ }
79
+ export interface MedGenPresentOptions {
80
+ entryQuestion?: string;
81
+ }
82
+ export type MedGenEventName = 'exchange.started' | 'exchange.succeeded' | 'exchange.failed' | 'surface.opened' | 'surface.closed' | 'session.expired' | 'session.refreshed'
83
+
84
+ | 'surface.externalLinkOpened'
85
+
86
+ | 'surface.externalLinkFailed'
87
+
88
+ | 'surface.loadFailed';
89
+ export interface MedGenEvent {
90
+ name: MedGenEventName;
91
+ at: number;
92
+ detail?: Record<string, unknown>;
93
+ }
94
+ export type MedGenErrorCode = 'NOT_INITIALIZED' | 'ASSERTION_PROVIDER_FAILED' | 'ASSERTION_PROVIDER_TIMEOUT' | 'ASSERTION_EXPIRED' | 'ASSERTION_REPLAYED' | 'SIGNATURE_INVALID' | 'AUDIENCE_INVALID' | 'PARTNER_NOT_ENABLED' | 'PARTNER_SUSPENDED' | 'ATTESTATION_REQUIRED' | 'ATTESTATION_FAILED' | 'SUBJECT_REUSE_SUSPECTED' | 'RATE_LIMIT_EXCEEDED' | 'NETWORK_UNAVAILABLE' | 'SESSION_EXPIRED' | 'UNKNOWN';
95
+ export declare class MedGenError extends Error {
96
+ readonly code: MedGenErrorCode;
97
+ readonly retryable: boolean;
98
+ readonly supportReference?: string;
99
+ constructor(code: MedGenErrorCode, message: string, retryable?: boolean, supportReference?: string);
100
+ }
101
+ export interface ExchangeResult {
102
+ handoffCode: string;
103
+ isNewUser: boolean;
104
+
105
+ emailCollisionPending: boolean;
106
+ brandingVersion: string;
107
+ capabilities: MedGenCapabilities;
108
+ }
package/package.json ADDED
@@ -0,0 +1,97 @@
1
+ {
2
+ "name": "@nihinmedia/medgen-react-native",
3
+ "version": "1.0.9",
4
+ "description": "MedGen Japan SDK for React Native",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "private": false,
7
+ "main": "lib/commonjs/index.js",
8
+ "module": "lib/module/index.js",
9
+ "types": "lib/typescript/index.d.ts",
10
+ "react-native": "lib/module/index.js",
11
+ "files": [
12
+ "lib",
13
+ "android",
14
+ "ios",
15
+ "*.podspec",
16
+ "README.md",
17
+ "LICENSE",
18
+ "SECURITY.md",
19
+ "!**/__tests__",
20
+ "!**/.*"
21
+ ],
22
+ "scripts": {
23
+ "build": "bob build && npm run strip-maps && npm run strip-comments",
24
+ "typecheck": "tsc --noEmit",
25
+ "lint": "eslint src --ext .ts,.tsx",
26
+ "test": "jest",
27
+ "prepack": "npm run build && node scripts/swap-readme.mjs to-npm",
28
+ "strip-maps": "find lib -name '*.map' -delete && find lib -type f \\( -name '*.js' -o -name '*.d.ts' \\) -exec perl -0777 -pi -e 's{\\n?^//# sourceMappingURL=.*$}{}mg' {} +",
29
+ "strip-comments": "node scripts/strip-comments.mjs",
30
+ "postpack": "node scripts/swap-readme.mjs restore"
31
+ },
32
+ "keywords": [
33
+ "react-native",
34
+ "medgen",
35
+ "healthcare",
36
+ "sdk"
37
+ ],
38
+ "peerDependencies": {
39
+ "react": ">=18.0.0",
40
+ "react-native": ">=0.71.0",
41
+ "react-native-webview": ">=13.0.0"
42
+ },
43
+ "dependencies": {
44
+ "react-native-keychain": "^8.2.0"
45
+ },
46
+ "devDependencies": {
47
+ "@react-native/babel-preset": "^0.73.21",
48
+ "@types/jest": "^29.5.12",
49
+ "@types/react": "^18.2.6",
50
+ "babel-jest": "^29.7.0",
51
+ "eslint": "^8.19.0",
52
+ "jest": "^29.7.0",
53
+ "react": "18.2.0",
54
+ "react-native": "0.73.6",
55
+ "react-native-builder-bob": "^0.23.2",
56
+ "react-native-webview": "^13.8.6",
57
+ "terser": "^5.31.0",
58
+ "typescript": "5.3.3"
59
+ },
60
+ "react-native-builder-bob": {
61
+ "source": "src",
62
+ "output": "lib",
63
+ "targets": [
64
+ [
65
+ "commonjs",
66
+ {
67
+ "sourceMaps": false
68
+ }
69
+ ],
70
+ [
71
+ "module",
72
+ {
73
+ "sourceMaps": false
74
+ }
75
+ ],
76
+ [
77
+ "typescript",
78
+ {
79
+ "project": "tsconfig.build.json"
80
+ }
81
+ ]
82
+ ]
83
+ },
84
+ "publishConfig": {
85
+ "registry": "https://registry.npmjs.org/",
86
+ "access": "public"
87
+ },
88
+ "engines": {
89
+ "node": ">=18"
90
+ },
91
+ "bugs": {
92
+ "email": "contact@nihinmedia.jp"
93
+ },
94
+ "homepage": "https://nihinmedia.jp",
95
+ "author": "Nihin Media K. K. <contact@nihinmedia.jp>",
96
+ "sideEffects": false
97
+ }