Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
259dafe
commit 49c5ee2
Showing
2 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
definitions/npm/expo-secure-store_v4.x.x/flow_v0.69.0-/expo-secure-store_v4.x.x.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
declare module 'expo-secure-store' { | ||
// Types | ||
// `KA$` is Keychain Accessible namespace | ||
declare export opaque type KA$AFTER_FIRST_UNLOCK: number; | ||
declare export opaque type KA$AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY: number; | ||
declare export opaque type KA$ALWAYS: number; | ||
declare export opaque type KA$WHEN_PASSCODE_SET_THIS_DEVICE_ONLY: number; | ||
declare export opaque type KA$ALWAYS_THIS_DEVICE_ONLY: number; | ||
declare export opaque type KA$WHEN_UNLOCKED: number; | ||
declare export opaque type KA$WHEN_UNLOCKED_THIS_DEVICE_ONLY: number; | ||
declare export type CommonSecureStoreOptions = {| | ||
keychainService?: string, | ||
|}; | ||
declare export type SecureStoreOptions = {| | ||
...CommonSecureStoreOptions, | ||
keychainAccessible?: | ||
| KA$AFTER_FIRST_UNLOCK | ||
| KA$AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY | ||
| KA$ALWAYS | ||
| KA$WHEN_PASSCODE_SET_THIS_DEVICE_ONLY | ||
| KA$ALWAYS_THIS_DEVICE_ONLY | ||
| KA$WHEN_UNLOCKED | ||
| KA$WHEN_UNLOCKED_THIS_DEVICE_ONLY, | ||
|}; | ||
|
||
// Variables | ||
declare export var AFTER_FIRST_UNLOCK: KA$AFTER_FIRST_UNLOCK; | ||
declare export var AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY: KA$AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY; | ||
declare export var ALWAYS: KA$ALWAYS; | ||
declare export var WHEN_PASSCODE_SET_THIS_DEVICE_ONLY: KA$WHEN_PASSCODE_SET_THIS_DEVICE_ONLY; | ||
declare export var ALWAYS_THIS_DEVICE_ONLY: KA$ALWAYS_THIS_DEVICE_ONLY; | ||
declare export var WHEN_UNLOCKED: KA$WHEN_UNLOCKED; | ||
declare export var WHEN_UNLOCKED_THIS_DEVICE_ONLY: KA$WHEN_UNLOCKED_THIS_DEVICE_ONLY; | ||
|
||
declare export function deleteItemAsync( | ||
key: string, | ||
options?: CommonSecureStoreOptions | ||
): Promise<void>; | ||
|
||
declare export function getItemAsync( | ||
key: string, | ||
options?: CommonSecureStoreOptions | ||
): Promise<string | null>; | ||
|
||
declare export function setItemAsync( | ||
key: string, | ||
value: string, | ||
options?: SecureStoreOptions | ||
): Promise<void>; | ||
} |
98 changes: 98 additions & 0 deletions
98
definitions/npm/expo-secure-store_v4.x.x/flow_v0.69.0-/test_expo-secure-store.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// @flow | ||
import { it, describe } from 'flow-typed-test'; | ||
|
||
import { | ||
AFTER_FIRST_UNLOCK, | ||
AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY, | ||
ALWAYS, | ||
WHEN_PASSCODE_SET_THIS_DEVICE_ONLY, | ||
ALWAYS_THIS_DEVICE_ONLY, | ||
WHEN_UNLOCKED, | ||
WHEN_UNLOCKED_THIS_DEVICE_ONLY, | ||
deleteItemAsync, | ||
getItemAsync, | ||
setItemAsync, | ||
} from 'expo-secure-store'; | ||
|
||
describe('deleteItemAsync', () => { | ||
it('should passes when used properly', () => { | ||
deleteItemAsync('KEY').then(result => { | ||
(result: void); | ||
|
||
// $ExpectError: check any | ||
(result: number); | ||
}); | ||
deleteItemAsync('KEY', {}); | ||
deleteItemAsync('KEY', { keychainService: 'kService' }); | ||
}); | ||
|
||
it('should raises an error when pass invalid arguments', () => { | ||
// $ExpectError: first argument is required | ||
deleteItemAsync(); | ||
// $ExpectError: first argument must be a number | ||
deleteItemAsync(69); | ||
// $ExpectError: second argument must be an object | ||
deleteItemAsync('', 69); | ||
}); | ||
}); | ||
|
||
describe('getItemAsync', () => { | ||
it('should passes when used properly', () => { | ||
getItemAsync('KEY').then(result => { | ||
if (result !== null) { | ||
(result: string); | ||
} else { | ||
(result: null); | ||
} | ||
|
||
// $ExpectError: check any | ||
(result: number); | ||
}); | ||
getItemAsync('KEY', {}); | ||
getItemAsync('KEY', { keychainService: 'kService' }); | ||
}); | ||
|
||
it('should raises an error when pass invalid arguments', () => { | ||
// $ExpectError: first argument is required | ||
getItemAsync(); | ||
// $ExpectError: first argument must be a number | ||
getItemAsync(69); | ||
// $ExpectError: second argument must be an object | ||
getItemAsync('', 69); | ||
}); | ||
}); | ||
|
||
describe('setItemAsync', () => { | ||
it('should passes when used properly', () => { | ||
setItemAsync('KEY', 'VALUE').then(result => { | ||
(result: void); | ||
|
||
// $ExpectError: check any | ||
(result: number); | ||
}); | ||
setItemAsync('KEY', 'VALUE', {}); | ||
setItemAsync('KEY', 'VALUE', { keychainService: 'kService' }); | ||
setItemAsync('KEY', 'VALUE', { | ||
keychainService: 'kService', | ||
keychainAccessible: AFTER_FIRST_UNLOCK, | ||
}); | ||
}); | ||
|
||
it('should raises an error when pass invalid arguments', () => { | ||
// $ExpectError: first argument is required | ||
setItemAsync(); | ||
// $ExpectError: first argument must be a number | ||
setItemAsync(69); | ||
// $ExpectError: second argument is required | ||
setItemAsync('KEY'); | ||
// $ExpectError: second argument is must be a string | ||
setItemAsync('KEY', 69); | ||
// $ExpectError: third argument is must be an object | ||
setItemAsync('KEY', 69); | ||
|
||
setItemAsync('KEY', 'VALUE', { | ||
// $ExpectError: invalid value | ||
keychainAccessible: 1, | ||
}); | ||
}); | ||
}); |