@solana-mobile/seed-vault-lib 0.2.1 → 0.3.3

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/lib/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useRef, useEffect } from 'react';
2
- import { Platform, NativeModules, PermissionsAndroid, NativeEventEmitter } from 'react-native';
2
+ import { Platform, NativeModules, NativeEventEmitter, PermissionsAndroid } from 'react-native';
3
3
 
4
4
  // EVENTS
5
5
  // Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
@@ -9,7 +9,8 @@ const SeedVaultEventType = {
9
9
  ImportExistingSeed: "ExistingSeedImported",
10
10
  PayloadsSigned: "PayloadsSigned",
11
11
  GetPublicKeys: "PublicKeysEvent",
12
- ContentChange: "SeedVaultContentChange"
12
+ ContentChange: "SeedVaultContentChange",
13
+ SeedSettingsShown: "SeedSettingsShown"
13
14
  };
14
15
 
15
16
  const SeedPurpose = {
@@ -30,6 +31,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
30
31
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
31
32
  PERFORMANCE OF THIS SOFTWARE.
32
33
  ***************************************************************************** */
34
+ /* global Reflect, Promise */
35
+
33
36
 
34
37
  function __awaiter(thisArg, _arguments, P, generator) {
35
38
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -57,13 +60,15 @@ const SolanaMobileSeedVaultLib = Platform.OS === 'android' && NativeModules.Sola
57
60
  },
58
61
  });
59
62
  const SeedVaultPermissionAndroid = 'com.solanamobile.seedvault.ACCESS_SEED_VAULT';
60
- const checkSeedVaultPermission = () => __awaiter(void 0, void 0, void 0, function* () {
61
- const granted = yield PermissionsAndroid.check(SeedVaultPermissionAndroid);
63
+ const SeedVaultPrivilegedPermissionAndroid = 'com.solanamobile.seedvault.ACCESS_SEED_VAULT_PRIVILEGED';
64
+ const checkSeedVaultPermission = () => __awaiter(undefined, undefined, undefined, function* () {
65
+ const granted = (yield PermissionsAndroid.check(SeedVaultPermissionAndroid))
66
+ || (yield PermissionsAndroid.check(SeedVaultPrivilegedPermissionAndroid));
62
67
  if (!granted) {
63
68
  throw new Error('You do not have permission to access Seed Vault. You must request permission to use Seed Vault.');
64
69
  }
65
70
  });
66
- const checkIsSeedVaultAvailable = (allowSimulated = false) => __awaiter(void 0, void 0, void 0, function* () {
71
+ const checkIsSeedVaultAvailable = (...args_1) => __awaiter(undefined, [...args_1], undefined, function* (allowSimulated = false) {
67
72
  const seedVaultAvailable = yield SolanaMobileSeedVaultLib.isSeedVaultAvailable(allowSimulated);
68
73
  if (!seedVaultAvailable) {
69
74
  throw new Error(allowSimulated
@@ -108,4 +113,4 @@ function isContentChangeEvent(nativeEvent) {
108
113
  }
109
114
  const SeedVault = SolanaMobileSeedVaultLib;
110
115
 
111
- export { SeedPurpose, SeedVault, SeedVaultEventType, SeedVaultPermissionAndroid, useSeedVault };
116
+ export { SeedPurpose, SeedVault, SeedVaultEventType, SeedVaultPermissionAndroid, SeedVaultPrivilegedPermissionAndroid, useSeedVault };
@@ -1,5 +1,5 @@
1
1
  import { useRef, useEffect } from 'react';
2
- import { Platform, NativeModules, PermissionsAndroid, NativeEventEmitter } from 'react-native';
2
+ import { Platform, NativeModules, NativeEventEmitter, PermissionsAndroid } from 'react-native';
3
3
 
4
4
  // EVENTS
5
5
  // Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
@@ -9,7 +9,8 @@ const SeedVaultEventType = {
9
9
  ImportExistingSeed: "ExistingSeedImported",
10
10
  PayloadsSigned: "PayloadsSigned",
11
11
  GetPublicKeys: "PublicKeysEvent",
12
- ContentChange: "SeedVaultContentChange"
12
+ ContentChange: "SeedVaultContentChange",
13
+ SeedSettingsShown: "SeedSettingsShown"
13
14
  };
14
15
 
15
16
  const SeedPurpose = {
@@ -30,6 +31,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
30
31
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
31
32
  PERFORMANCE OF THIS SOFTWARE.
32
33
  ***************************************************************************** */
34
+ /* global Reflect, Promise */
35
+
33
36
 
34
37
  function __awaiter(thisArg, _arguments, P, generator) {
35
38
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -57,13 +60,15 @@ const SolanaMobileSeedVaultLib = Platform.OS === 'android' && NativeModules.Sola
57
60
  },
58
61
  });
59
62
  const SeedVaultPermissionAndroid = 'com.solanamobile.seedvault.ACCESS_SEED_VAULT';
60
- const checkSeedVaultPermission = () => __awaiter(void 0, void 0, void 0, function* () {
61
- const granted = yield PermissionsAndroid.check(SeedVaultPermissionAndroid);
63
+ const SeedVaultPrivilegedPermissionAndroid = 'com.solanamobile.seedvault.ACCESS_SEED_VAULT_PRIVILEGED';
64
+ const checkSeedVaultPermission = () => __awaiter(undefined, undefined, undefined, function* () {
65
+ const granted = (yield PermissionsAndroid.check(SeedVaultPermissionAndroid))
66
+ || (yield PermissionsAndroid.check(SeedVaultPrivilegedPermissionAndroid));
62
67
  if (!granted) {
63
68
  throw new Error('You do not have permission to access Seed Vault. You must request permission to use Seed Vault.');
64
69
  }
65
70
  });
66
- const checkIsSeedVaultAvailable = (allowSimulated = false) => __awaiter(void 0, void 0, void 0, function* () {
71
+ const checkIsSeedVaultAvailable = (...args_1) => __awaiter(undefined, [...args_1], undefined, function* (allowSimulated = false) {
67
72
  const seedVaultAvailable = yield SolanaMobileSeedVaultLib.isSeedVaultAvailable(allowSimulated);
68
73
  if (!seedVaultAvailable) {
69
74
  throw new Error(allowSimulated
@@ -108,4 +113,4 @@ function isContentChangeEvent(nativeEvent) {
108
113
  }
109
114
  const SeedVault = SolanaMobileSeedVaultLib;
110
115
 
111
- export { SeedPurpose, SeedVault, SeedVaultEventType, SeedVaultPermissionAndroid, useSeedVault };
116
+ export { SeedPurpose, SeedVault, SeedVaultEventType, SeedVaultPermissionAndroid, SeedVaultPrivilegedPermissionAndroid, useSeedVault };
@@ -14,6 +14,7 @@ declare const SeedVaultEventType: {
14
14
  readonly PayloadsSigned: "PayloadsSigned";
15
15
  readonly GetPublicKeys: "PublicKeysEvent";
16
16
  readonly ContentChange: "SeedVaultContentChange";
17
+ readonly SeedSettingsShown: "SeedSettingsShown";
17
18
  };
18
19
  type SeedVaultEventType = (typeof SeedVaultEventType)[keyof typeof SeedVaultEventType];
19
20
  interface ISeedVaultEvent {
@@ -69,7 +70,12 @@ type SeedVaultContentChangeNotification = Readonly<{
69
70
  uris: string[];
70
71
  }> & ISeedVaultEvent;
71
72
  type SeedVaultContentChange = SeedVaultContentChangeNotification;
72
- type SeedVaultEvent = AuthorizeSeedAccessEvent | CreateNewSeedEvent | ImportExistingSeedEvent | SignPayloadsEvent | PublicKeyEvent;
73
+ // Show Seed Settings
74
+ type SeedSettingsShownNotification = Readonly<{
75
+ __type: typeof SeedVaultEventType.SeedSettingsShown;
76
+ }> & ISeedVaultEvent;
77
+ type SeedSettingsShown = SeedSettingsShownNotification;
78
+ type SeedVaultEvent = AuthorizeSeedAccessEvent | CreateNewSeedEvent | ImportExistingSeedEvent | SignPayloadsEvent | PublicKeyEvent | SeedSettingsShown;
73
79
  type AuthToken = number;
74
80
  type Base64EncodedAddress = string;
75
81
  type Base64EncodedSignature = string;
@@ -107,6 +113,7 @@ type SigningResult = Readonly<{
107
113
  }>;
108
114
  interface AuthorizeSeedAPI {
109
115
  hasUnauthorizedSeeds(): boolean;
116
+ hasUnauthorizedSeedsForPurpose(purpose: SeedPurpose): boolean;
110
117
  getAuthorizedSeeds(): Seed[];
111
118
  authorizeNewSeed(): {
112
119
  authToken: AuthToken;
@@ -114,14 +121,22 @@ interface AuthorizeSeedAPI {
114
121
  deauthorizeSeed(authToken: AuthToken): void;
115
122
  }
116
123
  interface AccountAPI {
117
- getAccounts(authToken: AuthToken): Account[];
124
+ getAccounts(authToken: AuthToken, filterOnColumn: string, value: any): Account[];
125
+ getUserWallets(authToken: AuthToken): Account[];
118
126
  updateAccountName(authToken: AuthToken, accountId: number, name?: string): void;
127
+ updateAccountIsUserWallet(authToken: AuthToken, accountId: number, isUserWallet: boolean): void;
128
+ updateAccountIsValid(authToken: AuthToken, accountId: number, isValid: boolean): void;
119
129
  }
120
130
  interface CreateNewSeedAPI {
121
131
  createNewSeed(): {
122
132
  authToken: AuthToken;
123
133
  };
124
134
  }
135
+ // TODO
136
+ // interface ImplementationLimitsAPI {
137
+ // getImplementationLimits(): void
138
+ // getImplementationLimitsForPurpose()
139
+ // }
125
140
  interface ImportExistingSeedAPI {
126
141
  importExistingSeed(): {
127
142
  authToken: AuthToken;
@@ -130,6 +145,8 @@ interface ImportExistingSeedAPI {
130
145
  interface PublicKeyAPI {
131
146
  getPublicKey(authToken: AuthToken, derivationPath: DerivationPath): SeedPublicKey;
132
147
  getPublicKeys(authToken: AuthToken, derivationPaths: DerivationPath[]): SeedPublicKey[];
148
+ resolveDerivationPath(derivationPath: DerivationPath): DerivationPath;
149
+ resolveDerivationPathForPurpose(derivationPath: DerivationPath, purpose: SeedPurpose): DerivationPath;
133
150
  }
134
151
  interface SignMessagesAPI {
135
152
  signMessage(authToken: AuthToken, derivationPath: DerivationPath, message: Base64EncodedMessage): SigningResult;
@@ -142,10 +159,14 @@ interface SignTransactionsAPI {
142
159
  interface SeedVaultAvailabilityAPI {
143
160
  isSeedVaultAvailable(allowSimulated: boolean): boolean;
144
161
  }
145
- interface SeedVaultAPI extends AuthorizeSeedAPI, AccountAPI, CreateNewSeedAPI, ImportExistingSeedAPI, PublicKeyAPI, SeedVaultAvailabilityAPI, SignMessagesAPI, SignTransactionsAPI {
162
+ interface ShowSeedSettingsAPI {
163
+ showSeedSettings(authToken: AuthToken): void;
164
+ }
165
+ interface SeedVaultAPI extends AuthorizeSeedAPI, AccountAPI, CreateNewSeedAPI, ImportExistingSeedAPI, PublicKeyAPI, SeedVaultAvailabilityAPI, SignMessagesAPI, SignTransactionsAPI, ShowSeedSettingsAPI {
146
166
  }
147
167
  declare const SeedVaultPermissionAndroid: Permission;
168
+ declare const SeedVaultPrivilegedPermissionAndroid: Permission;
148
169
  declare function useSeedVault(handleSeedVaultEvent: (event: SeedVaultEvent) => void, handleContentChange: (event: SeedVaultContentChange) => void): void;
149
170
  declare const SeedVault: SeedVaultAPI;
150
- export { SeedVaultError, ActionFailedError, NotModifiedError, SeedVaultEventType, ISeedVaultEvent, SeedAccessAuthorizedEvent, AuthorizeSeedAccessEvent, NewSeedCreatedEvent, CreateNewSeedEvent, ExistingSeedImportedEvent, ImportExistingSeedEvent, SeedEvent, SigningResponse, PayloadsSignedEvent, SignPayloadsEvent, PublicKeyResponse, GotPublicKeyEvent, PublicKeyEvent, SeedVaultContentChangeNotification, SeedVaultContentChange, SeedVaultEvent, Account, SeedPurpose, Seed, SeedPublicKey, SigningRequest, SigningResult, SeedVaultAPI, SeedVaultPermissionAndroid, useSeedVault, SeedVault };
171
+ export { SeedVaultError, ActionFailedError, NotModifiedError, SeedVaultEventType, ISeedVaultEvent, SeedAccessAuthorizedEvent, AuthorizeSeedAccessEvent, NewSeedCreatedEvent, CreateNewSeedEvent, ExistingSeedImportedEvent, ImportExistingSeedEvent, SeedEvent, SigningResponse, PayloadsSignedEvent, SignPayloadsEvent, PublicKeyResponse, GotPublicKeyEvent, PublicKeyEvent, SeedVaultContentChangeNotification, SeedVaultContentChange, SeedSettingsShownNotification, SeedSettingsShown, SeedVaultEvent, Account, SeedPurpose, Seed, SeedPublicKey, SigningRequest, SigningResult, SeedVaultAPI, SeedVaultPermissionAndroid, SeedVaultPrivilegedPermissionAndroid, useSeedVault, SeedVault };
151
172
  //# sourceMappingURL=index.d.ts.map
@@ -14,6 +14,7 @@ declare const SeedVaultEventType: {
14
14
  readonly PayloadsSigned: "PayloadsSigned";
15
15
  readonly GetPublicKeys: "PublicKeysEvent";
16
16
  readonly ContentChange: "SeedVaultContentChange";
17
+ readonly SeedSettingsShown: "SeedSettingsShown";
17
18
  };
18
19
  type SeedVaultEventType = (typeof SeedVaultEventType)[keyof typeof SeedVaultEventType];
19
20
  interface ISeedVaultEvent {
@@ -69,7 +70,12 @@ type SeedVaultContentChangeNotification = Readonly<{
69
70
  uris: string[];
70
71
  }> & ISeedVaultEvent;
71
72
  type SeedVaultContentChange = SeedVaultContentChangeNotification;
72
- type SeedVaultEvent = AuthorizeSeedAccessEvent | CreateNewSeedEvent | ImportExistingSeedEvent | SignPayloadsEvent | PublicKeyEvent;
73
+ // Show Seed Settings
74
+ type SeedSettingsShownNotification = Readonly<{
75
+ __type: typeof SeedVaultEventType.SeedSettingsShown;
76
+ }> & ISeedVaultEvent;
77
+ type SeedSettingsShown = SeedSettingsShownNotification;
78
+ type SeedVaultEvent = AuthorizeSeedAccessEvent | CreateNewSeedEvent | ImportExistingSeedEvent | SignPayloadsEvent | PublicKeyEvent | SeedSettingsShown;
73
79
  type AuthToken = number;
74
80
  type Base64EncodedAddress = string;
75
81
  type Base64EncodedSignature = string;
@@ -107,6 +113,7 @@ type SigningResult = Readonly<{
107
113
  }>;
108
114
  interface AuthorizeSeedAPI {
109
115
  hasUnauthorizedSeeds(): boolean;
116
+ hasUnauthorizedSeedsForPurpose(purpose: SeedPurpose): boolean;
110
117
  getAuthorizedSeeds(): Seed[];
111
118
  authorizeNewSeed(): {
112
119
  authToken: AuthToken;
@@ -114,14 +121,22 @@ interface AuthorizeSeedAPI {
114
121
  deauthorizeSeed(authToken: AuthToken): void;
115
122
  }
116
123
  interface AccountAPI {
117
- getAccounts(authToken: AuthToken): Account[];
124
+ getAccounts(authToken: AuthToken, filterOnColumn: string, value: any): Account[];
125
+ getUserWallets(authToken: AuthToken): Account[];
118
126
  updateAccountName(authToken: AuthToken, accountId: number, name?: string): void;
127
+ updateAccountIsUserWallet(authToken: AuthToken, accountId: number, isUserWallet: boolean): void;
128
+ updateAccountIsValid(authToken: AuthToken, accountId: number, isValid: boolean): void;
119
129
  }
120
130
  interface CreateNewSeedAPI {
121
131
  createNewSeed(): {
122
132
  authToken: AuthToken;
123
133
  };
124
134
  }
135
+ // TODO
136
+ // interface ImplementationLimitsAPI {
137
+ // getImplementationLimits(): void
138
+ // getImplementationLimitsForPurpose()
139
+ // }
125
140
  interface ImportExistingSeedAPI {
126
141
  importExistingSeed(): {
127
142
  authToken: AuthToken;
@@ -130,6 +145,8 @@ interface ImportExistingSeedAPI {
130
145
  interface PublicKeyAPI {
131
146
  getPublicKey(authToken: AuthToken, derivationPath: DerivationPath): SeedPublicKey;
132
147
  getPublicKeys(authToken: AuthToken, derivationPaths: DerivationPath[]): SeedPublicKey[];
148
+ resolveDerivationPath(derivationPath: DerivationPath): DerivationPath;
149
+ resolveDerivationPathForPurpose(derivationPath: DerivationPath, purpose: SeedPurpose): DerivationPath;
133
150
  }
134
151
  interface SignMessagesAPI {
135
152
  signMessage(authToken: AuthToken, derivationPath: DerivationPath, message: Base64EncodedMessage): SigningResult;
@@ -142,10 +159,14 @@ interface SignTransactionsAPI {
142
159
  interface SeedVaultAvailabilityAPI {
143
160
  isSeedVaultAvailable(allowSimulated: boolean): boolean;
144
161
  }
145
- interface SeedVaultAPI extends AuthorizeSeedAPI, AccountAPI, CreateNewSeedAPI, ImportExistingSeedAPI, PublicKeyAPI, SeedVaultAvailabilityAPI, SignMessagesAPI, SignTransactionsAPI {
162
+ interface ShowSeedSettingsAPI {
163
+ showSeedSettings(authToken: AuthToken): void;
164
+ }
165
+ interface SeedVaultAPI extends AuthorizeSeedAPI, AccountAPI, CreateNewSeedAPI, ImportExistingSeedAPI, PublicKeyAPI, SeedVaultAvailabilityAPI, SignMessagesAPI, SignTransactionsAPI, ShowSeedSettingsAPI {
146
166
  }
147
167
  declare const SeedVaultPermissionAndroid: Permission;
168
+ declare const SeedVaultPrivilegedPermissionAndroid: Permission;
148
169
  declare function useSeedVault(handleSeedVaultEvent: (event: SeedVaultEvent) => void, handleContentChange: (event: SeedVaultContentChange) => void): void;
149
170
  declare const SeedVault: SeedVaultAPI;
150
- export { SeedVaultError, ActionFailedError, NotModifiedError, SeedVaultEventType, ISeedVaultEvent, SeedAccessAuthorizedEvent, AuthorizeSeedAccessEvent, NewSeedCreatedEvent, CreateNewSeedEvent, ExistingSeedImportedEvent, ImportExistingSeedEvent, SeedEvent, SigningResponse, PayloadsSignedEvent, SignPayloadsEvent, PublicKeyResponse, GotPublicKeyEvent, PublicKeyEvent, SeedVaultContentChangeNotification, SeedVaultContentChange, SeedVaultEvent, Account, SeedPurpose, Seed, SeedPublicKey, SigningRequest, SigningResult, SeedVaultAPI, SeedVaultPermissionAndroid, useSeedVault, SeedVault };
171
+ export { SeedVaultError, ActionFailedError, NotModifiedError, SeedVaultEventType, ISeedVaultEvent, SeedAccessAuthorizedEvent, AuthorizeSeedAccessEvent, NewSeedCreatedEvent, CreateNewSeedEvent, ExistingSeedImportedEvent, ImportExistingSeedEvent, SeedEvent, SigningResponse, PayloadsSignedEvent, SignPayloadsEvent, PublicKeyResponse, GotPublicKeyEvent, PublicKeyEvent, SeedVaultContentChangeNotification, SeedVaultContentChange, SeedSettingsShownNotification, SeedSettingsShown, SeedVaultEvent, Account, SeedPurpose, Seed, SeedPublicKey, SigningRequest, SigningResult, SeedVaultAPI, SeedVaultPermissionAndroid, SeedVaultPrivilegedPermissionAndroid, useSeedVault, SeedVault };
151
172
  //# sourceMappingURL=index.native.d.ts.map
package/package.json CHANGED
@@ -1,44 +1,65 @@
1
- {
2
- "name": "@solana-mobile/seed-vault-lib",
3
- "description": "A React Native wrapper of the Solana Mobile, Seed Vault SDK. Apps can use this to interact with seed vault implementations on Android",
4
- "version": "0.2.1",
5
- "author": "Marco Martinez <marco.martinez@solanamobile.com>",
6
- "repository": "https://github.com/solana-mobile/seed-vault-sdk",
7
- "license": "Apache-2.0",
8
- "type": "module",
9
- "sideEffects": false,
10
- "main": "lib/esm/index",
11
- "react-native": "lib/esm/index",
12
- "module": "lib/esm/index",
13
- "types": "lib/types/index.d.ts",
14
- "exports": {
15
- "./package.json": "./package.json",
16
- ".": {
17
- "import": "./lib/esm/index.native.js"
18
- }
19
- },
20
- "files": [
21
- "android",
22
- "!android/build",
23
- "lib",
24
- "LICENSE"
25
- ],
26
- "publishConfig": {
27
- "access": "public"
28
- },
29
- "scripts": {
30
- "clean": "shx rm -rf lib/*",
31
- "build": "yarn clean && rollup --config ../../rollup.config.ts --configPlugin rollup-plugin-ts",
32
- "build:watch": "yarn clean && rollup --config ../../rollup.config.ts --configPlugin rollup-plugin-ts --watch",
33
- "postbuild": "cross-env echo {\\\"type\\\":\\\"module\\\"} | npx json > lib/esm/package.json"
34
- },
35
- "devDependencies": {
36
- "@solana/web3.js": "^1.58.0",
37
- "@types/react-native": "^0.69.3",
38
- "cross-env": "^7.0.3",
39
- "shx": "^0.3.4"
40
- },
41
- "peerDependencies": {
42
- "react-native": ">0.69"
43
- }
44
- }
1
+ {
2
+ "name": "@solana-mobile/seed-vault-lib",
3
+ "description": "A React Native wrapper of the Solana Mobile, Seed Vault SDK. Apps can use this to interact with seed vault implementations on Android",
4
+ "version": "0.3.3",
5
+ "author": "Marco Martinez <marco.martinez@solanamobile.com>",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/solana-mobile/seed-vault-sdk.git"
9
+ },
10
+ "license": "Apache-2.0",
11
+ "exports": {
12
+ "edge-light": {
13
+ "import": "./lib/esm/index.js",
14
+ "require": "./lib/cjs/index.js"
15
+ },
16
+ "workerd": {
17
+ "import": "./lib/esm/index.js",
18
+ "require": "./lib/cjs/index.js"
19
+ },
20
+ "browser": {
21
+ "import": "./lib/cjs/index.browser.js",
22
+ "require": "./lib/esm/index.browser.js"
23
+ },
24
+ "node": {
25
+ "import": "./lib/esm/index.js",
26
+ "require": "./lib/cjs/index.js"
27
+ },
28
+ "react-native": "./lib/cjs/index.native.js",
29
+ "types": "./lib/types/index.d.ts"
30
+ },
31
+ "browser": {
32
+ "./lib/cjs/index.js": "./lib/cjs/index.browser.js",
33
+ "./lib/esm/index.js": "./lib/esm/index.browser.js"
34
+ },
35
+ "main": "lib/esm/index",
36
+ "module": "lib/esm/index",
37
+ "react-native": "lib/esm/index",
38
+ "types": "lib/types/index.d.ts",
39
+ "type": "module",
40
+ "files": [
41
+ "android",
42
+ "!android/build",
43
+ "lib",
44
+ "LICENSE"
45
+ ],
46
+ "sideEffects": false,
47
+ "publishConfig": {
48
+ "access": "public"
49
+ },
50
+ "scripts": {
51
+ "clean": "shx rm -rf lib/*",
52
+ "build": "yarn clean && rollup --config ../../rollup.config.ts --configPlugin rollup-plugin-ts",
53
+ "build:watch": "yarn clean && rollup --config ../../rollup.config.ts --configPlugin rollup-plugin-ts --watch",
54
+ "postbuild": "cross-env echo {\\\"type\\\":\\\"module\\\"} | npx json > lib/esm/package.json"
55
+ },
56
+ "devDependencies": {
57
+ "@solana/web3.js": "^1.95.4",
58
+ "@types/react-native": "^0.69.3",
59
+ "cross-env": "^7.0.3",
60
+ "shx": "^0.3.4"
61
+ },
62
+ "peerDependencies": {
63
+ "react-native": ">0.69"
64
+ }
65
+ }
package/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- lib/
2
- android/build
@@ -1,14 +0,0 @@
1
- # OSX
2
- #
3
- .DS_Store
4
-
5
- # Android/IJ
6
- #
7
- .classpath
8
- .cxx
9
- .gradle
10
- .idea
11
- .project
12
- .settings
13
- local.properties
14
- android.iml
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './seedVaultEvent.js';
2
- export * from './types.js';
3
- export * from './useSeedVault.js';
@@ -1,101 +0,0 @@
1
-
2
- // ERRORS
3
- export interface SeedVaultError {
4
- message: string;
5
- }
6
-
7
- export type ActionFailedError = SeedVaultError;
8
- export type NotModifiedError = SeedVaultError;
9
-
10
- // EVENTS
11
- // Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
12
- export const SeedVaultEventType = {
13
- AuthorizeSeedAccess: "SeedAuthorized",
14
- CreateNewSeed: "NewSeedCreated",
15
- ImportExistingSeed: "ExistingSeedImported",
16
- PayloadsSigned: "PayloadsSigned",
17
- GetPublicKeys: "PublicKeysEvent",
18
- ContentChange: "SeedVaultContentChange"
19
- } as const;
20
- export type SeedVaultEventType = typeof SeedVaultEventType[keyof typeof SeedVaultEventType]
21
-
22
- export interface ISeedVaultEvent {
23
- __type: SeedVaultEventType;
24
- }
25
-
26
- // Authorize Seed Access
27
- export type SeedAccessAuthorizedEvent = Readonly<{
28
- __type: typeof SeedVaultEventType.AuthorizeSeedAccess;
29
- authToken: string
30
- }> &
31
- ISeedVaultEvent;
32
-
33
- export type AuthorizeSeedAccessEvent = SeedAccessAuthorizedEvent | ActionFailedError
34
-
35
- // Create New Seed
36
- export type NewSeedCreatedEvent = Readonly<{
37
- __type: typeof SeedVaultEventType.CreateNewSeed;
38
- authToken: string
39
- }> &
40
- ISeedVaultEvent;
41
-
42
- export type CreateNewSeedEvent = NewSeedCreatedEvent | ActionFailedError
43
-
44
- // Import Existing Seed
45
- export type ExistingSeedImportedEvent = Readonly<{
46
- __type: typeof SeedVaultEventType.ImportExistingSeed;
47
- authToken: string
48
- }> &
49
- ISeedVaultEvent;
50
-
51
- export type ImportExistingSeedEvent = ExistingSeedImportedEvent | ActionFailedError
52
-
53
- export type SeedEvent =
54
- | AuthorizeSeedAccessEvent
55
- | CreateNewSeedEvent
56
- | ImportExistingSeedEvent
57
-
58
- // Sign Payloads
59
- export type SigningResponse = Readonly<{
60
- signatures: [[]],
61
- resolvedDerivationPaths: string[]
62
- }>
63
-
64
- export type PayloadsSignedEvent = Readonly<{
65
- __type: typeof SeedVaultEventType.PayloadsSigned;
66
- result: SigningResponse[]
67
- }> &
68
- ISeedVaultEvent;
69
-
70
- export type SignPayloadsEvent = PayloadsSignedEvent | ActionFailedError
71
-
72
- // Get Public Keys
73
- export type PublicKeyResponse = Readonly<{
74
- publicKey: [],
75
- publicKeyEncoded: string,
76
- resolvedDerivationPath: string
77
- }>
78
-
79
- export type GotPublicKeyEvent = Readonly<{
80
- __type: typeof SeedVaultEventType.GetPublicKeys;
81
- result: PublicKeyResponse[]
82
- }> &
83
- ISeedVaultEvent;
84
-
85
- export type PublicKeyEvent = GotPublicKeyEvent | ActionFailedError
86
-
87
- // Content Change
88
- export type SeedVaultContentChangeNotification = Readonly<{
89
- __type: typeof SeedVaultEventType.ContentChange;
90
- uris: string[]
91
- }> &
92
- ISeedVaultEvent;
93
-
94
- export type SeedVaultContentChange = SeedVaultContentChangeNotification
95
-
96
- export type SeedVaultEvent =
97
- | AuthorizeSeedAccessEvent
98
- | CreateNewSeedEvent
99
- | ImportExistingSeedEvent
100
- | SignPayloadsEvent
101
- | PublicKeyEvent
package/src/types.ts DELETED
@@ -1,96 +0,0 @@
1
- type AuthToken = number;
2
-
3
- type Base64EncodedAddress = string;
4
-
5
- type Base64EncodedSignature = string;
6
-
7
- type Base64EncodedPayload = string;
8
-
9
- type Base64EncodedMessage = Base64EncodedPayload;
10
-
11
- type Base64EncodedTransaction = Base64EncodedPayload;
12
-
13
- type DerivationPath = string;
14
-
15
- export type Account = Readonly<{
16
- id: number,
17
- name: string,
18
- derivationPath: DerivationPath,
19
- publicKeyEncoded: Base64EncodedAddress
20
- }>;
21
-
22
- export const SeedPurpose = {
23
- SignSolanaTransaction: 0,
24
- } as const
25
- export type SeedPurpose = typeof SeedPurpose[keyof typeof SeedPurpose]
26
-
27
- export type Seed = Readonly<{
28
- authToken: AuthToken,
29
- name: string,
30
- purpose: SeedPurpose
31
- }>;
32
-
33
- export type SeedPublicKey = Readonly<{
34
- publicKey: Uint8Array,
35
- publicKeyEncoded: Base64EncodedAddress,
36
- resolvedDerivationPath: DerivationPath
37
- }>
38
-
39
- export type SigningRequest = Readonly<{
40
- payload: Base64EncodedPayload,
41
- requestedSignatures: DerivationPath[]
42
- }>;
43
-
44
- export type SigningResult = Readonly<{
45
- signatures: Base64EncodedSignature[],
46
- resolvedDerivationPaths: DerivationPath[]
47
- }>;
48
-
49
- interface AuthorizeSeedAPI {
50
- hasUnauthorizedSeeds(): boolean
51
- getAuthorizedSeeds(): Seed[]
52
- authorizeNewSeed(): {authToken: AuthToken}
53
- deauthorizeSeed(authToken: AuthToken): void
54
- }
55
-
56
- interface AccountAPI {
57
- getAccounts(authToken: AuthToken): Account[]
58
- updateAccountName(authToken: AuthToken, accountId: number, name?: string): void
59
- }
60
-
61
- interface CreateNewSeedAPI {
62
- createNewSeed(): {authToken: AuthToken}
63
- }
64
-
65
- interface ImportExistingSeedAPI {
66
- importExistingSeed(): {authToken: AuthToken}
67
- }
68
-
69
- interface PublicKeyAPI {
70
- getPublicKey(authToken: AuthToken, derivationPath: DerivationPath): SeedPublicKey
71
- getPublicKeys(authToken: AuthToken, derivationPaths: DerivationPath[]): SeedPublicKey[]
72
- }
73
-
74
- interface SignMessagesAPI {
75
- signMessage(authToken: AuthToken, derivationPath: DerivationPath, message: Base64EncodedMessage): SigningResult
76
- signMessages(authToken: AuthToken, signingRequests: SigningRequest[]): SigningResult[]
77
- }
78
-
79
- interface SignTransactionsAPI {
80
- signTransaction(authToken: AuthToken, derivationPath: DerivationPath, transaction: Base64EncodedTransaction): SigningResult
81
- signTransactions(authToken: AuthToken, signingRequests: SigningRequest[]): SigningResult[]
82
- }
83
-
84
- interface SeedVaultAvailabilityAPI {
85
- isSeedVaultAvailable(allowSimulated: boolean): boolean
86
- }
87
-
88
- export interface SeedVaultAPI
89
- extends AuthorizeSeedAPI,
90
- AccountAPI,
91
- CreateNewSeedAPI,
92
- ImportExistingSeedAPI,
93
- PublicKeyAPI,
94
- SeedVaultAvailabilityAPI,
95
- SignMessagesAPI,
96
- SignTransactionsAPI {}