TinyShip
TinyShip
 TinyShip
TinyShip
TinyShip Documentation
TinyShip User GuideGetting StartedBasic Configuration
Authentication ConfigurationEmail Password AuthenticationGoogle OAuth ConfigurationGitHub OAuth ConfigurationWeChat Login ConfigurationSMS Verification Login
Credits System ConfigurationAffiliate System Configuration
Storage Service ConfigurationDatabase ConfigurationCaptcha Configuration
Development Best PracticesLocal E2E Workflow
User GuideAuthentication

SMS Verification Login

Configure phone SMS verification login

SMS login sends a one-time code to a phone number. For gettinyship.dev, start with Twilio. Aliyun SMS is a China-only option.

config/sms.ts implements two providers: twilio and aliyun. The checked-in defaultProvider is 'aliyun'. Set it to 'twilio' for an English deployment.

Providers in this repo

ProviderWhere it fits
TwilioGlobal numbers. Lead with this on gettinyship.dev.
Aliyun SMSChina only. Enterprise account plus signature filing (签名报备). Personal accounts cannot complete filing.

The Chinese guide also mentions Tencent Cloud SMS. Those env names are not read by config/sms.ts, so this page does not document them.

Twilio

  1. Create a Twilio account and a sending number.
  2. Add the credentials to .env:
TWILIO_ACCOUNT_SID="your_twilio_account_sid"
TWILIO_AUTH_TOKEN="your_twilio_auth_token"
TWILIO_DEFAULT_FROM="+1234567890"
  1. Point the config at Twilio:
// config/sms.ts
export const smsConfig = {
  defaultProvider: 'twilio',
}

Aliyun SMS (China only)

Aliyun SMS requires an enterprise account. China now requires SMS signature filing (签名报备). Individuals cannot pass that filing, so this provider is not a personal-developer option.

ALIYUN_ACCESS_KEY_ID="your_aliyun_key_id"
ALIYUN_ACCESS_KEY_SECRET="your_aliyun_key_secret"
ALIYUN_SMS_SIGN_NAME="your-sms-sign-name"
ALIYUN_SMS_TEMPLATE_CODE="SMS_000000000"

ALIYUN_SMS_ENDPOINT defaults to dysmsapi.aliyuncs.com when unset.

To use Aliyun, set defaultProvider: 'aliyun' in config/sms.ts (that is the current file default).

Development

In development, the auth flow stores the OTP on the request context and logs it. Prefer that over sending real SMS while you iterate:

if (process.env.NODE_ENV === 'development') {
  (request as any).context = (request as any).context || {};
  (request as any).context.otpCode = code;
  console.log('[DEVELOPMENT MODE] OTP code stored in context:', code);
}

You can read otpCode from the network response in development. Comment out the live send after you have confirmed a provider once, so test signups do not keep billing you.

More provider detail is in libs/sms/README.md.

WeChat Login Configuration

Configure WeChat account login (China only)

Payment configuration

TinyShip payment system configuration guide

On this page

Providers in this repoTwilioAliyun SMS (China only)Development