
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
fms-api-client
Advanced tools
A FileMaker Data API client designed to allow easier interaction with a FileMaker application from a web environment.
A FileMaker Data API client designed to allow easier interaction with a FileMaker application from a web environment.
For in depth documentation head to the docs
Like what I have done? buy me a beer @ beerpay
This is a Node.js module available through the
npm registry. It can be installed using the
npm
or
yarn
command line tools.
npm install fms-api-client --save
'use strict';
/* eslint-disable */
const colors = require('colors');
/* eslint-enable */
const environment = require('dotenv');
const varium = require('varium');
const { connect } = require('marpat');
const { Filemaker } = require('./index.js');
environment.config({ path: './tests/.env' });
varium(process.env, './tests/env.manifest');
/**
* Connect must be called before the filemaker class is instiantiated. This
* connect uses Marpat. Marpat is a fork of Camo. much love to
* https://github.com/scottwrobinson for his creation and maintenance of Camo.
* My fork of Camo - Marpat is designed to allow the use of multiple datastores
* with the focus on encrypted storage.
*/
connect('nedb://memory').then(db => {
/**
* The client is the FileMaker class. The class then offers methods designed to
* make it easier to integrate into filemaker's api.
*/
const client = Filemaker.create({
application: process.env.APPLICATION,
server: process.env.SERVER,
user: process.env.USERNAME,
password: process.env.PASSWORD
});
/**
* A client can be used directly after saving it. It is also stored on the
* datastore so that it can be reused later.
*/
client.save().then(client =>
/**
* Using the client you can create filemaker records. To create a record
* specify the layout to use and the data to insert on creation. The client
* will automatically convert numbers, arrays, and objects into strings so
* they can be inserted into a filemaker field.
*/
client
.create('Heroes', {
name: 'George Lucas',
number: 5,
array: ['1'],
object: { driods: true }
})
.then(record =>
console.log('Some guy thought of a movie....'.yellow.underline, record)
)
.catch(error => console.log('That is no moon....'.red, error))
);
/**
* Most methods on the client are promises. The only exceptions to this are
* the utility methods of fieldData(), and recordId(). You can chain together
* multiple methods such as record creation.
*/
client
.save()
.then(client => {
return Promise.all([
client.create('Heroes', { name: 'Anakin Skywalker' }),
client.create('Heroes', { name: 'Obi-Wan' }),
client.create('Heroes', { name: 'Yoda' })
]).then(response => {
console.log('A Long Time Ago....'.rainbow.underline, response);
return client;
});
})
.then(client => {
/**
* You can use the client to list filemaker records. The List method
* accepts a layout and parameter variable. The client will automatically
* santize the limit, offset, and sort keys to correspond with the Data
* API's requirements.
*/
client
.list('Heroes', { limit: 5 })
.then(response => client.fieldData(response.data))
.then(response =>
console.log(
' For my ally is the Force, and a powerful ally it is.'.underline
.green,
response
)
)
.catch(error => console.log('That is no moon....'.red, error));
/**
* You can also use the client to set FileMaker Globals for the session.
*/
client
.globals({ 'Globals::ship': 'Millenium Falcon' })
.then(response =>
console.log(
'Made the Kessel Run in less than twelve parsecs.'.underline.blue,
response
)
)
.catch(error => console.log('That is no moon....'.red, error));
return client;
})
.then(client => {
/**
* The client's find method will accept either a single object as find
* parameters or an array. The find method will also santize the limit,
* sort, and offset parameters to conform with the Data API's
* requirements.
*/
client
.find('Heroes', [{ name: 'Anakin Skywalker' }], { limit: 1 })
.then(response => client.recordId(response.data))
.then(recordIds =>
client.edit('Heroes', recordIds[0], { name: 'Darth Vader' })
)
.then(response =>
console.log(
'I find your lack of faith disturbing'.cyan.underline,
response
)
)
.catch(error => console.log('That is no moon...'.red, error));
client
.upload('./assets/placeholder.md', 'Heroes', 'image')
.then(response => {
console.log('Perhaps an Image...'.cyan.underline, response);
})
.catch(error => console.log('That is no moon...'.red, error));
client
.find('Heroes', [{ name: 'Luke Skywalker' }], { limit: 1 })
.then(response => client.recordId(response.data))
.then(recordIds =>
client.upload(
'./assets/placeholder.md',
'Heroes',
'image',
recordIds[0]
)
)
.then(response => {
console.log('Dont Forget Luke...'.cyan.underline, response);
})
.catch(error => console.log('That is no moon...'.red, error));
client
.script('FMS Triggered Script', 'Heroes')
.then(response => {
console.log('or a script....'.cyan.underline, response);
})
.catch(error => console.log('That is no moon...'.red, error));
})
.catch(error => console.log('That is no moon...'.red, error));
client
.find('Heroes', [{ name: 'Darth Vader' }], {
limit: 1,
script: 'example script',
'script.param': 'han'
})
.then(response =>
console.log(
'I find your lack of faith disturbing'.cyan.underline,
response
)
)
.catch(error => console.log('find - That is no moon...'.red, error));
});
const rewind = () => {
Filemaker.findOne().then(client => {
console.log(client.data.status());
client
.find('Heroes', [{ id: '*' }], { limit: 10 })
.then(response => client.recordId(response.data))
.then(response => {
console.log('Be Kind.... Rewind.....'.rainbow, response);
return response;
})
.then(recordIds =>
recordIds.forEach(id => {
client
.delete('Heroes', id)
.catch(error => console.log('That is no moon....'.red, error));
})
);
});
};
setTimeout(() => rewind(), 10000);
npm install
npm test
> fms-api-client@1.0.2 test /Users/luidelaparra/Documents/Development/fms-api-client
> nyc _mocha --recursive ./tests --timeout=30000
Authentication Capabilities
✓ should authenticate into FileMaker. (144ms)
✓ should automatically request an authentication token (166ms)
✓ should reuse a saved authentication token (208ms)
✓ should log out of the filemaker. (157ms)
✓ should not attempt a logout if there is no valid token.
✓ reject if the authentication request fails (1576ms)
Create Capabilities
✓ should create FileMaker records. (174ms)
✓ should reject bad data with an error (484ms)
✓ should create FileMaker records with mixed types (198ms)
Delete Capabilities
✓ should delete FileMaker records. (240ms)
✓ should reject deletions that do not specify a recordId (208ms)
Edit Capabilities
✓ should edit FileMaker records.
✓ should reject bad data with an error (358ms)
Find Capabilities
✓ should perform a find request (229ms)
✓ should allow you to use an object instead of an array for a find (234ms)
✓ should specify omit Criterea (222ms)
✓ should allow additional parameters to manipulate the results (273ms)
✓ should allow you to use numbers in the find query parameters (214ms)
✓ should allow you to sort the results (206ms)
✓ should return an empty array if the find does not return results (196ms)
✓ should allow you run a pre request script (290ms)
✓ should return a response even if a script fails (162ms)
✓ should allow you to send a parameter to the pre request script (229ms)
✓ should allow you run script after the find and before the sort (205ms)
✓ should allow you to pass a parameter to a script after the find and before the sort (209ms)
Get Capabilities
✓ should get specific FileMaker records. (252ms)
✓ should reject get requests that do not specify a recordId (237ms)
Global Capabilities
✓ should allow you to set FileMaker globals (219ms)
✓ should reject with a message and code if it fails to set a global (240ms)
List Capabilities
✓ should allow you to list records (217ms)
✓ should allow you use parameters to modify the list response (3226ms)
✓ should should allow you to use numbers in parameters (530ms)
✓ should modify requests to comply with DAPI name reservations (161ms)
✓ should allow strings while complying with DAPI name reservations (229ms)
✓ should allow you to offset the list response (288ms)
✓ should reject requests that use unexpected parameters (148ms)
Script Capabilities
✓ should allow you to trigger a script in FileMaker (166ms)
✓ should allow you to trigger a script in FileMaker (222ms)
✓ should allow you to trigger a script in a find (202ms)
✓ should allow you to trigger a script in a list (171ms)
✓ should allow reject a script that does not exist (193ms)
✓ should allow return a result even if a script returns an error (210ms)
Storage
✓ should allow an instance to be created
✓ should allow an instance to be saved.
✓ should allow an instance to be recalled
✓ should allow insances to be listed
✓ should allow you to remove an instance
File Upload Capabilities
✓ should allow you to upload a file to a new record (1625ms)
✓ should reject with a message if it can not find the file to upload (164ms)
✓ should allow you to upload a file to a specific record (1460ms)
Data Usage Tracking Capabilities
✓ should track API usage data. (268ms)
✓ should allow you to reset usage data. (160ms)
Utility Capabilities
✓ should extract field while maintaining the array (286ms)
✓ should extract field data while maintaining the object (269ms)
✓ should extract the recordId while maintaining the array (288ms)
✓ should extract field data while maintaining the object (346ms)
56 passing (18s)
-----------------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
-----------------------|----------|----------|----------|----------|-------------------|
All files | 98.61 | 76.92 | 98.04 | 98.61 | |
fms-api-client | 100 | 100 | 100 | 100 | |
index.js | 100 | 100 | 100 | 100 | |
fms-api-client/src | 98.6 | 76.92 | 98.04 | 98.6 | |
client.model.js | 98.16 | 76 | 97.73 | 98.16 | 265,684,686 |
connection.model.js | 100 | 100 | 100 | 100 | |
credentials.model.js | 100 | 100 | 100 | 100 | |
data.model.js | 100 | 100 | 100 | 100 | |
index.js | 100 | 100 | 100 | 100 | |
-----------------------|----------|----------|----------|----------|-------------------|
MIT
FAQs
A FileMaker Data API client designed to allow easier interaction with a FileMaker database from a web environment.
The npm package fms-api-client receives a total of 34 weekly downloads. As such, fms-api-client popularity was classified as not popular.
We found that fms-api-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.